aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-03-11 19:21:17 -0500
committerJeff Garzik <jeff@garzik.org>2006-03-11 19:21:17 -0500
commitce1e7a2ac721eb9d825b63f74752d0c9e0c635c2 (patch)
treea7c0d18d6486734dffb9498e30db5b226b6e23bf /drivers
parentc2956a3b0d1c17b38da369811a6ce93eb7a01a04 (diff)
parent75deb6fa985bd3162b9472f1fc394e23294da816 (diff)
Merge branch 'upstream'
Diffstat (limited to 'drivers')
-rw-r--r--drivers/atm/fore200e.c36
-rw-r--r--drivers/block/DAC960.c3
-rw-r--r--drivers/char/hw_random.c2
-rw-r--r--drivers/char/mmtimer.c2
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c24
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c23
-rw-r--r--drivers/edac/Kconfig18
-rw-r--r--drivers/edac/edac_mc.c12
-rw-r--r--drivers/firmware/dcdbas.c8
-rw-r--r--drivers/ide/legacy/ide-cs.c1
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c6
-rw-r--r--drivers/input/mouse/psmouse-base.c2
-rw-r--r--drivers/isdn/hisax/config.c2
-rw-r--r--drivers/isdn/hisax/hfc_pci.c2
-rw-r--r--drivers/isdn/hisax/hfc_usb.c32
-rw-r--r--drivers/isdn/i4l/isdn_tty.c1
-rw-r--r--drivers/macintosh/windfarm_core.c7
-rw-r--r--drivers/macintosh/windfarm_cpufreq_clamp.c8
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c32
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c25
-rw-r--r--drivers/macintosh/windfarm_pid.c4
-rw-r--r--drivers/macintosh/windfarm_pm112.c8
-rw-r--r--drivers/md/raid1.c13
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c2
-rw-r--r--drivers/media/dvb/bt8xx/bt878.c2
-rw-r--r--drivers/media/dvb/bt8xx/dst.c2
-rw-r--r--drivers/media/dvb/dvb-core/demux.h2
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c8
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/dvb/frontends/Kconfig2
-rw-r--r--drivers/media/dvb/frontends/mt312.c116
-rw-r--r--drivers/media/dvb/frontends/mt312.h6
-rw-r--r--drivers/media/dvb/frontends/stv0297.c4
-rw-r--r--drivers/media/dvb/ttpci/av7110.c9
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c3
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c4
-rw-r--r--drivers/media/video/cpia.c2
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c4
-rw-r--r--drivers/media/video/saa7115.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c21
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c12
-rw-r--r--drivers/media/video/tda8290.c8
-rw-r--r--drivers/media/video/tuner-core.c5
-rw-r--r--drivers/media/video/videocodec.h2
-rw-r--r--drivers/media/video/zr36050.c2
-rw-r--r--drivers/media/video/zr36060.c2
-rw-r--r--drivers/media/video/zr36120_i2c.c2
-rw-r--r--drivers/misc/ibmasm/ibmasm.h9
-rw-r--r--drivers/mmc/au1xmmc.c24
-rw-r--r--drivers/mtd/redboot.c22
-rw-r--r--drivers/net/chelsio/espi.c4
-rw-r--r--drivers/net/e1000/e1000.h3
-rw-r--r--drivers/net/e1000/e1000_main.c119
-rw-r--r--drivers/net/pcmcia/axnet_cs.c1
-rw-r--r--drivers/net/s2io.c1
-rw-r--r--drivers/net/tg3.c87
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c5
-rw-r--r--drivers/parport/parport_serial.c11
-rw-r--r--drivers/pcmcia/ds.c40
-rw-r--r--drivers/s390/block/dasd.c38
-rw-r--r--drivers/s390/block/dasd_genhd.c2
-rw-r--r--drivers/s390/block/dasd_int.h7
-rw-r--r--drivers/s390/block/dasd_proc.c3
-rw-r--r--drivers/s390/cio/chsc.c5
-rw-r--r--drivers/s390/net/smsgiucv.c2
-rw-r--r--drivers/scsi/ahci.c14
-rw-r--r--drivers/scsi/ata_piix.c315
-rw-r--r--drivers/scsi/libata-core.c1003
-rw-r--r--drivers/scsi/libata-scsi.c2
-rw-r--r--drivers/scsi/libata.h1
-rw-r--r--drivers/scsi/sata_promise.c2
-rw-r--r--drivers/scsi/sata_sil.c99
-rw-r--r--drivers/scsi/sata_sil24.c1
-rw-r--r--drivers/scsi/sr_ioctl.c2
-rw-r--r--drivers/serial/ioc4_serial.c6
-rw-r--r--drivers/serial/ip22zilog.c4
-rw-r--r--drivers/serial/serial_core.c32
-rw-r--r--drivers/serial/sn_console.c2
-rw-r--r--drivers/usb/serial/usb-serial.c10
-rw-r--r--drivers/video/arcfb.c5
-rw-r--r--drivers/video/aty/aty128fb.c7
-rw-r--r--drivers/video/aty/radeon_monitor.c4
-rw-r--r--drivers/video/backlight/backlight.c2
-rw-r--r--drivers/video/backlight/lcd.c2
-rw-r--r--drivers/video/imsttfb.c2
-rw-r--r--drivers/video/intelfb/intelfbdrv.c50
-rw-r--r--drivers/video/kyro/STG4000VTG.c2
-rw-r--r--drivers/video/neofb.c4
-rw-r--r--drivers/video/s1d13xxxfb.c3
-rw-r--r--drivers/video/savage/savagefb_driver.c2
-rw-r--r--drivers/video/tdfxfb.c42
93 files changed, 1496 insertions, 1008 deletions
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 14f6a6201da3..05983a312d50 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -555,7 +555,7 @@ fore200e_pca_reset(struct fore200e* fore200e)
555} 555}
556 556
557 557
558static int __init 558static int __devinit
559fore200e_pca_map(struct fore200e* fore200e) 559fore200e_pca_map(struct fore200e* fore200e)
560{ 560{
561 DPRINTK(2, "device %s being mapped in memory\n", fore200e->name); 561 DPRINTK(2, "device %s being mapped in memory\n", fore200e->name);
@@ -589,7 +589,7 @@ fore200e_pca_unmap(struct fore200e* fore200e)
589} 589}
590 590
591 591
592static int __init 592static int __devinit
593fore200e_pca_configure(struct fore200e* fore200e) 593fore200e_pca_configure(struct fore200e* fore200e)
594{ 594{
595 struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev; 595 struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev;
@@ -2125,7 +2125,7 @@ fore200e_change_qos(struct atm_vcc* vcc,struct atm_qos* qos, int flags)
2125} 2125}
2126 2126
2127 2127
2128static int __init 2128static int __devinit
2129fore200e_irq_request(struct fore200e* fore200e) 2129fore200e_irq_request(struct fore200e* fore200e)
2130{ 2130{
2131 if (request_irq(fore200e->irq, fore200e_interrupt, SA_SHIRQ, fore200e->name, fore200e->atm_dev) < 0) { 2131 if (request_irq(fore200e->irq, fore200e_interrupt, SA_SHIRQ, fore200e->name, fore200e->atm_dev) < 0) {
@@ -2148,7 +2148,7 @@ fore200e_irq_request(struct fore200e* fore200e)
2148} 2148}
2149 2149
2150 2150
2151static int __init 2151static int __devinit
2152fore200e_get_esi(struct fore200e* fore200e) 2152fore200e_get_esi(struct fore200e* fore200e)
2153{ 2153{
2154 struct prom_data* prom = fore200e_kmalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA); 2154 struct prom_data* prom = fore200e_kmalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA);
@@ -2180,7 +2180,7 @@ fore200e_get_esi(struct fore200e* fore200e)
2180} 2180}
2181 2181
2182 2182
2183static int __init 2183static int __devinit
2184fore200e_alloc_rx_buf(struct fore200e* fore200e) 2184fore200e_alloc_rx_buf(struct fore200e* fore200e)
2185{ 2185{
2186 int scheme, magn, nbr, size, i; 2186 int scheme, magn, nbr, size, i;
@@ -2245,7 +2245,7 @@ fore200e_alloc_rx_buf(struct fore200e* fore200e)
2245} 2245}
2246 2246
2247 2247
2248static int __init 2248static int __devinit
2249fore200e_init_bs_queue(struct fore200e* fore200e) 2249fore200e_init_bs_queue(struct fore200e* fore200e)
2250{ 2250{
2251 int scheme, magn, i; 2251 int scheme, magn, i;
@@ -2308,7 +2308,7 @@ fore200e_init_bs_queue(struct fore200e* fore200e)
2308} 2308}
2309 2309
2310 2310
2311static int __init 2311static int __devinit
2312fore200e_init_rx_queue(struct fore200e* fore200e) 2312fore200e_init_rx_queue(struct fore200e* fore200e)
2313{ 2313{
2314 struct host_rxq* rxq = &fore200e->host_rxq; 2314 struct host_rxq* rxq = &fore200e->host_rxq;
@@ -2368,7 +2368,7 @@ fore200e_init_rx_queue(struct fore200e* fore200e)
2368} 2368}
2369 2369
2370 2370
2371static int __init 2371static int __devinit
2372fore200e_init_tx_queue(struct fore200e* fore200e) 2372fore200e_init_tx_queue(struct fore200e* fore200e)
2373{ 2373{
2374 struct host_txq* txq = &fore200e->host_txq; 2374 struct host_txq* txq = &fore200e->host_txq;
@@ -2431,7 +2431,7 @@ fore200e_init_tx_queue(struct fore200e* fore200e)
2431} 2431}
2432 2432
2433 2433
2434static int __init 2434static int __devinit
2435fore200e_init_cmd_queue(struct fore200e* fore200e) 2435fore200e_init_cmd_queue(struct fore200e* fore200e)
2436{ 2436{
2437 struct host_cmdq* cmdq = &fore200e->host_cmdq; 2437 struct host_cmdq* cmdq = &fore200e->host_cmdq;
@@ -2487,7 +2487,7 @@ fore200e_param_bs_queue(struct fore200e* fore200e,
2487} 2487}
2488 2488
2489 2489
2490static int __init 2490static int __devinit
2491fore200e_initialize(struct fore200e* fore200e) 2491fore200e_initialize(struct fore200e* fore200e)
2492{ 2492{
2493 struct cp_queues __iomem * cpq; 2493 struct cp_queues __iomem * cpq;
@@ -2539,7 +2539,7 @@ fore200e_initialize(struct fore200e* fore200e)
2539} 2539}
2540 2540
2541 2541
2542static void __init 2542static void __devinit
2543fore200e_monitor_putc(struct fore200e* fore200e, char c) 2543fore200e_monitor_putc(struct fore200e* fore200e, char c)
2544{ 2544{
2545 struct cp_monitor __iomem * monitor = fore200e->cp_monitor; 2545 struct cp_monitor __iomem * monitor = fore200e->cp_monitor;
@@ -2551,7 +2551,7 @@ fore200e_monitor_putc(struct fore200e* fore200e, char c)
2551} 2551}
2552 2552
2553 2553
2554static int __init 2554static int __devinit
2555fore200e_monitor_getc(struct fore200e* fore200e) 2555fore200e_monitor_getc(struct fore200e* fore200e)
2556{ 2556{
2557 struct cp_monitor __iomem * monitor = fore200e->cp_monitor; 2557 struct cp_monitor __iomem * monitor = fore200e->cp_monitor;
@@ -2576,7 +2576,7 @@ fore200e_monitor_getc(struct fore200e* fore200e)
2576} 2576}
2577 2577
2578 2578
2579static void __init 2579static void __devinit
2580fore200e_monitor_puts(struct fore200e* fore200e, char* str) 2580fore200e_monitor_puts(struct fore200e* fore200e, char* str)
2581{ 2581{
2582 while (*str) { 2582 while (*str) {
@@ -2591,7 +2591,7 @@ fore200e_monitor_puts(struct fore200e* fore200e, char* str)
2591} 2591}
2592 2592
2593 2593
2594static int __init 2594static int __devinit
2595fore200e_start_fw(struct fore200e* fore200e) 2595fore200e_start_fw(struct fore200e* fore200e)
2596{ 2596{
2597 int ok; 2597 int ok;
@@ -2622,7 +2622,7 @@ fore200e_start_fw(struct fore200e* fore200e)
2622} 2622}
2623 2623
2624 2624
2625static int __init 2625static int __devinit
2626fore200e_load_fw(struct fore200e* fore200e) 2626fore200e_load_fw(struct fore200e* fore200e)
2627{ 2627{
2628 u32* fw_data = (u32*) fore200e->bus->fw_data; 2628 u32* fw_data = (u32*) fore200e->bus->fw_data;
@@ -2648,7 +2648,7 @@ fore200e_load_fw(struct fore200e* fore200e)
2648} 2648}
2649 2649
2650 2650
2651static int __init 2651static int __devinit
2652fore200e_register(struct fore200e* fore200e) 2652fore200e_register(struct fore200e* fore200e)
2653{ 2653{
2654 struct atm_dev* atm_dev; 2654 struct atm_dev* atm_dev;
@@ -2675,7 +2675,7 @@ fore200e_register(struct fore200e* fore200e)
2675} 2675}
2676 2676
2677 2677
2678static int __init 2678static int __devinit
2679fore200e_init(struct fore200e* fore200e) 2679fore200e_init(struct fore200e* fore200e)
2680{ 2680{
2681 if (fore200e_register(fore200e) < 0) 2681 if (fore200e_register(fore200e) < 0)
@@ -2721,7 +2721,7 @@ fore200e_init(struct fore200e* fore200e)
2721 return -EBUSY; 2721 return -EBUSY;
2722 2722
2723 fore200e_supply(fore200e); 2723 fore200e_supply(fore200e);
2724 2724
2725 /* all done, board initialization is now complete */ 2725 /* all done, board initialization is now complete */
2726 fore200e->state = FORE200E_STATE_COMPLETE; 2726 fore200e->state = FORE200E_STATE_COMPLETE;
2727 return 0; 2727 return 0;
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 6ede1f352c29..37b8cda3e8bc 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -41,6 +41,7 @@
41#include <linux/timer.h> 41#include <linux/timer.h>
42#include <linux/pci.h> 42#include <linux/pci.h>
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/random.h>
44#include <asm/io.h> 45#include <asm/io.h>
45#include <asm/uaccess.h> 46#include <asm/uaccess.h>
46#include "DAC960.h" 47#include "DAC960.h"
@@ -3463,7 +3464,7 @@ static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
3463 Command->SegmentCount, Command->DmaDirection); 3464 Command->SegmentCount, Command->DmaDirection);
3464 3465
3465 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) { 3466 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) {
3466 3467 add_disk_randomness(Request->rq_disk);
3467 end_that_request_last(Request, UpToDate); 3468 end_that_request_last(Request, UpToDate);
3468 3469
3469 if (Command->Completion) { 3470 if (Command->Completion) {
diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c
index b3bc2e37e616..29dc87e59020 100644
--- a/drivers/char/hw_random.c
+++ b/drivers/char/hw_random.c
@@ -131,7 +131,9 @@ enum {
131 rng_hw_none, 131 rng_hw_none,
132 rng_hw_intel, 132 rng_hw_intel,
133 rng_hw_amd, 133 rng_hw_amd,
134#ifdef __i386__
134 rng_hw_via, 135 rng_hw_via,
136#endif
135 rng_hw_geode, 137 rng_hw_geode,
136}; 138};
137 139
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index c92378121b4c..1b05fa688996 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -675,7 +675,7 @@ static int __init mmtimer_init(void)
675 cnodeid_t node, maxn = -1; 675 cnodeid_t node, maxn = -1;
676 676
677 if (!ia64_platform_is("sn2")) 677 if (!ia64_platform_is("sn2"))
678 return -1; 678 return 0;
679 679
680 /* 680 /*
681 * Sanity check the cycles/sec variable 681 * Sanity check the cycles/sec variable
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 649677b5dc36..5fdf18515433 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -13,11 +13,12 @@
13 * 13 *
14 * (C) 2000,2001,2002,2003,2004 Omnikey AG 14 * (C) 2000,2001,2002,2003,2004 Omnikey AG
15 * 15 *
16 * (C) 2005 Harald Welte <laforge@gnumonks.org> 16 * (C) 2005-2006 Harald Welte <laforge@gnumonks.org>
17 * - Adhere to Kernel CodingStyle 17 * - Adhere to Kernel CodingStyle
18 * - Port to 2.6.13 "new" style PCMCIA 18 * - Port to 2.6.13 "new" style PCMCIA
19 * - Check for copy_{from,to}_user return values 19 * - Check for copy_{from,to}_user return values
20 * - Use nonseekable_open() 20 * - Use nonseekable_open()
21 * - add class interface for udev device creation
21 * 22 *
22 * All rights reserved. Licensed under dual BSD/GPL license. 23 * All rights reserved. Licensed under dual BSD/GPL license.
23 */ 24 */
@@ -56,7 +57,7 @@ module_param(pc_debug, int, 0600);
56#else 57#else
57#define DEBUGP(n, rdr, x, args...) 58#define DEBUGP(n, rdr, x, args...)
58#endif 59#endif
59static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte"; 60static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte";
60 61
61#define T_1SEC (HZ) 62#define T_1SEC (HZ)
62#define T_10MSEC msecs_to_jiffies(10) 63#define T_10MSEC msecs_to_jiffies(10)
@@ -156,6 +157,7 @@ struct cm4000_dev {
156 /*queue*/ 4*sizeof(wait_queue_head_t)) 157 /*queue*/ 4*sizeof(wait_queue_head_t))
157 158
158static dev_link_t *dev_table[CM4000_MAX_DEV]; 159static dev_link_t *dev_table[CM4000_MAX_DEV];
160static struct class *cmm_class;
159 161
160/* This table doesn't use spaces after the comma between fields and thus 162/* This table doesn't use spaces after the comma between fields and thus
161 * violates CodingStyle. However, I don't really think wrapping it around will 163 * violates CodingStyle. However, I don't really think wrapping it around will
@@ -1937,6 +1939,9 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1937 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1939 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1938 cm4000_config(link, i); 1940 cm4000_config(link, i);
1939 1941
1942 class_device_create(cmm_class, NULL, MKDEV(major, i), NULL,
1943 "cmm%d", i);
1944
1940 return 0; 1945 return 0;
1941} 1946}
1942 1947
@@ -1962,6 +1967,8 @@ static void cm4000_detach(struct pcmcia_device *p_dev)
1962 dev_table[devno] = NULL; 1967 dev_table[devno] = NULL;
1963 kfree(dev); 1968 kfree(dev);
1964 1969
1970 class_device_destroy(cmm_class, MKDEV(major, devno));
1971
1965 return; 1972 return;
1966} 1973}
1967 1974
@@ -1995,8 +2002,18 @@ static struct pcmcia_driver cm4000_driver = {
1995 2002
1996static int __init cmm_init(void) 2003static int __init cmm_init(void)
1997{ 2004{
2005 int rc;
2006
1998 printk(KERN_INFO "%s\n", version); 2007 printk(KERN_INFO "%s\n", version);
1999 pcmcia_register_driver(&cm4000_driver); 2008
2009 cmm_class = class_create(THIS_MODULE, "cardman_4000");
2010 if (!cmm_class)
2011 return -1;
2012
2013 rc = pcmcia_register_driver(&cm4000_driver);
2014 if (rc < 0)
2015 return rc;
2016
2000 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops); 2017 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
2001 if (major < 0) { 2018 if (major < 0) {
2002 printk(KERN_WARNING MODULE_NAME 2019 printk(KERN_WARNING MODULE_NAME
@@ -2012,6 +2029,7 @@ static void __exit cmm_exit(void)
2012 printk(KERN_INFO MODULE_NAME ": unloading\n"); 2029 printk(KERN_INFO MODULE_NAME ": unloading\n");
2013 pcmcia_unregister_driver(&cm4000_driver); 2030 pcmcia_unregister_driver(&cm4000_driver);
2014 unregister_chrdev(major, DEVICE_NAME); 2031 unregister_chrdev(major, DEVICE_NAME);
2032 class_destroy(cmm_class);
2015}; 2033};
2016 2034
2017module_init(cmm_init); 2035module_init(cmm_init);
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 46eb371bf17e..466e33bab029 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -3,12 +3,13 @@
3 * 3 *
4 * (c) 2000-2004 Omnikey AG (http://www.omnikey.com/) 4 * (c) 2000-2004 Omnikey AG (http://www.omnikey.com/)
5 * 5 *
6 * (C) 2005 Harald Welte <laforge@gnumonks.org> 6 * (C) 2005-2006 Harald Welte <laforge@gnumonks.org>
7 * - add support for poll() 7 * - add support for poll()
8 * - driver cleanup 8 * - driver cleanup
9 * - add waitqueues 9 * - add waitqueues
10 * - adhere to linux kernel coding style and policies 10 * - adhere to linux kernel coding style and policies
11 * - support 2.6.13 "new style" pcmcia interface 11 * - support 2.6.13 "new style" pcmcia interface
12 * - add class interface for udev device creation
12 * 13 *
13 * The device basically is a USB CCID compliant device that has been 14 * The device basically is a USB CCID compliant device that has been
14 * attached to an I/O-Mapped FIFO. 15 * attached to an I/O-Mapped FIFO.
@@ -53,7 +54,7 @@ module_param(pc_debug, int, 0600);
53#endif 54#endif
54 55
55static char *version = 56static char *version =
56"OMNIKEY CardMan 4040 v1.1.0gm4 - All bugs added by Harald Welte"; 57"OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte";
57 58
58#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) 59#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ)
59#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) 60#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ)
@@ -67,6 +68,7 @@ static char *version =
67static void reader_release(dev_link_t *link); 68static void reader_release(dev_link_t *link);
68 69
69static int major; 70static int major;
71static struct class *cmx_class;
70 72
71#define BS_READABLE 0x01 73#define BS_READABLE 0x01
72#define BS_WRITABLE 0x02 74#define BS_WRITABLE 0x02
@@ -696,6 +698,9 @@ static int reader_attach(struct pcmcia_device *p_dev)
696 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 698 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
697 reader_config(link, i); 699 reader_config(link, i);
698 700
701 class_device_create(cmx_class, NULL, MKDEV(major, i), NULL,
702 "cmx%d", i);
703
699 return 0; 704 return 0;
700} 705}
701 706
@@ -721,6 +726,8 @@ static void reader_detach(struct pcmcia_device *p_dev)
721 dev_table[devno] = NULL; 726 dev_table[devno] = NULL;
722 kfree(dev); 727 kfree(dev);
723 728
729 class_device_destroy(cmx_class, MKDEV(major, devno));
730
724 return; 731 return;
725} 732}
726 733
@@ -755,8 +762,17 @@ static struct pcmcia_driver reader_driver = {
755 762
756static int __init cm4040_init(void) 763static int __init cm4040_init(void)
757{ 764{
765 int rc;
766
758 printk(KERN_INFO "%s\n", version); 767 printk(KERN_INFO "%s\n", version);
759 pcmcia_register_driver(&reader_driver); 768 cmx_class = class_create(THIS_MODULE, "cardman_4040");
769 if (!cmx_class)
770 return -1;
771
772 rc = pcmcia_register_driver(&reader_driver);
773 if (rc < 0)
774 return rc;
775
760 major = register_chrdev(0, DEVICE_NAME, &reader_fops); 776 major = register_chrdev(0, DEVICE_NAME, &reader_fops);
761 if (major < 0) { 777 if (major < 0) {
762 printk(KERN_WARNING MODULE_NAME 778 printk(KERN_WARNING MODULE_NAME
@@ -771,6 +787,7 @@ static void __exit cm4040_exit(void)
771 printk(KERN_INFO MODULE_NAME ": unloading\n"); 787 printk(KERN_INFO MODULE_NAME ": unloading\n");
772 pcmcia_unregister_driver(&reader_driver); 788 pcmcia_unregister_driver(&reader_driver);
773 unregister_chrdev(major, DEVICE_NAME); 789 unregister_chrdev(major, DEVICE_NAME);
790 class_destroy(cmx_class);
774} 791}
775 792
776module_init(cm4040_init); 793module_init(cm4040_init);
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 18a455651121..52f3eb45d2b9 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -6,17 +6,29 @@
6# $Id: Kconfig,v 1.4.2.7 2005/07/08 22:05:38 dsp_llnl Exp $ 6# $Id: Kconfig,v 1.4.2.7 2005/07/08 22:05:38 dsp_llnl Exp $
7# 7#
8 8
9menu 'EDAC - error detection and reporting (RAS)' 9menu 'EDAC - error detection and reporting (RAS) (EXPERIMENTAL)'
10 10
11config EDAC 11config EDAC
12 tristate "EDAC core system error reporting" 12 tristate "EDAC core system error reporting (EXPERIMENTAL)"
13 depends on X86 13 depends on X86 && EXPERIMENTAL
14 help 14 help
15 EDAC is designed to report errors in the core system. 15 EDAC is designed to report errors in the core system.
16 These are low-level errors that are reported in the CPU or 16 These are low-level errors that are reported in the CPU or
17 supporting chipset: memory errors, cache errors, PCI errors, 17 supporting chipset: memory errors, cache errors, PCI errors,
18 thermal throttling, etc.. If unsure, select 'Y'. 18 thermal throttling, etc.. If unsure, select 'Y'.
19 19
20 If this code is reporting problems on your system, please
21 see the EDAC project web pages for more information at:
22
23 <http://bluesmoke.sourceforge.net/>
24
25 and:
26
27 <http://buttersideup.com/edacwiki>
28
29 There is also a mailing list for the EDAC project, which can
30 be found via the sourceforge page.
31
20 32
21comment "Reporting subsystems" 33comment "Reporting subsystems"
22 depends on EDAC 34 depends on EDAC
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index b10ee4698b1d..262e44544dc8 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -132,11 +132,13 @@ static struct kobject edac_pci_kobj;
132 * /sys/devices/system/edac/mc; 132 * /sys/devices/system/edac/mc;
133 * data structures and methods 133 * data structures and methods
134 */ 134 */
135#if 0
135static ssize_t memctrl_string_show(void *ptr, char *buffer) 136static ssize_t memctrl_string_show(void *ptr, char *buffer)
136{ 137{
137 char *value = (char*) ptr; 138 char *value = (char*) ptr;
138 return sprintf(buffer, "%s\n", value); 139 return sprintf(buffer, "%s\n", value);
139} 140}
141#endif
140 142
141static ssize_t memctrl_int_show(void *ptr, char *buffer) 143static ssize_t memctrl_int_show(void *ptr, char *buffer)
142{ 144{
@@ -207,7 +209,9 @@ struct memctrl_dev_attribute attr_##_name = { \
207}; 209};
208 210
209/* cwrow<id> attribute f*/ 211/* cwrow<id> attribute f*/
212#if 0
210MEMCTRL_STRING_ATTR(mc_version,EDAC_MC_VERSION,S_IRUGO,memctrl_string_show,NULL); 213MEMCTRL_STRING_ATTR(mc_version,EDAC_MC_VERSION,S_IRUGO,memctrl_string_show,NULL);
214#endif
211 215
212/* csrow<id> control files */ 216/* csrow<id> control files */
213MEMCTRL_ATTR(panic_on_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store); 217MEMCTRL_ATTR(panic_on_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
@@ -222,7 +226,6 @@ static struct memctrl_dev_attribute *memctrl_attr[] = {
222 &attr_log_ue, 226 &attr_log_ue,
223 &attr_log_ce, 227 &attr_log_ce,
224 &attr_poll_msec, 228 &attr_poll_msec,
225 &attr_mc_version,
226 NULL, 229 NULL,
227}; 230};
228 231
@@ -309,6 +312,8 @@ struct list_control {
309 int *count; 312 int *count;
310}; 313};
311 314
315
316#if 0
312/* Output the list as: vendor_id:device:id<,vendor_id:device_id> */ 317/* Output the list as: vendor_id:device:id<,vendor_id:device_id> */
313static ssize_t edac_pci_list_string_show(void *ptr, char *buffer) 318static ssize_t edac_pci_list_string_show(void *ptr, char *buffer)
314{ 319{
@@ -430,6 +435,7 @@ static ssize_t edac_pci_list_string_store(void *ptr, const char *buffer,
430 return count; 435 return count;
431} 436}
432 437
438#endif
433static ssize_t edac_pci_int_show(void *ptr, char *buffer) 439static ssize_t edac_pci_int_show(void *ptr, char *buffer)
434{ 440{
435 int *value = ptr; 441 int *value = ptr;
@@ -498,6 +504,7 @@ struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
498 .store = _store, \ 504 .store = _store, \
499}; 505};
500 506
507#if 0
501static struct list_control pci_whitelist_control = { 508static struct list_control pci_whitelist_control = {
502 .list = pci_whitelist, 509 .list = pci_whitelist,
503 .count = &pci_whitelist_count 510 .count = &pci_whitelist_count
@@ -520,6 +527,7 @@ EDAC_PCI_STRING_ATTR(pci_parity_blacklist,
520 S_IRUGO|S_IWUSR, 527 S_IRUGO|S_IWUSR,
521 edac_pci_list_string_show, 528 edac_pci_list_string_show,
522 edac_pci_list_string_store); 529 edac_pci_list_string_store);
530#endif
523 531
524/* PCI Parity control files */ 532/* PCI Parity control files */
525EDAC_PCI_ATTR(check_pci_parity,S_IRUGO|S_IWUSR,edac_pci_int_show,edac_pci_int_store); 533EDAC_PCI_ATTR(check_pci_parity,S_IRUGO|S_IWUSR,edac_pci_int_show,edac_pci_int_store);
@@ -531,8 +539,6 @@ static struct edac_pci_dev_attribute *edac_pci_attr[] = {
531 &edac_pci_attr_check_pci_parity, 539 &edac_pci_attr_check_pci_parity,
532 &edac_pci_attr_panic_on_pci_parity, 540 &edac_pci_attr_panic_on_pci_parity,
533 &edac_pci_attr_pci_parity_count, 541 &edac_pci_attr_pci_parity_count,
534 &edac_pci_attr_pci_parity_whitelist,
535 &edac_pci_attr_pci_parity_blacklist,
536 NULL, 542 NULL,
537}; 543};
538 544
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 8ed6ddbb9c5d..4652512f7d1a 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -39,7 +39,7 @@
39#include "dcdbas.h" 39#include "dcdbas.h"
40 40
41#define DRIVER_NAME "dcdbas" 41#define DRIVER_NAME "dcdbas"
42#define DRIVER_VERSION "5.6.0-1" 42#define DRIVER_VERSION "5.6.0-2"
43#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver" 43#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver"
44 44
45static struct platform_device *dcdbas_pdev; 45static struct platform_device *dcdbas_pdev;
@@ -581,9 +581,13 @@ static int __init dcdbas_init(void)
581 */ 581 */
582static void __exit dcdbas_exit(void) 582static void __exit dcdbas_exit(void)
583{ 583{
584 platform_device_unregister(dcdbas_pdev); 584 /*
585 * make sure functions that use dcdbas_pdev are called
586 * before platform_device_unregister
587 */
585 unregister_reboot_notifier(&dcdbas_reboot_nb); 588 unregister_reboot_notifier(&dcdbas_reboot_nb);
586 smi_data_buf_free(); 589 smi_data_buf_free();
590 platform_device_unregister(dcdbas_pdev);
587} 591}
588 592
589module_init(dcdbas_init); 593module_init(dcdbas_init);
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 4c2af9020905..6213bd3caee5 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -445,6 +445,7 @@ static struct pcmcia_device_id ide_ids[] = {
445 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "PnPIDE", 0x281f1c5d, 0x0c694728), 445 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "PnPIDE", 0x281f1c5d, 0x0c694728),
446 PCMCIA_DEVICE_PROD_ID12("SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", 0x4a3f0ba0, 0x322560e1), 446 PCMCIA_DEVICE_PROD_ID12("SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", 0x4a3f0ba0, 0x322560e1),
447 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 447 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
448 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
448 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 449 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
449 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 450 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
450 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), 451 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e),
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 2d2d4ac3525a..960dae5c87d1 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1155,6 +1155,12 @@ static int srp_send_tsk_mgmt(struct scsi_cmnd *scmnd, u8 func)
1155 1155
1156 spin_lock_irq(target->scsi_host->host_lock); 1156 spin_lock_irq(target->scsi_host->host_lock);
1157 1157
1158 if (target->state == SRP_TARGET_DEAD ||
1159 target->state == SRP_TARGET_REMOVED) {
1160 scmnd->result = DID_BAD_TARGET << 16;
1161 goto out;
1162 }
1163
1158 if (scmnd->host_scribble == (void *) -1L) 1164 if (scmnd->host_scribble == (void *) -1L)
1159 goto out; 1165 goto out;
1160 1166
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 19b1b0121726..ad6217467676 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -58,7 +58,7 @@ static unsigned int psmouse_resetafter = 5;
58module_param_named(resetafter, psmouse_resetafter, uint, 0644); 58module_param_named(resetafter, psmouse_resetafter, uint, 0644);
59MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); 59MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never).");
60 60
61static unsigned int psmouse_resync_time = 5; 61static unsigned int psmouse_resync_time;
62module_param_named(resync_time, psmouse_resync_time, uint, 0644); 62module_param_named(resync_time, psmouse_resync_time, uint, 0644);
63MODULE_PARM_DESC(resync_time, "How long can mouse stay idle before forcing resync (in seconds, 0 = never)."); 63MODULE_PARM_DESC(resync_time, "How long can mouse stay idle before forcing resync (in seconds, 0 = never).");
64 64
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 8159bcecd0c2..df9d65201819 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1929,6 +1929,8 @@ static struct pci_device_id hisax_pci_tbl[] __initdata = {
1929 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, PCI_ANY_ID, PCI_ANY_ID}, 1929 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, PCI_ANY_ID, PCI_ANY_ID},
1930 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, PCI_ANY_ID, PCI_ANY_ID}, 1930 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, PCI_ANY_ID, PCI_ANY_ID},
1931 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, PCI_ANY_ID, PCI_ANY_ID}, 1931 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, PCI_ANY_ID, PCI_ANY_ID},
1932 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B700, PCI_ANY_ID, PCI_ANY_ID},
1933 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B701, PCI_ANY_ID, PCI_ANY_ID},
1932 {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, PCI_ANY_ID, PCI_ANY_ID}, 1934 {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, PCI_ANY_ID, PCI_ANY_ID},
1933 {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, PCI_ANY_ID, PCI_ANY_ID}, 1935 {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, PCI_ANY_ID, PCI_ANY_ID},
1934 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID}, 1936 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID},
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 4866fc32d8d9..91d25acb5ede 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -51,6 +51,8 @@ static const PCI_ENTRY id_list[] =
51 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, "Billion", "B00B"}, 51 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, "Billion", "B00B"},
52 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, "Billion", "B00C"}, 52 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, "Billion", "B00C"},
53 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, "Seyeon", "B100"}, 53 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, "Seyeon", "B100"},
54 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B700, "Primux II S0", "B700"},
55 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B701, "Primux II S0 NT", "B701"},
54 {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, "Abocom/Magitek", "2BD1"}, 56 {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, "Abocom/Magitek", "2BD1"},
55 {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, "Asuscom/Askey", "675"}, 57 {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, "Asuscom/Askey", "675"},
56 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, "German telekom", "T-Concept"}, 58 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, "German telekom", "T-Concept"},
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index ca5b4a3b683e..262c44127419 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * hfc_usb.c 2 * hfc_usb.c
3 * 3 *
4 * $Id: hfc_usb.c,v 4.36 2005/04/08 09:55:13 martinb1 Exp $ 4 * $Id: hfc_usb.c,v 2.3.2.13 2006/02/17 17:17:22 mbachem Exp $
5 * 5 *
6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip 6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip
7 * 7 *
@@ -45,7 +45,7 @@
45#include "hfc_usb.h" 45#include "hfc_usb.h"
46 46
47static const char *hfcusb_revision = 47static const char *hfcusb_revision =
48 "$Revision: 4.36 $ $Date: 2005/04/08 09:55:13 $ "; 48 "$Revision: 2.3.2.13 $ $Date: 2006/02/17 17:17:22 $ ";
49 49
50/* Hisax debug support 50/* Hisax debug support
51* use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG 51* use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG
@@ -219,7 +219,7 @@ symbolic(struct hfcusb_symbolic_list list[], const int num)
219 for (i = 0; list[i].name != NULL; i++) 219 for (i = 0; list[i].name != NULL; i++)
220 if (list[i].num == num) 220 if (list[i].num == num)
221 return (list[i].name); 221 return (list[i].name);
222 return "<unkown ERROR>"; 222 return "<unknown ERROR>";
223} 223}
224 224
225 225
@@ -235,9 +235,9 @@ ctrl_start_transfer(hfcusb_data * hfc)
235 hfc->ctrl_urb->transfer_buffer = NULL; 235 hfc->ctrl_urb->transfer_buffer = NULL;
236 hfc->ctrl_urb->transfer_buffer_length = 0; 236 hfc->ctrl_urb->transfer_buffer_length = 0;
237 hfc->ctrl_write.wIndex = 237 hfc->ctrl_write.wIndex =
238 hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg; 238 cpu_to_le16(hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg);
239 hfc->ctrl_write.wValue = 239 hfc->ctrl_write.wValue =
240 hfc->ctrl_buff[hfc->ctrl_out_idx].reg_val; 240 cpu_to_le16(hfc->ctrl_buff[hfc->ctrl_out_idx].reg_val);
241 241
242 usb_submit_urb(hfc->ctrl_urb, GFP_ATOMIC); /* start transfer */ 242 usb_submit_urb(hfc->ctrl_urb, GFP_ATOMIC); /* start transfer */
243 } 243 }
@@ -1282,7 +1282,7 @@ usb_init(hfcusb_data * hfc)
1282 /* init the background machinery for control requests */ 1282 /* init the background machinery for control requests */
1283 hfc->ctrl_read.bRequestType = 0xc0; 1283 hfc->ctrl_read.bRequestType = 0xc0;
1284 hfc->ctrl_read.bRequest = 1; 1284 hfc->ctrl_read.bRequest = 1;
1285 hfc->ctrl_read.wLength = 1; 1285 hfc->ctrl_read.wLength = cpu_to_le16(1);
1286 hfc->ctrl_write.bRequestType = 0x40; 1286 hfc->ctrl_write.bRequestType = 0x40;
1287 hfc->ctrl_write.bRequest = 0; 1287 hfc->ctrl_write.bRequest = 0;
1288 hfc->ctrl_write.wLength = 0; 1288 hfc->ctrl_write.wLength = 0;
@@ -1373,9 +1373,8 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1373 1373
1374 vend_idx = 0xffff; 1374 vend_idx = 0xffff;
1375 for (i = 0; hfcusb_idtab[i].idVendor; i++) { 1375 for (i = 0; hfcusb_idtab[i].idVendor; i++) {
1376 if (dev->descriptor.idVendor == hfcusb_idtab[i].idVendor 1376 if ((le16_to_cpu(dev->descriptor.idVendor) == hfcusb_idtab[i].idVendor)
1377 && dev->descriptor.idProduct == 1377 && (le16_to_cpu(dev->descriptor.idProduct) == hfcusb_idtab[i].idProduct)) {
1378 hfcusb_idtab[i].idProduct) {
1379 vend_idx = i; 1378 vend_idx = i;
1380 continue; 1379 continue;
1381 } 1380 }
@@ -1516,8 +1515,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1516 usb_transfer_mode 1515 usb_transfer_mode
1517 = USB_INT; 1516 = USB_INT;
1518 packet_size = 1517 packet_size =
1519 ep->desc. 1518 le16_to_cpu(ep->desc.wMaxPacketSize);
1520 wMaxPacketSize;
1521 break; 1519 break;
1522 case USB_ENDPOINT_XFER_BULK: 1520 case USB_ENDPOINT_XFER_BULK:
1523 if (ep_addr & 0x80) 1521 if (ep_addr & 0x80)
@@ -1545,8 +1543,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1545 usb_transfer_mode 1543 usb_transfer_mode
1546 = USB_BULK; 1544 = USB_BULK;
1547 packet_size = 1545 packet_size =
1548 ep->desc. 1546 le16_to_cpu(ep->desc.wMaxPacketSize);
1549 wMaxPacketSize;
1550 break; 1547 break;
1551 case USB_ENDPOINT_XFER_ISOC: 1548 case USB_ENDPOINT_XFER_ISOC:
1552 if (ep_addr & 0x80) 1549 if (ep_addr & 0x80)
@@ -1574,8 +1571,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1574 usb_transfer_mode 1571 usb_transfer_mode
1575 = USB_ISOC; 1572 = USB_ISOC;
1576 iso_packet_size = 1573 iso_packet_size =
1577 ep->desc. 1574 le16_to_cpu(ep->desc.wMaxPacketSize);
1578 wMaxPacketSize;
1579 break; 1575 break;
1580 default: 1576 default:
1581 context-> 1577 context->
@@ -1588,10 +1584,8 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1588 fifonum = cidx; 1584 fifonum = cidx;
1589 context->fifos[cidx].hfc = 1585 context->fifos[cidx].hfc =
1590 context; 1586 context;
1591 context->fifos[cidx]. 1587 context->fifos[cidx].usb_packet_maxlen =
1592 usb_packet_maxlen = 1588 le16_to_cpu(ep->desc.wMaxPacketSize);
1593 ep->desc.
1594 wMaxPacketSize;
1595 context->fifos[cidx]. 1589 context->fifos[cidx].
1596 intervall = 1590 intervall =
1597 ep->desc.bInterval; 1591 ep->desc.bInterval;
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 393633681f49..aeaa1db74bd8 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1682,6 +1682,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1682#ifdef ISDN_DEBUG_MODEM_OPEN 1682#ifdef ISDN_DEBUG_MODEM_OPEN
1683 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n"); 1683 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
1684#endif 1684#endif
1685 module_put(info->owner);
1685 return; 1686 return;
1686 } 1687 }
1687 info->flags |= ISDN_ASYNC_CLOSING; 1688 info->flags |= ISDN_ASYNC_CLOSING;
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index bb8d5efe19bf..6c0ba04bc57a 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -35,6 +35,8 @@
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37 37
38#include <asm/prom.h>
39
38#include "windfarm.h" 40#include "windfarm.h"
39 41
40#define VERSION "0.2" 42#define VERSION "0.2"
@@ -465,6 +467,11 @@ static int __init windfarm_core_init(void)
465{ 467{
466 DBG("wf: core loaded\n"); 468 DBG("wf: core loaded\n");
467 469
470 /* Don't register on old machines that use therm_pm72 for now */
471 if (machine_is_compatible("PowerMac7,2") ||
472 machine_is_compatible("PowerMac7,3") ||
473 machine_is_compatible("RackMac3,1"))
474 return -ENODEV;
468 platform_device_register(&wf_platform_device); 475 platform_device_register(&wf_platform_device);
469 return 0; 476 return 0;
470} 477}
diff --git a/drivers/macintosh/windfarm_cpufreq_clamp.c b/drivers/macintosh/windfarm_cpufreq_clamp.c
index 607dbaca69c9..81337cd16e80 100644
--- a/drivers/macintosh/windfarm_cpufreq_clamp.c
+++ b/drivers/macintosh/windfarm_cpufreq_clamp.c
@@ -8,6 +8,8 @@
8#include <linux/wait.h> 8#include <linux/wait.h>
9#include <linux/cpufreq.h> 9#include <linux/cpufreq.h>
10 10
11#include <asm/prom.h>
12
11#include "windfarm.h" 13#include "windfarm.h"
12 14
13#define VERSION "0.3" 15#define VERSION "0.3"
@@ -74,6 +76,12 @@ static int __init wf_cpufreq_clamp_init(void)
74{ 76{
75 struct wf_control *clamp; 77 struct wf_control *clamp;
76 78
79 /* Don't register on old machines that use therm_pm72 for now */
80 if (machine_is_compatible("PowerMac7,2") ||
81 machine_is_compatible("PowerMac7,3") ||
82 machine_is_compatible("RackMac3,1"))
83 return -ENODEV;
84
77 clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL); 85 clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL);
78 if (clamp == NULL) 86 if (clamp == NULL)
79 return -ENOMEM; 87 return -ENOMEM;
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index 906d3ecae6e6..423bfa2432c0 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -25,7 +25,7 @@
25 25
26#include "windfarm.h" 26#include "windfarm.h"
27 27
28#define VERSION "0.1" 28#define VERSION "0.2"
29 29
30#undef DEBUG 30#undef DEBUG
31 31
@@ -113,6 +113,7 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
113 const char *loc) 113 const char *loc)
114{ 114{
115 struct wf_lm75_sensor *lm; 115 struct wf_lm75_sensor *lm;
116 int rc;
116 117
117 DBG("wf_lm75: creating %s device at address 0x%02x\n", 118 DBG("wf_lm75: creating %s device at address 0x%02x\n",
118 ds1775 ? "ds1775" : "lm75", addr); 119 ds1775 ? "ds1775" : "lm75", addr);
@@ -139,9 +140,11 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
139 lm->i2c.driver = &wf_lm75_driver; 140 lm->i2c.driver = &wf_lm75_driver;
140 strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1); 141 strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1);
141 142
142 if (i2c_attach_client(&lm->i2c)) { 143 rc = i2c_attach_client(&lm->i2c);
143 printk(KERN_ERR "windfarm: failed to attach %s %s to i2c\n", 144 if (rc) {
144 ds1775 ? "ds1775" : "lm75", lm->i2c.name); 145 printk(KERN_ERR "windfarm: failed to attach %s %s to i2c,"
146 " err %d\n", ds1775 ? "ds1775" : "lm75",
147 lm->i2c.name, rc);
145 goto fail; 148 goto fail;
146 } 149 }
147 150
@@ -175,16 +178,22 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
175 (dev = of_get_next_child(busnode, dev)) != NULL;) { 178 (dev = of_get_next_child(busnode, dev)) != NULL;) {
176 const char *loc = 179 const char *loc =
177 get_property(dev, "hwsensor-location", NULL); 180 get_property(dev, "hwsensor-location", NULL);
178 u32 *reg = (u32 *)get_property(dev, "reg", NULL); 181 u8 addr;
179 DBG(" dev: %s... (loc: %p, reg: %p)\n", dev->name, loc, reg); 182
180 if (loc == NULL || reg == NULL) 183 /* We must re-match the adapter in order to properly check
184 * the channel on multibus setups
185 */
186 if (!pmac_i2c_match_adapter(dev, adapter))
187 continue;
188 addr = pmac_i2c_get_dev_addr(dev);
189 if (loc == NULL || addr == 0)
181 continue; 190 continue;
182 /* real lm75 */ 191 /* real lm75 */
183 if (device_is_compatible(dev, "lm75")) 192 if (device_is_compatible(dev, "lm75"))
184 wf_lm75_create(adapter, *reg, 0, loc); 193 wf_lm75_create(adapter, addr, 0, loc);
185 /* ds1775 (compatible, better resolution */ 194 /* ds1775 (compatible, better resolution */
186 else if (device_is_compatible(dev, "ds1775")) 195 else if (device_is_compatible(dev, "ds1775"))
187 wf_lm75_create(adapter, *reg, 1, loc); 196 wf_lm75_create(adapter, addr, 1, loc);
188 } 197 }
189 return 0; 198 return 0;
190} 199}
@@ -206,6 +215,11 @@ static int wf_lm75_detach(struct i2c_client *client)
206 215
207static int __init wf_lm75_sensor_init(void) 216static int __init wf_lm75_sensor_init(void)
208{ 217{
218 /* Don't register on old machines that use therm_pm72 for now */
219 if (machine_is_compatible("PowerMac7,2") ||
220 machine_is_compatible("PowerMac7,3") ||
221 machine_is_compatible("RackMac3,1"))
222 return -ENODEV;
209 return i2c_add_driver(&wf_lm75_driver); 223 return i2c_add_driver(&wf_lm75_driver);
210} 224}
211 225
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index 5b9ad6ca7cba..8e99d408fddd 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -17,7 +17,7 @@
17 17
18#include "windfarm.h" 18#include "windfarm.h"
19 19
20#define VERSION "0.1" 20#define VERSION "0.2"
21 21
22/* This currently only exports the external temperature sensor, 22/* This currently only exports the external temperature sensor,
23 since that's all the control loops need. */ 23 since that's all the control loops need. */
@@ -81,7 +81,7 @@ static struct wf_sensor_ops wf_max6690_ops = {
81static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr) 81static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
82{ 82{
83 struct wf_6690_sensor *max; 83 struct wf_6690_sensor *max;
84 char *name = "u4-temp"; 84 char *name = "backside-temp";
85 85
86 max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL); 86 max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
87 if (max == NULL) { 87 if (max == NULL) {
@@ -118,7 +118,6 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
118 struct device_node *busnode, *dev = NULL; 118 struct device_node *busnode, *dev = NULL;
119 struct pmac_i2c_bus *bus; 119 struct pmac_i2c_bus *bus;
120 const char *loc; 120 const char *loc;
121 u32 *reg;
122 121
123 bus = pmac_i2c_adapter_to_bus(adapter); 122 bus = pmac_i2c_adapter_to_bus(adapter);
124 if (bus == NULL) 123 if (bus == NULL)
@@ -126,16 +125,23 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
126 busnode = pmac_i2c_get_bus_node(bus); 125 busnode = pmac_i2c_get_bus_node(bus);
127 126
128 while ((dev = of_get_next_child(busnode, dev)) != NULL) { 127 while ((dev = of_get_next_child(busnode, dev)) != NULL) {
128 u8 addr;
129
130 /* We must re-match the adapter in order to properly check
131 * the channel on multibus setups
132 */
133 if (!pmac_i2c_match_adapter(dev, adapter))
134 continue;
129 if (!device_is_compatible(dev, "max6690")) 135 if (!device_is_compatible(dev, "max6690"))
130 continue; 136 continue;
137 addr = pmac_i2c_get_dev_addr(dev);
131 loc = get_property(dev, "hwsensor-location", NULL); 138 loc = get_property(dev, "hwsensor-location", NULL);
132 reg = (u32 *) get_property(dev, "reg", NULL); 139 if (loc == NULL || addr == 0)
133 if (!loc || !reg)
134 continue; 140 continue;
135 printk("found max6690, loc=%s reg=%x\n", loc, *reg); 141 printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
136 if (strcmp(loc, "BACKSIDE")) 142 if (strcmp(loc, "BACKSIDE"))
137 continue; 143 continue;
138 wf_max6690_create(adapter, *reg); 144 wf_max6690_create(adapter, addr);
139 } 145 }
140 146
141 return 0; 147 return 0;
@@ -153,6 +159,11 @@ static int wf_max6690_detach(struct i2c_client *client)
153 159
154static int __init wf_max6690_sensor_init(void) 160static int __init wf_max6690_sensor_init(void)
155{ 161{
162 /* Don't register on old machines that use therm_pm72 for now */
163 if (machine_is_compatible("PowerMac7,2") ||
164 machine_is_compatible("PowerMac7,3") ||
165 machine_is_compatible("RackMac3,1"))
166 return -ENODEV;
156 return i2c_add_driver(&wf_max6690_driver); 167 return i2c_add_driver(&wf_max6690_driver);
157} 168}
158 169
diff --git a/drivers/macintosh/windfarm_pid.c b/drivers/macintosh/windfarm_pid.c
index 0842432e27ad..f10efb28cae4 100644
--- a/drivers/macintosh/windfarm_pid.c
+++ b/drivers/macintosh/windfarm_pid.c
@@ -143,3 +143,7 @@ s32 wf_cpu_pid_run(struct wf_cpu_pid_state *st, s32 new_power, s32 new_temp)
143 return st->target; 143 return st->target;
144} 144}
145EXPORT_SYMBOL_GPL(wf_cpu_pid_run); 145EXPORT_SYMBOL_GPL(wf_cpu_pid_run);
146
147MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
148MODULE_DESCRIPTION("PID algorithm for PowerMacs thermal control");
149MODULE_LICENSE("GPL");
diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c
index c2a4e689c784..ef66bf2778ec 100644
--- a/drivers/macintosh/windfarm_pm112.c
+++ b/drivers/macintosh/windfarm_pm112.c
@@ -358,6 +358,7 @@ static void backside_fan_tick(void)
358 return; 358 return;
359 if (!backside_tick) { 359 if (!backside_tick) {
360 /* first time; initialize things */ 360 /* first time; initialize things */
361 printk(KERN_INFO "windfarm: Backside control loop started.\n");
361 backside_param.min = backside_fan->ops->get_min(backside_fan); 362 backside_param.min = backside_fan->ops->get_min(backside_fan);
362 backside_param.max = backside_fan->ops->get_max(backside_fan); 363 backside_param.max = backside_fan->ops->get_max(backside_fan);
363 wf_pid_init(&backside_pid, &backside_param); 364 wf_pid_init(&backside_pid, &backside_param);
@@ -407,6 +408,7 @@ static void drive_bay_fan_tick(void)
407 return; 408 return;
408 if (!drive_bay_tick) { 409 if (!drive_bay_tick) {
409 /* first time; initialize things */ 410 /* first time; initialize things */
411 printk(KERN_INFO "windfarm: Drive bay control loop started.\n");
410 drive_bay_prm.min = drive_bay_fan->ops->get_min(drive_bay_fan); 412 drive_bay_prm.min = drive_bay_fan->ops->get_min(drive_bay_fan);
411 drive_bay_prm.max = drive_bay_fan->ops->get_max(drive_bay_fan); 413 drive_bay_prm.max = drive_bay_fan->ops->get_max(drive_bay_fan);
412 wf_pid_init(&drive_bay_pid, &drive_bay_prm); 414 wf_pid_init(&drive_bay_pid, &drive_bay_prm);
@@ -458,6 +460,7 @@ static void slots_fan_tick(void)
458 return; 460 return;
459 if (!slots_started) { 461 if (!slots_started) {
460 /* first time; initialize things */ 462 /* first time; initialize things */
463 printk(KERN_INFO "windfarm: Slots control loop started.\n");
461 wf_pid_init(&slots_pid, &slots_param); 464 wf_pid_init(&slots_pid, &slots_param);
462 slots_started = 1; 465 slots_started = 1;
463 } 466 }
@@ -504,6 +507,7 @@ static void pm112_tick(void)
504 507
505 if (!started) { 508 if (!started) {
506 started = 1; 509 started = 1;
510 printk(KERN_INFO "windfarm: CPUs control loops started.\n");
507 for (i = 0; i < nr_cores; ++i) { 511 for (i = 0; i < nr_cores; ++i) {
508 if (create_cpu_loop(i) < 0) { 512 if (create_cpu_loop(i) < 0) {
509 failure_state = FAILURE_PERM; 513 failure_state = FAILURE_PERM;
@@ -594,8 +598,6 @@ static void pm112_new_sensor(struct wf_sensor *sr)
594{ 598{
595 unsigned int i; 599 unsigned int i;
596 600
597 if (have_all_sensors)
598 return;
599 if (!strncmp(sr->name, "cpu-temp-", 9)) { 601 if (!strncmp(sr->name, "cpu-temp-", 9)) {
600 i = sr->name[9] - '0'; 602 i = sr->name[9] - '0';
601 if (sr->name[10] == 0 && i < NR_CORES && 603 if (sr->name[10] == 0 && i < NR_CORES &&
@@ -613,7 +615,7 @@ static void pm112_new_sensor(struct wf_sensor *sr)
613 } else if (!strcmp(sr->name, "slots-power")) { 615 } else if (!strcmp(sr->name, "slots-power")) {
614 if (slots_power == NULL && wf_get_sensor(sr) == 0) 616 if (slots_power == NULL && wf_get_sensor(sr) == 0)
615 slots_power = sr; 617 slots_power = sr;
616 } else if (!strcmp(sr->name, "u4-temp")) { 618 } else if (!strcmp(sr->name, "backside-temp")) {
617 if (u4_temp == NULL && wf_get_sensor(sr) == 0) 619 if (u4_temp == NULL && wf_get_sensor(sr) == 0)
618 u4_temp = sr; 620 u4_temp = sr;
619 } else 621 } else
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d39f584cd8b3..5d88329e3c7a 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -306,6 +306,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
306 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); 306 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
307 int mirror, behind = test_bit(R1BIO_BehindIO, &r1_bio->state); 307 int mirror, behind = test_bit(R1BIO_BehindIO, &r1_bio->state);
308 conf_t *conf = mddev_to_conf(r1_bio->mddev); 308 conf_t *conf = mddev_to_conf(r1_bio->mddev);
309 struct bio *to_put = NULL;
309 310
310 if (bio->bi_size) 311 if (bio->bi_size)
311 return 1; 312 return 1;
@@ -323,6 +324,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
323 * this branch is our 'one mirror IO has finished' event handler: 324 * this branch is our 'one mirror IO has finished' event handler:
324 */ 325 */
325 r1_bio->bios[mirror] = NULL; 326 r1_bio->bios[mirror] = NULL;
327 to_put = bio;
326 if (!uptodate) { 328 if (!uptodate) {
327 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev); 329 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
328 /* an I/O failed, we can't clear the bitmap */ 330 /* an I/O failed, we can't clear the bitmap */
@@ -375,7 +377,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
375 /* Don't dec_pending yet, we want to hold 377 /* Don't dec_pending yet, we want to hold
376 * the reference over the retry 378 * the reference over the retry
377 */ 379 */
378 return 0; 380 goto out;
379 } 381 }
380 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { 382 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
381 /* free extra copy of the data pages */ 383 /* free extra copy of the data pages */
@@ -392,10 +394,11 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
392 raid_end_bio_io(r1_bio); 394 raid_end_bio_io(r1_bio);
393 } 395 }
394 396
395 if (r1_bio->bios[mirror]==NULL)
396 bio_put(bio);
397
398 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); 397 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
398 out:
399 if (to_put)
400 bio_put(to_put);
401
399 return 0; 402 return 0;
400} 403}
401 404
@@ -857,7 +860,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
857 atomic_set(&r1_bio->remaining, 0); 860 atomic_set(&r1_bio->remaining, 0);
858 atomic_set(&r1_bio->behind_remaining, 0); 861 atomic_set(&r1_bio->behind_remaining, 0);
859 862
860 do_barriers = bio->bi_rw & BIO_RW_BARRIER; 863 do_barriers = bio_barrier(bio);
861 if (do_barriers) 864 if (do_barriers)
862 set_bit(R1BIO_Barrier, &r1_bio->state); 865 set_bit(R1BIO_Barrier, &r1_bio->state);
863 866
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 390cc3a99ce6..9c7f122826e0 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -526,7 +526,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
526 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); 526 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
527 } else 527 } else
528 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 528 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
529 if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { 529 if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
530 ops = fc->fe->ops; 530 ops = fc->fe->ops;
531 531
532 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; 532 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c
index 34c3189a1a33..356f447ee2ab 100644
--- a/drivers/media/dvb/bt8xx/bt878.c
+++ b/drivers/media/dvb/bt8xx/bt878.c
@@ -382,7 +382,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
382EXPORT_SYMBOL(bt878_device_control); 382EXPORT_SYMBOL(bt878_device_control);
383 383
384 384
385struct cards card_list[] __devinitdata = { 385static struct cards card_list[] __devinitdata = {
386 386
387 { 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" }, 387 { 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
388 { 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" }, 388 { 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" },
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 3a2ff1cc24b7..0310e3dd07e6 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -602,7 +602,7 @@ static int dst_type_print(u8 type)
602 602
603*/ 603*/
604 604
605struct dst_types dst_tlist[] = { 605static struct dst_types dst_tlist[] = {
606 { 606 {
607 .device_id = "200103A", 607 .device_id = "200103A",
608 .offset = 0, 608 .offset = 0,
diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h
index 9f025825b2d2..0c1d87c5227a 100644
--- a/drivers/media/dvb/dvb-core/demux.h
+++ b/drivers/media/dvb/dvb-core/demux.h
@@ -216,7 +216,7 @@ struct dmx_frontend {
216/*--------------------------------------------------------------------------*/ 216/*--------------------------------------------------------------------------*/
217 217
218/* 218/*
219 * Flags OR'ed in the capabilites field of struct dmx_demux. 219 * Flags OR'ed in the capabilities field of struct dmx_demux.
220 */ 220 */
221 221
222#define DMX_TS_FILTERING 1 222#define DMX_TS_FILTERING 1
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index f327fac1688e..162f9795cd89 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -282,7 +282,7 @@ static struct cx22702_config cxusb_cx22702_config = {
282 .pll_set = dvb_usb_pll_set_i2c, 282 .pll_set = dvb_usb_pll_set_i2c,
283}; 283};
284 284
285static struct lgdt330x_config cxusb_lgdt330x_config = { 285static struct lgdt330x_config cxusb_lgdt3303_config = {
286 .demod_address = 0x0e, 286 .demod_address = 0x0e,
287 .demod_chip = LGDT3303, 287 .demod_chip = LGDT3303,
288 .pll_set = dvb_usb_pll_set_i2c, 288 .pll_set = dvb_usb_pll_set_i2c,
@@ -357,14 +357,14 @@ static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d)
357 return -EIO; 357 return -EIO;
358} 358}
359 359
360static int cxusb_lgdt330x_frontend_attach(struct dvb_usb_device *d) 360static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_device *d)
361{ 361{
362 if (usb_set_interface(d->udev,0,7) < 0) 362 if (usb_set_interface(d->udev,0,7) < 0)
363 err("set interface failed"); 363 err("set interface failed");
364 364
365 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 365 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
366 366
367 if ((d->fe = lgdt330x_attach(&cxusb_lgdt330x_config, &d->i2c_adap)) != NULL) 367 if ((d->fe = lgdt330x_attach(&cxusb_lgdt3303_config, &d->i2c_adap)) != NULL)
368 return 0; 368 return 0;
369 369
370 return -EIO; 370 return -EIO;
@@ -506,7 +506,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
506 506
507 .streaming_ctrl = cxusb_streaming_ctrl, 507 .streaming_ctrl = cxusb_streaming_ctrl,
508 .power_ctrl = cxusb_power_ctrl, 508 .power_ctrl = cxusb_power_ctrl,
509 .frontend_attach = cxusb_lgdt330x_frontend_attach, 509 .frontend_attach = cxusb_lgdt3303_frontend_attach,
510 .tuner_attach = cxusb_lgh064f_tuner_attach, 510 .tuner_attach = cxusb_lgh064f_tuner_attach,
511 511
512 .i2c_algo = &cxusb_i2c_algo, 512 .i2c_algo = &cxusb_i2c_algo,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index 716f8bf528cd..ce34a55e5c24 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -47,7 +47,7 @@ static int dvb_usb_init(struct dvb_usb_device *d)
47 47
48 d->state = DVB_USB_STATE_INIT; 48 d->state = DVB_USB_STATE_INIT;
49 49
50/* check the capabilites and set appropriate variables */ 50/* check the capabilities and set appropriate variables */
51 51
52/* speed - when running at FULL speed we need a HW PID filter */ 52/* speed - when running at FULL speed we need a HW PID filter */
53 if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) { 53 if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) {
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 5e5d21ad93c9..d4909e5c67e0 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -87,7 +87,7 @@ struct dvb_usb_device;
87 87
88/** 88/**
89 * struct dvb_usb_properties - properties of a dvb-usb-device 89 * struct dvb_usb_properties - properties of a dvb-usb-device
90 * @caps: capabilites of the DVB USB device. 90 * @caps: capabilities of the DVB USB device.
91 * @pid_filter_count: number of PID filter position in the optional hardware 91 * @pid_filter_count: number of PID filter position in the optional hardware
92 * PID-filter. 92 * PID-filter.
93 * 93 *
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 76b6a2aef32f..c676b1e23ab0 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -29,7 +29,7 @@ config DVB_TDA8083
29 A DVB-S tuner module. Say Y when you want to support this frontend. 29 A DVB-S tuner module. Say Y when you want to support this frontend.
30 30
31config DVB_MT312 31config DVB_MT312
32 tristate "Zarlink MT312 based" 32 tristate "Zarlink VP310/MT312 based"
33 depends on DVB_CORE 33 depends on DVB_CORE
34 help 34 help
35 A DVB-S tuner module. Say Y when you want to support this frontend. 35 A DVB-S tuner module. Say Y when you want to support this frontend.
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index ec4e641acc64..d3aea83cf218 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -612,76 +612,6 @@ static void mt312_release(struct dvb_frontend* fe)
612 kfree(state); 612 kfree(state);
613} 613}
614 614
615static struct dvb_frontend_ops vp310_mt312_ops;
616
617struct dvb_frontend* vp310_attach(const struct mt312_config* config,
618 struct i2c_adapter* i2c)
619{
620 struct mt312_state* state = NULL;
621
622 /* allocate memory for the internal state */
623 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
624 if (state == NULL)
625 goto error;
626
627 /* setup the state */
628 state->config = config;
629 state->i2c = i2c;
630 memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
631 strcpy(state->ops.info.name, "Zarlink VP310 DVB-S");
632
633 /* check if the demod is there */
634 if (mt312_readreg(state, ID, &state->id) < 0)
635 goto error;
636 if (state->id != ID_VP310) {
637 goto error;
638 }
639
640 /* create dvb_frontend */
641 state->frequency = 90;
642 state->frontend.ops = &state->ops;
643 state->frontend.demodulator_priv = state;
644 return &state->frontend;
645
646error:
647 kfree(state);
648 return NULL;
649}
650
651struct dvb_frontend* mt312_attach(const struct mt312_config* config,
652 struct i2c_adapter* i2c)
653{
654 struct mt312_state* state = NULL;
655
656 /* allocate memory for the internal state */
657 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
658 if (state == NULL)
659 goto error;
660
661 /* setup the state */
662 state->config = config;
663 state->i2c = i2c;
664 memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
665 strcpy(state->ops.info.name, "Zarlink MT312 DVB-S");
666
667 /* check if the demod is there */
668 if (mt312_readreg(state, ID, &state->id) < 0)
669 goto error;
670 if (state->id != ID_MT312) {
671 goto error;
672 }
673
674 /* create dvb_frontend */
675 state->frequency = 60;
676 state->frontend.ops = &state->ops;
677 state->frontend.demodulator_priv = state;
678 return &state->frontend;
679
680error:
681 kfree(state);
682 return NULL;
683}
684
685static struct dvb_frontend_ops vp310_mt312_ops = { 615static struct dvb_frontend_ops vp310_mt312_ops = {
686 616
687 .info = { 617 .info = {
@@ -720,6 +650,49 @@ static struct dvb_frontend_ops vp310_mt312_ops = {
720 .set_voltage = mt312_set_voltage, 650 .set_voltage = mt312_set_voltage,
721}; 651};
722 652
653struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
654 struct i2c_adapter* i2c)
655{
656 struct mt312_state* state = NULL;
657
658 /* allocate memory for the internal state */
659 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
660 if (state == NULL)
661 goto error;
662
663 /* setup the state */
664 state->config = config;
665 state->i2c = i2c;
666 memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
667
668 /* check if the demod is there */
669 if (mt312_readreg(state, ID, &state->id) < 0)
670 goto error;
671
672 switch (state->id) {
673 case ID_VP310:
674 strcpy(state->ops.info.name, "Zarlink VP310 DVB-S");
675 state->frequency = 90;
676 break;
677 case ID_MT312:
678 strcpy(state->ops.info.name, "Zarlink MT312 DVB-S");
679 state->frequency = 60;
680 break;
681 default:
682 printk (KERN_WARNING "Only Zarlink VP310/MT312 are supported chips.\n");
683 goto error;
684 }
685
686 /* create dvb_frontend */
687 state->frontend.ops = &state->ops;
688 state->frontend.demodulator_priv = state;
689 return &state->frontend;
690
691error:
692 kfree(state);
693 return NULL;
694}
695
723module_param(debug, int, 0644); 696module_param(debug, int, 0644);
724MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 697MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
725 698
@@ -727,5 +700,4 @@ MODULE_DESCRIPTION("Zarlink VP310/MT312 DVB-S Demodulator driver");
727MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); 700MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
728MODULE_LICENSE("GPL"); 701MODULE_LICENSE("GPL");
729 702
730EXPORT_SYMBOL(mt312_attach); 703EXPORT_SYMBOL(vp310_mt312_attach);
731EXPORT_SYMBOL(vp310_attach);
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index b3a53a73a117..074d844f0139 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -38,10 +38,8 @@ struct mt312_config
38 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 38 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
39}; 39};
40 40
41extern struct dvb_frontend* mt312_attach(const struct mt312_config* config, 41struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
42 struct i2c_adapter* i2c); 42 struct i2c_adapter* i2c);
43 43
44extern struct dvb_frontend* vp310_attach(const struct mt312_config* config,
45 struct i2c_adapter* i2c);
46 44
47#endif // MT312_H 45#endif // MT312_H
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c
index 6122ba754bc5..eb15676d374f 100644
--- a/drivers/media/dvb/frontends/stv0297.c
+++ b/drivers/media/dvb/frontends/stv0297.c
@@ -393,10 +393,6 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
393 break; 393 break;
394 394
395 case QAM_128: 395 case QAM_128:
396 delay = 150;
397 sweeprate = 1000;
398 break;
399
400 case QAM_256: 396 case QAM_256:
401 delay = 200; 397 delay = 200;
402 sweeprate = 500; 398 sweeprate = 500;
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index d36369e9e88f..7c6ccb96b157 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -1439,7 +1439,7 @@ static int check_firmware(struct av7110* av7110)
1439 len = ntohl(*(u32*) ptr); 1439 len = ntohl(*(u32*) ptr);
1440 ptr += 4; 1440 ptr += 4;
1441 if (len >= 512) { 1441 if (len >= 512) {
1442 printk("dvb-ttpci: dpram file is way to big.\n"); 1442 printk("dvb-ttpci: dpram file is way too big.\n");
1443 return -EINVAL; 1443 return -EINVAL;
1444 } 1444 }
1445 if (crc != crc32_le(0, ptr, len)) { 1445 if (crc != crc32_le(0, ptr, len)) {
@@ -2477,7 +2477,8 @@ static int frontend_init(struct av7110 *av7110)
2477 * The same behaviour of missing VSYNC can be duplicated on budget 2477 * The same behaviour of missing VSYNC can be duplicated on budget
2478 * cards, by seting DD1_INIT trigger mode 7 in 3rd nibble. 2478 * cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
2479 */ 2479 */
2480static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *pci_ext) 2480static int __devinit av7110_attach(struct saa7146_dev* dev,
2481 struct saa7146_pci_extension_data *pci_ext)
2481{ 2482{
2482 const int length = TS_WIDTH * TS_HEIGHT; 2483 const int length = TS_WIDTH * TS_HEIGHT;
2483 struct pci_dev *pdev = dev->pci; 2484 struct pci_dev *pdev = dev->pci;
@@ -2827,7 +2828,7 @@ err_kfree_0:
2827 goto out; 2828 goto out;
2828} 2829}
2829 2830
2830static int av7110_detach(struct saa7146_dev* saa) 2831static int __devexit av7110_detach(struct saa7146_dev* saa)
2831{ 2832{
2832 struct av7110 *av7110 = saa->ext_priv; 2833 struct av7110 *av7110 = saa->ext_priv;
2833 dprintk(4, "%p\n", av7110); 2834 dprintk(4, "%p\n", av7110);
@@ -2974,7 +2975,7 @@ static struct saa7146_extension av7110_extension = {
2974 .module = THIS_MODULE, 2975 .module = THIS_MODULE,
2975 .pci_tbl = &pci_tbl[0], 2976 .pci_tbl = &pci_tbl[0],
2976 .attach = av7110_attach, 2977 .attach = av7110_attach,
2977 .detach = av7110_detach, 2978 .detach = __devexit_p(av7110_detach),
2978 2979
2979 .irq_mask = MASK_19 | MASK_03 | MASK_10, 2980 .irq_mask = MASK_19 | MASK_03 | MASK_10,
2980 .irq_func = av7110_irq, 2981 .irq_func = av7110_irq,
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index b2e63e9fc053..0bb6e74ae7f0 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -245,6 +245,9 @@ int av7110_bootarm(struct av7110 *av7110)
245 245
246 /* test DEBI */ 246 /* test DEBI */
247 iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4); 247 iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
248 /* FIXME: Why does Nexus CA require 2x iwdebi for first init? */
249 iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
250
248 if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) { 251 if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) {
249 printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: " 252 printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: "
250 "%08x != %08x (check your BIOS 'Plug&Play OS' settings)\n", 253 "%08x != %08x (check your BIOS 'Plug&Play OS' settings)\n",
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index 617e4f6c0ed7..d54bbcdde2cc 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -208,7 +208,7 @@ static void ir_handler(struct av7110 *av7110, u32 ircom)
208} 208}
209 209
210 210
211int __init av7110_ir_init(struct av7110 *av7110) 211int __devinit av7110_ir_init(struct av7110 *av7110)
212{ 212{
213 static struct proc_dir_entry *e; 213 static struct proc_dir_entry *e;
214 214
@@ -248,7 +248,7 @@ int __init av7110_ir_init(struct av7110 *av7110)
248} 248}
249 249
250 250
251void __exit av7110_ir_exit(struct av7110 *av7110) 251void __devexit av7110_ir_exit(struct av7110 *av7110)
252{ 252{
253 int i; 253 int i;
254 254
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 9f59541155d9..85d964b5b33c 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -3369,7 +3369,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3369 //DBG("cpia_ioctl: %u\n", ioctlnr); 3369 //DBG("cpia_ioctl: %u\n", ioctlnr);
3370 3370
3371 switch (ioctlnr) { 3371 switch (ioctlnr) {
3372 /* query capabilites */ 3372 /* query capabilities */
3373 case VIDIOCGCAP: 3373 case VIDIOCGCAP:
3374 { 3374 {
3375 struct video_capability *b = arg; 3375 struct video_capability *b = arg;
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 08ffd1f325fc..5588b9a5c430 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -567,7 +567,7 @@ static struct v4l2_queryctrl cx25840_qctrl[] = {
567 .type = V4L2_CTRL_TYPE_INTEGER, 567 .type = V4L2_CTRL_TYPE_INTEGER,
568 .name = "Contrast", 568 .name = "Contrast",
569 .minimum = 0, 569 .minimum = 0,
570 .maximum = 255, 570 .maximum = 127,
571 .step = 1, 571 .step = 1,
572 .default_value = 64, 572 .default_value = 64,
573 .flags = 0, 573 .flags = 0,
@@ -576,7 +576,7 @@ static struct v4l2_queryctrl cx25840_qctrl[] = {
576 .type = V4L2_CTRL_TYPE_INTEGER, 576 .type = V4L2_CTRL_TYPE_INTEGER,
577 .name = "Saturation", 577 .name = "Saturation",
578 .minimum = 0, 578 .minimum = 0,
579 .maximum = 255, 579 .maximum = 127,
580 .step = 1, 580 .step = 1,
581 .default_value = 64, 581 .default_value = 64,
582 .flags = 0, 582 .flags = 0,
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 048d000941c7..ffd87ce55556 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1027,7 +1027,7 @@ static struct v4l2_queryctrl saa7115_qctrl[] = {
1027 .type = V4L2_CTRL_TYPE_INTEGER, 1027 .type = V4L2_CTRL_TYPE_INTEGER,
1028 .name = "Contrast", 1028 .name = "Contrast",
1029 .minimum = 0, 1029 .minimum = 0,
1030 .maximum = 255, 1030 .maximum = 127,
1031 .step = 1, 1031 .step = 1,
1032 .default_value = 64, 1032 .default_value = 64,
1033 .flags = 0, 1033 .flags = 0,
@@ -1036,7 +1036,7 @@ static struct v4l2_queryctrl saa7115_qctrl[] = {
1036 .type = V4L2_CTRL_TYPE_INTEGER, 1036 .type = V4L2_CTRL_TYPE_INTEGER,
1037 .name = "Saturation", 1037 .name = "Saturation",
1038 .minimum = 0, 1038 .minimum = 0,
1039 .maximum = 255, 1039 .maximum = 127,
1040 .step = 1, 1040 .step = 1,
1041 .default_value = 64, 1041 .default_value = 64,
1042 .flags = 0, 1042 .flags = 0,
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index a7a6ab9298a9..7df5e0826e12 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -54,10 +54,12 @@ MODULE_PARM_DESC(debug,"enable debug messages [alsa]");
54 54
55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
57static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; 57static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 1};
58 58
59module_param_array(index, int, NULL, 0444); 59module_param_array(index, int, NULL, 0444);
60module_param_array(enable, int, NULL, 0444);
60MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); 61MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
62MODULE_PARM_DESC(enable, "Enable (or not) the SAA7134 capture interface(s).");
61 63
62#define dprintk(fmt, arg...) if (debug) \ 64#define dprintk(fmt, arg...) if (debug) \
63 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ##arg) 65 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ##arg)
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 5a35d3b6550d..6bc63a4086c1 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -977,7 +977,7 @@ struct saa7134_board saa7134_boards[] = {
977 .radio_type = UNSET, 977 .radio_type = UNSET,
978 .tuner_addr = ADDR_UNSET, 978 .tuner_addr = ADDR_UNSET,
979 .radio_addr = ADDR_UNSET, 979 .radio_addr = ADDR_UNSET,
980 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_ACTIVE, 980 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE,
981 .inputs = {{ 981 .inputs = {{
982 .name = name_tv, 982 .name = name_tv,
983 .vmux = 3, 983 .vmux = 3,
@@ -1666,7 +1666,7 @@ struct saa7134_board saa7134_boards[] = {
1666 .radio_type = UNSET, 1666 .radio_type = UNSET,
1667 .tuner_addr = ADDR_UNSET, 1667 .tuner_addr = ADDR_UNSET,
1668 .radio_addr = ADDR_UNSET, 1668 .radio_addr = ADDR_UNSET,
1669 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_ACTIVE, 1669 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE,
1670 .mpeg = SAA7134_MPEG_DVB, 1670 .mpeg = SAA7134_MPEG_DVB,
1671 .inputs = {{ 1671 .inputs = {{
1672 .name = name_tv, 1672 .name = name_tv,
@@ -2187,7 +2187,7 @@ struct saa7134_board saa7134_boards[] = {
2187 .radio_type = UNSET, 2187 .radio_type = UNSET,
2188 .tuner_addr = 0x61, 2188 .tuner_addr = 0x61,
2189 .radio_addr = ADDR_UNSET, 2189 .radio_addr = ADDR_UNSET,
2190 .tda9887_conf = TDA9887_PRESENT, 2190 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
2191 .mpeg = SAA7134_MPEG_DVB, 2191 .mpeg = SAA7134_MPEG_DVB,
2192 .inputs = {{ 2192 .inputs = {{
2193 .name = name_tv, 2193 .name = name_tv,
@@ -2211,7 +2211,7 @@ struct saa7134_board saa7134_boards[] = {
2211 .radio_type = UNSET, 2211 .radio_type = UNSET,
2212 .tuner_addr = 0x61, 2212 .tuner_addr = 0x61,
2213 .radio_addr = ADDR_UNSET, 2213 .radio_addr = ADDR_UNSET,
2214 .tda9887_conf = TDA9887_PRESENT, 2214 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
2215 .mpeg = SAA7134_MPEG_DVB, 2215 .mpeg = SAA7134_MPEG_DVB,
2216 .inputs = {{ 2216 .inputs = {{
2217 .name = name_tv, 2217 .name = name_tv,
@@ -2392,7 +2392,7 @@ struct saa7134_board saa7134_boards[] = {
2392 }}, 2392 }},
2393 }, 2393 },
2394 [SAA7134_BOARD_PINNACLE_PCTV_110i] = { 2394 [SAA7134_BOARD_PINNACLE_PCTV_110i] = {
2395 .name = "Pinnacle PCTV 110i (saa7133)", 2395 .name = "Pinnacle PCTV 40i/50i/110i (saa7133)",
2396 .audio_clock = 0x00187de7, 2396 .audio_clock = 0x00187de7,
2397 .tuner_type = TUNER_PHILIPS_TDA8290, 2397 .tuner_type = TUNER_PHILIPS_TDA8290,
2398 .radio_type = UNSET, 2398 .radio_type = UNSET,
@@ -2407,6 +2407,10 @@ struct saa7134_board saa7134_boards[] = {
2407 },{ 2407 },{
2408 .name = name_comp1, 2408 .name = name_comp1,
2409 .vmux = 1, 2409 .vmux = 1,
2410 .amux = LINE2,
2411 },{
2412 .name = name_comp2,
2413 .vmux = 0,
2410 .amux = LINE2, 2414 .amux = LINE2,
2411 },{ 2415 },{
2412 .name = name_svideo, 2416 .name = name_svideo,
@@ -2745,7 +2749,7 @@ struct pci_device_id saa7134_pci_tbl[] = {
2745 .vendor = PCI_VENDOR_ID_PHILIPS, 2749 .vendor = PCI_VENDOR_ID_PHILIPS,
2746 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 2750 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
2747 .subvendor = 0x1048, 2751 .subvendor = 0x1048,
2748 .subdevice = 0x226b, 2752 .subdevice = 0x226a,
2749 .driver_data = SAA7134_BOARD_ELSA_500TV, 2753 .driver_data = SAA7134_BOARD_ELSA_500TV,
2750 },{ 2754 },{
2751 .vendor = PCI_VENDOR_ID_PHILIPS, 2755 .vendor = PCI_VENDOR_ID_PHILIPS,
@@ -3201,6 +3205,11 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3201 /* power-up tuner chip */ 3205 /* power-up tuner chip */
3202 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000); 3206 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000);
3203 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000); 3207 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000);
3208 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
3209 /* this turns the remote control chip off to work around a bug in it */
3210 saa_writeb(SAA7134_GPIO_GPMODE1, 0x80);
3211 saa_writeb(SAA7134_GPIO_GPSTATUS1, 0x80);
3212 break;
3204 case SAA7134_BOARD_MONSTERTV_MOBILE: 3213 case SAA7134_BOARD_MONSTERTV_MOBILE:
3205 /* power-up tuner chip */ 3214 /* power-up tuner chip */
3206 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000); 3215 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 1a536e865277..9db8e13f21c3 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -110,6 +110,7 @@ static int mt352_pinnacle_init(struct dvb_frontend* fe)
110 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg)); 110 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
111 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg)); 111 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
112 mt352_write(fe, irq_cfg, sizeof(irq_cfg)); 112 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
113
113 return 0; 114 return 0;
114} 115}
115 116
@@ -117,8 +118,10 @@ static int mt352_pinnacle_pll_set(struct dvb_frontend* fe,
117 struct dvb_frontend_parameters* params, 118 struct dvb_frontend_parameters* params,
118 u8* pllbuf) 119 u8* pllbuf)
119{ 120{
120 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE; 121 u8 off[] = { 0x00, 0xf1};
121 static int off = TDA9887_PRESENT | TDA9887_PORT2_ACTIVE; 122 u8 on[] = { 0x00, 0x71};
123 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
124
122 struct saa7134_dev *dev = fe->dvb->priv; 125 struct saa7134_dev *dev = fe->dvb->priv;
123 struct v4l2_frequency f; 126 struct v4l2_frequency f;
124 127
@@ -126,9 +129,10 @@ static int mt352_pinnacle_pll_set(struct dvb_frontend* fe,
126 f.tuner = 0; 129 f.tuner = 0;
127 f.type = V4L2_TUNER_DIGITAL_TV; 130 f.type = V4L2_TUNER_DIGITAL_TV;
128 f.frequency = params->frequency / 1000 * 16 / 1000; 131 f.frequency = params->frequency / 1000 * 16 / 1000;
129 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on); 132 i2c_transfer(&dev->i2c_adap, &msg, 1);
130 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); 133 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
131 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&off); 134 msg.buf = on;
135 i2c_transfer(&dev->i2c_adap, &msg, 1);
132 136
133 pinnacle_antenna_pwr(dev, antenna_pwr); 137 pinnacle_antenna_pwr(dev, antenna_pwr);
134 138
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index 7b4fb282ac82..a796a4e1917c 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -580,9 +580,10 @@ int tda8290_init(struct i2c_client *c)
580 580
581int tda8290_probe(struct i2c_client *c) 581int tda8290_probe(struct i2c_client *c)
582{ 582{
583 unsigned char soft_reset[] = { 0x00, 0x00 }; 583 unsigned char soft_reset[] = { 0x00, 0x00 };
584 unsigned char easy_mode_b[] = { 0x01, 0x02 }; 584 unsigned char easy_mode_b[] = { 0x01, 0x02 };
585 unsigned char easy_mode_g[] = { 0x01, 0x04 }; 585 unsigned char easy_mode_g[] = { 0x01, 0x04 };
586 unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 };
586 unsigned char addr_dto_lsb = 0x07; 587 unsigned char addr_dto_lsb = 0x07;
587 unsigned char data; 588 unsigned char data;
588 589
@@ -599,6 +600,7 @@ int tda8290_probe(struct i2c_client *c)
599 return 0; 600 return 0;
600 } 601 }
601 } 602 }
603 i2c_master_send(c, restore_9886, 3);
602 return -1; 604 return -1;
603} 605}
604 606
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index e7ee619d62c5..b6101bf446d4 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -713,8 +713,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
713 struct v4l2_frequency *f = arg; 713 struct v4l2_frequency *f = arg;
714 714
715 switch_v4l2(); 715 switch_v4l2();
716 if (V4L2_TUNER_RADIO == f->type && 716 if ((V4L2_TUNER_RADIO == f->type && V4L2_TUNER_RADIO != t->mode)
717 V4L2_TUNER_RADIO != t->mode) { 717 || (V4L2_TUNER_DIGITAL_TV == f->type
718 && V4L2_TUNER_DIGITAL_TV != t->mode)) {
718 if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY") 719 if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY")
719 == EINVAL) 720 == EINVAL)
720 return 0; 721 return 0;
diff --git a/drivers/media/video/videocodec.h b/drivers/media/video/videocodec.h
index 156ae57096fe..b1239ac7f371 100644
--- a/drivers/media/video/videocodec.h
+++ b/drivers/media/video/videocodec.h
@@ -56,7 +56,7 @@
56 the slave is bound to it). Otherwise it doesn't need this functions and 56 the slave is bound to it). Otherwise it doesn't need this functions and
57 therfor they may not be initialized. 57 therfor they may not be initialized.
58 58
59 The other fuctions are just for convenience, as they are for shure used by 59 The other fuctions are just for convenience, as they are for sure used by
60 most/all of the codecs. The last ones may be ommited, too. 60 most/all of the codecs. The last ones may be ommited, too.
61 61
62 See the structure declaration below for more information and which data has 62 See the structure declaration below for more information and which data has
diff --git a/drivers/media/video/zr36050.c b/drivers/media/video/zr36050.c
index bd0cd28543ca..6699725be605 100644
--- a/drivers/media/video/zr36050.c
+++ b/drivers/media/video/zr36050.c
@@ -159,7 +159,7 @@ zr36050_wait_end (struct zr36050 *ptr)
159 159
160 while (!(zr36050_read_status1(ptr) & 0x4)) { 160 while (!(zr36050_read_status1(ptr) & 0x4)) {
161 udelay(1); 161 udelay(1);
162 if (i++ > 200000) { // 200ms, there is for shure something wrong!!! 162 if (i++ > 200000) { // 200ms, there is for sure something wrong!!!
163 dprintk(1, 163 dprintk(1,
164 "%s: timout at wait_end (last status: 0x%02x)\n", 164 "%s: timout at wait_end (last status: 0x%02x)\n",
165 ptr->name, ptr->status1); 165 ptr->name, ptr->status1);
diff --git a/drivers/media/video/zr36060.c b/drivers/media/video/zr36060.c
index 28fa31a5f150..d8dd003a7aad 100644
--- a/drivers/media/video/zr36060.c
+++ b/drivers/media/video/zr36060.c
@@ -161,7 +161,7 @@ zr36060_wait_end (struct zr36060 *ptr)
161 161
162 while (zr36060_read_status(ptr) & ZR060_CFSR_Busy) { 162 while (zr36060_read_status(ptr) & ZR060_CFSR_Busy) {
163 udelay(1); 163 udelay(1);
164 if (i++ > 200000) { // 200ms, there is for shure something wrong!!! 164 if (i++ > 200000) { // 200ms, there is for sure something wrong!!!
165 dprintk(1, 165 dprintk(1,
166 "%s: timout at wait_end (last status: 0x%02x)\n", 166 "%s: timout at wait_end (last status: 0x%02x)\n",
167 ptr->name, ptr->status); 167 ptr->name, ptr->status);
diff --git a/drivers/media/video/zr36120_i2c.c b/drivers/media/video/zr36120_i2c.c
index 6bfe84d657f1..21fde43a6aed 100644
--- a/drivers/media/video/zr36120_i2c.c
+++ b/drivers/media/video/zr36120_i2c.c
@@ -65,7 +65,7 @@ void attach_inform(struct i2c_bus *bus, int id)
65 case I2C_DRIVERID_VIDEODECODER: 65 case I2C_DRIVERID_VIDEODECODER:
66 DEBUG(printk(CARD_INFO "decoder attached\n",CARD)); 66 DEBUG(printk(CARD_INFO "decoder attached\n",CARD));
67 67
68 /* fetch the capabilites of the decoder */ 68 /* fetch the capabilities of the decoder */
69 rv = i2c_control_device(&ztv->i2c, I2C_DRIVERID_VIDEODECODER, DECODER_GET_CAPABILITIES, &dc); 69 rv = i2c_control_device(&ztv->i2c, I2C_DRIVERID_VIDEODECODER, DECODER_GET_CAPABILITIES, &dc);
70 if (rv) { 70 if (rv) {
71 DEBUG(printk(CARD_DEBUG "decoder is not V4L aware!\n",CARD)); 71 DEBUG(printk(CARD_DEBUG "decoder is not V4L aware!\n",CARD));
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h
index 1cef2387fa65..6aba41954448 100644
--- a/drivers/misc/ibmasm/ibmasm.h
+++ b/drivers/misc/ibmasm/ibmasm.h
@@ -101,15 +101,16 @@ struct command {
101static inline void command_put(struct command *cmd) 101static inline void command_put(struct command *cmd)
102{ 102{
103 unsigned long flags; 103 unsigned long flags;
104 spinlock_t *lock = cmd->lock;
104 105
105 spin_lock_irqsave(cmd->lock, flags); 106 spin_lock_irqsave(lock, flags);
106 kobject_put(&cmd->kobj); 107 kobject_put(&cmd->kobj);
107 spin_unlock_irqrestore(cmd->lock, flags); 108 spin_unlock_irqrestore(lock, flags);
108} 109}
109 110
110static inline void command_get(struct command *cmd) 111static inline void command_get(struct command *cmd)
111{ 112{
112 kobject_get(&cmd->kobj); 113 kobject_get(&cmd->kobj);
113} 114}
114 115
115 116
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index 227c39a7c1b4..8d84b045bc83 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -37,7 +37,7 @@
37#include <linux/config.h> 37#include <linux/config.h>
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/device.h> 40#include <linux/platform_device.h>
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
@@ -194,7 +194,7 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
194 194
195 u32 mmccmd = (cmd->opcode << SD_CMD_CI_SHIFT); 195 u32 mmccmd = (cmd->opcode << SD_CMD_CI_SHIFT);
196 196
197 switch (mmc_rsp_type(cmd->flags)) { 197 switch (mmc_resp_type(cmd)) {
198 case MMC_RSP_R1: 198 case MMC_RSP_R1:
199 mmccmd |= SD_CMD_RT_1; 199 mmccmd |= SD_CMD_RT_1;
200 break; 200 break;
@@ -740,7 +740,6 @@ static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
740static void au1xmmc_dma_callback(int irq, void *dev_id, struct pt_regs *regs) 740static void au1xmmc_dma_callback(int irq, void *dev_id, struct pt_regs *regs)
741{ 741{
742 struct au1xmmc_host *host = (struct au1xmmc_host *) dev_id; 742 struct au1xmmc_host *host = (struct au1xmmc_host *) dev_id;
743 u32 status;
744 743
745 /* Avoid spurious interrupts */ 744 /* Avoid spurious interrupts */
746 745
@@ -887,7 +886,7 @@ struct mmc_host_ops au1xmmc_ops = {
887 .set_ios = au1xmmc_set_ios, 886 .set_ios = au1xmmc_set_ios,
888}; 887};
889 888
890static int au1xmmc_probe(struct device *dev) 889static int __devinit au1xmmc_probe(struct platform_device *pdev)
891{ 890{
892 891
893 int i, ret = 0; 892 int i, ret = 0;
@@ -904,7 +903,7 @@ static int au1xmmc_probe(struct device *dev)
904 disable_irq(AU1100_SD_IRQ); 903 disable_irq(AU1100_SD_IRQ);
905 904
906 for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) { 905 for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
907 struct mmc_host *mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), dev); 906 struct mmc_host *mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
908 struct au1xmmc_host *host = 0; 907 struct au1xmmc_host *host = 0;
909 908
910 if (!mmc) { 909 if (!mmc) {
@@ -967,7 +966,7 @@ static int au1xmmc_probe(struct device *dev)
967 return 0; 966 return 0;
968} 967}
969 968
970static int au1xmmc_remove(struct device *dev) 969static int __devexit au1xmmc_remove(struct platform_device *pdev)
971{ 970{
972 971
973 int i; 972 int i;
@@ -997,23 +996,24 @@ static int au1xmmc_remove(struct device *dev)
997 return 0; 996 return 0;
998} 997}
999 998
1000static struct device_driver au1xmmc_driver = { 999static struct platform_driver au1xmmc_driver = {
1001 .name = DRIVER_NAME,
1002 .bus = &platform_bus_type,
1003 .probe = au1xmmc_probe, 1000 .probe = au1xmmc_probe,
1004 .remove = au1xmmc_remove, 1001 .remove = au1xmmc_remove,
1005 .suspend = NULL, 1002 .suspend = NULL,
1006 .resume = NULL 1003 .resume = NULL,
1004 .driver = {
1005 .name = DRIVER_NAME,
1006 },
1007}; 1007};
1008 1008
1009static int __init au1xmmc_init(void) 1009static int __init au1xmmc_init(void)
1010{ 1010{
1011 return driver_register(&au1xmmc_driver); 1011 return platform_driver_register(&au1xmmc_driver);
1012} 1012}
1013 1013
1014static void __exit au1xmmc_exit(void) 1014static void __exit au1xmmc_exit(void)
1015{ 1015{
1016 driver_unregister(&au1xmmc_driver); 1016 platform_driver_unregister(&au1xmmc_driver);
1017} 1017}
1018 1018
1019module_init(au1xmmc_init); 1019module_init(au1xmmc_init);
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index d01b6a9198e0..8815c8dbef2d 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: redboot.c,v 1.18 2005/11/07 11:14:21 gleixner Exp $ 2 * $Id: redboot.c,v 1.19 2005/12/01 10:03:51 dwmw2 Exp $
3 * 3 *
4 * Parse RedBoot-style Flash Image System (FIS) tables and 4 * Parse RedBoot-style Flash Image System (FIS) tables and
5 * produce a Linux partition array to match. 5 * produce a Linux partition array to match.
@@ -92,10 +92,10 @@ static int parse_redboot_partitions(struct mtd_info *master,
92 if (!memcmp(buf[i].name, "FIS directory", 14)) { 92 if (!memcmp(buf[i].name, "FIS directory", 14)) {
93 /* This is apparently the FIS directory entry for the 93 /* This is apparently the FIS directory entry for the
94 * FIS directory itself. The FIS directory size is 94 * FIS directory itself. The FIS directory size is
95 * one erase block, if the buf[i].size field is 95 * one erase block; if the buf[i].size field is
96 * swab32(erasesize) then we know we are looking at 96 * swab32(erasesize) then we know we are looking at
97 * a byte swapped FIS directory - swap all the entries! 97 * a byte swapped FIS directory - swap all the entries!
98 * (NOTE: this is 'size' not 'data_length', size is 98 * (NOTE: this is 'size' not 'data_length'; size is
99 * the full size of the entry.) 99 * the full size of the entry.)
100 */ 100 */
101 if (swab32(buf[i].size) == master->erasesize) { 101 if (swab32(buf[i].size) == master->erasesize) {
@@ -104,15 +104,13 @@ static int parse_redboot_partitions(struct mtd_info *master,
104 /* The unsigned long fields were written with the 104 /* The unsigned long fields were written with the
105 * wrong byte sex, name and pad have no byte sex. 105 * wrong byte sex, name and pad have no byte sex.
106 */ 106 */
107# define do_swab32(x) (x) = swab32(x) 107 swab32s(&buf[j].flash_base);
108 do_swab32(buf[j].flash_base); 108 swab32s(&buf[j].mem_base);
109 do_swab32(buf[j].mem_base); 109 swab32s(&buf[j].size);
110 do_swab32(buf[j].size); 110 swab32s(&buf[j].entry_point);
111 do_swab32(buf[j].entry_point); 111 swab32s(&buf[j].data_length);
112 do_swab32(buf[j].data_length); 112 swab32s(&buf[j].desc_cksum);
113 do_swab32(buf[j].desc_cksum); 113 swab32s(&buf[j].file_cksum);
114 do_swab32(buf[j].file_cksum);
115# undef do_swab32
116 } 114 }
117 } 115 }
118 break; 116 break;
diff --git a/drivers/net/chelsio/espi.c b/drivers/net/chelsio/espi.c
index 230642571c92..e824acaf188a 100644
--- a/drivers/net/chelsio/espi.c
+++ b/drivers/net/chelsio/espi.c
@@ -296,9 +296,7 @@ void t1_espi_destroy(struct peespi *espi)
296 296
297struct peespi *t1_espi_create(adapter_t *adapter) 297struct peespi *t1_espi_create(adapter_t *adapter)
298{ 298{
299 struct peespi *espi = kmalloc(sizeof(*espi), GFP_KERNEL); 299 struct peespi *espi = kzalloc(sizeof(*espi), GFP_KERNEL);
300
301 memset(espi, 0, sizeof(*espi));
302 300
303 if (espi) 301 if (espi)
304 espi->adapter = adapter; 302 espi->adapter = adapter;
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 27c77306193b..99baf0e099fc 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -225,9 +225,6 @@ struct e1000_rx_ring {
225 struct e1000_ps_page *ps_page; 225 struct e1000_ps_page *ps_page;
226 struct e1000_ps_page_dma *ps_page_dma; 226 struct e1000_ps_page_dma *ps_page_dma;
227 227
228 struct sk_buff *rx_skb_top;
229 struct sk_buff *rx_skb_prev;
230
231 /* cpu for rx queue */ 228 /* cpu for rx queue */
232 int cpu; 229 int cpu;
233 230
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 31e332935e5a..5b7d0f425af2 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -103,7 +103,7 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
103#else 103#else
104#define DRIVERNAPI "-NAPI" 104#define DRIVERNAPI "-NAPI"
105#endif 105#endif
106#define DRV_VERSION "6.3.9-k2"DRIVERNAPI 106#define DRV_VERSION "6.3.9-k4"DRIVERNAPI
107char e1000_driver_version[] = DRV_VERSION; 107char e1000_driver_version[] = DRV_VERSION;
108static char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation."; 108static char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
109 109
@@ -1635,8 +1635,6 @@ setup_rx_desc_die:
1635 1635
1636 rxdr->next_to_clean = 0; 1636 rxdr->next_to_clean = 0;
1637 rxdr->next_to_use = 0; 1637 rxdr->next_to_use = 0;
1638 rxdr->rx_skb_top = NULL;
1639 rxdr->rx_skb_prev = NULL;
1640 1638
1641 return 0; 1639 return 0;
1642} 1640}
@@ -1713,8 +1711,23 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1713 rctl |= adapter->rx_buffer_len << 0x11; 1711 rctl |= adapter->rx_buffer_len << 0x11;
1714 } else { 1712 } else {
1715 rctl &= ~E1000_RCTL_SZ_4096; 1713 rctl &= ~E1000_RCTL_SZ_4096;
1716 rctl &= ~E1000_RCTL_BSEX; 1714 rctl |= E1000_RCTL_BSEX;
1717 rctl |= E1000_RCTL_SZ_2048; 1715 switch (adapter->rx_buffer_len) {
1716 case E1000_RXBUFFER_2048:
1717 default:
1718 rctl |= E1000_RCTL_SZ_2048;
1719 rctl &= ~E1000_RCTL_BSEX;
1720 break;
1721 case E1000_RXBUFFER_4096:
1722 rctl |= E1000_RCTL_SZ_4096;
1723 break;
1724 case E1000_RXBUFFER_8192:
1725 rctl |= E1000_RCTL_SZ_8192;
1726 break;
1727 case E1000_RXBUFFER_16384:
1728 rctl |= E1000_RCTL_SZ_16384;
1729 break;
1730 }
1718 } 1731 }
1719 1732
1720#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT 1733#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
@@ -2107,16 +2120,6 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter,
2107 } 2120 }
2108 } 2121 }
2109 2122
2110 /* there also may be some cached data in our adapter */
2111 if (rx_ring->rx_skb_top) {
2112 dev_kfree_skb(rx_ring->rx_skb_top);
2113
2114 /* rx_skb_prev will be wiped out by rx_skb_top */
2115 rx_ring->rx_skb_top = NULL;
2116 rx_ring->rx_skb_prev = NULL;
2117 }
2118
2119
2120 size = sizeof(struct e1000_buffer) * rx_ring->count; 2123 size = sizeof(struct e1000_buffer) * rx_ring->count;
2121 memset(rx_ring->buffer_info, 0, size); 2124 memset(rx_ring->buffer_info, 0, size);
2122 size = sizeof(struct e1000_ps_page) * rx_ring->count; 2125 size = sizeof(struct e1000_ps_page) * rx_ring->count;
@@ -3106,24 +3109,27 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
3106 break; 3109 break;
3107 } 3110 }
3108 3111
3109 /* since the driver code now supports splitting a packet across 3112
3110 * multiple descriptors, most of the fifo related limitations on
3111 * jumbo frame traffic have gone away.
3112 * simply use 2k descriptors for everything.
3113 *
3114 * NOTE: dev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
3115 * means we reserve 2 more, this pushes us to allocate from the next
3116 * larger slab size
3117 * i.e. RXBUFFER_2048 --> size-4096 slab */
3118
3119 /* recent hardware supports 1KB granularity */
3120 if (adapter->hw.mac_type > e1000_82547_rev_2) { 3113 if (adapter->hw.mac_type > e1000_82547_rev_2) {
3121 adapter->rx_buffer_len = 3114 adapter->rx_buffer_len = max_frame;
3122 ((max_frame < E1000_RXBUFFER_2048) ?
3123 max_frame : E1000_RXBUFFER_2048);
3124 E1000_ROUNDUP(adapter->rx_buffer_len, 1024); 3115 E1000_ROUNDUP(adapter->rx_buffer_len, 1024);
3125 } else 3116 } else {
3126 adapter->rx_buffer_len = E1000_RXBUFFER_2048; 3117 if(unlikely((adapter->hw.mac_type < e1000_82543) &&
3118 (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
3119 DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
3120 "on 82542\n");
3121 return -EINVAL;
3122 } else {
3123 if(max_frame <= E1000_RXBUFFER_2048)
3124 adapter->rx_buffer_len = E1000_RXBUFFER_2048;
3125 else if(max_frame <= E1000_RXBUFFER_4096)
3126 adapter->rx_buffer_len = E1000_RXBUFFER_4096;
3127 else if(max_frame <= E1000_RXBUFFER_8192)
3128 adapter->rx_buffer_len = E1000_RXBUFFER_8192;
3129 else if(max_frame <= E1000_RXBUFFER_16384)
3130 adapter->rx_buffer_len = E1000_RXBUFFER_16384;
3131 }
3132 }
3127 3133
3128 netdev->mtu = new_mtu; 3134 netdev->mtu = new_mtu;
3129 3135
@@ -3620,7 +3626,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3620 uint8_t last_byte; 3626 uint8_t last_byte;
3621 unsigned int i; 3627 unsigned int i;
3622 int cleaned_count = 0; 3628 int cleaned_count = 0;
3623 boolean_t cleaned = FALSE, multi_descriptor = FALSE; 3629 boolean_t cleaned = FALSE;
3624 3630
3625 i = rx_ring->next_to_clean; 3631 i = rx_ring->next_to_clean;
3626 rx_desc = E1000_RX_DESC(*rx_ring, i); 3632 rx_desc = E1000_RX_DESC(*rx_ring, i);
@@ -3652,43 +3658,12 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3652 3658
3653 length = le16_to_cpu(rx_desc->length); 3659 length = le16_to_cpu(rx_desc->length);
3654 3660
3655 skb_put(skb, length); 3661 if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
3656 3662 /* All receives must fit into a single buffer */
3657 if (!(status & E1000_RXD_STAT_EOP)) { 3663 E1000_DBG("%s: Receive packet consumed multiple"
3658 if (!rx_ring->rx_skb_top) { 3664 " buffers\n", netdev->name);
3659 rx_ring->rx_skb_top = skb; 3665 dev_kfree_skb_irq(skb);
3660 rx_ring->rx_skb_top->len = length;
3661 rx_ring->rx_skb_prev = skb;
3662 } else {
3663 if (skb_shinfo(rx_ring->rx_skb_top)->frag_list) {
3664 rx_ring->rx_skb_prev->next = skb;
3665 skb->prev = rx_ring->rx_skb_prev;
3666 } else {
3667 skb_shinfo(rx_ring->rx_skb_top)->frag_list = skb;
3668 }
3669 rx_ring->rx_skb_prev = skb;
3670 rx_ring->rx_skb_top->data_len += length;
3671 }
3672 goto next_desc; 3666 goto next_desc;
3673 } else {
3674 if (rx_ring->rx_skb_top) {
3675 if (skb_shinfo(rx_ring->rx_skb_top)
3676 ->frag_list) {
3677 rx_ring->rx_skb_prev->next = skb;
3678 skb->prev = rx_ring->rx_skb_prev;
3679 } else
3680 skb_shinfo(rx_ring->rx_skb_top)
3681 ->frag_list = skb;
3682
3683 rx_ring->rx_skb_top->data_len += length;
3684 rx_ring->rx_skb_top->len +=
3685 rx_ring->rx_skb_top->data_len;
3686
3687 skb = rx_ring->rx_skb_top;
3688 multi_descriptor = TRUE;
3689 rx_ring->rx_skb_top = NULL;
3690 rx_ring->rx_skb_prev = NULL;
3691 }
3692 } 3667 }
3693 3668
3694 if (unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { 3669 if (unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
@@ -3712,10 +3687,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3712 * performance for small packets with large amounts 3687 * performance for small packets with large amounts
3713 * of reassembly being done in the stack */ 3688 * of reassembly being done in the stack */
3714#define E1000_CB_LENGTH 256 3689#define E1000_CB_LENGTH 256
3715 if ((length < E1000_CB_LENGTH) && 3690 if (length < E1000_CB_LENGTH) {
3716 !rx_ring->rx_skb_top &&
3717 /* or maybe (status & E1000_RXD_STAT_EOP) && */
3718 !multi_descriptor) {
3719 struct sk_buff *new_skb = 3691 struct sk_buff *new_skb =
3720 dev_alloc_skb(length + NET_IP_ALIGN); 3692 dev_alloc_skb(length + NET_IP_ALIGN);
3721 if (new_skb) { 3693 if (new_skb) {
@@ -3729,7 +3701,8 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3729 skb = new_skb; 3701 skb = new_skb;
3730 skb_put(skb, length); 3702 skb_put(skb, length);
3731 } 3703 }
3732 } 3704 } else
3705 skb_put(skb, length);
3733 3706
3734 /* end copybreak code */ 3707 /* end copybreak code */
3735 3708
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 01ddfc8cce3f..aa5581369399 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -806,6 +806,7 @@ static struct pcmcia_device_id axnet_ids[] = {
806 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0309), 806 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0309),
807 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1106), 807 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1106),
808 PCMCIA_DEVICE_MANF_CARD(0x8a01, 0xc1ab), 808 PCMCIA_DEVICE_MANF_CARD(0x8a01, 0xc1ab),
809 PCMCIA_DEVICE_PROD_ID12("AmbiCom,Inc.", "Fast Ethernet PC Card(AMB8110)", 0x49b020a7, 0x119cc9fc),
809 PCMCIA_DEVICE_PROD_ID124("Fast Ethernet", "16-bit PC Card", "AX88190", 0xb4be14e3, 0x9a12eb6a, 0xab9be5ef), 810 PCMCIA_DEVICE_PROD_ID124("Fast Ethernet", "16-bit PC Card", "AX88190", 0xb4be14e3, 0x9a12eb6a, 0xab9be5ef),
810 PCMCIA_DEVICE_PROD_ID12("ASIX", "AX88190", 0x0959823b, 0xab9be5ef), 811 PCMCIA_DEVICE_PROD_ID12("ASIX", "AX88190", 0x0959823b, 0xab9be5ef),
811 PCMCIA_DEVICE_PROD_ID12("Billionton", "LNA-100B", 0x552ab682, 0xbc3b87e1), 812 PCMCIA_DEVICE_PROD_ID12("Billionton", "LNA-100B", 0x552ab682, 0xbc3b87e1),
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 49b597cbc19a..b7f00d6eb6a6 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -4092,6 +4092,7 @@ static void s2io_set_multicast(struct net_device *dev)
4092 i++, mclist = mclist->next) { 4092 i++, mclist = mclist->next) {
4093 memcpy(sp->usr_addrs[i].addr, mclist->dmi_addr, 4093 memcpy(sp->usr_addrs[i].addr, mclist->dmi_addr,
4094 ETH_ALEN); 4094 ETH_ALEN);
4095 mac_addr = 0;
4095 for (j = 0; j < ETH_ALEN; j++) { 4096 for (j = 0; j < ETH_ALEN; j++) {
4096 mac_addr |= mclist->dmi_addr[j]; 4097 mac_addr |= mclist->dmi_addr[j];
4097 mac_addr <<= 8; 4098 mac_addr <<= 8;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index e8e92c853e89..15545620ab0e 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -3532,9 +3532,23 @@ static inline int tg3_4g_overflow_test(dma_addr_t mapping, int len)
3532 (base + len + 8 < base)); 3532 (base + len + 8 < base));
3533} 3533}
3534 3534
3535/* Test for DMA addresses > 40-bit */
3536static inline int tg3_40bit_overflow_test(struct tg3 *tp, dma_addr_t mapping,
3537 int len)
3538{
3539#if defined(CONFIG_HIGHMEM) && (BITS_PER_LONG == 64)
3540 if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)
3541 return (((u64) mapping + len) > DMA_40BIT_MASK);
3542 return 0;
3543#else
3544 return 0;
3545#endif
3546}
3547
3535static void tg3_set_txd(struct tg3 *, int, dma_addr_t, int, u32, u32); 3548static void tg3_set_txd(struct tg3 *, int, dma_addr_t, int, u32, u32);
3536 3549
3537static int tigon3_4gb_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb, 3550/* Workaround 4GB and 40-bit hardware DMA bugs. */
3551static int tigon3_dma_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
3538 u32 last_plus_one, u32 *start, 3552 u32 last_plus_one, u32 *start,
3539 u32 base_flags, u32 mss) 3553 u32 base_flags, u32 mss)
3540{ 3554{
@@ -3742,6 +3756,9 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3742 if (tg3_4g_overflow_test(mapping, len)) 3756 if (tg3_4g_overflow_test(mapping, len))
3743 would_hit_hwbug = 1; 3757 would_hit_hwbug = 1;
3744 3758
3759 if (tg3_40bit_overflow_test(tp, mapping, len))
3760 would_hit_hwbug = 1;
3761
3745 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 3762 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
3746 tg3_set_txd(tp, entry, mapping, len, 3763 tg3_set_txd(tp, entry, mapping, len,
3747 base_flags, (i == last)|(mss << 1)); 3764 base_flags, (i == last)|(mss << 1));
@@ -3763,7 +3780,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3763 /* If the workaround fails due to memory/mapping 3780 /* If the workaround fails due to memory/mapping
3764 * failure, silently drop this packet. 3781 * failure, silently drop this packet.
3765 */ 3782 */
3766 if (tigon3_4gb_hwbug_workaround(tp, skb, last_plus_one, 3783 if (tigon3_dma_hwbug_workaround(tp, skb, last_plus_one,
3767 &start, base_flags, mss)) 3784 &start, base_flags, mss))
3768 goto out_unlock; 3785 goto out_unlock;
3769 3786
@@ -10608,8 +10625,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10608 unsigned long tg3reg_base, tg3reg_len; 10625 unsigned long tg3reg_base, tg3reg_len;
10609 struct net_device *dev; 10626 struct net_device *dev;
10610 struct tg3 *tp; 10627 struct tg3 *tp;
10611 int i, err, pci_using_dac, pm_cap; 10628 int i, err, pm_cap;
10612 char str[40]; 10629 char str[40];
10630 u64 dma_mask, persist_dma_mask;
10613 10631
10614 if (tg3_version_printed++ == 0) 10632 if (tg3_version_printed++ == 0)
10615 printk(KERN_INFO "%s", version); 10633 printk(KERN_INFO "%s", version);
@@ -10646,26 +10664,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10646 goto err_out_free_res; 10664 goto err_out_free_res;
10647 } 10665 }
10648 10666
10649 /* Configure DMA attributes. */
10650 err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
10651 if (!err) {
10652 pci_using_dac = 1;
10653 err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
10654 if (err < 0) {
10655 printk(KERN_ERR PFX "Unable to obtain 64 bit DMA "
10656 "for consistent allocations\n");
10657 goto err_out_free_res;
10658 }
10659 } else {
10660 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
10661 if (err) {
10662 printk(KERN_ERR PFX "No usable DMA configuration, "
10663 "aborting.\n");
10664 goto err_out_free_res;
10665 }
10666 pci_using_dac = 0;
10667 }
10668
10669 tg3reg_base = pci_resource_start(pdev, 0); 10667 tg3reg_base = pci_resource_start(pdev, 0);
10670 tg3reg_len = pci_resource_len(pdev, 0); 10668 tg3reg_len = pci_resource_len(pdev, 0);
10671 10669
@@ -10679,8 +10677,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10679 SET_MODULE_OWNER(dev); 10677 SET_MODULE_OWNER(dev);
10680 SET_NETDEV_DEV(dev, &pdev->dev); 10678 SET_NETDEV_DEV(dev, &pdev->dev);
10681 10679
10682 if (pci_using_dac)
10683 dev->features |= NETIF_F_HIGHDMA;
10684 dev->features |= NETIF_F_LLTX; 10680 dev->features |= NETIF_F_LLTX;
10685#if TG3_VLAN_TAG_USED 10681#if TG3_VLAN_TAG_USED
10686 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 10682 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
@@ -10765,6 +10761,44 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10765 goto err_out_iounmap; 10761 goto err_out_iounmap;
10766 } 10762 }
10767 10763
10764 /* 5714, 5715 and 5780 cannot support DMA addresses > 40-bit.
10765 * On 64-bit systems with IOMMU, use 40-bit dma_mask.
10766 * On 64-bit systems without IOMMU, use 64-bit dma_mask and
10767 * do DMA address check in tg3_start_xmit().
10768 */
10769 if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) {
10770 persist_dma_mask = dma_mask = DMA_40BIT_MASK;
10771#ifdef CONFIG_HIGHMEM
10772 dma_mask = DMA_64BIT_MASK;
10773#endif
10774 } else if (tp->tg3_flags2 & TG3_FLG2_IS_5788)
10775 persist_dma_mask = dma_mask = DMA_32BIT_MASK;
10776 else
10777 persist_dma_mask = dma_mask = DMA_64BIT_MASK;
10778
10779 /* Configure DMA attributes. */
10780 if (dma_mask > DMA_32BIT_MASK) {
10781 err = pci_set_dma_mask(pdev, dma_mask);
10782 if (!err) {
10783 dev->features |= NETIF_F_HIGHDMA;
10784 err = pci_set_consistent_dma_mask(pdev,
10785 persist_dma_mask);
10786 if (err < 0) {
10787 printk(KERN_ERR PFX "Unable to obtain 64 bit "
10788 "DMA for consistent allocations\n");
10789 goto err_out_iounmap;
10790 }
10791 }
10792 }
10793 if (err || dma_mask == DMA_32BIT_MASK) {
10794 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
10795 if (err) {
10796 printk(KERN_ERR PFX "No usable DMA configuration, "
10797 "aborting.\n");
10798 goto err_out_iounmap;
10799 }
10800 }
10801
10768 tg3_init_bufmgr_config(tp); 10802 tg3_init_bufmgr_config(tp);
10769 10803
10770#if TG3_TSO_SUPPORT != 0 10804#if TG3_TSO_SUPPORT != 0
@@ -10833,9 +10867,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10833 } else 10867 } else
10834 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS; 10868 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS;
10835 10869
10836 if (tp->tg3_flags2 & TG3_FLG2_IS_5788)
10837 dev->features &= ~NETIF_F_HIGHDMA;
10838
10839 /* flow control autonegotiation is default behavior */ 10870 /* flow control autonegotiation is default behavior */
10840 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; 10871 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG;
10841 10872
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 8bc0b528548f..f8f4503475f9 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -877,7 +877,6 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
877 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), 877 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),
878 PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), 878 PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),
879 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), 879 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
880 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
881 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), 880 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),
882 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b), 881 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b),
883 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), 882 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),
@@ -891,6 +890,10 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
891 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), 890 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
892 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), 891 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
893 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), 892 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
893 PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "INTERSIL",
894 0x74c5e40d),
895 PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "Intersil",
896 0x4b801a17),
894 PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", 897 PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",
895 0x7a954bd9, 0x74be00c6), 898 0x7a954bd9, 0x74be00c6),
896 PCMCIA_DEVICE_PROD_ID1234( 899 PCMCIA_DEVICE_PROD_ID1234(
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 166de3507780..10845253c9e0 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -312,8 +312,7 @@ static int __devinit parport_register (struct pci_dev *dev,
312{ 312{
313 struct parport_pc_pci *card; 313 struct parport_pc_pci *card;
314 struct parport_serial_private *priv = pci_get_drvdata (dev); 314 struct parport_serial_private *priv = pci_get_drvdata (dev);
315 int i = id->driver_data, n; 315 int n, success = 0;
316 int success = 0;
317 316
318 priv->par = cards[id->driver_data]; 317 priv->par = cards[id->driver_data];
319 card = &priv->par; 318 card = &priv->par;
@@ -344,10 +343,8 @@ static int __devinit parport_register (struct pci_dev *dev,
344 "hi" as an offset (see SYBA 343 "hi" as an offset (see SYBA
345 def.) */ 344 def.) */
346 /* TODO: test if sharing interrupts works */ 345 /* TODO: test if sharing interrupts works */
347 printk (KERN_DEBUG "PCI parallel port detected: %04x:%04x, " 346 dev_dbg(&dev->dev, "PCI parallel port detected: I/O at "
348 "I/O at %#lx(%#lx)\n", 347 "%#lx(%#lx)\n", io_lo, io_hi);
349 parport_serial_pci_tbl[i].vendor,
350 parport_serial_pci_tbl[i].device, io_lo, io_hi);
351 port = parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE, 348 port = parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE,
352 PARPORT_DMA_NONE, dev); 349 PARPORT_DMA_NONE, dev);
353 if (port) { 350 if (port) {
@@ -359,7 +356,7 @@ static int __devinit parport_register (struct pci_dev *dev,
359 if (card->postinit_hook) 356 if (card->postinit_hook)
360 card->postinit_hook (dev, card, !success); 357 card->postinit_hook (dev, card, !success);
361 358
362 return success ? 0 : 1; 359 return 0;
363} 360}
364 361
365static int __devinit parport_serial_pci_probe (struct pci_dev *dev, 362static int __devinit parport_serial_pci_probe (struct pci_dev *dev,
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 0a424a4e8187..bb96ce1db08c 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -352,11 +352,20 @@ static void pcmcia_release_dev(struct device *dev)
352 kfree(p_dev); 352 kfree(p_dev);
353} 353}
354 354
355static void pcmcia_add_pseudo_device(struct pcmcia_socket *s)
356{
357 if (!s->pcmcia_state.device_add_pending) {
358 s->pcmcia_state.device_add_pending = 1;
359 schedule_work(&s->device_add);
360 }
361 return;
362}
355 363
356static int pcmcia_device_probe(struct device * dev) 364static int pcmcia_device_probe(struct device * dev)
357{ 365{
358 struct pcmcia_device *p_dev; 366 struct pcmcia_device *p_dev;
359 struct pcmcia_driver *p_drv; 367 struct pcmcia_driver *p_drv;
368 struct pcmcia_device_id *did;
360 struct pcmcia_socket *s; 369 struct pcmcia_socket *s;
361 int ret = 0; 370 int ret = 0;
362 371
@@ -392,6 +401,19 @@ static int pcmcia_device_probe(struct device * dev)
392 } 401 }
393 402
394 ret = p_drv->probe(p_dev); 403 ret = p_drv->probe(p_dev);
404 if (ret)
405 goto put_module;
406
407 /* handle pseudo multifunction devices:
408 * there are at most two pseudo multifunction devices.
409 * if we're matching against the first, schedule a
410 * call which will then check whether there are two
411 * pseudo devices, and if not, add the second one.
412 */
413 did = (struct pcmcia_device_id *) p_dev->dev.driver_data;
414 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
415 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0))
416 pcmcia_add_pseudo_device(p_dev->socket);
395 417
396 put_module: 418 put_module:
397 if (ret) 419 if (ret)
@@ -660,15 +682,6 @@ static void pcmcia_delayed_add_pseudo_device(void *data)
660 s->pcmcia_state.device_add_pending = 0; 682 s->pcmcia_state.device_add_pending = 0;
661} 683}
662 684
663static inline void pcmcia_add_pseudo_device(struct pcmcia_socket *s)
664{
665 if (!s->pcmcia_state.device_add_pending) {
666 s->pcmcia_state.device_add_pending = 1;
667 schedule_work(&s->device_add);
668 }
669 return;
670}
671
672static int pcmcia_requery(struct device *dev, void * _data) 685static int pcmcia_requery(struct device *dev, void * _data)
673{ 686{
674 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 687 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
@@ -755,15 +768,6 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
755 } 768 }
756 769
757 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { 770 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) {
758 /* handle pseudo multifunction devices:
759 * there are at most two pseudo multifunction devices.
760 * if we're matching against the first, schedule a
761 * call which will then check whether there are two
762 * pseudo devices, and if not, add the second one.
763 */
764 if (dev->device_no == 0)
765 pcmcia_add_pseudo_device(dev->socket);
766
767 if (dev->device_no != did->device_no) 771 if (dev->device_no != did->device_no)
768 return 0; 772 return 0;
769 } 773 }
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index af1d5b404cee..33157c84d1d3 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -215,9 +215,10 @@ dasd_state_basic_to_known(struct dasd_device * device)
215 * interrupt for this detection ccw uses the kernel event daemon to 215 * interrupt for this detection ccw uses the kernel event daemon to
216 * trigger the call to dasd_change_state. All this is done in the 216 * trigger the call to dasd_change_state. All this is done in the
217 * discipline code, see dasd_eckd.c. 217 * discipline code, see dasd_eckd.c.
218 * After the analysis ccw is done (do_analysis returned 0 or error) 218 * After the analysis ccw is done (do_analysis returned 0) the block
219 * the block device is setup. Either a fake disk is added to allow 219 * device is setup.
220 * formatting or a proper device request queue is created. 220 * In case the analysis returns an error, the device setup is stopped
221 * (a fake disk was already added to allow formatting).
221 */ 222 */
222static inline int 223static inline int
223dasd_state_basic_to_ready(struct dasd_device * device) 224dasd_state_basic_to_ready(struct dasd_device * device)
@@ -227,13 +228,19 @@ dasd_state_basic_to_ready(struct dasd_device * device)
227 rc = 0; 228 rc = 0;
228 if (device->discipline->do_analysis != NULL) 229 if (device->discipline->do_analysis != NULL)
229 rc = device->discipline->do_analysis(device); 230 rc = device->discipline->do_analysis(device);
230 if (rc) 231 if (rc) {
232 if (rc != -EAGAIN)
233 device->state = DASD_STATE_UNFMT;
231 return rc; 234 return rc;
235 }
236 /* make disk known with correct capacity */
232 dasd_setup_queue(device); 237 dasd_setup_queue(device);
238 set_capacity(device->gdp, device->blocks << device->s2b_shift);
233 device->state = DASD_STATE_READY; 239 device->state = DASD_STATE_READY;
234 if (dasd_scan_partitions(device) != 0) 240 rc = dasd_scan_partitions(device);
241 if (rc)
235 device->state = DASD_STATE_BASIC; 242 device->state = DASD_STATE_BASIC;
236 return 0; 243 return rc;
237} 244}
238 245
239/* 246/*
@@ -254,6 +261,15 @@ dasd_state_ready_to_basic(struct dasd_device * device)
254} 261}
255 262
256/* 263/*
264 * Back to basic.
265 */
266static inline void
267dasd_state_unfmt_to_basic(struct dasd_device * device)
268{
269 device->state = DASD_STATE_BASIC;
270}
271
272/*
257 * Make the device online and schedule the bottom half to start 273 * Make the device online and schedule the bottom half to start
258 * the requeueing of requests from the linux request queue to the 274 * the requeueing of requests from the linux request queue to the
259 * ccw queue. 275 * ccw queue.
@@ -319,8 +335,12 @@ dasd_decrease_state(struct dasd_device *device)
319 if (device->state == DASD_STATE_READY && 335 if (device->state == DASD_STATE_READY &&
320 device->target <= DASD_STATE_BASIC) 336 device->target <= DASD_STATE_BASIC)
321 dasd_state_ready_to_basic(device); 337 dasd_state_ready_to_basic(device);
322 338
323 if (device->state == DASD_STATE_BASIC && 339 if (device->state == DASD_STATE_UNFMT &&
340 device->target <= DASD_STATE_BASIC)
341 dasd_state_unfmt_to_basic(device);
342
343 if (device->state == DASD_STATE_BASIC &&
324 device->target <= DASD_STATE_KNOWN) 344 device->target <= DASD_STATE_KNOWN)
325 dasd_state_basic_to_known(device); 345 dasd_state_basic_to_known(device);
326 346
@@ -1722,7 +1742,7 @@ dasd_open(struct inode *inp, struct file *filp)
1722 goto out; 1742 goto out;
1723 } 1743 }
1724 1744
1725 if (device->state < DASD_STATE_BASIC) { 1745 if (device->state <= DASD_STATE_BASIC) {
1726 DBF_DEV_EVENT(DBF_ERR, device, " %s", 1746 DBF_DEV_EVENT(DBF_ERR, device, " %s",
1727 " Cannot open unrecognized device"); 1747 " Cannot open unrecognized device");
1728 rc = -ENODEV; 1748 rc = -ENODEV;
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index 65dc844b975c..fce2835e7d19 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -100,8 +100,6 @@ dasd_scan_partitions(struct dasd_device * device)
100{ 100{
101 struct block_device *bdev; 101 struct block_device *bdev;
102 102
103 /* Make the disk known. */
104 set_capacity(device->gdp, device->blocks << device->s2b_shift);
105 bdev = bdget_disk(device->gdp, 0); 103 bdev = bdget_disk(device->gdp, 0);
106 if (!bdev || blkdev_get(bdev, FMODE_READ, 1) < 0) 104 if (!bdev || blkdev_get(bdev, FMODE_READ, 1) < 0)
107 return -ENODEV; 105 return -ENODEV;
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 0592354cc604..7cb0b9e78a6a 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -26,7 +26,7 @@
26 * new: the dasd_device structure is allocated. 26 * new: the dasd_device structure is allocated.
27 * known: the discipline for the device is identified. 27 * known: the discipline for the device is identified.
28 * basic: the device can do basic i/o. 28 * basic: the device can do basic i/o.
29 * accept: the device is analysed (format is known). 29 * unfmt: the device could not be analyzed (format is unknown).
30 * ready: partition detection is done and the device is can do block io. 30 * ready: partition detection is done and the device is can do block io.
31 * online: the device accepts requests from the block device queue. 31 * online: the device accepts requests from the block device queue.
32 * 32 *
@@ -47,8 +47,9 @@
47#define DASD_STATE_NEW 0 47#define DASD_STATE_NEW 0
48#define DASD_STATE_KNOWN 1 48#define DASD_STATE_KNOWN 1
49#define DASD_STATE_BASIC 2 49#define DASD_STATE_BASIC 2
50#define DASD_STATE_READY 3 50#define DASD_STATE_UNFMT 3
51#define DASD_STATE_ONLINE 4 51#define DASD_STATE_READY 4
52#define DASD_STATE_ONLINE 5
52 53
53#include <linux/module.h> 54#include <linux/module.h>
54#include <linux/wait.h> 55#include <linux/wait.h>
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 2d5da3c75ca7..1aa3c261718a 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -93,6 +93,9 @@ dasd_devices_show(struct seq_file *m, void *v)
93 case DASD_STATE_BASIC: 93 case DASD_STATE_BASIC:
94 seq_printf(m, "basic"); 94 seq_printf(m, "basic");
95 break; 95 break;
96 case DASD_STATE_UNFMT:
97 seq_printf(m, "unformatted");
98 break;
96 case DASD_STATE_READY: 99 case DASD_STATE_READY:
97 case DASD_STATE_ONLINE: 100 case DASD_STATE_ONLINE:
98 seq_printf(m, "active "); 101 seq_printf(m, "active ");
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 8cf9905d484b..f4183d660258 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -1115,6 +1115,9 @@ chsc_enable_facility(int operation_code)
1115 goto out; 1115 goto out;
1116 } 1116 }
1117 switch (sda_area->response.code) { 1117 switch (sda_area->response.code) {
1118 case 0x0001: /* everything ok */
1119 ret = 0;
1120 break;
1118 case 0x0003: /* invalid request block */ 1121 case 0x0003: /* invalid request block */
1119 case 0x0007: 1122 case 0x0007:
1120 ret = -EINVAL; 1123 ret = -EINVAL;
@@ -1123,6 +1126,8 @@ chsc_enable_facility(int operation_code)
1123 case 0x0101: /* facility not provided */ 1126 case 0x0101: /* facility not provided */
1124 ret = -EOPNOTSUPP; 1127 ret = -EOPNOTSUPP;
1125 break; 1128 break;
1129 default: /* something went wrong */
1130 ret = -EIO;
1126 } 1131 }
1127 out: 1132 out:
1128 free_page((unsigned long)sda_area); 1133 free_page((unsigned long)sda_area);
diff --git a/drivers/s390/net/smsgiucv.c b/drivers/s390/net/smsgiucv.c
index d6469baa7e16..72118ee68954 100644
--- a/drivers/s390/net/smsgiucv.c
+++ b/drivers/s390/net/smsgiucv.c
@@ -168,7 +168,7 @@ smsg_init(void)
168 driver_unregister(&smsg_driver); 168 driver_unregister(&smsg_driver);
169 return -EIO; /* better errno ? */ 169 return -EIO; /* better errno ? */
170 } 170 }
171 rc = iucv_connect (&smsg_pathid, 1, 0, "*MSG ", 0, 0, 0, 0, 171 rc = iucv_connect (&smsg_pathid, 255, 0, "*MSG ", 0, 0, 0, 0,
172 smsg_handle, 0); 172 smsg_handle, 0);
173 if (rc) { 173 if (rc) {
174 printk(KERN_ERR "SMSGIUCV: failed to connect to *MSG"); 174 printk(KERN_ERR "SMSGIUCV: failed to connect to *MSG");
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 1c2ab3dede71..00dfdefe2967 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -778,23 +778,17 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
778 struct ata_queued_cmd *qc; 778 struct ata_queued_cmd *qc;
779 qc = ata_qc_from_tag(ap, ap->active_tag); 779 qc = ata_qc_from_tag(ap, ap->active_tag);
780 if (!ahci_host_intr(ap, qc)) 780 if (!ahci_host_intr(ap, qc))
781 if (ata_ratelimit()) { 781 if (ata_ratelimit())
782 struct pci_dev *pdev = 782 dev_printk(KERN_WARNING, host_set->dev,
783 to_pci_dev(ap->host_set->dev);
784 dev_printk(KERN_WARNING, &pdev->dev,
785 "unhandled interrupt on port %u\n", 783 "unhandled interrupt on port %u\n",
786 i); 784 i);
787 }
788 785
789 VPRINTK("port %u\n", i); 786 VPRINTK("port %u\n", i);
790 } else { 787 } else {
791 VPRINTK("port %u (no irq)\n", i); 788 VPRINTK("port %u (no irq)\n", i);
792 if (ata_ratelimit()) { 789 if (ata_ratelimit())
793 struct pci_dev *pdev = 790 dev_printk(KERN_WARNING, host_set->dev,
794 to_pci_dev(ap->host_set->dev);
795 dev_printk(KERN_WARNING, &pdev->dev,
796 "interrupt on disabled port %u\n", i); 791 "interrupt on disabled port %u\n", i);
797 }
798 } 792 }
799 793
800 irq_ack |= (1 << i); 794 irq_ack |= (1 << i);
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index c662bf531514..9327b62f97de 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -101,6 +101,8 @@ enum {
101 ICH5_PCS = 0x92, /* port control and status */ 101 ICH5_PCS = 0x92, /* port control and status */
102 PIIX_SCC = 0x0A, /* sub-class code register */ 102 PIIX_SCC = 0x0A, /* sub-class code register */
103 103
104 PIIX_FLAG_IGNORE_PCS = (1 << 25), /* ignore PCS present bits */
105 PIIX_FLAG_SCR = (1 << 26), /* SCR available */
104 PIIX_FLAG_AHCI = (1 << 27), /* AHCI possible */ 106 PIIX_FLAG_AHCI = (1 << 27), /* AHCI possible */
105 PIIX_FLAG_CHECKINTR = (1 << 28), /* make sure PCI INTx enabled */ 107 PIIX_FLAG_CHECKINTR = (1 << 28), /* make sure PCI INTx enabled */
106 PIIX_FLAG_COMBINED = (1 << 29), /* combined mode possible */ 108 PIIX_FLAG_COMBINED = (1 << 29), /* combined mode possible */
@@ -110,24 +112,38 @@ enum {
110 /* combined mode. if set, PATA is channel 0. 112 /* combined mode. if set, PATA is channel 0.
111 * if clear, PATA is channel 1. 113 * if clear, PATA is channel 1.
112 */ 114 */
113 PIIX_COMB_PATA_P0 = (1 << 1),
114 PIIX_COMB = (1 << 2), /* combined mode enabled? */
115
116 PIIX_PORT_ENABLED = (1 << 0), 115 PIIX_PORT_ENABLED = (1 << 0),
117 PIIX_PORT_PRESENT = (1 << 4), 116 PIIX_PORT_PRESENT = (1 << 4),
118 117
119 PIIX_80C_PRI = (1 << 5) | (1 << 4), 118 PIIX_80C_PRI = (1 << 5) | (1 << 4),
120 PIIX_80C_SEC = (1 << 7) | (1 << 6), 119 PIIX_80C_SEC = (1 << 7) | (1 << 6),
121 120
122 ich5_pata = 0, 121 /* controller IDs */
123 ich5_sata = 1, 122 piix4_pata = 0,
124 piix4_pata = 2, 123 ich5_pata = 1,
125 ich6_sata = 3, 124 ich5_sata = 2,
126 ich6_sata_ahci = 4, 125 esb_sata = 3,
126 ich6_sata = 4,
127 ich6_sata_ahci = 5,
128 ich6m_sata_ahci = 6,
129
130 /* constants for mapping table */
131 P0 = 0, /* port 0 */
132 P1 = 1, /* port 1 */
133 P2 = 2, /* port 2 */
134 P3 = 3, /* port 3 */
135 IDE = -1, /* IDE */
136 NA = -2, /* not avaliable */
137 RV = -3, /* reserved */
127 138
128 PIIX_AHCI_DEVICE = 6, 139 PIIX_AHCI_DEVICE = 6,
129}; 140};
130 141
142struct piix_map_db {
143 const u32 mask;
144 const int map[][4];
145};
146
131static int piix_init_one (struct pci_dev *pdev, 147static int piix_init_one (struct pci_dev *pdev,
132 const struct pci_device_id *ent); 148 const struct pci_device_id *ent);
133 149
@@ -149,19 +165,32 @@ static const struct pci_device_id piix_pci_tbl[] = {
149 * list in drivers/pci/quirks.c. 165 * list in drivers/pci/quirks.c.
150 */ 166 */
151 167
168 /* 82801EB (ICH5) */
152 { 0x8086, 0x24d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 169 { 0x8086, 0x24d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
170 /* 82801EB (ICH5) */
153 { 0x8086, 0x24df, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 171 { 0x8086, 0x24df, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
154 { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 172 /* 6300ESB (ICH5 variant with broken PCS present bits) */
155 { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 173 { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb_sata },
174 /* 6300ESB pretending RAID */
175 { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb_sata },
176 /* 82801FB/FW (ICH6/ICH6W) */
156 { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata }, 177 { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata },
178 /* 82801FR/FRW (ICH6R/ICH6RW) */
157 { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 179 { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
158 { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 180 /* 82801FBM ICH6M (ICH6R with only port 0 and 2 implemented) */
181 { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
182 /* 82801GB/GR/GH (ICH7, identical to ICH6) */
159 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 183 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
160 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 184 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */
185 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
186 /* Enterprise Southbridge 2 (where's the datasheet?) */
161 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 187 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
188 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */
162 { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 189 { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
190 /* SATA Controller 2 IDE (ICH8, ditto) */
163 { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 191 { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
164 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 192 /* Mobile SATA Controller IDE (ICH8M, ditto) */
193 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
165 194
166 { } /* terminate list */ 195 { } /* terminate list */
167}; 196};
@@ -254,7 +283,58 @@ static const struct ata_port_operations piix_sata_ops = {
254 .host_stop = ata_host_stop, 283 .host_stop = ata_host_stop,
255}; 284};
256 285
286static struct piix_map_db ich5_map_db = {
287 .mask = 0x7,
288 .map = {
289 /* PM PS SM SS MAP */
290 { P0, NA, P1, NA }, /* 000b */
291 { P1, NA, P0, NA }, /* 001b */
292 { RV, RV, RV, RV },
293 { RV, RV, RV, RV },
294 { P0, P1, IDE, IDE }, /* 100b */
295 { P1, P0, IDE, IDE }, /* 101b */
296 { IDE, IDE, P0, P1 }, /* 110b */
297 { IDE, IDE, P1, P0 }, /* 111b */
298 },
299};
300
301static struct piix_map_db ich6_map_db = {
302 .mask = 0x3,
303 .map = {
304 /* PM PS SM SS MAP */
305 { P0, P1, P2, P3 }, /* 00b */
306 { IDE, IDE, P1, P3 }, /* 01b */
307 { P0, P2, IDE, IDE }, /* 10b */
308 { RV, RV, RV, RV },
309 },
310};
311
312static struct piix_map_db ich6m_map_db = {
313 .mask = 0x3,
314 .map = {
315 /* PM PS SM SS MAP */
316 { P0, P1, P2, P3 }, /* 00b */
317 { RV, RV, RV, RV },
318 { P0, P2, IDE, IDE }, /* 10b */
319 { RV, RV, RV, RV },
320 },
321};
322
257static struct ata_port_info piix_port_info[] = { 323static struct ata_port_info piix_port_info[] = {
324 /* piix4_pata */
325 {
326 .sht = &piix_sht,
327 .host_flags = ATA_FLAG_SLAVE_POSS,
328 .pio_mask = 0x1f, /* pio0-4 */
329#if 0
330 .mwdma_mask = 0x06, /* mwdma1-2 */
331#else
332 .mwdma_mask = 0x00, /* mwdma broken */
333#endif
334 .udma_mask = ATA_UDMA_MASK_40C,
335 .port_ops = &piix_pata_ops,
336 },
337
258 /* ich5_pata */ 338 /* ich5_pata */
259 { 339 {
260 .sht = &piix_sht, 340 .sht = &piix_sht,
@@ -278,43 +358,57 @@ static struct ata_port_info piix_port_info[] = {
278 .mwdma_mask = 0x07, /* mwdma0-2 */ 358 .mwdma_mask = 0x07, /* mwdma0-2 */
279 .udma_mask = 0x7f, /* udma0-6 */ 359 .udma_mask = 0x7f, /* udma0-6 */
280 .port_ops = &piix_sata_ops, 360 .port_ops = &piix_sata_ops,
361 .private_data = &ich5_map_db,
281 }, 362 },
282 363
283 /* piix4_pata */ 364 /* i6300esb_sata */
284 { 365 {
285 .sht = &piix_sht, 366 .sht = &piix_sht,
286 .host_flags = ATA_FLAG_SLAVE_POSS, 367 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED |
368 PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGNORE_PCS,
287 .pio_mask = 0x1f, /* pio0-4 */ 369 .pio_mask = 0x1f, /* pio0-4 */
288#if 0 370 .mwdma_mask = 0x07, /* mwdma0-2 */
289 .mwdma_mask = 0x06, /* mwdma1-2 */ 371 .udma_mask = 0x7f, /* udma0-6 */
290#else 372 .port_ops = &piix_sata_ops,
291 .mwdma_mask = 0x00, /* mwdma broken */ 373 .private_data = &ich5_map_db,
292#endif
293 .udma_mask = ATA_UDMA_MASK_40C,
294 .port_ops = &piix_pata_ops,
295 }, 374 },
296 375
297 /* ich6_sata */ 376 /* ich6_sata */
298 { 377 {
299 .sht = &piix_sht, 378 .sht = &piix_sht,
300 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED_ICH6 | 379 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED_ICH6 |
301 PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS, 380 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR,
302 .pio_mask = 0x1f, /* pio0-4 */ 381 .pio_mask = 0x1f, /* pio0-4 */
303 .mwdma_mask = 0x07, /* mwdma0-2 */ 382 .mwdma_mask = 0x07, /* mwdma0-2 */
304 .udma_mask = 0x7f, /* udma0-6 */ 383 .udma_mask = 0x7f, /* udma0-6 */
305 .port_ops = &piix_sata_ops, 384 .port_ops = &piix_sata_ops,
385 .private_data = &ich6_map_db,
306 }, 386 },
307 387
308 /* ich6_sata_ahci */ 388 /* ich6_sata_ahci */
309 { 389 {
310 .sht = &piix_sht, 390 .sht = &piix_sht,
311 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED_ICH6 | 391 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED_ICH6 |
312 PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS | 392 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
313 PIIX_FLAG_AHCI, 393 PIIX_FLAG_AHCI,
314 .pio_mask = 0x1f, /* pio0-4 */ 394 .pio_mask = 0x1f, /* pio0-4 */
315 .mwdma_mask = 0x07, /* mwdma0-2 */ 395 .mwdma_mask = 0x07, /* mwdma0-2 */
316 .udma_mask = 0x7f, /* udma0-6 */ 396 .udma_mask = 0x7f, /* udma0-6 */
317 .port_ops = &piix_sata_ops, 397 .port_ops = &piix_sata_ops,
398 .private_data = &ich6_map_db,
399 },
400
401 /* ich6m_sata_ahci */
402 {
403 .sht = &piix_sht,
404 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED_ICH6 |
405 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
406 PIIX_FLAG_AHCI,
407 .pio_mask = 0x1f, /* pio0-4 */
408 .mwdma_mask = 0x07, /* mwdma0-2 */
409 .udma_mask = 0x7f, /* udma0-6 */
410 .port_ops = &piix_sata_ops,
411 .private_data = &ich6m_map_db,
318 }, 412 },
319}; 413};
320 414
@@ -405,44 +499,59 @@ static int piix_pata_probe_reset(struct ata_port *ap, unsigned int *classes)
405 * piix_sata_probe - Probe PCI device for present SATA devices 499 * piix_sata_probe - Probe PCI device for present SATA devices
406 * @ap: Port associated with the PCI device we wish to probe 500 * @ap: Port associated with the PCI device we wish to probe
407 * 501 *
408 * Reads SATA PCI device's PCI config register Port Configuration 502 * Reads and configures SATA PCI device's PCI config register
409 * and Status (PCS) to determine port and device availability. 503 * Port Configuration and Status (PCS) to determine port and
504 * device availability.
410 * 505 *
411 * LOCKING: 506 * LOCKING:
412 * None (inherited from caller). 507 * None (inherited from caller).
413 * 508 *
414 * RETURNS: 509 * RETURNS:
415 * Non-zero if port is enabled, it may or may not have a device 510 * Mask of avaliable devices on the port.
416 * attached in that case (PRESENT bit would only be set if BIOS probe
417 * was done). Zero is returned if port is disabled.
418 */ 511 */
419static int piix_sata_probe (struct ata_port *ap) 512static unsigned int piix_sata_probe (struct ata_port *ap)
420{ 513{
421 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 514 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
422 int combined = (ap->flags & ATA_FLAG_SLAVE_POSS); 515 const unsigned int *map = ap->host_set->private_data;
423 int orig_mask, mask, i; 516 int base = 2 * ap->hard_port_no;
517 unsigned int present_mask = 0;
518 int port, i;
424 u8 pcs; 519 u8 pcs;
425 520
426 pci_read_config_byte(pdev, ICH5_PCS, &pcs); 521 pci_read_config_byte(pdev, ICH5_PCS, &pcs);
427 orig_mask = (int) pcs & 0xff; 522 DPRINTK("ata%u: ENTER, pcs=0x%x base=%d\n", ap->id, pcs, base);
428
429 /* TODO: this is vaguely wrong for ICH6 combined mode,
430 * where only two of the four SATA ports are mapped
431 * onto a single ATA channel. It is also vaguely inaccurate
432 * for ICH5, which has only two ports. However, this is ok,
433 * as further device presence detection code will handle
434 * any false positives produced here.
435 */
436 523
437 for (i = 0; i < 4; i++) { 524 /* enable all ports on this ap and wait for them to settle */
438 mask = (PIIX_PORT_ENABLED << i); 525 for (i = 0; i < 2; i++) {
526 port = map[base + i];
527 if (port >= 0)
528 pcs |= 1 << port;
529 }
439 530
440 if ((orig_mask & mask) == mask) 531 pci_write_config_byte(pdev, ICH5_PCS, pcs);
441 if (combined || (i == ap->hard_port_no)) 532 msleep(100);
442 return 1; 533
534 /* let's see which devices are present */
535 pci_read_config_byte(pdev, ICH5_PCS, &pcs);
536
537 for (i = 0; i < 2; i++) {
538 port = map[base + i];
539 if (port < 0)
540 continue;
541 if (ap->flags & PIIX_FLAG_IGNORE_PCS || pcs & 1 << (4 + port))
542 present_mask |= 1 << i;
543 else
544 pcs &= ~(1 << port);
443 } 545 }
444 546
445 return 0; 547 /* disable offline ports on non-AHCI controllers */
548 if (!(ap->flags & PIIX_FLAG_AHCI))
549 pci_write_config_byte(pdev, ICH5_PCS, pcs);
550
551 DPRINTK("ata%u: LEAVE, pcs=0x%x present_mask=0x%x\n",
552 ap->id, pcs, present_mask);
553
554 return present_mask;
446} 555}
447 556
448/** 557/**
@@ -666,6 +775,54 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
666 return no_piix_dma; 775 return no_piix_dma;
667} 776}
668 777
778static void __devinit piix_init_sata_map(struct pci_dev *pdev,
779 struct ata_port_info *pinfo)
780{
781 struct piix_map_db *map_db = pinfo[0].private_data;
782 const unsigned int *map;
783 int i, invalid_map = 0;
784 u8 map_value;
785
786 pci_read_config_byte(pdev, ICH5_PMR, &map_value);
787
788 map = map_db->map[map_value & map_db->mask];
789
790 dev_printk(KERN_INFO, &pdev->dev, "MAP [");
791 for (i = 0; i < 4; i++) {
792 switch (map[i]) {
793 case RV:
794 invalid_map = 1;
795 printk(" XX");
796 break;
797
798 case NA:
799 printk(" --");
800 break;
801
802 case IDE:
803 WARN_ON((i & 1) || map[i + 1] != IDE);
804 pinfo[i / 2] = piix_port_info[ich5_pata];
805 i++;
806 printk(" IDE IDE");
807 break;
808
809 default:
810 printk(" P%d", map[i]);
811 if (i & 1)
812 pinfo[i / 2].host_flags |= ATA_FLAG_SLAVE_POSS;
813 break;
814 }
815 }
816 printk(" ]\n");
817
818 if (invalid_map)
819 dev_printk(KERN_ERR, &pdev->dev,
820 "invalid MAP value %u\n", map_value);
821
822 pinfo[0].private_data = (void *)map;
823 pinfo[1].private_data = (void *)map;
824}
825
669/** 826/**
670 * piix_init_one - Register PIIX ATA PCI device with kernel services 827 * piix_init_one - Register PIIX ATA PCI device with kernel services
671 * @pdev: PCI device to register 828 * @pdev: PCI device to register
@@ -684,9 +841,8 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
684static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 841static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
685{ 842{
686 static int printed_version; 843 static int printed_version;
687 struct ata_port_info *port_info[2]; 844 struct ata_port_info port_info[2];
688 unsigned int combined = 0; 845 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
689 unsigned int pata_chan = 0, sata_chan = 0;
690 unsigned long host_flags; 846 unsigned long host_flags;
691 847
692 if (!printed_version++) 848 if (!printed_version++)
@@ -697,10 +853,10 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
697 if (!in_module_init) 853 if (!in_module_init)
698 return -ENODEV; 854 return -ENODEV;
699 855
700 port_info[0] = &piix_port_info[ent->driver_data]; 856 port_info[0] = piix_port_info[ent->driver_data];
701 port_info[1] = &piix_port_info[ent->driver_data]; 857 port_info[1] = piix_port_info[ent->driver_data];
702 858
703 host_flags = port_info[0]->host_flags; 859 host_flags = port_info[0].host_flags;
704 860
705 if (host_flags & PIIX_FLAG_AHCI) { 861 if (host_flags & PIIX_FLAG_AHCI) {
706 u8 tmp; 862 u8 tmp;
@@ -712,37 +868,9 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
712 } 868 }
713 } 869 }
714 870
715 if (host_flags & PIIX_FLAG_COMBINED) { 871 /* Initialize SATA map */
716 u8 tmp; 872 if (host_flags & ATA_FLAG_SATA)
717 pci_read_config_byte(pdev, ICH5_PMR, &tmp); 873 piix_init_sata_map(pdev, port_info);
718
719 if (host_flags & PIIX_FLAG_COMBINED_ICH6) {
720 switch (tmp & 0x3) {
721 case 0:
722 break;
723 case 1:
724 combined = 1;
725 sata_chan = 1;
726 break;
727 case 2:
728 combined = 1;
729 pata_chan = 1;
730 break;
731 case 3:
732 dev_printk(KERN_WARNING, &pdev->dev,
733 "invalid MAP value %u\n", tmp);
734 break;
735 }
736 } else {
737 if (tmp & PIIX_COMB) {
738 combined = 1;
739 if (tmp & PIIX_COMB_PATA_P0)
740 sata_chan = 1;
741 else
742 pata_chan = 1;
743 }
744 }
745 }
746 874
747 /* On ICH5, some BIOSen disable the interrupt using the 875 /* On ICH5, some BIOSen disable the interrupt using the
748 * PCI_COMMAND_INTX_DISABLE bit added in PCI 2.3. 876 * PCI_COMMAND_INTX_DISABLE bit added in PCI 2.3.
@@ -753,25 +881,16 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
753 if (host_flags & PIIX_FLAG_CHECKINTR) 881 if (host_flags & PIIX_FLAG_CHECKINTR)
754 pci_intx(pdev, 1); 882 pci_intx(pdev, 1);
755 883
756 if (combined) {
757 port_info[sata_chan] = &piix_port_info[ent->driver_data];
758 port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS;
759 port_info[pata_chan] = &piix_port_info[ich5_pata];
760
761 dev_printk(KERN_WARNING, &pdev->dev,
762 "combined mode detected (p=%u, s=%u)\n",
763 pata_chan, sata_chan);
764 }
765 if (piix_check_450nx_errata(pdev)) { 884 if (piix_check_450nx_errata(pdev)) {
766 /* This writes into the master table but it does not 885 /* This writes into the master table but it does not
767 really matter for this errata as we will apply it to 886 really matter for this errata as we will apply it to
768 all the PIIX devices on the board */ 887 all the PIIX devices on the board */
769 port_info[0]->mwdma_mask = 0; 888 port_info[0].mwdma_mask = 0;
770 port_info[0]->udma_mask = 0; 889 port_info[0].udma_mask = 0;
771 port_info[1]->mwdma_mask = 0; 890 port_info[1].mwdma_mask = 0;
772 port_info[1]->udma_mask = 0; 891 port_info[1].udma_mask = 0;
773 } 892 }
774 return ata_pci_init_one(pdev, port_info, 2); 893 return ata_pci_init_one(pdev, ppinfo, 2);
775} 894}
776 895
777static int __init piix_init(void) 896static int __init piix_init(void)
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 9132698d29b8..5060a1a1ad25 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -65,12 +65,9 @@ static unsigned int ata_dev_init_params(struct ata_port *ap,
65 struct ata_device *dev); 65 struct ata_device *dev);
66static void ata_set_mode(struct ata_port *ap); 66static void ata_set_mode(struct ata_port *ap);
67static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev); 67static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
68static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift);
69static int fgb(u32 bitmap);
70static int ata_choose_xfer_mode(const struct ata_port *ap,
71 u8 *xfer_mode_out,
72 unsigned int *xfer_shift_out);
73static void ata_pio_error(struct ata_port *ap); 68static void ata_pio_error(struct ata_port *ap);
69static unsigned int ata_dev_xfermask(struct ata_port *ap,
70 struct ata_device *dev);
74 71
75static unsigned int ata_unique_id = 1; 72static unsigned int ata_unique_id = 1;
76static struct workqueue_struct *ata_wq; 73static struct workqueue_struct *ata_wq;
@@ -232,58 +229,148 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
232 return -1; 229 return -1;
233} 230}
234 231
235static const char * const xfer_mode_str[] = { 232/**
236 "UDMA/16", 233 * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask
237 "UDMA/25", 234 * @pio_mask: pio_mask
238 "UDMA/33", 235 * @mwdma_mask: mwdma_mask
239 "UDMA/44", 236 * @udma_mask: udma_mask
240 "UDMA/66", 237 *
241 "UDMA/100", 238 * Pack @pio_mask, @mwdma_mask and @udma_mask into a single
242 "UDMA/133", 239 * unsigned int xfer_mask.
243 "UDMA7", 240 *
244 "MWDMA0", 241 * LOCKING:
245 "MWDMA1", 242 * None.
246 "MWDMA2", 243 *
247 "PIO0", 244 * RETURNS:
248 "PIO1", 245 * Packed xfer_mask.
249 "PIO2", 246 */
250 "PIO3", 247static unsigned int ata_pack_xfermask(unsigned int pio_mask,
251 "PIO4", 248 unsigned int mwdma_mask,
249 unsigned int udma_mask)
250{
251 return ((pio_mask << ATA_SHIFT_PIO) & ATA_MASK_PIO) |
252 ((mwdma_mask << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA) |
253 ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA);
254}
255
256static const struct ata_xfer_ent {
257 unsigned int shift, bits;
258 u8 base;
259} ata_xfer_tbl[] = {
260 { ATA_SHIFT_PIO, ATA_BITS_PIO, XFER_PIO_0 },
261 { ATA_SHIFT_MWDMA, ATA_BITS_MWDMA, XFER_MW_DMA_0 },
262 { ATA_SHIFT_UDMA, ATA_BITS_UDMA, XFER_UDMA_0 },
263 { -1, },
252}; 264};
253 265
254/** 266/**
255 * ata_udma_string - convert UDMA bit offset to string 267 * ata_xfer_mask2mode - Find matching XFER_* for the given xfer_mask
256 * @mask: mask of bits supported; only highest bit counts. 268 * @xfer_mask: xfer_mask of interest
257 * 269 *
258 * Determine string which represents the highest speed 270 * Return matching XFER_* value for @xfer_mask. Only the highest
259 * (highest bit in @udma_mask). 271 * bit of @xfer_mask is considered.
260 * 272 *
261 * LOCKING: 273 * LOCKING:
262 * None. 274 * None.
263 * 275 *
264 * RETURNS: 276 * RETURNS:
265 * Constant C string representing highest speed listed in 277 * Matching XFER_* value, 0 if no match found.
266 * @udma_mask, or the constant C string "<n/a>".
267 */ 278 */
279static u8 ata_xfer_mask2mode(unsigned int xfer_mask)
280{
281 int highbit = fls(xfer_mask) - 1;
282 const struct ata_xfer_ent *ent;
268 283
269static const char *ata_mode_string(unsigned int mask) 284 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
285 if (highbit >= ent->shift && highbit < ent->shift + ent->bits)
286 return ent->base + highbit - ent->shift;
287 return 0;
288}
289
290/**
291 * ata_xfer_mode2mask - Find matching xfer_mask for XFER_*
292 * @xfer_mode: XFER_* of interest
293 *
294 * Return matching xfer_mask for @xfer_mode.
295 *
296 * LOCKING:
297 * None.
298 *
299 * RETURNS:
300 * Matching xfer_mask, 0 if no match found.
301 */
302static unsigned int ata_xfer_mode2mask(u8 xfer_mode)
270{ 303{
271 int i; 304 const struct ata_xfer_ent *ent;
272 305
273 for (i = 7; i >= 0; i--) 306 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
274 if (mask & (1 << i)) 307 if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits)
275 goto out; 308 return 1 << (ent->shift + xfer_mode - ent->base);
276 for (i = ATA_SHIFT_MWDMA + 2; i >= ATA_SHIFT_MWDMA; i--) 309 return 0;
277 if (mask & (1 << i)) 310}
278 goto out;
279 for (i = ATA_SHIFT_PIO + 4; i >= ATA_SHIFT_PIO; i--)
280 if (mask & (1 << i))
281 goto out;
282 311
283 return "<n/a>"; 312/**
313 * ata_xfer_mode2shift - Find matching xfer_shift for XFER_*
314 * @xfer_mode: XFER_* of interest
315 *
316 * Return matching xfer_shift for @xfer_mode.
317 *
318 * LOCKING:
319 * None.
320 *
321 * RETURNS:
322 * Matching xfer_shift, -1 if no match found.
323 */
324static int ata_xfer_mode2shift(unsigned int xfer_mode)
325{
326 const struct ata_xfer_ent *ent;
284 327
285out: 328 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
286 return xfer_mode_str[i]; 329 if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits)
330 return ent->shift;
331 return -1;
332}
333
334/**
335 * ata_mode_string - convert xfer_mask to string
336 * @xfer_mask: mask of bits supported; only highest bit counts.
337 *
338 * Determine string which represents the highest speed
339 * (highest bit in @modemask).
340 *
341 * LOCKING:
342 * None.
343 *
344 * RETURNS:
345 * Constant C string representing highest speed listed in
346 * @mode_mask, or the constant C string "<n/a>".
347 */
348static const char *ata_mode_string(unsigned int xfer_mask)
349{
350 static const char * const xfer_mode_str[] = {
351 "PIO0",
352 "PIO1",
353 "PIO2",
354 "PIO3",
355 "PIO4",
356 "MWDMA0",
357 "MWDMA1",
358 "MWDMA2",
359 "UDMA/16",
360 "UDMA/25",
361 "UDMA/33",
362 "UDMA/44",
363 "UDMA/66",
364 "UDMA/100",
365 "UDMA/133",
366 "UDMA7",
367 };
368 int highbit;
369
370 highbit = fls(xfer_mask) - 1;
371 if (highbit >= 0 && highbit < ARRAY_SIZE(xfer_mode_str))
372 return xfer_mode_str[highbit];
373 return "<n/a>";
287} 374}
288 375
289/** 376/**
@@ -693,69 +780,104 @@ static inline void ata_dump_id(const u16 *id)
693 id[93]); 780 id[93]);
694} 781}
695 782
696/* 783/**
697 * Compute the PIO modes available for this device. This is not as 784 * ata_id_xfermask - Compute xfermask from the given IDENTIFY data
698 * trivial as it seems if we must consider early devices correctly. 785 * @id: IDENTIFY data to compute xfer mask from
699 * 786 *
700 * FIXME: pre IDE drive timing (do we care ?). 787 * Compute the xfermask for this device. This is not as trivial
788 * as it seems if we must consider early devices correctly.
789 *
790 * FIXME: pre IDE drive timing (do we care ?).
791 *
792 * LOCKING:
793 * None.
794 *
795 * RETURNS:
796 * Computed xfermask
701 */ 797 */
702 798static unsigned int ata_id_xfermask(const u16 *id)
703static unsigned int ata_pio_modes(const struct ata_device *adev)
704{ 799{
705 u16 modes; 800 unsigned int pio_mask, mwdma_mask, udma_mask;
706 801
707 /* Usual case. Word 53 indicates word 64 is valid */ 802 /* Usual case. Word 53 indicates word 64 is valid */
708 if (adev->id[ATA_ID_FIELD_VALID] & (1 << 1)) { 803 if (id[ATA_ID_FIELD_VALID] & (1 << 1)) {
709 modes = adev->id[ATA_ID_PIO_MODES] & 0x03; 804 pio_mask = id[ATA_ID_PIO_MODES] & 0x03;
710 modes <<= 3; 805 pio_mask <<= 3;
711 modes |= 0x7; 806 pio_mask |= 0x7;
712 return modes; 807 } else {
808 /* If word 64 isn't valid then Word 51 high byte holds
809 * the PIO timing number for the maximum. Turn it into
810 * a mask.
811 */
812 pio_mask = (2 << (id[ATA_ID_OLD_PIO_MODES] & 0xFF)) - 1 ;
813
814 /* But wait.. there's more. Design your standards by
815 * committee and you too can get a free iordy field to
816 * process. However its the speeds not the modes that
817 * are supported... Note drivers using the timing API
818 * will get this right anyway
819 */
713 } 820 }
714 821
715 /* If word 64 isn't valid then Word 51 high byte holds the PIO timing 822 mwdma_mask = id[ATA_ID_MWDMA_MODES] & 0x07;
716 number for the maximum. Turn it into a mask and return it */ 823 udma_mask = id[ATA_ID_UDMA_MODES] & 0xff;
717 modes = (2 << ((adev->id[ATA_ID_OLD_PIO_MODES] >> 8) & 0xFF)) - 1 ;
718 return modes;
719 /* But wait.. there's more. Design your standards by committee and
720 you too can get a free iordy field to process. However its the
721 speeds not the modes that are supported... Note drivers using the
722 timing API will get this right anyway */
723}
724 824
725static inline void 825 return ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask);
726ata_queue_pio_task(struct ata_port *ap)
727{
728 if (!(ap->flags & ATA_FLAG_FLUSH_PIO_TASK))
729 queue_work(ata_wq, &ap->pio_task);
730} 826}
731 827
732static inline void 828/**
733ata_queue_delayed_pio_task(struct ata_port *ap, unsigned long delay) 829 * ata_port_queue_task - Queue port_task
830 * @ap: The ata_port to queue port_task for
831 *
832 * Schedule @fn(@data) for execution after @delay jiffies using
833 * port_task. There is one port_task per port and it's the
834 * user(low level driver)'s responsibility to make sure that only
835 * one task is active at any given time.
836 *
837 * libata core layer takes care of synchronization between
838 * port_task and EH. ata_port_queue_task() may be ignored for EH
839 * synchronization.
840 *
841 * LOCKING:
842 * Inherited from caller.
843 */
844void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data,
845 unsigned long delay)
734{ 846{
735 if (!(ap->flags & ATA_FLAG_FLUSH_PIO_TASK)) 847 int rc;
736 queue_delayed_work(ata_wq, &ap->pio_task, delay); 848
849 if (ap->flags & ATA_FLAG_FLUSH_PORT_TASK)
850 return;
851
852 PREPARE_WORK(&ap->port_task, fn, data);
853
854 if (!delay)
855 rc = queue_work(ata_wq, &ap->port_task);
856 else
857 rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
858
859 /* rc == 0 means that another user is using port task */
860 WARN_ON(rc == 0);
737} 861}
738 862
739/** 863/**
740 * ata_flush_pio_tasks - Flush pio_task 864 * ata_port_flush_task - Flush port_task
741 * @ap: the target ata_port 865 * @ap: The ata_port to flush port_task for
742 * 866 *
743 * After this function completes, pio_task is 867 * After this function completes, port_task is guranteed not to
744 * guranteed not to be running or scheduled. 868 * be running or scheduled.
745 * 869 *
746 * LOCKING: 870 * LOCKING:
747 * Kernel thread context (may sleep) 871 * Kernel thread context (may sleep)
748 */ 872 */
749 873void ata_port_flush_task(struct ata_port *ap)
750static void ata_flush_pio_tasks(struct ata_port *ap)
751{ 874{
752 int tmp = 0;
753 unsigned long flags; 875 unsigned long flags;
754 876
755 DPRINTK("ENTER\n"); 877 DPRINTK("ENTER\n");
756 878
757 spin_lock_irqsave(&ap->host_set->lock, flags); 879 spin_lock_irqsave(&ap->host_set->lock, flags);
758 ap->flags |= ATA_FLAG_FLUSH_PIO_TASK; 880 ap->flags |= ATA_FLAG_FLUSH_PORT_TASK;
759 spin_unlock_irqrestore(&ap->host_set->lock, flags); 881 spin_unlock_irqrestore(&ap->host_set->lock, flags);
760 882
761 DPRINTK("flush #1\n"); 883 DPRINTK("flush #1\n");
@@ -766,14 +888,13 @@ static void ata_flush_pio_tasks(struct ata_port *ap)
766 * the FLUSH flag; thus, it will never queue pio tasks again. 888 * the FLUSH flag; thus, it will never queue pio tasks again.
767 * Cancel and flush. 889 * Cancel and flush.
768 */ 890 */
769 tmp |= cancel_delayed_work(&ap->pio_task); 891 if (!cancel_delayed_work(&ap->port_task)) {
770 if (!tmp) {
771 DPRINTK("flush #2\n"); 892 DPRINTK("flush #2\n");
772 flush_workqueue(ata_wq); 893 flush_workqueue(ata_wq);
773 } 894 }
774 895
775 spin_lock_irqsave(&ap->host_set->lock, flags); 896 spin_lock_irqsave(&ap->host_set->lock, flags);
776 ap->flags &= ~ATA_FLAG_FLUSH_PIO_TASK; 897 ap->flags &= ~ATA_FLAG_FLUSH_PORT_TASK;
777 spin_unlock_irqrestore(&ap->host_set->lock, flags); 898 spin_unlock_irqrestore(&ap->host_set->lock, flags);
778 899
779 DPRINTK("EXIT\n"); 900 DPRINTK("EXIT\n");
@@ -904,7 +1025,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
904 * @dev: target device 1025 * @dev: target device
905 * @p_class: pointer to class of the target device (may be changed) 1026 * @p_class: pointer to class of the target device (may be changed)
906 * @post_reset: is this read ID post-reset? 1027 * @post_reset: is this read ID post-reset?
907 * @id: buffer to fill IDENTIFY page into 1028 * @p_id: read IDENTIFY page (newly allocated)
908 * 1029 *
909 * Read ID data from the specified device. ATA_CMD_ID_ATA is 1030 * Read ID data from the specified device. ATA_CMD_ID_ATA is
910 * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI 1031 * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI
@@ -919,12 +1040,13 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
919 * 0 on success, -errno otherwise. 1040 * 0 on success, -errno otherwise.
920 */ 1041 */
921static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, 1042static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
922 unsigned int *p_class, int post_reset, u16 *id) 1043 unsigned int *p_class, int post_reset, u16 **p_id)
923{ 1044{
924 unsigned int class = *p_class; 1045 unsigned int class = *p_class;
925 unsigned int using_edd; 1046 unsigned int using_edd;
926 struct ata_taskfile tf; 1047 struct ata_taskfile tf;
927 unsigned int err_mask = 0; 1048 unsigned int err_mask = 0;
1049 u16 *id;
928 const char *reason; 1050 const char *reason;
929 int rc; 1051 int rc;
930 1052
@@ -938,6 +1060,13 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
938 1060
939 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ 1061 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */
940 1062
1063 id = kmalloc(sizeof(id[0]) * ATA_ID_WORDS, GFP_KERNEL);
1064 if (id == NULL) {
1065 rc = -ENOMEM;
1066 reason = "out of memory";
1067 goto err_out;
1068 }
1069
941 retry: 1070 retry:
942 ata_tf_init(ap, &tf, dev->devno); 1071 ata_tf_init(ap, &tf, dev->devno);
943 1072
@@ -1028,53 +1157,59 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
1028 } 1157 }
1029 1158
1030 *p_class = class; 1159 *p_class = class;
1160 *p_id = id;
1031 return 0; 1161 return 0;
1032 1162
1033 err_out: 1163 err_out:
1034 printk(KERN_WARNING "ata%u: dev %u failed to IDENTIFY (%s)\n", 1164 printk(KERN_WARNING "ata%u: dev %u failed to IDENTIFY (%s)\n",
1035 ap->id, dev->devno, reason); 1165 ap->id, dev->devno, reason);
1166 kfree(id);
1036 return rc; 1167 return rc;
1037} 1168}
1038 1169
1170static inline u8 ata_dev_knobble(const struct ata_port *ap,
1171 struct ata_device *dev)
1172{
1173 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id)));
1174}
1175
1039/** 1176/**
1040 * ata_dev_identify - obtain IDENTIFY x DEVICE page 1177 * ata_dev_configure - Configure the specified ATA/ATAPI device
1041 * @ap: port on which device we wish to probe resides 1178 * @ap: Port on which target device resides
1042 * @device: device bus address, starting at zero 1179 * @dev: Target device to configure
1043 * 1180 * @print_info: Enable device info printout
1044 * Following bus reset, we issue the IDENTIFY [PACKET] DEVICE 1181 *
1045 * command, and read back the 512-byte device information page. 1182 * Configure @dev according to @dev->id. Generic and low-level
1046 * The device information page is fed to us via the standard 1183 * driver specific fixups are also applied.
1047 * PIO-IN protocol, but we hand-code it here. (TODO: investigate
1048 * using standard PIO-IN paths)
1049 *
1050 * After reading the device information page, we use several
1051 * bits of information from it to initialize data structures
1052 * that will be used during the lifetime of the ata_device.
1053 * Other data from the info page is used to disqualify certain
1054 * older ATA devices we do not wish to support.
1055 * 1184 *
1056 * LOCKING: 1185 * LOCKING:
1057 * Inherited from caller. Some functions called by this function 1186 * Kernel thread context (may sleep)
1058 * obtain the host_set lock. 1187 *
1188 * RETURNS:
1189 * 0 on success, -errno otherwise
1059 */ 1190 */
1060 1191static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
1061static void ata_dev_identify(struct ata_port *ap, unsigned int device) 1192 int print_info)
1062{ 1193{
1063 struct ata_device *dev = &ap->device[device]; 1194 unsigned int xfer_mask;
1064 unsigned long xfer_modes;
1065 int i, rc; 1195 int i, rc;
1066 1196
1067 if (!ata_dev_present(dev)) { 1197 if (!ata_dev_present(dev)) {
1068 DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n", 1198 DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n",
1069 ap->id, device); 1199 ap->id, dev->devno);
1070 return; 1200 return 0;
1071 } 1201 }
1072 1202
1073 DPRINTK("ENTER, host %u, dev %u\n", ap->id, device); 1203 DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno);
1074 1204
1075 rc = ata_dev_read_id(ap, dev, &dev->class, 1, dev->id); 1205 /* initialize to-be-configured parameters */
1076 if (rc) 1206 dev->flags = 0;
1077 goto err_out; 1207 dev->max_sectors = 0;
1208 dev->cdb_len = 0;
1209 dev->n_sectors = 0;
1210 dev->cylinders = 0;
1211 dev->heads = 0;
1212 dev->sectors = 0;
1078 1213
1079 /* 1214 /*
1080 * common ATA, ATAPI feature tests 1215 * common ATA, ATAPI feature tests
@@ -1083,15 +1218,12 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1083 /* we require DMA support (bits 8 of word 49) */ 1218 /* we require DMA support (bits 8 of word 49) */
1084 if (!ata_id_has_dma(dev->id)) { 1219 if (!ata_id_has_dma(dev->id)) {
1085 printk(KERN_DEBUG "ata%u: no dma\n", ap->id); 1220 printk(KERN_DEBUG "ata%u: no dma\n", ap->id);
1221 rc = -EINVAL;
1086 goto err_out_nosup; 1222 goto err_out_nosup;
1087 } 1223 }
1088 1224
1089 /* quick-n-dirty find max transfer mode; for printk only */ 1225 /* find max transfer mode; for printk only */
1090 xfer_modes = dev->id[ATA_ID_UDMA_MODES]; 1226 xfer_mask = ata_id_xfermask(dev->id);
1091 if (!xfer_modes)
1092 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA;
1093 if (!xfer_modes)
1094 xfer_modes = ata_pio_modes(dev);
1095 1227
1096 ata_dump_id(dev->id); 1228 ata_dump_id(dev->id);
1097 1229
@@ -1100,19 +1232,25 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1100 dev->n_sectors = ata_id_n_sectors(dev->id); 1232 dev->n_sectors = ata_id_n_sectors(dev->id);
1101 1233
1102 if (ata_id_has_lba(dev->id)) { 1234 if (ata_id_has_lba(dev->id)) {
1103 dev->flags |= ATA_DFLAG_LBA; 1235 const char *lba_desc;
1104 1236
1105 if (ata_id_has_lba48(dev->id)) 1237 lba_desc = "LBA";
1238 dev->flags |= ATA_DFLAG_LBA;
1239 if (ata_id_has_lba48(dev->id)) {
1106 dev->flags |= ATA_DFLAG_LBA48; 1240 dev->flags |= ATA_DFLAG_LBA48;
1241 lba_desc = "LBA48";
1242 }
1107 1243
1108 /* print device info to dmesg */ 1244 /* print device info to dmesg */
1109 printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n", 1245 if (print_info)
1110 ap->id, device, 1246 printk(KERN_INFO "ata%u: dev %u ATA-%d, "
1111 ata_id_major_version(dev->id), 1247 "max %s, %Lu sectors: %s\n",
1112 ata_mode_string(xfer_modes), 1248 ap->id, dev->devno,
1113 (unsigned long long)dev->n_sectors, 1249 ata_id_major_version(dev->id),
1114 dev->flags & ATA_DFLAG_LBA48 ? " LBA48" : " LBA"); 1250 ata_mode_string(xfer_mask),
1115 } else { 1251 (unsigned long long)dev->n_sectors,
1252 lba_desc);
1253 } else {
1116 /* CHS */ 1254 /* CHS */
1117 1255
1118 /* Default translation */ 1256 /* Default translation */
@@ -1128,13 +1266,14 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1128 } 1266 }
1129 1267
1130 /* print device info to dmesg */ 1268 /* print device info to dmesg */
1131 printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors: CHS %d/%d/%d\n", 1269 if (print_info)
1132 ap->id, device, 1270 printk(KERN_INFO "ata%u: dev %u ATA-%d, "
1133 ata_id_major_version(dev->id), 1271 "max %s, %Lu sectors: CHS %u/%u/%u\n",
1134 ata_mode_string(xfer_modes), 1272 ap->id, dev->devno,
1135 (unsigned long long)dev->n_sectors, 1273 ata_id_major_version(dev->id),
1136 (int)dev->cylinders, (int)dev->heads, (int)dev->sectors); 1274 ata_mode_string(xfer_mask),
1137 1275 (unsigned long long)dev->n_sectors,
1276 dev->cylinders, dev->heads, dev->sectors);
1138 } 1277 }
1139 1278
1140 if (dev->id[59] & 0x100) { 1279 if (dev->id[59] & 0x100) {
@@ -1150,6 +1289,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1150 rc = atapi_cdb_len(dev->id); 1289 rc = atapi_cdb_len(dev->id);
1151 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { 1290 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {
1152 printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id); 1291 printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id);
1292 rc = -EINVAL;
1153 goto err_out_nosup; 1293 goto err_out_nosup;
1154 } 1294 }
1155 dev->cdb_len = (unsigned int) rc; 1295 dev->cdb_len = (unsigned int) rc;
@@ -1158,9 +1298,9 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1158 dev->flags |= ATA_DFLAG_CDB_INTR; 1298 dev->flags |= ATA_DFLAG_CDB_INTR;
1159 1299
1160 /* print device info to dmesg */ 1300 /* print device info to dmesg */
1161 printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", 1301 if (print_info)
1162 ap->id, device, 1302 printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
1163 ata_mode_string(xfer_modes)); 1303 ap->id, dev->devno, ata_mode_string(xfer_mask));
1164 } 1304 }
1165 1305
1166 ap->host->max_cmd_len = 0; 1306 ap->host->max_cmd_len = 0;
@@ -1169,44 +1309,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1169 ap->host->max_cmd_len, 1309 ap->host->max_cmd_len,
1170 ap->device[i].cdb_len); 1310 ap->device[i].cdb_len);
1171 1311
1172 DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap));
1173 return;
1174
1175err_out_nosup:
1176 printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n",
1177 ap->id, device);
1178err_out:
1179 dev->class++; /* converts ATA_DEV_xxx into ATA_DEV_xxx_UNSUP */
1180 DPRINTK("EXIT, err\n");
1181}
1182
1183
1184static inline u8 ata_dev_knobble(const struct ata_port *ap,
1185 struct ata_device *dev)
1186{
1187 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id)));
1188}
1189
1190/**
1191 * ata_dev_config - Run device specific handlers & check for SATA->PATA bridges
1192 * @ap: Bus
1193 * @i: Device
1194 *
1195 * LOCKING:
1196 */
1197
1198void ata_dev_config(struct ata_port *ap, unsigned int i)
1199{
1200 /* limit bridge transfers to udma5, 200 sectors */ 1312 /* limit bridge transfers to udma5, 200 sectors */
1201 if (ata_dev_knobble(ap, &ap->device[i])) { 1313 if (ata_dev_knobble(ap, dev)) {
1202 printk(KERN_INFO "ata%u(%u): applying bridge limits\n", 1314 if (print_info)
1203 ap->id, i); 1315 printk(KERN_INFO "ata%u(%u): applying bridge limits\n",
1316 ap->id, dev->devno);
1204 ap->udma_mask &= ATA_UDMA5; 1317 ap->udma_mask &= ATA_UDMA5;
1205 ap->device[i].max_sectors = ATA_MAX_SECTORS; 1318 dev->max_sectors = ATA_MAX_SECTORS;
1206 } 1319 }
1207 1320
1208 if (ap->ops->dev_config) 1321 if (ap->ops->dev_config)
1209 ap->ops->dev_config(ap, &ap->device[i]); 1322 ap->ops->dev_config(ap, dev);
1323
1324 DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap));
1325 return 0;
1326
1327err_out_nosup:
1328 printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n",
1329 ap->id, dev->devno);
1330 DPRINTK("EXIT, err\n");
1331 return rc;
1210} 1332}
1211 1333
1212/** 1334/**
@@ -1226,41 +1348,61 @@ void ata_dev_config(struct ata_port *ap, unsigned int i)
1226 1348
1227static int ata_bus_probe(struct ata_port *ap) 1349static int ata_bus_probe(struct ata_port *ap)
1228{ 1350{
1229 unsigned int i, found = 0; 1351 unsigned int classes[ATA_MAX_DEVICES];
1352 unsigned int i, rc, found = 0;
1230 1353
1231 if (ap->ops->probe_reset) { 1354 ata_port_probe(ap);
1232 unsigned int classes[ATA_MAX_DEVICES];
1233 int rc;
1234 1355
1235 ata_port_probe(ap); 1356 /* reset */
1357 if (ap->ops->probe_reset) {
1358 for (i = 0; i < ATA_MAX_DEVICES; i++)
1359 classes[i] = ATA_DEV_UNKNOWN;
1236 1360
1237 rc = ap->ops->probe_reset(ap, classes); 1361 rc = ap->ops->probe_reset(ap, classes);
1238 if (rc == 0) { 1362 if (rc) {
1239 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1363 printk("ata%u: reset failed (errno=%d)\n", ap->id, rc);
1240 if (classes[i] == ATA_DEV_UNKNOWN) 1364 return rc;
1241 classes[i] = ATA_DEV_NONE;
1242 ap->device[i].class = classes[i];
1243 }
1244 } else {
1245 printk(KERN_ERR "ata%u: probe reset failed, "
1246 "disabling port\n", ap->id);
1247 ata_port_disable(ap);
1248 } 1365 }
1249 } else 1366
1367 for (i = 0; i < ATA_MAX_DEVICES; i++)
1368 if (classes[i] == ATA_DEV_UNKNOWN)
1369 classes[i] = ATA_DEV_NONE;
1370 } else {
1250 ap->ops->phy_reset(ap); 1371 ap->ops->phy_reset(ap);
1251 1372
1252 if (ap->flags & ATA_FLAG_PORT_DISABLED) 1373 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1253 goto err_out; 1374 if (!(ap->flags & ATA_FLAG_PORT_DISABLED))
1375 classes[i] = ap->device[i].class;
1376 else
1377 ap->device[i].class = ATA_DEV_UNKNOWN;
1378 }
1379 ata_port_probe(ap);
1380 }
1254 1381
1382 /* read IDENTIFY page and configure devices */
1255 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1383 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1256 ata_dev_identify(ap, i); 1384 struct ata_device *dev = &ap->device[i];
1257 if (ata_dev_present(&ap->device[i])) { 1385
1258 found = 1; 1386 dev->class = classes[i];
1259 ata_dev_config(ap,i); 1387
1388 if (!ata_dev_present(dev))
1389 continue;
1390
1391 WARN_ON(dev->id != NULL);
1392 if (ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id)) {
1393 dev->class = ATA_DEV_NONE;
1394 continue;
1395 }
1396
1397 if (ata_dev_configure(ap, dev, 1)) {
1398 dev->class++; /* disable device */
1399 continue;
1260 } 1400 }
1401
1402 found = 1;
1261 } 1403 }
1262 1404
1263 if ((!found) || (ap->flags & ATA_FLAG_PORT_DISABLED)) 1405 if (!found)
1264 goto err_out_disable; 1406 goto err_out_disable;
1265 1407
1266 ata_set_mode(ap); 1408 ata_set_mode(ap);
@@ -1271,7 +1413,6 @@ static int ata_bus_probe(struct ata_port *ap)
1271 1413
1272err_out_disable: 1414err_out_disable:
1273 ap->ops->port_disable(ap); 1415 ap->ops->port_disable(ap);
1274err_out:
1275 return -1; 1416 return -1;
1276} 1417}
1277 1418
@@ -1567,31 +1708,8 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1567 return 0; 1708 return 0;
1568} 1709}
1569 1710
1570static const struct {
1571 unsigned int shift;
1572 u8 base;
1573} xfer_mode_classes[] = {
1574 { ATA_SHIFT_UDMA, XFER_UDMA_0 },
1575 { ATA_SHIFT_MWDMA, XFER_MW_DMA_0 },
1576 { ATA_SHIFT_PIO, XFER_PIO_0 },
1577};
1578
1579static u8 base_from_shift(unsigned int shift)
1580{
1581 int i;
1582
1583 for (i = 0; i < ARRAY_SIZE(xfer_mode_classes); i++)
1584 if (xfer_mode_classes[i].shift == shift)
1585 return xfer_mode_classes[i].base;
1586
1587 return 0xff;
1588}
1589
1590static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) 1711static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
1591{ 1712{
1592 int ofs, idx;
1593 u8 base;
1594
1595 if (!ata_dev_present(dev) || (ap->flags & ATA_FLAG_PORT_DISABLED)) 1713 if (!ata_dev_present(dev) || (ap->flags & ATA_FLAG_PORT_DISABLED))
1596 return; 1714 return;
1597 1715
@@ -1600,65 +1718,58 @@ static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
1600 1718
1601 ata_dev_set_xfermode(ap, dev); 1719 ata_dev_set_xfermode(ap, dev);
1602 1720
1603 base = base_from_shift(dev->xfer_shift); 1721 if (ata_dev_revalidate(ap, dev, 0)) {
1604 ofs = dev->xfer_mode - base; 1722 printk(KERN_ERR "ata%u: failed to revalidate after set "
1605 idx = ofs + dev->xfer_shift; 1723 "xfermode, disabled\n", ap->id);
1606 WARN_ON(idx >= ARRAY_SIZE(xfer_mode_str)); 1724 ata_port_disable(ap);
1725 }
1607 1726
1608 DPRINTK("idx=%d xfer_shift=%u, xfer_mode=0x%x, base=0x%x, offset=%d\n", 1727 DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n",
1609 idx, dev->xfer_shift, (int)dev->xfer_mode, (int)base, ofs); 1728 dev->xfer_shift, (int)dev->xfer_mode);
1610 1729
1611 printk(KERN_INFO "ata%u: dev %u configured for %s\n", 1730 printk(KERN_INFO "ata%u: dev %u configured for %s\n",
1612 ap->id, dev->devno, xfer_mode_str[idx]); 1731 ap->id, dev->devno,
1732 ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode)));
1613} 1733}
1614 1734
1615static int ata_host_set_pio(struct ata_port *ap) 1735static int ata_host_set_pio(struct ata_port *ap)
1616{ 1736{
1617 unsigned int mask; 1737 int i;
1618 int x, i;
1619 u8 base, xfer_mode;
1620
1621 mask = ata_get_mode_mask(ap, ATA_SHIFT_PIO);
1622 x = fgb(mask);
1623 if (x < 0) {
1624 printk(KERN_WARNING "ata%u: no PIO support\n", ap->id);
1625 return -1;
1626 }
1627
1628 base = base_from_shift(ATA_SHIFT_PIO);
1629 xfer_mode = base + x;
1630
1631 DPRINTK("base 0x%x xfer_mode 0x%x mask 0x%x x %d\n",
1632 (int)base, (int)xfer_mode, mask, x);
1633 1738
1634 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1739 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1635 struct ata_device *dev = &ap->device[i]; 1740 struct ata_device *dev = &ap->device[i];
1636 if (ata_dev_present(dev)) { 1741
1637 dev->pio_mode = xfer_mode; 1742 if (!ata_dev_present(dev))
1638 dev->xfer_mode = xfer_mode; 1743 continue;
1639 dev->xfer_shift = ATA_SHIFT_PIO; 1744
1640 if (ap->ops->set_piomode) 1745 if (!dev->pio_mode) {
1641 ap->ops->set_piomode(ap, dev); 1746 printk(KERN_WARNING "ata%u: no PIO support\n", ap->id);
1747 return -1;
1642 } 1748 }
1749
1750 dev->xfer_mode = dev->pio_mode;
1751 dev->xfer_shift = ATA_SHIFT_PIO;
1752 if (ap->ops->set_piomode)
1753 ap->ops->set_piomode(ap, dev);
1643 } 1754 }
1644 1755
1645 return 0; 1756 return 0;
1646} 1757}
1647 1758
1648static void ata_host_set_dma(struct ata_port *ap, u8 xfer_mode, 1759static void ata_host_set_dma(struct ata_port *ap)
1649 unsigned int xfer_shift)
1650{ 1760{
1651 int i; 1761 int i;
1652 1762
1653 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1763 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1654 struct ata_device *dev = &ap->device[i]; 1764 struct ata_device *dev = &ap->device[i];
1655 if (ata_dev_present(dev)) { 1765
1656 dev->dma_mode = xfer_mode; 1766 if (!ata_dev_present(dev) || !dev->dma_mode)
1657 dev->xfer_mode = xfer_mode; 1767 continue;
1658 dev->xfer_shift = xfer_shift; 1768
1659 if (ap->ops->set_dmamode) 1769 dev->xfer_mode = dev->dma_mode;
1660 ap->ops->set_dmamode(ap, dev); 1770 dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode);
1661 } 1771 if (ap->ops->set_dmamode)
1772 ap->ops->set_dmamode(ap, dev);
1662 } 1773 }
1663} 1774}
1664 1775
@@ -1673,28 +1784,34 @@ static void ata_host_set_dma(struct ata_port *ap, u8 xfer_mode,
1673 */ 1784 */
1674static void ata_set_mode(struct ata_port *ap) 1785static void ata_set_mode(struct ata_port *ap)
1675{ 1786{
1676 unsigned int xfer_shift; 1787 int i, rc;
1677 u8 xfer_mode;
1678 int rc;
1679 1788
1680 /* step 1: always set host PIO timings */ 1789 /* step 1: calculate xfer_mask */
1681 rc = ata_host_set_pio(ap); 1790 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1682 if (rc) 1791 struct ata_device *dev = &ap->device[i];
1683 goto err_out; 1792 unsigned int xfer_mask;
1793
1794 if (!ata_dev_present(dev))
1795 continue;
1796
1797 xfer_mask = ata_dev_xfermask(ap, dev);
1684 1798
1685 /* step 2: choose the best data xfer mode */ 1799 dev->pio_mode = ata_xfer_mask2mode(xfer_mask & ATA_MASK_PIO);
1686 xfer_mode = xfer_shift = 0; 1800 dev->dma_mode = ata_xfer_mask2mode(xfer_mask & (ATA_MASK_MWDMA |
1687 rc = ata_choose_xfer_mode(ap, &xfer_mode, &xfer_shift); 1801 ATA_MASK_UDMA));
1802 }
1803
1804 /* step 2: always set host PIO timings */
1805 rc = ata_host_set_pio(ap);
1688 if (rc) 1806 if (rc)
1689 goto err_out; 1807 goto err_out;
1690 1808
1691 /* step 3: if that xfer mode isn't PIO, set host DMA timings */ 1809 /* step 3: set host DMA timings */
1692 if (xfer_shift != ATA_SHIFT_PIO) 1810 ata_host_set_dma(ap);
1693 ata_host_set_dma(ap, xfer_mode, xfer_shift);
1694 1811
1695 /* step 4: update devices' xfer mode */ 1812 /* step 4: update devices' xfer mode */
1696 ata_dev_set_mode(ap, &ap->device[0]); 1813 for (i = 0; i < ATA_MAX_DEVICES; i++)
1697 ata_dev_set_mode(ap, &ap->device[1]); 1814 ata_dev_set_mode(ap, &ap->device[i]);
1698 1815
1699 if (ap->flags & ATA_FLAG_PORT_DISABLED) 1816 if (ap->flags & ATA_FLAG_PORT_DISABLED)
1700 return; 1817 return;
@@ -2325,11 +2442,118 @@ int ata_drive_probe_reset(struct ata_port *ap, ata_probeinit_fn_t probeinit,
2325 return rc; 2442 return rc;
2326} 2443}
2327 2444
2328static void ata_pr_blacklisted(const struct ata_port *ap, 2445/**
2329 const struct ata_device *dev) 2446 * ata_dev_same_device - Determine whether new ID matches configured device
2447 * @ap: port on which the device to compare against resides
2448 * @dev: device to compare against
2449 * @new_class: class of the new device
2450 * @new_id: IDENTIFY page of the new device
2451 *
2452 * Compare @new_class and @new_id against @dev and determine
2453 * whether @dev is the device indicated by @new_class and
2454 * @new_id.
2455 *
2456 * LOCKING:
2457 * None.
2458 *
2459 * RETURNS:
2460 * 1 if @dev matches @new_class and @new_id, 0 otherwise.
2461 */
2462static int ata_dev_same_device(struct ata_port *ap, struct ata_device *dev,
2463 unsigned int new_class, const u16 *new_id)
2464{
2465 const u16 *old_id = dev->id;
2466 unsigned char model[2][41], serial[2][21];
2467 u64 new_n_sectors;
2468
2469 if (dev->class != new_class) {
2470 printk(KERN_INFO
2471 "ata%u: dev %u class mismatch %d != %d\n",
2472 ap->id, dev->devno, dev->class, new_class);
2473 return 0;
2474 }
2475
2476 ata_id_c_string(old_id, model[0], ATA_ID_PROD_OFS, sizeof(model[0]));
2477 ata_id_c_string(new_id, model[1], ATA_ID_PROD_OFS, sizeof(model[1]));
2478 ata_id_c_string(old_id, serial[0], ATA_ID_SERNO_OFS, sizeof(serial[0]));
2479 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO_OFS, sizeof(serial[1]));
2480 new_n_sectors = ata_id_n_sectors(new_id);
2481
2482 if (strcmp(model[0], model[1])) {
2483 printk(KERN_INFO
2484 "ata%u: dev %u model number mismatch '%s' != '%s'\n",
2485 ap->id, dev->devno, model[0], model[1]);
2486 return 0;
2487 }
2488
2489 if (strcmp(serial[0], serial[1])) {
2490 printk(KERN_INFO
2491 "ata%u: dev %u serial number mismatch '%s' != '%s'\n",
2492 ap->id, dev->devno, serial[0], serial[1]);
2493 return 0;
2494 }
2495
2496 if (dev->class == ATA_DEV_ATA && dev->n_sectors != new_n_sectors) {
2497 printk(KERN_INFO
2498 "ata%u: dev %u n_sectors mismatch %llu != %llu\n",
2499 ap->id, dev->devno, (unsigned long long)dev->n_sectors,
2500 (unsigned long long)new_n_sectors);
2501 return 0;
2502 }
2503
2504 return 1;
2505}
2506
2507/**
2508 * ata_dev_revalidate - Revalidate ATA device
2509 * @ap: port on which the device to revalidate resides
2510 * @dev: device to revalidate
2511 * @post_reset: is this revalidation after reset?
2512 *
2513 * Re-read IDENTIFY page and make sure @dev is still attached to
2514 * the port.
2515 *
2516 * LOCKING:
2517 * Kernel thread context (may sleep)
2518 *
2519 * RETURNS:
2520 * 0 on success, negative errno otherwise
2521 */
2522int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
2523 int post_reset)
2330{ 2524{
2331 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n", 2525 unsigned int class;
2332 ap->id, dev->devno); 2526 u16 *id;
2527 int rc;
2528
2529 if (!ata_dev_present(dev))
2530 return -ENODEV;
2531
2532 class = dev->class;
2533 id = NULL;
2534
2535 /* allocate & read ID data */
2536 rc = ata_dev_read_id(ap, dev, &class, post_reset, &id);
2537 if (rc)
2538 goto fail;
2539
2540 /* is the device still there? */
2541 if (!ata_dev_same_device(ap, dev, class, id)) {
2542 rc = -ENODEV;
2543 goto fail;
2544 }
2545
2546 kfree(dev->id);
2547 dev->id = id;
2548
2549 /* configure device according to the new ID */
2550 return ata_dev_configure(ap, dev, 0);
2551
2552 fail:
2553 printk(KERN_ERR "ata%u: dev %u revalidation failed (errno=%d)\n",
2554 ap->id, dev->devno, rc);
2555 kfree(id);
2556 return rc;
2333} 2557}
2334 2558
2335static const char * const ata_dma_blacklist [] = { 2559static const char * const ata_dma_blacklist [] = {
@@ -2378,128 +2602,45 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
2378 return 0; 2602 return 0;
2379} 2603}
2380 2604
2381static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift)
2382{
2383 const struct ata_device *master, *slave;
2384 unsigned int mask;
2385
2386 master = &ap->device[0];
2387 slave = &ap->device[1];
2388
2389 WARN_ON(!ata_dev_present(master) && !ata_dev_present(slave));
2390
2391 if (shift == ATA_SHIFT_UDMA) {
2392 mask = ap->udma_mask;
2393 if (ata_dev_present(master)) {
2394 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff);
2395 if (ata_dma_blacklisted(master)) {
2396 mask = 0;
2397 ata_pr_blacklisted(ap, master);
2398 }
2399 }
2400 if (ata_dev_present(slave)) {
2401 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff);
2402 if (ata_dma_blacklisted(slave)) {
2403 mask = 0;
2404 ata_pr_blacklisted(ap, slave);
2405 }
2406 }
2407 }
2408 else if (shift == ATA_SHIFT_MWDMA) {
2409 mask = ap->mwdma_mask;
2410 if (ata_dev_present(master)) {
2411 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07);
2412 if (ata_dma_blacklisted(master)) {
2413 mask = 0;
2414 ata_pr_blacklisted(ap, master);
2415 }
2416 }
2417 if (ata_dev_present(slave)) {
2418 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07);
2419 if (ata_dma_blacklisted(slave)) {
2420 mask = 0;
2421 ata_pr_blacklisted(ap, slave);
2422 }
2423 }
2424 }
2425 else if (shift == ATA_SHIFT_PIO) {
2426 mask = ap->pio_mask;
2427 if (ata_dev_present(master)) {
2428 /* spec doesn't return explicit support for
2429 * PIO0-2, so we fake it
2430 */
2431 u16 tmp_mode = master->id[ATA_ID_PIO_MODES] & 0x03;
2432 tmp_mode <<= 3;
2433 tmp_mode |= 0x7;
2434 mask &= tmp_mode;
2435 }
2436 if (ata_dev_present(slave)) {
2437 /* spec doesn't return explicit support for
2438 * PIO0-2, so we fake it
2439 */
2440 u16 tmp_mode = slave->id[ATA_ID_PIO_MODES] & 0x03;
2441 tmp_mode <<= 3;
2442 tmp_mode |= 0x7;
2443 mask &= tmp_mode;
2444 }
2445 }
2446 else {
2447 mask = 0xffffffff; /* shut up compiler warning */
2448 BUG();
2449 }
2450
2451 return mask;
2452}
2453
2454/* find greatest bit */
2455static int fgb(u32 bitmap)
2456{
2457 unsigned int i;
2458 int x = -1;
2459
2460 for (i = 0; i < 32; i++)
2461 if (bitmap & (1 << i))
2462 x = i;
2463
2464 return x;
2465}
2466
2467/** 2605/**
2468 * ata_choose_xfer_mode - attempt to find best transfer mode 2606 * ata_dev_xfermask - Compute supported xfermask of the given device
2469 * @ap: Port for which an xfer mode will be selected 2607 * @ap: Port on which the device to compute xfermask for resides
2470 * @xfer_mode_out: (output) SET FEATURES - XFER MODE code 2608 * @dev: Device to compute xfermask for
2471 * @xfer_shift_out: (output) bit shift that selects this mode
2472 * 2609 *
2473 * Based on host and device capabilities, determine the 2610 * Compute supported xfermask of @dev. This function is
2474 * maximum transfer mode that is amenable to all. 2611 * responsible for applying all known limits including host
2612 * controller limits, device blacklist, etc...
2475 * 2613 *
2476 * LOCKING: 2614 * LOCKING:
2477 * PCI/etc. bus probe sem. 2615 * None.
2478 * 2616 *
2479 * RETURNS: 2617 * RETURNS:
2480 * Zero on success, negative on error. 2618 * Computed xfermask.
2481 */ 2619 */
2482 2620static unsigned int ata_dev_xfermask(struct ata_port *ap,
2483static int ata_choose_xfer_mode(const struct ata_port *ap, 2621 struct ata_device *dev)
2484 u8 *xfer_mode_out,
2485 unsigned int *xfer_shift_out)
2486{ 2622{
2487 unsigned int mask, shift; 2623 unsigned long xfer_mask;
2488 int x, i; 2624 int i;
2489 2625
2490 for (i = 0; i < ARRAY_SIZE(xfer_mode_classes); i++) { 2626 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask,
2491 shift = xfer_mode_classes[i].shift; 2627 ap->udma_mask);
2492 mask = ata_get_mode_mask(ap, shift);
2493 2628
2494 x = fgb(mask); 2629 /* use port-wide xfermask for now */
2495 if (x >= 0) { 2630 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2496 *xfer_mode_out = xfer_mode_classes[i].base + x; 2631 struct ata_device *d = &ap->device[i];
2497 *xfer_shift_out = shift; 2632 if (!ata_dev_present(d))
2498 return 0; 2633 continue;
2499 } 2634 xfer_mask &= ata_id_xfermask(d->id);
2635 if (ata_dma_blacklisted(d))
2636 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
2500 } 2637 }
2501 2638
2502 return -1; 2639 if (ata_dma_blacklisted(dev))
2640 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, "
2641 "disabling DMA\n", ap->id, dev->devno);
2642
2643 return xfer_mask;
2503} 2644}
2504 2645
2505/** 2646/**
@@ -3667,12 +3808,84 @@ fsm_start:
3667 } 3808 }
3668 3809
3669 if (timeout) 3810 if (timeout)
3670 ata_queue_delayed_pio_task(ap, timeout); 3811 ata_port_queue_task(ap, ata_pio_task, ap, timeout);
3671 else if (has_next) 3812 else if (!qc_completed)
3672 goto fsm_start; 3813 goto fsm_start;
3673} 3814}
3674 3815
3675/** 3816/**
3817 * atapi_packet_task - Write CDB bytes to hardware
3818 * @_data: Port to which ATAPI device is attached.
3819 *
3820 * When device has indicated its readiness to accept
3821 * a CDB, this function is called. Send the CDB.
3822 * If DMA is to be performed, exit immediately.
3823 * Otherwise, we are in polling mode, so poll
3824 * status under operation succeeds or fails.
3825 *
3826 * LOCKING:
3827 * Kernel thread context (may sleep)
3828 */
3829
3830static void atapi_packet_task(void *_data)
3831{
3832 struct ata_port *ap = _data;
3833 struct ata_queued_cmd *qc;
3834 u8 status;
3835
3836 qc = ata_qc_from_tag(ap, ap->active_tag);
3837 WARN_ON(qc == NULL);
3838 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
3839
3840 /* sleep-wait for BSY to clear */
3841 DPRINTK("busy wait\n");
3842 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
3843 qc->err_mask |= AC_ERR_TIMEOUT;
3844 goto err_out;
3845 }
3846
3847 /* make sure DRQ is set */
3848 status = ata_chk_status(ap);
3849 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) {
3850 qc->err_mask |= AC_ERR_HSM;
3851 goto err_out;
3852 }
3853
3854 /* send SCSI cdb */
3855 DPRINTK("send cdb\n");
3856 WARN_ON(qc->dev->cdb_len < 12);
3857
3858 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA ||
3859 qc->tf.protocol == ATA_PROT_ATAPI_NODATA) {
3860 unsigned long flags;
3861
3862 /* Once we're done issuing command and kicking bmdma,
3863 * irq handler takes over. To not lose irq, we need
3864 * to clear NOINTR flag before sending cdb, but
3865 * interrupt handler shouldn't be invoked before we're
3866 * finished. Hence, the following locking.
3867 */
3868 spin_lock_irqsave(&ap->host_set->lock, flags);
3869 ap->flags &= ~ATA_FLAG_NOINTR;
3870 ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
3871 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA)
3872 ap->ops->bmdma_start(qc); /* initiate bmdma */
3873 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3874 } else {
3875 ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
3876
3877 /* PIO commands are handled by polling */
3878 ap->hsm_task_state = HSM_ST;
3879 ata_port_queue_task(ap, ata_pio_task, ap, 0);
3880 }
3881
3882 return;
3883
3884err_out:
3885 ata_poll_qc_complete(qc);
3886}
3887
3888/**
3676 * ata_qc_timeout - Handle timeout of queued command 3889 * ata_qc_timeout - Handle timeout of queued command
3677 * @qc: Command that timed out 3890 * @qc: Command that timed out
3678 * 3891 *
@@ -3700,7 +3913,6 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3700 3913
3701 DPRINTK("ENTER\n"); 3914 DPRINTK("ENTER\n");
3702 3915
3703 ata_flush_pio_tasks(ap);
3704 ap->hsm_task_state = HSM_ST_IDLE; 3916 ap->hsm_task_state = HSM_ST_IDLE;
3705 3917
3706 spin_lock_irqsave(&host_set->lock, flags); 3918 spin_lock_irqsave(&host_set->lock, flags);
@@ -4010,7 +4222,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4010 if (qc->tf.flags & ATA_TFLAG_WRITE) { 4222 if (qc->tf.flags & ATA_TFLAG_WRITE) {
4011 /* PIO data out protocol */ 4223 /* PIO data out protocol */
4012 ap->hsm_task_state = HSM_ST_FIRST; 4224 ap->hsm_task_state = HSM_ST_FIRST;
4013 ata_queue_pio_task(ap); 4225 ata_port_queue_task(ap, ata_pio_task, ap, 0);
4014 4226
4015 /* always send first data block using 4227 /* always send first data block using
4016 * the ata_pio_task() codepath. 4228 * the ata_pio_task() codepath.
@@ -4020,7 +4232,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4020 ap->hsm_task_state = HSM_ST; 4232 ap->hsm_task_state = HSM_ST;
4021 4233
4022 if (qc->tf.flags & ATA_TFLAG_POLLING) 4234 if (qc->tf.flags & ATA_TFLAG_POLLING)
4023 ata_queue_pio_task(ap); 4235 ata_port_queue_task(ap, ata_pio_task, ap, 0);
4024 4236
4025 /* if polling, ata_pio_task() handles the rest. 4237 /* if polling, ata_pio_task() handles the rest.
4026 * otherwise, interrupt handler takes over from here. 4238 * otherwise, interrupt handler takes over from here.
@@ -4041,7 +4253,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4041 /* send cdb by polling if no cdb interrupt */ 4253 /* send cdb by polling if no cdb interrupt */
4042 if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) || 4254 if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) ||
4043 (qc->tf.flags & ATA_TFLAG_POLLING)) 4255 (qc->tf.flags & ATA_TFLAG_POLLING))
4044 ata_queue_pio_task(ap); 4256 ata_port_queue_task(ap, atapi_packet_task, ap, 0);
4045 break; 4257 break;
4046 4258
4047 case ATA_PROT_ATAPI_DMA: 4259 case ATA_PROT_ATAPI_DMA:
@@ -4053,7 +4265,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4053 4265
4054 /* send cdb by polling if no cdb interrupt */ 4266 /* send cdb by polling if no cdb interrupt */
4055 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) 4267 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
4056 ata_queue_pio_task(ap); 4268 ata_port_queue_task(ap, atapi_packet_task, ap, 0);
4057 break; 4269 break;
4058 4270
4059 default: 4271 default:
@@ -4533,6 +4745,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
4533 return IRQ_RETVAL(handled); 4745 return IRQ_RETVAL(handled);
4534} 4746}
4535 4747
4748
4536/* 4749/*
4537 * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, 4750 * Execute a 'simple' command, that only consists of the opcode 'cmd' itself,
4538 * without filling any other registers 4751 * without filling any other registers
@@ -4752,7 +4965,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4752 ap->active_tag = ATA_TAG_POISON; 4965 ap->active_tag = ATA_TAG_POISON;
4753 ap->last_ctl = 0xFF; 4966 ap->last_ctl = 0xFF;
4754 4967
4755 INIT_WORK(&ap->pio_task, ata_pio_task, ap); 4968 INIT_WORK(&ap->port_task, NULL, NULL);
4756 INIT_LIST_HEAD(&ap->eh_done_q); 4969 INIT_LIST_HEAD(&ap->eh_done_q);
4757 4970
4758 for (i = 0; i < ATA_MAX_DEVICES; i++) 4971 for (i = 0; i < ATA_MAX_DEVICES; i++)
@@ -5007,11 +5220,14 @@ void ata_host_set_remove(struct ata_host_set *host_set)
5007int ata_scsi_release(struct Scsi_Host *host) 5220int ata_scsi_release(struct Scsi_Host *host)
5008{ 5221{
5009 struct ata_port *ap = (struct ata_port *) &host->hostdata[0]; 5222 struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
5223 int i;
5010 5224
5011 DPRINTK("ENTER\n"); 5225 DPRINTK("ENTER\n");
5012 5226
5013 ap->ops->port_disable(ap); 5227 ap->ops->port_disable(ap);
5014 ata_host_remove(ap, 0); 5228 ata_host_remove(ap, 0);
5229 for (i = 0; i < ATA_MAX_DEVICES; i++)
5230 kfree(ap->device[i].id);
5015 5231
5016 DPRINTK("EXIT\n"); 5232 DPRINTK("EXIT\n");
5017 return 1; 5233 return 1;
@@ -5215,9 +5431,11 @@ EXPORT_SYMBOL_GPL(sata_std_hardreset);
5215EXPORT_SYMBOL_GPL(ata_std_postreset); 5431EXPORT_SYMBOL_GPL(ata_std_postreset);
5216EXPORT_SYMBOL_GPL(ata_std_probe_reset); 5432EXPORT_SYMBOL_GPL(ata_std_probe_reset);
5217EXPORT_SYMBOL_GPL(ata_drive_probe_reset); 5433EXPORT_SYMBOL_GPL(ata_drive_probe_reset);
5434EXPORT_SYMBOL_GPL(ata_dev_revalidate);
5218EXPORT_SYMBOL_GPL(ata_port_disable); 5435EXPORT_SYMBOL_GPL(ata_port_disable);
5219EXPORT_SYMBOL_GPL(ata_ratelimit); 5436EXPORT_SYMBOL_GPL(ata_ratelimit);
5220EXPORT_SYMBOL_GPL(ata_busy_sleep); 5437EXPORT_SYMBOL_GPL(ata_busy_sleep);
5438EXPORT_SYMBOL_GPL(ata_port_queue_task);
5221EXPORT_SYMBOL_GPL(ata_scsi_ioctl); 5439EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
5222EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 5440EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
5223EXPORT_SYMBOL_GPL(ata_scsi_timed_out); 5441EXPORT_SYMBOL_GPL(ata_scsi_timed_out);
@@ -5228,7 +5446,6 @@ EXPORT_SYMBOL_GPL(ata_host_intr);
5228EXPORT_SYMBOL_GPL(ata_dev_classify); 5446EXPORT_SYMBOL_GPL(ata_dev_classify);
5229EXPORT_SYMBOL_GPL(ata_id_string); 5447EXPORT_SYMBOL_GPL(ata_id_string);
5230EXPORT_SYMBOL_GPL(ata_id_c_string); 5448EXPORT_SYMBOL_GPL(ata_id_c_string);
5231EXPORT_SYMBOL_GPL(ata_dev_config);
5232EXPORT_SYMBOL_GPL(ata_scsi_simulate); 5449EXPORT_SYMBOL_GPL(ata_scsi_simulate);
5233EXPORT_SYMBOL_GPL(ata_eh_qc_complete); 5450EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
5234EXPORT_SYMBOL_GPL(ata_eh_qc_retry); 5451EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index d0bd94abb413..ccedb4536977 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -785,6 +785,8 @@ int ata_scsi_error(struct Scsi_Host *host)
785 WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); 785 WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL);
786 spin_unlock_irqrestore(&ap->host_set->lock, flags); 786 spin_unlock_irqrestore(&ap->host_set->lock, flags);
787 787
788 ata_port_flush_task(ap);
789
788 ap->ops->eng_timeout(ap); 790 ap->ops->eng_timeout(ap);
789 791
790 WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q)); 792 WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q));
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index d822eba05f3c..f4c48c91b63d 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -45,6 +45,7 @@ extern int libata_fua;
45extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 45extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
46 struct ata_device *dev); 46 struct ata_device *dev);
47extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); 47extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc);
48extern void ata_port_flush_task(struct ata_port *ap);
48extern void ata_qc_free(struct ata_queued_cmd *qc); 49extern void ata_qc_free(struct ata_queued_cmd *qc);
49extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc); 50extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc);
50extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); 51extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 7fa807d7d9e1..e5862ad5e6cd 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -256,6 +256,8 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = {
256 board_20319 }, 256 board_20319 },
257 { PCI_VENDOR_ID_PROMISE, 0x3319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 257 { PCI_VENDOR_ID_PROMISE, 0x3319, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
258 board_20319 }, 258 board_20319 },
259 { PCI_VENDOR_ID_PROMISE, 0x3515, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
260 board_20319 },
259 { PCI_VENDOR_ID_PROMISE, 0x3519, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 261 { PCI_VENDOR_ID_PROMISE, 0x3519, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
260 board_20319 }, 262 board_20319 },
261 { PCI_VENDOR_ID_PROMISE, 0x3d17, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 263 { PCI_VENDOR_ID_PROMISE, 0x3d17, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index cdf800e3ec13..4f2a67ed39d8 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -49,24 +49,30 @@
49#define DRV_VERSION "0.9" 49#define DRV_VERSION "0.9"
50 50
51enum { 51enum {
52 /*
53 * host flags
54 */
52 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29), 55 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29),
53 SIL_FLAG_MOD15WRITE = (1 << 30), 56 SIL_FLAG_MOD15WRITE = (1 << 30),
57 SIL_DFL_HOST_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
58 ATA_FLAG_MMIO,
54 59
60 /*
61 * Controller IDs
62 */
55 sil_3112 = 0, 63 sil_3112 = 0,
56 sil_3112_m15w = 1, 64 sil_3512 = 1,
57 sil_3512 = 2, 65 sil_3114 = 2,
58 sil_3114 = 3,
59
60 SIL_FIFO_R0 = 0x40,
61 SIL_FIFO_W0 = 0x41,
62 SIL_FIFO_R1 = 0x44,
63 SIL_FIFO_W1 = 0x45,
64 SIL_FIFO_R2 = 0x240,
65 SIL_FIFO_W2 = 0x241,
66 SIL_FIFO_R3 = 0x244,
67 SIL_FIFO_W3 = 0x245,
68 66
67 /*
68 * Register offsets
69 */
69 SIL_SYSCFG = 0x48, 70 SIL_SYSCFG = 0x48,
71
72 /*
73 * Register bits
74 */
75 /* SYSCFG */
70 SIL_MASK_IDE0_INT = (1 << 22), 76 SIL_MASK_IDE0_INT = (1 << 22),
71 SIL_MASK_IDE1_INT = (1 << 23), 77 SIL_MASK_IDE1_INT = (1 << 23),
72 SIL_MASK_IDE2_INT = (1 << 24), 78 SIL_MASK_IDE2_INT = (1 << 24),
@@ -75,9 +81,12 @@ enum {
75 SIL_MASK_4PORT = SIL_MASK_2PORT | 81 SIL_MASK_4PORT = SIL_MASK_2PORT |
76 SIL_MASK_IDE2_INT | SIL_MASK_IDE3_INT, 82 SIL_MASK_IDE2_INT | SIL_MASK_IDE3_INT,
77 83
78 SIL_IDE2_BMDMA = 0x200, 84 /* BMDMA/BMDMA2 */
79
80 SIL_INTR_STEERING = (1 << 1), 85 SIL_INTR_STEERING = (1 << 1),
86
87 /*
88 * Others
89 */
81 SIL_QUIRK_MOD15WRITE = (1 << 0), 90 SIL_QUIRK_MOD15WRITE = (1 << 0),
82 SIL_QUIRK_UDMA5MAX = (1 << 1), 91 SIL_QUIRK_UDMA5MAX = (1 << 1),
83}; 92};
@@ -90,13 +99,13 @@ static void sil_post_set_mode (struct ata_port *ap);
90 99
91 100
92static const struct pci_device_id sil_pci_tbl[] = { 101static const struct pci_device_id sil_pci_tbl[] = {
93 { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, 102 { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
94 { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, 103 { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
95 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 }, 104 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 },
96 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 }, 105 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
97 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, 106 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
98 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, 107 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
99 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, 108 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
100 { } /* terminate list */ 109 { } /* terminate list */
101}; 110};
102 111
@@ -181,18 +190,7 @@ static const struct ata_port_info sil_port_info[] = {
181 /* sil_3112 */ 190 /* sil_3112 */
182 { 191 {
183 .sht = &sil_sht, 192 .sht = &sil_sht,
184 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 193 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_MOD15WRITE,
185 ATA_FLAG_MMIO,
186 .pio_mask = 0x1f, /* pio0-4 */
187 .mwdma_mask = 0x07, /* mwdma0-2 */
188 .udma_mask = 0x3f, /* udma0-5 */
189 .port_ops = &sil_ops,
190 },
191 /* sil_3112_15w - keep it sync'd w/ sil_3112 */
192 {
193 .sht = &sil_sht,
194 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
195 ATA_FLAG_MMIO | SIL_FLAG_MOD15WRITE,
196 .pio_mask = 0x1f, /* pio0-4 */ 194 .pio_mask = 0x1f, /* pio0-4 */
197 .mwdma_mask = 0x07, /* mwdma0-2 */ 195 .mwdma_mask = 0x07, /* mwdma0-2 */
198 .udma_mask = 0x3f, /* udma0-5 */ 196 .udma_mask = 0x3f, /* udma0-5 */
@@ -201,9 +199,7 @@ static const struct ata_port_info sil_port_info[] = {
201 /* sil_3512 */ 199 /* sil_3512 */
202 { 200 {
203 .sht = &sil_sht, 201 .sht = &sil_sht,
204 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 202 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
205 ATA_FLAG_MMIO |
206 SIL_FLAG_RERR_ON_DMA_ACT,
207 .pio_mask = 0x1f, /* pio0-4 */ 203 .pio_mask = 0x1f, /* pio0-4 */
208 .mwdma_mask = 0x07, /* mwdma0-2 */ 204 .mwdma_mask = 0x07, /* mwdma0-2 */
209 .udma_mask = 0x3f, /* udma0-5 */ 205 .udma_mask = 0x3f, /* udma0-5 */
@@ -212,9 +208,7 @@ static const struct ata_port_info sil_port_info[] = {
212 /* sil_3114 */ 208 /* sil_3114 */
213 { 209 {
214 .sht = &sil_sht, 210 .sht = &sil_sht,
215 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 211 .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT,
216 ATA_FLAG_MMIO |
217 SIL_FLAG_RERR_ON_DMA_ACT,
218 .pio_mask = 0x1f, /* pio0-4 */ 212 .pio_mask = 0x1f, /* pio0-4 */
219 .mwdma_mask = 0x07, /* mwdma0-2 */ 213 .mwdma_mask = 0x07, /* mwdma0-2 */
220 .udma_mask = 0x3f, /* udma0-5 */ 214 .udma_mask = 0x3f, /* udma0-5 */
@@ -228,16 +222,17 @@ static const struct {
228 unsigned long tf; /* ATA taskfile register block */ 222 unsigned long tf; /* ATA taskfile register block */
229 unsigned long ctl; /* ATA control/altstatus register block */ 223 unsigned long ctl; /* ATA control/altstatus register block */
230 unsigned long bmdma; /* DMA register block */ 224 unsigned long bmdma; /* DMA register block */
225 unsigned long fifo_cfg; /* FIFO Valid Byte Count and Control */
231 unsigned long scr; /* SATA control register block */ 226 unsigned long scr; /* SATA control register block */
232 unsigned long sien; /* SATA Interrupt Enable register */ 227 unsigned long sien; /* SATA Interrupt Enable register */
233 unsigned long xfer_mode;/* data transfer mode register */ 228 unsigned long xfer_mode;/* data transfer mode register */
234 unsigned long sfis_cfg; /* SATA FIS reception config register */ 229 unsigned long sfis_cfg; /* SATA FIS reception config register */
235} sil_port[] = { 230} sil_port[] = {
236 /* port 0 ... */ 231 /* port 0 ... */
237 { 0x80, 0x8A, 0x00, 0x100, 0x148, 0xb4, 0x14c }, 232 { 0x80, 0x8A, 0x00, 0x40, 0x100, 0x148, 0xb4, 0x14c },
238 { 0xC0, 0xCA, 0x08, 0x180, 0x1c8, 0xf4, 0x1cc }, 233 { 0xC0, 0xCA, 0x08, 0x44, 0x180, 0x1c8, 0xf4, 0x1cc },
239 { 0x280, 0x28A, 0x200, 0x300, 0x348, 0x2b4, 0x34c }, 234 { 0x280, 0x28A, 0x200, 0x240, 0x300, 0x348, 0x2b4, 0x34c },
240 { 0x2C0, 0x2CA, 0x208, 0x380, 0x3c8, 0x2f4, 0x3cc }, 235 { 0x2C0, 0x2CA, 0x208, 0x244, 0x380, 0x3c8, 0x2f4, 0x3cc },
241 /* ... port 3 */ 236 /* ... port 3 */
242}; 237};
243 238
@@ -418,13 +413,12 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
418 if (rc) 413 if (rc)
419 goto err_out_regions; 414 goto err_out_regions;
420 415
421 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); 416 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
422 if (probe_ent == NULL) { 417 if (probe_ent == NULL) {
423 rc = -ENOMEM; 418 rc = -ENOMEM;
424 goto err_out_regions; 419 goto err_out_regions;
425 } 420 }
426 421
427 memset(probe_ent, 0, sizeof(*probe_ent));
428 INIT_LIST_HEAD(&probe_ent->node); 422 INIT_LIST_HEAD(&probe_ent->node);
429 probe_ent->dev = pci_dev_to_dev(pdev); 423 probe_ent->dev = pci_dev_to_dev(pdev);
430 probe_ent->port_ops = sil_port_info[ent->driver_data].port_ops; 424 probe_ent->port_ops = sil_port_info[ent->driver_data].port_ops;
@@ -461,19 +455,12 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
461 if (cls) { 455 if (cls) {
462 cls >>= 3; 456 cls >>= 3;
463 cls++; /* cls = (line_size/8)+1 */ 457 cls++; /* cls = (line_size/8)+1 */
464 writeb(cls, mmio_base + SIL_FIFO_R0); 458 for (i = 0; i < probe_ent->n_ports; i++)
465 writeb(cls, mmio_base + SIL_FIFO_W0); 459 writew(cls << 8 | cls,
466 writeb(cls, mmio_base + SIL_FIFO_R1); 460 mmio_base + sil_port[i].fifo_cfg);
467 writeb(cls, mmio_base + SIL_FIFO_W1);
468 if (ent->driver_data == sil_3114) {
469 writeb(cls, mmio_base + SIL_FIFO_R2);
470 writeb(cls, mmio_base + SIL_FIFO_W2);
471 writeb(cls, mmio_base + SIL_FIFO_R3);
472 writeb(cls, mmio_base + SIL_FIFO_W3);
473 }
474 } else 461 } else
475 dev_printk(KERN_WARNING, &pdev->dev, 462 dev_printk(KERN_WARNING, &pdev->dev,
476 "cache line size not set. Driver may not function\n"); 463 "cache line size not set. Driver may not function\n");
477 464
478 /* Apply R_ERR on DMA activate FIS errata workaround */ 465 /* Apply R_ERR on DMA activate FIS errata workaround */
479 if (probe_ent->host_flags & SIL_FLAG_RERR_ON_DMA_ACT) { 466 if (probe_ent->host_flags & SIL_FLAG_RERR_ON_DMA_ACT) {
@@ -496,10 +483,10 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
496 irq_mask = SIL_MASK_4PORT; 483 irq_mask = SIL_MASK_4PORT;
497 484
498 /* flip the magic "make 4 ports work" bit */ 485 /* flip the magic "make 4 ports work" bit */
499 tmp = readl(mmio_base + SIL_IDE2_BMDMA); 486 tmp = readl(mmio_base + sil_port[2].bmdma);
500 if ((tmp & SIL_INTR_STEERING) == 0) 487 if ((tmp & SIL_INTR_STEERING) == 0)
501 writel(tmp | SIL_INTR_STEERING, 488 writel(tmp | SIL_INTR_STEERING,
502 mmio_base + SIL_IDE2_BMDMA); 489 mmio_base + sil_port[2].bmdma);
503 490
504 } else { 491 } else {
505 irq_mask = SIL_MASK_2PORT; 492 irq_mask = SIL_MASK_2PORT;
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 5c5822e33a49..8fb62427be84 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -892,6 +892,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
892 probe_ent->sht = pinfo->sht; 892 probe_ent->sht = pinfo->sht;
893 probe_ent->host_flags = pinfo->host_flags; 893 probe_ent->host_flags = pinfo->host_flags;
894 probe_ent->pio_mask = pinfo->pio_mask; 894 probe_ent->pio_mask = pinfo->pio_mask;
895 probe_ent->mwdma_mask = pinfo->mwdma_mask;
895 probe_ent->udma_mask = pinfo->udma_mask; 896 probe_ent->udma_mask = pinfo->udma_mask;
896 probe_ent->port_ops = pinfo->port_ops; 897 probe_ent->port_ops = pinfo->port_ops;
897 probe_ent->n_ports = SIL24_FLAG2NPORTS(pinfo->host_flags); 898 probe_ent->n_ports = SIL24_FLAG2NPORTS(pinfo->host_flags);
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 5d02ff4db6cc..b65462f76484 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -192,7 +192,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
192 SDev = cd->device; 192 SDev = cd->device;
193 193
194 if (!sense) { 194 if (!sense) {
195 sense = kmalloc(sizeof(*sense), GFP_KERNEL); 195 sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
196 if (!sense) { 196 if (!sense) {
197 err = -ENOMEM; 197 err = -ENOMEM;
198 goto out; 198 goto out;
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index f3763d2ccb86..a37579ce6d76 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -2301,7 +2301,6 @@ static void receive_chars(struct uart_port *the_port)
2301 int read_count, request_count = IOC4_MAX_CHARS; 2301 int read_count, request_count = IOC4_MAX_CHARS;
2302 struct uart_icount *icount; 2302 struct uart_icount *icount;
2303 struct uart_info *info = the_port->info; 2303 struct uart_info *info = the_port->info;
2304 int flip = 0;
2305 unsigned long pflags; 2304 unsigned long pflags;
2306 2305
2307 /* Make sure all the pointers are "good" ones */ 2306 /* Make sure all the pointers are "good" ones */
@@ -2313,7 +2312,7 @@ static void receive_chars(struct uart_port *the_port)
2313 spin_lock_irqsave(&the_port->lock, pflags); 2312 spin_lock_irqsave(&the_port->lock, pflags);
2314 tty = info->tty; 2313 tty = info->tty;
2315 2314
2316 request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS - 2); 2315 request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS);
2317 2316
2318 if (request_count > 0) { 2317 if (request_count > 0) {
2319 icount = &the_port->icount; 2318 icount = &the_port->icount;
@@ -2326,8 +2325,7 @@ static void receive_chars(struct uart_port *the_port)
2326 2325
2327 spin_unlock_irqrestore(&the_port->lock, pflags); 2326 spin_unlock_irqrestore(&the_port->lock, pflags);
2328 2327
2329 if (flip) 2328 tty_flip_buffer_push(tty);
2330 tty_flip_buffer_push(tty);
2331} 2329}
2332 2330
2333/** 2331/**
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index 419dd3cd7862..193722d680cf 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -420,10 +420,8 @@ static void ip22zilog_transmit_chars(struct uart_ip22zilog_port *up,
420 if (up->port.info == NULL) 420 if (up->port.info == NULL)
421 goto ack_tx_int; 421 goto ack_tx_int;
422 xmit = &up->port.info->xmit; 422 xmit = &up->port.info->xmit;
423 if (uart_circ_empty(xmit)) { 423 if (uart_circ_empty(xmit))
424 uart_write_wakeup(&up->port);
425 goto ack_tx_int; 424 goto ack_tx_int;
426 }
427 if (uart_tx_stopped(&up->port)) 425 if (uart_tx_stopped(&up->port))
428 goto ack_tx_int; 426 goto ack_tx_int;
429 427
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 95fb4939c675..cc1faa31d124 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -71,6 +71,11 @@ static void uart_change_pm(struct uart_state *state, int pm_state);
71void uart_write_wakeup(struct uart_port *port) 71void uart_write_wakeup(struct uart_port *port)
72{ 72{
73 struct uart_info *info = port->info; 73 struct uart_info *info = port->info;
74 /*
75 * This means you called this function _after_ the port was
76 * closed. No cookie for you.
77 */
78 BUG_ON(!info);
74 tasklet_schedule(&info->tlet); 79 tasklet_schedule(&info->tlet);
75} 80}
76 81
@@ -471,14 +476,26 @@ static void uart_flush_chars(struct tty_struct *tty)
471} 476}
472 477
473static int 478static int
474uart_write(struct tty_struct *tty, const unsigned char * buf, int count) 479uart_write(struct tty_struct *tty, const unsigned char *buf, int count)
475{ 480{
476 struct uart_state *state = tty->driver_data; 481 struct uart_state *state = tty->driver_data;
477 struct uart_port *port = state->port; 482 struct uart_port *port;
478 struct circ_buf *circ = &state->info->xmit; 483 struct circ_buf *circ;
479 unsigned long flags; 484 unsigned long flags;
480 int c, ret = 0; 485 int c, ret = 0;
481 486
487 /*
488 * This means you called this function _after_ the port was
489 * closed. No cookie for you.
490 */
491 if (!state || !state->info) {
492 WARN_ON(1);
493 return -EL3HLT;
494 }
495
496 port = state->port;
497 circ = &state->info->xmit;
498
482 if (!circ->buf) 499 if (!circ->buf)
483 return 0; 500 return 0;
484 501
@@ -521,6 +538,15 @@ static void uart_flush_buffer(struct tty_struct *tty)
521 struct uart_port *port = state->port; 538 struct uart_port *port = state->port;
522 unsigned long flags; 539 unsigned long flags;
523 540
541 /*
542 * This means you called this function _after_ the port was
543 * closed. No cookie for you.
544 */
545 if (!state || !state->info) {
546 WARN_ON(1);
547 return;
548 }
549
524 DPRINTK("uart_flush_buffer(%d) called\n", tty->index); 550 DPRINTK("uart_flush_buffer(%d) called\n", tty->index);
525 551
526 spin_lock_irqsave(&port->lock, flags); 552 spin_lock_irqsave(&port->lock, flags);
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index 43e67d6c29d4..60ea4a3f0713 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -820,7 +820,7 @@ static int __init sn_sal_module_init(void)
820 int retval; 820 int retval;
821 821
822 if (!ia64_platform_is("sn2")) 822 if (!ia64_platform_is("sn2"))
823 return -ENODEV; 823 return 0;
824 824
825 printk(KERN_INFO "sn_console: Console driver init\n"); 825 printk(KERN_INFO "sn_console: Console driver init\n");
826 826
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 4dd6865d32b0..b5c96e74a903 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -242,8 +242,10 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
242 242
243 down(&port->sem); 243 down(&port->sem);
244 244
245 if (port->open_count == 0) 245 if (port->open_count == 0) {
246 goto out; 246 up(&port->sem);
247 return;
248 }
247 249
248 --port->open_count; 250 --port->open_count;
249 if (port->open_count == 0) { 251 if (port->open_count == 0) {
@@ -260,10 +262,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
260 module_put(port->serial->type->driver.owner); 262 module_put(port->serial->type->driver.owner);
261 } 263 }
262 264
263 kref_put(&port->serial->kref, destroy_serial);
264
265out:
266 up(&port->sem); 265 up(&port->sem);
266 kref_put(&port->serial->kref, destroy_serial);
267} 267}
268 268
269static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) 269static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count)
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index df8e5667b348..466042808daf 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -253,7 +253,7 @@ static void arcfb_lcd_update_page(struct arcfb_par *par, unsigned int upper,
253{ 253{
254 unsigned char *src; 254 unsigned char *src;
255 unsigned int xindex, yindex, chipindex, linesize; 255 unsigned int xindex, yindex, chipindex, linesize;
256 int i, count; 256 int i;
257 unsigned char val; 257 unsigned char val;
258 unsigned char bitmask, rightshift; 258 unsigned char bitmask, rightshift;
259 259
@@ -282,7 +282,6 @@ static void arcfb_lcd_update_page(struct arcfb_par *par, unsigned int upper,
282 } 282 }
283 ks108_writeb_data(par, chipindex, val); 283 ks108_writeb_data(par, chipindex, val);
284 left++; 284 left++;
285 count++;
286 if (bitmask == 0x80) { 285 if (bitmask == 0x80) {
287 bitmask = 1; 286 bitmask = 1;
288 src++; 287 src++;
@@ -460,11 +459,11 @@ static ssize_t arcfb_write(struct file *file, const char __user *buf, size_t cou
460 inode = file->f_dentry->d_inode; 459 inode = file->f_dentry->d_inode;
461 fbidx = iminor(inode); 460 fbidx = iminor(inode);
462 info = registered_fb[fbidx]; 461 info = registered_fb[fbidx];
463 par = info->par;
464 462
465 if (!info || !info->screen_base) 463 if (!info || !info->screen_base)
466 return -ENODEV; 464 return -ENODEV;
467 465
466 par = info->par;
468 xres = info->var.xres; 467 xres = info->var.xres;
469 fbmemlength = (xres * info->var.yres)/8; 468 fbmemlength = (xres * info->var.yres)/8;
470 469
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index bfc8a93b2c73..620c9a934e0e 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1326,7 +1326,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
1326 unsigned char post_dividers[] = {1,2,4,8,3,6,12}; 1326 unsigned char post_dividers[] = {1,2,4,8,3,6,12};
1327 u32 output_freq; 1327 u32 output_freq;
1328 u32 vclk; /* in .01 MHz */ 1328 u32 vclk; /* in .01 MHz */
1329 int i; 1329 int i = 0;
1330 u32 n, d; 1330 u32 n, d;
1331 1331
1332 vclk = 100000000 / period_in_ps; /* convert units to 10 kHz */ 1332 vclk = 100000000 / period_in_ps; /* convert units to 10 kHz */
@@ -1340,15 +1340,16 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
1340 /* now, find an acceptable divider */ 1340 /* now, find an acceptable divider */
1341 for (i = 0; i < sizeof(post_dividers); i++) { 1341 for (i = 0; i < sizeof(post_dividers); i++) {
1342 output_freq = post_dividers[i] * vclk; 1342 output_freq = post_dividers[i] * vclk;
1343 if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) 1343 if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) {
1344 pll->post_divider = post_dividers[i];
1344 break; 1345 break;
1346 }
1345 } 1347 }
1346 1348
1347 /* calculate feedback divider */ 1349 /* calculate feedback divider */
1348 n = c.ref_divider * output_freq; 1350 n = c.ref_divider * output_freq;
1349 d = c.ref_clk; 1351 d = c.ref_clk;
1350 1352
1351 pll->post_divider = post_dividers[i];
1352 pll->feedback_divider = round_div(n, d); 1353 pll->feedback_divider = round_div(n, d);
1353 pll->vclk = vclk; 1354 pll->vclk = vclk;
1354 1355
diff --git a/drivers/video/aty/radeon_monitor.c b/drivers/video/aty/radeon_monitor.c
index 7f9838dceab5..98c05bc0de44 100644
--- a/drivers/video/aty/radeon_monitor.c
+++ b/drivers/video/aty/radeon_monitor.c
@@ -396,6 +396,10 @@ static int __devinit radeon_parse_monitor_layout(struct radeonfb_info *rinfo,
396 s1[i] = *s; 396 s1[i] = *s;
397 i++; 397 i++;
398 } 398 }
399
400 if (i > 4)
401 i = 4;
402
399 } while (*s++); 403 } while (*s++);
400 if (second) 404 if (second)
401 s2[i] = 0; 405 s2[i] = 0;
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index bd39bbd88d41..151fda8dded0 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -172,7 +172,7 @@ struct backlight_device *backlight_device_register(const char *name, void *devda
172 172
173 new_bd = kmalloc(sizeof(struct backlight_device), GFP_KERNEL); 173 new_bd = kmalloc(sizeof(struct backlight_device), GFP_KERNEL);
174 if (unlikely(!new_bd)) 174 if (unlikely(!new_bd))
175 return ERR_PTR(ENOMEM); 175 return ERR_PTR(-ENOMEM);
176 176
177 init_MUTEX(&new_bd->sem); 177 init_MUTEX(&new_bd->sem);
178 new_bd->props = bp; 178 new_bd->props = bp;
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 9e32485ee7bb..86908a60c630 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -171,7 +171,7 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
171 171
172 new_ld = kmalloc(sizeof(struct lcd_device), GFP_KERNEL); 172 new_ld = kmalloc(sizeof(struct lcd_device), GFP_KERNEL);
173 if (unlikely(!new_ld)) 173 if (unlikely(!new_ld))
174 return ERR_PTR(ENOMEM); 174 return ERR_PTR(-ENOMEM);
175 175
176 init_MUTEX(&new_ld->sem); 176 init_MUTEX(&new_ld->sem);
177 new_ld->props = lp; 177 new_ld->props = lp;
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index ad416ae47596..7db42542eb19 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -1510,6 +1510,8 @@ imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1510 default: 1510 default:
1511 printk(KERN_INFO "imsttfb: Device 0x%x unknown, " 1511 printk(KERN_INFO "imsttfb: Device 0x%x unknown, "
1512 "contact maintainer.\n", pdev->device); 1512 "contact maintainer.\n", pdev->device);
1513 release_mem_region(addr, size);
1514 framebuffer_release(info);
1513 return -ENODEV; 1515 return -ENODEV;
1514 } 1516 }
1515 1517
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 6b8bd3cdf9c0..995b47c165a7 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -1333,33 +1333,35 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
1333 if (regno > 255) 1333 if (regno > 255)
1334 return 1; 1334 return 1;
1335 1335
1336 switch (dinfo->depth) { 1336 if (dinfo->depth == 8) {
1337 case 8: 1337 red >>= 8;
1338 { 1338 green >>= 8;
1339 red >>= 8; 1339 blue >>= 8;
1340 green >>= 8; 1340
1341 blue >>= 8; 1341 intelfbhw_setcolreg(dinfo, regno, red, green, blue,
1342 transp);
1343 }
1342 1344
1343 intelfbhw_setcolreg(dinfo, regno, red, green, blue, 1345 if (regno < 16) {
1344 transp); 1346 switch (dinfo->depth) {
1347 case 15:
1348 dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
1349 ((green & 0xf800) >> 6) |
1350 ((blue & 0xf800) >> 11);
1351 break;
1352 case 16:
1353 dinfo->pseudo_palette[regno] = (red & 0xf800) |
1354 ((green & 0xfc00) >> 5) |
1355 ((blue & 0xf800) >> 11);
1356 break;
1357 case 24:
1358 dinfo->pseudo_palette[regno] = ((red & 0xff00) << 8) |
1359 (green & 0xff00) |
1360 ((blue & 0xff00) >> 8);
1361 break;
1345 } 1362 }
1346 break;
1347 case 15:
1348 dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
1349 ((green & 0xf800) >> 6) |
1350 ((blue & 0xf800) >> 11);
1351 break;
1352 case 16:
1353 dinfo->pseudo_palette[regno] = (red & 0xf800) |
1354 ((green & 0xfc00) >> 5) |
1355 ((blue & 0xf800) >> 11);
1356 break;
1357 case 24:
1358 dinfo->pseudo_palette[regno] = ((red & 0xff00) << 8) |
1359 (green & 0xff00) |
1360 ((blue & 0xff00) >> 8);
1361 break;
1362 } 1363 }
1364
1363 return 0; 1365 return 0;
1364} 1366}
1365 1367
diff --git a/drivers/video/kyro/STG4000VTG.c b/drivers/video/kyro/STG4000VTG.c
index 3690b04190af..bd389709d234 100644
--- a/drivers/video/kyro/STG4000VTG.c
+++ b/drivers/video/kyro/STG4000VTG.c
@@ -17,7 +17,7 @@
17void DisableVGA(volatile STG4000REG __iomem *pSTGReg) 17void DisableVGA(volatile STG4000REG __iomem *pSTGReg)
18{ 18{
19 u32 tmp; 19 u32 tmp;
20 volatile u32 count, i; 20 volatile u32 count = 0, i;
21 21
22 /* Reset the VGA registers */ 22 /* Reset the VGA registers */
23 tmp = STG_READ_REG(SoftwareReset); 23 tmp = STG_READ_REG(SoftwareReset);
diff --git a/drivers/video/neofb.c b/drivers/video/neofb.c
index a2e201dc40f7..b961d5601bd9 100644
--- a/drivers/video/neofb.c
+++ b/drivers/video/neofb.c
@@ -486,10 +486,8 @@ static void vgaHWRestore(const struct fb_info *info,
486static inline int neo2200_sync(struct fb_info *info) 486static inline int neo2200_sync(struct fb_info *info)
487{ 487{
488 struct neofb_par *par = info->par; 488 struct neofb_par *par = info->par;
489 int waitcycles;
490 489
491 while (readl(&par->neo2200->bltStat) & 1) 490 while (readl(&par->neo2200->bltStat) & 1);
492 waitcycles++;
493 return 0; 491 return 0;
494} 492}
495 493
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index e5d0f92eeae3..feec47bdd479 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -588,6 +588,7 @@ s1d13xxxfb_probe(struct platform_device *pdev)
588 goto bail; 588 goto bail;
589 } 589 }
590 590
591 platform_set_drvdata(pdev, info);
591 default_par = info->par; 592 default_par = info->par;
592 default_par->regs = ioremap_nocache(pdev->resource[1].start, 593 default_par->regs = ioremap_nocache(pdev->resource[1].start,
593 pdev->resource[1].end - pdev->resource[1].start +1); 594 pdev->resource[1].end - pdev->resource[1].start +1);
@@ -638,8 +639,6 @@ s1d13xxxfb_probe(struct platform_device *pdev)
638 goto bail; 639 goto bail;
639 } 640 }
640 641
641 platform_set_drvdata(pdev, info);
642
643 printk(KERN_INFO "fb%d: %s frame buffer device\n", 642 printk(KERN_INFO "fb%d: %s frame buffer device\n",
644 info->node, info->fix.id); 643 info->node, info->fix.id);
645 644
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index ab727eaa7f43..10e6b3aab9ea 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -2021,8 +2021,8 @@ static int __devinit savagefb_probe (struct pci_dev* dev,
2021#if defined(CONFIG_FB_SAVAGE_I2C) 2021#if defined(CONFIG_FB_SAVAGE_I2C)
2022 savagefb_create_i2c_busses(info); 2022 savagefb_create_i2c_busses(info);
2023 savagefb_probe_i2c_connector(info, &par->edid); 2023 savagefb_probe_i2c_connector(info, &par->edid);
2024 kfree(par->edid);
2025 fb_edid_to_monspecs(par->edid, &info->monspecs); 2024 fb_edid_to_monspecs(par->edid, &info->monspecs);
2025 kfree(par->edid);
2026 fb_videomode_to_modelist(info->monspecs.modedb, 2026 fb_videomode_to_modelist(info->monspecs.modedb,
2027 info->monspecs.modedb_len, 2027 info->monspecs.modedb_len,
2028 &info->modelist); 2028 &info->modelist);
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index 3e7baf4c9fa8..5e5328d682db 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -786,28 +786,32 @@ static int tdfxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
786 if (regno >= info->cmap.len || regno > 255) return 1; 786 if (regno >= info->cmap.len || regno > 255) return 1;
787 787
788 switch (info->fix.visual) { 788 switch (info->fix.visual) {
789 case FB_VISUAL_PSEUDOCOLOR: 789 case FB_VISUAL_PSEUDOCOLOR:
790 rgbcol =(((u32)red & 0xff00) << 8) | 790 rgbcol =(((u32)red & 0xff00) << 8) |
791 (((u32)green & 0xff00) << 0) | 791 (((u32)green & 0xff00) << 0) |
792 (((u32)blue & 0xff00) >> 8); 792 (((u32)blue & 0xff00) >> 8);
793 do_setpalentry(par, regno, rgbcol); 793 do_setpalentry(par, regno, rgbcol);
794 break; 794 break;
795 /* Truecolor has no hardware color palettes. */ 795 /* Truecolor has no hardware color palettes. */
796 case FB_VISUAL_TRUECOLOR: 796 case FB_VISUAL_TRUECOLOR:
797 if (regno < 16) {
797 rgbcol = (CNVT_TOHW( red, info->var.red.length) << 798 rgbcol = (CNVT_TOHW( red, info->var.red.length) <<
798 info->var.red.offset) | 799 info->var.red.offset) |
799 (CNVT_TOHW( green, info->var.green.length) << 800 (CNVT_TOHW( green, info->var.green.length) <<
800 info->var.green.offset) | 801 info->var.green.offset) |
801 (CNVT_TOHW( blue, info->var.blue.length) << 802 (CNVT_TOHW( blue, info->var.blue.length) <<
802 info->var.blue.offset) | 803 info->var.blue.offset) |
803 (CNVT_TOHW( transp, info->var.transp.length) << 804 (CNVT_TOHW( transp, info->var.transp.length) <<
804 info->var.transp.offset); 805 info->var.transp.offset);
805 par->palette[regno] = rgbcol; 806 par->palette[regno] = rgbcol;
806 break; 807 }
807 default: 808
808 DPRINTK("bad depth %u\n", info->var.bits_per_pixel); 809 break;
809 break; 810 default:
811 DPRINTK("bad depth %u\n", info->var.bits_per_pixel);
812 break;
810 } 813 }
814
811 return 0; 815 return 0;
812} 816}
813 817