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

1  2 
drivers/acpi/video.c
drivers/usb/misc/appledisplay.c
drivers/video/aty/atyfb_base.c
drivers/video/backlight/cr_bllcd.c
drivers/video/riva/fbdev.c

diff --combined drivers/acpi/video.c
@@@ -33,7 -33,6 +33,7 @@@
  #include <linux/seq_file.h>
  
  #include <linux/backlight.h>
 +#include <linux/video_output.h>
  #include <asm/uaccess.h>
  
  #include <acpi/acpi_bus.h>
@@@ -170,7 -169,6 +170,7 @@@ struct acpi_video_device 
        struct acpi_device *dev;
        struct acpi_video_device_brightness *brightness;
        struct backlight_device *backlight;
 +      struct output_device *output_dev;
  };
  
  /* bus */
@@@ -274,17 -272,13 +274,17 @@@ static int acpi_video_get_next_level(st
                                     u32 level_current, u32 event);
  static void acpi_video_switch_brightness(struct acpi_video_device *device,
                                         int event);
 +static int acpi_video_device_get_state(struct acpi_video_device *device,
 +                          unsigned long *state);
 +static int acpi_video_output_get(struct output_device *od);
 +static int acpi_video_device_set_state(struct acpi_video_device *device, int state);
  
  /*backlight device sysfs support*/
  static int acpi_video_get_brightness(struct backlight_device *bd)
  {
        unsigned long cur_level;
        struct acpi_video_device *vd =
-               (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
+               (struct acpi_video_device *)bl_get_data(bd);
        acpi_video_device_lcd_get_level_current(vd, &cur_level);
        return (int) cur_level;
  }
@@@ -293,7 -287,7 +293,7 @@@ static int acpi_video_set_brightness(st
  {
        int request_level = bd->props.brightness;
        struct acpi_video_device *vd =
-               (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
+               (struct acpi_video_device *)bl_get_data(bd);
        acpi_video_device_lcd_set_level(vd, request_level);
        return 0;
  }
@@@ -303,28 -297,6 +303,28 @@@ static struct backlight_ops acpi_backli
        .update_status  = acpi_video_set_brightness,
  };
  
 +/*video output device sysfs support*/
 +static int acpi_video_output_get(struct output_device *od)
 +{
 +      unsigned long state;
 +      struct acpi_video_device *vd =
 +              (struct acpi_video_device *)class_get_devdata(&od->class_dev);
 +      acpi_video_device_get_state(vd, &state);
 +      return (int)state;
 +}
 +
 +static int acpi_video_output_set(struct output_device *od)
 +{
 +      unsigned long state = od->request_state;
 +      struct acpi_video_device *vd=
 +              (struct acpi_video_device *)class_get_devdata(&od->class_dev);
 +      return acpi_video_device_set_state(vd, state);
 +}
 +
 +static struct output_properties acpi_output_properties = {
 +      .set_state = acpi_video_output_set,
 +      .get_status = acpi_video_output_get,
 +};
  /* --------------------------------------------------------------------------
                                 Video Management
     -------------------------------------------------------------------------- */
@@@ -559,6 -531,7 +559,6 @@@ acpi_video_bus_DOS(struct acpi_video_bu
  
  static void acpi_video_device_find_cap(struct acpi_video_device *device)
  {
 -      acpi_integer status;
        acpi_handle h_dummy1;
        int i;
        u32 max_level = 0;
                device->cap._DSS = 1;
        }
  
 -      status = acpi_video_device_lcd_query_levels(device, &obj);
 -
 -      if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
 -              int count = 0;
 -              union acpi_object *o;
 -
 -              br = kzalloc(sizeof(*br), GFP_KERNEL);
 -              if (!br) {
 -                      printk(KERN_ERR "can't allocate memory\n");
 -              } else {
 -                      br->levels = kmalloc(obj->package.count *
 -                                           sizeof *(br->levels), GFP_KERNEL);
 -                      if (!br->levels)
 -                              goto out;
 -
 -                      for (i = 0; i < obj->package.count; i++) {
 -                              o = (union acpi_object *)&obj->package.
 -                                  elements[i];
 -                              if (o->type != ACPI_TYPE_INTEGER) {
 -                                      printk(KERN_ERR PREFIX "Invalid data\n");
 -                                      continue;
 -                              }
 -                              br->levels[count] = (u32) o->integer.value;
 -                              if (br->levels[count] > max_level)
 -                                      max_level = br->levels[count];
 -                              count++;
 -                      }
 -                    out:
 -                      if (count < 2) {
 -                              kfree(br->levels);
 -                              kfree(br);
 +      if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
 +
 +              if (obj->package.count >= 2) {
 +                      int count = 0;
 +                      union acpi_object *o;
 +
 +                      br = kzalloc(sizeof(*br), GFP_KERNEL);
 +                      if (!br) {
 +                              printk(KERN_ERR "can't allocate memory\n");
                        } else {
 -                              br->count = count;
 -                              device->brightness = br;
 -                              ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 -                                                "found %d brightness levels\n",
 -                                                count));
 +                              br->levels = kmalloc(obj->package.count *
 +                                                   sizeof *(br->levels), GFP_KERNEL);
 +                              if (!br->levels)
 +                                      goto out;
 +
 +                              for (i = 0; i < obj->package.count; i++) {
 +                                      o = (union acpi_object *)&obj->package.
 +                                          elements[i];
 +                                      if (o->type != ACPI_TYPE_INTEGER) {
 +                                              printk(KERN_ERR PREFIX "Invalid data\n");
 +                                              continue;
 +                                      }
 +                                      br->levels[count] = (u32) o->integer.value;
 +
 +                                      if (br->levels[count] > max_level)
 +                                              max_level = br->levels[count];
 +                                      count++;
 +                              }
 +                            out:
 +                              if (count < 2) {
 +                                      kfree(br->levels);
 +                                      kfree(br);
 +                              } else {
 +                                      br->count = count;
 +                                      device->brightness = br;
 +                                      ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 +                                                        "found %d brightness levels\n",
 +                                                        count));
 +                              }
                        }
                }
 +
 +      } else {
 +              ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD brightness level\n"));
        }
  
        kfree(obj);
  
 -      if (device->cap._BCL && device->cap._BCM && device->cap._BQC){
 +      if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
                unsigned long tmp;
                static int count = 0;
                char *name;
  
                kfree(name);
        }
 +      if (device->cap._DCS && device->cap._DSS){
 +              static int count = 0;
 +              char *name;
 +              name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
 +              if (!name)
 +                      return;
 +              sprintf(name, "acpi_video%d", count++);
 +              device->output_dev = video_output_register(name,
 +                              NULL, device, &acpi_output_properties);
 +              kfree(name);
 +      }
        return;
  }
  
@@@ -1712,7 -1669,6 +1712,7 @@@ static int acpi_video_bus_put_one_devic
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_video_device_notify);
        backlight_device_unregister(device->backlight);
 +      video_output_unregister(device->output_dev);
        return 0;
  }
  
@@@ -88,10 -88,9 +88,10 @@@ static void appledisplay_complete(struc
  {
        struct appledisplay *pdata = urb->context;
        unsigned long flags;
 +      int status = urb->status;
        int retval;
  
 -      switch (urb->status) {
 +      switch (status) {
        case 0:
                /* success */
                break;
        case -ENOENT:
        case -ESHUTDOWN:
                /* This urb is terminated, clean up */
 -              dbg("%s - urb shutting down with status: %d",
 -                      __FUNCTION__, urb->status);
 +              dbg("%s - urb shuttingdown with status: %d",
 +                      __FUNCTION__, status);
                return;
        default:
                dbg("%s - nonzero urb status received: %d",
 -                      __FUNCTION__, urb->status);
 +                      __FUNCTION__, status);
                goto exit;
        }
  
@@@ -138,7 -137,7 +138,7 @@@ exit
  
  static int appledisplay_bl_update_status(struct backlight_device *bd)
  {
-       struct appledisplay *pdata = class_get_devdata(&bd->class_dev);
+       struct appledisplay *pdata = bl_get_data(bd);
        int retval;
  
        pdata->msgdata[0] = 0x10;
  
  static int appledisplay_bl_get_brightness(struct backlight_device *bd)
  {
-       struct appledisplay *pdata = class_get_devdata(&bd->class_dev);
+       struct appledisplay *pdata = bl_get_data(bd);
        int retval;
  
        retval = usb_control_msg(
@@@ -541,7 -541,7 +541,7 @@@ static char ram_off[] __devinitdata = "
  #endif /* CONFIG_FB_ATY_CT */
  
  
 -static u32 pseudo_palette[17];
 +static u32 pseudo_palette[16];
  
  #ifdef CONFIG_FB_ATY_GX
  static char *aty_gx_ram[8] __devinitdata = {
@@@ -2141,7 -2141,7 +2141,7 @@@ static int aty_bl_get_level_brightness(
  
  static int aty_bl_update_status(struct backlight_device *bd)
  {
-       struct atyfb_par *par = class_get_devdata(&bd->class_dev);
+       struct atyfb_par *par = bl_get_data(bd);
        unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
        int level;
  
@@@ -2913,6 -2913,10 +2913,6 @@@ static int __devinit atyfb_setup_sparc(
        int node, len, i, j, ret;
        u32 mem, chip_id;
  
 -      /* Do not attach when we have a serial console. */
 -      if (!con_is_present())
 -              return -ENXIO;
 -
        /*
         * Map memory-mapped registers.
         */
                /* nothing */ ;
        j = i + 4;
  
 -      par->mmap_map = kmalloc(j * sizeof(*par->mmap_map), GFP_ATOMIC);
 +      par->mmap_map = kcalloc(j, sizeof(*par->mmap_map), GFP_ATOMIC);
        if (!par->mmap_map) {
                PRINTKE("atyfb_setup_sparc() can't alloc mmap_map\n");
                return -ENOMEM;
        }
 -      memset(par->mmap_map, 0, j * sizeof(*par->mmap_map));
  
        for (i = 0, j = 2; i < 6 && pdev->resource[i].start; i++) {
                struct resource *rp = &pdev->resource[i];
@@@ -174,7 -174,7 +174,7 @@@ static int cr_backlight_probe(struct pl
        struct cr_panel *crp;
        u8 dev_en;
  
 -      crp = kzalloc(sizeof(crp), GFP_KERNEL);
 +      crp = kzalloc(sizeof(*crp), GFP_KERNEL);
        if (crp == NULL)
                return -ENOMEM;
  
        }
  
        crp->cr_lcd_device = lcd_device_register("cr-lcd",
-                                                       &pdev->dev,
+                                                       &pdev->dev, NULL,
                                                        &cr_lcd_ops);
  
        if (IS_ERR(crp->cr_lcd_device)) {
@@@ -307,7 -307,7 +307,7 @@@ static int riva_bl_get_level_brightness
  
  static int riva_bl_update_status(struct backlight_device *bd)
  {
-       struct riva_par *par = class_get_devdata(&bd->class_dev);
+       struct riva_par *par = bl_get_data(bd);
        U032 tmp_pcrt, tmp_pmc;
        int level;
  
@@@ -2146,7 -2146,7 +2146,7 @@@ static void __devexit rivafb_remove(str
   * ------------------------------------------------------------------------- */
  
  #ifndef MODULE
 -static int __init rivafb_setup(char *options)
 +static int __devinit rivafb_setup(char *options)
  {
        char *this_opt;