Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 22 Jul 2007 18:19:46 +0000 (11:19 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 22 Jul 2007 18:19:46 +0000 (11:19 -0700)
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight:
  leds: cr_bllcd.c: build fix
  backlight: Convert from struct class_device to struct device
  backlight: Fix order of Kconfig entries

13 files changed:
drivers/acpi/video.c
drivers/usb/misc/appledisplay.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb_base.c
drivers/video/aty/radeon_backlight.c
drivers/video/backlight/Kconfig
drivers/video/backlight/backlight.c
drivers/video/backlight/cr_bllcd.c
drivers/video/backlight/lcd.c
drivers/video/nvidia/nv_backlight.c
drivers/video/riva/fbdev.c
include/linux/backlight.h
include/linux/lcd.h

index 5f014d3764c85b51b3ac3552f0722732254987fe..04ea697f72bff00b94cc2d1151df53d8b5d93e1e 100644 (file)
@@ -284,7 +284,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
 {
        unsigned long cur_level;
        struct acpi_video_device *vd =
-               (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
+               (struct acpi_video_device *)bl_get_data(bd);
        acpi_video_device_lcd_get_level_current(vd, &cur_level);
        return (int) cur_level;
 }
@@ -293,7 +293,7 @@ static int acpi_video_set_brightness(struct backlight_device *bd)
 {
        int request_level = bd->props.brightness;
        struct acpi_video_device *vd =
-               (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
+               (struct acpi_video_device *)bl_get_data(bd);
        acpi_video_device_lcd_set_level(vd, request_level);
        return 0;
 }
index b09c83568c1a8b455520feb3cd58df8250fe3aef..1cb56f2d5c8421df8036cf09bc00d9405fb97c32 100644 (file)
@@ -138,7 +138,7 @@ exit:
 
 static int appledisplay_bl_update_status(struct backlight_device *bd)
 {
-       struct appledisplay *pdata = class_get_devdata(&bd->class_dev);
+       struct appledisplay *pdata = bl_get_data(bd);
        int retval;
 
        pdata->msgdata[0] = 0x10;
@@ -159,7 +159,7 @@ static int appledisplay_bl_update_status(struct backlight_device *bd)
 
 static int appledisplay_bl_get_brightness(struct backlight_device *bd)
 {
-       struct appledisplay *pdata = class_get_devdata(&bd->class_dev);
+       struct appledisplay *pdata = bl_get_data(bd);
        int retval;
 
        retval = usb_control_msg(
index 7fea4d8ae8e2a59719c6db6d918c9f77d79531a8..cfcbe37d2d703478742a95f847c33878721edce4 100644 (file)
@@ -1733,7 +1733,7 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
 
 static int aty128_bl_update_status(struct backlight_device *bd)
 {
-       struct aty128fb_par *par = class_get_devdata(&bd->class_dev);
+       struct aty128fb_par *par = bl_get_data(bd);
        unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL);
        int level;
 
index 13990697b5c12a76e41cd31fdc37873bebcbc2d5..bc6f0096aa04424c333a28d8dc7f89def808c132 100644 (file)
@@ -2141,7 +2141,7 @@ static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
 
 static int aty_bl_update_status(struct backlight_device *bd)
 {
-       struct atyfb_par *par = class_get_devdata(&bd->class_dev);
+       struct atyfb_par *par = bl_get_data(bd);
        unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
        int level;
 
index 0be25fa5540c8a938507bbdb7f3046e40c5973ff..1a056adb61c836784fce99d1c0314e710f4948e8 100644 (file)
@@ -47,7 +47,7 @@ static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata,
 
 static int radeon_bl_update_status(struct backlight_device *bd)
 {
-       struct radeon_bl_privdata *pdata = class_get_devdata(&bd->class_dev);
+       struct radeon_bl_privdata *pdata = bl_get_data(bd);
        struct radeonfb_info *rinfo = pdata->rinfo;
        u32 lvds_gen_cntl, tmpPixclksCntl;
        int level;
@@ -206,7 +206,7 @@ void radeonfb_bl_exit(struct radeonfb_info *rinfo)
        if (bd) {
                struct radeon_bl_privdata *pdata;
 
-               pdata = class_get_devdata(&bd->class_dev);
+               pdata = bl_get_data(bd);
                backlight_device_unregister(bd);
                kfree(pdata);
                rinfo->info->bl_dev = NULL;
index fbef663fc0571988001fa848a11b460020035972..2580f5fa2486e4caefbed82b3bbd357901926151 100644 (file)
@@ -8,26 +8,32 @@ menuconfig BACKLIGHT_LCD_SUPPORT
          Enable this to be able to choose the drivers for controlling the
          backlight and the LCD panel on some platforms, for example on PDAs.
 
-config BACKLIGHT_CLASS_DEVICE
-        tristate "Lowlevel Backlight controls"
+#
+# LCD
+#
+config LCD_CLASS_DEVICE
+        tristate "Lowlevel LCD controls"
        depends on BACKLIGHT_LCD_SUPPORT
        default m
        help
-         This framework adds support for low-level control of the LCD
-          backlight. This includes support for brightness and power.
+         This framework adds support for low-level control of LCD.
+         Some framebuffer devices connect to platform-specific LCD modules
+         in order to have a platform-specific way to control the flat panel
+         (contrast and applying power to the LCD (not to the backlight!)).
 
          To have support for your specific LCD panel you will have to
          select the proper drivers which depend on this option.
 
-config LCD_CLASS_DEVICE
-        tristate "Lowlevel LCD controls"
+#
+# Backlight
+#
+config BACKLIGHT_CLASS_DEVICE
+        tristate "Lowlevel Backlight controls"
        depends on BACKLIGHT_LCD_SUPPORT
        default m
        help
-         This framework adds support for low-level control of LCD.
-         Some framebuffer devices connect to platform-specific LCD modules
-         in order to have a platform-specific way to control the flat panel
-         (contrast and applying power to the LCD (not to the backlight!)).
+         This framework adds support for low-level control of the LCD
+          backlight. This includes support for brightness and power.
 
          To have support for your specific LCD panel you will have to
          select the proper drivers which depend on this option.
index 7e06223bca9494178632f444b989a554f3e5180f..b26de8cf311270ef4eff4a1478f48dbf7120d8b8 100644 (file)
@@ -69,18 +69,20 @@ static inline void backlight_unregister_fb(struct backlight_device *bd)
 }
 #endif /* CONFIG_FB */
 
-static ssize_t backlight_show_power(struct class_device *cdev, char *buf)
+static ssize_t backlight_show_power(struct device *dev,
+               struct device_attribute *attr,char *buf)
 {
-       struct backlight_device *bd = to_backlight_device(cdev);
+       struct backlight_device *bd = to_backlight_device(dev);
 
        return sprintf(buf, "%d\n", bd->props.power);
 }
 
-static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, size_t count)
+static ssize_t backlight_store_power(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
 {
        int rc = -ENXIO;
        char *endp;
-       struct backlight_device *bd = to_backlight_device(cdev);
+       struct backlight_device *bd = to_backlight_device(dev);
        int power = simple_strtoul(buf, &endp, 0);
        size_t size = endp - buf;
 
@@ -101,18 +103,20 @@ static ssize_t backlight_store_power(struct class_device *cdev, const char *buf,
        return rc;
 }
 
-static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf)
+static ssize_t backlight_show_brightness(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
-       struct backlight_device *bd = to_backlight_device(cdev);
+       struct backlight_device *bd = to_backlight_device(dev);
 
        return sprintf(buf, "%d\n", bd->props.brightness);
 }
 
-static ssize_t backlight_store_brightness(struct class_device *cdev, const char *buf, size_t count)
+static ssize_t backlight_store_brightness(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
 {
        int rc = -ENXIO;
        char *endp;
-       struct backlight_device *bd = to_backlight_device(cdev);
+       struct backlight_device *bd = to_backlight_device(dev);
        int brightness = simple_strtoul(buf, &endp, 0);
        size_t size = endp - buf;
 
@@ -138,18 +142,19 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char
        return rc;
 }
 
-static ssize_t backlight_show_max_brightness(struct class_device *cdev, char *buf)
+static ssize_t backlight_show_max_brightness(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
-       struct backlight_device *bd = to_backlight_device(cdev);
+       struct backlight_device *bd = to_backlight_device(dev);
 
        return sprintf(buf, "%d\n", bd->props.max_brightness);
 }
 
-static ssize_t backlight_show_actual_brightness(struct class_device *cdev,
-                                               char *buf)
+static ssize_t backlight_show_actual_brightness(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
        int rc = -ENXIO;
-       struct backlight_device *bd = to_backlight_device(cdev);
+       struct backlight_device *bd = to_backlight_device(dev);
 
        mutex_lock(&bd->ops_lock);
        if (bd->ops && bd->ops->get_brightness)
@@ -159,31 +164,22 @@ static ssize_t backlight_show_actual_brightness(struct class_device *cdev,
        return rc;
 }
 
-static void backlight_class_release(struct class_device *dev)
+struct class *backlight_class;
+
+static void bl_device_release(struct device *dev)
 {
        struct backlight_device *bd = to_backlight_device(dev);
        kfree(bd);
 }
 
-static struct class backlight_class = {
-       .name = "backlight",
-       .release = backlight_class_release,
-};
-
-#define DECLARE_ATTR(_name,_mode,_show,_store)                 \
-{                                                              \
-       .attr   = { .name = __stringify(_name), .mode = _mode }, \
-       .show   = _show,                                        \
-       .store  = _store,                                       \
-}
-
-static const struct class_device_attribute bl_class_device_attributes[] = {
-       DECLARE_ATTR(power, 0644, backlight_show_power, backlight_store_power),
-       DECLARE_ATTR(brightness, 0644, backlight_show_brightness,
+static struct device_attribute bl_device_attributes[] = {
+       __ATTR(bl_power, 0644, backlight_show_power, backlight_store_power),
+       __ATTR(brightness, 0644, backlight_show_brightness,
                     backlight_store_brightness),
-       DECLARE_ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
+       __ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
                     NULL),
-       DECLARE_ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
+       __ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
+       __ATTR_NULL,
 };
 
 /**
@@ -191,22 +187,20 @@ static const struct class_device_attribute bl_class_device_attributes[] = {
  *   backlight_device class.
  * @name: the name of the new object(must be the same as the name of the
  *   respective framebuffer device).
- * @devdata: an optional pointer to be stored in the class_device. The
- *   methods may retrieve it by using class_get_devdata(&bd->class_dev).
+ * @devdata: an optional pointer to be stored for private driver use. The
+ *   methods may retrieve it by using bl_get_data(bd).
  * @ops: the backlight operations structure.
  *
- * Creates and registers new backlight class_device. Returns either an
+ * Creates and registers new backlight device. Returns either an
  * ERR_PTR() or a pointer to the newly allocated device.
  */
 struct backlight_device *backlight_device_register(const char *name,
-       struct device *dev,
-       void *devdata,
-       struct backlight_ops *ops)
+               struct device *parent, void *devdata, struct backlight_ops *ops)
 {
-       int i, rc;
        struct backlight_device *new_bd;
+       int rc;
 
-       pr_debug("backlight_device_alloc: name=%s\n", name);
+       pr_debug("backlight_device_register: name=%s\n", name);
 
        new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL);
        if (!new_bd)
@@ -214,13 +208,14 @@ struct backlight_device *backlight_device_register(const char *name,
 
        mutex_init(&new_bd->update_lock);
        mutex_init(&new_bd->ops_lock);
-       new_bd->ops = ops;
-       new_bd->class_dev.class = &backlight_class;
-       new_bd->class_dev.dev = dev;
-       strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN);
-       class_set_devdata(&new_bd->class_dev, devdata);
 
-       rc = class_device_register(&new_bd->class_dev);
+       new_bd->dev.class = backlight_class;
+       new_bd->dev.parent = parent;
+       new_bd->dev.release = bl_device_release;
+       strlcpy(new_bd->dev.bus_id, name, BUS_ID_SIZE);
+       dev_set_drvdata(&new_bd->dev, devdata);
+
+       rc = device_register(&new_bd->dev);
        if (rc) {
                kfree(new_bd);
                return ERR_PTR(rc);
@@ -228,23 +223,11 @@ struct backlight_device *backlight_device_register(const char *name,
 
        rc = backlight_register_fb(new_bd);
        if (rc) {
-               class_device_unregister(&new_bd->class_dev);
+               device_unregister(&new_bd->dev);
                return ERR_PTR(rc);
        }
 
-
-       for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) {
-               rc = class_device_create_file(&new_bd->class_dev,
-                                             &bl_class_device_attributes[i]);
-               if (rc) {
-                       while (--i >= 0)
-                               class_device_remove_file(&new_bd->class_dev,
-                                                        &bl_class_device_attributes[i]);
-                       class_device_unregister(&new_bd->class_dev);
-                       /* No need to kfree(new_bd) since release() method was called */
-                       return ERR_PTR(rc);
-               }
-       }
+       new_bd->ops = ops;
 
 #ifdef CONFIG_PMAC_BACKLIGHT
        mutex_lock(&pmac_backlight_mutex);
@@ -265,42 +248,40 @@ EXPORT_SYMBOL(backlight_device_register);
  */
 void backlight_device_unregister(struct backlight_device *bd)
 {
-       int i;
-
        if (!bd)
                return;
 
-       pr_debug("backlight_device_unregister: name=%s\n", bd->class_dev.class_id);
-
 #ifdef CONFIG_PMAC_BACKLIGHT
        mutex_lock(&pmac_backlight_mutex);
        if (pmac_backlight == bd)
                pmac_backlight = NULL;
        mutex_unlock(&pmac_backlight_mutex);
 #endif
-
-       for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++)
-               class_device_remove_file(&bd->class_dev,
-                                        &bl_class_device_attributes[i]);
-
        mutex_lock(&bd->ops_lock);
        bd->ops = NULL;
        mutex_unlock(&bd->ops_lock);
 
        backlight_unregister_fb(bd);
-
-       class_device_unregister(&bd->class_dev);
+       device_unregister(&bd->dev);
 }
 EXPORT_SYMBOL(backlight_device_unregister);
 
 static void __exit backlight_class_exit(void)
 {
-       class_unregister(&backlight_class);
+       class_destroy(backlight_class);
 }
 
 static int __init backlight_class_init(void)
 {
-       return class_register(&backlight_class);
+       backlight_class = class_create(THIS_MODULE, "backlight");
+       if (IS_ERR(backlight_class)) {
+               printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n",
+                               PTR_ERR(backlight_class));
+               return PTR_ERR(backlight_class);
+       }
+
+       backlight_class->dev_attrs = bl_device_attributes;
+       return 0;
 }
 
 /*
index 1b3f6586bc9f433295ccee5bf5c32d5868e6d461..b7904da51b231158d4f74d0a4ff5da448f3b8821 100644 (file)
@@ -202,7 +202,7 @@ static int cr_backlight_probe(struct platform_device *pdev)
        }
 
        crp->cr_lcd_device = lcd_device_register("cr-lcd",
-                                                       &pdev->dev,
+                                                       &pdev->dev, NULL,
                                                        &cr_lcd_ops);
 
        if (IS_ERR(crp->cr_lcd_device)) {
index 648b53c1fdea7f7f2687f8f5d6b60c179f61007a..6f652c65fae130ab59bbcd89a29d5da0a0be551f 100644 (file)
@@ -61,10 +61,11 @@ static inline void lcd_unregister_fb(struct lcd_device *ld)
 }
 #endif /* CONFIG_FB */
 
-static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
+static ssize_t lcd_show_power(struct device *dev, struct device_attribute *attr,
+               char *buf)
 {
        int rc;
-       struct lcd_device *ld = to_lcd_device(cdev);
+       struct lcd_device *ld = to_lcd_device(dev);
 
        mutex_lock(&ld->ops_lock);
        if (ld->ops && ld->ops->get_power)
@@ -76,11 +77,12 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
        return rc;
 }
 
-static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_t count)
+static ssize_t lcd_store_power(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
 {
        int rc = -ENXIO;
        char *endp;
-       struct lcd_device *ld = to_lcd_device(cdev);
+       struct lcd_device *ld = to_lcd_device(dev);
        int power = simple_strtoul(buf, &endp, 0);
        size_t size = endp - buf;
 
@@ -100,10 +102,11 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_
        return rc;
 }
 
-static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
+static ssize_t lcd_show_contrast(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
        int rc = -ENXIO;
-       struct lcd_device *ld = to_lcd_device(cdev);
+       struct lcd_device *ld = to_lcd_device(dev);
 
        mutex_lock(&ld->ops_lock);
        if (ld->ops && ld->ops->get_contrast)
@@ -113,11 +116,12 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
        return rc;
 }
 
-static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, size_t count)
+static ssize_t lcd_store_contrast(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
 {
        int rc = -ENXIO;
        char *endp;
-       struct lcd_device *ld = to_lcd_device(cdev);
+       struct lcd_device *ld = to_lcd_device(dev);
        int contrast = simple_strtoul(buf, &endp, 0);
        size_t size = endp - buf;
 
@@ -137,53 +141,45 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si
        return rc;
 }
 
-static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf)
+static ssize_t lcd_show_max_contrast(struct device *dev,
+               struct device_attribute *attr, char *buf)
 {
-       struct lcd_device *ld = to_lcd_device(cdev);
+       struct lcd_device *ld = to_lcd_device(dev);
 
        return sprintf(buf, "%d\n", ld->props.max_contrast);
 }
 
-static void lcd_class_release(struct class_device *dev)
+struct class *lcd_class;
+
+static void lcd_device_release(struct device *dev)
 {
        struct lcd_device *ld = to_lcd_device(dev);
        kfree(ld);
 }
 
-static struct class lcd_class = {
-       .name = "lcd",
-       .release = lcd_class_release,
-};
-
-#define DECLARE_ATTR(_name,_mode,_show,_store)                 \
-{                                                              \
-       .attr   = { .name = __stringify(_name), .mode = _mode }, \
-       .show   = _show,                                        \
-       .store  = _store,                                       \
-}
-
-static const struct class_device_attribute lcd_class_device_attributes[] = {
-       DECLARE_ATTR(power, 0644, lcd_show_power, lcd_store_power),
-       DECLARE_ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
-       DECLARE_ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
+static struct device_attribute lcd_device_attributes[] = {
+       __ATTR(lcd_power, 0644, lcd_show_power, lcd_store_power),
+       __ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
+       __ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
+       __ATTR_NULL,
 };
 
 /**
  * lcd_device_register - register a new object of lcd_device class.
  * @name: the name of the new object(must be the same as the name of the
  *   respective framebuffer device).
- * @devdata: an optional pointer to be stored in the class_device. The
- *   methods may retrieve it by using class_get_devdata(ld->class_dev).
+ * @devdata: an optional pointer to be stored in the device. The
+ *   methods may retrieve it by using lcd_get_data(ld).
  * @ops: the lcd operations structure.
  *
- * Creates and registers a new lcd class_device. Returns either an ERR_PTR()
+ * Creates and registers a new lcd device. Returns either an ERR_PTR()
  * or a pointer to the newly allocated device.
  */
-struct lcd_device *lcd_device_register(const char *name, void *devdata,
-                                      struct lcd_ops *ops)
+struct lcd_device *lcd_device_register(const char *name, struct device *parent,
+               void *devdata, struct lcd_ops *ops)
 {
-       int i, rc;
        struct lcd_device *new_ld;
+       int rc;
 
        pr_debug("lcd_device_register: name=%s\n", name);
 
@@ -193,12 +189,14 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
 
        mutex_init(&new_ld->ops_lock);
        mutex_init(&new_ld->update_lock);
-       new_ld->ops = ops;
-       new_ld->class_dev.class = &lcd_class;
-       strlcpy(new_ld->class_dev.class_id, name, KOBJ_NAME_LEN);
-       class_set_devdata(&new_ld->class_dev, devdata);
 
-       rc = class_device_register(&new_ld->class_dev);
+       new_ld->dev.class = lcd_class;
+       new_ld->dev.parent = parent;
+       new_ld->dev.release = lcd_device_release;
+       strlcpy(new_ld->dev.bus_id, name, BUS_ID_SIZE);
+       dev_set_drvdata(&new_ld->dev, devdata);
+
+       rc = device_register(&new_ld->dev);
        if (rc) {
                kfree(new_ld);
                return ERR_PTR(rc);
@@ -206,22 +204,11 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
 
        rc = lcd_register_fb(new_ld);
        if (rc) {
-               class_device_unregister(&new_ld->class_dev);
+               device_unregister(&new_ld->dev);
                return ERR_PTR(rc);
        }
 
-       for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) {
-               rc = class_device_create_file(&new_ld->class_dev,
-                                             &lcd_class_device_attributes[i]);
-               if (rc) {
-                       while (--i >= 0)
-                               class_device_remove_file(&new_ld->class_dev,
-                                                        &lcd_class_device_attributes[i]);
-                       class_device_unregister(&new_ld->class_dev);
-                       /* No need to kfree(new_ld) since release() method was called */
-                       return ERR_PTR(rc);
-               }
-       }
+       new_ld->ops = ops;
 
        return new_ld;
 }
@@ -235,33 +222,34 @@ EXPORT_SYMBOL(lcd_device_register);
  */
 void lcd_device_unregister(struct lcd_device *ld)
 {
-       int i;
-
        if (!ld)
                return;
 
-       pr_debug("lcd_device_unregister: name=%s\n", ld->class_dev.class_id);
-
-       for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++)
-               class_device_remove_file(&ld->class_dev,
-                                        &lcd_class_device_attributes[i]);
-
        mutex_lock(&ld->ops_lock);
        ld->ops = NULL;
        mutex_unlock(&ld->ops_lock);
        lcd_unregister_fb(ld);
-       class_device_unregister(&ld->class_dev);
+
+       device_unregister(&ld->dev);
 }
 EXPORT_SYMBOL(lcd_device_unregister);
 
 static void __exit lcd_class_exit(void)
 {
-       class_unregister(&lcd_class);
+       class_destroy(lcd_class);
 }
 
 static int __init lcd_class_init(void)
 {
-       return class_register(&lcd_class);
+       lcd_class = class_create(THIS_MODULE, "lcd");
+       if (IS_ERR(lcd_class)) {
+               printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n",
+                               PTR_ERR(lcd_class));
+               return PTR_ERR(lcd_class);
+       }
+
+       lcd_class->dev_attrs = lcd_device_attributes;
+       return 0;
 }
 
 /*
index 43f62d8ee41d8e3f0417c75757ffd1864e881bfb..443e3c85a9a0a677c12c2840899b55c209b261be 100644 (file)
@@ -50,7 +50,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
 
 static int nvidia_bl_update_status(struct backlight_device *bd)
 {
-       struct nvidia_par *par = class_get_devdata(&bd->class_dev);
+       struct nvidia_par *par = bl_get_data(bd);
        u32 tmp_pcrt, tmp_pmc, fpcontrol;
        int level;
 
index 41381e61832cb61285782736e681fc039e382264..5c47968e7f2152bd3004cd8f0dd9c8a93ff18880 100644 (file)
@@ -307,7 +307,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par,
 
 static int riva_bl_update_status(struct backlight_device *bd)
 {
-       struct riva_par *par = class_get_devdata(&bd->class_dev);
+       struct riva_par *par = bl_get_data(bd);
        U032 tmp_pcrt, tmp_pmc;
        int level;
 
index 1023ba0d6e5541aadfbca392ef42cc68a94a9acd..c897c7b038582157a3374373a4160b8c81e54dc2 100644 (file)
@@ -69,8 +69,8 @@ struct backlight_device {
 
        /* The framebuffer notifier block */
        struct notifier_block fb_notif;
-       /* The class device structure */
-       struct class_device class_dev;
+
+       struct device dev;
 };
 
 static inline void backlight_update_status(struct backlight_device *bd)
@@ -85,6 +85,11 @@ extern struct backlight_device *backlight_device_register(const char *name,
        struct device *dev, void *devdata, struct backlight_ops *ops);
 extern void backlight_device_unregister(struct backlight_device *bd);
 
-#define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev)
+#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
+
+static inline void * bl_get_data(struct backlight_device *bl_dev)
+{
+       return dev_get_drvdata(&bl_dev->dev);
+}
 
 #endif
index 598793c0745b3c97ec593f1329b351b5743c3b1d..1d379787f2e78e4a1b56cb35c448e8e84ff39f38 100644 (file)
@@ -62,8 +62,8 @@ struct lcd_device {
        struct mutex update_lock;
        /* The framebuffer notifier block */
        struct notifier_block fb_notif;
-       /* The class device structure */
-       struct class_device class_dev;
+
+       struct device dev;
 };
 
 static inline void lcd_set_power(struct lcd_device *ld, int power)
@@ -75,9 +75,15 @@ static inline void lcd_set_power(struct lcd_device *ld, int power)
 }
 
 extern struct lcd_device *lcd_device_register(const char *name,
-       void *devdata, struct lcd_ops *ops);
+       struct device *parent, void *devdata, struct lcd_ops *ops);
 extern void lcd_device_unregister(struct lcd_device *ld);
 
-#define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev)
+#define to_lcd_device(obj) container_of(obj, struct lcd_device, dev)
+
+static inline void * lcd_get_data(struct lcd_device *ld_dev)
+{
+       return dev_get_drvdata(&ld_dev->dev);
+}
+
 
 #endif