Pull platform-drivers into test branch
authorLen Brown <len.brown@intel.com>
Wed, 20 Dec 2006 07:52:17 +0000 (02:52 -0500)
committerLen Brown <len.brown@intel.com>
Wed, 20 Dec 2006 07:52:17 +0000 (02:52 -0500)
1  2 
drivers/acpi/asus_acpi.c
drivers/acpi/ibm_acpi.c
drivers/acpi/video.c
drivers/usb/misc/appledisplay.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb_base.c
drivers/video/backlight/backlight.c
drivers/video/riva/fbdev.c

diff --combined drivers/acpi/asus_acpi.c
index bfae3ffff13c050017d28cf209e1718ce2cee8ab,11468e46253c4e86edec63f29f7247ad5fe3553f..7cc54aacd4c082f8623eb5a90a382f99ddda499b
@@@ -1146,7 -1146,7 +1146,7 @@@ static int asus_hotk_get_info(void
        if (ACPI_FAILURE(status))
                printk(KERN_WARNING "  Couldn't get the DSDT table header\n");
        else
 -              asus_info = (struct acpi_table_header *)dsdt.pointer;
 +              asus_info = dsdt.pointer;
  
        /* We have to write 0 on init this far for all ASUS models */
        if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
         * asus_model_match() and try something completely different.
         */
        if (buffer.pointer) {
 -              model = (union acpi_object *)buffer.pointer;
 +              model = buffer.pointer;
                switch (model->type) {
                case ACPI_TYPE_STRING:
                        string = model->string.pointer;
@@@ -1264,7 -1264,8 +1264,7 @@@ static int asus_hotk_add(struct acpi_de
        printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
               ASUS_ACPI_VERSION);
  
 -      hotk =
 -          (struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
 +      hotk = kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
        if (!hotk)
                return -ENOMEM;
        memset(hotk, 0, sizeof(struct asus_hotk));
@@@ -1401,7 -1402,7 +1401,7 @@@ static int __init asus_acpi_init(void
                return result;
        }
  
-       asus_backlight_device = backlight_device_register("asus", NULL,
+       asus_backlight_device = backlight_device_register("asus",NULL,NULL,
                                                          &asus_backlight_data);
          if (IS_ERR(asus_backlight_device)) {
                printk(KERN_ERR "Could not register asus backlight device\n");
diff --combined drivers/acpi/ibm_acpi.c
index 1e7abef404b0a44ef96d033f81c6ef4bb42f6a72,da08b9c62ffc5a5ba00192592a7eff0a50bc71df..130cc8c37e226a227d1182cb77efe2678207f752
@@@ -1714,7 -1714,7 +1714,7 @@@ static struct backlight_properties ibm_
  
  static int brightness_init(void)
  {
-       ibm_backlight_device = backlight_device_register("ibm", NULL,
+       ibm_backlight_device = backlight_device_register("ibm", NULL, NULL,
                                                         &ibm_backlight_data);
        if (IS_ERR(ibm_backlight_device)) {
                printk(IBM_ERR "Could not register backlight device\n");
@@@ -1825,9 -1825,9 +1825,9 @@@ static enum fan_control_commands fan_co
  static int fan_control_status_known;
  static u8 fan_control_initial_status;
  
 -static void fan_watchdog_fire(void *ignored);
 +static void fan_watchdog_fire(struct work_struct *ignored);
  static int fan_watchdog_maxinterval;
 -static DECLARE_WORK(fan_watchdog_task, fan_watchdog_fire, NULL);
 +static DECLARE_DELAYED_WORK(fan_watchdog_task, fan_watchdog_fire);
  
  static int fan_init(void)
  {
@@@ -2284,7 -2284,7 +2284,7 @@@ static int fan_write(char *buf
        return rc;
  }
  
 -static void fan_watchdog_fire(void *ignored)
 +static void fan_watchdog_fire(struct work_struct *ignored)
  {
        printk(IBM_NOTICE "fan watchdog: enabling fan\n");
        if (fan_set_enable()) {
@@@ -2417,7 -2417,7 +2417,7 @@@ static struct ibm_struct ibms[] = 
  static int dispatch_read(char *page, char **start, off_t off, int count,
                         int *eof, void *data)
  {
 -      struct ibm_struct *ibm = (struct ibm_struct *)data;
 +      struct ibm_struct *ibm = data;
        int len;
  
        if (!ibm || !ibm->read)
  static int dispatch_write(struct file *file, const char __user * userbuf,
                          unsigned long count, void *data)
  {
 -      struct ibm_struct *ibm = (struct ibm_struct *)data;
 +      struct ibm_struct *ibm = data;
        char *kernbuf;
        int ret;
  
  
  static void dispatch_notify(acpi_handle handle, u32 event, void *data)
  {
 -      struct ibm_struct *ibm = (struct ibm_struct *)data;
 +      struct ibm_struct *ibm = data;
  
        if (!ibm || !ibm->notify)
                return;
@@@ -2503,7 -2503,7 +2503,7 @@@ static int __init setup_notify(struct i
                       ibm->name, status);
                return -ENODEV;
        }
+       ibm->notify_installed = 1;
        return 0;
  }
  
@@@ -2580,7 -2580,6 +2580,6 @@@ static int __init ibm_init(struct ibm_s
                ret = setup_notify(ibm);
                if (ret < 0)
                        return ret;
-               ibm->notify_installed = 1;
        }
  
        return 0;
diff --combined drivers/acpi/video.c
index 53a9eb015d6b0fe889420a551de726e9b2b30fab,9200a46c38bdda5eeb2f2af0bd69dc0ecfb0f883..eb5141f9ef8f80a51e1ba1012e504bc7ff7ad9ae
@@@ -3,6 -3,7 +3,7 @@@
   *
   *  Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
   *  Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
+  *  Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
   *
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   *
  #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
  #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
  
- #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS    0x82
- #define       ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS        0x83
- #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS      0x84
- #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS     0x85
- #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF         0x86
+ #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS    0x85
+ #define       ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS        0x86
+ #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS      0x87
+ #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS     0x88
+ #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF         0x89
  
  #define ACPI_VIDEO_HEAD_INVALID               (~0u - 1)
  #define ACPI_VIDEO_HEAD_END           (~0u)
@@@ -386,7 -387,7 +387,7 @@@ acpi_video_device_EDID(struct acpi_vide
        if (ACPI_FAILURE(status))
                return -ENODEV;
  
 -      obj = (union acpi_object *)buffer.pointer;
 +      obj = buffer.pointer;
  
        if (obj && obj->type == ACPI_TYPE_BUFFER)
                *edid = obj;
@@@ -654,7 -655,8 +655,7 @@@ static struct proc_dir_entry *acpi_vide
  
  static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_device *dev =
 -          (struct acpi_video_device *)seq->private;
 +      struct acpi_video_device *dev = seq->private;
  
  
        if (!dev)
@@@ -687,7 -689,8 +688,7 @@@ acpi_video_device_info_open_fs(struct i
  static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
  {
        int status;
 -      struct acpi_video_device *dev =
 -          (struct acpi_video_device *)seq->private;
 +      struct acpi_video_device *dev = seq->private;
        unsigned long state;
  
  
@@@ -725,8 -728,8 +726,8 @@@ acpi_video_device_write_state(struct fi
                              size_t count, loff_t * data)
  {
        int status;
 -      struct seq_file *m = (struct seq_file *)file->private_data;
 -      struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
 +      struct seq_file *m = file->private_data;
 +      struct acpi_video_device *dev = m->private;
        char str[12] = { 0 };
        u32 state = 0;
  
  static int
  acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_device *dev =
 -          (struct acpi_video_device *)seq->private;
 +      struct acpi_video_device *dev = seq->private;
        int i;
  
  
@@@ -781,8 -785,8 +782,8 @@@ acpi_video_device_write_brightness(stru
                                   const char __user * buffer,
                                   size_t count, loff_t * data)
  {
 -      struct seq_file *m = (struct seq_file *)file->private_data;
 -      struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
 +      struct seq_file *m = file->private_data;
 +      struct acpi_video_device *dev = m->private;
        char str[4] = { 0 };
        unsigned int level = 0;
        int i;
  
  static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_device *dev =
 -          (struct acpi_video_device *)seq->private;
 +      struct acpi_video_device *dev = seq->private;
        int status;
        int i;
        union acpi_object *edid = NULL;
@@@ -862,7 -867,7 +863,7 @@@ static int acpi_video_device_add_fs(str
        if (!device)
                return -ENODEV;
  
 -      vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
 +      vid_dev = acpi_driver_data(device);
        if (!vid_dev)
                return -ENODEV;
  
@@@ -927,7 -932,7 +928,7 @@@ static int acpi_video_device_remove_fs(
  {
        struct acpi_video_device *vid_dev;
  
 -      vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
 +      vid_dev = acpi_driver_data(device);
        if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
                return -ENODEV;
  
  /* video bus */
  static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 +      struct acpi_video_bus *video = seq->private;
  
  
        if (!video)
@@@ -971,7 -976,7 +972,7 @@@ static int acpi_video_bus_info_open_fs(
  
  static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 +      struct acpi_video_bus *video = seq->private;
  
  
        if (!video)
@@@ -991,7 -996,7 +992,7 @@@ static int acpi_video_bus_ROM_open_fs(s
  
  static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 +      struct acpi_video_bus *video = seq->private;
        unsigned long options;
        int status;
  
@@@ -1029,7 -1034,7 +1030,7 @@@ acpi_video_bus_POST_info_open_fs(struc
  
  static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 +      struct acpi_video_bus *video = seq->private;
        int status;
        unsigned long id;
  
  
  static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
  {
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
 +      struct acpi_video_bus *video = seq->private;
  
  
        seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
@@@ -1075,8 -1080,8 +1076,8 @@@ acpi_video_bus_write_POST(struct file *
                          size_t count, loff_t * data)
  {
        int status;
 -      struct seq_file *m = (struct seq_file *)file->private_data;
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
 +      struct seq_file *m = file->private_data;
 +      struct acpi_video_bus *video = m->private;
        char str[12] = { 0 };
        unsigned long opt, options;
  
@@@ -1115,8 -1120,8 +1116,8 @@@ acpi_video_bus_write_DOS(struct file *f
                         size_t count, loff_t * data)
  {
        int status;
 -      struct seq_file *m = (struct seq_file *)file->private_data;
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
 +      struct seq_file *m = file->private_data;
 +      struct acpi_video_bus *video = m->private;
        char str[12] = { 0 };
        unsigned long opt;
  
@@@ -1146,7 -1151,7 +1147,7 @@@ static int acpi_video_bus_add_fs(struc
        struct acpi_video_bus *video;
  
  
 -      video = (struct acpi_video_bus *)acpi_driver_data(device);
 +      video = acpi_driver_data(device);
  
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
@@@ -1222,7 -1227,7 +1223,7 @@@ static int acpi_video_bus_remove_fs(str
        struct acpi_video_bus *video;
  
  
 -      video = (struct acpi_video_bus *)acpi_driver_data(device);
 +      video = acpi_driver_data(device);
  
        if (acpi_device_dir(device)) {
                remove_proc_entry("info", acpi_device_dir(device));
@@@ -1399,7 -1404,7 +1400,7 @@@ static int acpi_video_device_enumerate(
                return status;
        }
  
 -      dod = (union acpi_object *)buffer.pointer;
 +      dod = buffer.pointer;
        if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
                ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
                status = -EFAULT;
  
        count = 0;
        for (i = 0; i < dod->package.count; i++) {
 -              obj = (union acpi_object *)&dod->package.elements[i];
 +              obj = &dod->package.elements[i];
  
                if (obj->type != ACPI_TYPE_INTEGER) {
                        printk(KERN_ERR PREFIX "Invalid _DOD data\n");
@@@ -1505,8 -1510,34 +1506,34 @@@ static in
  acpi_video_get_next_level(struct acpi_video_device *device,
                          u32 level_current, u32 event)
  {
-       /*Fix me */
-       return level_current;
+       int min, max, min_above, max_below, i, l;
+       max = max_below = 0;
+       min = min_above = 255;
+       for (i = 0; i < device->brightness->count; i++) {
+               l = device->brightness->levels[i];
+               if (l < min)
+                       min = l;
+               if (l > max)
+                       max = l;
+               if (l < min_above && l > level_current)
+                       min_above = l;
+               if (l > max_below && l < level_current)
+                       max_below = l;
+       }
+       switch (event) {
+       case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
+               return (level_current < max) ? min_above : min;
+       case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
+               return (level_current < max) ? min_above : max;
+       case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
+               return (level_current > min) ? max_below : min;
+       case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
+       case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
+               return 0;
+       default:
+               return level_current;
+       }
  }
  
  static void
@@@ -1608,7 -1639,7 +1635,7 @@@ static int acpi_video_bus_stop_devices(
  
  static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
  {
 -      struct acpi_video_bus *video = (struct acpi_video_bus *)data;
 +      struct acpi_video_bus *video = data;
        struct acpi_device *device = NULL;
  
        printk("video bus notify\n");
  
  static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
  {
 -      struct acpi_video_device *video_device =
 -          (struct acpi_video_device *)data;
 +      struct acpi_video_device *video_device = data;
        struct acpi_device *device = NULL;
  
  
@@@ -1752,7 -1784,7 +1779,7 @@@ static int acpi_video_bus_remove(struc
        if (!device || !acpi_driver_data(device))
                return -EINVAL;
  
 -      video = (struct acpi_video_bus *)acpi_driver_data(device);
 +      video = acpi_driver_data(device);
  
        acpi_video_bus_stop_devices(video);
  
index 02cbb7fff24f0c5e812450fc476b4ea2bc5f804b,a4522e6c31ec2a68c9c6d897e88266b323368233..a7932a72d2988425de04921eba702eabe85e9121
@@@ -76,7 -76,7 +76,7 @@@ struct appledisplay 
        char *urbdata;                  /* interrupt URB data buffer */
        char *msgdata;                  /* control message data buffer */
  
 -      struct work_struct work;
 +      struct delayed_work work;
        int button_pressed;
        spinlock_t lock;
  };
@@@ -117,7 -117,7 +117,7 @@@ static void appledisplay_complete(struc
        case ACD_BTN_BRIGHT_UP:
        case ACD_BTN_BRIGHT_DOWN:
                pdata->button_pressed = 1;
 -              queue_work(wq, &pdata->work);
 +              queue_delayed_work(wq, &pdata->work, 0);
                break;
        case ACD_BTN_NONE:
        default:
@@@ -184,10 -184,9 +184,10 @@@ static struct backlight_properties appl
        .max_brightness = 0xFF
  };
  
 -static void appledisplay_work(void *private)
 +static void appledisplay_work(struct work_struct *work)
  {
 -      struct appledisplay *pdata = private;
 +      struct appledisplay *pdata =
 +              container_of(work, struct appledisplay, work.work);
        int retval;
  
        up(&pdata->bd->sem);
@@@ -217,7 -216,10 +217,7 @@@ static int appledisplay_probe(struct us
        iface_desc = iface->cur_altsetting;
        for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
                endpoint = &iface_desc->endpoint[i].desc;
 -              if (!int_in_endpointAddr &&
 -                  (endpoint->bEndpointAddress & USB_DIR_IN) &&
 -                  ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
 -                   USB_ENDPOINT_XFER_INT)) {
 +              if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) {
                        /* we found an interrupt in endpoint */
                        int_in_endpointAddr = endpoint->bEndpointAddress;
                        break;
        pdata->udev = udev;
  
        spin_lock_init(&pdata->lock);
 -      INIT_WORK(&pdata->work, appledisplay_work, pdata);
 +      INIT_DELAYED_WORK(&pdata->work, appledisplay_work);
  
        /* Allocate buffer for control messages */
        pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL);
        /* Register backlight device */
        snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
                atomic_inc_return(&count_displays) - 1);
-       pdata->bd = backlight_device_register(bl_name, pdata,
+       pdata->bd = backlight_device_register(bl_name, NULL, NULL,
                                                &appledisplay_bl_data);
        if (IS_ERR(pdata->bd)) {
                err("appledisplay: Backlight registration failed");
index 3feddf89d100b881bf75aa69aa2be55fa8bc42be,5341462b6b4803d407735a68eaceccb6cf72802e..2e976ffcde0fa53a3977da6e05ed1f61884f99c3
@@@ -1333,8 -1333,6 +1333,8 @@@ static int aty128_var_to_pll(u32 period
        if (vclk * 12 < c.ppll_min)
                vclk = c.ppll_min/12;
  
 +      pll->post_divider = -1;
 +
        /* now, find an acceptable divider */
        for (i = 0; i < sizeof(post_dividers); i++) {
                output_freq = post_dividers[i] * vclk;
                }
        }
  
 +      if (pll->post_divider < 0)
 +              return -EINVAL;
 +
        /* calculate feedback divider */
        n = c.ref_divider * output_freq;
        d = c.ref_clk;
@@@ -1834,7 -1829,7 +1834,7 @@@ static void aty128_bl_init(struct aty12
  
        snprintf(name, sizeof(name), "aty128bl%d", info->node);
  
-       bd = backlight_device_register(name, par, &aty128_bl_data);
+       bd = backlight_device_register(name, info->dev, par, &aty128_bl_data);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "aty128: Backlight registration failed\n");
index 09684d7a7ce942c8458d23fcad35f3cfa161958c,cc4bd8089fe2727e7fc421f92dc1df0d8fb34483..f2ebdd880085a6f69183160fa667062e3c499148
@@@ -203,6 -203,14 +203,6 @@@ static void ATIReduceRatio(int *Numerat
       *  The Hardware parameters for each card
       */
  
 -struct aty_cmap_regs {
 -      u8 windex;
 -      u8 lut;
 -      u8 mask;
 -      u8 rindex;
 -      u8 cntl;
 -};
 -
  struct pci_mmap_map {
        unsigned long voff;
        unsigned long poff;
@@@ -241,8 -249,7 +241,8 @@@ static int atyfb_sync(struct fb_info *i
       *  Internal routines
       */
  
 -static int aty_init(struct fb_info *info, const char *name);
 +static int aty_init(struct fb_info *info);
 +static void aty_resume_chip(struct fb_info *info);
  #ifdef CONFIG_ATARI
  static int store_video_par(char *videopar, unsigned char m64_num);
  #endif
@@@ -399,7 -406,7 +399,7 @@@ static struct 
        { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO },
        { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
        { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 },
 -      { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
 +      { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1024x768 },
        { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
  
        { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL },
@@@ -1488,6 -1495,10 +1488,6 @@@ static int atyfb_check_var(struct fb_va
        else
                info->var.accel_flags = 0;
  
 -#if 0 /* fbmon is not done. uncomment for 2.5.x -brad */
 -      if (!fbmon_valid_timings(pixclock, htotal, vtotal, info))
 -              return -EINVAL;
 -#endif
        aty_crtc_to_var(&crtc, var);
        var->pixclock = par->pll_ops->pll_to_var(info, &pll);
        return 0;
@@@ -1926,14 -1937,17 +1926,14 @@@ static void atyfb_save_palette(struct a
                aty_st_8(DAC_CNTL, tmp, par);
                aty_st_8(DAC_MASK, 0xff, par);
  
 -              writeb(i, &par->aty_cmap_regs->rindex);
 -              atyfb_save.r[enter][i] = readb(&par->aty_cmap_regs->lut);
 -              atyfb_save.g[enter][i] = readb(&par->aty_cmap_regs->lut);
 -              atyfb_save.b[enter][i] = readb(&par->aty_cmap_regs->lut);
 -              writeb(i, &par->aty_cmap_regs->windex);
 -              writeb(atyfb_save.r[1 - enter][i],
 -                     &par->aty_cmap_regs->lut);
 -              writeb(atyfb_save.g[1 - enter][i],
 -                     &par->aty_cmap_regs->lut);
 -              writeb(atyfb_save.b[1 - enter][i],
 -                     &par->aty_cmap_regs->lut);
 +              aty_st_8(DAC_R_INDEX, i, par);
 +              atyfb_save.r[enter][i] = aty_ld_8(DAC_DATA, par);
 +              atyfb_save.g[enter][i] = aty_ld_8(DAC_DATA, par);
 +              atyfb_save.b[enter][i] = aty_ld_8(DAC_DATA, par);
 +              aty_st_8(DAC_W_INDEX, i, par);
 +              aty_st_8(DAC_DATA, atyfb_save.r[1 - enter][i], par);
 +              aty_st_8(DAC_DATA, atyfb_save.g[1 - enter][i], par);
 +              aty_st_8(DAC_DATA, atyfb_save.b[1 - enter][i], par);
        }
  }
  
@@@ -1968,7 -1982,6 +1968,7 @@@ static void atyfb_palette(int enter
  
  #if defined(CONFIG_PM) && defined(CONFIG_PCI)
  
 +#ifdef CONFIG_PPC_PMAC
  /* Power management routines. Those are used for PowerBook sleep.
   */
  static int aty_power_mgmt(int sleep, struct atyfb_par *par)
  
        return timeout ? 0 : -EIO;
  }
 +#endif
  
  static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
  {
        struct fb_info *info = pci_get_drvdata(pdev);
        struct atyfb_par *par = (struct atyfb_par *) info->par;
  
 -#ifndef CONFIG_PPC_PMAC
 -      /* HACK ALERT ! Once I find a proper way to say to each driver
 -       * individually what will happen with it's PCI slot, I'll change
 -       * that. On laptops, the AGP slot is just unclocked, so D2 is
 -       * expected, while on desktops, the card is powered off
 -       */
 -      return 0;
 -#endif /* CONFIG_PPC_PMAC */
 -
        if (state.event == pdev->dev.power.power_state.event)
                return 0;
  
        par->asleep = 1;
        par->lock_blank = 1;
  
 +#ifdef CONFIG_PPC_PMAC
        /* Set chip to "suspend" mode */
        if (aty_power_mgmt(1, par)) {
                par->asleep = 0;
                release_console_sem();
                return -EIO;
        }
 +#else
 +      pci_set_power_state(pdev, pci_choose_state(pdev, state));
 +#endif
  
        release_console_sem();
  
@@@ -2080,15 -2097,8 +2080,15 @@@ static int atyfb_pci_resume(struct pci_
  
        acquire_console_sem();
  
 +#ifdef CONFIG_PPC_PMAC
        if (pdev->dev.power.power_state.event == 2)
                aty_power_mgmt(0, par);
 +#else
 +      pci_set_power_state(pdev, PCI_D0);
 +#endif
 +
 +      aty_resume_chip(info);
 +
        par->asleep = 0;
  
        /* Restore display */
@@@ -2211,7 -2221,7 +2211,7 @@@ static void aty_bl_init(struct atyfb_pa
  
        snprintf(name, sizeof(name), "atybl%d", info->node);
  
-       bd = backlight_device_register(name, par, &aty_bl_data);
+       bd = backlight_device_register(name, info->dev, par, &aty_bl_data);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "aty: Backlight registration failed\n");
@@@ -2334,16 -2344,24 +2334,16 @@@ static int __devinit atyfb_get_timings_
  }
  #endif /* defined(__i386__) && defined(CONFIG_FB_ATY_GENERIC_LCD) */
  
 -static int __devinit aty_init(struct fb_info *info, const char *name)
 +static int __devinit aty_init(struct fb_info *info)
  {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        const char *ramname = NULL, *xtal;
        int gtb_memsize, has_var = 0;
        struct fb_var_screeninfo var;
 -      u8 pll_ref_div;
 -      u32 i;
 -#if defined(CONFIG_PPC)
 -      int sense;
 -#endif
  
        init_waitqueue_head(&par->vblank.wait);
        spin_lock_init(&par->int_lock);
  
 -      par->aty_cmap_regs =
 -          (struct aty_cmap_regs __iomem *) (par->ati_regbase + 0xc0);
 -
  #ifdef CONFIG_PPC_PMAC
        /* The Apple iBook1 uses non-standard memory frequencies. We detect it
         * and set the frequency manually. */
                        par->pll_limits.mclk = 63;
        }
  
 -      if (M64_HAS(GTB_DSP)
 -          && (pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par))) {
 -              int diff1, diff2;
 -              diff1 = 510 * 14 / pll_ref_div - par->pll_limits.pll_max;
 -              diff2 = 510 * 29 / pll_ref_div - par->pll_limits.pll_max;
 -              if (diff1 < 0)
 -                      diff1 = -diff1;
 -              if (diff2 < 0)
 -                      diff2 = -diff2;
 -              if (diff2 < diff1) {
 -                      par->ref_clk_per = 1000000000000ULL / 29498928;
 -                      xtal = "29.498928";
 +      if (M64_HAS(GTB_DSP)) {
 +              u8 pll_ref_div = aty_ld_pll_ct(PLL_REF_DIV, par);
 +
 +              if (pll_ref_div) {
 +                      int diff1, diff2;
 +                      diff1 = 510 * 14 / pll_ref_div - par->pll_limits.pll_max;
 +                      diff2 = 510 * 29 / pll_ref_div - par->pll_limits.pll_max;
 +                      if (diff1 < 0)
 +                              diff1 = -diff1;
 +                      if (diff2 < 0)
 +                              diff2 = -diff2;
 +                      if (diff2 < diff1) {
 +                              par->ref_clk_per = 1000000000000ULL / 29498928;
 +                              xtal = "29.498928";
 +                      }
                }
        }
  #endif /* CONFIG_FB_ATY_CT */
        if(par->pll_ops->get_pll)
                par->pll_ops->get_pll(info, &saved_pll);
  
 -      i = aty_ld_le32(MEM_CNTL, par);
 +      par->mem_cntl = aty_ld_le32(MEM_CNTL, par);
        gtb_memsize = M64_HAS(GTB_DSP);
        if (gtb_memsize)
 -              switch (i & 0xF) {      /* 0xF used instead of MEM_SIZE_ALIAS */
 +              switch (par->mem_cntl & 0xF) {  /* 0xF used instead of MEM_SIZE_ALIAS */
                case MEM_SIZE_512K:
                        info->fix.smem_len = 0x80000;
                        break;
                default:
                        info->fix.smem_len = 0x80000;
        } else
 -              switch (i & MEM_SIZE_ALIAS) {
 +              switch (par->mem_cntl & MEM_SIZE_ALIAS) {
                case MEM_SIZE_512K:
                        info->fix.smem_len = 0x80000;
                        break;
  
        if (vram) {
                info->fix.smem_len = vram * 1024;
 -              i = i & ~(gtb_memsize ? 0xF : MEM_SIZE_ALIAS);
 +              par->mem_cntl &= ~(gtb_memsize ? 0xF : MEM_SIZE_ALIAS);
                if (info->fix.smem_len <= 0x80000)
 -                      i |= MEM_SIZE_512K;
 +                      par->mem_cntl |= MEM_SIZE_512K;
                else if (info->fix.smem_len <= 0x100000)
 -                      i |= MEM_SIZE_1M;
 +                      par->mem_cntl |= MEM_SIZE_1M;
                else if (info->fix.smem_len <= 0x200000)
 -                      i |= gtb_memsize ? MEM_SIZE_2M_GTB : MEM_SIZE_2M;
 +                      par->mem_cntl |= gtb_memsize ? MEM_SIZE_2M_GTB : MEM_SIZE_2M;
                else if (info->fix.smem_len <= 0x400000)
 -                      i |= gtb_memsize ? MEM_SIZE_4M_GTB : MEM_SIZE_4M;
 +                      par->mem_cntl |= gtb_memsize ? MEM_SIZE_4M_GTB : MEM_SIZE_4M;
                else if (info->fix.smem_len <= 0x600000)
 -                      i |= gtb_memsize ? MEM_SIZE_6M_GTB : MEM_SIZE_6M;
 +                      par->mem_cntl |= gtb_memsize ? MEM_SIZE_6M_GTB : MEM_SIZE_6M;
                else
 -                      i |= gtb_memsize ? MEM_SIZE_8M_GTB : MEM_SIZE_8M;
 -              aty_st_le32(MEM_CNTL, i, par);
 +                      par->mem_cntl |= gtb_memsize ? MEM_SIZE_8M_GTB : MEM_SIZE_8M;
 +              aty_st_le32(MEM_CNTL, par->mem_cntl, par);
        }
  
        /*
  #endif
        if(par->pll_ops->init_pll)
                par->pll_ops->init_pll(info, &par->pll);
 +      if (par->pll_ops->resume_pll)
 +              par->pll_ops->resume_pll(info, &par->pll);
  
        /*
 -       *  Last page of 8 MB (4 MB on ISA) aperture is MMIO
 -       *  FIXME: we should use the auxiliary aperture instead so we can access
 -       *  the full 8 MB of video RAM on 8 MB boards
 +       *  Last page of 8 MB (4 MB on ISA) aperture is MMIO,
 +       *  unless the auxiliary register aperture is used.
         */
  
        if (!par->aux_start &&
                                has_var = 1;
                } else {
                        if (default_vmode == VMODE_CHOOSE) {
 +                              int sense;
                                if (M64_HAS(G3_PB_1024x768))
                                        /* G3 PowerBook with 1024x768 LCD */
                                        default_vmode = VMODE_1024_768_60;
        fb_list = info;
  
        PRINTKI("fb%d: %s frame buffer device on %s\n",
 -             info->node, info->fix.id, name);
 +              info->node, info->fix.id, par->bus_type == ISA ? "ISA" : "PCI");
        return 0;
  
  aty_init_exit:
        return -1;
  }
  
 +static void aty_resume_chip(struct fb_info *info)
 +{
 +      struct atyfb_par *par = info->par;
 +
 +      aty_st_le32(MEM_CNTL, par->mem_cntl, par);
 +
 +      if (par->pll_ops->resume_pll)
 +              par->pll_ops->resume_pll(info, &par->pll);
 +
 +      if (par->aux_start)
 +              aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par);
 +}
 +
  #ifdef CONFIG_ATARI
  static int __devinit store_video_par(char *video_str, unsigned char m64_num)
  {
@@@ -2826,9 -2826,9 +2826,9 @@@ static int atyfb_blank(int blank, struc
  #endif
  
        gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par);
 +      gen_cntl &= ~0x400004c;
        switch (blank) {
 -              case FB_BLANK_UNBLANK:
 -                      gen_cntl &= ~0x400004c;
 +              case FB_BLANK_UNBLANK:
                        break;
                case FB_BLANK_NORMAL:
                        gen_cntl |= 0x4000040;
  static void aty_st_pal(u_int regno, u_int red, u_int green, u_int blue,
                       const struct atyfb_par *par)
  {
 -#ifdef CONFIG_ATARI
 -      out_8(&par->aty_cmap_regs->windex, regno);
 -      out_8(&par->aty_cmap_regs->lut, red);
 -      out_8(&par->aty_cmap_regs->lut, green);
 -      out_8(&par->aty_cmap_regs->lut, blue);
 -#else
 -      writeb(regno, &par->aty_cmap_regs->windex);
 -      writeb(red, &par->aty_cmap_regs->lut);
 -      writeb(green, &par->aty_cmap_regs->lut);
 -      writeb(blue, &par->aty_cmap_regs->lut);
 -#endif
 +      aty_st_8(DAC_W_INDEX, regno, par);
 +      aty_st_8(DAC_DATA, red, par);
 +      aty_st_8(DAC_DATA, green, par);
 +      aty_st_8(DAC_DATA, blue, par);
  }
  
      /*
@@@ -3175,7 -3182,7 +3175,7 @@@ static int __devinit atyfb_setup_sparc(
  
  #ifdef __i386__
  #ifdef CONFIG_FB_ATY_GENERIC_LCD
 -static void aty_init_lcd(struct atyfb_par *par, u32 bios_base)
 +static void __devinit aty_init_lcd(struct atyfb_par *par, u32 bios_base)
  {
        u32 driv_inf_tab, sig;
        u16 lcd_ofs;
@@@ -3520,10 -3527,6 +3520,10 @@@ static int __devinit atyfb_setup_generi
  atyfb_setup_generic_fail:
        iounmap(par->ati_regbase);
        par->ati_regbase = NULL;
 +      if (info->screen_base) {
 +              iounmap(info->screen_base);
 +              info->screen_base = NULL;
 +      }
        return ret;
  }
  
@@@ -3591,7 -3594,7 +3591,7 @@@ static int __devinit atyfb_pci_probe(st
        pci_set_drvdata(pdev, info);
  
        /* Init chip & register framebuffer */
 -      if (aty_init(info, "PCI"))
 +      if (aty_init(info))
                goto err_release_io;
  
  #ifdef __sparc__
@@@ -3638,13 -3641,12 +3638,13 @@@ err_release_mem
  
  #ifdef CONFIG_ATARI
  
 -static int __devinit atyfb_atari_probe(void)
 +static int __init atyfb_atari_probe(void)
  {
        struct atyfb_par *par;
        struct fb_info *info;
        int m64_num;
        u32 clock_r;
 +      int num_found = 0;
  
        for (m64_num = 0; m64_num < mach64_count; m64_num++) {
                if (!phys_vmembase[m64_num] || !phys_size[m64_num] ||
                        break;
                }
  
 -              if (aty_init(info, "ISA bus")) {
 +              /* Fake pci_id for correct_chipset() */
 +              switch (aty_ld_le32(CONFIG_CHIP_ID, par) & CFG_CHIP_TYPE) {
 +              case 0x00d7:
 +                      par->pci_id = PCI_CHIP_MACH64GX;
 +                      break;
 +              case 0x0057:
 +                      par->pci_id = PCI_CHIP_MACH64CX;
 +                      break;
 +              default:
 +                      break;
 +              }
 +
 +              if (correct_chipset(par) || aty_init(info)) {
 +                      iounmap(info->screen_base);
 +                      iounmap(par->ati_regbase);
                        framebuffer_release(info);
 -                      /* This is insufficient! kernel_map has added two large chunks!! */
 -                      return -ENXIO;
 +              } else {
 +                      num_found++;
                }
        }
 +
 +      return num_found ? 0 : -ENXIO;
  }
  
  #endif /* CONFIG_ATARI */
  
 +#ifdef CONFIG_PCI
 +
  static void __devexit atyfb_remove(struct fb_info *info)
  {
        struct atyfb_par *par = (struct atyfb_par *) info->par;
        framebuffer_release(info);
  }
  
 -#ifdef CONFIG_PCI
  
  static void __devexit atyfb_pci_remove(struct pci_dev *pdev)
  {
@@@ -3801,7 -3786,7 +3801,7 @@@ static struct pci_driver atyfb_driver 
  #endif /* CONFIG_PCI */
  
  #ifndef MODULE
 -static int __devinit atyfb_setup(char *options)
 +static int __init atyfb_setup(char *options)
  {
        char *this_opt;
  
  }
  #endif  /*  MODULE  */
  
 -static int __devinit atyfb_init(void)
 +static int __init atyfb_init(void)
  {
      int err1 = 1, err2 = 1;
  #ifndef MODULE
index db8c191b12013e941c1ab61cea7db7101763bdc0,1d97cdf6f38249ca3bb8b24f3f2be512f2df1cde..9601bfe309ac2744c922a1f612eb4b6188e12aa0
  #include <linux/err.h>
  #include <linux/fb.h>
  
 +
 +#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
 +                         defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
 +/* This callback gets called when something important happens inside a
 + * framebuffer driver. We're looking if that important event is blanking,
 + * and if it is, we're switching backlight power as well ...
 + */
 +static int fb_notifier_callback(struct notifier_block *self,
 +                              unsigned long event, void *data)
 +{
 +      struct backlight_device *bd;
 +      struct fb_event *evdata = data;
 +
 +      /* If we aren't interested in this event, skip it immediately ... */
 +      if (event != FB_EVENT_BLANK)
 +              return 0;
 +
 +      bd = container_of(self, struct backlight_device, fb_notif);
 +      down(&bd->sem);
 +      if (bd->props)
 +              if (!bd->props->check_fb ||
 +                  bd->props->check_fb(evdata->info)) {
 +                      bd->props->fb_blank = *(int *)evdata->data;
 +                      if (likely(bd->props && bd->props->update_status))
 +                              bd->props->update_status(bd);
 +              }
 +      up(&bd->sem);
 +      return 0;
 +}
 +
 +static int backlight_register_fb(struct backlight_device *bd)
 +{
 +      memset(&bd->fb_notif, 0, sizeof(bd->fb_notif));
 +      bd->fb_notif.notifier_call = fb_notifier_callback;
 +
 +      return fb_register_client(&bd->fb_notif);
 +}
 +
 +static void backlight_unregister_fb(struct backlight_device *bd)
 +{
 +      fb_unregister_client(&bd->fb_notif);
 +}
 +#else
 +static inline int backlight_register_fb(struct backlight_device *bd)
 +{
 +      return 0;
 +}
 +
 +static inline void backlight_unregister_fb(struct backlight_device *bd)
 +{
 +}
 +#endif /* CONFIG_FB */
 +
  static ssize_t backlight_show_power(struct class_device *cdev, char *buf)
  {
        int rc = -ENXIO;
@@@ -195,7 -142,7 +195,7 @@@ static struct class backlight_class = 
        .store  = _store,                                       \
  }
  
 -static struct class_device_attribute bl_class_device_attributes[] = {
 +static const struct class_device_attribute bl_class_device_attributes[] = {
        DECLARE_ATTR(power, 0644, backlight_show_power, backlight_store_power),
        DECLARE_ATTR(brightness, 0644, backlight_show_brightness,
                     backlight_store_brightness),
        DECLARE_ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
  };
  
 -/* This callback gets called when something important happens inside a
 - * framebuffer driver. We're looking if that important event is blanking,
 - * and if it is, we're switching backlight power as well ...
 - */
 -static int fb_notifier_callback(struct notifier_block *self,
 -                              unsigned long event, void *data)
 -{
 -      struct backlight_device *bd;
 -      struct fb_event *evdata =(struct fb_event *)data;
 -
 -      /* If we aren't interested in this event, skip it immediately ... */
 -      if (event != FB_EVENT_BLANK)
 -              return 0;
 -
 -      bd = container_of(self, struct backlight_device, fb_notif);
 -      down(&bd->sem);
 -      if (bd->props)
 -              if (!bd->props->check_fb ||
 -                  bd->props->check_fb(evdata->info)) {
 -                      bd->props->fb_blank = *(int *)evdata->data;
 -                      if (likely(bd->props && bd->props->update_status))
 -                              bd->props->update_status(bd);
 -              }
 -      up(&bd->sem);
 -      return 0;
 -}
 -
  /**
   * backlight_device_register - create and register a new object of
   *   backlight_device class.
   * Creates and registers new backlight class_device. Returns either an
   * ERR_PTR() or a pointer to the newly allocated device.
   */
- struct backlight_device *backlight_device_register(const char *name, void *devdata,
-                                                  struct backlight_properties *bp)
+ struct backlight_device *backlight_device_register(const char *name,
+       struct device *dev,
+       void *devdata,
+       struct backlight_properties *bp)
  {
        int i, rc;
        struct backlight_device *new_bd;
        new_bd->props = bp;
        memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev));
        new_bd->class_dev.class = &backlight_class;
+       new_bd->class_dev.dev = dev;
        strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN);
        class_set_devdata(&new_bd->class_dev, devdata);
  
@@@ -241,7 -218,10 +244,7 @@@ error:            kfree(new_bd)
                return ERR_PTR(rc);
        }
  
 -      memset(&new_bd->fb_notif, 0, sizeof(new_bd->fb_notif));
 -      new_bd->fb_notif.notifier_call = fb_notifier_callback;
 -
 -      rc = fb_register_client(&new_bd->fb_notif);
 +      rc = backlight_register_fb(new_bd);
        if (unlikely(rc))
                goto error;
  
@@@ -282,10 -262,16 +285,10 @@@ void backlight_device_unregister(struc
                                         &bl_class_device_attributes[i]);
  
        down(&bd->sem);
 -      if (likely(bd->props && bd->props->update_status)) {
 -              bd->props->brightness = 0;
 -              bd->props->power = 0;
 -              bd->props->update_status(bd);
 -      }
 -
        bd->props = NULL;
        up(&bd->sem);
  
 -      fb_unregister_client(&bd->fb_notif);
 +      backlight_unregister_fb(bd);
  
        class_device_unregister(&bd->class_dev);
  }
index 345e8b1c1af86cbc89378ca988dd28ca40d89224,a160c4de2ca2f209a5b769fd8076d51ac8131df9..1a13966b7d5b04d5aaa3a45a0b72e68638982806
@@@ -40,7 -40,6 +40,7 @@@
  #include <linux/init.h>
  #include <linux/pci.h>
  #include <linux/backlight.h>
 +#include <linux/bitrev.h>
  #ifdef CONFIG_MTRR
  #include <asm/mtrr.h>
  #endif
@@@ -384,7 -383,7 +384,7 @@@ static void riva_bl_init(struct riva_pa
  
        snprintf(name, sizeof(name), "rivabl%d", info->node);
  
-       bd = backlight_device_register(name, par, &riva_bl_data);
+       bd = backlight_device_register(name, info->dev, par, &riva_bl_data);
        if (IS_ERR(bd)) {
                info->bl_dev = NULL;
                printk(KERN_WARNING "riva: Backlight registration failed\n");
@@@ -522,13 -521,48 +522,13 @@@ static inline unsigned char MISCin(stru
        return (VGA_RD08(par->riva.PVIO, 0x3cc));
  }
  
 -static u8 byte_rev[256] = {
 -      0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
 -      0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
 -      0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
 -      0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
 -      0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
 -      0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
 -      0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
 -      0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
 -      0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
 -      0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
 -      0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
 -      0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
 -      0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
 -      0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
 -      0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
 -      0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
 -      0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
 -      0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
 -      0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
 -      0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
 -      0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
 -      0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
 -      0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
 -      0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
 -      0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
 -      0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
 -      0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
 -      0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
 -      0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
 -      0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
 -      0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
 -      0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
 -};
 -
  static inline void reverse_order(u32 *l)
  {
        u8 *a = (u8 *)l;
 -      *a = byte_rev[*a], a++;
 -      *a = byte_rev[*a], a++;
 -      *a = byte_rev[*a], a++;
 -      *a = byte_rev[*a];
 +      a[0] = bitrev8(a[0]);
 +      a[1] = bitrev8(a[1]);
 +      a[2] = bitrev8(a[2]);
 +      a[3] = bitrev8(a[3]);
  }
  
  /* ------------------------------------------------------------------------- *
@@@ -740,12 -774,11 +740,12 @@@ static void riva_load_state(struct riva
   * CALLED FROM:
   * rivafb_set_par()
   */
 -static void riva_load_video_mode(struct fb_info *info)
 +static int riva_load_video_mode(struct fb_info *info)
  {
        int bpp, width, hDisplaySize, hDisplay, hStart,
            hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock;
        int hBlankStart, hBlankEnd, vBlankStart, vBlankEnd;
 +      int rc;
        struct riva_par *par = info->par;
        struct riva_regs newmode;
        
        else
                newmode.misc_output |= 0x80;    
  
 -      par->riva.CalcStateExt(&par->riva, &newmode.ext, bpp, width,
 -                                hDisplaySize, height, dotClock);
 +      rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width,
 +                        hDisplaySize, height, dotClock);
 +      if (rc)
 +              goto out;
  
        newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) &
                0xfff000ff;
        par->current_state = newmode;
        riva_load_state(par, &par->current_state);
        par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */
 +
 +out:
        rivafb_blank(FB_BLANK_UNBLANK, info);
        NVTRACE_LEAVE();
 +
 +      return rc;
  }
  
  static void riva_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb)
@@@ -1259,15 -1286,12 +1259,15 @@@ static int rivafb_check_var(struct fb_v
  static int rivafb_set_par(struct fb_info *info)
  {
        struct riva_par *par = info->par;
 +      int rc = 0;
  
        NVTRACE_ENTER();
        /* vgaHWunlock() + riva unlock (0x7F) */
        CRTCout(par, 0x11, 0xFF);
        par->riva.LockUnlock(&par->riva, 0);
 -      riva_load_video_mode(info);
 +      rc = riva_load_video_mode(info);
 +      if (rc)
 +              goto out;
        if(!(info->flags & FBINFO_HWACCEL_DISABLED))
                riva_setup_accel(info);
        
                info->pixmap.scan_align = 1;
        else
                info->pixmap.scan_align = 4;
 +
 +out:
        NVTRACE_LEAVE();
 -      return 0;
 +      return rc;
  }
  
  /**