OSDN Git Service

auxdisplay: charlcd: Introduce charlcd_free() helper
[uclinux-h8/linux.git] / drivers / auxdisplay / charlcd.c
index 60e0b77..a351a94 100644 (file)
@@ -91,7 +91,7 @@ struct charlcd_priv {
        unsigned long long drvdata[0];
 };
 
-#define to_priv(p)     container_of(p, struct charlcd_priv, lcd)
+#define charlcd_to_priv(p)     container_of(p, struct charlcd_priv, lcd)
 
 /* Device single-open policy control */
 static atomic_t charlcd_available = ATOMIC_INIT(1);
@@ -105,7 +105,7 @@ static void long_sleep(int ms)
 /* turn the backlight on or off */
 static void charlcd_backlight(struct charlcd *lcd, int on)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        if (!lcd->ops->backlight)
                return;
@@ -134,7 +134,7 @@ static void charlcd_bl_off(struct work_struct *work)
 /* turn the backlight on for a little while */
 void charlcd_poke(struct charlcd *lcd)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        if (!lcd->ops->backlight)
                return;
@@ -152,7 +152,7 @@ EXPORT_SYMBOL_GPL(charlcd_poke);
 
 static void charlcd_gotoxy(struct charlcd *lcd)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
        unsigned int addr;
 
        /*
@@ -170,7 +170,7 @@ static void charlcd_gotoxy(struct charlcd *lcd)
 
 static void charlcd_home(struct charlcd *lcd)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        priv->addr.x = 0;
        priv->addr.y = 0;
@@ -179,7 +179,7 @@ static void charlcd_home(struct charlcd *lcd)
 
 static void charlcd_print(struct charlcd *lcd, char c)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        if (priv->addr.x < lcd->bwidth) {
                if (lcd->char_conv)
@@ -211,7 +211,7 @@ static void charlcd_clear_fast(struct charlcd *lcd)
 /* clears the display and resets X/Y */
 static void charlcd_clear_display(struct charlcd *lcd)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        lcd->ops->write_cmd(lcd, LCD_CMD_DISPLAY_CLEAR);
        priv->addr.x = 0;
@@ -223,7 +223,7 @@ static void charlcd_clear_display(struct charlcd *lcd)
 static int charlcd_init_display(struct charlcd *lcd)
 {
        void (*write_cmd_raw)(struct charlcd *lcd, int cmd);
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
        u8 init;
 
        if (lcd->ifwidth != 4 && lcd->ifwidth != 8)
@@ -369,7 +369,7 @@ static bool parse_xy(const char *s, unsigned long *x, unsigned long *y)
 
 static inline int handle_lcd_special_code(struct charlcd *lcd)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        /* LCD special codes */
 
@@ -580,7 +580,7 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
 
 static void charlcd_write_char(struct charlcd *lcd, char c)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        /* first, we'll test if we're in escape mode */
        if ((c != '\n') && priv->esc_seq.len >= 0) {
@@ -705,7 +705,7 @@ static ssize_t charlcd_write(struct file *file, const char __user *buf,
 
 static int charlcd_open(struct inode *inode, struct file *file)
 {
-       struct charlcd_priv *priv = to_priv(the_charlcd);
+       struct charlcd_priv *priv = charlcd_to_priv(the_charlcd);
        int ret;
 
        ret = -EBUSY;
@@ -766,7 +766,7 @@ static void charlcd_puts(struct charlcd *lcd, const char *s)
 /* initialize the LCD driver */
 static int charlcd_init(struct charlcd *lcd)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
        int ret;
 
        if (lcd->ops->backlight) {
@@ -818,6 +818,12 @@ struct charlcd *charlcd_alloc(unsigned int drvdata_size)
 }
 EXPORT_SYMBOL_GPL(charlcd_alloc);
 
+void charlcd_free(struct charlcd *lcd)
+{
+       kfree(charlcd_to_priv(lcd));
+}
+EXPORT_SYMBOL_GPL(charlcd_free);
+
 static int panel_notify_sys(struct notifier_block *this, unsigned long code,
                            void *unused)
 {
@@ -866,7 +872,7 @@ EXPORT_SYMBOL_GPL(charlcd_register);
 
 int charlcd_unregister(struct charlcd *lcd)
 {
-       struct charlcd_priv *priv = to_priv(lcd);
+       struct charlcd_priv *priv = charlcd_to_priv(lcd);
 
        unregister_reboot_notifier(&panel_notifier);
        charlcd_puts(lcd, "\x0cLCD driver unloaded.\x1b[Lc\x1b[Lb\x1b[L-");