backlight: Allow properties to be passed at registration
authorMatthew Garrett <mjg@redhat.com>
Wed, 17 Feb 2010 21:39:44 +0000 (16:39 -0500)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 16 Mar 2010 19:47:54 +0000 (19:47 +0000)
Values such as max_brightness should be set before backlights are
registered, but the current API doesn't allow that. Add a parameter to
backlight_device_register and update drivers to ensure that they
set this correctly.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
49 files changed:
drivers/acpi/video.c
drivers/gpu/drm/nouveau/nouveau_backlight.c
drivers/macintosh/via-pmu-backlight.c
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/asus-laptop.c
drivers/platform/x86/asus_acpi.c
drivers/platform/x86/classmate-laptop.c
drivers/platform/x86/compal-laptop.c
drivers/platform/x86/dell-laptop.c
drivers/platform/x86/eeepc-laptop.c
drivers/platform/x86/fujitsu-laptop.c
drivers/platform/x86/msi-laptop.c
drivers/platform/x86/msi-wmi.c
drivers/platform/x86/panasonic-laptop.c
drivers/platform/x86/sony-laptop.c
drivers/platform/x86/thinkpad_acpi.c
drivers/platform/x86/toshiba_acpi.c
drivers/staging/samsung-laptop/samsung-laptop.c
drivers/usb/misc/appledisplay.c
drivers/video/atmel_lcdfb.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb_base.c
drivers/video/aty/radeon_backlight.c
drivers/video/backlight/88pm860x_bl.c
drivers/video/backlight/adp5520_bl.c
drivers/video/backlight/adx_bl.c
drivers/video/backlight/atmel-pwm-bl.c
drivers/video/backlight/backlight.c
drivers/video/backlight/corgi_lcd.c
drivers/video/backlight/cr_bllcd.c
drivers/video/backlight/da903x_bl.c
drivers/video/backlight/generic_bl.c
drivers/video/backlight/hp680_bl.c
drivers/video/backlight/jornada720_bl.c
drivers/video/backlight/kb3886_bl.c
drivers/video/backlight/locomolcd.c
drivers/video/backlight/max8925_bl.c
drivers/video/backlight/mbp_nvidia_bl.c
drivers/video/backlight/omap1_bl.c
drivers/video/backlight/progear_bl.c
drivers/video/backlight/pwm_bl.c
drivers/video/backlight/tosa_bl.c
drivers/video/backlight/wm831x_bl.c
drivers/video/bf54x-lq043fb.c
drivers/video/bfin-t350mcqb-fb.c
drivers/video/nvidia/nv_backlight.c
drivers/video/omap2/displays/panel-taal.c
drivers/video/riva/fbdev.c
include/linux/backlight.h

index 2ff2b6ab5b6c3c656090a4947638bdb9bb618622..cbe6f3924a102d327cb92511255c8df0d63329b1 100644 (file)
@@ -998,6 +998,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
        }
 
        if (acpi_video_backlight_support()) {
+               struct backlight_properties props;
                int result;
                static int count = 0;
                char *name;
@@ -1010,12 +1011,14 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                        return;
 
                sprintf(name, "acpi_video%d", count++);
-               device->backlight = backlight_device_register(name,
-                       NULL, device, &acpi_backlight_ops);
+               memset(&props, 0, sizeof(struct backlight_properties));
+               props.max_brightness = device->brightness->count - 3;
+               device->backlight = backlight_device_register(name, NULL, device,
+                                                             &acpi_backlight_ops,
+                                                             &props);
                kfree(name);
                if (IS_ERR(device->backlight))
                        return;
-               device->backlight->props.max_brightness = device->brightness->count-3;
 
                result = sysfs_create_link(&device->backlight->dev.kobj,
                                           &device->dev->dev.kobj, "device");
index 20564f8cb0ec45f2fa13f82aa69c6bea375600e5..406228f4a2a05e549090f8a4e4fca09253546833 100644 (file)
@@ -89,19 +89,21 @@ static struct backlight_ops nv50_bl_ops = {
 
 static int nouveau_nv40_backlight_init(struct drm_device *dev)
 {
+       struct backlight_properties props;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        struct backlight_device *bd;
 
        if (!(nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
                return 0;
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 31;
        bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
-                                      &nv40_bl_ops);
+                                      &nv40_bl_ops, &props);
        if (IS_ERR(bd))
                return PTR_ERR(bd);
 
        dev_priv->backlight = bd;
-       bd->props.max_brightness = 31;
        bd->props.brightness = nv40_get_intensity(bd);
        backlight_update_status(bd);
 
@@ -110,19 +112,21 @@ static int nouveau_nv40_backlight_init(struct drm_device *dev)
 
 static int nouveau_nv50_backlight_init(struct drm_device *dev)
 {
+       struct backlight_properties props;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        struct backlight_device *bd;
 
        if (!nv_rd32(dev, NV50_PDISPLAY_SOR_BACKLIGHT))
                return 0;
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 1025;
        bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
-                                      &nv50_bl_ops);
+                                      &nv50_bl_ops, &props);
        if (IS_ERR(bd))
                return PTR_ERR(bd);
 
        dev_priv->backlight = bd;
-       bd->props.max_brightness = 1025;
        bd->props.brightness = nv50_get_intensity(bd);
        backlight_update_status(bd);
        return 0;
index 4f3c4479c16aa16da18efd22bbc37e12dc39d2c7..1cec02f6c431a0af52f8360f262c2cdb6859e14e 100644 (file)
@@ -144,6 +144,7 @@ void pmu_backlight_set_sleep(int sleep)
 
 void __init pmu_backlight_init()
 {
+       struct backlight_properties props;
        struct backlight_device *bd;
        char name[10];
        int level, autosave;
@@ -161,13 +162,15 @@ void __init pmu_backlight_init()
 
        snprintf(name, sizeof(name), "pmubl");
 
-       bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data,
+                                      &props);
        if (IS_ERR(bd)) {
                printk(KERN_ERR "PMU Backlight registration failed\n");
                return;
        }
        uses_pmu_bl = 1;
-       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
        pmu_backlight_init_curve(0x7F, 0x46, 0x0E);
 
        level = bd->props.max_brightness;
index 226b3e93498c45d8f63fc2f67544950a512b20cd..cbca40aa400612f7a61b8a7267e4efbec51c6bdd 100644 (file)
@@ -922,9 +922,13 @@ static struct backlight_ops acer_bl_ops = {
 
 static int __devinit acer_backlight_init(struct device *dev)
 {
+       struct backlight_properties props;
        struct backlight_device *bd;
 
-       bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = max_brightness;
+       bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops,
+                                      &props);
        if (IS_ERR(bd)) {
                printk(ACER_ERR "Could not register Acer backlight device\n");
                acer_backlight_device = NULL;
@@ -935,7 +939,6 @@ static int __devinit acer_backlight_init(struct device *dev)
 
        bd->props.power = FB_BLANK_UNBLANK;
        bd->props.brightness = read_brightness(bd);
-       bd->props.max_brightness = max_brightness;
        backlight_update_status(bd);
        return 0;
 }
index 791fcf321506af6df46e243e061539a47c88cdad..db5f7db2ba33e4821b41dae2226fe656c32b2518 100644 (file)
@@ -639,12 +639,16 @@ static int asus_backlight_init(struct asus_laptop *asus)
 {
        struct backlight_device *bd;
        struct device *dev = &asus->platform_device->dev;
+       struct backlight_properties props;
 
        if (!acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) &&
            !acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) &&
            lcd_switch_handle) {
+               memset(&props, 0, sizeof(struct backlight_properties));
+               props.max_brightness = 15;
+
                bd = backlight_device_register(ASUS_LAPTOP_FILE, dev,
-                                              asus, &asusbl_ops);
+                                              asus, &asusbl_ops, &props);
                if (IS_ERR(bd)) {
                        pr_err("Could not register asus backlight device\n");
                        asus->backlight_device = NULL;
@@ -653,7 +657,6 @@ static int asus_backlight_init(struct asus_laptop *asus)
 
                asus->backlight_device = bd;
 
-               bd->props.max_brightness = 15;
                bd->props.power = FB_BLANK_UNBLANK;
                bd->props.brightness = asus_read_brightness(bd);
                backlight_update_status(bd);
index 1381430e110565f012f4c98bb7927b01874fd026..ee520357abaad9e3f310b57b219df9722e97f6c6 100644 (file)
@@ -1481,6 +1481,7 @@ static void asus_acpi_exit(void)
 
 static int __init asus_acpi_init(void)
 {
+       struct backlight_properties props;
        int result;
 
        result = acpi_bus_register_driver(&asus_hotk_driver);
@@ -1507,15 +1508,17 @@ static int __init asus_acpi_init(void)
                return -ENODEV;
        }
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 15;
        asus_backlight_device = backlight_device_register("asus", NULL, NULL,
-                                                         &asus_backlight_data);
+                                                         &asus_backlight_data,
+                                                         &props);
        if (IS_ERR(asus_backlight_device)) {
                printk(KERN_ERR "Could not register asus backlight device\n");
                asus_backlight_device = NULL;
                asus_acpi_exit();
                return -ENODEV;
        }
-       asus_backlight_device->props.max_brightness = 15;
 
        return 0;
 }
index 035a7dd65a3fdf87d08305b9f0d663446240d4cd..6670ed8f9e5b4c849f4f8b853b4fda41069d2a05 100644 (file)
@@ -462,11 +462,13 @@ static struct backlight_ops cmpc_bl_ops = {
 
 static int cmpc_bl_add(struct acpi_device *acpi)
 {
+       struct backlight_properties props;
        struct backlight_device *bd;
 
-       bd = backlight_device_register("cmpc_bl", &acpi->dev,
-                                      acpi->handle, &cmpc_bl_ops);
-       bd->props.max_brightness = 7;
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 7;
+       bd = backlight_device_register("cmpc_bl", &acpi->dev, acpi->handle,
+                                      &cmpc_bl_ops, &props);
        dev_set_drvdata(&acpi->dev, bd);
        return 0;
 }
index 2740b40aad9b318bbaf289357c197b6294323bf8..71ff1545a93e0a87e3c0ea80953e909c7f901424 100644 (file)
@@ -291,12 +291,15 @@ static int __init compal_init(void)
        /* Register backlight stuff */
 
        if (!acpi_video_backlight_support()) {
-               compalbl_device = backlight_device_register("compal-laptop", NULL, NULL,
-                                                           &compalbl_ops);
+               struct backlight_properties props;
+               memset(&props, 0, sizeof(struct backlight_properties));
+               props.max_brightness = COMPAL_LCD_LEVEL_MAX - 1;
+               compalbl_device = backlight_device_register("compal-laptop",
+                                                           NULL, NULL,
+                                                           &compalbl_ops,
+                                                           &props);
                if (IS_ERR(compalbl_device))
                        return PTR_ERR(compalbl_device);
-
-               compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1;
        }
 
        ret = platform_driver_register(&compal_driver);
index ef614979afe97de3f5c3e90eb4c37214374ac6e8..46435ac4684f91a9ba1738e0b995bb294aeadeb2 100644 (file)
@@ -559,10 +559,14 @@ static int __init dell_init(void)
        release_buffer();
 
        if (max_intensity) {
-               dell_backlight_device = backlight_device_register(
-                       "dell_backlight",
-                       &platform_device->dev, NULL,
-                       &dell_ops);
+               struct backlight_properties props;
+               memset(&props, 0, sizeof(struct backlight_properties));
+               props.max_brightness = max_intensity;
+               dell_backlight_device = backlight_device_register("dell_backlight",
+                                                                 &platform_device->dev,
+                                                                 NULL,
+                                                                 &dell_ops,
+                                                                 &props);
 
                if (IS_ERR(dell_backlight_device)) {
                        ret = PTR_ERR(dell_backlight_device);
@@ -570,7 +574,6 @@ static int __init dell_init(void)
                        goto fail_backlight;
                }
 
-               dell_backlight_device->props.max_brightness = max_intensity;
                dell_backlight_device->props.brightness =
                        dell_get_intensity(dell_backlight_device);
                backlight_update_status(dell_backlight_device);
index 9a844caa3756717e9dd355d1309b6bf6c46cfb4d..3fdf21e0052e5ee320b915439e50ce96ddde24d7 100644 (file)
@@ -1131,18 +1131,20 @@ static int eeepc_backlight_notify(struct eeepc_laptop *eeepc)
 
 static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
 {
+       struct backlight_properties props;
        struct backlight_device *bd;
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 15;
        bd = backlight_device_register(EEEPC_LAPTOP_FILE,
-                                      &eeepc->platform_device->dev,
-                                      eeepc, &eeepcbl_ops);
+                                      &eeepc->platform_device->dev, eeepc,
+                                      &eeepcbl_ops, &props);
        if (IS_ERR(bd)) {
                pr_err("Could not register eeepc backlight device\n");
                eeepc->backlight_device = NULL;
                return PTR_ERR(bd);
        }
        eeepc->backlight_device = bd;
-       bd->props.max_brightness = 15;
        bd->props.brightness = read_brightness(bd);
        bd->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
index 5f3320d468f61bd6aa37d7606e86570508910b81..c1074b32490e4346f06241b52ab7fd4a94e465c7 100644 (file)
@@ -1126,16 +1126,20 @@ static int __init fujitsu_init(void)
        /* Register backlight stuff */
 
        if (!acpi_video_backlight_support()) {
-               fujitsu->bl_device =
-                       backlight_device_register("fujitsu-laptop", NULL, NULL,
-                                                 &fujitsubl_ops);
+               struct backlight_properties props;
+
+               memset(&props, 0, sizeof(struct backlight_properties));
+               max_brightness = fujitsu->max_brightness;
+               props.max_brightness = max_brightness - 1;
+               fujitsu->bl_device = backlight_device_register("fujitsu-laptop",
+                                                              NULL, NULL,
+                                                              &fujitsubl_ops,
+                                                              &props);
                if (IS_ERR(fujitsu->bl_device)) {
                        ret = PTR_ERR(fujitsu->bl_device);
                        fujitsu->bl_device = NULL;
                        goto fail_sysfs_group;
                }
-               max_brightness = fujitsu->max_brightness;
-               fujitsu->bl_device->props.max_brightness = max_brightness - 1;
                fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
        }
 
index c2b05da4289a7dadd8f79f1add1b507610f5c77f..996223a7c009b01f080d0130e7c5e701872fa511 100644 (file)
@@ -683,11 +683,14 @@ static int __init msi_init(void)
                printk(KERN_INFO "MSI: Brightness ignored, must be controlled "
                       "by ACPI video driver\n");
        } else {
+               struct backlight_properties props;
+               memset(&props, 0, sizeof(struct backlight_properties));
+               props.max_brightness = MSI_LCD_LEVEL_MAX - 1;
                msibl_device = backlight_device_register("msi-laptop-bl", NULL,
-                                                        NULL, &msibl_ops);
+                                                        NULL, &msibl_ops,
+                                                        &props);
                if (IS_ERR(msibl_device))
                        return PTR_ERR(msibl_device);
-               msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1;
        }
 
        ret = platform_driver_register(&msipf_driver);
index f5f70d4c6913bf373af4a052e6618c3077bee85d..fb7ccaae65635cfc8758f3fea28e5f750489871e 100644 (file)
@@ -249,12 +249,15 @@ static int __init msi_wmi_init(void)
                goto err_uninstall_notifier;
 
        if (!acpi_video_backlight_support()) {
-               backlight = backlight_device_register(DRV_NAME,
-                               NULL, NULL, &msi_backlight_ops);
+               struct backlight_properties props;
+               memset(&props, 0, sizeof(struct backlight_properties));
+               props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
+               backlight = backlight_device_register(DRV_NAME, NULL, NULL,
+                                                     &msi_backlight_ops,
+                                                     &props);
                if (IS_ERR(backlight))
                        goto err_free_input;
 
-               backlight->props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
                err = bl_get(NULL);
                if (err < 0)
                        goto err_free_backlight;
index c9fc479fc290ee5bb5266cd25f6a23397e7bf1da..ab5c9cea14627e8cba3869ce2f0d93df39d41ec9 100644 (file)
@@ -600,6 +600,7 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device)
 
 static int acpi_pcc_hotkey_add(struct acpi_device *device)
 {
+       struct backlight_properties props;
        struct pcc_acpi *pcc;
        int num_sifr, result;
 
@@ -637,24 +638,23 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
        if (result) {
                ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                  "Error installing keyinput handler\n"));
-               goto out_sinf;
+               goto out_hotkey;
        }
 
-       /* initialize backlight */
-       pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
-                                                  &pcc_backlight_ops);
-       if (IS_ERR(pcc->backlight))
-               goto out_input;
-
        if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) {
                ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                 "Couldn't retrieve BIOS data\n"));
-               goto out_backlight;
+               goto out_input;
        }
+       /* initialize backlight */
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT];
+       pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
+                                                  &pcc_backlight_ops, &props);
+       if (IS_ERR(pcc->backlight))
+               goto out_sinf;
 
        /* read the initial brightness setting from the hardware */
-       pcc->backlight->props.max_brightness =
-                                       pcc->sinf[SINF_AC_MAX_BRIGHT];
        pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT];
 
        /* read the initial sticky key mode from the hardware */
@@ -669,12 +669,12 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
 
 out_backlight:
        backlight_device_unregister(pcc->backlight);
+out_sinf:
+       kfree(pcc->sinf);
 out_input:
        input_unregister_device(pcc->input_dev);
        /* no need to input_free_device() since core input API refcount and
         * free()s the device */
-out_sinf:
-       kfree(pcc->sinf);
 out_hotkey:
        kfree(pcc);
 
index 5a3d8514c66dafbd57c4d1900151626a55550ae5..6553b91caaa4a4d1373065861ec296e9e34a6c3c 100644 (file)
@@ -1291,9 +1291,13 @@ static int sony_nc_add(struct acpi_device *device)
                       "controlled by ACPI video driver\n");
        } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
                                                &handle))) {
+                                                       struct backlight_properties props;
+               memset(&props, 0, sizeof(struct backlight_properties));
+               props.max_brightness = SONY_MAX_BRIGHTNESS - 1;
                sony_backlight_device = backlight_device_register("sony", NULL,
                                                                  NULL,
-                                                                 &sony_backlight_ops);
+                                                                 &sony_backlight_ops,
+                                                                 &props);
 
                if (IS_ERR(sony_backlight_device)) {
                        printk(KERN_WARNING DRV_PFX "unable to register backlight device\n");
@@ -1302,8 +1306,6 @@ static int sony_nc_add(struct acpi_device *device)
                        sony_backlight_device->props.brightness =
                            sony_backlight_get_brightness
                            (sony_backlight_device);
-                       sony_backlight_device->props.max_brightness =
-                           SONY_MAX_BRIGHTNESS - 1;
                }
 
        }
index c64e3528889bd9fdd91cddd6b0e7fd2e4130c4ea..770b85327f84b0177bbaab47c224b8f5c1b55b57 100644 (file)
@@ -6170,6 +6170,7 @@ static const struct tpacpi_quirk brightness_quirk_table[] __initconst = {
 
 static int __init brightness_init(struct ibm_init_struct *iibm)
 {
+       struct backlight_properties props;
        int b;
        unsigned long quirks;
 
@@ -6259,9 +6260,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
                printk(TPACPI_INFO
                       "detected a 16-level brightness capable ThinkPad\n");
 
-       ibm_backlight_device = backlight_device_register(
-                                       TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL,
-                                       &ibm_backlight_data);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = (tp_features.bright_16levels) ? 15 : 7;
+       ibm_backlight_device = backlight_device_register(TPACPI_BACKLIGHT_DEV_NAME,
+                                                        NULL, NULL,
+                                                        &ibm_backlight_data,
+                                                        &props);
        if (IS_ERR(ibm_backlight_device)) {
                int rc = PTR_ERR(ibm_backlight_device);
                ibm_backlight_device = NULL;
@@ -6280,8 +6284,6 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
                        "or not on your ThinkPad\n", TPACPI_MAIL);
        }
 
-       ibm_backlight_device->props.max_brightness =
-                               (tp_features.bright_16levels)? 15 : 7;
        ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK;
        backlight_update_status(ibm_backlight_device);
 
index 789240d1b577b9c1fc43f861c4ee884ca5e22d16..def4841183be621b8a140a503b559f3766d45ebb 100644 (file)
@@ -924,6 +924,7 @@ static int __init toshiba_acpi_init(void)
        u32 hci_result;
        bool bt_present;
        int ret = 0;
+       struct backlight_properties props;
 
        if (acpi_disabled)
                return -ENODEV;
@@ -974,10 +975,12 @@ static int __init toshiba_acpi_init(void)
                }
        }
 
+       props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
        toshiba_backlight_device = backlight_device_register("toshiba",
-                                               &toshiba_acpi.p_dev->dev,
-                                               NULL,
-                                               &toshiba_backlight_data);
+                                                            &toshiba_acpi.p_dev->dev,
+                                                            NULL,
+                                                            &toshiba_backlight_data,
+                                                            &props);
         if (IS_ERR(toshiba_backlight_device)) {
                ret = PTR_ERR(toshiba_backlight_device);
 
@@ -986,7 +989,6 @@ static int __init toshiba_acpi_init(void)
                toshiba_acpi_exit();
                return ret;
        }
-        toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
 
        /* Register rfkill switch for Bluetooth */
        if (hci_get_bt_present(&bt_present) == HCI_SUCCESS && bt_present) {
index dd7ea4c075dbb319d5148c25fad0601592858d82..eb44b60e1eb542d735cb0cbabbff1e55109008c9 100644 (file)
@@ -394,6 +394,7 @@ MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
 
 static int __init samsung_init(void)
 {
+       struct backlight_properties props;
        struct sabi_retval sretval;
        const char *testStr = "SECLINUX";
        void __iomem *memcheck;
@@ -486,12 +487,14 @@ static int __init samsung_init(void)
                goto error_no_platform;
 
        /* create a backlight device to talk to this one */
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = MAX_BRIGHT;
        backlight_device = backlight_device_register("samsung", &sdev->dev,
-                                                    NULL, &backlight_ops);
+                                                    NULL, &backlight_ops,
+                                                    &props);
        if (IS_ERR(backlight_device))
                goto error_no_backlight;
 
-       backlight_device->props.max_brightness = MAX_BRIGHT;
        backlight_device->props.brightness = read_brightness();
        backlight_device->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(backlight_device);
index 4d2952f1fb1370f86b7c13630ee7a096769f94e5..3adab041355a56a9e1b76b0c0ebd20232f41ee31 100644 (file)
@@ -202,6 +202,7 @@ static void appledisplay_work(struct work_struct *work)
 static int appledisplay_probe(struct usb_interface *iface,
        const struct usb_device_id *id)
 {
+       struct backlight_properties props;
        struct appledisplay *pdata;
        struct usb_device *udev = interface_to_usbdev(iface);
        struct usb_host_interface *iface_desc;
@@ -279,16 +280,16 @@ static int appledisplay_probe(struct usb_interface *iface,
        /* Register backlight device */
        snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
                atomic_inc_return(&count_displays) - 1);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 0xff;
        pdata->bd = backlight_device_register(bl_name, NULL, pdata,
-                                               &appledisplay_bl_data);
+                                             &appledisplay_bl_data, &props);
        if (IS_ERR(pdata->bd)) {
                dev_err(&iface->dev, "Backlight registration failed\n");
                retval = PTR_ERR(pdata->bd);
                goto error;
        }
 
-       pdata->bd->props.max_brightness = 0xff;
-
        /* Try to get brightness */
        brightness = appledisplay_bl_get_brightness(pdata->bd);
 
index 3d886c6902f9fe463064ac7d2d39818e36944339..11de3bfd4e543f29d152308b363767205f969aee 100644 (file)
@@ -117,6 +117,7 @@ static struct backlight_ops atmel_lcdc_bl_ops = {
 
 static void init_backlight(struct atmel_lcdfb_info *sinfo)
 {
+       struct backlight_properties props;
        struct backlight_device *bl;
 
        sinfo->bl_power = FB_BLANK_UNBLANK;
@@ -124,8 +125,10 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
        if (sinfo->backlight)
                return;
 
-       bl = backlight_device_register("backlight", &sinfo->pdev->dev,
-                       sinfo, &atmel_lcdc_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 0xff;
+       bl = backlight_device_register("backlight", &sinfo->pdev->dev, sinfo,
+                                      &atmel_lcdc_bl_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n",
                                PTR_ERR(bl));
@@ -135,7 +138,6 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
 
        bl->props.power = FB_BLANK_UNBLANK;
        bl->props.fb_blank = FB_BLANK_UNBLANK;
-       bl->props.max_brightness = 0xff;
        bl->props.brightness = atmel_bl_get_brightness(bl);
 }
 
index 9ee67d6da7101f1d3b0f714553792f60015b4c02..a489be0c461493dd6b61669b82961a2a207f9a74 100644 (file)
@@ -1802,6 +1802,7 @@ static void aty128_bl_set_power(struct fb_info *info, int power)
 
 static void aty128_bl_init(struct aty128fb_par *par)
 {
+       struct backlight_properties props;
        struct fb_info *info = pci_get_drvdata(par->pdev);
        struct backlight_device *bd;
        char name[12];
@@ -1817,7 +1818,10 @@ static void aty128_bl_init(struct aty128fb_par *par)
 
        snprintf(name, sizeof(name), "aty128bl%d", info->node);
 
-       bd = backlight_device_register(name, info->dev, par, &aty128_bl_data);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd = backlight_device_register(name, info->dev, par, &aty128_bl_data,
+                                      &props);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "aty128: Backlight registration failed\n");
@@ -1829,7 +1833,6 @@ static void aty128_bl_init(struct aty128fb_par *par)
                 63 * FB_BACKLIGHT_MAX / MAX_LEVEL,
                219 * FB_BACKLIGHT_MAX / MAX_LEVEL);
 
-       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
        bd->props.brightness = bd->props.max_brightness;
        bd->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
index e45ab8db2ddc6f7f46d98ff09504dcc8c45ff2e6..29d72851f85bd1d01aa50448b1cc9f1e34f5924f 100644 (file)
@@ -2232,6 +2232,7 @@ static struct backlight_ops aty_bl_data = {
 
 static void aty_bl_init(struct atyfb_par *par)
 {
+       struct backlight_properties props;
        struct fb_info *info = pci_get_drvdata(par->pdev);
        struct backlight_device *bd;
        char name[12];
@@ -2243,7 +2244,10 @@ static void aty_bl_init(struct atyfb_par *par)
 
        snprintf(name, sizeof(name), "atybl%d", info->node);
 
-       bd = backlight_device_register(name, info->dev, par, &aty_bl_data);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd = backlight_device_register(name, info->dev, par, &aty_bl_data,
+                                      &props);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "aty: Backlight registration failed\n");
@@ -2255,7 +2259,6 @@ static void aty_bl_init(struct atyfb_par *par)
                            0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL,
                            0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL);
 
-       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
        bd->props.brightness = bd->props.max_brightness;
        bd->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
index fa1198c4ccc5d0041072b5ca95913134e3531ee3..9fc8c66be3cece99f453ec50300403252b1da718 100644 (file)
@@ -134,6 +134,7 @@ static struct backlight_ops radeon_bl_data = {
 
 void radeonfb_bl_init(struct radeonfb_info *rinfo)
 {
+       struct backlight_properties props;
        struct backlight_device *bd;
        struct radeon_bl_privdata *pdata;
        char name[12];
@@ -155,7 +156,10 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)
 
        snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node);
 
-       bd = backlight_device_register(name, rinfo->info->dev, pdata, &radeon_bl_data);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd = backlight_device_register(name, rinfo->info->dev, pdata,
+                                      &radeon_bl_data, &props);
        if (IS_ERR(bd)) {
                rinfo->info->bl_dev = NULL;
                printk("radeonfb: Backlight registration failed\n");
@@ -185,7 +189,6 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)
                 63 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL,
                217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL);
 
-       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
        bd->props.brightness = bd->props.max_brightness;
        bd->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
index b8f705cca438b43d641168188a2eaf55f8aec75e..93e25c77aeb2816434322a5a09a1545f475092a5 100644 (file)
@@ -187,6 +187,7 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
        struct pm860x_backlight_data *data;
        struct backlight_device *bl;
        struct resource *res;
+       struct backlight_properties props;
        unsigned char value;
        char name[MFD_NAME_SIZE];
        int ret;
@@ -223,14 +224,15 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = MAX_BRIGHTNESS;
        bl = backlight_device_register(name, &pdev->dev, data,
-                                       &pm860x_backlight_ops);
+                                       &pm860x_backlight_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&pdev->dev, "failed to register backlight\n");
                kfree(data);
                return PTR_ERR(bl);
        }
-       bl->props.max_brightness = MAX_BRIGHTNESS;
        bl->props.brightness = MAX_BRIGHTNESS;
 
        platform_set_drvdata(pdev, bl);
index 86d95c228adb7289ec294f454b44e9575516d1f7..5183f0e4d3145986d0d68998aa752c240bf3fd5e 100644 (file)
@@ -278,6 +278,7 @@ static const struct attribute_group adp5520_bl_attr_group = {
 
 static int __devinit adp5520_bl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct backlight_device *bl;
        struct adp5520_bl *data;
        int ret = 0;
@@ -300,17 +301,17 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev)
 
        mutex_init(&data->lock);
 
-       bl = backlight_device_register(pdev->name, data->master,
-                       data, &adp5520_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = ADP5020_MAX_BRIGHTNESS;
+       bl = backlight_device_register(pdev->name, data->master, data,
+                                      &adp5520_bl_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&pdev->dev, "failed to register backlight\n");
                kfree(data);
                return PTR_ERR(bl);
        }
 
-       bl->props.max_brightness =
-               bl->props.brightness = ADP5020_MAX_BRIGHTNESS;
-
+       bl->props.brightness = ADP5020_MAX_BRIGHTNESS;
        if (data->pdata->en_ambl_sens)
                ret = sysfs_create_group(&bl->dev.kobj,
                        &adp5520_bl_attr_group);
index a683dd1be4bcb20847a349ca78911d5f307a5616..b0624b983889273c72219d4b94ade29b7c0ce603 100644 (file)
@@ -70,6 +70,7 @@ static const struct backlight_ops adx_backlight_ops = {
 
 static int __devinit adx_backlight_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct backlight_device *bldev;
        struct resource *res;
        struct adxbl *bl;
@@ -101,14 +102,15 @@ static int __devinit adx_backlight_probe(struct platform_device *pdev)
                goto out;
        }
 
-       bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, bl,
-                       &adx_backlight_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 0xff;
+       bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev,
+                                         bl, &adx_backlight_ops, &props);
        if (!bldev) {
                ret = -ENOMEM;
                goto out;
        }
 
-       bldev->props.max_brightness = 0xff;
        bldev->props.brightness = 0xff;
        bldev->props.power = FB_BLANK_UNBLANK;
 
index f625ffc69ad3139cef6ba88688ac1e76878ff1e4..2d9760551a4b738e1d0ebaef4ffed32f2a4fdf2f 100644 (file)
@@ -120,6 +120,7 @@ static const struct backlight_ops atmel_pwm_bl_ops = {
 
 static int atmel_pwm_bl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        const struct atmel_pwm_bl_platform_data *pdata;
        struct backlight_device *bldev;
        struct atmel_pwm_bl *pwmbl;
@@ -165,8 +166,10 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
                        goto err_free_gpio;
        }
 
-       bldev = backlight_device_register("atmel-pwm-bl",
-                       &pdev->dev, pwmbl, &atmel_pwm_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min;
+       bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl,
+                                         &atmel_pwm_bl_ops, &props);
        if (IS_ERR(bldev)) {
                retval = PTR_ERR(bldev);
                goto err_free_gpio;
@@ -178,7 +181,6 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
 
        /* Power up the backlight by default at middle intesity. */
        bldev->props.power = FB_BLANK_UNBLANK;
-       bldev->props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min;
        bldev->props.brightness = bldev->props.max_brightness / 2;
 
        retval = atmel_pwm_bl_init_pwm(pwmbl);
index b800cd4eeec881a83e3fa83ce29a41dc76bd0039..68bb838b9f115677e09c5cb874de195c109e5c88 100644 (file)
@@ -269,7 +269,8 @@ EXPORT_SYMBOL(backlight_force_update);
  * ERR_PTR() or a pointer to the newly allocated device.
  */
 struct backlight_device *backlight_device_register(const char *name,
-               struct device *parent, void *devdata, const struct backlight_ops *ops)
+       struct device *parent, void *devdata, const struct backlight_ops *ops,
+       const struct backlight_properties *props)
 {
        struct backlight_device *new_bd;
        int rc;
@@ -289,6 +290,11 @@ struct backlight_device *backlight_device_register(const char *name,
        dev_set_name(&new_bd->dev, name);
        dev_set_drvdata(&new_bd->dev, devdata);
 
+       /* Set default properties */
+       if (props)
+               memcpy(&new_bd->props, props,
+                      sizeof(struct backlight_properties));
+
        rc = device_register(&new_bd->dev);
        if (rc) {
                kfree(new_bd);
index b4bcf8043797d18ced2ab1618ee9ef57853e6399..73bdd8454c943ed587b6fd3bf7abbf83a64ef622 100644 (file)
@@ -533,6 +533,7 @@ err_free_backlight_on:
 
 static int __devinit corgi_lcd_probe(struct spi_device *spi)
 {
+       struct backlight_properties props;
        struct corgi_lcd_platform_data *pdata = spi->dev.platform_data;
        struct corgi_lcd *lcd;
        int ret = 0;
@@ -559,13 +560,14 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
        lcd->power = FB_BLANK_POWERDOWN;
        lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;
 
-       lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev,
-                                       lcd, &corgi_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = pdata->max_intensity;
+       lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd,
+                                               &corgi_bl_ops, &props);
        if (IS_ERR(lcd->bl_dev)) {
                ret = PTR_ERR(lcd->bl_dev);
                goto err_unregister_lcd;
        }
-       lcd->bl_dev->props.max_brightness = pdata->max_intensity;
        lcd->bl_dev->props.brightness = pdata->default_intensity;
        lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
 
index da86db4374a05a350084b2f06834d489e773f4ba..1cce6031bff24a5736a505e007d316270104cfc1 100644 (file)
@@ -170,6 +170,7 @@ static struct lcd_ops cr_lcd_ops = {
 
 static int cr_backlight_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct backlight_device *bdp;
        struct lcd_device *ldp;
        struct cr_panel *crp;
@@ -190,8 +191,9 @@ static int cr_backlight_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       bdp = backlight_device_register("cr-backlight",
-                                       &pdev->dev, NULL, &cr_backlight_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       bdp = backlight_device_register("cr-backlight", &pdev->dev, NULL,
+                                       &cr_backlight_ops, &props);
        if (IS_ERR(bdp)) {
                pci_dev_put(lpc_dev);
                return PTR_ERR(bdp);
@@ -220,9 +222,7 @@ static int cr_backlight_probe(struct platform_device *pdev)
        crp->cr_lcd_device = ldp;
        crp->cr_backlight_device->props.power = FB_BLANK_UNBLANK;
        crp->cr_backlight_device->props.brightness = 0;
-       crp->cr_backlight_device->props.max_brightness = 0;
        cr_backlight_set_intensity(crp->cr_backlight_device);
-
        cr_lcd_set_power(crp->cr_lcd_device, FB_BLANK_UNBLANK);
 
        platform_set_drvdata(pdev, crp);
index 74cdc640173de5879af656d46cfaafa4ec8ad6bf..686e4a789238832f80fda14b2e4af8218f095640 100644 (file)
@@ -105,6 +105,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
        struct da9034_backlight_pdata *pdata = pdev->dev.platform_data;
        struct da903x_backlight_data *data;
        struct backlight_device *bl;
+       struct backlight_properties props;
        int max_brightness;
 
        data = kzalloc(sizeof(*data), GFP_KERNEL);
@@ -134,15 +135,15 @@ static int da903x_backlight_probe(struct platform_device *pdev)
                da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2,
                                DA9034_WLED_ISET(pdata->output_current));
 
-       bl = backlight_device_register(pdev->name, data->da903x_dev,
-                       data, &da903x_backlight_ops);
+       props.max_brightness = max_brightness;
+       bl = backlight_device_register(pdev->name, data->da903x_dev, data,
+                                      &da903x_backlight_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&pdev->dev, "failed to register backlight\n");
                kfree(data);
                return PTR_ERR(bl);
        }
 
-       bl->props.max_brightness = max_brightness;
        bl->props.brightness = max_brightness;
 
        platform_set_drvdata(pdev, bl);
index e6d348e63596455f06d4a3443e82ea4f982a91e6..312ca619735d4dcafa4a0bb70294be13fe5081db 100644 (file)
@@ -78,6 +78,7 @@ static const struct backlight_ops genericbl_ops = {
 
 static int genericbl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct generic_bl_info *machinfo = pdev->dev.platform_data;
        const char *name = "generic-bl";
        struct backlight_device *bd;
@@ -89,14 +90,15 @@ static int genericbl_probe(struct platform_device *pdev)
        if (machinfo->name)
                name = machinfo->name;
 
-       bd = backlight_device_register (name,
-               &pdev->dev, NULL, &genericbl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = machinfo->max_intensity;
+       bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops,
+                                      &props);
        if (IS_ERR (bd))
                return PTR_ERR (bd);
 
        platform_set_drvdata(pdev, bd);
 
-       bd->props.max_brightness = machinfo->max_intensity;
        bd->props.power = FB_BLANK_UNBLANK;
        bd->props.brightness = machinfo->default_intensity;
        backlight_update_status(bd);
index f7cc528d5be79a066347e43b3271c0d376e5275c..267d23f8d645fc889d7f5faace0d951e93ae41c0 100644 (file)
@@ -105,16 +105,18 @@ static const struct backlight_ops hp680bl_ops = {
 
 static int __devinit hp680bl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct backlight_device *bd;
 
-       bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL,
-                   &hp680bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = HP680_MAX_INTENSITY;
+       bd = backlight_device_register("hp680-bl", &pdev->dev, NULL,
+                                      &hp680bl_ops, &props);
        if (IS_ERR(bd))
                return PTR_ERR(bd);
 
        platform_set_drvdata(pdev, bd);
 
-       bd->props.max_brightness = HP680_MAX_INTENSITY;
        bd->props.brightness = HP680_DEFAULT_INTENSITY;
        hp680bl_send_intensity(bd);
 
index db9071fc56654add5b279b31845c75e34e7726cc..2f177b3a4885c1658685712703d266184b5b35ed 100644 (file)
@@ -101,10 +101,14 @@ static const struct backlight_ops jornada_bl_ops = {
 
 static int jornada_bl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        int ret;
        struct backlight_device *bd;
 
-       bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL, &jornada_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = BL_MAX_BRIGHT;
+       bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL,
+                                      &jornada_bl_ops, &props);
 
        if (IS_ERR(bd)) {
                ret = PTR_ERR(bd);
@@ -117,7 +121,6 @@ static int jornada_bl_probe(struct platform_device *pdev)
        /* note. make sure max brightness is set otherwise
           you will get seemingly non-related errors when
           trying to change brightness */
-       bd->props.max_brightness = BL_MAX_BRIGHT;
        jornada_bl_update_status(bd);
 
        platform_set_drvdata(pdev, bd);
index 939e7b830cf3f5afabaf104e694d465e63759bd5..f439a863228755d22621f57b4ecb384327ab3966 100644 (file)
@@ -141,20 +141,24 @@ static const struct backlight_ops kb3886bl_ops = {
 
 static int kb3886bl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct kb3886bl_machinfo *machinfo = pdev->dev.platform_data;
 
        bl_machinfo = machinfo;
        if (!machinfo->limit_mask)
                machinfo->limit_mask = -1;
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = machinfo->max_intensity;
        kb3886_backlight_device = backlight_device_register("kb3886-bl",
-               &pdev->dev, NULL, &kb3886bl_ops);
+                                                           &pdev->dev, NULL,
+                                                           &kb3886bl_ops,
+                                                           &props);
        if (IS_ERR(kb3886_backlight_device))
                return PTR_ERR(kb3886_backlight_device);
 
        platform_set_drvdata(pdev, kb3886_backlight_device);
 
-       kb3886_backlight_device->props.max_brightness = machinfo->max_intensity;
        kb3886_backlight_device->props.power = FB_BLANK_UNBLANK;
        kb3886_backlight_device->props.brightness = machinfo->default_intensity;
        backlight_update_status(kb3886_backlight_device);
index 00a9591b00030f8a3bf744ec124cc163ff061ad9..7571bc26071e7039f5b9c064604e5077cdf4bf79 100644 (file)
@@ -167,6 +167,7 @@ static int locomolcd_resume(struct locomo_dev *dev)
 
 static int locomolcd_probe(struct locomo_dev *ldev)
 {
+       struct backlight_properties props;
        unsigned long flags;
 
        local_irq_save(flags);
@@ -182,13 +183,16 @@ static int locomolcd_probe(struct locomo_dev *ldev)
 
        local_irq_restore(flags);
 
-       locomolcd_bl_device = backlight_device_register("locomo-bl", &ldev->dev, NULL, &locomobl_data);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 4;
+       locomolcd_bl_device = backlight_device_register("locomo-bl",
+                                                       &ldev->dev, NULL,
+                                                       &locomobl_data, &props);
 
        if (IS_ERR (locomolcd_bl_device))
                return PTR_ERR (locomolcd_bl_device);
 
        /* Set up frontlight so that screen is readable */
-       locomolcd_bl_device->props.max_brightness = 4,
        locomolcd_bl_device->props.brightness = 2;
        locomolcd_set_intensity(locomolcd_bl_device);
 
index c267069a52a3e926361c627be32b267c8b62754c..c91adaf492cf9eb52fb596516d128f43beb1d0a5 100644 (file)
@@ -104,6 +104,7 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
        struct max8925_backlight_pdata *pdata = NULL;
        struct max8925_backlight_data *data;
        struct backlight_device *bl;
+       struct backlight_properties props;
        struct resource *res;
        char name[MAX8925_NAME_SIZE];
        unsigned char value;
@@ -133,14 +134,15 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
        data->chip = chip;
        data->current_brightness = 0;
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = MAX_BRIGHTNESS;
        bl = backlight_device_register(name, &pdev->dev, data,
-                                       &max8925_backlight_ops);
+                                       &max8925_backlight_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&pdev->dev, "failed to register backlight\n");
                kfree(data);
                return PTR_ERR(bl);
        }
-       bl->props.max_brightness = MAX_BRIGHTNESS;
        bl->props.brightness = MAX_BRIGHTNESS;
 
        platform_set_drvdata(pdev, bl);
index 2e78b0784bdc8b1dae7083fbee8f052302a30227..0881358eeace669b04b06f17c68a8161ee054b44 100644 (file)
@@ -250,6 +250,7 @@ static const struct dmi_system_id __initdata mbp_device_table[] = {
 
 static int __init mbp_init(void)
 {
+       struct backlight_properties props;
        if (!dmi_check_system(mbp_device_table))
                return -ENODEV;
 
@@ -257,14 +258,17 @@ static int __init mbp_init(void)
                                                "Macbook Pro backlight"))
                return -ENXIO;
 
-       mbp_backlight_device = backlight_device_register("mbp_backlight",
-                                       NULL, NULL, &driver_data->backlight_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 15;
+       mbp_backlight_device = backlight_device_register("mbp_backlight", NULL,
+                                                        NULL,
+                                                        &driver_data->backlight_ops,
+                                                        &props);
        if (IS_ERR(mbp_backlight_device)) {
                release_region(driver_data->iostart, driver_data->iolen);
                return PTR_ERR(mbp_backlight_device);
        }
 
-       mbp_backlight_device->props.max_brightness = 15;
        mbp_backlight_device->props.brightness =
                driver_data->backlight_ops.get_brightness(mbp_backlight_device);
        backlight_update_status(mbp_backlight_device);
index a3a7f893817516aacbfa0da8e4aecf727c671932..333d28e6b062ff448550bf2352d3f8a4ff76694d 100644 (file)
@@ -132,6 +132,7 @@ static const struct backlight_ops omapbl_ops = {
 
 static int omapbl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct backlight_device *dev;
        struct omap_backlight *bl;
        struct omap_backlight_config *pdata = pdev->dev.platform_data;
@@ -143,7 +144,10 @@ static int omapbl_probe(struct platform_device *pdev)
        if (unlikely(!bl))
                return -ENOMEM;
 
-       dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = OMAPBL_MAX_INTENSITY;
+       dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops,
+                                       &props);
        if (IS_ERR(dev)) {
                kfree(bl);
                return PTR_ERR(dev);
@@ -160,7 +164,6 @@ static int omapbl_probe(struct platform_device *pdev)
        omap_cfg_reg(PWL);      /* Conflicts with UART3 */
 
        dev->props.fb_blank = FB_BLANK_UNBLANK;
-       dev->props.max_brightness = OMAPBL_MAX_INTENSITY;
        dev->props.brightness = pdata->default_intensity;
        omapbl_update_status(dev);
 
index 2ec16deb2397763d34003a0ba9a491a57deb7fd5..809278c90738945b8546bad7faeb7676f842114f 100644 (file)
@@ -61,6 +61,7 @@ static const struct backlight_ops progearbl_ops = {
 
 static int progearbl_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        u8 temp;
        struct backlight_device *progear_backlight_device;
        int ret;
@@ -82,9 +83,12 @@ static int progearbl_probe(struct platform_device *pdev)
        pci_read_config_byte(sb_dev, SB_MPS1, &temp);
        pci_write_config_byte(sb_dev, SB_MPS1, temp | 0x20);
 
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
        progear_backlight_device = backlight_device_register("progear-bl",
                                                             &pdev->dev, NULL,
-                                                            &progearbl_ops);
+                                                            &progearbl_ops,
+                                                            &props);
        if (IS_ERR(progear_backlight_device)) {
                ret = PTR_ERR(progear_backlight_device);
                goto put_sb;
@@ -94,7 +98,6 @@ static int progearbl_probe(struct platform_device *pdev)
 
        progear_backlight_device->props.power = FB_BLANK_UNBLANK;
        progear_backlight_device->props.brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
-       progear_backlight_device->props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
        progearbl_set_intensity(progear_backlight_device);
 
        return 0;
index 9d2ec2a1cce8fff721d40680277d45ac5bc1bb55..b89eebc3f77d357c0f68c64aa45b0b68b65f9909 100644 (file)
@@ -65,6 +65,7 @@ static const struct backlight_ops pwm_backlight_ops = {
 
 static int pwm_backlight_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct platform_pwm_backlight_data *data = pdev->dev.platform_data;
        struct backlight_device *bl;
        struct pwm_bl_data *pb;
@@ -100,15 +101,16 @@ static int pwm_backlight_probe(struct platform_device *pdev)
        } else
                dev_dbg(&pdev->dev, "got pwm for backlight\n");
 
-       bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev,
-                       pb, &pwm_backlight_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = data->max_brightness;
+       bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
+                                      &pwm_backlight_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&pdev->dev, "failed to register backlight\n");
                ret = PTR_ERR(bl);
                goto err_bl;
        }
 
-       bl->props.max_brightness = data->max_brightness;
        bl->props.brightness = data->dft_brightness;
        backlight_update_status(bl);
 
index e14ce4d469f57f1ed6525ba53113bcbd6bca6913..f57bbf170049c8c7444210155a4d143a43ec0090 100644 (file)
@@ -80,6 +80,7 @@ static const struct backlight_ops bl_ops = {
 static int __devinit tosa_bl_probe(struct i2c_client *client,
                const struct i2c_device_id *id)
 {
+       struct backlight_properties props;
        struct tosa_bl_data *data = kzalloc(sizeof(struct tosa_bl_data), GFP_KERNEL);
        int ret = 0;
        if (!data)
@@ -99,15 +100,16 @@ static int __devinit tosa_bl_probe(struct i2c_client *client,
        i2c_set_clientdata(client, data);
        data->i2c = client;
 
-       data->bl = backlight_device_register("tosa-bl", &client->dev,
-                       data, &bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 512 - 1;
+       data->bl = backlight_device_register("tosa-bl", &client->dev, data,
+                                            &bl_ops, &props);
        if (IS_ERR(data->bl)) {
                ret = PTR_ERR(data->bl);
                goto err_reg;
        }
 
        data->bl->props.brightness = 69;
-       data->bl->props.max_brightness = 512 - 1;
        data->bl->props.power = FB_BLANK_UNBLANK;
 
        backlight_update_status(data->bl);
index e32add37a203453558c80a6c195276cb402094c6..a4312709fb1bfffe83e83a6152873a8ad65e11b0 100644 (file)
@@ -125,6 +125,7 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
        struct wm831x_backlight_pdata *pdata;
        struct wm831x_backlight_data *data;
        struct backlight_device *bl;
+       struct backlight_properties props;
        int ret, i, max_isel, isink_reg, dcdc_cfg;
 
        /* We need platform data */
@@ -191,15 +192,15 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
        data->current_brightness = 0;
        data->isink_reg = isink_reg;
 
-       bl = backlight_device_register("wm831x", &pdev->dev,
-                       data, &wm831x_backlight_ops);
+       props.max_brightness = max_isel;
+       bl = backlight_device_register("wm831x", &pdev->dev, data,
+                                      &wm831x_backlight_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&pdev->dev, "failed to register backlight\n");
                kfree(data);
                return PTR_ERR(bl);
        }
 
-       bl->props.max_brightness = max_isel;
        bl->props.brightness = max_isel;
 
        platform_set_drvdata(pdev, bl);
index 814312a7452fc389a9c9c0314654bb6174a9b2f4..54df3d44af8f34c42cc5d1b023d9f46b76c6ff77 100644 (file)
@@ -501,6 +501,7 @@ static irqreturn_t bfin_bf54x_irq_error(int irq, void *dev_id)
 
 static int __devinit bfin_bf54x_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct bfin_bf54xfb_info *info;
        struct fb_info *fbinfo;
        int ret;
@@ -645,10 +646,10 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev)
                goto out8;
        }
 #ifndef NO_BL_SUPPORT
-       bl_dev =
-           backlight_device_register("bf54x-bl", NULL, NULL,
-                                     &bfin_lq043fb_bl_ops);
-       bl_dev->props.max_brightness = 255;
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 255;
+       bl_dev = backlight_device_register("bf54x-bl", NULL, NULL,
+                                          &bfin_lq043fb_bl_ops, &props);
 
        lcd_dev = lcd_device_register(DRIVER_NAME, &pdev->dev, NULL, &bfin_lcd_ops);
        lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
index 5653d083a9837c6de9c1e7ba9da613faacb8c489..3a8e811a7e9ffe56da3e04ec76ba80f9a0456da7 100644 (file)
@@ -419,6 +419,7 @@ static irqreturn_t bfin_t350mcqb_irq_error(int irq, void *dev_id)
 
 static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
 {
+       struct backlight_properties props;
        struct bfin_t350mcqbfb_info *info;
        struct fb_info *fbinfo;
        int ret;
@@ -540,10 +541,10 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
                goto out8;
        }
 #ifndef NO_BL_SUPPORT
-       bl_dev =
-           backlight_device_register("bf52x-bl", NULL, NULL,
-                                     &bfin_lq043fb_bl_ops);
-       bl_dev->props.max_brightness = 255;
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = 255;
+       bl_dev = backlight_device_register("bf52x-bl", NULL, NULL,
+                                          &bfin_lq043fb_bl_ops, &props);
 
        lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops);
        lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
index 443e3c85a9a0a677c12c2840899b55c209b261be..2fb552a6f32cf52910e551f989dbdbf6c0d30c74 100644 (file)
@@ -94,6 +94,7 @@ static struct backlight_ops nvidia_bl_ops = {
 
 void nvidia_bl_init(struct nvidia_par *par)
 {
+       struct backlight_properties props;
        struct fb_info *info = pci_get_drvdata(par->pci_dev);
        struct backlight_device *bd;
        char name[12];
@@ -109,7 +110,10 @@ void nvidia_bl_init(struct nvidia_par *par)
 
        snprintf(name, sizeof(name), "nvidiabl%d", info->node);
 
-       bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops,
+                                      &props);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "nvidia: Backlight registration failed\n");
@@ -121,7 +125,6 @@ void nvidia_bl_init(struct nvidia_par *par)
                0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL,
                0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL);
 
-       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
        bd->props.brightness = bd->props.max_brightness;
        bd->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
index fcd6a61a91ebf73d519385c9c1c3a2247a30da62..59769e85d41cca70c3499dbfa34628978ff2c228 100644 (file)
@@ -486,6 +486,7 @@ static struct attribute_group taal_attr_group = {
 
 static int taal_probe(struct omap_dss_device *dssdev)
 {
+       struct backlight_properties props;
        struct taal_data *td;
        struct backlight_device *bldev;
        int r;
@@ -520,11 +521,16 @@ static int taal_probe(struct omap_dss_device *dssdev)
 
        /* if no platform set_backlight() defined, presume DSI backlight
         * control */
+       memset(&props, 0, sizeof(struct backlight_properties));
        if (!dssdev->set_backlight)
                td->use_dsi_bl = true;
 
+       if (td->use_dsi_bl)
+               props.max_brightness = 255;
+       else
+               props.max_brightness = 127;
        bldev = backlight_device_register("taal", &dssdev->dev, dssdev,
-                       &taal_bl_ops);
+                                         &taal_bl_ops, &props);
        if (IS_ERR(bldev)) {
                r = PTR_ERR(bldev);
                goto err2;
@@ -534,13 +540,10 @@ static int taal_probe(struct omap_dss_device *dssdev)
 
        bldev->props.fb_blank = FB_BLANK_UNBLANK;
        bldev->props.power = FB_BLANK_UNBLANK;
-       if (td->use_dsi_bl) {
-               bldev->props.max_brightness = 255;
+       if (td->use_dsi_bl)
                bldev->props.brightness = 255;
-       } else {
-               bldev->props.max_brightness = 127;
+       else
                bldev->props.brightness = 127;
-       }
 
        taal_bl_update_status(bldev);
 
index d94c57ffbdb1661b4c7b3476ce406275388980ca..618f36bec10d10ed5ece287e19e02909506e11a3 100644 (file)
@@ -338,6 +338,7 @@ static struct backlight_ops riva_bl_ops = {
 
 static void riva_bl_init(struct riva_par *par)
 {
+       struct backlight_properties props;
        struct fb_info *info = pci_get_drvdata(par->pdev);
        struct backlight_device *bd;
        char name[12];
@@ -353,7 +354,10 @@ static void riva_bl_init(struct riva_par *par)
 
        snprintf(name, sizeof(name), "rivabl%d", info->node);
 
-       bd = backlight_device_register(name, info->dev, par, &riva_bl_ops);
+       memset(&props, 0, sizeof(struct backlight_properties));
+       props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+       bd = backlight_device_register(name, info->dev, par, &riva_bl_ops,
+                                      &props);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "riva: Backlight registration failed\n");
@@ -365,7 +369,6 @@ static void riva_bl_init(struct riva_par *par)
                MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL,
                FB_BACKLIGHT_MAX);
 
-       bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
        bd->props.brightness = bd->props.max_brightness;
        bd->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
index 21cd866d24cd089952a7b576761ac15646edcf70..4a3d52e545e186876f2e36d679c9812e4ce1d8a0 100644 (file)
@@ -103,7 +103,8 @@ static inline void backlight_update_status(struct backlight_device *bd)
 }
 
 extern struct backlight_device *backlight_device_register(const char *name,
-       struct device *dev, void *devdata, const struct backlight_ops *ops);
+       struct device *dev, void *devdata, const struct backlight_ops *ops,
+       const struct backlight_properties *props);
 extern void backlight_device_unregister(struct backlight_device *bd);
 extern void backlight_force_update(struct backlight_device *bd,
                                   enum backlight_update_reason reason);