Commit a19a6ee6cad2b20292a774c2f56ba8039b0fac9c

Authored by Matthew Garrett
Committed by Richard Purdie
1 parent 57e148b6a9

backlight: Allow properties to be passed at registration

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>

Showing 49 changed files with 271 additions and 151 deletions Side-by-side Diff

drivers/acpi/video.c
... ... @@ -998,6 +998,7 @@
998 998 }
999 999  
1000 1000 if (acpi_video_backlight_support()) {
  1001 + struct backlight_properties props;
1001 1002 int result;
1002 1003 static int count = 0;
1003 1004 char *name;
1004 1005  
... ... @@ -1010,12 +1011,14 @@
1010 1011 return;
1011 1012  
1012 1013 sprintf(name, "acpi_video%d", count++);
1013   - device->backlight = backlight_device_register(name,
1014   - NULL, device, &acpi_backlight_ops);
  1014 + memset(&props, 0, sizeof(struct backlight_properties));
  1015 + props.max_brightness = device->brightness->count - 3;
  1016 + device->backlight = backlight_device_register(name, NULL, device,
  1017 + &acpi_backlight_ops,
  1018 + &props);
1015 1019 kfree(name);
1016 1020 if (IS_ERR(device->backlight))
1017 1021 return;
1018   - device->backlight->props.max_brightness = device->brightness->count-3;
1019 1022  
1020 1023 result = sysfs_create_link(&device->backlight->dev.kobj,
1021 1024 &device->dev->dev.kobj, "device");
drivers/gpu/drm/nouveau/nouveau_backlight.c
... ... @@ -89,19 +89,21 @@
89 89  
90 90 static int nouveau_nv40_backlight_init(struct drm_device *dev)
91 91 {
  92 + struct backlight_properties props;
92 93 struct drm_nouveau_private *dev_priv = dev->dev_private;
93 94 struct backlight_device *bd;
94 95  
95 96 if (!(nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
96 97 return 0;
97 98  
  99 + memset(&props, 0, sizeof(struct backlight_properties));
  100 + props.max_brightness = 31;
98 101 bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
99   - &nv40_bl_ops);
  102 + &nv40_bl_ops, &props);
100 103 if (IS_ERR(bd))
101 104 return PTR_ERR(bd);
102 105  
103 106 dev_priv->backlight = bd;
104   - bd->props.max_brightness = 31;
105 107 bd->props.brightness = nv40_get_intensity(bd);
106 108 backlight_update_status(bd);
107 109  
108 110  
109 111  
110 112  
... ... @@ -110,19 +112,21 @@
110 112  
111 113 static int nouveau_nv50_backlight_init(struct drm_device *dev)
112 114 {
  115 + struct backlight_properties props;
113 116 struct drm_nouveau_private *dev_priv = dev->dev_private;
114 117 struct backlight_device *bd;
115 118  
116 119 if (!nv_rd32(dev, NV50_PDISPLAY_SOR_BACKLIGHT))
117 120 return 0;
118 121  
  122 + memset(&props, 0, sizeof(struct backlight_properties));
  123 + props.max_brightness = 1025;
119 124 bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
120   - &nv50_bl_ops);
  125 + &nv50_bl_ops, &props);
121 126 if (IS_ERR(bd))
122 127 return PTR_ERR(bd);
123 128  
124 129 dev_priv->backlight = bd;
125   - bd->props.max_brightness = 1025;
126 130 bd->props.brightness = nv50_get_intensity(bd);
127 131 backlight_update_status(bd);
128 132 return 0;
drivers/macintosh/via-pmu-backlight.c
... ... @@ -144,6 +144,7 @@
144 144  
145 145 void __init pmu_backlight_init()
146 146 {
  147 + struct backlight_properties props;
147 148 struct backlight_device *bd;
148 149 char name[10];
149 150 int level, autosave;
150 151  
... ... @@ -161,13 +162,15 @@
161 162  
162 163 snprintf(name, sizeof(name), "pmubl");
163 164  
164   - bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data);
  165 + memset(&props, 0, sizeof(struct backlight_properties));
  166 + props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
  167 + bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data,
  168 + &props);
165 169 if (IS_ERR(bd)) {
166 170 printk(KERN_ERR "PMU Backlight registration failed\n");
167 171 return;
168 172 }
169 173 uses_pmu_bl = 1;
170   - bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
171 174 pmu_backlight_init_curve(0x7F, 0x46, 0x0E);
172 175  
173 176 level = bd->props.max_brightness;
drivers/platform/x86/acer-wmi.c
... ... @@ -922,9 +922,13 @@
922 922  
923 923 static int __devinit acer_backlight_init(struct device *dev)
924 924 {
  925 + struct backlight_properties props;
925 926 struct backlight_device *bd;
926 927  
927   - bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops);
  928 + memset(&props, 0, sizeof(struct backlight_properties));
  929 + props.max_brightness = max_brightness;
  930 + bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops,
  931 + &props);
928 932 if (IS_ERR(bd)) {
929 933 printk(ACER_ERR "Could not register Acer backlight device\n");
930 934 acer_backlight_device = NULL;
... ... @@ -935,7 +939,6 @@
935 939  
936 940 bd->props.power = FB_BLANK_UNBLANK;
937 941 bd->props.brightness = read_brightness(bd);
938   - bd->props.max_brightness = max_brightness;
939 942 backlight_update_status(bd);
940 943 return 0;
941 944 }
drivers/platform/x86/asus-laptop.c
... ... @@ -639,12 +639,16 @@
639 639 {
640 640 struct backlight_device *bd;
641 641 struct device *dev = &asus->platform_device->dev;
  642 + struct backlight_properties props;
642 643  
643 644 if (!acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) &&
644 645 !acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) &&
645 646 lcd_switch_handle) {
  647 + memset(&props, 0, sizeof(struct backlight_properties));
  648 + props.max_brightness = 15;
  649 +
646 650 bd = backlight_device_register(ASUS_LAPTOP_FILE, dev,
647   - asus, &asusbl_ops);
  651 + asus, &asusbl_ops, &props);
648 652 if (IS_ERR(bd)) {
649 653 pr_err("Could not register asus backlight device\n");
650 654 asus->backlight_device = NULL;
... ... @@ -653,7 +657,6 @@
653 657  
654 658 asus->backlight_device = bd;
655 659  
656   - bd->props.max_brightness = 15;
657 660 bd->props.power = FB_BLANK_UNBLANK;
658 661 bd->props.brightness = asus_read_brightness(bd);
659 662 backlight_update_status(bd);
drivers/platform/x86/asus_acpi.c
... ... @@ -1481,6 +1481,7 @@
1481 1481  
1482 1482 static int __init asus_acpi_init(void)
1483 1483 {
  1484 + struct backlight_properties props;
1484 1485 int result;
1485 1486  
1486 1487 result = acpi_bus_register_driver(&asus_hotk_driver);
1487 1488  
1488 1489  
... ... @@ -1507,15 +1508,17 @@
1507 1508 return -ENODEV;
1508 1509 }
1509 1510  
  1511 + memset(&props, 0, sizeof(struct backlight_properties));
  1512 + props.max_brightness = 15;
1510 1513 asus_backlight_device = backlight_device_register("asus", NULL, NULL,
1511   - &asus_backlight_data);
  1514 + &asus_backlight_data,
  1515 + &props);
1512 1516 if (IS_ERR(asus_backlight_device)) {
1513 1517 printk(KERN_ERR "Could not register asus backlight device\n");
1514 1518 asus_backlight_device = NULL;
1515 1519 asus_acpi_exit();
1516 1520 return -ENODEV;
1517 1521 }
1518   - asus_backlight_device->props.max_brightness = 15;
1519 1522  
1520 1523 return 0;
1521 1524 }
drivers/platform/x86/classmate-laptop.c
... ... @@ -462,11 +462,13 @@
462 462  
463 463 static int cmpc_bl_add(struct acpi_device *acpi)
464 464 {
  465 + struct backlight_properties props;
465 466 struct backlight_device *bd;
466 467  
467   - bd = backlight_device_register("cmpc_bl", &acpi->dev,
468   - acpi->handle, &cmpc_bl_ops);
469   - bd->props.max_brightness = 7;
  468 + memset(&props, 0, sizeof(struct backlight_properties));
  469 + props.max_brightness = 7;
  470 + bd = backlight_device_register("cmpc_bl", &acpi->dev, acpi->handle,
  471 + &cmpc_bl_ops, &props);
470 472 dev_set_drvdata(&acpi->dev, bd);
471 473 return 0;
472 474 }
drivers/platform/x86/compal-laptop.c
... ... @@ -291,12 +291,15 @@
291 291 /* Register backlight stuff */
292 292  
293 293 if (!acpi_video_backlight_support()) {
294   - compalbl_device = backlight_device_register("compal-laptop", NULL, NULL,
295   - &compalbl_ops);
  294 + struct backlight_properties props;
  295 + memset(&props, 0, sizeof(struct backlight_properties));
  296 + props.max_brightness = COMPAL_LCD_LEVEL_MAX - 1;
  297 + compalbl_device = backlight_device_register("compal-laptop",
  298 + NULL, NULL,
  299 + &compalbl_ops,
  300 + &props);
296 301 if (IS_ERR(compalbl_device))
297 302 return PTR_ERR(compalbl_device);
298   -
299   - compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1;
300 303 }
301 304  
302 305 ret = platform_driver_register(&compal_driver);
drivers/platform/x86/dell-laptop.c
... ... @@ -559,10 +559,14 @@
559 559 release_buffer();
560 560  
561 561 if (max_intensity) {
562   - dell_backlight_device = backlight_device_register(
563   - "dell_backlight",
564   - &platform_device->dev, NULL,
565   - &dell_ops);
  562 + struct backlight_properties props;
  563 + memset(&props, 0, sizeof(struct backlight_properties));
  564 + props.max_brightness = max_intensity;
  565 + dell_backlight_device = backlight_device_register("dell_backlight",
  566 + &platform_device->dev,
  567 + NULL,
  568 + &dell_ops,
  569 + &props);
566 570  
567 571 if (IS_ERR(dell_backlight_device)) {
568 572 ret = PTR_ERR(dell_backlight_device);
... ... @@ -570,7 +574,6 @@
570 574 goto fail_backlight;
571 575 }
572 576  
573   - dell_backlight_device->props.max_brightness = max_intensity;
574 577 dell_backlight_device->props.brightness =
575 578 dell_get_intensity(dell_backlight_device);
576 579 backlight_update_status(dell_backlight_device);
drivers/platform/x86/eeepc-laptop.c
... ... @@ -1131,18 +1131,20 @@
1131 1131  
1132 1132 static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
1133 1133 {
  1134 + struct backlight_properties props;
1134 1135 struct backlight_device *bd;
1135 1136  
  1137 + memset(&props, 0, sizeof(struct backlight_properties));
  1138 + props.max_brightness = 15;
1136 1139 bd = backlight_device_register(EEEPC_LAPTOP_FILE,
1137   - &eeepc->platform_device->dev,
1138   - eeepc, &eeepcbl_ops);
  1140 + &eeepc->platform_device->dev, eeepc,
  1141 + &eeepcbl_ops, &props);
1139 1142 if (IS_ERR(bd)) {
1140 1143 pr_err("Could not register eeepc backlight device\n");
1141 1144 eeepc->backlight_device = NULL;
1142 1145 return PTR_ERR(bd);
1143 1146 }
1144 1147 eeepc->backlight_device = bd;
1145   - bd->props.max_brightness = 15;
1146 1148 bd->props.brightness = read_brightness(bd);
1147 1149 bd->props.power = FB_BLANK_UNBLANK;
1148 1150 backlight_update_status(bd);
drivers/platform/x86/fujitsu-laptop.c
... ... @@ -1126,16 +1126,20 @@
1126 1126 /* Register backlight stuff */
1127 1127  
1128 1128 if (!acpi_video_backlight_support()) {
1129   - fujitsu->bl_device =
1130   - backlight_device_register("fujitsu-laptop", NULL, NULL,
1131   - &fujitsubl_ops);
  1129 + struct backlight_properties props;
  1130 +
  1131 + memset(&props, 0, sizeof(struct backlight_properties));
  1132 + max_brightness = fujitsu->max_brightness;
  1133 + props.max_brightness = max_brightness - 1;
  1134 + fujitsu->bl_device = backlight_device_register("fujitsu-laptop",
  1135 + NULL, NULL,
  1136 + &fujitsubl_ops,
  1137 + &props);
1132 1138 if (IS_ERR(fujitsu->bl_device)) {
1133 1139 ret = PTR_ERR(fujitsu->bl_device);
1134 1140 fujitsu->bl_device = NULL;
1135 1141 goto fail_sysfs_group;
1136 1142 }
1137   - max_brightness = fujitsu->max_brightness;
1138   - fujitsu->bl_device->props.max_brightness = max_brightness - 1;
1139 1143 fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
1140 1144 }
1141 1145  
drivers/platform/x86/msi-laptop.c
... ... @@ -683,11 +683,14 @@
683 683 printk(KERN_INFO "MSI: Brightness ignored, must be controlled "
684 684 "by ACPI video driver\n");
685 685 } else {
  686 + struct backlight_properties props;
  687 + memset(&props, 0, sizeof(struct backlight_properties));
  688 + props.max_brightness = MSI_LCD_LEVEL_MAX - 1;
686 689 msibl_device = backlight_device_register("msi-laptop-bl", NULL,
687   - NULL, &msibl_ops);
  690 + NULL, &msibl_ops,
  691 + &props);
688 692 if (IS_ERR(msibl_device))
689 693 return PTR_ERR(msibl_device);
690   - msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1;
691 694 }
692 695  
693 696 ret = platform_driver_register(&msipf_driver);
drivers/platform/x86/msi-wmi.c
... ... @@ -249,12 +249,15 @@
249 249 goto err_uninstall_notifier;
250 250  
251 251 if (!acpi_video_backlight_support()) {
252   - backlight = backlight_device_register(DRV_NAME,
253   - NULL, NULL, &msi_backlight_ops);
  252 + struct backlight_properties props;
  253 + memset(&props, 0, sizeof(struct backlight_properties));
  254 + props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
  255 + backlight = backlight_device_register(DRV_NAME, NULL, NULL,
  256 + &msi_backlight_ops,
  257 + &props);
254 258 if (IS_ERR(backlight))
255 259 goto err_free_input;
256 260  
257   - backlight->props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
258 261 err = bl_get(NULL);
259 262 if (err < 0)
260 263 goto err_free_backlight;
drivers/platform/x86/panasonic-laptop.c
... ... @@ -600,6 +600,7 @@
600 600  
601 601 static int acpi_pcc_hotkey_add(struct acpi_device *device)
602 602 {
  603 + struct backlight_properties props;
603 604 struct pcc_acpi *pcc;
604 605 int num_sifr, result;
605 606  
606 607  
607 608  
608 609  
609 610  
... ... @@ -637,24 +638,23 @@
637 638 if (result) {
638 639 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
639 640 "Error installing keyinput handler\n"));
640   - goto out_sinf;
  641 + goto out_hotkey;
641 642 }
642 643  
643   - /* initialize backlight */
644   - pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
645   - &pcc_backlight_ops);
646   - if (IS_ERR(pcc->backlight))
647   - goto out_input;
648   -
649 644 if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) {
650 645 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
651 646 "Couldn't retrieve BIOS data\n"));
652   - goto out_backlight;
  647 + goto out_input;
653 648 }
  649 + /* initialize backlight */
  650 + memset(&props, 0, sizeof(struct backlight_properties));
  651 + props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT];
  652 + pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
  653 + &pcc_backlight_ops, &props);
  654 + if (IS_ERR(pcc->backlight))
  655 + goto out_sinf;
654 656  
655 657 /* read the initial brightness setting from the hardware */
656   - pcc->backlight->props.max_brightness =
657   - pcc->sinf[SINF_AC_MAX_BRIGHT];
658 658 pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT];
659 659  
660 660 /* read the initial sticky key mode from the hardware */
661 661  
... ... @@ -669,12 +669,12 @@
669 669  
670 670 out_backlight:
671 671 backlight_device_unregister(pcc->backlight);
  672 +out_sinf:
  673 + kfree(pcc->sinf);
672 674 out_input:
673 675 input_unregister_device(pcc->input_dev);
674 676 /* no need to input_free_device() since core input API refcount and
675 677 * free()s the device */
676   -out_sinf:
677   - kfree(pcc->sinf);
678 678 out_hotkey:
679 679 kfree(pcc);
680 680  
drivers/platform/x86/sony-laptop.c
... ... @@ -1291,9 +1291,13 @@
1291 1291 "controlled by ACPI video driver\n");
1292 1292 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
1293 1293 &handle))) {
  1294 + struct backlight_properties props;
  1295 + memset(&props, 0, sizeof(struct backlight_properties));
  1296 + props.max_brightness = SONY_MAX_BRIGHTNESS - 1;
1294 1297 sony_backlight_device = backlight_device_register("sony", NULL,
1295 1298 NULL,
1296   - &sony_backlight_ops);
  1299 + &sony_backlight_ops,
  1300 + &props);
1297 1301  
1298 1302 if (IS_ERR(sony_backlight_device)) {
1299 1303 printk(KERN_WARNING DRV_PFX "unable to register backlight device\n");
... ... @@ -1302,8 +1306,6 @@
1302 1306 sony_backlight_device->props.brightness =
1303 1307 sony_backlight_get_brightness
1304 1308 (sony_backlight_device);
1305   - sony_backlight_device->props.max_brightness =
1306   - SONY_MAX_BRIGHTNESS - 1;
1307 1309 }
1308 1310  
1309 1311 }
drivers/platform/x86/thinkpad_acpi.c
... ... @@ -6170,6 +6170,7 @@
6170 6170  
6171 6171 static int __init brightness_init(struct ibm_init_struct *iibm)
6172 6172 {
  6173 + struct backlight_properties props;
6173 6174 int b;
6174 6175 unsigned long quirks;
6175 6176  
... ... @@ -6259,9 +6260,12 @@
6259 6260 printk(TPACPI_INFO
6260 6261 "detected a 16-level brightness capable ThinkPad\n");
6261 6262  
6262   - ibm_backlight_device = backlight_device_register(
6263   - TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL,
6264   - &ibm_backlight_data);
  6263 + memset(&props, 0, sizeof(struct backlight_properties));
  6264 + props.max_brightness = (tp_features.bright_16levels) ? 15 : 7;
  6265 + ibm_backlight_device = backlight_device_register(TPACPI_BACKLIGHT_DEV_NAME,
  6266 + NULL, NULL,
  6267 + &ibm_backlight_data,
  6268 + &props);
6265 6269 if (IS_ERR(ibm_backlight_device)) {
6266 6270 int rc = PTR_ERR(ibm_backlight_device);
6267 6271 ibm_backlight_device = NULL;
... ... @@ -6280,8 +6284,6 @@
6280 6284 "or not on your ThinkPad\n", TPACPI_MAIL);
6281 6285 }
6282 6286  
6283   - ibm_backlight_device->props.max_brightness =
6284   - (tp_features.bright_16levels)? 15 : 7;
6285 6287 ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK;
6286 6288 backlight_update_status(ibm_backlight_device);
6287 6289  
drivers/platform/x86/toshiba_acpi.c
... ... @@ -924,6 +924,7 @@
924 924 u32 hci_result;
925 925 bool bt_present;
926 926 int ret = 0;
  927 + struct backlight_properties props;
927 928  
928 929 if (acpi_disabled)
929 930 return -ENODEV;
930 931  
... ... @@ -974,10 +975,12 @@
974 975 }
975 976 }
976 977  
  978 + props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
977 979 toshiba_backlight_device = backlight_device_register("toshiba",
978   - &toshiba_acpi.p_dev->dev,
979   - NULL,
980   - &toshiba_backlight_data);
  980 + &toshiba_acpi.p_dev->dev,
  981 + NULL,
  982 + &toshiba_backlight_data,
  983 + &props);
981 984 if (IS_ERR(toshiba_backlight_device)) {
982 985 ret = PTR_ERR(toshiba_backlight_device);
983 986  
... ... @@ -986,7 +989,6 @@
986 989 toshiba_acpi_exit();
987 990 return ret;
988 991 }
989   - toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
990 992  
991 993 /* Register rfkill switch for Bluetooth */
992 994 if (hci_get_bt_present(&bt_present) == HCI_SUCCESS && bt_present) {
drivers/staging/samsung-laptop/samsung-laptop.c
... ... @@ -394,6 +394,7 @@
394 394  
395 395 static int __init samsung_init(void)
396 396 {
  397 + struct backlight_properties props;
397 398 struct sabi_retval sretval;
398 399 const char *testStr = "SECLINUX";
399 400 void __iomem *memcheck;
400 401  
401 402  
... ... @@ -486,12 +487,14 @@
486 487 goto error_no_platform;
487 488  
488 489 /* create a backlight device to talk to this one */
  490 + memset(&props, 0, sizeof(struct backlight_properties));
  491 + props.max_brightness = MAX_BRIGHT;
489 492 backlight_device = backlight_device_register("samsung", &sdev->dev,
490   - NULL, &backlight_ops);
  493 + NULL, &backlight_ops,
  494 + &props);
491 495 if (IS_ERR(backlight_device))
492 496 goto error_no_backlight;
493 497  
494   - backlight_device->props.max_brightness = MAX_BRIGHT;
495 498 backlight_device->props.brightness = read_brightness();
496 499 backlight_device->props.power = FB_BLANK_UNBLANK;
497 500 backlight_update_status(backlight_device);
drivers/usb/misc/appledisplay.c
... ... @@ -202,6 +202,7 @@
202 202 static int appledisplay_probe(struct usb_interface *iface,
203 203 const struct usb_device_id *id)
204 204 {
  205 + struct backlight_properties props;
205 206 struct appledisplay *pdata;
206 207 struct usb_device *udev = interface_to_usbdev(iface);
207 208 struct usb_host_interface *iface_desc;
208 209  
209 210  
... ... @@ -279,15 +280,15 @@
279 280 /* Register backlight device */
280 281 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
281 282 atomic_inc_return(&count_displays) - 1);
  283 + memset(&props, 0, sizeof(struct backlight_properties));
  284 + props.max_brightness = 0xff;
282 285 pdata->bd = backlight_device_register(bl_name, NULL, pdata,
283   - &appledisplay_bl_data);
  286 + &appledisplay_bl_data, &props);
284 287 if (IS_ERR(pdata->bd)) {
285 288 dev_err(&iface->dev, "Backlight registration failed\n");
286 289 retval = PTR_ERR(pdata->bd);
287 290 goto error;
288 291 }
289   -
290   - pdata->bd->props.max_brightness = 0xff;
291 292  
292 293 /* Try to get brightness */
293 294 brightness = appledisplay_bl_get_brightness(pdata->bd);
drivers/video/atmel_lcdfb.c
... ... @@ -117,6 +117,7 @@
117 117  
118 118 static void init_backlight(struct atmel_lcdfb_info *sinfo)
119 119 {
  120 + struct backlight_properties props;
120 121 struct backlight_device *bl;
121 122  
122 123 sinfo->bl_power = FB_BLANK_UNBLANK;
... ... @@ -124,8 +125,10 @@
124 125 if (sinfo->backlight)
125 126 return;
126 127  
127   - bl = backlight_device_register("backlight", &sinfo->pdev->dev,
128   - sinfo, &atmel_lcdc_bl_ops);
  128 + memset(&props, 0, sizeof(struct backlight_properties));
  129 + props.max_brightness = 0xff;
  130 + bl = backlight_device_register("backlight", &sinfo->pdev->dev, sinfo,
  131 + &atmel_lcdc_bl_ops, &props);
129 132 if (IS_ERR(bl)) {
130 133 dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n",
131 134 PTR_ERR(bl));
... ... @@ -135,7 +138,6 @@
135 138  
136 139 bl->props.power = FB_BLANK_UNBLANK;
137 140 bl->props.fb_blank = FB_BLANK_UNBLANK;
138   - bl->props.max_brightness = 0xff;
139 141 bl->props.brightness = atmel_bl_get_brightness(bl);
140 142 }
141 143  
drivers/video/aty/aty128fb.c
... ... @@ -1802,6 +1802,7 @@
1802 1802  
1803 1803 static void aty128_bl_init(struct aty128fb_par *par)
1804 1804 {
  1805 + struct backlight_properties props;
1805 1806 struct fb_info *info = pci_get_drvdata(par->pdev);
1806 1807 struct backlight_device *bd;
1807 1808 char name[12];
... ... @@ -1817,7 +1818,10 @@
1817 1818  
1818 1819 snprintf(name, sizeof(name), "aty128bl%d", info->node);
1819 1820  
1820   - bd = backlight_device_register(name, info->dev, par, &aty128_bl_data);
  1821 + memset(&props, 0, sizeof(struct backlight_properties));
  1822 + props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
  1823 + bd = backlight_device_register(name, info->dev, par, &aty128_bl_data,
  1824 + &props);
1821 1825 if (IS_ERR(bd)) {
1822 1826 info->bl_dev = NULL;
1823 1827 printk(KERN_WARNING "aty128: Backlight registration failed\n");
... ... @@ -1829,7 +1833,6 @@
1829 1833 63 * FB_BACKLIGHT_MAX / MAX_LEVEL,
1830 1834 219 * FB_BACKLIGHT_MAX / MAX_LEVEL);
1831 1835  
1832   - bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
1833 1836 bd->props.brightness = bd->props.max_brightness;
1834 1837 bd->props.power = FB_BLANK_UNBLANK;
1835 1838 backlight_update_status(bd);
drivers/video/aty/atyfb_base.c
... ... @@ -2232,6 +2232,7 @@
2232 2232  
2233 2233 static void aty_bl_init(struct atyfb_par *par)
2234 2234 {
  2235 + struct backlight_properties props;
2235 2236 struct fb_info *info = pci_get_drvdata(par->pdev);
2236 2237 struct backlight_device *bd;
2237 2238 char name[12];
... ... @@ -2243,7 +2244,10 @@
2243 2244  
2244 2245 snprintf(name, sizeof(name), "atybl%d", info->node);
2245 2246  
2246   - bd = backlight_device_register(name, info->dev, par, &aty_bl_data);
  2247 + memset(&props, 0, sizeof(struct backlight_properties));
  2248 + props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
  2249 + bd = backlight_device_register(name, info->dev, par, &aty_bl_data,
  2250 + &props);
2247 2251 if (IS_ERR(bd)) {
2248 2252 info->bl_dev = NULL;
2249 2253 printk(KERN_WARNING "aty: Backlight registration failed\n");
... ... @@ -2255,7 +2259,6 @@
2255 2259 0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL,
2256 2260 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL);
2257 2261  
2258   - bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
2259 2262 bd->props.brightness = bd->props.max_brightness;
2260 2263 bd->props.power = FB_BLANK_UNBLANK;
2261 2264 backlight_update_status(bd);
drivers/video/aty/radeon_backlight.c
... ... @@ -134,6 +134,7 @@
134 134  
135 135 void radeonfb_bl_init(struct radeonfb_info *rinfo)
136 136 {
  137 + struct backlight_properties props;
137 138 struct backlight_device *bd;
138 139 struct radeon_bl_privdata *pdata;
139 140 char name[12];
... ... @@ -155,7 +156,10 @@
155 156  
156 157 snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node);
157 158  
158   - bd = backlight_device_register(name, rinfo->info->dev, pdata, &radeon_bl_data);
  159 + memset(&props, 0, sizeof(struct backlight_properties));
  160 + props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
  161 + bd = backlight_device_register(name, rinfo->info->dev, pdata,
  162 + &radeon_bl_data, &props);
159 163 if (IS_ERR(bd)) {
160 164 rinfo->info->bl_dev = NULL;
161 165 printk("radeonfb: Backlight registration failed\n");
... ... @@ -185,7 +189,6 @@
185 189 63 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL,
186 190 217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL);
187 191  
188   - bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
189 192 bd->props.brightness = bd->props.max_brightness;
190 193 bd->props.power = FB_BLANK_UNBLANK;
191 194 backlight_update_status(bd);
drivers/video/backlight/88pm860x_bl.c
... ... @@ -187,6 +187,7 @@
187 187 struct pm860x_backlight_data *data;
188 188 struct backlight_device *bl;
189 189 struct resource *res;
  190 + struct backlight_properties props;
190 191 unsigned char value;
191 192 char name[MFD_NAME_SIZE];
192 193 int ret;
193 194  
194 195  
... ... @@ -223,14 +224,15 @@
223 224 return -EINVAL;
224 225 }
225 226  
  227 + memset(&props, 0, sizeof(struct backlight_properties));
  228 + props.max_brightness = MAX_BRIGHTNESS;
226 229 bl = backlight_device_register(name, &pdev->dev, data,
227   - &pm860x_backlight_ops);
  230 + &pm860x_backlight_ops, &props);
228 231 if (IS_ERR(bl)) {
229 232 dev_err(&pdev->dev, "failed to register backlight\n");
230 233 kfree(data);
231 234 return PTR_ERR(bl);
232 235 }
233   - bl->props.max_brightness = MAX_BRIGHTNESS;
234 236 bl->props.brightness = MAX_BRIGHTNESS;
235 237  
236 238 platform_set_drvdata(pdev, bl);
drivers/video/backlight/adp5520_bl.c
... ... @@ -278,6 +278,7 @@
278 278  
279 279 static int __devinit adp5520_bl_probe(struct platform_device *pdev)
280 280 {
  281 + struct backlight_properties props;
281 282 struct backlight_device *bl;
282 283 struct adp5520_bl *data;
283 284 int ret = 0;
284 285  
... ... @@ -300,17 +301,17 @@
300 301  
301 302 mutex_init(&data->lock);
302 303  
303   - bl = backlight_device_register(pdev->name, data->master,
304   - data, &adp5520_bl_ops);
  304 + memset(&props, 0, sizeof(struct backlight_properties));
  305 + props.max_brightness = ADP5020_MAX_BRIGHTNESS;
  306 + bl = backlight_device_register(pdev->name, data->master, data,
  307 + &adp5520_bl_ops, &props);
305 308 if (IS_ERR(bl)) {
306 309 dev_err(&pdev->dev, "failed to register backlight\n");
307 310 kfree(data);
308 311 return PTR_ERR(bl);
309 312 }
310 313  
311   - bl->props.max_brightness =
312   - bl->props.brightness = ADP5020_MAX_BRIGHTNESS;
313   -
  314 + bl->props.brightness = ADP5020_MAX_BRIGHTNESS;
314 315 if (data->pdata->en_ambl_sens)
315 316 ret = sysfs_create_group(&bl->dev.kobj,
316 317 &adp5520_bl_attr_group);
drivers/video/backlight/adx_bl.c
... ... @@ -70,6 +70,7 @@
70 70  
71 71 static int __devinit adx_backlight_probe(struct platform_device *pdev)
72 72 {
  73 + struct backlight_properties props;
73 74 struct backlight_device *bldev;
74 75 struct resource *res;
75 76 struct adxbl *bl;
76 77  
... ... @@ -101,14 +102,15 @@
101 102 goto out;
102 103 }
103 104  
104   - bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, bl,
105   - &adx_backlight_ops);
  105 + memset(&props, 0, sizeof(struct backlight_properties));
  106 + props.max_brightness = 0xff;
  107 + bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev,
  108 + bl, &adx_backlight_ops, &props);
106 109 if (!bldev) {
107 110 ret = -ENOMEM;
108 111 goto out;
109 112 }
110 113  
111   - bldev->props.max_brightness = 0xff;
112 114 bldev->props.brightness = 0xff;
113 115 bldev->props.power = FB_BLANK_UNBLANK;
114 116  
drivers/video/backlight/atmel-pwm-bl.c
... ... @@ -120,6 +120,7 @@
120 120  
121 121 static int atmel_pwm_bl_probe(struct platform_device *pdev)
122 122 {
  123 + struct backlight_properties props;
123 124 const struct atmel_pwm_bl_platform_data *pdata;
124 125 struct backlight_device *bldev;
125 126 struct atmel_pwm_bl *pwmbl;
... ... @@ -165,8 +166,10 @@
165 166 goto err_free_gpio;
166 167 }
167 168  
168   - bldev = backlight_device_register("atmel-pwm-bl",
169   - &pdev->dev, pwmbl, &atmel_pwm_bl_ops);
  169 + memset(&props, 0, sizeof(struct backlight_properties));
  170 + props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min;
  171 + bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl,
  172 + &atmel_pwm_bl_ops, &props);
170 173 if (IS_ERR(bldev)) {
171 174 retval = PTR_ERR(bldev);
172 175 goto err_free_gpio;
... ... @@ -178,7 +181,6 @@
178 181  
179 182 /* Power up the backlight by default at middle intesity. */
180 183 bldev->props.power = FB_BLANK_UNBLANK;
181   - bldev->props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min;
182 184 bldev->props.brightness = bldev->props.max_brightness / 2;
183 185  
184 186 retval = atmel_pwm_bl_init_pwm(pwmbl);
drivers/video/backlight/backlight.c
... ... @@ -269,7 +269,8 @@
269 269 * ERR_PTR() or a pointer to the newly allocated device.
270 270 */
271 271 struct backlight_device *backlight_device_register(const char *name,
272   - struct device *parent, void *devdata, const struct backlight_ops *ops)
  272 + struct device *parent, void *devdata, const struct backlight_ops *ops,
  273 + const struct backlight_properties *props)
273 274 {
274 275 struct backlight_device *new_bd;
275 276 int rc;
... ... @@ -288,6 +289,11 @@
288 289 new_bd->dev.release = bl_device_release;
289 290 dev_set_name(&new_bd->dev, name);
290 291 dev_set_drvdata(&new_bd->dev, devdata);
  292 +
  293 + /* Set default properties */
  294 + if (props)
  295 + memcpy(&new_bd->props, props,
  296 + sizeof(struct backlight_properties));
291 297  
292 298 rc = device_register(&new_bd->dev);
293 299 if (rc) {
drivers/video/backlight/corgi_lcd.c
... ... @@ -533,6 +533,7 @@
533 533  
534 534 static int __devinit corgi_lcd_probe(struct spi_device *spi)
535 535 {
  536 + struct backlight_properties props;
536 537 struct corgi_lcd_platform_data *pdata = spi->dev.platform_data;
537 538 struct corgi_lcd *lcd;
538 539 int ret = 0;
539 540  
... ... @@ -559,13 +560,14 @@
559 560 lcd->power = FB_BLANK_POWERDOWN;
560 561 lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;
561 562  
562   - lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev,
563   - lcd, &corgi_bl_ops);
  563 + memset(&props, 0, sizeof(struct backlight_properties));
  564 + props.max_brightness = pdata->max_intensity;
  565 + lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd,
  566 + &corgi_bl_ops, &props);
564 567 if (IS_ERR(lcd->bl_dev)) {
565 568 ret = PTR_ERR(lcd->bl_dev);
566 569 goto err_unregister_lcd;
567 570 }
568   - lcd->bl_dev->props.max_brightness = pdata->max_intensity;
569 571 lcd->bl_dev->props.brightness = pdata->default_intensity;
570 572 lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
571 573  
drivers/video/backlight/cr_bllcd.c
... ... @@ -170,6 +170,7 @@
170 170  
171 171 static int cr_backlight_probe(struct platform_device *pdev)
172 172 {
  173 + struct backlight_properties props;
173 174 struct backlight_device *bdp;
174 175 struct lcd_device *ldp;
175 176 struct cr_panel *crp;
... ... @@ -190,8 +191,9 @@
190 191 return -ENODEV;
191 192 }
192 193  
193   - bdp = backlight_device_register("cr-backlight",
194   - &pdev->dev, NULL, &cr_backlight_ops);
  194 + memset(&props, 0, sizeof(struct backlight_properties));
  195 + bdp = backlight_device_register("cr-backlight", &pdev->dev, NULL,
  196 + &cr_backlight_ops, &props);
195 197 if (IS_ERR(bdp)) {
196 198 pci_dev_put(lpc_dev);
197 199 return PTR_ERR(bdp);
198 200  
... ... @@ -220,9 +222,7 @@
220 222 crp->cr_lcd_device = ldp;
221 223 crp->cr_backlight_device->props.power = FB_BLANK_UNBLANK;
222 224 crp->cr_backlight_device->props.brightness = 0;
223   - crp->cr_backlight_device->props.max_brightness = 0;
224 225 cr_backlight_set_intensity(crp->cr_backlight_device);
225   -
226 226 cr_lcd_set_power(crp->cr_lcd_device, FB_BLANK_UNBLANK);
227 227  
228 228 platform_set_drvdata(pdev, crp);
drivers/video/backlight/da903x_bl.c
... ... @@ -105,6 +105,7 @@
105 105 struct da9034_backlight_pdata *pdata = pdev->dev.platform_data;
106 106 struct da903x_backlight_data *data;
107 107 struct backlight_device *bl;
  108 + struct backlight_properties props;
108 109 int max_brightness;
109 110  
110 111 data = kzalloc(sizeof(*data), GFP_KERNEL);
111 112  
... ... @@ -134,15 +135,15 @@
134 135 da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2,
135 136 DA9034_WLED_ISET(pdata->output_current));
136 137  
137   - bl = backlight_device_register(pdev->name, data->da903x_dev,
138   - data, &da903x_backlight_ops);
  138 + props.max_brightness = max_brightness;
  139 + bl = backlight_device_register(pdev->name, data->da903x_dev, data,
  140 + &da903x_backlight_ops, &props);
139 141 if (IS_ERR(bl)) {
140 142 dev_err(&pdev->dev, "failed to register backlight\n");
141 143 kfree(data);
142 144 return PTR_ERR(bl);
143 145 }
144 146  
145   - bl->props.max_brightness = max_brightness;
146 147 bl->props.brightness = max_brightness;
147 148  
148 149 platform_set_drvdata(pdev, bl);
drivers/video/backlight/generic_bl.c
... ... @@ -78,6 +78,7 @@
78 78  
79 79 static int genericbl_probe(struct platform_device *pdev)
80 80 {
  81 + struct backlight_properties props;
81 82 struct generic_bl_info *machinfo = pdev->dev.platform_data;
82 83 const char *name = "generic-bl";
83 84 struct backlight_device *bd;
84 85  
... ... @@ -89,14 +90,15 @@
89 90 if (machinfo->name)
90 91 name = machinfo->name;
91 92  
92   - bd = backlight_device_register (name,
93   - &pdev->dev, NULL, &genericbl_ops);
  93 + memset(&props, 0, sizeof(struct backlight_properties));
  94 + props.max_brightness = machinfo->max_intensity;
  95 + bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops,
  96 + &props);
94 97 if (IS_ERR (bd))
95 98 return PTR_ERR (bd);
96 99  
97 100 platform_set_drvdata(pdev, bd);
98 101  
99   - bd->props.max_brightness = machinfo->max_intensity;
100 102 bd->props.power = FB_BLANK_UNBLANK;
101 103 bd->props.brightness = machinfo->default_intensity;
102 104 backlight_update_status(bd);
drivers/video/backlight/hp680_bl.c
... ... @@ -105,16 +105,18 @@
105 105  
106 106 static int __devinit hp680bl_probe(struct platform_device *pdev)
107 107 {
  108 + struct backlight_properties props;
108 109 struct backlight_device *bd;
109 110  
110   - bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL,
111   - &hp680bl_ops);
  111 + memset(&props, 0, sizeof(struct backlight_properties));
  112 + props.max_brightness = HP680_MAX_INTENSITY;
  113 + bd = backlight_device_register("hp680-bl", &pdev->dev, NULL,
  114 + &hp680bl_ops, &props);
112 115 if (IS_ERR(bd))
113 116 return PTR_ERR(bd);
114 117  
115 118 platform_set_drvdata(pdev, bd);
116 119  
117   - bd->props.max_brightness = HP680_MAX_INTENSITY;
118 120 bd->props.brightness = HP680_DEFAULT_INTENSITY;
119 121 hp680bl_send_intensity(bd);
120 122  
drivers/video/backlight/jornada720_bl.c
... ... @@ -101,10 +101,14 @@
101 101  
102 102 static int jornada_bl_probe(struct platform_device *pdev)
103 103 {
  104 + struct backlight_properties props;
104 105 int ret;
105 106 struct backlight_device *bd;
106 107  
107   - bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL, &jornada_bl_ops);
  108 + memset(&props, 0, sizeof(struct backlight_properties));
  109 + props.max_brightness = BL_MAX_BRIGHT;
  110 + bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL,
  111 + &jornada_bl_ops, &props);
108 112  
109 113 if (IS_ERR(bd)) {
110 114 ret = PTR_ERR(bd);
... ... @@ -117,7 +121,6 @@
117 121 /* note. make sure max brightness is set otherwise
118 122 you will get seemingly non-related errors when
119 123 trying to change brightness */
120   - bd->props.max_brightness = BL_MAX_BRIGHT;
121 124 jornada_bl_update_status(bd);
122 125  
123 126 platform_set_drvdata(pdev, bd);
drivers/video/backlight/kb3886_bl.c
... ... @@ -141,20 +141,24 @@
141 141  
142 142 static int kb3886bl_probe(struct platform_device *pdev)
143 143 {
  144 + struct backlight_properties props;
144 145 struct kb3886bl_machinfo *machinfo = pdev->dev.platform_data;
145 146  
146 147 bl_machinfo = machinfo;
147 148 if (!machinfo->limit_mask)
148 149 machinfo->limit_mask = -1;
149 150  
  151 + memset(&props, 0, sizeof(struct backlight_properties));
  152 + props.max_brightness = machinfo->max_intensity;
150 153 kb3886_backlight_device = backlight_device_register("kb3886-bl",
151   - &pdev->dev, NULL, &kb3886bl_ops);
  154 + &pdev->dev, NULL,
  155 + &kb3886bl_ops,
  156 + &props);
152 157 if (IS_ERR(kb3886_backlight_device))
153 158 return PTR_ERR(kb3886_backlight_device);
154 159  
155 160 platform_set_drvdata(pdev, kb3886_backlight_device);
156 161  
157   - kb3886_backlight_device->props.max_brightness = machinfo->max_intensity;
158 162 kb3886_backlight_device->props.power = FB_BLANK_UNBLANK;
159 163 kb3886_backlight_device->props.brightness = machinfo->default_intensity;
160 164 backlight_update_status(kb3886_backlight_device);
drivers/video/backlight/locomolcd.c
... ... @@ -167,6 +167,7 @@
167 167  
168 168 static int locomolcd_probe(struct locomo_dev *ldev)
169 169 {
  170 + struct backlight_properties props;
170 171 unsigned long flags;
171 172  
172 173 local_irq_save(flags);
173 174  
... ... @@ -182,13 +183,16 @@
182 183  
183 184 local_irq_restore(flags);
184 185  
185   - locomolcd_bl_device = backlight_device_register("locomo-bl", &ldev->dev, NULL, &locomobl_data);
  186 + memset(&props, 0, sizeof(struct backlight_properties));
  187 + props.max_brightness = 4;
  188 + locomolcd_bl_device = backlight_device_register("locomo-bl",
  189 + &ldev->dev, NULL,
  190 + &locomobl_data, &props);
186 191  
187 192 if (IS_ERR (locomolcd_bl_device))
188 193 return PTR_ERR (locomolcd_bl_device);
189 194  
190 195 /* Set up frontlight so that screen is readable */
191   - locomolcd_bl_device->props.max_brightness = 4,
192 196 locomolcd_bl_device->props.brightness = 2;
193 197 locomolcd_set_intensity(locomolcd_bl_device);
194 198  
drivers/video/backlight/max8925_bl.c
... ... @@ -104,6 +104,7 @@
104 104 struct max8925_backlight_pdata *pdata = NULL;
105 105 struct max8925_backlight_data *data;
106 106 struct backlight_device *bl;
  107 + struct backlight_properties props;
107 108 struct resource *res;
108 109 char name[MAX8925_NAME_SIZE];
109 110 unsigned char value;
110 111  
111 112  
... ... @@ -133,14 +134,15 @@
133 134 data->chip = chip;
134 135 data->current_brightness = 0;
135 136  
  137 + memset(&props, 0, sizeof(struct backlight_properties));
  138 + props.max_brightness = MAX_BRIGHTNESS;
136 139 bl = backlight_device_register(name, &pdev->dev, data,
137   - &max8925_backlight_ops);
  140 + &max8925_backlight_ops, &props);
138 141 if (IS_ERR(bl)) {
139 142 dev_err(&pdev->dev, "failed to register backlight\n");
140 143 kfree(data);
141 144 return PTR_ERR(bl);
142 145 }
143   - bl->props.max_brightness = MAX_BRIGHTNESS;
144 146 bl->props.brightness = MAX_BRIGHTNESS;
145 147  
146 148 platform_set_drvdata(pdev, bl);
drivers/video/backlight/mbp_nvidia_bl.c
... ... @@ -250,6 +250,7 @@
250 250  
251 251 static int __init mbp_init(void)
252 252 {
  253 + struct backlight_properties props;
253 254 if (!dmi_check_system(mbp_device_table))
254 255 return -ENODEV;
255 256  
256 257  
... ... @@ -257,14 +258,17 @@
257 258 "Macbook Pro backlight"))
258 259 return -ENXIO;
259 260  
260   - mbp_backlight_device = backlight_device_register("mbp_backlight",
261   - NULL, NULL, &driver_data->backlight_ops);
  261 + memset(&props, 0, sizeof(struct backlight_properties));
  262 + props.max_brightness = 15;
  263 + mbp_backlight_device = backlight_device_register("mbp_backlight", NULL,
  264 + NULL,
  265 + &driver_data->backlight_ops,
  266 + &props);
262 267 if (IS_ERR(mbp_backlight_device)) {
263 268 release_region(driver_data->iostart, driver_data->iolen);
264 269 return PTR_ERR(mbp_backlight_device);
265 270 }
266 271  
267   - mbp_backlight_device->props.max_brightness = 15;
268 272 mbp_backlight_device->props.brightness =
269 273 driver_data->backlight_ops.get_brightness(mbp_backlight_device);
270 274 backlight_update_status(mbp_backlight_device);
drivers/video/backlight/omap1_bl.c
... ... @@ -132,6 +132,7 @@
132 132  
133 133 static int omapbl_probe(struct platform_device *pdev)
134 134 {
  135 + struct backlight_properties props;
135 136 struct backlight_device *dev;
136 137 struct omap_backlight *bl;
137 138 struct omap_backlight_config *pdata = pdev->dev.platform_data;
... ... @@ -143,7 +144,10 @@
143 144 if (unlikely(!bl))
144 145 return -ENOMEM;
145 146  
146   - dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops);
  147 + memset(&props, 0, sizeof(struct backlight_properties));
  148 + props.max_brightness = OMAPBL_MAX_INTENSITY;
  149 + dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops,
  150 + &props);
147 151 if (IS_ERR(dev)) {
148 152 kfree(bl);
149 153 return PTR_ERR(dev);
... ... @@ -160,7 +164,6 @@
160 164 omap_cfg_reg(PWL); /* Conflicts with UART3 */
161 165  
162 166 dev->props.fb_blank = FB_BLANK_UNBLANK;
163   - dev->props.max_brightness = OMAPBL_MAX_INTENSITY;
164 167 dev->props.brightness = pdata->default_intensity;
165 168 omapbl_update_status(dev);
166 169  
drivers/video/backlight/progear_bl.c
... ... @@ -61,6 +61,7 @@
61 61  
62 62 static int progearbl_probe(struct platform_device *pdev)
63 63 {
  64 + struct backlight_properties props;
64 65 u8 temp;
65 66 struct backlight_device *progear_backlight_device;
66 67 int ret;
67 68  
... ... @@ -82,9 +83,12 @@
82 83 pci_read_config_byte(sb_dev, SB_MPS1, &temp);
83 84 pci_write_config_byte(sb_dev, SB_MPS1, temp | 0x20);
84 85  
  86 + memset(&props, 0, sizeof(struct backlight_properties));
  87 + props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
85 88 progear_backlight_device = backlight_device_register("progear-bl",
86 89 &pdev->dev, NULL,
87   - &progearbl_ops);
  90 + &progearbl_ops,
  91 + &props);
88 92 if (IS_ERR(progear_backlight_device)) {
89 93 ret = PTR_ERR(progear_backlight_device);
90 94 goto put_sb;
... ... @@ -94,7 +98,6 @@
94 98  
95 99 progear_backlight_device->props.power = FB_BLANK_UNBLANK;
96 100 progear_backlight_device->props.brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
97   - progear_backlight_device->props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
98 101 progearbl_set_intensity(progear_backlight_device);
99 102  
100 103 return 0;
drivers/video/backlight/pwm_bl.c
... ... @@ -65,6 +65,7 @@
65 65  
66 66 static int pwm_backlight_probe(struct platform_device *pdev)
67 67 {
  68 + struct backlight_properties props;
68 69 struct platform_pwm_backlight_data *data = pdev->dev.platform_data;
69 70 struct backlight_device *bl;
70 71 struct pwm_bl_data *pb;
71 72  
... ... @@ -100,15 +101,16 @@
100 101 } else
101 102 dev_dbg(&pdev->dev, "got pwm for backlight\n");
102 103  
103   - bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev,
104   - pb, &pwm_backlight_ops);
  104 + memset(&props, 0, sizeof(struct backlight_properties));
  105 + props.max_brightness = data->max_brightness;
  106 + bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
  107 + &pwm_backlight_ops, &props);
105 108 if (IS_ERR(bl)) {
106 109 dev_err(&pdev->dev, "failed to register backlight\n");
107 110 ret = PTR_ERR(bl);
108 111 goto err_bl;
109 112 }
110 113  
111   - bl->props.max_brightness = data->max_brightness;
112 114 bl->props.brightness = data->dft_brightness;
113 115 backlight_update_status(bl);
114 116  
drivers/video/backlight/tosa_bl.c
... ... @@ -80,6 +80,7 @@
80 80 static int __devinit tosa_bl_probe(struct i2c_client *client,
81 81 const struct i2c_device_id *id)
82 82 {
  83 + struct backlight_properties props;
83 84 struct tosa_bl_data *data = kzalloc(sizeof(struct tosa_bl_data), GFP_KERNEL);
84 85 int ret = 0;
85 86 if (!data)
86 87  
... ... @@ -99,15 +100,16 @@
99 100 i2c_set_clientdata(client, data);
100 101 data->i2c = client;
101 102  
102   - data->bl = backlight_device_register("tosa-bl", &client->dev,
103   - data, &bl_ops);
  103 + memset(&props, 0, sizeof(struct backlight_properties));
  104 + props.max_brightness = 512 - 1;
  105 + data->bl = backlight_device_register("tosa-bl", &client->dev, data,
  106 + &bl_ops, &props);
104 107 if (IS_ERR(data->bl)) {
105 108 ret = PTR_ERR(data->bl);
106 109 goto err_reg;
107 110 }
108 111  
109 112 data->bl->props.brightness = 69;
110   - data->bl->props.max_brightness = 512 - 1;
111 113 data->bl->props.power = FB_BLANK_UNBLANK;
112 114  
113 115 backlight_update_status(data->bl);
drivers/video/backlight/wm831x_bl.c
... ... @@ -125,6 +125,7 @@
125 125 struct wm831x_backlight_pdata *pdata;
126 126 struct wm831x_backlight_data *data;
127 127 struct backlight_device *bl;
  128 + struct backlight_properties props;
128 129 int ret, i, max_isel, isink_reg, dcdc_cfg;
129 130  
130 131 /* We need platform data */
131 132  
... ... @@ -191,15 +192,15 @@
191 192 data->current_brightness = 0;
192 193 data->isink_reg = isink_reg;
193 194  
194   - bl = backlight_device_register("wm831x", &pdev->dev,
195   - data, &wm831x_backlight_ops);
  195 + props.max_brightness = max_isel;
  196 + bl = backlight_device_register("wm831x", &pdev->dev, data,
  197 + &wm831x_backlight_ops, &props);
196 198 if (IS_ERR(bl)) {
197 199 dev_err(&pdev->dev, "failed to register backlight\n");
198 200 kfree(data);
199 201 return PTR_ERR(bl);
200 202 }
201 203  
202   - bl->props.max_brightness = max_isel;
203 204 bl->props.brightness = max_isel;
204 205  
205 206 platform_set_drvdata(pdev, bl);
drivers/video/bf54x-lq043fb.c
... ... @@ -501,6 +501,7 @@
501 501  
502 502 static int __devinit bfin_bf54x_probe(struct platform_device *pdev)
503 503 {
  504 + struct backlight_properties props;
504 505 struct bfin_bf54xfb_info *info;
505 506 struct fb_info *fbinfo;
506 507 int ret;
... ... @@ -645,10 +646,10 @@
645 646 goto out8;
646 647 }
647 648 #ifndef NO_BL_SUPPORT
648   - bl_dev =
649   - backlight_device_register("bf54x-bl", NULL, NULL,
650   - &bfin_lq043fb_bl_ops);
651   - bl_dev->props.max_brightness = 255;
  649 + memset(&props, 0, sizeof(struct backlight_properties));
  650 + props.max_brightness = 255;
  651 + bl_dev = backlight_device_register("bf54x-bl", NULL, NULL,
  652 + &bfin_lq043fb_bl_ops, &props);
652 653  
653 654 lcd_dev = lcd_device_register(DRIVER_NAME, &pdev->dev, NULL, &bfin_lcd_ops);
654 655 lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
drivers/video/bfin-t350mcqb-fb.c
... ... @@ -419,6 +419,7 @@
419 419  
420 420 static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
421 421 {
  422 + struct backlight_properties props;
422 423 struct bfin_t350mcqbfb_info *info;
423 424 struct fb_info *fbinfo;
424 425 int ret;
... ... @@ -540,10 +541,10 @@
540 541 goto out8;
541 542 }
542 543 #ifndef NO_BL_SUPPORT
543   - bl_dev =
544   - backlight_device_register("bf52x-bl", NULL, NULL,
545   - &bfin_lq043fb_bl_ops);
546   - bl_dev->props.max_brightness = 255;
  544 + memset(&props, 0, sizeof(struct backlight_properties));
  545 + props.max_brightness = 255;
  546 + bl_dev = backlight_device_register("bf52x-bl", NULL, NULL,
  547 + &bfin_lq043fb_bl_ops, &props);
547 548  
548 549 lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops);
549 550 lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
drivers/video/nvidia/nv_backlight.c
... ... @@ -94,6 +94,7 @@
94 94  
95 95 void nvidia_bl_init(struct nvidia_par *par)
96 96 {
  97 + struct backlight_properties props;
97 98 struct fb_info *info = pci_get_drvdata(par->pci_dev);
98 99 struct backlight_device *bd;
99 100 char name[12];
... ... @@ -109,7 +110,10 @@
109 110  
110 111 snprintf(name, sizeof(name), "nvidiabl%d", info->node);
111 112  
112   - bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops);
  113 + memset(&props, 0, sizeof(struct backlight_properties));
  114 + props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
  115 + bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops,
  116 + &props);
113 117 if (IS_ERR(bd)) {
114 118 info->bl_dev = NULL;
115 119 printk(KERN_WARNING "nvidia: Backlight registration failed\n");
... ... @@ -121,7 +125,6 @@
121 125 0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL,
122 126 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL);
123 127  
124   - bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
125 128 bd->props.brightness = bd->props.max_brightness;
126 129 bd->props.power = FB_BLANK_UNBLANK;
127 130 backlight_update_status(bd);
drivers/video/omap2/displays/panel-taal.c
... ... @@ -486,6 +486,7 @@
486 486  
487 487 static int taal_probe(struct omap_dss_device *dssdev)
488 488 {
  489 + struct backlight_properties props;
489 490 struct taal_data *td;
490 491 struct backlight_device *bldev;
491 492 int r;
492 493  
493 494  
... ... @@ -520,11 +521,16 @@
520 521  
521 522 /* if no platform set_backlight() defined, presume DSI backlight
522 523 * control */
  524 + memset(&props, 0, sizeof(struct backlight_properties));
523 525 if (!dssdev->set_backlight)
524 526 td->use_dsi_bl = true;
525 527  
  528 + if (td->use_dsi_bl)
  529 + props.max_brightness = 255;
  530 + else
  531 + props.max_brightness = 127;
526 532 bldev = backlight_device_register("taal", &dssdev->dev, dssdev,
527   - &taal_bl_ops);
  533 + &taal_bl_ops, &props);
528 534 if (IS_ERR(bldev)) {
529 535 r = PTR_ERR(bldev);
530 536 goto err2;
531 537  
532 538  
... ... @@ -534,13 +540,10 @@
534 540  
535 541 bldev->props.fb_blank = FB_BLANK_UNBLANK;
536 542 bldev->props.power = FB_BLANK_UNBLANK;
537   - if (td->use_dsi_bl) {
538   - bldev->props.max_brightness = 255;
  543 + if (td->use_dsi_bl)
539 544 bldev->props.brightness = 255;
540   - } else {
541   - bldev->props.max_brightness = 127;
  545 + else
542 546 bldev->props.brightness = 127;
543   - }
544 547  
545 548 taal_bl_update_status(bldev);
546 549  
drivers/video/riva/fbdev.c
... ... @@ -338,6 +338,7 @@
338 338  
339 339 static void riva_bl_init(struct riva_par *par)
340 340 {
  341 + struct backlight_properties props;
341 342 struct fb_info *info = pci_get_drvdata(par->pdev);
342 343 struct backlight_device *bd;
343 344 char name[12];
... ... @@ -353,7 +354,10 @@
353 354  
354 355 snprintf(name, sizeof(name), "rivabl%d", info->node);
355 356  
356   - bd = backlight_device_register(name, info->dev, par, &riva_bl_ops);
  357 + memset(&props, 0, sizeof(struct backlight_properties));
  358 + props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
  359 + bd = backlight_device_register(name, info->dev, par, &riva_bl_ops,
  360 + &props);
357 361 if (IS_ERR(bd)) {
358 362 info->bl_dev = NULL;
359 363 printk(KERN_WARNING "riva: Backlight registration failed\n");
... ... @@ -365,7 +369,6 @@
365 369 MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL,
366 370 FB_BACKLIGHT_MAX);
367 371  
368   - bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
369 372 bd->props.brightness = bd->props.max_brightness;
370 373 bd->props.power = FB_BLANK_UNBLANK;
371 374 backlight_update_status(bd);
include/linux/backlight.h
... ... @@ -103,7 +103,8 @@
103 103 }
104 104  
105 105 extern struct backlight_device *backlight_device_register(const char *name,
106   - struct device *dev, void *devdata, const struct backlight_ops *ops);
  106 + struct device *dev, void *devdata, const struct backlight_ops *ops,
  107 + const struct backlight_properties *props);
107 108 extern void backlight_device_unregister(struct backlight_device *bd);
108 109 extern void backlight_force_update(struct backlight_device *bd,
109 110 enum backlight_update_reason reason);