aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt19
-rw-r--r--drivers/ata/Kconfig36
-rw-r--r--drivers/ata/Makefile2
-rw-r--r--drivers/ata/ahci.c5
-rw-r--r--drivers/ata/ata_generic.c12
-rw-r--r--drivers/ata/ata_piix.c8
-rw-r--r--drivers/ata/libata-acpi.c192
-rw-r--r--drivers/ata/libata-core.c72
-rw-r--r--drivers/ata/libata-eh.c246
-rw-r--r--drivers/ata/libata-scsi.c157
-rw-r--r--drivers/ata/libata-sff.c162
-rw-r--r--drivers/ata/libata.h7
-rw-r--r--drivers/ata/pata_ali.c36
-rw-r--r--drivers/ata/pata_amd.c13
-rw-r--r--drivers/ata/pata_artop.c25
-rw-r--r--drivers/ata/pata_atiixp.c10
-rw-r--r--drivers/ata/pata_cmd640.c11
-rw-r--r--drivers/ata/pata_cmd64x.c17
-rw-r--r--drivers/ata/pata_cs5520.c4
-rw-r--r--drivers/ata/pata_cs5530.c14
-rw-r--r--drivers/ata/pata_cs5535.c10
-rw-r--r--drivers/ata/pata_cypress.c10
-rw-r--r--drivers/ata/pata_efar.c10
-rw-r--r--drivers/ata/pata_hpt366.c17
-rw-r--r--drivers/ata/pata_hpt37x.c33
-rw-r--r--drivers/ata/pata_hpt3x2n.c13
-rw-r--r--drivers/ata/pata_hpt3x3.c10
-rw-r--r--drivers/ata/pata_it8213.c12
-rw-r--r--drivers/ata/pata_it821x.c16
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c2
-rw-r--r--drivers/ata/pata_jmicron.c10
-rw-r--r--drivers/ata/pata_marvell.c15
-rw-r--r--drivers/ata/pata_mpc52xx.c4
-rw-r--r--drivers/ata/pata_mpiix.c4
-rw-r--r--drivers/ata/pata_netcell.c10
-rw-r--r--drivers/ata/pata_ns87410.c10
-rw-r--r--drivers/ata/pata_oldpiix.c10
-rw-r--r--drivers/ata/pata_opti.c10
-rw-r--r--drivers/ata/pata_optidma.c16
-rw-r--r--drivers/ata/pata_pcmcia.c1
-rw-r--r--drivers/ata/pata_pdc202xx_old.c12
-rw-r--r--drivers/ata/pata_platform.c4
-rw-r--r--drivers/ata/pata_radisys.c10
-rw-r--r--drivers/ata/pata_rz1000.c18
-rw-r--r--drivers/ata/pata_sc1200.c12
-rw-r--r--drivers/ata/pata_scc.c4
-rw-r--r--drivers/ata/pata_serverworks.c19
-rw-r--r--drivers/ata/pata_sil680.c14
-rw-r--r--drivers/ata/pata_sis.c33
-rw-r--r--drivers/ata/pata_sl82c105.c17
-rw-r--r--drivers/ata/pata_triflex.c10
-rw-r--r--drivers/ata/pata_via.c36
-rw-r--r--drivers/ata/sata_inic162x.c4
-rw-r--r--drivers/ata/sata_nv.c16
-rw-r--r--drivers/ata/sata_sil.c4
-rw-r--r--drivers/ata/sata_sil24.c4
-rw-r--r--drivers/ata/sata_sis.c6
-rw-r--r--drivers/ata/sata_uli.c22
-rw-r--r--drivers/ata/sata_via.c6
-rw-r--r--drivers/ata/sis.h2
-rw-r--r--drivers/atm/Kconfig32
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c2
-rw-r--r--drivers/net/Kconfig16
-rw-r--r--drivers/net/mlx4/eq.c2
-rw-r--r--drivers/net/netxen/netxen_nic_main.c2
-rw-r--r--drivers/net/pcmcia/Kconfig23
-rw-r--r--drivers/net/phy/Kconfig22
-rw-r--r--drivers/net/phy/davicom.c34
-rw-r--r--drivers/net/s2io.c368
-rw-r--r--drivers/net/s2io.h32
-rw-r--r--drivers/net/skge.c9
-rw-r--r--drivers/net/sky2.c53
-rw-r--r--drivers/net/spider_net.c8
-rw-r--r--drivers/net/wan/Kconfig34
-rw-r--r--drivers/net/wireless/libertas/Makefile9
-rw-r--r--drivers/net/wireless/libertas/README516
-rw-r--r--drivers/net/wireless/libertas/assoc.c41
-rw-r--r--drivers/net/wireless/libertas/cmd.c23
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c4
-rw-r--r--drivers/net/wireless/libertas/debugfs.c31
-rw-r--r--drivers/net/wireless/libertas/defs.h52
-rw-r--r--drivers/net/wireless/libertas/dev.h14
-rw-r--r--drivers/net/wireless/libertas/fw.c9
-rw-r--r--drivers/net/wireless/libertas/if_usb.c5
-rw-r--r--drivers/net/wireless/libertas/if_usb.h2
-rw-r--r--drivers/net/wireless/libertas/ioctl.c1529
-rw-r--r--drivers/net/wireless/libertas/join.c194
-rw-r--r--drivers/net/wireless/libertas/join.h7
-rw-r--r--drivers/net/wireless/libertas/main.c7
-rw-r--r--drivers/net/wireless/libertas/rx.c4
-rw-r--r--drivers/net/wireless/libertas/scan.c203
-rw-r--r--drivers/net/wireless/libertas/scan.h22
-rw-r--r--drivers/net/wireless/libertas/tx.c2
-rw-r--r--drivers/net/wireless/libertas/version.h7
-rw-r--r--drivers/net/wireless/libertas/wext.c448
-rw-r--r--drivers/net/wireless/libertas/wext.h85
-rw-r--r--drivers/pci/msi.c6
-rw-r--r--drivers/pci/quirks.c1
-rw-r--r--include/linux/libata.h31
-rw-r--r--include/linux/pci_ids.h1
100 files changed, 1287 insertions, 4127 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index c6322c760348..498ff31f3aa1 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -328,3 +328,22 @@ Who: Adrian Bunk <bunk@stusta.de>
328 328
329--------------------------- 329---------------------------
330 330
331What: libata.spindown_compat module parameter
332When: Dec 2008
333Why: halt(8) synchronizes caches for and spins down libata disks
334 because libata didn't use to spin down disk on system halt
335 (only synchronized caches).
336 Spin down on system halt is now implemented and can be tested
337 using sysfs node /sys/class/scsi_disk/h:c:i:l/manage_start_stop.
338 Because issuing spin down command to an already spun down disk
339 makes some disks spin up just to spin down again, the old
340 behavior needs to be maintained till userspace tool is updated
341 to check the sysfs node and not to spin down disks with the
342 node set to one.
343 This module parameter is to give userspace tool the time to
344 get updated and should be removed after userspace is
345 reasonably updated.
346Who: Tejun Heo <htejun@gmail.com>
347
348---------------------------
349
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index f031b8732330..ad1f59c1b3fc 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -2,11 +2,9 @@
2# SATA/PATA driver configuration 2# SATA/PATA driver configuration
3# 3#
4 4
5menu "Serial ATA (prod) and Parallel ATA (experimental) drivers" 5menuconfig ATA
6 tristate "Serial ATA (prod) and Parallel ATA (experimental) drivers"
6 depends on HAS_IOMEM 7 depends on HAS_IOMEM
7
8config ATA
9 tristate "ATA device support"
10 depends on BLOCK 8 depends on BLOCK
11 depends on !(M32R || M68K) || BROKEN 9 depends on !(M32R || M68K) || BROKEN
12 depends on !SUN4 || BROKEN 10 depends on !SUN4 || BROKEN
@@ -24,6 +22,19 @@ config ATA_NONSTANDARD
24 bool 22 bool
25 default n 23 default n
26 24
25config ATA_ACPI
26 bool
27 depends on ACPI && PCI
28 default y
29 help
30 This option adds support for ATA-related ACPI objects.
31 These ACPI objects add the ability to retrieve taskfiles
32 from the ACPI BIOS and write them to the disk controller.
33 These objects may be related to performance, security,
34 power management, or other areas.
35 You can disable this at kernel boot time by using the
36 option libata.noacpi=1
37
27config SATA_AHCI 38config SATA_AHCI
28 tristate "AHCI SATA support" 39 tristate "AHCI SATA support"
29 depends on PCI 40 depends on PCI
@@ -157,19 +168,6 @@ config SATA_INIC162X
157 help 168 help
158 This option enables support for Initio 162x Serial ATA. 169 This option enables support for Initio 162x Serial ATA.
159 170
160config SATA_ACPI
161 bool
162 depends on ACPI && PCI
163 default y
164 help
165 This option adds support for SATA-related ACPI objects.
166 These ACPI objects add the ability to retrieve taskfiles
167 from the ACPI BIOS and write them to the disk controller.
168 These objects may be related to performance, security,
169 power management, or other areas.
170 You can disable this at kernel boot time by using the
171 option libata.noacpi=1
172
173config PATA_ALI 171config PATA_ALI
174 tristate "ALi PATA support (Experimental)" 172 tristate "ALi PATA support (Experimental)"
175 depends on PCI && EXPERIMENTAL 173 depends on PCI && EXPERIMENTAL
@@ -585,6 +583,4 @@ config PATA_SCC
585 583
586 If unsure, say N. 584 If unsure, say N.
587 585
588endif 586endif # ATA
589endmenu
590
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 6f42a0e2812d..8149c68ac2c7 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -69,4 +69,4 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o
69obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o 69obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o
70 70
71libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o 71libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o
72libata-$(CONFIG_SATA_ACPI) += libata-acpi.o 72libata-$(CONFIG_ATA_ACPI) += libata-acpi.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index d9617892fc23..1ae443d7ab92 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -250,10 +250,6 @@ static struct scsi_host_template ahci_sht = {
250 .slave_configure = ata_scsi_slave_config, 250 .slave_configure = ata_scsi_slave_config,
251 .slave_destroy = ata_scsi_slave_destroy, 251 .slave_destroy = ata_scsi_slave_destroy,
252 .bios_param = ata_std_bios_param, 252 .bios_param = ata_std_bios_param,
253#ifdef CONFIG_PM
254 .suspend = ata_scsi_device_suspend,
255 .resume = ata_scsi_device_resume,
256#endif
257}; 253};
258 254
259static const struct ata_port_operations ahci_ops = { 255static const struct ata_port_operations ahci_ops = {
@@ -400,6 +396,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
400 396
401 /* ATI */ 397 /* ATI */
402 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ 398 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
399 { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 */
403 400
404 /* VIA */ 401 /* VIA */
405 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ 402 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 92a491ddd030..c3d753296bc6 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -54,7 +54,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)
54 54
55 for (i = 0; i < ATA_MAX_DEVICES; i++) { 55 for (i = 0; i < ATA_MAX_DEVICES; i++) {
56 struct ata_device *dev = &ap->device[i]; 56 struct ata_device *dev = &ap->device[i];
57 if (ata_dev_ready(dev)) { 57 if (ata_dev_enabled(dev)) {
58 /* We don't really care */ 58 /* We don't really care */
59 dev->pio_mode = XFER_PIO_0; 59 dev->pio_mode = XFER_PIO_0;
60 dev->dma_mode = XFER_MW_DMA_0; 60 dev->dma_mode = XFER_MW_DMA_0;
@@ -90,10 +90,6 @@ static struct scsi_host_template generic_sht = {
90 .slave_configure = ata_scsi_slave_config, 90 .slave_configure = ata_scsi_slave_config,
91 .slave_destroy = ata_scsi_slave_destroy, 91 .slave_destroy = ata_scsi_slave_destroy,
92 .bios_param = ata_std_bios_param, 92 .bios_param = ata_std_bios_param,
93#ifdef CONFIG_PM
94 .resume = ata_scsi_device_resume,
95 .suspend = ata_scsi_device_suspend,
96#endif
97}; 93};
98 94
99static struct ata_port_operations generic_port_ops = { 95static struct ata_port_operations generic_port_ops = {
@@ -145,7 +141,7 @@ static int all_generic_ide; /* Set to claim all devices */
145static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) 141static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
146{ 142{
147 u16 command; 143 u16 command;
148 static struct ata_port_info info = { 144 static const struct ata_port_info info = {
149 .sht = &generic_sht, 145 .sht = &generic_sht,
150 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 146 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
151 .pio_mask = 0x1f, 147 .pio_mask = 0x1f,
@@ -153,7 +149,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
153 .udma_mask = 0x3f, 149 .udma_mask = 0x3f,
154 .port_ops = &generic_port_ops 150 .port_ops = &generic_port_ops
155 }; 151 };
156 static struct ata_port_info *port_info[2] = { &info, &info }; 152 const struct ata_port_info *ppi[] = { &info, NULL };
157 153
158 /* Don't use the generic entry unless instructed to do so */ 154 /* Don't use the generic entry unless instructed to do so */
159 if (id->driver_data == 1 && all_generic_ide == 0) 155 if (id->driver_data == 1 && all_generic_ide == 0)
@@ -179,7 +175,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
179 if (dev->vendor == PCI_VENDOR_ID_AL) 175 if (dev->vendor == PCI_VENDOR_ID_AL)
180 ata_pci_clear_simplex(dev); 176 ata_pci_clear_simplex(dev);
181 177
182 return ata_pci_init_one(dev, port_info, 2); 178 return ata_pci_init_one(dev, ppi);
183} 179}
184 180
185static struct pci_device_id ata_generic[] = { 181static struct pci_device_id ata_generic[] = {
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 4a795fdb6a02..13b6b1df2ac4 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -275,10 +275,6 @@ static struct scsi_host_template piix_sht = {
275 .slave_configure = ata_scsi_slave_config, 275 .slave_configure = ata_scsi_slave_config,
276 .slave_destroy = ata_scsi_slave_destroy, 276 .slave_destroy = ata_scsi_slave_destroy,
277 .bios_param = ata_std_bios_param, 277 .bios_param = ata_std_bios_param,
278#ifdef CONFIG_PM
279 .resume = ata_scsi_device_resume,
280 .suspend = ata_scsi_device_suspend,
281#endif
282}; 278};
283 279
284static const struct ata_port_operations piix_pata_ops = { 280static const struct ata_port_operations piix_pata_ops = {
@@ -1034,7 +1030,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1034 static int printed_version; 1030 static int printed_version;
1035 struct device *dev = &pdev->dev; 1031 struct device *dev = &pdev->dev;
1036 struct ata_port_info port_info[2]; 1032 struct ata_port_info port_info[2];
1037 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; 1033 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
1038 struct piix_host_priv *hpriv; 1034 struct piix_host_priv *hpriv;
1039 unsigned long port_flags; 1035 unsigned long port_flags;
1040 1036
@@ -1093,7 +1089,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1093 port_info[1].mwdma_mask = 0; 1089 port_info[1].mwdma_mask = 0;
1094 port_info[1].udma_mask = 0; 1090 port_info[1].udma_mask = 0;
1095 } 1091 }
1096 return ata_pci_init_one(pdev, ppinfo, 2); 1092 return ata_pci_init_one(pdev, ppi);
1097} 1093}
1098 1094
1099static int __init piix_init(void) 1095static int __init piix_init(void)
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index cb3eab6e379d..ed4138e24b0c 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -270,8 +270,7 @@ out:
270 270
271/** 271/**
272 * do_drive_get_GTF - get the drive bootup default taskfile settings 272 * do_drive_get_GTF - get the drive bootup default taskfile settings
273 * @ap: the ata_port for the drive 273 * @dev: target ATA device
274 * @ix: target ata_device (drive) index
275 * @gtf_length: number of bytes of _GTF data returned at @gtf_address 274 * @gtf_length: number of bytes of _GTF data returned at @gtf_address
276 * @gtf_address: buffer containing _GTF taskfile arrays 275 * @gtf_address: buffer containing _GTF taskfile arrays
277 * 276 *
@@ -286,20 +285,19 @@ out:
286 * The returned @gtf_length and @gtf_address are only valid if the 285 * The returned @gtf_length and @gtf_address are only valid if the
287 * function return value is 0. 286 * function return value is 0.
288 */ 287 */
289static int do_drive_get_GTF(struct ata_port *ap, int ix, 288static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
290 unsigned int *gtf_length, unsigned long *gtf_address, 289 unsigned long *gtf_address, unsigned long *obj_loc)
291 unsigned long *obj_loc)
292{ 290{
293 acpi_status status; 291 struct ata_port *ap = dev->ap;
294 acpi_handle dev_handle = NULL; 292 acpi_status status;
295 acpi_handle chan_handle, drive_handle; 293 acpi_handle dev_handle = NULL;
296 acpi_integer pcidevfn = 0; 294 acpi_handle chan_handle, drive_handle;
297 u32 dev_adr; 295 acpi_integer pcidevfn = 0;
298 struct acpi_buffer output; 296 u32 dev_adr;
299 union acpi_object *out_obj; 297 struct acpi_buffer output;
300 struct device *dev = ap->host->dev; 298 union acpi_object *out_obj;
301 struct ata_device *atadev = &ap->device[ix]; 299 struct device *gdev = ap->host->dev;
302 int err = -ENODEV; 300 int err = -ENODEV;
303 301
304 *gtf_length = 0; 302 *gtf_length = 0;
305 *gtf_address = 0UL; 303 *gtf_address = 0UL;
@@ -309,14 +307,14 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
309 return 0; 307 return 0;
310 308
311 if (ata_msg_probe(ap)) 309 if (ata_msg_probe(ap))
312 ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 310 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
313 __FUNCTION__, ap->port_no); 311 __FUNCTION__, ap->port_no);
314 312
315 if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { 313 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) {
316 if (ata_msg_probe(ap)) 314 if (ata_msg_probe(ap))
317 ata_dev_printk(atadev, KERN_DEBUG, "%s: ERR: " 315 ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: "
318 "ata_dev_present: %d, PORT_DISABLED: %lu\n", 316 "ata_dev_present: %d, PORT_DISABLED: %lu\n",
319 __FUNCTION__, ata_dev_enabled(atadev), 317 __FUNCTION__, ata_dev_enabled(dev),
320 ap->flags & ATA_FLAG_DISABLED); 318 ap->flags & ATA_FLAG_DISABLED);
321 goto out; 319 goto out;
322 } 320 }
@@ -324,19 +322,19 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
324 /* Don't continue if device has no _ADR method. 322 /* Don't continue if device has no _ADR method.
325 * _GTF is intended for known motherboard devices. */ 323 * _GTF is intended for known motherboard devices. */
326 if (!(ap->cbl == ATA_CBL_SATA)) { 324 if (!(ap->cbl == ATA_CBL_SATA)) {
327 err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); 325 err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
328 if (err < 0) { 326 if (err < 0) {
329 if (ata_msg_probe(ap)) 327 if (ata_msg_probe(ap))
330 ata_dev_printk(atadev, KERN_DEBUG, 328 ata_dev_printk(dev, KERN_DEBUG,
331 "%s: pata_get_dev_handle failed (%d)\n", 329 "%s: pata_get_dev_handle failed (%d)\n",
332 __FUNCTION__, err); 330 __FUNCTION__, err);
333 goto out; 331 goto out;
334 } 332 }
335 } else { 333 } else {
336 err = sata_get_dev_handle(dev, &dev_handle, &pcidevfn); 334 err = sata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
337 if (err < 0) { 335 if (err < 0) {
338 if (ata_msg_probe(ap)) 336 if (ata_msg_probe(ap))
339 ata_dev_printk(atadev, KERN_DEBUG, 337 ata_dev_printk(dev, KERN_DEBUG,
340 "%s: sata_get_dev_handle failed (%d\n", 338 "%s: sata_get_dev_handle failed (%d\n",
341 __FUNCTION__, err); 339 __FUNCTION__, err);
342 goto out; 340 goto out;
@@ -344,7 +342,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
344 } 342 }
345 343
346 /* Get this drive's _ADR info. if not already known. */ 344 /* Get this drive's _ADR info. if not already known. */
347 if (!atadev->obj_handle) { 345 if (!dev->obj_handle) {
348 if (!(ap->cbl == ATA_CBL_SATA)) { 346 if (!(ap->cbl == ATA_CBL_SATA)) {
349 /* get child objects of dev_handle == channel objects, 347 /* get child objects of dev_handle == channel objects,
350 * + _their_ children == drive objects */ 348 * + _their_ children == drive objects */
@@ -352,7 +350,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
352 chan_handle = acpi_get_child(dev_handle, 350 chan_handle = acpi_get_child(dev_handle,
353 ap->port_no); 351 ap->port_no);
354 if (ata_msg_probe(ap)) 352 if (ata_msg_probe(ap))
355 ata_dev_printk(atadev, KERN_DEBUG, 353 ata_dev_printk(dev, KERN_DEBUG,
356 "%s: chan adr=%d: chan_handle=0x%p\n", 354 "%s: chan adr=%d: chan_handle=0x%p\n",
357 __FUNCTION__, ap->port_no, 355 __FUNCTION__, ap->port_no,
358 chan_handle); 356 chan_handle);
@@ -361,26 +359,26 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
361 goto out; 359 goto out;
362 } 360 }
363 /* TBD: could also check ACPI object VALID bits */ 361 /* TBD: could also check ACPI object VALID bits */
364 drive_handle = acpi_get_child(chan_handle, ix); 362 drive_handle = acpi_get_child(chan_handle, dev->devno);
365 if (!drive_handle) { 363 if (!drive_handle) {
366 err = -ENODEV; 364 err = -ENODEV;
367 goto out; 365 goto out;
368 } 366 }
369 dev_adr = ix; 367 dev_adr = dev->devno;
370 atadev->obj_handle = drive_handle; 368 dev->obj_handle = drive_handle;
371 } else { /* for SATA mode */ 369 } else { /* for SATA mode */
372 dev_adr = SATA_ADR_RSVD; 370 dev_adr = SATA_ADR_RSVD;
373 err = get_sata_adr(dev, dev_handle, pcidevfn, 0, 371 err = get_sata_adr(gdev, dev_handle, pcidevfn, 0,
374 ap, atadev, &dev_adr); 372 ap, dev, &dev_adr);
375 } 373 }
376 if (err < 0 || dev_adr == SATA_ADR_RSVD || 374 if (err < 0 || dev_adr == SATA_ADR_RSVD ||
377 !atadev->obj_handle) { 375 !dev->obj_handle) {
378 if (ata_msg_probe(ap)) 376 if (ata_msg_probe(ap))
379 ata_dev_printk(atadev, KERN_DEBUG, 377 ata_dev_printk(dev, KERN_DEBUG,
380 "%s: get_sata/pata_adr failed: " 378 "%s: get_sata/pata_adr failed: "
381 "err=%d, dev_adr=%u, obj_handle=0x%p\n", 379 "err=%d, dev_adr=%u, obj_handle=0x%p\n",
382 __FUNCTION__, err, dev_adr, 380 __FUNCTION__, err, dev_adr,
383 atadev->obj_handle); 381 dev->obj_handle);
384 goto out; 382 goto out;
385 } 383 }
386 } 384 }
@@ -391,11 +389,11 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
391 389
392 /* _GTF has no input parameters */ 390 /* _GTF has no input parameters */
393 err = -EIO; 391 err = -EIO;
394 status = acpi_evaluate_object(atadev->obj_handle, "_GTF", 392 status = acpi_evaluate_object(dev->obj_handle, "_GTF",
395 NULL, &output); 393 NULL, &output);
396 if (ACPI_FAILURE(status)) { 394 if (ACPI_FAILURE(status)) {
397 if (ata_msg_probe(ap)) 395 if (ata_msg_probe(ap))
398 ata_dev_printk(atadev, KERN_DEBUG, 396 ata_dev_printk(dev, KERN_DEBUG,
399 "%s: Run _GTF error: status = 0x%x\n", 397 "%s: Run _GTF error: status = 0x%x\n",
400 __FUNCTION__, status); 398 __FUNCTION__, status);
401 goto out; 399 goto out;
@@ -403,7 +401,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
403 401
404 if (!output.length || !output.pointer) { 402 if (!output.length || !output.pointer) {
405 if (ata_msg_probe(ap)) 403 if (ata_msg_probe(ap))
406 ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " 404 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: "
407 "length or ptr is NULL (0x%llx, 0x%p)\n", 405 "length or ptr is NULL (0x%llx, 0x%p)\n",
408 __FUNCTION__, 406 __FUNCTION__,
409 (unsigned long long)output.length, 407 (unsigned long long)output.length,
@@ -416,7 +414,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
416 if (out_obj->type != ACPI_TYPE_BUFFER) { 414 if (out_obj->type != ACPI_TYPE_BUFFER) {
417 kfree(output.pointer); 415 kfree(output.pointer);
418 if (ata_msg_probe(ap)) 416 if (ata_msg_probe(ap))
419 ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " 417 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: "
420 "error: expected object type of " 418 "error: expected object type of "
421 " ACPI_TYPE_BUFFER, got 0x%x\n", 419 " ACPI_TYPE_BUFFER, got 0x%x\n",
422 __FUNCTION__, out_obj->type); 420 __FUNCTION__, out_obj->type);
@@ -427,7 +425,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
427 if (!out_obj->buffer.length || !out_obj->buffer.pointer || 425 if (!out_obj->buffer.length || !out_obj->buffer.pointer ||
428 out_obj->buffer.length % REGS_PER_GTF) { 426 out_obj->buffer.length % REGS_PER_GTF) {
429 if (ata_msg_drv(ap)) 427 if (ata_msg_drv(ap))
430 ata_dev_printk(atadev, KERN_ERR, 428 ata_dev_printk(dev, KERN_ERR,
431 "%s: unexpected GTF length (%d) or addr (0x%p)\n", 429 "%s: unexpected GTF length (%d) or addr (0x%p)\n",
432 __FUNCTION__, out_obj->buffer.length, 430 __FUNCTION__, out_obj->buffer.length,
433 out_obj->buffer.pointer); 431 out_obj->buffer.pointer);
@@ -439,7 +437,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
439 *gtf_address = (unsigned long)out_obj->buffer.pointer; 437 *gtf_address = (unsigned long)out_obj->buffer.pointer;
440 *obj_loc = (unsigned long)out_obj; 438 *obj_loc = (unsigned long)out_obj;
441 if (ata_msg_probe(ap)) 439 if (ata_msg_probe(ap))
442 ata_dev_printk(atadev, KERN_DEBUG, "%s: returning " 440 ata_dev_printk(dev, KERN_DEBUG, "%s: returning "
443 "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", 441 "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n",
444 __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); 442 __FUNCTION__, *gtf_length, *gtf_address, *obj_loc);
445 err = 0; 443 err = 0;
@@ -449,7 +447,7 @@ out:
449 447
450/** 448/**
451 * taskfile_load_raw - send taskfile registers to host controller 449 * taskfile_load_raw - send taskfile registers to host controller
452 * @ap: Port to which output is sent 450 * @dev: target ATA device
453 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) 451 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
454 * 452 *
455 * Outputs ATA taskfile to standard ATA host controller using MMIO 453 * Outputs ATA taskfile to standard ATA host controller using MMIO
@@ -466,15 +464,15 @@ out:
466 * LOCKING: TBD: 464 * LOCKING: TBD:
467 * Inherited from caller. 465 * Inherited from caller.
468 */ 466 */
469static void taskfile_load_raw(struct ata_port *ap, 467static void taskfile_load_raw(struct ata_device *dev,
470 struct ata_device *atadev, 468 const struct taskfile_array *gtf)
471 const struct taskfile_array *gtf)
472{ 469{
470 struct ata_port *ap = dev->ap;
473 struct ata_taskfile tf; 471 struct ata_taskfile tf;
474 unsigned int err; 472 unsigned int err;
475 473
476 if (ata_msg_probe(ap)) 474 if (ata_msg_probe(ap))
477 ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " 475 ata_dev_printk(dev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: "
478 "%02x %02x %02x %02x %02x %02x %02x\n", 476 "%02x %02x %02x %02x %02x %02x %02x\n",
479 __FUNCTION__, 477 __FUNCTION__,
480 gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], 478 gtf->tfa[0], gtf->tfa[1], gtf->tfa[2],
@@ -485,7 +483,7 @@ static void taskfile_load_raw(struct ata_port *ap,
485 && (gtf->tfa[6] == 0)) 483 && (gtf->tfa[6] == 0))
486 return; 484 return;
487 485
488 ata_tf_init(atadev, &tf); 486 ata_tf_init(dev, &tf);
489 487
490 /* convert gtf to tf */ 488 /* convert gtf to tf */
491 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ 489 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */
@@ -498,17 +496,16 @@ static void taskfile_load_raw(struct ata_port *ap,
498 tf.device = gtf->tfa[5]; /* 0x1f6 */ 496 tf.device = gtf->tfa[5]; /* 0x1f6 */
499 tf.command = gtf->tfa[6]; /* 0x1f7 */ 497 tf.command = gtf->tfa[6]; /* 0x1f7 */
500 498
501 err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); 499 err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
502 if (err && ata_msg_probe(ap)) 500 if (err && ata_msg_probe(ap))
503 ata_dev_printk(atadev, KERN_ERR, 501 ata_dev_printk(dev, KERN_ERR,
504 "%s: ata_exec_internal failed: %u\n", 502 "%s: ata_exec_internal failed: %u\n",
505 __FUNCTION__, err); 503 __FUNCTION__, err);
506} 504}
507 505
508/** 506/**
509 * do_drive_set_taskfiles - write the drive taskfile settings from _GTF 507 * do_drive_set_taskfiles - write the drive taskfile settings from _GTF
510 * @ap: the ata_port for the drive 508 * @dev: target ATA device
511 * @atadev: target ata_device
512 * @gtf_length: total number of bytes of _GTF taskfiles 509 * @gtf_length: total number of bytes of _GTF taskfiles
513 * @gtf_address: location of _GTF taskfile arrays 510 * @gtf_address: location of _GTF taskfile arrays
514 * 511 *
@@ -517,30 +514,31 @@ static void taskfile_load_raw(struct ata_port *ap,
517 * Write {gtf_address, length gtf_length} in groups of 514 * Write {gtf_address, length gtf_length} in groups of
518 * REGS_PER_GTF bytes. 515 * REGS_PER_GTF bytes.
519 */ 516 */
520static int do_drive_set_taskfiles(struct ata_port *ap, 517static int do_drive_set_taskfiles(struct ata_device *dev,
521 struct ata_device *atadev, unsigned int gtf_length, 518 unsigned int gtf_length,
522 unsigned long gtf_address) 519 unsigned long gtf_address)
523{ 520{
524 int err = -ENODEV; 521 struct ata_port *ap = dev->ap;
525 int gtf_count = gtf_length / REGS_PER_GTF; 522 int err = -ENODEV;
526 int ix; 523 int gtf_count = gtf_length / REGS_PER_GTF;
524 int ix;
527 struct taskfile_array *gtf; 525 struct taskfile_array *gtf;
528 526
529 if (ata_msg_probe(ap)) 527 if (ata_msg_probe(ap))
530 ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 528 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
531 __FUNCTION__, ap->port_no); 529 __FUNCTION__, ap->port_no);
532 530
533 if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) 531 if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA))
534 return 0; 532 return 0;
535 533
536 if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) 534 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED))
537 goto out; 535 goto out;
538 if (!gtf_count) /* shouldn't be here */ 536 if (!gtf_count) /* shouldn't be here */
539 goto out; 537 goto out;
540 538
541 if (gtf_length % REGS_PER_GTF) { 539 if (gtf_length % REGS_PER_GTF) {
542 if (ata_msg_drv(ap)) 540 if (ata_msg_drv(ap))
543 ata_dev_printk(atadev, KERN_ERR, 541 ata_dev_printk(dev, KERN_ERR,
544 "%s: unexpected GTF length (%d)\n", 542 "%s: unexpected GTF length (%d)\n",
545 __FUNCTION__, gtf_length); 543 __FUNCTION__, gtf_length);
546 goto out; 544 goto out;
@@ -551,7 +549,7 @@ static int do_drive_set_taskfiles(struct ata_port *ap,
551 (gtf_address + ix * REGS_PER_GTF); 549 (gtf_address + ix * REGS_PER_GTF);
552 550
553 /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ 551 /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */
554 taskfile_load_raw(ap, atadev, gtf); 552 taskfile_load_raw(dev, gtf);
555 } 553 }
556 554
557 err = 0; 555 err = 0;
@@ -567,11 +565,11 @@ out:
567 */ 565 */
568int ata_acpi_exec_tfs(struct ata_port *ap) 566int ata_acpi_exec_tfs(struct ata_port *ap)
569{ 567{
570 int ix; 568 int ix;
571 int ret =0; 569 int ret = 0;
572 unsigned int gtf_length; 570 unsigned int gtf_length;
573 unsigned long gtf_address; 571 unsigned long gtf_address;
574 unsigned long obj_loc; 572 unsigned long obj_loc;
575 573
576 if (libata_noacpi) 574 if (libata_noacpi)
577 return 0; 575 return 0;
@@ -584,11 +582,13 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
584 return 0; 582 return 0;
585 583
586 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { 584 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) {
587 if (!ata_dev_enabled(&ap->device[ix])) 585 struct ata_device *dev = &ap->device[ix];
586
587 if (!ata_dev_enabled(dev))
588 continue; 588 continue;
589 589
590 ret = do_drive_get_GTF(ap, ix, 590 ret = do_drive_get_GTF(dev, &gtf_length, &gtf_address,
591 &gtf_length, &gtf_address, &obj_loc); 591 &obj_loc);
592 if (ret < 0) { 592 if (ret < 0) {
593 if (ata_msg_probe(ap)) 593 if (ata_msg_probe(ap))
594 ata_port_printk(ap, KERN_DEBUG, 594 ata_port_printk(ap, KERN_DEBUG,
@@ -597,8 +597,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
597 break; 597 break;
598 } 598 }
599 599
600 ret = do_drive_set_taskfiles(ap, &ap->device[ix], 600 ret = do_drive_set_taskfiles(dev, gtf_length, gtf_address);
601 gtf_length, gtf_address);
602 kfree((void *)obj_loc); 601 kfree((void *)obj_loc);
603 if (ret < 0) { 602 if (ret < 0) {
604 if (ata_msg_probe(ap)) 603 if (ata_msg_probe(ap))
@@ -614,8 +613,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
614 613
615/** 614/**
616 * ata_acpi_push_id - send Identify data to drive 615 * ata_acpi_push_id - send Identify data to drive
617 * @ap: the ata_port for the drive 616 * @dev: target ATA device
618 * @ix: drive index
619 * 617 *
620 * _SDD ACPI object: for SATA mode only 618 * _SDD ACPI object: for SATA mode only
621 * Must be after Identify (Packet) Device -- uses its data 619 * Must be after Identify (Packet) Device -- uses its data
@@ -623,57 +621,57 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
623 * method and if it fails for whatever reason, we should still 621 * method and if it fails for whatever reason, we should still
624 * just keep going. 622 * just keep going.
625 */ 623 */
626int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) 624int ata_acpi_push_id(struct ata_device *dev)
627{ 625{
628 acpi_handle handle; 626 struct ata_port *ap = dev->ap;
629 acpi_integer pcidevfn; 627 acpi_handle handle;
630 int err; 628 acpi_integer pcidevfn;
631 struct device *dev = ap->host->dev; 629 int err;
632 struct ata_device *atadev = &ap->device[ix]; 630 struct device *gdev = ap->host->dev;
633 u32 dev_adr; 631 u32 dev_adr;
634 acpi_status status; 632 acpi_status status;
635 struct acpi_object_list input; 633 struct acpi_object_list input;
636 union acpi_object in_params[1]; 634 union acpi_object in_params[1];
637 635
638 if (libata_noacpi) 636 if (libata_noacpi)
639 return 0; 637 return 0;
640 638
641 if (ata_msg_probe(ap)) 639 if (ata_msg_probe(ap))
642 ata_dev_printk(atadev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", 640 ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n",
643 __FUNCTION__, ix, ap->port_no); 641 __FUNCTION__, dev->devno, ap->port_no);
644 642
645 /* Don't continue if not a SATA device. */ 643 /* Don't continue if not a SATA device. */
646 if (!(ap->cbl == ATA_CBL_SATA)) { 644 if (!(ap->cbl == ATA_CBL_SATA)) {
647 if (ata_msg_probe(ap)) 645 if (ata_msg_probe(ap))
648 ata_dev_printk(atadev, KERN_DEBUG, 646 ata_dev_printk(dev, KERN_DEBUG,
649 "%s: Not a SATA device\n", __FUNCTION__); 647 "%s: Not a SATA device\n", __FUNCTION__);
650 goto out; 648 goto out;
651 } 649 }
652 650
653 /* Don't continue if device has no _ADR method. 651 /* Don't continue if device has no _ADR method.
654 * _SDD is intended for known motherboard devices. */ 652 * _SDD is intended for known motherboard devices. */
655 err = sata_get_dev_handle(dev, &handle, &pcidevfn); 653 err = sata_get_dev_handle(gdev, &handle, &pcidevfn);
656 if (err < 0) { 654 if (err < 0) {
657 if (ata_msg_probe(ap)) 655 if (ata_msg_probe(ap))
658 ata_dev_printk(atadev, KERN_DEBUG, 656 ata_dev_printk(dev, KERN_DEBUG,
659 "%s: sata_get_dev_handle failed (%d\n", 657 "%s: sata_get_dev_handle failed (%d\n",
660 __FUNCTION__, err); 658 __FUNCTION__, err);
661 goto out; 659 goto out;
662 } 660 }
663 661
664 /* Get this drive's _ADR info, if not already known */ 662 /* Get this drive's _ADR info, if not already known */
665 if (!atadev->obj_handle) { 663 if (!dev->obj_handle) {
666 dev_adr = SATA_ADR_RSVD; 664 dev_adr = SATA_ADR_RSVD;
667 err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev, 665 err = get_sata_adr(gdev, handle, pcidevfn, dev->devno, ap, dev,
668 &dev_adr); 666 &dev_adr);
669 if (err < 0 || dev_adr == SATA_ADR_RSVD || 667 if (err < 0 || dev_adr == SATA_ADR_RSVD ||
670 !atadev->obj_handle) { 668 !dev->obj_handle) {
671 if (ata_msg_probe(ap)) 669 if (ata_msg_probe(ap))
672 ata_dev_printk(atadev, KERN_DEBUG, 670 ata_dev_printk(dev, KERN_DEBUG,
673 "%s: get_sata_adr failed: " 671 "%s: get_sata_adr failed: "
674 "err=%d, dev_adr=%u, obj_handle=0x%p\n", 672 "err=%d, dev_adr=%u, obj_handle=0x%p\n",
675 __FUNCTION__, err, dev_adr, 673 __FUNCTION__, err, dev_adr,
676 atadev->obj_handle); 674 dev->obj_handle);
677 goto out; 675 goto out;
678 } 676 }
679 } 677 }
@@ -683,19 +681,19 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
683 input.count = 1; 681 input.count = 1;
684 input.pointer = in_params; 682 input.pointer = in_params;
685 in_params[0].type = ACPI_TYPE_BUFFER; 683 in_params[0].type = ACPI_TYPE_BUFFER;
686 in_params[0].buffer.length = sizeof(atadev->id[0]) * ATA_ID_WORDS; 684 in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS;
687 in_params[0].buffer.pointer = (u8 *)atadev->id; 685 in_params[0].buffer.pointer = (u8 *)dev->id;
688 /* Output buffer: _SDD has no output */ 686 /* Output buffer: _SDD has no output */
689 687
690 /* It's OK for _SDD to be missing too. */ 688 /* It's OK for _SDD to be missing too. */
691 swap_buf_le16(atadev->id, ATA_ID_WORDS); 689 swap_buf_le16(dev->id, ATA_ID_WORDS);
692 status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL); 690 status = acpi_evaluate_object(dev->obj_handle, "_SDD", &input, NULL);
693 swap_buf_le16(atadev->id, ATA_ID_WORDS); 691 swap_buf_le16(dev->id, ATA_ID_WORDS);
694 692
695 err = ACPI_FAILURE(status) ? -EIO : 0; 693 err = ACPI_FAILURE(status) ? -EIO : 0;
696 if (err < 0) { 694 if (err < 0) {
697 if (ata_msg_probe(ap)) 695 if (ata_msg_probe(ap))
698 ata_dev_printk(atadev, KERN_DEBUG, 696 ata_dev_printk(dev, KERN_DEBUG,
699 "%s _SDD error: status = 0x%x\n", 697 "%s _SDD error: status = 0x%x\n",
700 __FUNCTION__, status); 698 __FUNCTION__, status);
701 } 699 }
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4595d1f8cf60..4166407eb47c 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -101,6 +101,12 @@ int libata_noacpi = 1;
101module_param_named(noacpi, libata_noacpi, int, 0444); 101module_param_named(noacpi, libata_noacpi, int, 0444);
102MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); 102MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
103 103
104int ata_spindown_compat = 1;
105module_param_named(spindown_compat, ata_spindown_compat, int, 0644);
106MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown "
107 "behavior. Will be removed. More info can be found in "
108 "Documentation/feature-removal-schedule.txt\n");
109
104MODULE_AUTHOR("Jeff Garzik"); 110MODULE_AUTHOR("Jeff Garzik");
105MODULE_DESCRIPTION("Library module for ATA devices"); 111MODULE_DESCRIPTION("Library module for ATA devices");
106MODULE_LICENSE("GPL"); 112MODULE_LICENSE("GPL");
@@ -1654,7 +1660,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1654 struct ata_taskfile tf; 1660 struct ata_taskfile tf;
1655 unsigned int err_mask = 0; 1661 unsigned int err_mask = 0;
1656 const char *reason; 1662 const char *reason;
1657 int tried_spinup = 0; 1663 int may_fallback = 1, tried_spinup = 0;
1658 int rc; 1664 int rc;
1659 1665
1660 if (ata_msg_ctl(ap)) 1666 if (ata_msg_ctl(ap))
@@ -1698,11 +1704,31 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1698 return -ENOENT; 1704 return -ENOENT;
1699 } 1705 }
1700 1706
1707 /* Device or controller might have reported the wrong
1708 * device class. Give a shot at the other IDENTIFY if
1709 * the current one is aborted by the device.
1710 */
1711 if (may_fallback &&
1712 (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
1713 may_fallback = 0;
1714
1715 if (class == ATA_DEV_ATA)
1716 class = ATA_DEV_ATAPI;
1717 else
1718 class = ATA_DEV_ATA;
1719 goto retry;
1720 }
1721
1701 rc = -EIO; 1722 rc = -EIO;
1702 reason = "I/O error"; 1723 reason = "I/O error";
1703 goto err_out; 1724 goto err_out;
1704 } 1725 }
1705 1726
1727 /* Falling back doesn't make sense if ID data was read
1728 * successfully at least once.
1729 */
1730 may_fallback = 0;
1731
1706 swap_buf_le16(id, ATA_ID_WORDS); 1732 swap_buf_le16(id, ATA_ID_WORDS);
1707 1733
1708 /* sanity check */ 1734 /* sanity check */
@@ -1843,7 +1869,7 @@ int ata_dev_configure(struct ata_device *dev)
1843 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); 1869 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__);
1844 1870
1845 /* set _SDD */ 1871 /* set _SDD */
1846 rc = ata_acpi_push_id(ap, dev->devno); 1872 rc = ata_acpi_push_id(dev);
1847 if (rc) { 1873 if (rc) {
1848 ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", 1874 ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n",
1849 rc); 1875 rc);
@@ -2860,7 +2886,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2860 dev = &ap->device[i]; 2886 dev = &ap->device[i];
2861 2887
2862 /* don't update suspended devices' xfer mode */ 2888 /* don't update suspended devices' xfer mode */
2863 if (!ata_dev_ready(dev)) 2889 if (!ata_dev_enabled(dev))
2864 continue; 2890 continue;
2865 2891
2866 rc = ata_dev_set_mode(dev); 2892 rc = ata_dev_set_mode(dev);
@@ -5845,37 +5871,11 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg,
5845 */ 5871 */
5846int ata_host_suspend(struct ata_host *host, pm_message_t mesg) 5872int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
5847{ 5873{
5848 int i, j, rc; 5874 int rc;
5849 5875
5850 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); 5876 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
5851 if (rc) 5877 if (rc == 0)
5852 goto fail; 5878 host->dev->power.power_state = mesg;
5853
5854 /* EH is quiescent now. Fail if we have any ready device.
5855 * This happens if hotplug occurs between completion of device
5856 * suspension and here.
5857 */
5858 for (i = 0; i < host->n_ports; i++) {
5859 struct ata_port *ap = host->ports[i];
5860
5861 for (j = 0; j < ATA_MAX_DEVICES; j++) {
5862 struct ata_device *dev = &ap->device[j];
5863
5864 if (ata_dev_ready(dev)) {
5865 ata_port_printk(ap, KERN_WARNING,
5866 "suspend failed, device %d "
5867 "still active\n", dev->devno);
5868 rc = -EBUSY;
5869 goto fail;
5870 }
5871 }
5872 }
5873
5874 host->dev->power.power_state = mesg;
5875 return 0;
5876
5877 fail:
5878 ata_host_resume(host);
5879 return rc; 5879 return rc;
5880} 5880}
5881 5881
@@ -5984,6 +5984,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
5984 if (!ap) 5984 if (!ap)
5985 return NULL; 5985 return NULL;
5986 5986
5987 ap->pflags |= ATA_PFLAG_INITIALIZING;
5987 ap->lock = &host->lock; 5988 ap->lock = &host->lock;
5988 ap->flags = ATA_FLAG_DISABLED; 5989 ap->flags = ATA_FLAG_DISABLED;
5989 ap->print_id = -1; 5990 ap->print_id = -1;
@@ -6352,6 +6353,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6352 ehi->action |= ATA_EH_SOFTRESET; 6353 ehi->action |= ATA_EH_SOFTRESET;
6353 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; 6354 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
6354 6355
6356 ap->pflags &= ~ATA_PFLAG_INITIALIZING;
6355 ap->pflags |= ATA_PFLAG_LOADING; 6357 ap->pflags |= ATA_PFLAG_LOADING;
6356 ata_port_schedule_eh(ap); 6358 ata_port_schedule_eh(ap);
6357 6359
@@ -6876,6 +6878,7 @@ EXPORT_SYMBOL_GPL(ata_timing_merge);
6876#ifdef CONFIG_PCI 6878#ifdef CONFIG_PCI
6877EXPORT_SYMBOL_GPL(pci_test_config_bits); 6879EXPORT_SYMBOL_GPL(pci_test_config_bits);
6878EXPORT_SYMBOL_GPL(ata_pci_init_native_host); 6880EXPORT_SYMBOL_GPL(ata_pci_init_native_host);
6881EXPORT_SYMBOL_GPL(ata_pci_init_bmdma);
6879EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); 6882EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host);
6880EXPORT_SYMBOL_GPL(ata_pci_init_one); 6883EXPORT_SYMBOL_GPL(ata_pci_init_one);
6881EXPORT_SYMBOL_GPL(ata_pci_remove_one); 6884EXPORT_SYMBOL_GPL(ata_pci_remove_one);
@@ -6889,11 +6892,6 @@ EXPORT_SYMBOL_GPL(ata_pci_default_filter);
6889EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); 6892EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
6890#endif /* CONFIG_PCI */ 6893#endif /* CONFIG_PCI */
6891 6894
6892#ifdef CONFIG_PM
6893EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
6894EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
6895#endif /* CONFIG_PM */
6896
6897EXPORT_SYMBOL_GPL(ata_eng_timeout); 6895EXPORT_SYMBOL_GPL(ata_eng_timeout);
6898EXPORT_SYMBOL_GPL(ata_port_schedule_eh); 6896EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
6899EXPORT_SYMBOL_GPL(ata_port_abort); 6897EXPORT_SYMBOL_GPL(ata_port_abort);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 8256655ce7d9..5309c312f517 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -77,29 +77,12 @@ static void ata_eh_finish(struct ata_port *ap);
77#ifdef CONFIG_PM 77#ifdef CONFIG_PM
78static void ata_eh_handle_port_suspend(struct ata_port *ap); 78static void ata_eh_handle_port_suspend(struct ata_port *ap);
79static void ata_eh_handle_port_resume(struct ata_port *ap); 79static void ata_eh_handle_port_resume(struct ata_port *ap);
80static int ata_eh_suspend(struct ata_port *ap,
81 struct ata_device **r_failed_dev);
82static void ata_eh_prep_resume(struct ata_port *ap);
83static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev);
84#else /* CONFIG_PM */ 80#else /* CONFIG_PM */
85static void ata_eh_handle_port_suspend(struct ata_port *ap) 81static void ata_eh_handle_port_suspend(struct ata_port *ap)
86{ } 82{ }
87 83
88static void ata_eh_handle_port_resume(struct ata_port *ap) 84static void ata_eh_handle_port_resume(struct ata_port *ap)
89{ } 85{ }
90
91static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
92{
93 return 0;
94}
95
96static void ata_eh_prep_resume(struct ata_port *ap)
97{ }
98
99static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
100{
101 return 0;
102}
103#endif /* CONFIG_PM */ 86#endif /* CONFIG_PM */
104 87
105static void ata_ering_record(struct ata_ering *ering, int is_io, 88static void ata_ering_record(struct ata_ering *ering, int is_io,
@@ -568,6 +551,9 @@ void ata_port_schedule_eh(struct ata_port *ap)
568{ 551{
569 WARN_ON(!ap->ops->error_handler); 552 WARN_ON(!ap->ops->error_handler);
570 553
554 if (ap->pflags & ATA_PFLAG_INITIALIZING)
555 return;
556
571 ap->pflags |= ATA_PFLAG_EH_PENDING; 557 ap->pflags |= ATA_PFLAG_EH_PENDING;
572 scsi_schedule_eh(ap->scsi_host); 558 scsi_schedule_eh(ap->scsi_host);
573 559
@@ -1791,7 +1777,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1791 if (ehc->i.flags & ATA_EHI_DID_RESET) 1777 if (ehc->i.flags & ATA_EHI_DID_RESET)
1792 readid_flags |= ATA_READID_POSTRESET; 1778 readid_flags |= ATA_READID_POSTRESET;
1793 1779
1794 if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { 1780 if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
1795 if (ata_port_offline(ap)) { 1781 if (ata_port_offline(ap)) {
1796 rc = -EIO; 1782 rc = -EIO;
1797 goto err; 1783 goto err;
@@ -1872,166 +1858,6 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1872 return rc; 1858 return rc;
1873} 1859}
1874 1860
1875#ifdef CONFIG_PM
1876/**
1877 * ata_eh_suspend - handle suspend EH action
1878 * @ap: target host port
1879 * @r_failed_dev: result parameter to indicate failing device
1880 *
1881 * Handle suspend EH action. Disk devices are spinned down and
1882 * other types of devices are just marked suspended. Once
1883 * suspended, no EH action to the device is allowed until it is
1884 * resumed.
1885 *
1886 * LOCKING:
1887 * Kernel thread context (may sleep).
1888 *
1889 * RETURNS:
1890 * 0 on success, -errno otherwise
1891 */
1892static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
1893{
1894 struct ata_device *dev;
1895 int i, rc = 0;
1896
1897 DPRINTK("ENTER\n");
1898
1899 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1900 unsigned long flags;
1901 unsigned int action, err_mask;
1902
1903 dev = &ap->device[i];
1904 action = ata_eh_dev_action(dev);
1905
1906 if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND))
1907 continue;
1908
1909 WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED);
1910
1911 ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND);
1912
1913 if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
1914 /* flush cache */
1915 rc = ata_flush_cache(dev);
1916 if (rc)
1917 break;
1918
1919 /* spin down */
1920 err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1);
1921 if (err_mask) {
1922 ata_dev_printk(dev, KERN_ERR, "failed to "
1923 "spin down (err_mask=0x%x)\n",
1924 err_mask);
1925 rc = -EIO;
1926 break;
1927 }
1928 }
1929
1930 spin_lock_irqsave(ap->lock, flags);
1931 dev->flags |= ATA_DFLAG_SUSPENDED;
1932 spin_unlock_irqrestore(ap->lock, flags);
1933
1934 ata_eh_done(ap, dev, ATA_EH_SUSPEND);
1935 }
1936
1937 if (rc)
1938 *r_failed_dev = dev;
1939
1940 DPRINTK("EXIT\n");
1941 return rc;
1942}
1943
1944/**
1945 * ata_eh_prep_resume - prep for resume EH action
1946 * @ap: target host port
1947 *
1948 * Clear SUSPENDED in preparation for scheduled resume actions.
1949 * This allows other parts of EH to access the devices being
1950 * resumed.
1951 *
1952 * LOCKING:
1953 * Kernel thread context (may sleep).
1954 */
1955static void ata_eh_prep_resume(struct ata_port *ap)
1956{
1957 struct ata_device *dev;
1958 unsigned long flags;
1959 int i;
1960
1961 DPRINTK("ENTER\n");
1962
1963 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1964 unsigned int action;
1965
1966 dev = &ap->device[i];
1967 action = ata_eh_dev_action(dev);
1968
1969 if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
1970 continue;
1971
1972 spin_lock_irqsave(ap->lock, flags);
1973 dev->flags &= ~ATA_DFLAG_SUSPENDED;
1974 spin_unlock_irqrestore(ap->lock, flags);
1975 }
1976
1977 DPRINTK("EXIT\n");
1978}
1979
1980/**
1981 * ata_eh_resume - handle resume EH action
1982 * @ap: target host port
1983 * @r_failed_dev: result parameter to indicate failing device
1984 *
1985 * Handle resume EH action. Target devices are already reset and
1986 * revalidated. Spinning up is the only operation left.
1987 *
1988 * LOCKING:
1989 * Kernel thread context (may sleep).
1990 *
1991 * RETURNS:
1992 * 0 on success, -errno otherwise
1993 */
1994static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
1995{
1996 struct ata_device *dev;
1997 int i, rc = 0;
1998
1999 DPRINTK("ENTER\n");
2000
2001 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2002 unsigned int action, err_mask;
2003
2004 dev = &ap->device[i];
2005 action = ata_eh_dev_action(dev);
2006
2007 if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
2008 continue;
2009
2010 ata_eh_about_to_do(ap, dev, ATA_EH_RESUME);
2011
2012 if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
2013 err_mask = ata_do_simple_cmd(dev,
2014 ATA_CMD_IDLEIMMEDIATE);
2015 if (err_mask) {
2016 ata_dev_printk(dev, KERN_ERR, "failed to "
2017 "spin up (err_mask=0x%x)\n",
2018 err_mask);
2019 rc = -EIO;
2020 break;
2021 }
2022 }
2023
2024 ata_eh_done(ap, dev, ATA_EH_RESUME);
2025 }
2026
2027 if (rc)
2028 *r_failed_dev = dev;
2029
2030 DPRINTK("EXIT\n");
2031 return 0;
2032}
2033#endif /* CONFIG_PM */
2034
2035static int ata_port_nr_enabled(struct ata_port *ap) 1861static int ata_port_nr_enabled(struct ata_port *ap)
2036{ 1862{
2037 int i, cnt = 0; 1863 int i, cnt = 0;
@@ -2057,17 +1883,6 @@ static int ata_eh_skip_recovery(struct ata_port *ap)
2057 struct ata_eh_context *ehc = &ap->eh_context; 1883 struct ata_eh_context *ehc = &ap->eh_context;
2058 int i; 1884 int i;
2059 1885
2060 /* skip if all possible devices are suspended */
2061 for (i = 0; i < ata_port_max_devices(ap); i++) {
2062 struct ata_device *dev = &ap->device[i];
2063
2064 if (!(dev->flags & ATA_DFLAG_SUSPENDED))
2065 break;
2066 }
2067
2068 if (i == ata_port_max_devices(ap))
2069 return 1;
2070
2071 /* thaw frozen port, resume link and recover failed devices */ 1886 /* thaw frozen port, resume link and recover failed devices */
2072 if ((ap->pflags & ATA_PFLAG_FROZEN) || 1887 if ((ap->pflags & ATA_PFLAG_FROZEN) ||
2073 (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) 1888 (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap))
@@ -2147,9 +1962,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2147 if (ap->pflags & ATA_PFLAG_UNLOADING) 1962 if (ap->pflags & ATA_PFLAG_UNLOADING)
2148 goto out; 1963 goto out;
2149 1964
2150 /* prep for resume */
2151 ata_eh_prep_resume(ap);
2152
2153 /* skip EH if possible. */ 1965 /* skip EH if possible. */
2154 if (ata_eh_skip_recovery(ap)) 1966 if (ata_eh_skip_recovery(ap))
2155 ehc->i.action = 0; 1967 ehc->i.action = 0;
@@ -2177,11 +1989,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2177 if (rc) 1989 if (rc)
2178 goto dev_fail; 1990 goto dev_fail;
2179 1991
2180 /* resume devices */
2181 rc = ata_eh_resume(ap, &dev);
2182 if (rc)
2183 goto dev_fail;
2184
2185 /* configure transfer mode if necessary */ 1992 /* configure transfer mode if necessary */
2186 if (ehc->i.flags & ATA_EHI_SETMODE) { 1993 if (ehc->i.flags & ATA_EHI_SETMODE) {
2187 rc = ata_set_mode(ap, &dev); 1994 rc = ata_set_mode(ap, &dev);
@@ -2190,25 +1997,16 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2190 ehc->i.flags &= ~ATA_EHI_SETMODE; 1997 ehc->i.flags &= ~ATA_EHI_SETMODE;
2191 } 1998 }
2192 1999
2193 /* suspend devices */
2194 rc = ata_eh_suspend(ap, &dev);
2195 if (rc)
2196 goto dev_fail;
2197
2198 goto out; 2000 goto out;
2199 2001
2200 dev_fail: 2002 dev_fail:
2201 ehc->tries[dev->devno]--; 2003 ehc->tries[dev->devno]--;
2202 2004
2203 switch (rc) { 2005 switch (rc) {
2204 case -EINVAL:
2205 /* eeek, something went very wrong, give up */
2206 ehc->tries[dev->devno] = 0;
2207 break;
2208
2209 case -ENODEV: 2006 case -ENODEV:
2210 /* device missing or wrong IDENTIFY data, schedule probing */ 2007 /* device missing or wrong IDENTIFY data, schedule probing */
2211 ehc->i.probe_mask |= (1 << dev->devno); 2008 ehc->i.probe_mask |= (1 << dev->devno);
2009 case -EINVAL:
2212 /* give it just one more chance */ 2010 /* give it just one more chance */
2213 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); 2011 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1);
2214 case -EIO: 2012 case -EIO:
@@ -2390,22 +2188,13 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
2390 * 2188 *
2391 * Resume @ap. 2189 * Resume @ap.
2392 * 2190 *
2393 * This function also waits upto one second until all devices
2394 * hanging off this port requests resume EH action. This is to
2395 * prevent invoking EH and thus reset multiple times on resume.
2396 *
2397 * On DPM resume, where some of devices might not be resumed
2398 * together, this may delay port resume upto one second, but such
2399 * DPM resumes are rare and 1 sec delay isn't too bad.
2400 *
2401 * LOCKING: 2191 * LOCKING:
2402 * Kernel thread context (may sleep). 2192 * Kernel thread context (may sleep).
2403 */ 2193 */
2404static void ata_eh_handle_port_resume(struct ata_port *ap) 2194static void ata_eh_handle_port_resume(struct ata_port *ap)
2405{ 2195{
2406 unsigned long timeout;
2407 unsigned long flags; 2196 unsigned long flags;
2408 int i, rc = 0; 2197 int rc = 0;
2409 2198
2410 /* are we resuming? */ 2199 /* are we resuming? */
2411 spin_lock_irqsave(ap->lock, flags); 2200 spin_lock_irqsave(ap->lock, flags);
@@ -2416,31 +2205,12 @@ static void ata_eh_handle_port_resume(struct ata_port *ap)
2416 } 2205 }
2417 spin_unlock_irqrestore(ap->lock, flags); 2206 spin_unlock_irqrestore(ap->lock, flags);
2418 2207
2419 /* spurious? */ 2208 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
2420 if (!(ap->pflags & ATA_PFLAG_SUSPENDED))
2421 goto done;
2422 2209
2423 if (ap->ops->port_resume) 2210 if (ap->ops->port_resume)
2424 rc = ap->ops->port_resume(ap); 2211 rc = ap->ops->port_resume(ap);
2425 2212
2426 /* give devices time to request EH */ 2213 /* report result */
2427 timeout = jiffies + HZ; /* 1s max */
2428 while (1) {
2429 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2430 struct ata_device *dev = &ap->device[i];
2431 unsigned int action = ata_eh_dev_action(dev);
2432
2433 if ((dev->flags & ATA_DFLAG_SUSPENDED) &&
2434 !(action & ATA_EH_RESUME))
2435 break;
2436 }
2437
2438 if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout))
2439 break;
2440 msleep(10);
2441 }
2442
2443 done:
2444 spin_lock_irqsave(ap->lock, flags); 2214 spin_lock_irqsave(ap->lock, flags);
2445 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); 2215 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED);
2446 if (ap->pm_result) { 2216 if (ap->pm_result) {
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 9afba2ba489e..dd81fa78cdcf 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -510,133 +510,6 @@ static void ata_dump_status(unsigned id, struct ata_taskfile *tf)
510 } 510 }
511} 511}
512 512
513#ifdef CONFIG_PM
514/**
515 * ata_scsi_device_suspend - suspend ATA device associated with sdev
516 * @sdev: the SCSI device to suspend
517 * @mesg: target power management message
518 *
519 * Request suspend EH action on the ATA device associated with
520 * @sdev and wait for the operation to complete.
521 *
522 * LOCKING:
523 * Kernel thread context (may sleep).
524 *
525 * RETURNS:
526 * 0 on success, -errno otherwise.
527 */
528int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg)
529{
530 struct ata_port *ap = ata_shost_to_port(sdev->host);
531 struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
532 unsigned long flags;
533 unsigned int action;
534 int rc = 0;
535
536 if (!dev)
537 goto out;
538
539 spin_lock_irqsave(ap->lock, flags);
540
541 /* wait for the previous resume to complete */
542 while (dev->flags & ATA_DFLAG_SUSPENDED) {
543 spin_unlock_irqrestore(ap->lock, flags);
544 ata_port_wait_eh(ap);
545 spin_lock_irqsave(ap->lock, flags);
546 }
547
548 /* if @sdev is already detached, nothing to do */
549 if (sdev->sdev_state == SDEV_OFFLINE ||
550 sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL)
551 goto out_unlock;
552
553 /* request suspend */
554 action = ATA_EH_SUSPEND;
555 if (mesg.event != PM_EVENT_SUSPEND)
556 action |= ATA_EH_PM_FREEZE;
557 ap->eh_info.dev_action[dev->devno] |= action;
558 ap->eh_info.flags |= ATA_EHI_QUIET;
559 ata_port_schedule_eh(ap);
560
561 spin_unlock_irqrestore(ap->lock, flags);
562
563 /* wait for EH to do the job */
564 ata_port_wait_eh(ap);
565
566 spin_lock_irqsave(ap->lock, flags);
567
568 /* If @sdev is still attached but the associated ATA device
569 * isn't suspended, the operation failed.
570 */
571 if (sdev->sdev_state != SDEV_OFFLINE &&
572 sdev->sdev_state != SDEV_CANCEL && sdev->sdev_state != SDEV_DEL &&
573 !(dev->flags & ATA_DFLAG_SUSPENDED))
574 rc = -EIO;
575
576 out_unlock:
577 spin_unlock_irqrestore(ap->lock, flags);
578 out:
579 if (rc == 0)
580 sdev->sdev_gendev.power.power_state = mesg;
581 return rc;
582}
583
584/**
585 * ata_scsi_device_resume - resume ATA device associated with sdev
586 * @sdev: the SCSI device to resume
587 *
588 * Request resume EH action on the ATA device associated with
589 * @sdev and return immediately. This enables parallel
590 * wakeup/spinup of devices.
591 *
592 * LOCKING:
593 * Kernel thread context (may sleep).
594 *
595 * RETURNS:
596 * 0.
597 */
598int ata_scsi_device_resume(struct scsi_device *sdev)
599{
600 struct ata_port *ap = ata_shost_to_port(sdev->host);
601 struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
602 struct ata_eh_info *ehi = &ap->eh_info;
603 unsigned long flags;
604 unsigned int action;
605
606 if (!dev)
607 goto out;
608
609 spin_lock_irqsave(ap->lock, flags);
610
611 /* if @sdev is already detached, nothing to do */
612 if (sdev->sdev_state == SDEV_OFFLINE ||
613 sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL)
614 goto out_unlock;
615
616 /* request resume */
617 action = ATA_EH_RESUME;
618 if (sdev->sdev_gendev.power.power_state.event == PM_EVENT_SUSPEND)
619 __ata_ehi_hotplugged(ehi);
620 else
621 action |= ATA_EH_PM_FREEZE | ATA_EH_SOFTRESET;
622 ehi->dev_action[dev->devno] |= action;
623
624 /* We don't want autopsy and verbose EH messages. Disable
625 * those if we're the only device on this link.
626 */
627 if (ata_port_max_devices(ap) == 1)
628 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
629
630 ata_port_schedule_eh(ap);
631
632 out_unlock:
633 spin_unlock_irqrestore(ap->lock, flags);
634 out:
635 sdev->sdev_gendev.power.power_state = PMSG_ON;
636 return 0;
637}
638#endif /* CONFIG_PM */
639
640/** 513/**
641 * ata_to_sense_error - convert ATA error to SCSI error 514 * ata_to_sense_error - convert ATA error to SCSI error
642 * @id: ATA device number 515 * @id: ATA device number
@@ -929,6 +802,8 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
929 802
930 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); 803 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
931 804
805 sdev->manage_start_stop = 1;
806
932 if (dev) 807 if (dev)
933 ata_scsi_dev_config(sdev, dev); 808 ata_scsi_dev_config(sdev, dev);
934 809
@@ -1069,9 +944,35 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
1069 } 944 }
1070 945
1071 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ 946 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */
1072 } else 947 } else {
948 /* XXX: This is for backward compatibility, will be
949 * removed. Read Documentation/feature-removal-schedule.txt
950 * for more info.
951 */
952 if (ata_spindown_compat &&
953 (system_state == SYSTEM_HALT ||
954 system_state == SYSTEM_POWER_OFF)) {
955 static int warned = 0;
956
957 if (!warned) {
958 spin_unlock_irq(qc->ap->lock);
959 ata_dev_printk(qc->dev, KERN_WARNING,
960 "DISK MIGHT NOT BE SPUN DOWN PROPERLY. "
961 "UPDATE SHUTDOWN UTILITY\n");
962 ata_dev_printk(qc->dev, KERN_WARNING,
963 "For more info, visit "
964 "http://linux-ata.org/shutdown.html\n");
965 warned = 1;
966 ssleep(5);
967 spin_lock_irq(qc->ap->lock);
968 }
969 scmd->result = SAM_STAT_GOOD;
970 return 1;
971 }
972
1073 /* Issue ATA STANDBY IMMEDIATE command */ 973 /* Issue ATA STANDBY IMMEDIATE command */
1074 tf->command = ATA_CMD_STANDBYNOW1; 974 tf->command = ATA_CMD_STANDBYNOW1;
975 }
1075 976
1076 /* 977 /*
1077 * Standby and Idle condition timers could be implemented but that 978 * Standby and Idle condition timers could be implemented but that
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index d211db6b35a2..e35d13466c69 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -544,7 +544,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port)
544 * RETURNS: 544 * RETURNS:
545 * 0 on success, -errno otherwise. 545 * 0 on success, -errno otherwise.
546 */ 546 */
547static int ata_pci_init_bmdma(struct ata_host *host) 547int ata_pci_init_bmdma(struct ata_host *host)
548{ 548{
549 struct device *gdev = host->dev; 549 struct device *gdev = host->dev;
550 struct pci_dev *pdev = to_pci_dev(gdev); 550 struct pci_dev *pdev = to_pci_dev(gdev);
@@ -566,7 +566,7 @@ static int ata_pci_init_bmdma(struct ata_host *host)
566 } 566 }
567 host->iomap = pcim_iomap_table(pdev); 567 host->iomap = pcim_iomap_table(pdev);
568 568
569 for (i = 0; i < host->n_ports; i++) { 569 for (i = 0; i < 2; i++) {
570 struct ata_port *ap = host->ports[i]; 570 struct ata_port *ap = host->ports[i];
571 void __iomem *bmdma = host->iomap[4] + 8 * i; 571 void __iomem *bmdma = host->iomap[4] + 8 * i;
572 572
@@ -585,54 +585,52 @@ static int ata_pci_init_bmdma(struct ata_host *host)
585/** 585/**
586 * ata_pci_init_native_host - acquire native ATA resources and init host 586 * ata_pci_init_native_host - acquire native ATA resources and init host
587 * @host: target ATA host 587 * @host: target ATA host
588 * @port_mask: ports to consider
589 * 588 *
590 * Acquire native PCI ATA resources for @host and initialize 589 * Acquire native PCI ATA resources for @host and initialize the
591 * @host accordoingly. 590 * first two ports of @host accordingly. Ports marked dummy are
591 * skipped and allocation failure makes the port dummy.
592 * 592 *
593 * LOCKING: 593 * LOCKING:
594 * Inherited from calling layer (may sleep). 594 * Inherited from calling layer (may sleep).
595 * 595 *
596 * RETURNS: 596 * RETURNS:
597 * 0 on success, -errno otherwise. 597 * 0 if at least one port is initialized, -ENODEV if no port is
598 * available.
598 */ 599 */
599int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) 600int ata_pci_init_native_host(struct ata_host *host)
600{ 601{
601 struct device *gdev = host->dev; 602 struct device *gdev = host->dev;
602 struct pci_dev *pdev = to_pci_dev(gdev); 603 struct pci_dev *pdev = to_pci_dev(gdev);
604 unsigned int mask = 0;
603 int i, rc; 605 int i, rc;
604 606
605 /* Discard disabled ports. Some controllers show their unused
606 * channels this way. Disabled ports are made dummy.
607 */
608 for (i = 0; i < 2; i++) {
609 if ((port_mask & (1 << i)) && !ata_resources_present(pdev, i)) {
610 host->ports[i]->ops = &ata_dummy_port_ops;
611 port_mask &= ~(1 << i);
612 }
613 }
614
615 if (!port_mask) {
616 dev_printk(KERN_ERR, gdev, "no available port\n");
617 return -ENODEV;
618 }
619
620 /* request, iomap BARs and init port addresses accordingly */ 607 /* request, iomap BARs and init port addresses accordingly */
621 for (i = 0; i < 2; i++) { 608 for (i = 0; i < 2; i++) {
622 struct ata_port *ap = host->ports[i]; 609 struct ata_port *ap = host->ports[i];
623 int base = i * 2; 610 int base = i * 2;
624 void __iomem * const *iomap; 611 void __iomem * const *iomap;
625 612
626 if (!(port_mask & (1 << i))) 613 if (ata_port_is_dummy(ap))
614 continue;
615
616 /* Discard disabled ports. Some controllers show
617 * their unused channels this way. Disabled ports are
618 * made dummy.
619 */
620 if (!ata_resources_present(pdev, i)) {
621 ap->ops = &ata_dummy_port_ops;
627 continue; 622 continue;
623 }
628 624
629 rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); 625 rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME);
630 if (rc) { 626 if (rc) {
631 dev_printk(KERN_ERR, gdev, "failed to request/iomap " 627 dev_printk(KERN_WARNING, gdev,
632 "BARs for port %d (errno=%d)\n", i, rc); 628 "failed to request/iomap BARs for port %d "
629 "(errno=%d)\n", i, rc);
633 if (rc == -EBUSY) 630 if (rc == -EBUSY)
634 pcim_pin_device(pdev); 631 pcim_pin_device(pdev);
635 return rc; 632 ap->ops = &ata_dummy_port_ops;
633 continue;
636 } 634 }
637 host->iomap = iomap = pcim_iomap_table(pdev); 635 host->iomap = iomap = pcim_iomap_table(pdev);
638 636
@@ -641,6 +639,13 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask)
641 ap->ioaddr.ctl_addr = (void __iomem *) 639 ap->ioaddr.ctl_addr = (void __iomem *)
642 ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); 640 ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS);
643 ata_std_ports(&ap->ioaddr); 641 ata_std_ports(&ap->ioaddr);
642
643 mask |= 1 << i;
644 }
645
646 if (!mask) {
647 dev_printk(KERN_ERR, gdev, "no available native port\n");
648 return -ENODEV;
644 } 649 }
645 650
646 return 0; 651 return 0;
@@ -649,8 +654,7 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask)
649/** 654/**
650 * ata_pci_prepare_native_host - helper to prepare native PCI ATA host 655 * ata_pci_prepare_native_host - helper to prepare native PCI ATA host
651 * @pdev: target PCI device 656 * @pdev: target PCI device
652 * @ppi: array of port_info 657 * @ppi: array of port_info, must be enough for two ports
653 * @n_ports: number of ports to allocate
654 * @r_host: out argument for the initialized ATA host 658 * @r_host: out argument for the initialized ATA host
655 * 659 *
656 * Helper to allocate ATA host for @pdev, acquire all native PCI 660 * Helper to allocate ATA host for @pdev, acquire all native PCI
@@ -664,10 +668,9 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask)
664 */ 668 */
665int ata_pci_prepare_native_host(struct pci_dev *pdev, 669int ata_pci_prepare_native_host(struct pci_dev *pdev,
666 const struct ata_port_info * const * ppi, 670 const struct ata_port_info * const * ppi,
667 int n_ports, struct ata_host **r_host) 671 struct ata_host **r_host)
668{ 672{
669 struct ata_host *host; 673 struct ata_host *host;
670 unsigned int port_mask;
671 int rc; 674 int rc;
672 675
673 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) 676 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL))
@@ -681,11 +684,7 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev,
681 goto err_out; 684 goto err_out;
682 } 685 }
683 686
684 port_mask = ATA_PORT_PRIMARY; 687 rc = ata_pci_init_native_host(host);
685 if (n_ports > 1)
686 port_mask |= ATA_PORT_SECONDARY;
687
688 rc = ata_pci_init_native_host(host, port_mask);
689 if (rc) 688 if (rc)
690 goto err_out; 689 goto err_out;
691 690
@@ -777,8 +776,11 @@ static int ata_init_legacy_port(struct ata_port *ap,
777 /* iomap cmd and ctl ports */ 776 /* iomap cmd and ctl ports */
778 legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); 777 legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8);
779 legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); 778 legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1);
780 if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) 779 if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) {
780 dev_printk(KERN_WARNING, host->dev,
781 "failed to map cmd/ctl ports\n");
781 return -ENOMEM; 782 return -ENOMEM;
783 }
782 784
783 /* init IO addresses */ 785 /* init IO addresses */
784 ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; 786 ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no];
@@ -792,19 +794,20 @@ static int ata_init_legacy_port(struct ata_port *ap,
792/** 794/**
793 * ata_init_legacy_host - acquire legacy ATA resources and init ATA host 795 * ata_init_legacy_host - acquire legacy ATA resources and init ATA host
794 * @host: target ATA host 796 * @host: target ATA host
795 * @legacy_mask: out parameter, mask indicating ports is in legacy mode
796 * @was_busy: out parameter, indicates whether any port was busy 797 * @was_busy: out parameter, indicates whether any port was busy
797 * 798 *
798 * Acquire legacy ATA resources for ports. 799 * Acquire legacy ATA resources for the first two ports of @host
800 * and initialize it accordingly. Ports marked dummy are skipped
801 * and resource acquistion failure makes the port dummy.
799 * 802 *
800 * LOCKING: 803 * LOCKING:
801 * Inherited from calling layer (may sleep). 804 * Inherited from calling layer (may sleep).
802 * 805 *
803 * RETURNS: 806 * RETURNS:
804 * 0 on success, -errno otherwise. 807 * 0 if at least one port is initialized, -ENODEV if no port is
808 * available.
805 */ 809 */
806static int ata_init_legacy_host(struct ata_host *host, 810static int ata_init_legacy_host(struct ata_host *host, int *was_busy)
807 unsigned int *legacy_mask, int *was_busy)
808{ 811{
809 struct device *gdev = host->dev; 812 struct device *gdev = host->dev;
810 struct ata_legacy_devres *legacy_dr; 813 struct ata_legacy_devres *legacy_dr;
@@ -821,22 +824,23 @@ static int ata_init_legacy_host(struct ata_host *host,
821 devres_add(gdev, legacy_dr); 824 devres_add(gdev, legacy_dr);
822 825
823 for (i = 0; i < 2; i++) { 826 for (i = 0; i < 2; i++) {
824 *legacy_mask &= ~(1 << i); 827 if (ata_port_is_dummy(host->ports[i]))
828 continue;
829
825 rc = ata_init_legacy_port(host->ports[i], legacy_dr); 830 rc = ata_init_legacy_port(host->ports[i], legacy_dr);
826 if (rc == 0) 831 if (rc == 0)
827 legacy_dr->mask |= 1 << i; 832 legacy_dr->mask |= 1 << i;
828 else if (rc == -EBUSY) 833 else {
829 (*was_busy)++; 834 if (rc == -EBUSY)
830 } 835 (*was_busy)++;
831
832 if (!legacy_dr->mask)
833 return -EBUSY;
834
835 for (i = 0; i < 2; i++)
836 if (!(legacy_dr->mask & (1 << i)))
837 host->ports[i]->ops = &ata_dummy_port_ops; 836 host->ports[i]->ops = &ata_dummy_port_ops;
837 }
838 }
838 839
839 *legacy_mask |= legacy_dr->mask; 840 if (!legacy_dr->mask) {
841 dev_printk(KERN_ERR, gdev, "no available legacy port\n");
842 return -ENODEV;
843 }
840 844
841 devres_remove_group(gdev, NULL); 845 devres_remove_group(gdev, NULL);
842 return 0; 846 return 0;
@@ -875,7 +879,7 @@ static int ata_request_legacy_irqs(struct ata_host *host,
875 legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); 879 legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL);
876 BUG_ON(!legacy_dr); 880 BUG_ON(!legacy_dr);
877 881
878 for (i = 0; i < host->n_ports; i++) { 882 for (i = 0; i < 2; i++) {
879 unsigned int irq; 883 unsigned int irq;
880 884
881 /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ 885 /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */
@@ -923,8 +927,7 @@ static int ata_request_legacy_irqs(struct ata_host *host,
923/** 927/**
924 * ata_pci_init_one - Initialize/register PCI IDE host controller 928 * ata_pci_init_one - Initialize/register PCI IDE host controller
925 * @pdev: Controller to be initialized 929 * @pdev: Controller to be initialized
926 * @port_info: Information from low-level host driver 930 * @ppi: array of port_info, must be enough for two ports
927 * @n_ports: Number of ports attached to host controller
928 * 931 *
929 * This is a helper function which can be called from a driver's 932 * This is a helper function which can be called from a driver's
930 * xxx_init_one() probe function if the hardware uses traditional 933 * xxx_init_one() probe function if the hardware uses traditional
@@ -944,26 +947,34 @@ static int ata_request_legacy_irqs(struct ata_host *host,
944 * RETURNS: 947 * RETURNS:
945 * Zero on success, negative on errno-based value on error. 948 * Zero on success, negative on errno-based value on error.
946 */ 949 */
947 950int ata_pci_init_one(struct pci_dev *pdev,
948int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 951 const struct ata_port_info * const * ppi)
949 unsigned int n_ports)
950{ 952{
951 struct device *dev = &pdev->dev; 953 struct device *dev = &pdev->dev;
954 const struct ata_port_info *pi = NULL;
952 struct ata_host *host = NULL; 955 struct ata_host *host = NULL;
953 const struct ata_port_info *port[2];
954 u8 mask; 956 u8 mask;
955 unsigned int legacy_mode = 0; 957 int legacy_mode = 0;
956 int rc; 958 int i, rc;
957 959
958 DPRINTK("ENTER\n"); 960 DPRINTK("ENTER\n");
959 961
960 if (!devres_open_group(dev, NULL, GFP_KERNEL)) 962 /* look up the first valid port_info */
961 return -ENOMEM; 963 for (i = 0; i < 2 && ppi[i]; i++) {
964 if (ppi[i]->port_ops != &ata_dummy_port_ops) {
965 pi = ppi[i];
966 break;
967 }
968 }
962 969
963 BUG_ON(n_ports < 1 || n_ports > 2); 970 if (!pi) {
971 dev_printk(KERN_ERR, &pdev->dev,
972 "no valid port_info specified\n");
973 return -EINVAL;
974 }
964 975
965 port[0] = port_info[0]; 976 if (!devres_open_group(dev, NULL, GFP_KERNEL))
966 port[1] = (n_ports > 1) ? port_info[1] : NULL; 977 return -ENOMEM;
967 978
968 /* FIXME: Really for ATA it isn't safe because the device may be 979 /* FIXME: Really for ATA it isn't safe because the device may be
969 multi-purpose and we want to leave it alone if it was already 980 multi-purpose and we want to leave it alone if it was already
@@ -984,7 +995,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
984 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); 995 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
985 mask = (1 << 2) | (1 << 0); 996 mask = (1 << 2) | (1 << 0);
986 if ((tmp8 & mask) != mask) 997 if ((tmp8 & mask) != mask)
987 legacy_mode = (1 << 3); 998 legacy_mode = 1;
988#if defined(CONFIG_NO_ATA_LEGACY) 999#if defined(CONFIG_NO_ATA_LEGACY)
989 /* Some platforms with PCI limits cannot address compat 1000 /* Some platforms with PCI limits cannot address compat
990 port space. In that case we punt if their firmware has 1001 port space. In that case we punt if their firmware has
@@ -998,7 +1009,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
998 } 1009 }
999 1010
1000 /* alloc and init host */ 1011 /* alloc and init host */
1001 host = ata_host_alloc_pinfo(dev, port, n_ports); 1012 host = ata_host_alloc_pinfo(dev, ppi, 2);
1002 if (!host) { 1013 if (!host) {
1003 dev_printk(KERN_ERR, &pdev->dev, 1014 dev_printk(KERN_ERR, &pdev->dev,
1004 "failed to allocate ATA host\n"); 1015 "failed to allocate ATA host\n");
@@ -1007,19 +1018,13 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1007 } 1018 }
1008 1019
1009 if (!legacy_mode) { 1020 if (!legacy_mode) {
1010 unsigned int port_mask; 1021 rc = ata_pci_init_native_host(host);
1011
1012 port_mask = ATA_PORT_PRIMARY;
1013 if (n_ports > 1)
1014 port_mask |= ATA_PORT_SECONDARY;
1015
1016 rc = ata_pci_init_native_host(host, port_mask);
1017 if (rc) 1022 if (rc)
1018 goto err_out; 1023 goto err_out;
1019 } else { 1024 } else {
1020 int was_busy = 0; 1025 int was_busy = 0;
1021 1026
1022 rc = ata_init_legacy_host(host, &legacy_mode, &was_busy); 1027 rc = ata_init_legacy_host(host, &was_busy);
1023 if (was_busy) 1028 if (was_busy)
1024 pcim_pin_device(pdev); 1029 pcim_pin_device(pdev);
1025 if (rc) 1030 if (rc)
@@ -1040,8 +1045,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1040 goto err_out; 1045 goto err_out;
1041 1046
1042 if (!legacy_mode) 1047 if (!legacy_mode)
1043 rc = devm_request_irq(dev, pdev->irq, 1048 rc = devm_request_irq(dev, pdev->irq, pi->port_ops->irq_handler,
1044 port_info[0]->port_ops->irq_handler,
1045 IRQF_SHARED, DRV_NAME, host); 1049 IRQF_SHARED, DRV_NAME, host);
1046 else { 1050 else {
1047 irq_handler_t handler[2] = { host->ops->irq_handler, 1051 irq_handler_t handler[2] = { host->ops->irq_handler,
@@ -1055,7 +1059,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1055 goto err_out; 1059 goto err_out;
1056 1060
1057 /* register */ 1061 /* register */
1058 rc = ata_host_register(host, port_info[0]->sht); 1062 rc = ata_host_register(host, pi->sht);
1059 if (rc) 1063 if (rc)
1060 goto err_out; 1064 goto err_out;
1061 1065
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 5f4d40cd3288..8b71b73a199c 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -58,6 +58,7 @@ extern int atapi_enabled;
58extern int atapi_dmadir; 58extern int atapi_dmadir;
59extern int libata_fua; 59extern int libata_fua;
60extern int libata_noacpi; 60extern int libata_noacpi;
61extern int ata_spindown_compat;
61extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); 62extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
62extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 63extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
63 u64 block, u32 n_block, unsigned int tf_flags, 64 u64 block, u32 n_block, unsigned int tf_flags,
@@ -96,15 +97,15 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
96extern struct ata_port *ata_port_alloc(struct ata_host *host); 97extern struct ata_port *ata_port_alloc(struct ata_host *host);
97 98
98/* libata-acpi.c */ 99/* libata-acpi.c */
99#ifdef CONFIG_SATA_ACPI 100#ifdef CONFIG_ATA_ACPI
100extern int ata_acpi_exec_tfs(struct ata_port *ap); 101extern int ata_acpi_exec_tfs(struct ata_port *ap);
101extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix); 102extern int ata_acpi_push_id(struct ata_device *dev);
102#else 103#else
103static inline int ata_acpi_exec_tfs(struct ata_port *ap) 104static inline int ata_acpi_exec_tfs(struct ata_port *ap)
104{ 105{
105 return 0; 106 return 0;
106} 107}
107static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) 108static inline int ata_acpi_push_id(struct ata_device *dev)
108{ 109{
109 return 0; 110 return 0;
110} 111}
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index d40edebb510a..3c55a5ff74c7 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -291,10 +291,6 @@ static struct scsi_host_template ali_sht = {
291 .slave_configure = ata_scsi_slave_config, 291 .slave_configure = ata_scsi_slave_config,
292 .slave_destroy = ata_scsi_slave_destroy, 292 .slave_destroy = ata_scsi_slave_destroy,
293 .bios_param = ata_std_bios_param, 293 .bios_param = ata_std_bios_param,
294#ifdef CONFIG_PM
295 .resume = ata_scsi_device_resume,
296 .suspend = ata_scsi_device_suspend,
297#endif
298}; 294};
299 295
300/* 296/*
@@ -522,14 +518,14 @@ static void ali_init_chipset(struct pci_dev *pdev)
522 518
523static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 519static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
524{ 520{
525 static struct ata_port_info info_early = { 521 static const struct ata_port_info info_early = {
526 .sht = &ali_sht, 522 .sht = &ali_sht,
527 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 523 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
528 .pio_mask = 0x1f, 524 .pio_mask = 0x1f,
529 .port_ops = &ali_early_port_ops 525 .port_ops = &ali_early_port_ops
530 }; 526 };
531 /* Revision 0x20 added DMA */ 527 /* Revision 0x20 added DMA */
532 static struct ata_port_info info_20 = { 528 static const struct ata_port_info info_20 = {
533 .sht = &ali_sht, 529 .sht = &ali_sht,
534 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 530 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
535 .pio_mask = 0x1f, 531 .pio_mask = 0x1f,
@@ -537,7 +533,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
537 .port_ops = &ali_20_port_ops 533 .port_ops = &ali_20_port_ops
538 }; 534 };
539 /* Revision 0x20 with support logic added UDMA */ 535 /* Revision 0x20 with support logic added UDMA */
540 static struct ata_port_info info_20_udma = { 536 static const struct ata_port_info info_20_udma = {
541 .sht = &ali_sht, 537 .sht = &ali_sht,
542 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 538 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
543 .pio_mask = 0x1f, 539 .pio_mask = 0x1f,
@@ -546,7 +542,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
546 .port_ops = &ali_20_port_ops 542 .port_ops = &ali_20_port_ops
547 }; 543 };
548 /* Revision 0xC2 adds UDMA66 */ 544 /* Revision 0xC2 adds UDMA66 */
549 static struct ata_port_info info_c2 = { 545 static const struct ata_port_info info_c2 = {
550 .sht = &ali_sht, 546 .sht = &ali_sht,
551 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 547 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
552 .pio_mask = 0x1f, 548 .pio_mask = 0x1f,
@@ -555,7 +551,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
555 .port_ops = &ali_c2_port_ops 551 .port_ops = &ali_c2_port_ops
556 }; 552 };
557 /* Revision 0xC3 is UDMA100 */ 553 /* Revision 0xC3 is UDMA100 */
558 static struct ata_port_info info_c3 = { 554 static const struct ata_port_info info_c3 = {
559 .sht = &ali_sht, 555 .sht = &ali_sht,
560 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 556 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
561 .pio_mask = 0x1f, 557 .pio_mask = 0x1f,
@@ -564,7 +560,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
564 .port_ops = &ali_c2_port_ops 560 .port_ops = &ali_c2_port_ops
565 }; 561 };
566 /* Revision 0xC4 is UDMA133 */ 562 /* Revision 0xC4 is UDMA133 */
567 static struct ata_port_info info_c4 = { 563 static const struct ata_port_info info_c4 = {
568 .sht = &ali_sht, 564 .sht = &ali_sht,
569 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 565 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
570 .pio_mask = 0x1f, 566 .pio_mask = 0x1f,
@@ -573,7 +569,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
573 .port_ops = &ali_c2_port_ops 569 .port_ops = &ali_c2_port_ops
574 }; 570 };
575 /* Revision 0xC5 is UDMA133 with LBA48 DMA */ 571 /* Revision 0xC5 is UDMA133 with LBA48 DMA */
576 static struct ata_port_info info_c5 = { 572 static const struct ata_port_info info_c5 = {
577 .sht = &ali_sht, 573 .sht = &ali_sht,
578 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 574 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
579 .pio_mask = 0x1f, 575 .pio_mask = 0x1f,
@@ -582,7 +578,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
582 .port_ops = &ali_c5_port_ops 578 .port_ops = &ali_c5_port_ops
583 }; 579 };
584 580
585 static struct ata_port_info *port_info[2]; 581 const struct ata_port_info *ppi[] = { NULL, NULL };
586 u8 rev, tmp; 582 u8 rev, tmp;
587 struct pci_dev *isa_bridge; 583 struct pci_dev *isa_bridge;
588 584
@@ -594,17 +590,17 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
594 */ 590 */
595 591
596 if (rev < 0x20) { 592 if (rev < 0x20) {
597 port_info[0] = port_info[1] = &info_early; 593 ppi[0] = &info_early;
598 } else if (rev < 0xC2) { 594 } else if (rev < 0xC2) {
599 port_info[0] = port_info[1] = &info_20; 595 ppi[0] = &info_20;
600 } else if (rev == 0xC2) { 596 } else if (rev == 0xC2) {
601 port_info[0] = port_info[1] = &info_c2; 597 ppi[0] = &info_c2;
602 } else if (rev == 0xC3) { 598 } else if (rev == 0xC3) {
603 port_info[0] = port_info[1] = &info_c3; 599 ppi[0] = &info_c3;
604 } else if (rev == 0xC4) { 600 } else if (rev == 0xC4) {
605 port_info[0] = port_info[1] = &info_c4; 601 ppi[0] = &info_c4;
606 } else 602 } else
607 port_info[0] = port_info[1] = &info_c5; 603 ppi[0] = &info_c5;
608 604
609 ali_init_chipset(pdev); 605 ali_init_chipset(pdev);
610 606
@@ -613,10 +609,10 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
613 /* Are we paired with a UDMA capable chip */ 609 /* Are we paired with a UDMA capable chip */
614 pci_read_config_byte(isa_bridge, 0x5E, &tmp); 610 pci_read_config_byte(isa_bridge, 0x5E, &tmp);
615 if ((tmp & 0x1E) == 0x12) 611 if ((tmp & 0x1E) == 0x12)
616 port_info[0] = port_info[1] = &info_20_udma; 612 ppi[0] = &info_20_udma;
617 pci_dev_put(isa_bridge); 613 pci_dev_put(isa_bridge);
618 } 614 }
619 return ata_pci_init_one(pdev, port_info, 2); 615 return ata_pci_init_one(pdev, ppi);
620} 616}
621 617
622#ifdef CONFIG_PM 618#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 67c7e87dec04..b439351f1fd3 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -324,10 +324,6 @@ static struct scsi_host_template amd_sht = {
324 .slave_configure = ata_scsi_slave_config, 324 .slave_configure = ata_scsi_slave_config,
325 .slave_destroy = ata_scsi_slave_destroy, 325 .slave_destroy = ata_scsi_slave_destroy,
326 .bios_param = ata_std_bios_param, 326 .bios_param = ata_std_bios_param,
327#ifdef CONFIG_PM
328 .resume = ata_scsi_device_resume,
329 .suspend = ata_scsi_device_suspend,
330#endif
331}; 327};
332 328
333static struct ata_port_operations amd33_port_ops = { 329static struct ata_port_operations amd33_port_ops = {
@@ -542,7 +538,7 @@ static struct ata_port_operations nv133_port_ops = {
542 538
543static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 539static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
544{ 540{
545 static struct ata_port_info info[10] = { 541 static const struct ata_port_info info[10] = {
546 { /* 0: AMD 7401 */ 542 { /* 0: AMD 7401 */
547 .sht = &amd_sht, 543 .sht = &amd_sht,
548 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 544 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -624,7 +620,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
624 .port_ops = &amd100_port_ops 620 .port_ops = &amd100_port_ops
625 } 621 }
626 }; 622 };
627 static struct ata_port_info *port_info[2]; 623 const struct ata_port_info *ppi[] = { NULL, NULL };
628 static int printed_version; 624 static int printed_version;
629 int type = id->driver_data; 625 int type = id->driver_data;
630 u8 rev; 626 u8 rev;
@@ -656,9 +652,8 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
656 ata_pci_clear_simplex(pdev); 652 ata_pci_clear_simplex(pdev);
657 653
658 /* And fire it up */ 654 /* And fire it up */
659 655 ppi[0] = &info[type];
660 port_info[0] = port_info[1] = &info[type]; 656 return ata_pci_init_one(pdev, ppi);
661 return ata_pci_init_one(pdev, port_info, 2);
662} 657}
663 658
664#ifdef CONFIG_PM 659#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index ef51940c3adb..9861059dd673 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = {
414static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 414static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
415{ 415{
416 static int printed_version; 416 static int printed_version;
417 static struct ata_port_info info_6210 = { 417 static const struct ata_port_info info_6210 = {
418 .sht = &artop_sht, 418 .sht = &artop_sht,
419 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 419 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
420 .pio_mask = 0x1f, /* pio0-4 */ 420 .pio_mask = 0x1f, /* pio0-4 */
@@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
422 .udma_mask = ATA_UDMA2, 422 .udma_mask = ATA_UDMA2,
423 .port_ops = &artop6210_ops, 423 .port_ops = &artop6210_ops,
424 }; 424 };
425 static struct ata_port_info info_626x = { 425 static const struct ata_port_info info_626x = {
426 .sht = &artop_sht, 426 .sht = &artop_sht,
427 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 427 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
428 .pio_mask = 0x1f, /* pio0-4 */ 428 .pio_mask = 0x1f, /* pio0-4 */
@@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
430 .udma_mask = ATA_UDMA4, 430 .udma_mask = ATA_UDMA4,
431 .port_ops = &artop6260_ops, 431 .port_ops = &artop6260_ops,
432 }; 432 };
433 static struct ata_port_info info_626x_fast = { 433 static const struct ata_port_info info_626x_fast = {
434 .sht = &artop_sht, 434 .sht = &artop_sht,
435 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 435 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
436 .pio_mask = 0x1f, /* pio0-4 */ 436 .pio_mask = 0x1f, /* pio0-4 */
@@ -438,32 +438,30 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
438 .udma_mask = ATA_UDMA5, 438 .udma_mask = ATA_UDMA5,
439 .port_ops = &artop6260_ops, 439 .port_ops = &artop6260_ops,
440 }; 440 };
441 struct ata_port_info *port_info[2]; 441 const struct ata_port_info *ppi[] = { NULL, NULL };
442 struct ata_port_info *info = NULL;
443 int ports = 2;
444 442
445 if (!printed_version++) 443 if (!printed_version++)
446 dev_printk(KERN_DEBUG, &pdev->dev, 444 dev_printk(KERN_DEBUG, &pdev->dev,
447 "version " DRV_VERSION "\n"); 445 "version " DRV_VERSION "\n");
448 446
449 if (id->driver_data == 0) { /* 6210 variant */ 447 if (id->driver_data == 0) { /* 6210 variant */
450 info = &info_6210; 448 ppi[0] = &info_6210;
449 ppi[1] = &ata_dummy_port_info;
451 /* BIOS may have left us in UDMA, clear it before libata probe */ 450 /* BIOS may have left us in UDMA, clear it before libata probe */
452 pci_write_config_byte(pdev, 0x54, 0); 451 pci_write_config_byte(pdev, 0x54, 0);
453 /* For the moment (also lacks dsc) */ 452 /* For the moment (also lacks dsc) */
454 printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); 453 printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n");
455 printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); 454 printk(KERN_WARNING "Secondary ATA ports will not be activated.\n");
456 ports = 1;
457 } 455 }
458 else if (id->driver_data == 1) /* 6260 */ 456 else if (id->driver_data == 1) /* 6260 */
459 info = &info_626x; 457 ppi[0] = &info_626x;
460 else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ 458 else if (id->driver_data == 2) { /* 6260 or 6260 + fast */
461 unsigned long io = pci_resource_start(pdev, 4); 459 unsigned long io = pci_resource_start(pdev, 4);
462 u8 reg; 460 u8 reg;
463 461
464 info = &info_626x; 462 ppi[0] = &info_626x;
465 if (inb(io) & 0x10) 463 if (inb(io) & 0x10)
466 info = &info_626x_fast; 464 ppi[0] = &info_626x_fast;
467 /* Mac systems come up with some registers not set as we 465 /* Mac systems come up with some registers not set as we
468 will need them */ 466 will need them */
469 467
@@ -484,10 +482,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
484 482
485 } 483 }
486 484
487 BUG_ON(info == NULL); 485 BUG_ON(ppi[0] == NULL);
488 486
489 port_info[0] = port_info[1] = info; 487 return ata_pci_init_one(pdev, ppi);
490 return ata_pci_init_one(pdev, port_info, ports);
491} 488}
492 489
493static const struct pci_device_id artop_pci_tbl[] = { 490static const struct pci_device_id artop_pci_tbl[] = {
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 21515381b5b3..844914681a2a 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -229,10 +229,6 @@ static struct scsi_host_template atiixp_sht = {
229 .slave_configure = ata_scsi_slave_config, 229 .slave_configure = ata_scsi_slave_config,
230 .slave_destroy = ata_scsi_slave_destroy, 230 .slave_destroy = ata_scsi_slave_destroy,
231 .bios_param = ata_std_bios_param, 231 .bios_param = ata_std_bios_param,
232#ifdef CONFIG_PM
233 .resume = ata_scsi_device_resume,
234 .suspend = ata_scsi_device_suspend,
235#endif
236}; 232};
237 233
238static struct ata_port_operations atiixp_port_ops = { 234static struct ata_port_operations atiixp_port_ops = {
@@ -272,7 +268,7 @@ static struct ata_port_operations atiixp_port_ops = {
272 268
273static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) 269static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
274{ 270{
275 static struct ata_port_info info = { 271 static const struct ata_port_info info = {
276 .sht = &atiixp_sht, 272 .sht = &atiixp_sht,
277 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 273 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
278 .pio_mask = 0x1f, 274 .pio_mask = 0x1f,
@@ -280,8 +276,8 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
280 .udma_mask = 0x3F, 276 .udma_mask = 0x3F,
281 .port_ops = &atiixp_port_ops 277 .port_ops = &atiixp_port_ops
282 }; 278 };
283 static struct ata_port_info *port_info[2] = { &info, &info }; 279 const struct ata_port_info *ppi[] = { &info, NULL };
284 return ata_pci_init_one(dev, port_info, 2); 280 return ata_pci_init_one(dev, ppi);
285} 281}
286 282
287static const struct pci_device_id atiixp[] = { 283static const struct pci_device_id atiixp[] = {
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 2105985a8013..ed00fa9d53be 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -181,10 +181,6 @@ static struct scsi_host_template cmd640_sht = {
181 .slave_configure = ata_scsi_slave_config, 181 .slave_configure = ata_scsi_slave_config,
182 .slave_destroy = ata_scsi_slave_destroy, 182 .slave_destroy = ata_scsi_slave_destroy,
183 .bios_param = ata_std_bios_param, 183 .bios_param = ata_std_bios_param,
184#ifdef CONFIG_PM
185 .resume = ata_scsi_device_resume,
186 .suspend = ata_scsi_device_suspend,
187#endif
188}; 184};
189 185
190static struct ata_port_operations cmd640_port_ops = { 186static struct ata_port_operations cmd640_port_ops = {
@@ -253,17 +249,16 @@ static void cmd640_hardware_init(struct pci_dev *pdev)
253 249
254static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 250static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
255{ 251{
256 static struct ata_port_info info = { 252 static const struct ata_port_info info = {
257 .sht = &cmd640_sht, 253 .sht = &cmd640_sht,
258 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 254 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
259 .pio_mask = 0x1f, 255 .pio_mask = 0x1f,
260 .port_ops = &cmd640_port_ops 256 .port_ops = &cmd640_port_ops
261 }; 257 };
262 258 const struct ata_port_info *ppi[] = { &info, NULL };
263 static struct ata_port_info *port_info[2] = { &info, &info };
264 259
265 cmd640_hardware_init(pdev); 260 cmd640_hardware_init(pdev);
266 return ata_pci_init_one(pdev, port_info, 2); 261 return ata_pci_init_one(pdev, ppi);
267} 262}
268 263
269static int cmd640_reinit_one(struct pci_dev *pdev) 264static int cmd640_reinit_one(struct pci_dev *pdev)
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 3989cc577fcd..2a79b335cfcc 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -266,10 +266,6 @@ static struct scsi_host_template cmd64x_sht = {
266 .slave_configure = ata_scsi_slave_config, 266 .slave_configure = ata_scsi_slave_config,
267 .slave_destroy = ata_scsi_slave_destroy, 267 .slave_destroy = ata_scsi_slave_destroy,
268 .bios_param = ata_std_bios_param, 268 .bios_param = ata_std_bios_param,
269#ifdef CONFIG_PM
270 .resume = ata_scsi_device_resume,
271 .suspend = ata_scsi_device_suspend,
272#endif
273}; 269};
274 270
275static struct ata_port_operations cmd64x_port_ops = { 271static struct ata_port_operations cmd64x_port_ops = {
@@ -381,7 +377,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
381{ 377{
382 u32 class_rev; 378 u32 class_rev;
383 379
384 static struct ata_port_info cmd_info[6] = { 380 static const struct ata_port_info cmd_info[6] = {
385 { /* CMD 643 - no UDMA */ 381 { /* CMD 643 - no UDMA */
386 .sht = &cmd64x_sht, 382 .sht = &cmd64x_sht,
387 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 383 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -428,11 +424,9 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
428 .port_ops = &cmd648_port_ops 424 .port_ops = &cmd648_port_ops
429 } 425 }
430 }; 426 };
431 static struct ata_port_info *port_info[2], *info; 427 const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL };
432 u8 mrdmode; 428 u8 mrdmode;
433 429
434 info = &cmd_info[id->driver_data];
435
436 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); 430 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
437 class_rev &= 0xFF; 431 class_rev &= 0xFF;
438 432
@@ -442,10 +436,10 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
442 if (pdev->device == PCI_DEVICE_ID_CMD_646) { 436 if (pdev->device == PCI_DEVICE_ID_CMD_646) {
443 /* Does UDMA work ? */ 437 /* Does UDMA work ? */
444 if (class_rev > 4) 438 if (class_rev > 4)
445 info = &cmd_info[2]; 439 ppi[0] = &cmd_info[2];
446 /* Early rev with other problems ? */ 440 /* Early rev with other problems ? */
447 else if (class_rev == 1) 441 else if (class_rev == 1)
448 info = &cmd_info[3]; 442 ppi[0] = &cmd_info[3];
449 } 443 }
450 444
451 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); 445 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
@@ -461,8 +455,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
461 pci_write_config_byte(pdev, UDIDETCR0, 0xF0); 455 pci_write_config_byte(pdev, UDIDETCR0, 0xF0);
462#endif 456#endif
463 457
464 port_info[0] = port_info[1] = info; 458 return ata_pci_init_one(pdev, ppi);
465 return ata_pci_init_one(pdev, port_info, 2);
466} 459}
467 460
468#ifdef CONFIG_PM 461#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index 79bef0d1fad3..83bcc5b32597 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -155,10 +155,6 @@ static struct scsi_host_template cs5520_sht = {
155 .slave_configure = ata_scsi_slave_config, 155 .slave_configure = ata_scsi_slave_config,
156 .slave_destroy = ata_scsi_slave_destroy, 156 .slave_destroy = ata_scsi_slave_destroy,
157 .bios_param = ata_std_bios_param, 157 .bios_param = ata_std_bios_param,
158#ifdef CONFIG_PM
159 .resume = ata_scsi_device_resume,
160 .suspend = ata_scsi_device_suspend,
161#endif
162}; 158};
163 159
164static struct ata_port_operations cs5520_port_ops = { 160static struct ata_port_operations cs5520_port_ops = {
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index 29642d5ee189..1b67923d7a4e 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -176,10 +176,6 @@ static struct scsi_host_template cs5530_sht = {
176 .slave_configure = ata_scsi_slave_config, 176 .slave_configure = ata_scsi_slave_config,
177 .slave_destroy = ata_scsi_slave_destroy, 177 .slave_destroy = ata_scsi_slave_destroy,
178 .bios_param = ata_std_bios_param, 178 .bios_param = ata_std_bios_param,
179#ifdef CONFIG_PM
180 .resume = ata_scsi_device_resume,
181 .suspend = ata_scsi_device_suspend,
182#endif
183}; 179};
184 180
185static struct ata_port_operations cs5530_port_ops = { 181static struct ata_port_operations cs5530_port_ops = {
@@ -339,7 +335,7 @@ fail_put:
339 335
340static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 336static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
341{ 337{
342 static struct ata_port_info info = { 338 static const struct ata_port_info info = {
343 .sht = &cs5530_sht, 339 .sht = &cs5530_sht,
344 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 340 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
345 .pio_mask = 0x1f, 341 .pio_mask = 0x1f,
@@ -348,23 +344,23 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
348 .port_ops = &cs5530_port_ops 344 .port_ops = &cs5530_port_ops
349 }; 345 };
350 /* The docking connector doesn't do UDMA, and it seems not MWDMA */ 346 /* The docking connector doesn't do UDMA, and it seems not MWDMA */
351 static struct ata_port_info info_palmax_secondary = { 347 static const struct ata_port_info info_palmax_secondary = {
352 .sht = &cs5530_sht, 348 .sht = &cs5530_sht,
353 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 349 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
354 .pio_mask = 0x1f, 350 .pio_mask = 0x1f,
355 .port_ops = &cs5530_port_ops 351 .port_ops = &cs5530_port_ops
356 }; 352 };
357 static struct ata_port_info *port_info[2] = { &info, &info }; 353 const struct ata_port_info *ppi[] = { &info, NULL };
358 354
359 /* Chip initialisation */ 355 /* Chip initialisation */
360 if (cs5530_init_chip()) 356 if (cs5530_init_chip())
361 return -ENODEV; 357 return -ENODEV;
362 358
363 if (cs5530_is_palmax()) 359 if (cs5530_is_palmax())
364 port_info[1] = &info_palmax_secondary; 360 ppi[1] = &info_palmax_secondary;
365 361
366 /* Now kick off ATA set up */ 362 /* Now kick off ATA set up */
367 return ata_pci_init_one(pdev, port_info, 2); 363 return ata_pci_init_one(pdev, ppi);
368} 364}
369 365
370#ifdef CONFIG_PM 366#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index 22006ae71941..f37d4cd812a1 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -173,10 +173,6 @@ static struct scsi_host_template cs5535_sht = {
173 .slave_configure = ata_scsi_slave_config, 173 .slave_configure = ata_scsi_slave_config,
174 .slave_destroy = ata_scsi_slave_destroy, 174 .slave_destroy = ata_scsi_slave_destroy,
175 .bios_param = ata_std_bios_param, 175 .bios_param = ata_std_bios_param,
176#ifdef CONFIG_PM
177 .resume = ata_scsi_device_resume,
178 .suspend = ata_scsi_device_suspend,
179#endif
180}; 176};
181 177
182static struct ata_port_operations cs5535_port_ops = { 178static struct ata_port_operations cs5535_port_ops = {
@@ -227,7 +223,7 @@ static struct ata_port_operations cs5535_port_ops = {
227 223
228static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) 224static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
229{ 225{
230 static struct ata_port_info info = { 226 static const struct ata_port_info info = {
231 .sht = &cs5535_sht, 227 .sht = &cs5535_sht,
232 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 228 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
233 .pio_mask = 0x1f, 229 .pio_mask = 0x1f,
@@ -235,7 +231,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
235 .udma_mask = 0x1f, 231 .udma_mask = 0x1f,
236 .port_ops = &cs5535_port_ops 232 .port_ops = &cs5535_port_ops
237 }; 233 };
238 struct ata_port_info *ports[1] = { &info }; 234 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
239 235
240 u32 timings, dummy; 236 u32 timings, dummy;
241 237
@@ -247,7 +243,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
247 rdmsr(ATAC_CH0D1_PIO, timings, dummy); 243 rdmsr(ATAC_CH0D1_PIO, timings, dummy);
248 if (CS5535_BAD_PIO(timings)) 244 if (CS5535_BAD_PIO(timings))
249 wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); 245 wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0);
250 return ata_pci_init_one(dev, ports, 1); 246 return ata_pci_init_one(dev, ppi);
251} 247}
252 248
253static const struct pci_device_id cs5535[] = { 249static const struct pci_device_id cs5535[] = {
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
index 6ec049c3b1dc..27b9f29c01e3 100644
--- a/drivers/ata/pata_cypress.c
+++ b/drivers/ata/pata_cypress.c
@@ -125,10 +125,6 @@ static struct scsi_host_template cy82c693_sht = {
125 .slave_configure = ata_scsi_slave_config, 125 .slave_configure = ata_scsi_slave_config,
126 .slave_destroy = ata_scsi_slave_destroy, 126 .slave_destroy = ata_scsi_slave_destroy,
127 .bios_param = ata_std_bios_param, 127 .bios_param = ata_std_bios_param,
128#ifdef CONFIG_PM
129 .resume = ata_scsi_device_resume,
130 .suspend = ata_scsi_device_suspend,
131#endif
132}; 128};
133 129
134static struct ata_port_operations cy82c693_port_ops = { 130static struct ata_port_operations cy82c693_port_ops = {
@@ -169,14 +165,14 @@ static struct ata_port_operations cy82c693_port_ops = {
169 165
170static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 166static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
171{ 167{
172 static struct ata_port_info info = { 168 static const struct ata_port_info info = {
173 .sht = &cy82c693_sht, 169 .sht = &cy82c693_sht,
174 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 170 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
175 .pio_mask = 0x1f, 171 .pio_mask = 0x1f,
176 .mwdma_mask = 0x07, 172 .mwdma_mask = 0x07,
177 .port_ops = &cy82c693_port_ops 173 .port_ops = &cy82c693_port_ops
178 }; 174 };
179 static struct ata_port_info *port_info[1] = { &info }; 175 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
180 176
181 /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. 177 /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2.
182 For the moment we don't handle the secondary. FIXME */ 178 For the moment we don't handle the secondary. FIXME */
@@ -184,7 +180,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i
184 if (PCI_FUNC(pdev->devfn) != 1) 180 if (PCI_FUNC(pdev->devfn) != 1)
185 return -ENODEV; 181 return -ENODEV;
186 182
187 return ata_pci_init_one(pdev, port_info, 1); 183 return ata_pci_init_one(pdev, ppi);
188} 184}
189 185
190static const struct pci_device_id cy82c693[] = { 186static const struct pci_device_id cy82c693[] = {
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index d0f52e034906..079248a9b460 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -247,10 +247,6 @@ static struct scsi_host_template efar_sht = {
247 .slave_configure = ata_scsi_slave_config, 247 .slave_configure = ata_scsi_slave_config,
248 .slave_destroy = ata_scsi_slave_destroy, 248 .slave_destroy = ata_scsi_slave_destroy,
249 .bios_param = ata_std_bios_param, 249 .bios_param = ata_std_bios_param,
250#ifdef CONFIG_PM
251 .resume = ata_scsi_device_resume,
252 .suspend = ata_scsi_device_suspend,
253#endif
254}; 250};
255 251
256static const struct ata_port_operations efar_ops = { 252static const struct ata_port_operations efar_ops = {
@@ -305,7 +301,7 @@ static const struct ata_port_operations efar_ops = {
305static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 301static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
306{ 302{
307 static int printed_version; 303 static int printed_version;
308 static struct ata_port_info info = { 304 static const struct ata_port_info info = {
309 .sht = &efar_sht, 305 .sht = &efar_sht,
310 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 306 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
311 .pio_mask = 0x1f, /* pio0-4 */ 307 .pio_mask = 0x1f, /* pio0-4 */
@@ -313,13 +309,13 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
313 .udma_mask = 0x0f, /* UDMA 66 */ 309 .udma_mask = 0x0f, /* UDMA 66 */
314 .port_ops = &efar_ops, 310 .port_ops = &efar_ops,
315 }; 311 };
316 static struct ata_port_info *port_info[2] = { &info, &info }; 312 const struct ata_port_info *ppi[] = { &info, NULL };
317 313
318 if (!printed_version++) 314 if (!printed_version++)
319 dev_printk(KERN_DEBUG, &pdev->dev, 315 dev_printk(KERN_DEBUG, &pdev->dev,
320 "version " DRV_VERSION "\n"); 316 "version " DRV_VERSION "\n");
321 317
322 return ata_pci_init_one(pdev, port_info, 2); 318 return ata_pci_init_one(pdev, ppi);
323} 319}
324 320
325static const struct pci_device_id efar_pci_tbl[] = { 321static const struct pci_device_id efar_pci_tbl[] = {
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index e64e05e5c7fe..c6c8a8bb06d0 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -331,10 +331,6 @@ static struct scsi_host_template hpt36x_sht = {
331 .slave_configure = ata_scsi_slave_config, 331 .slave_configure = ata_scsi_slave_config,
332 .slave_destroy = ata_scsi_slave_destroy, 332 .slave_destroy = ata_scsi_slave_destroy,
333 .bios_param = ata_std_bios_param, 333 .bios_param = ata_std_bios_param,
334#ifdef CONFIG_PM
335 .resume = ata_scsi_device_resume,
336 .suspend = ata_scsi_device_suspend,
337#endif
338}; 334};
339 335
340/* 336/*
@@ -421,7 +417,7 @@ static void hpt36x_init_chipset(struct pci_dev *dev)
421 417
422static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 418static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
423{ 419{
424 static struct ata_port_info info_hpt366 = { 420 static const struct ata_port_info info_hpt366 = {
425 .sht = &hpt36x_sht, 421 .sht = &hpt36x_sht,
426 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 422 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
427 .pio_mask = 0x1f, 423 .pio_mask = 0x1f,
@@ -429,7 +425,8 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
429 .udma_mask = 0x1f, 425 .udma_mask = 0x1f,
430 .port_ops = &hpt366_port_ops 426 .port_ops = &hpt366_port_ops
431 }; 427 };
432 struct ata_port_info *port_info[2] = {&info_hpt366, &info_hpt366}; 428 struct ata_port_info info = info_hpt366;
429 const struct ata_port_info *ppi[] = { &info, NULL };
433 430
434 u32 class_rev; 431 u32 class_rev;
435 u32 reg1; 432 u32 reg1;
@@ -450,17 +447,17 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
450 /* info_hpt366 is safe against re-entry so we can scribble on it */ 447 /* info_hpt366 is safe against re-entry so we can scribble on it */
451 switch((reg1 & 0x700) >> 8) { 448 switch((reg1 & 0x700) >> 8) {
452 case 5: 449 case 5:
453 info_hpt366.private_data = &hpt366_40; 450 info.private_data = &hpt366_40;
454 break; 451 break;
455 case 9: 452 case 9:
456 info_hpt366.private_data = &hpt366_25; 453 info.private_data = &hpt366_25;
457 break; 454 break;
458 default: 455 default:
459 info_hpt366.private_data = &hpt366_33; 456 info.private_data = &hpt366_33;
460 break; 457 break;
461 } 458 }
462 /* Now kick off ATA set up */ 459 /* Now kick off ATA set up */
463 return ata_pci_init_one(dev, port_info, 2); 460 return ata_pci_init_one(dev, ppi);
464} 461}
465 462
466#ifdef CONFIG_PM 463#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 1614e8c822a4..5a0a410654e2 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -887,7 +887,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
887static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 887static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
888{ 888{
889 /* HPT370 - UDMA100 */ 889 /* HPT370 - UDMA100 */
890 static struct ata_port_info info_hpt370 = { 890 static const struct ata_port_info info_hpt370 = {
891 .sht = &hpt37x_sht, 891 .sht = &hpt37x_sht,
892 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 892 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
893 .pio_mask = 0x1f, 893 .pio_mask = 0x1f,
@@ -896,7 +896,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
896 .port_ops = &hpt370_port_ops 896 .port_ops = &hpt370_port_ops
897 }; 897 };
898 /* HPT370A - UDMA100 */ 898 /* HPT370A - UDMA100 */
899 static struct ata_port_info info_hpt370a = { 899 static const struct ata_port_info info_hpt370a = {
900 .sht = &hpt37x_sht, 900 .sht = &hpt37x_sht,
901 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 901 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
902 .pio_mask = 0x1f, 902 .pio_mask = 0x1f,
@@ -905,7 +905,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
905 .port_ops = &hpt370a_port_ops 905 .port_ops = &hpt370a_port_ops
906 }; 906 };
907 /* HPT370 - UDMA100 */ 907 /* HPT370 - UDMA100 */
908 static struct ata_port_info info_hpt370_33 = { 908 static const struct ata_port_info info_hpt370_33 = {
909 .sht = &hpt37x_sht, 909 .sht = &hpt37x_sht,
910 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 910 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
911 .pio_mask = 0x1f, 911 .pio_mask = 0x1f,
@@ -914,7 +914,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
914 .port_ops = &hpt370_port_ops 914 .port_ops = &hpt370_port_ops
915 }; 915 };
916 /* HPT370A - UDMA100 */ 916 /* HPT370A - UDMA100 */
917 static struct ata_port_info info_hpt370a_33 = { 917 static const struct ata_port_info info_hpt370a_33 = {
918 .sht = &hpt37x_sht, 918 .sht = &hpt37x_sht,
919 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 919 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
920 .pio_mask = 0x1f, 920 .pio_mask = 0x1f,
@@ -923,7 +923,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
923 .port_ops = &hpt370a_port_ops 923 .port_ops = &hpt370a_port_ops
924 }; 924 };
925 /* HPT371, 372 and friends - UDMA133 */ 925 /* HPT371, 372 and friends - UDMA133 */
926 static struct ata_port_info info_hpt372 = { 926 static const struct ata_port_info info_hpt372 = {
927 .sht = &hpt37x_sht, 927 .sht = &hpt37x_sht,
928 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 928 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
929 .pio_mask = 0x1f, 929 .pio_mask = 0x1f,
@@ -932,7 +932,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
932 .port_ops = &hpt372_port_ops 932 .port_ops = &hpt372_port_ops
933 }; 933 };
934 /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ 934 /* HPT371, 372 and friends - UDMA100 at 50MHz clock */
935 static struct ata_port_info info_hpt372_50 = { 935 static const struct ata_port_info info_hpt372_50 = {
936 .sht = &hpt37x_sht, 936 .sht = &hpt37x_sht,
937 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 937 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
938 .pio_mask = 0x1f, 938 .pio_mask = 0x1f,
@@ -941,7 +941,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
941 .port_ops = &hpt372_port_ops 941 .port_ops = &hpt372_port_ops
942 }; 942 };
943 /* HPT374 - UDMA133 */ 943 /* HPT374 - UDMA133 */
944 static struct ata_port_info info_hpt374 = { 944 static const struct ata_port_info info_hpt374 = {
945 .sht = &hpt37x_sht, 945 .sht = &hpt37x_sht,
946 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 946 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
947 .pio_mask = 0x1f, 947 .pio_mask = 0x1f,
@@ -951,9 +951,10 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
951 }; 951 };
952 952
953 static const int MHz[4] = { 33, 40, 50, 66 }; 953 static const int MHz[4] = { 33, 40, 50, 66 };
954 954 const struct ata_port_info *port;
955 struct ata_port_info *port_info[2]; 955 void *private_data = NULL;
956 struct ata_port_info *port; 956 struct ata_port_info port_info;
957 const struct ata_port_info *ppi[] = { &port_info, NULL };
957 958
958 u8 irqmask; 959 u8 irqmask;
959 u32 class_rev; 960 u32 class_rev;
@@ -1124,13 +1125,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1124 return -ENODEV; 1125 return -ENODEV;
1125 } 1126 }
1126 if (clock_slot == 3) 1127 if (clock_slot == 3)
1127 port->private_data = (void *)hpt37x_timings_66; 1128 private_data = (void *)hpt37x_timings_66;
1128 else 1129 else
1129 port->private_data = (void *)hpt37x_timings_50; 1130 private_data = (void *)hpt37x_timings_50;
1130 1131
1131 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); 1132 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]);
1132 } else { 1133 } else {
1133 port->private_data = (void *)chip_table->clocks[clock_slot]; 1134 private_data = (void *)chip_table->clocks[clock_slot];
1134 /* 1135 /*
1135 * Perform a final fixup. Note that we will have used the 1136 * Perform a final fixup. Note that we will have used the
1136 * DPLL on the HPT372 which means we don't have to worry 1137 * DPLL on the HPT372 which means we don't have to worry
@@ -1144,9 +1145,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1144 printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); 1145 printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]);
1145 } 1146 }
1146 1147
1147 port_info[0] = port_info[1] = port;
1148 /* Now kick off ATA set up */ 1148 /* Now kick off ATA set up */
1149 return ata_pci_init_one(dev, port_info, 2); 1149 port_info = *port;
1150 port_info.private_data = private_data;
1151
1152 return ata_pci_init_one(dev, ppi);
1150} 1153}
1151 1154
1152static const struct pci_device_id hpt37x[] = { 1155static const struct pci_device_id hpt37x[] = {
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index ea1037d67860..f25154aed75d 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -488,7 +488,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
488static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) 488static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
489{ 489{
490 /* HPT372N and friends - UDMA133 */ 490 /* HPT372N and friends - UDMA133 */
491 static struct ata_port_info info = { 491 static const struct ata_port_info info = {
492 .sht = &hpt3x2n_sht, 492 .sht = &hpt3x2n_sht,
493 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 493 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
494 .pio_mask = 0x1f, 494 .pio_mask = 0x1f,
@@ -496,8 +496,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
496 .udma_mask = 0x7f, 496 .udma_mask = 0x7f,
497 .port_ops = &hpt3x2n_port_ops 497 .port_ops = &hpt3x2n_port_ops
498 }; 498 };
499 struct ata_port_info *port_info[2]; 499 struct ata_port_info port = info;
500 struct ata_port_info *port = &info; 500 const struct ata_port_info *ppi[] = { &port, NULL };
501 501
502 u8 irqmask; 502 u8 irqmask;
503 u32 class_rev; 503 u32 class_rev;
@@ -585,9 +585,9 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
585 585
586 /* Set our private data up. We only need a few flags so we use 586 /* Set our private data up. We only need a few flags so we use
587 it directly */ 587 it directly */
588 port->private_data = NULL; 588 port.private_data = NULL;
589 if (pci_mhz > 60) { 589 if (pci_mhz > 60) {
590 port->private_data = (void *)PCI66; 590 port.private_data = (void *)PCI66;
591 /* 591 /*
592 * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in 592 * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
593 * the MISC. register to stretch the UltraDMA Tss timing. 593 * the MISC. register to stretch the UltraDMA Tss timing.
@@ -598,8 +598,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
598 } 598 }
599 599
600 /* Now kick off ATA set up */ 600 /* Now kick off ATA set up */
601 port_info[0] = port_info[1] = port; 601 return ata_pci_init_one(dev, ppi);
602 return ata_pci_init_one(dev, port_info, 2);
603} 602}
604 603
605static const struct pci_device_id hpt3x2n[] = { 604static const struct pci_device_id hpt3x2n[] = {
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index ac28ec8c50aa..bbabe7902fbb 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -100,10 +100,6 @@ static struct scsi_host_template hpt3x3_sht = {
100 .slave_configure = ata_scsi_slave_config, 100 .slave_configure = ata_scsi_slave_config,
101 .slave_destroy = ata_scsi_slave_destroy, 101 .slave_destroy = ata_scsi_slave_destroy,
102 .bios_param = ata_std_bios_param, 102 .bios_param = ata_std_bios_param,
103#ifdef CONFIG_PM
104 .resume = ata_scsi_device_resume,
105 .suspend = ata_scsi_device_suspend,
106#endif
107}; 103};
108 104
109static struct ata_port_operations hpt3x3_port_ops = { 105static struct ata_port_operations hpt3x3_port_ops = {
@@ -175,7 +171,7 @@ static void hpt3x3_init_chipset(struct pci_dev *dev)
175 171
176static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) 172static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
177{ 173{
178 static struct ata_port_info info = { 174 static const struct ata_port_info info = {
179 .sht = &hpt3x3_sht, 175 .sht = &hpt3x3_sht,
180 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 176 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
181 .pio_mask = 0x1f, 177 .pio_mask = 0x1f,
@@ -183,11 +179,11 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
183 .udma_mask = 0x07, 179 .udma_mask = 0x07,
184 .port_ops = &hpt3x3_port_ops 180 .port_ops = &hpt3x3_port_ops
185 }; 181 };
186 static struct ata_port_info *port_info[2] = { &info, &info }; 182 const struct ata_port_info *ppi[] = { &info, NULL };
187 183
188 hpt3x3_init_chipset(dev); 184 hpt3x3_init_chipset(dev);
189 /* Now kick off ATA set up */ 185 /* Now kick off ATA set up */
190 return ata_pci_init_one(dev, port_info, 2); 186 return ata_pci_init_one(dev, ppi);
191} 187}
192 188
193#ifdef CONFIG_PM 189#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index 17bf9f3ed013..a769952646e1 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -257,10 +257,6 @@ static struct scsi_host_template it8213_sht = {
257 .dma_boundary = ATA_DMA_BOUNDARY, 257 .dma_boundary = ATA_DMA_BOUNDARY,
258 .slave_configure = ata_scsi_slave_config, 258 .slave_configure = ata_scsi_slave_config,
259 .bios_param = ata_std_bios_param, 259 .bios_param = ata_std_bios_param,
260#ifdef CONFIG_PM
261 .resume = ata_scsi_device_resume,
262 .suspend = ata_scsi_device_suspend,
263#endif
264}; 260};
265 261
266static const struct ata_port_operations it8213_ops = { 262static const struct ata_port_operations it8213_ops = {
@@ -315,7 +311,7 @@ static const struct ata_port_operations it8213_ops = {
315static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 311static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
316{ 312{
317 static int printed_version; 313 static int printed_version;
318 static struct ata_port_info info = { 314 static const struct ata_port_info info = {
319 .sht = &it8213_sht, 315 .sht = &it8213_sht,
320 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 316 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
321 .pio_mask = 0x1f, /* pio0-4 */ 317 .pio_mask = 0x1f, /* pio0-4 */
@@ -323,14 +319,14 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en
323 .udma_mask = 0x1f, /* UDMA 100 */ 319 .udma_mask = 0x1f, /* UDMA 100 */
324 .port_ops = &it8213_ops, 320 .port_ops = &it8213_ops,
325 }; 321 };
326 static struct ata_port_info *port_info[2] = { &info, &info }; 322 /* Current IT8213 stuff is single port */
323 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
327 324
328 if (!printed_version++) 325 if (!printed_version++)
329 dev_printk(KERN_DEBUG, &pdev->dev, 326 dev_printk(KERN_DEBUG, &pdev->dev,
330 "version " DRV_VERSION "\n"); 327 "version " DRV_VERSION "\n");
331 328
332 /* Current IT8213 stuff is single port */ 329 return ata_pci_init_one(pdev, ppi);
333 return ata_pci_init_one(pdev, port_info, 1);
334} 330}
335 331
336static const struct pci_device_id it8213_pci_tbl[] = { 332static const struct pci_device_id it8213_pci_tbl[] = {
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index f1f8cec8c224..ff9a6fd36657 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -620,10 +620,6 @@ static struct scsi_host_template it821x_sht = {
620 .slave_configure = ata_scsi_slave_config, 620 .slave_configure = ata_scsi_slave_config,
621 .slave_destroy = ata_scsi_slave_destroy, 621 .slave_destroy = ata_scsi_slave_destroy,
622 .bios_param = ata_std_bios_param, 622 .bios_param = ata_std_bios_param,
623#ifdef CONFIG_PM
624 .resume = ata_scsi_device_resume,
625 .suspend = ata_scsi_device_suspend,
626#endif
627}; 623};
628 624
629static struct ata_port_operations it821x_smart_port_ops = { 625static struct ata_port_operations it821x_smart_port_ops = {
@@ -722,14 +718,14 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
722{ 718{
723 u8 conf; 719 u8 conf;
724 720
725 static struct ata_port_info info_smart = { 721 static const struct ata_port_info info_smart = {
726 .sht = &it821x_sht, 722 .sht = &it821x_sht,
727 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 723 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
728 .pio_mask = 0x1f, 724 .pio_mask = 0x1f,
729 .mwdma_mask = 0x07, 725 .mwdma_mask = 0x07,
730 .port_ops = &it821x_smart_port_ops 726 .port_ops = &it821x_smart_port_ops
731 }; 727 };
732 static struct ata_port_info info_passthru = { 728 static const struct ata_port_info info_passthru = {
733 .sht = &it821x_sht, 729 .sht = &it821x_sht,
734 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 730 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
735 .pio_mask = 0x1f, 731 .pio_mask = 0x1f,
@@ -737,8 +733,8 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
737 .udma_mask = 0x7f, 733 .udma_mask = 0x7f,
738 .port_ops = &it821x_passthru_port_ops 734 .port_ops = &it821x_passthru_port_ops
739 }; 735 };
740 static struct ata_port_info *port_info[2];
741 736
737 const struct ata_port_info *ppi[] = { NULL, NULL };
742 static char *mode[2] = { "pass through", "smart" }; 738 static char *mode[2] = { "pass through", "smart" };
743 739
744 /* Force the card into bypass mode if so requested */ 740 /* Force the card into bypass mode if so requested */
@@ -751,11 +747,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
751 747
752 printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); 748 printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]);
753 if (conf == 0) 749 if (conf == 0)
754 port_info[0] = port_info[1] = &info_passthru; 750 ppi[0] = &info_passthru;
755 else 751 else
756 port_info[0] = port_info[1] = &info_smart; 752 ppi[0] = &info_smart;
757 753
758 return ata_pci_init_one(pdev, port_info, 2); 754 return ata_pci_init_one(pdev, ppi);
759} 755}
760 756
761#ifdef CONFIG_PM 757#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 420c343e5711..b994351fbcd0 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error)
31 31
32 for (i = 0; i < ATA_MAX_DEVICES; i++) { 32 for (i = 0; i < ATA_MAX_DEVICES; i++) {
33 struct ata_device *dev = &ap->device[i]; 33 struct ata_device *dev = &ap->device[i];
34 if (ata_dev_ready(dev)) { 34 if (ata_dev_enabled(dev)) {
35 ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); 35 ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
36 dev->pio_mode = XFER_PIO_0; 36 dev->pio_mode = XFER_PIO_0;
37 dev->xfer_mode = XFER_PIO_0; 37 dev->xfer_mode = XFER_PIO_0;
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 1daf78ac6efb..8d799e87f752 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -138,10 +138,6 @@ static struct scsi_host_template jmicron_sht = {
138 .slave_destroy = ata_scsi_slave_destroy, 138 .slave_destroy = ata_scsi_slave_destroy,
139 /* Use standard CHS mapping rules */ 139 /* Use standard CHS mapping rules */
140 .bios_param = ata_std_bios_param, 140 .bios_param = ata_std_bios_param,
141#ifdef CONFIG_PM
142 .suspend = ata_scsi_device_suspend,
143 .resume = ata_scsi_device_resume,
144#endif
145}; 141};
146 142
147static const struct ata_port_operations jmicron_ops = { 143static const struct ata_port_operations jmicron_ops = {
@@ -195,7 +191,7 @@ static const struct ata_port_operations jmicron_ops = {
195 191
196static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 192static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
197{ 193{
198 static struct ata_port_info info = { 194 static const struct ata_port_info info = {
199 .sht = &jmicron_sht, 195 .sht = &jmicron_sht,
200 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 196 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
201 197
@@ -205,9 +201,9 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
205 201
206 .port_ops = &jmicron_ops, 202 .port_ops = &jmicron_ops,
207 }; 203 };
208 struct ata_port_info *port_info[2] = { &info, &info }; 204 const struct ata_port_info *ppi[] = { &info, NULL };
209 205
210 return ata_pci_init_one(pdev, port_info, 2); 206 return ata_pci_init_one(pdev, ppi);
211} 207}
212 208
213static const struct pci_device_id jmicron_pci_tbl[] = { 209static const struct pci_device_id jmicron_pci_tbl[] = {
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index 837b7fe77dc7..edbfe0dbbf78 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -107,10 +107,6 @@ static struct scsi_host_template marvell_sht = {
107 .slave_destroy = ata_scsi_slave_destroy, 107 .slave_destroy = ata_scsi_slave_destroy,
108 /* Use standard CHS mapping rules */ 108 /* Use standard CHS mapping rules */
109 .bios_param = ata_std_bios_param, 109 .bios_param = ata_std_bios_param,
110#ifdef CONFIG_PM
111 .resume = ata_scsi_device_resume,
112 .suspend = ata_scsi_device_suspend,
113#endif
114}; 110};
115 111
116static const struct ata_port_operations marvell_ops = { 112static const struct ata_port_operations marvell_ops = {
@@ -165,7 +161,7 @@ static const struct ata_port_operations marvell_ops = {
165 161
166static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 162static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
167{ 163{
168 static struct ata_port_info info = { 164 static const struct ata_port_info info = {
169 .sht = &marvell_sht, 165 .sht = &marvell_sht,
170 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 166 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
171 167
@@ -175,7 +171,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
175 171
176 .port_ops = &marvell_ops, 172 .port_ops = &marvell_ops,
177 }; 173 };
178 static struct ata_port_info info_sata = { 174 static const struct ata_port_info info_sata = {
179 .sht = &marvell_sht, 175 .sht = &marvell_sht,
180 /* Slave possible as its magically mapped not real */ 176 /* Slave possible as its magically mapped not real */
181 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 177 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -186,13 +182,12 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
186 182
187 .port_ops = &marvell_ops, 183 .port_ops = &marvell_ops,
188 }; 184 };
189 struct ata_port_info *port_info[2] = { &info, &info_sata }; 185 const struct ata_port_info *ppi[] = { &info, &info_sata };
190 int n_port = 2;
191 186
192 if (pdev->device == 0x6101) 187 if (pdev->device == 0x6101)
193 n_port = 1; 188 ppi[1] = &ata_dummy_port_info;
194 189
195 return ata_pci_init_one(pdev, port_info, n_port); 190 return ata_pci_init_one(pdev, ppi);
196} 191}
197 192
198static const struct pci_device_id marvell_pci_tbl[] = { 193static const struct pci_device_id marvell_pci_tbl[] = {
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 9587a89f9683..368fac7d168b 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -280,10 +280,6 @@ static struct scsi_host_template mpc52xx_ata_sht = {
280 .dma_boundary = ATA_DMA_BOUNDARY, 280 .dma_boundary = ATA_DMA_BOUNDARY,
281 .slave_configure = ata_scsi_slave_config, 281 .slave_configure = ata_scsi_slave_config,
282 .bios_param = ata_std_bios_param, 282 .bios_param = ata_std_bios_param,
283#ifdef CONFIG_PM
284 .suspend = ata_scsi_device_suspend,
285 .resume = ata_scsi_device_resume,
286#endif
287}; 283};
288 284
289static struct ata_port_operations mpc52xx_ata_port_ops = { 285static struct ata_port_operations mpc52xx_ata_port_ops = {
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 3bfbd495f643..4ea42838297e 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -165,10 +165,6 @@ static struct scsi_host_template mpiix_sht = {
165 .slave_configure = ata_scsi_slave_config, 165 .slave_configure = ata_scsi_slave_config,
166 .slave_destroy = ata_scsi_slave_destroy, 166 .slave_destroy = ata_scsi_slave_destroy,
167 .bios_param = ata_std_bios_param, 167 .bios_param = ata_std_bios_param,
168#ifdef CONFIG_PM
169 .resume = ata_scsi_device_resume,
170 .suspend = ata_scsi_device_suspend,
171#endif
172}; 168};
173 169
174static struct ata_port_operations mpiix_port_ops = { 170static struct ata_port_operations mpiix_port_ops = {
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index dbba5b77d79c..81f563458666 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -37,10 +37,6 @@ static struct scsi_host_template netcell_sht = {
37 .slave_destroy = ata_scsi_slave_destroy, 37 .slave_destroy = ata_scsi_slave_destroy,
38 /* Use standard CHS mapping rules */ 38 /* Use standard CHS mapping rules */
39 .bios_param = ata_std_bios_param, 39 .bios_param = ata_std_bios_param,
40#ifdef CONFIG_PM
41 .resume = ata_scsi_device_resume,
42 .suspend = ata_scsi_device_suspend,
43#endif
44}; 40};
45 41
46static const struct ata_port_operations netcell_ops = { 42static const struct ata_port_operations netcell_ops = {
@@ -96,7 +92,7 @@ static const struct ata_port_operations netcell_ops = {
96static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 92static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
97{ 93{
98 static int printed_version; 94 static int printed_version;
99 static struct ata_port_info info = { 95 static const struct ata_port_info info = {
100 .sht = &netcell_sht, 96 .sht = &netcell_sht,
101 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 97 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
102 /* Actually we don't really care about these as the 98 /* Actually we don't really care about these as the
@@ -106,7 +102,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
106 .udma_mask = 0x3f, /* UDMA 133 */ 102 .udma_mask = 0x3f, /* UDMA 133 */
107 .port_ops = &netcell_ops, 103 .port_ops = &netcell_ops,
108 }; 104 };
109 static struct ata_port_info *port_info[2] = { &info, &info }; 105 const struct ata_port_info *port_info[] = { &info, NULL };
110 106
111 if (!printed_version++) 107 if (!printed_version++)
112 dev_printk(KERN_DEBUG, &pdev->dev, 108 dev_printk(KERN_DEBUG, &pdev->dev,
@@ -116,7 +112,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
116 ata_pci_clear_simplex(pdev); 112 ata_pci_clear_simplex(pdev);
117 113
118 /* And let the library code do the work */ 114 /* And let the library code do the work */
119 return ata_pci_init_one(pdev, port_info, 2); 115 return ata_pci_init_one(pdev, port_info);
120} 116}
121 117
122static const struct pci_device_id netcell_pci_tbl[] = { 118static const struct pci_device_id netcell_pci_tbl[] = {
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index ebc58a907d26..ea70ec744879 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -158,10 +158,6 @@ static struct scsi_host_template ns87410_sht = {
158 .slave_configure = ata_scsi_slave_config, 158 .slave_configure = ata_scsi_slave_config,
159 .slave_destroy = ata_scsi_slave_destroy, 159 .slave_destroy = ata_scsi_slave_destroy,
160 .bios_param = ata_std_bios_param, 160 .bios_param = ata_std_bios_param,
161#ifdef CONFIG_PM
162 .resume = ata_scsi_device_resume,
163 .suspend = ata_scsi_device_suspend,
164#endif
165}; 161};
166 162
167static struct ata_port_operations ns87410_port_ops = { 163static struct ata_port_operations ns87410_port_ops = {
@@ -195,14 +191,14 @@ static struct ata_port_operations ns87410_port_ops = {
195 191
196static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) 192static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id)
197{ 193{
198 static struct ata_port_info info = { 194 static const struct ata_port_info info = {
199 .sht = &ns87410_sht, 195 .sht = &ns87410_sht,
200 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 196 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
201 .pio_mask = 0x0F, 197 .pio_mask = 0x0F,
202 .port_ops = &ns87410_port_ops 198 .port_ops = &ns87410_port_ops
203 }; 199 };
204 static struct ata_port_info *port_info[2] = {&info, &info}; 200 const struct ata_port_info *ppi[] = { &info, NULL };
205 return ata_pci_init_one(dev, port_info, 2); 201 return ata_pci_init_one(dev, ppi);
206} 202}
207 203
208static const struct pci_device_id ns87410[] = { 204static const struct pci_device_id ns87410[] = {
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index 4d75d32e5826..29c23ddd6550 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -234,10 +234,6 @@ static struct scsi_host_template oldpiix_sht = {
234 .slave_configure = ata_scsi_slave_config, 234 .slave_configure = ata_scsi_slave_config,
235 .slave_destroy = ata_scsi_slave_destroy, 235 .slave_destroy = ata_scsi_slave_destroy,
236 .bios_param = ata_std_bios_param, 236 .bios_param = ata_std_bios_param,
237#ifdef CONFIG_PM
238 .resume = ata_scsi_device_resume,
239 .suspend = ata_scsi_device_suspend,
240#endif
241}; 237};
242 238
243static const struct ata_port_operations oldpiix_pata_ops = { 239static const struct ata_port_operations oldpiix_pata_ops = {
@@ -293,20 +289,20 @@ static const struct ata_port_operations oldpiix_pata_ops = {
293static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 289static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
294{ 290{
295 static int printed_version; 291 static int printed_version;
296 static struct ata_port_info info = { 292 static const struct ata_port_info info = {
297 .sht = &oldpiix_sht, 293 .sht = &oldpiix_sht,
298 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 294 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
299 .pio_mask = 0x1f, /* pio0-4 */ 295 .pio_mask = 0x1f, /* pio0-4 */
300 .mwdma_mask = 0x07, /* mwdma1-2 */ 296 .mwdma_mask = 0x07, /* mwdma1-2 */
301 .port_ops = &oldpiix_pata_ops, 297 .port_ops = &oldpiix_pata_ops,
302 }; 298 };
303 static struct ata_port_info *port_info[2] = { &info, &info }; 299 const struct ata_port_info *ppi[] = { &info, NULL };
304 300
305 if (!printed_version++) 301 if (!printed_version++)
306 dev_printk(KERN_DEBUG, &pdev->dev, 302 dev_printk(KERN_DEBUG, &pdev->dev,
307 "version " DRV_VERSION "\n"); 303 "version " DRV_VERSION "\n");
308 304
309 return ata_pci_init_one(pdev, port_info, 2); 305 return ata_pci_init_one(pdev, ppi);
310} 306}
311 307
312static const struct pci_device_id oldpiix_pci_tbl[] = { 308static const struct pci_device_id oldpiix_pci_tbl[] = {
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index 0af8a2c77cc9..1c44653e1e06 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -179,10 +179,6 @@ static struct scsi_host_template opti_sht = {
179 .slave_configure = ata_scsi_slave_config, 179 .slave_configure = ata_scsi_slave_config,
180 .slave_destroy = ata_scsi_slave_destroy, 180 .slave_destroy = ata_scsi_slave_destroy,
181 .bios_param = ata_std_bios_param, 181 .bios_param = ata_std_bios_param,
182#ifdef CONFIG_PM
183 .resume = ata_scsi_device_resume,
184 .suspend = ata_scsi_device_suspend,
185#endif
186}; 182};
187 183
188static struct ata_port_operations opti_port_ops = { 184static struct ata_port_operations opti_port_ops = {
@@ -220,19 +216,19 @@ static struct ata_port_operations opti_port_ops = {
220 216
221static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) 217static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
222{ 218{
223 static struct ata_port_info info = { 219 static const struct ata_port_info info = {
224 .sht = &opti_sht, 220 .sht = &opti_sht,
225 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 221 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
226 .pio_mask = 0x1f, 222 .pio_mask = 0x1f,
227 .port_ops = &opti_port_ops 223 .port_ops = &opti_port_ops
228 }; 224 };
229 static struct ata_port_info *port_info[2] = { &info, &info }; 225 const struct ata_port_info *ppi[] = { &info, NULL };
230 static int printed_version; 226 static int printed_version;
231 227
232 if (!printed_version++) 228 if (!printed_version++)
233 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 229 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
234 230
235 return ata_pci_init_one(dev, port_info, 2); 231 return ata_pci_init_one(dev, ppi);
236} 232}
237 233
238static const struct pci_device_id opti[] = { 234static const struct pci_device_id opti[] = {
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 2843e480f216..3093b02286ce 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -363,10 +363,6 @@ static struct scsi_host_template optidma_sht = {
363 .slave_configure = ata_scsi_slave_config, 363 .slave_configure = ata_scsi_slave_config,
364 .slave_destroy = ata_scsi_slave_destroy, 364 .slave_destroy = ata_scsi_slave_destroy,
365 .bios_param = ata_std_bios_param, 365 .bios_param = ata_std_bios_param,
366#ifdef CONFIG_PM
367 .resume = ata_scsi_device_resume,
368 .suspend = ata_scsi_device_suspend,
369#endif
370}; 366};
371 367
372static struct ata_port_operations optidma_port_ops = { 368static struct ata_port_operations optidma_port_ops = {
@@ -486,14 +482,14 @@ done_nomsg: /* Wrong chip revision */
486 482
487static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) 483static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
488{ 484{
489 static struct ata_port_info info_82c700 = { 485 static const struct ata_port_info info_82c700 = {
490 .sht = &optidma_sht, 486 .sht = &optidma_sht,
491 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 487 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
492 .pio_mask = 0x1f, 488 .pio_mask = 0x1f,
493 .mwdma_mask = 0x07, 489 .mwdma_mask = 0x07,
494 .port_ops = &optidma_port_ops 490 .port_ops = &optidma_port_ops
495 }; 491 };
496 static struct ata_port_info info_82c700_udma = { 492 static const struct ata_port_info info_82c700_udma = {
497 .sht = &optidma_sht, 493 .sht = &optidma_sht,
498 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 494 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
499 .pio_mask = 0x1f, 495 .pio_mask = 0x1f,
@@ -501,8 +497,7 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
501 .udma_mask = 0x07, 497 .udma_mask = 0x07,
502 .port_ops = &optiplus_port_ops 498 .port_ops = &optiplus_port_ops
503 }; 499 };
504 static struct ata_port_info *port_info[2]; 500 const struct ata_port_info *ppi[] = { &info_82c700, NULL };
505 struct ata_port_info *info = &info_82c700;
506 static int printed_version; 501 static int printed_version;
507 502
508 if (!printed_version++) 503 if (!printed_version++)
@@ -514,10 +509,9 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
514 pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ 509 pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */
515 510
516 if (optiplus_with_udma(dev)) 511 if (optiplus_with_udma(dev))
517 info = &info_82c700_udma; 512 ppi[0] = &info_82c700_udma;
518 513
519 port_info[0] = port_info[1] = info; 514 return ata_pci_init_one(dev, ppi);
520 return ata_pci_init_one(dev, port_info, 2);
521} 515}
522 516
523static const struct pci_device_id optidma[] = { 517static const struct pci_device_id optidma[] = {
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 11245e331f77..4d44c7555db1 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -397,6 +397,7 @@ static struct pcmcia_device_id pcmcia_devices[] = {
397 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 397 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
398 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), 398 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
399 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), 399 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
400 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2),
400 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 401 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
401 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 402 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
402 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), 403 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index ee636beb05e1..edbaf9d653b8 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -244,10 +244,6 @@ static struct scsi_host_template pdc202xx_sht = {
244 .slave_configure = ata_scsi_slave_config, 244 .slave_configure = ata_scsi_slave_config,
245 .slave_destroy = ata_scsi_slave_destroy, 245 .slave_destroy = ata_scsi_slave_destroy,
246 .bios_param = ata_std_bios_param, 246 .bios_param = ata_std_bios_param,
247#ifdef CONFIG_PM
248 .resume = ata_scsi_device_resume,
249 .suspend = ata_scsi_device_suspend,
250#endif
251}; 247};
252 248
253static struct ata_port_operations pdc2024x_port_ops = { 249static struct ata_port_operations pdc2024x_port_ops = {
@@ -321,7 +317,7 @@ static struct ata_port_operations pdc2026x_port_ops = {
321 317
322static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) 318static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id)
323{ 319{
324 static struct ata_port_info info[3] = { 320 static const struct ata_port_info info[3] = {
325 { 321 {
326 .sht = &pdc202xx_sht, 322 .sht = &pdc202xx_sht,
327 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 323 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -348,9 +344,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id
348 } 344 }
349 345
350 }; 346 };
351 static struct ata_port_info *port_info[2]; 347 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL };
352
353 port_info[0] = port_info[1] = &info[id->driver_data];
354 348
355 if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { 349 if (dev->device == PCI_DEVICE_ID_PROMISE_20265) {
356 struct pci_dev *bridge = dev->bus->self; 350 struct pci_dev *bridge = dev->bus->self;
@@ -362,7 +356,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id
362 return -ENODEV; 356 return -ENODEV;
363 } 357 }
364 } 358 }
365 return ata_pci_init_one(dev, port_info, 2); 359 return ata_pci_init_one(dev, ppi);
366} 360}
367 361
368static const struct pci_device_id pdc202xx[] = { 362static const struct pci_device_id pdc202xx[] = {
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index a0a650c7f272..1f6384895a4f 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -48,6 +48,8 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse
48 return 0; 48 return 0;
49} 49}
50 50
51static int ata_dummy_ret0(struct ata_port *ap) { return 0; }
52
51static struct scsi_host_template pata_platform_sht = { 53static struct scsi_host_template pata_platform_sht = {
52 .module = THIS_MODULE, 54 .module = THIS_MODULE,
53 .name = DRV_NAME, 55 .name = DRV_NAME,
@@ -91,7 +93,7 @@ static struct ata_port_operations pata_platform_port_ops = {
91 .irq_on = ata_irq_on, 93 .irq_on = ata_irq_on,
92 .irq_ack = ata_irq_ack, 94 .irq_ack = ata_irq_ack,
93 95
94 .port_start = ata_port_start, 96 .port_start = ata_dummy_ret0,
95}; 97};
96 98
97static void pata_platform_setup_port(struct ata_ioports *ioaddr, 99static void pata_platform_setup_port(struct ata_ioports *ioaddr,
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 1c54673e008d..ba96b54f5b87 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -200,10 +200,6 @@ static struct scsi_host_template radisys_sht = {
200 .slave_configure = ata_scsi_slave_config, 200 .slave_configure = ata_scsi_slave_config,
201 .slave_destroy = ata_scsi_slave_destroy, 201 .slave_destroy = ata_scsi_slave_destroy,
202 .bios_param = ata_std_bios_param, 202 .bios_param = ata_std_bios_param,
203#ifdef CONFIG_PM
204 .resume = ata_scsi_device_resume,
205 .suspend = ata_scsi_device_suspend,
206#endif
207}; 203};
208 204
209static const struct ata_port_operations radisys_pata_ops = { 205static const struct ata_port_operations radisys_pata_ops = {
@@ -259,7 +255,7 @@ static const struct ata_port_operations radisys_pata_ops = {
259static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 255static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
260{ 256{
261 static int printed_version; 257 static int printed_version;
262 static struct ata_port_info info = { 258 static const struct ata_port_info info = {
263 .sht = &radisys_sht, 259 .sht = &radisys_sht,
264 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 260 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
265 .pio_mask = 0x1f, /* pio0-4 */ 261 .pio_mask = 0x1f, /* pio0-4 */
@@ -267,13 +263,13 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e
267 .udma_mask = 0x14, /* UDMA33/66 only */ 263 .udma_mask = 0x14, /* UDMA33/66 only */
268 .port_ops = &radisys_pata_ops, 264 .port_ops = &radisys_pata_ops,
269 }; 265 };
270 static struct ata_port_info *port_info[2] = { &info, &info }; 266 const struct ata_port_info *ppi[] = { &info, NULL };
271 267
272 if (!printed_version++) 268 if (!printed_version++)
273 dev_printk(KERN_DEBUG, &pdev->dev, 269 dev_printk(KERN_DEBUG, &pdev->dev,
274 "version " DRV_VERSION "\n"); 270 "version " DRV_VERSION "\n");
275 271
276 return ata_pci_init_one(pdev, port_info, 2); 272 return ata_pci_init_one(pdev, ppi);
277} 273}
278 274
279static const struct pci_device_id radisys_pci_tbl[] = { 275static const struct pci_device_id radisys_pci_tbl[] = {
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 85c45290eeee..2bfd7ef42af5 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -40,7 +40,7 @@ static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused)
40 40
41 for (i = 0; i < ATA_MAX_DEVICES; i++) { 41 for (i = 0; i < ATA_MAX_DEVICES; i++) {
42 struct ata_device *dev = &ap->device[i]; 42 struct ata_device *dev = &ap->device[i];
43 if (ata_dev_ready(dev)) { 43 if (ata_dev_enabled(dev)) {
44 /* We don't really care */ 44 /* We don't really care */
45 dev->pio_mode = XFER_PIO_0; 45 dev->pio_mode = XFER_PIO_0;
46 dev->xfer_mode = XFER_PIO_0; 46 dev->xfer_mode = XFER_PIO_0;
@@ -69,10 +69,6 @@ static struct scsi_host_template rz1000_sht = {
69 .slave_configure = ata_scsi_slave_config, 69 .slave_configure = ata_scsi_slave_config,
70 .slave_destroy = ata_scsi_slave_destroy, 70 .slave_destroy = ata_scsi_slave_destroy,
71 .bios_param = ata_std_bios_param, 71 .bios_param = ata_std_bios_param,
72#ifdef CONFIG_PM
73 .resume = ata_scsi_device_resume,
74 .suspend = ata_scsi_device_suspend,
75#endif
76}; 72};
77 73
78static struct ata_port_operations rz1000_port_ops = { 74static struct ata_port_operations rz1000_port_ops = {
@@ -135,22 +131,20 @@ static int rz1000_fifo_disable(struct pci_dev *pdev)
135static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 131static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
136{ 132{
137 static int printed_version; 133 static int printed_version;
138 struct ata_port_info *port_info[2]; 134 static const struct ata_port_info info = {
139 static struct ata_port_info info = {
140 .sht = &rz1000_sht, 135 .sht = &rz1000_sht,
141 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 136 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
142 .pio_mask = 0x1f, 137 .pio_mask = 0x1f,
143 .port_ops = &rz1000_port_ops 138 .port_ops = &rz1000_port_ops
144 }; 139 };
140 const struct ata_port_info *ppi[] = { &info, NULL };
145 141
146 if (!printed_version++) 142 if (!printed_version++)
147 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 143 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
148 144
149 if (rz1000_fifo_disable(pdev) == 0) { 145 if (rz1000_fifo_disable(pdev) == 0)
150 port_info[0] = &info; 146 return ata_pci_init_one(pdev, ppi);
151 port_info[1] = &info; 147
152 return ata_pci_init_one(pdev, port_info, 2);
153 }
154 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); 148 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n");
155 /* Not safe to use so skip */ 149 /* Not safe to use so skip */
156 return -ENODEV; 150 return -ENODEV;
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
index 66e8ff467c8d..225013ecf4b6 100644
--- a/drivers/ata/pata_sc1200.c
+++ b/drivers/ata/pata_sc1200.c
@@ -194,10 +194,6 @@ static struct scsi_host_template sc1200_sht = {
194 .slave_configure = ata_scsi_slave_config, 194 .slave_configure = ata_scsi_slave_config,
195 .slave_destroy = ata_scsi_slave_destroy, 195 .slave_destroy = ata_scsi_slave_destroy,
196 .bios_param = ata_std_bios_param, 196 .bios_param = ata_std_bios_param,
197#ifdef CONFIG_PM
198 .resume = ata_scsi_device_resume,
199 .suspend = ata_scsi_device_suspend,
200#endif
201}; 197};
202 198
203static struct ata_port_operations sc1200_port_ops = { 199static struct ata_port_operations sc1200_port_ops = {
@@ -247,7 +243,7 @@ static struct ata_port_operations sc1200_port_ops = {
247 243
248static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) 244static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
249{ 245{
250 static struct ata_port_info info = { 246 static const struct ata_port_info info = {
251 .sht = &sc1200_sht, 247 .sht = &sc1200_sht,
252 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 248 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
253 .pio_mask = 0x1f, 249 .pio_mask = 0x1f,
@@ -255,10 +251,10 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
255 .udma_mask = 0x07, 251 .udma_mask = 0x07,
256 .port_ops = &sc1200_port_ops 252 .port_ops = &sc1200_port_ops
257 }; 253 };
258 static struct ata_port_info *port_info[2] = { &info, &info };
259
260 /* Can't enable port 2 yet, see top comments */ 254 /* Can't enable port 2 yet, see top comments */
261 return ata_pci_init_one(dev, port_info, 1); 255 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
256
257 return ata_pci_init_one(dev, ppi);
262} 258}
263 259
264static const struct pci_device_id sc1200[] = { 260static const struct pci_device_id sc1200[] = {
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index 203f463ac39f..cca3aa225efe 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -984,10 +984,6 @@ static struct scsi_host_template scc_sht = {
984 .slave_configure = ata_scsi_slave_config, 984 .slave_configure = ata_scsi_slave_config,
985 .slave_destroy = ata_scsi_slave_destroy, 985 .slave_destroy = ata_scsi_slave_destroy,
986 .bios_param = ata_std_bios_param, 986 .bios_param = ata_std_bios_param,
987#ifdef CONFIG_PM
988 .resume = ata_scsi_device_resume,
989 .suspend = ata_scsi_device_suspend,
990#endif
991}; 987};
992 988
993static const struct ata_port_operations scc_pata_ops = { 989static const struct ata_port_operations scc_pata_ops = {
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index b6e020383dd9..dee6e211949d 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -315,10 +315,6 @@ static struct scsi_host_template serverworks_sht = {
315 .slave_configure = ata_scsi_slave_config, 315 .slave_configure = ata_scsi_slave_config,
316 .slave_destroy = ata_scsi_slave_destroy, 316 .slave_destroy = ata_scsi_slave_destroy,
317 .bios_param = ata_std_bios_param, 317 .bios_param = ata_std_bios_param,
318#ifdef CONFIG_PM
319 .resume = ata_scsi_device_resume,
320 .suspend = ata_scsi_device_suspend,
321#endif
322}; 318};
323 319
324static struct ata_port_operations serverworks_osb4_port_ops = { 320static struct ata_port_operations serverworks_osb4_port_ops = {
@@ -479,8 +475,7 @@ static void serverworks_fixup_ht1000(struct pci_dev *pdev)
479 475
480static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 476static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
481{ 477{
482 int ports = 2; 478 static const struct ata_port_info info[4] = {
483 static struct ata_port_info info[4] = {
484 { /* OSB4 */ 479 { /* OSB4 */
485 .sht = &serverworks_sht, 480 .sht = &serverworks_sht,
486 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 481 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -511,8 +506,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
511 .port_ops = &serverworks_csb_port_ops 506 .port_ops = &serverworks_csb_port_ops
512 } 507 }
513 }; 508 };
514 static struct ata_port_info *port_info[2]; 509 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL };
515 struct ata_port_info *devinfo = &info[id->driver_data];
516 510
517 /* Force master latency timer to 64 PCI clocks */ 511 /* Force master latency timer to 64 PCI clocks */
518 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); 512 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
@@ -521,7 +515,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
521 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { 515 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
522 /* Select non UDMA capable OSB4 if we can't do fixups */ 516 /* Select non UDMA capable OSB4 if we can't do fixups */
523 if ( serverworks_fixup_osb4(pdev) < 0) 517 if ( serverworks_fixup_osb4(pdev) < 0)
524 devinfo = &info[1]; 518 ppi[0] = &info[1];
525 } 519 }
526 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ 520 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */
527 else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || 521 else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||
@@ -531,11 +525,11 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
531 /* If the returned btr is the newer revision then 525 /* If the returned btr is the newer revision then
532 select the right info block */ 526 select the right info block */
533 if (serverworks_fixup_csb(pdev) == 3) 527 if (serverworks_fixup_csb(pdev) == 3)
534 devinfo = &info[3]; 528 ppi[0] = &info[3];
535 529
536 /* Is this the 3rd channel CSB6 IDE ? */ 530 /* Is this the 3rd channel CSB6 IDE ? */
537 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) 531 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)
538 ports = 1; 532 ppi[1] = &ata_dummy_port_info;
539 } 533 }
540 /* setup HT1000E */ 534 /* setup HT1000E */
541 else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) 535 else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE)
@@ -544,8 +538,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
544 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) 538 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
545 ata_pci_clear_simplex(pdev); 539 ata_pci_clear_simplex(pdev);
546 540
547 port_info[0] = port_info[1] = devinfo; 541 return ata_pci_init_one(pdev, ppi);
548 return ata_pci_init_one(pdev, port_info, ports);
549} 542}
550 543
551#ifdef CONFIG_PM 544#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index a5886f061c0b..440e2cb6ee75 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -232,10 +232,6 @@ static struct scsi_host_template sil680_sht = {
232 .slave_configure = ata_scsi_slave_config, 232 .slave_configure = ata_scsi_slave_config,
233 .slave_destroy = ata_scsi_slave_destroy, 233 .slave_destroy = ata_scsi_slave_destroy,
234 .bios_param = ata_std_bios_param, 234 .bios_param = ata_std_bios_param,
235#ifdef CONFIG_PM
236 .suspend = ata_scsi_device_suspend,
237 .resume = ata_scsi_device_resume,
238#endif
239}; 235};
240 236
241static struct ata_port_operations sil680_port_ops = { 237static struct ata_port_operations sil680_port_ops = {
@@ -345,7 +341,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev)
345 341
346static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 342static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
347{ 343{
348 static struct ata_port_info info = { 344 static const struct ata_port_info info = {
349 .sht = &sil680_sht, 345 .sht = &sil680_sht,
350 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 346 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
351 .pio_mask = 0x1f, 347 .pio_mask = 0x1f,
@@ -353,7 +349,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
353 .udma_mask = 0x7f, 349 .udma_mask = 0x7f,
354 .port_ops = &sil680_port_ops 350 .port_ops = &sil680_port_ops
355 }; 351 };
356 static struct ata_port_info info_slow = { 352 static const struct ata_port_info info_slow = {
357 .sht = &sil680_sht, 353 .sht = &sil680_sht,
358 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 354 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
359 .pio_mask = 0x1f, 355 .pio_mask = 0x1f,
@@ -361,7 +357,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
361 .udma_mask = 0x3f, 357 .udma_mask = 0x3f,
362 .port_ops = &sil680_port_ops 358 .port_ops = &sil680_port_ops
363 }; 359 };
364 static struct ata_port_info *port_info[2] = {&info, &info}; 360 const struct ata_port_info *ppi[] = { &info, NULL };
365 static int printed_version; 361 static int printed_version;
366 362
367 if (!printed_version++) 363 if (!printed_version++)
@@ -370,12 +366,12 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
370 switch(sil680_init_chip(pdev)) 366 switch(sil680_init_chip(pdev))
371 { 367 {
372 case 0: 368 case 0:
373 port_info[0] = port_info[1] = &info_slow; 369 ppi[0] = &info_slow;
374 break; 370 break;
375 case 0x30: 371 case 0x30:
376 return -ENODEV; 372 return -ENODEV;
377 } 373 }
378 return ata_pci_init_one(pdev, port_info, 2); 374 return ata_pci_init_one(pdev, ppi);
379} 375}
380 376
381#ifdef CONFIG_PM 377#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index f5838cc11728..f2231267e011 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -38,8 +38,8 @@
38#define DRV_VERSION "0.5.1" 38#define DRV_VERSION "0.5.1"
39 39
40struct sis_chipset { 40struct sis_chipset {
41 u16 device; /* PCI host ID */ 41 u16 device; /* PCI host ID */
42 struct ata_port_info *info; /* Info block */ 42 const struct ata_port_info *info; /* Info block */
43 /* Probably add family, cable detect type etc here to clean 43 /* Probably add family, cable detect type etc here to clean
44 up code later */ 44 up code later */
45}; 45};
@@ -524,10 +524,6 @@ static struct scsi_host_template sis_sht = {
524 .slave_configure = ata_scsi_slave_config, 524 .slave_configure = ata_scsi_slave_config,
525 .slave_destroy = ata_scsi_slave_destroy, 525 .slave_destroy = ata_scsi_slave_destroy,
526 .bios_param = ata_std_bios_param, 526 .bios_param = ata_std_bios_param,
527#ifdef CONFIG_PM
528 .resume = ata_scsi_device_resume,
529 .suspend = ata_scsi_device_suspend,
530#endif
531}; 527};
532 528
533static const struct ata_port_operations sis_133_ops = { 529static const struct ata_port_operations sis_133_ops = {
@@ -700,7 +696,7 @@ static const struct ata_port_operations sis_old_ops = {
700 .port_start = ata_port_start, 696 .port_start = ata_port_start,
701}; 697};
702 698
703static struct ata_port_info sis_info = { 699static const struct ata_port_info sis_info = {
704 .sht = &sis_sht, 700 .sht = &sis_sht,
705 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 701 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
706 .pio_mask = 0x1f, /* pio0-4 */ 702 .pio_mask = 0x1f, /* pio0-4 */
@@ -708,7 +704,7 @@ static struct ata_port_info sis_info = {
708 .udma_mask = 0, 704 .udma_mask = 0,
709 .port_ops = &sis_old_ops, 705 .port_ops = &sis_old_ops,
710}; 706};
711static struct ata_port_info sis_info33 = { 707static const struct ata_port_info sis_info33 = {
712 .sht = &sis_sht, 708 .sht = &sis_sht,
713 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 709 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
714 .pio_mask = 0x1f, /* pio0-4 */ 710 .pio_mask = 0x1f, /* pio0-4 */
@@ -716,35 +712,35 @@ static struct ata_port_info sis_info33 = {
716 .udma_mask = ATA_UDMA2, /* UDMA 33 */ 712 .udma_mask = ATA_UDMA2, /* UDMA 33 */
717 .port_ops = &sis_old_ops, 713 .port_ops = &sis_old_ops,
718}; 714};
719static struct ata_port_info sis_info66 = { 715static const struct ata_port_info sis_info66 = {
720 .sht = &sis_sht, 716 .sht = &sis_sht,
721 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 717 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
722 .pio_mask = 0x1f, /* pio0-4 */ 718 .pio_mask = 0x1f, /* pio0-4 */
723 .udma_mask = ATA_UDMA4, /* UDMA 66 */ 719 .udma_mask = ATA_UDMA4, /* UDMA 66 */
724 .port_ops = &sis_66_ops, 720 .port_ops = &sis_66_ops,
725}; 721};
726static struct ata_port_info sis_info100 = { 722static const struct ata_port_info sis_info100 = {
727 .sht = &sis_sht, 723 .sht = &sis_sht,
728 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 724 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
729 .pio_mask = 0x1f, /* pio0-4 */ 725 .pio_mask = 0x1f, /* pio0-4 */
730 .udma_mask = ATA_UDMA5, 726 .udma_mask = ATA_UDMA5,
731 .port_ops = &sis_100_ops, 727 .port_ops = &sis_100_ops,
732}; 728};
733static struct ata_port_info sis_info100_early = { 729static const struct ata_port_info sis_info100_early = {
734 .sht = &sis_sht, 730 .sht = &sis_sht,
735 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 731 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
736 .udma_mask = ATA_UDMA5, 732 .udma_mask = ATA_UDMA5,
737 .pio_mask = 0x1f, /* pio0-4 */ 733 .pio_mask = 0x1f, /* pio0-4 */
738 .port_ops = &sis_66_ops, 734 .port_ops = &sis_66_ops,
739}; 735};
740struct ata_port_info sis_info133 = { 736const struct ata_port_info sis_info133 = {
741 .sht = &sis_sht, 737 .sht = &sis_sht,
742 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 738 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
743 .pio_mask = 0x1f, /* pio0-4 */ 739 .pio_mask = 0x1f, /* pio0-4 */
744 .udma_mask = ATA_UDMA6, 740 .udma_mask = ATA_UDMA6,
745 .port_ops = &sis_133_ops, 741 .port_ops = &sis_133_ops,
746}; 742};
747static struct ata_port_info sis_info133_early = { 743static const struct ata_port_info sis_info133_early = {
748 .sht = &sis_sht, 744 .sht = &sis_sht,
749 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 745 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
750 .pio_mask = 0x1f, /* pio0-4 */ 746 .pio_mask = 0x1f, /* pio0-4 */
@@ -827,8 +823,8 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis)
827static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 823static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
828{ 824{
829 static int printed_version; 825 static int printed_version;
830 static struct ata_port_info *port_info[2]; 826 struct ata_port_info port;
831 struct ata_port_info *port; 827 const struct ata_port_info *ppi[] = { &port, NULL };
832 struct pci_dev *host = NULL; 828 struct pci_dev *host = NULL;
833 struct sis_chipset *chipset = NULL; 829 struct sis_chipset *chipset = NULL;
834 struct sis_chipset *sets; 830 struct sis_chipset *sets;
@@ -968,13 +964,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
968 if (chipset == NULL) 964 if (chipset == NULL)
969 return -ENODEV; 965 return -ENODEV;
970 966
971 port = chipset->info; 967 port = *chipset->info;
972 port->private_data = chipset; 968 port.private_data = chipset;
973 969
974 sis_fixup(pdev, chipset); 970 sis_fixup(pdev, chipset);
975 971
976 port_info[0] = port_info[1] = port; 972 return ata_pci_init_one(pdev, ppi);
977 return ata_pci_init_one(pdev, port_info, 2);
978} 973}
979 974
980static const struct pci_device_id sis_pci_tbl[] = { 975static const struct pci_device_id sis_pci_tbl[] = {
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 9aeffdbe2829..f48491ad5f3a 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -301,20 +301,22 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev)
301 301
302static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) 302static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id)
303{ 303{
304 static struct ata_port_info info_dma = { 304 static const struct ata_port_info info_dma = {
305 .sht = &sl82c105_sht, 305 .sht = &sl82c105_sht,
306 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 306 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
307 .pio_mask = 0x1f, 307 .pio_mask = 0x1f,
308 .mwdma_mask = 0x07, 308 .mwdma_mask = 0x07,
309 .port_ops = &sl82c105_port_ops 309 .port_ops = &sl82c105_port_ops
310 }; 310 };
311 static struct ata_port_info info_early = { 311 static const struct ata_port_info info_early = {
312 .sht = &sl82c105_sht, 312 .sht = &sl82c105_sht,
313 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 313 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
314 .pio_mask = 0x1f, 314 .pio_mask = 0x1f,
315 .port_ops = &sl82c105_port_ops 315 .port_ops = &sl82c105_port_ops
316 }; 316 };
317 static struct ata_port_info *port_info[2] = { &info_early, &info_early }; 317 /* for now use only the first port */
318 const struct ata_port_info *ppi[] = { &info_early,
319 &ata_dummy_port_info };
318 u32 val; 320 u32 val;
319 int rev; 321 int rev;
320 322
@@ -324,17 +326,14 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
324 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); 326 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n");
325 else if (rev <= 5) 327 else if (rev <= 5)
326 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); 328 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n");
327 else { 329 else
328 port_info[0] = &info_dma; 330 ppi[0] = &info_dma;
329 port_info[1] = &info_dma;
330 }
331 331
332 pci_read_config_dword(dev, 0x40, &val); 332 pci_read_config_dword(dev, 0x40, &val);
333 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; 333 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16;
334 pci_write_config_dword(dev, 0x40, val); 334 pci_write_config_dword(dev, 0x40, val);
335 335
336 336 return ata_pci_init_one(dev, ppi);
337 return ata_pci_init_one(dev, port_info, 1); /* For now */
338} 337}
339 338
340static const struct pci_device_id sl82c105[] = { 339static const struct pci_device_id sl82c105[] = {
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index 349887bf5b93..b1d3076dfe51 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -194,10 +194,6 @@ static struct scsi_host_template triflex_sht = {
194 .slave_configure = ata_scsi_slave_config, 194 .slave_configure = ata_scsi_slave_config,
195 .slave_destroy = ata_scsi_slave_destroy, 195 .slave_destroy = ata_scsi_slave_destroy,
196 .bios_param = ata_std_bios_param, 196 .bios_param = ata_std_bios_param,
197#ifdef CONFIG_PM
198 .resume = ata_scsi_device_resume,
199 .suspend = ata_scsi_device_suspend,
200#endif
201}; 197};
202 198
203static struct ata_port_operations triflex_port_ops = { 199static struct ata_port_operations triflex_port_ops = {
@@ -237,20 +233,20 @@ static struct ata_port_operations triflex_port_ops = {
237 233
238static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) 234static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
239{ 235{
240 static struct ata_port_info info = { 236 static const struct ata_port_info info = {
241 .sht = &triflex_sht, 237 .sht = &triflex_sht,
242 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 238 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
243 .pio_mask = 0x1f, 239 .pio_mask = 0x1f,
244 .mwdma_mask = 0x07, 240 .mwdma_mask = 0x07,
245 .port_ops = &triflex_port_ops 241 .port_ops = &triflex_port_ops
246 }; 242 };
247 static struct ata_port_info *port_info[2] = { &info, &info }; 243 const struct ata_port_info *ppi[] = { &info, NULL };
248 static int printed_version; 244 static int printed_version;
249 245
250 if (!printed_version++) 246 if (!printed_version++)
251 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 247 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
252 248
253 return ata_pci_init_one(dev, port_info, 2); 249 return ata_pci_init_one(dev, ppi);
254} 250}
255 251
256static const struct pci_device_id triflex[] = { 252static const struct pci_device_id triflex[] = {
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 362beb2f489c..e4c71f76bd55 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -301,10 +301,6 @@ static struct scsi_host_template via_sht = {
301 .slave_configure = ata_scsi_slave_config, 301 .slave_configure = ata_scsi_slave_config,
302 .slave_destroy = ata_scsi_slave_destroy, 302 .slave_destroy = ata_scsi_slave_destroy,
303 .bios_param = ata_std_bios_param, 303 .bios_param = ata_std_bios_param,
304#ifdef CONFIG_PM
305 .resume = ata_scsi_device_resume,
306 .suspend = ata_scsi_device_suspend,
307#endif
308}; 304};
309 305
310static struct ata_port_operations via_port_ops = { 306static struct ata_port_operations via_port_ops = {
@@ -425,7 +421,7 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags)
425static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 421static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
426{ 422{
427 /* Early VIA without UDMA support */ 423 /* Early VIA without UDMA support */
428 static struct ata_port_info via_mwdma_info = { 424 static const struct ata_port_info via_mwdma_info = {
429 .sht = &via_sht, 425 .sht = &via_sht,
430 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 426 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
431 .pio_mask = 0x1f, 427 .pio_mask = 0x1f,
@@ -433,7 +429,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
433 .port_ops = &via_port_ops 429 .port_ops = &via_port_ops
434 }; 430 };
435 /* Ditto with IRQ masking required */ 431 /* Ditto with IRQ masking required */
436 static struct ata_port_info via_mwdma_info_borked = { 432 static const struct ata_port_info via_mwdma_info_borked = {
437 .sht = &via_sht, 433 .sht = &via_sht,
438 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 434 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
439 .pio_mask = 0x1f, 435 .pio_mask = 0x1f,
@@ -441,7 +437,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
441 .port_ops = &via_port_ops_noirq, 437 .port_ops = &via_port_ops_noirq,
442 }; 438 };
443 /* VIA UDMA 33 devices (and borked 66) */ 439 /* VIA UDMA 33 devices (and borked 66) */
444 static struct ata_port_info via_udma33_info = { 440 static const struct ata_port_info via_udma33_info = {
445 .sht = &via_sht, 441 .sht = &via_sht,
446 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 442 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
447 .pio_mask = 0x1f, 443 .pio_mask = 0x1f,
@@ -450,7 +446,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
450 .port_ops = &via_port_ops 446 .port_ops = &via_port_ops
451 }; 447 };
452 /* VIA UDMA 66 devices */ 448 /* VIA UDMA 66 devices */
453 static struct ata_port_info via_udma66_info = { 449 static const struct ata_port_info via_udma66_info = {
454 .sht = &via_sht, 450 .sht = &via_sht,
455 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 451 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
456 .pio_mask = 0x1f, 452 .pio_mask = 0x1f,
@@ -459,7 +455,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
459 .port_ops = &via_port_ops 455 .port_ops = &via_port_ops
460 }; 456 };
461 /* VIA UDMA 100 devices */ 457 /* VIA UDMA 100 devices */
462 static struct ata_port_info via_udma100_info = { 458 static const struct ata_port_info via_udma100_info = {
463 .sht = &via_sht, 459 .sht = &via_sht,
464 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 460 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
465 .pio_mask = 0x1f, 461 .pio_mask = 0x1f,
@@ -468,7 +464,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
468 .port_ops = &via_port_ops 464 .port_ops = &via_port_ops
469 }; 465 };
470 /* UDMA133 with bad AST (All current 133) */ 466 /* UDMA133 with bad AST (All current 133) */
471 static struct ata_port_info via_udma133_info = { 467 static const struct ata_port_info via_udma133_info = {
472 .sht = &via_sht, 468 .sht = &via_sht,
473 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 469 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
474 .pio_mask = 0x1f, 470 .pio_mask = 0x1f,
@@ -476,7 +472,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
476 .udma_mask = 0x7f, /* FIXME: should check north bridge */ 472 .udma_mask = 0x7f, /* FIXME: should check north bridge */
477 .port_ops = &via_port_ops 473 .port_ops = &via_port_ops
478 }; 474 };
479 struct ata_port_info *port_info[2], *type; 475 struct ata_port_info type;
476 const struct ata_port_info *ppi[] = { &type, NULL };
480 struct pci_dev *isa = NULL; 477 struct pci_dev *isa = NULL;
481 const struct via_isa_bridge *config; 478 const struct via_isa_bridge *config;
482 static int printed_version; 479 static int printed_version;
@@ -521,25 +518,25 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
521 switch(config->flags & VIA_UDMA) { 518 switch(config->flags & VIA_UDMA) {
522 case VIA_UDMA_NONE: 519 case VIA_UDMA_NONE:
523 if (config->flags & VIA_NO_UNMASK) 520 if (config->flags & VIA_NO_UNMASK)
524 type = &via_mwdma_info_borked; 521 type = via_mwdma_info_borked;
525 else 522 else
526 type = &via_mwdma_info; 523 type = via_mwdma_info;
527 break; 524 break;
528 case VIA_UDMA_33: 525 case VIA_UDMA_33:
529 type = &via_udma33_info; 526 type = via_udma33_info;
530 break; 527 break;
531 case VIA_UDMA_66: 528 case VIA_UDMA_66:
532 type = &via_udma66_info; 529 type = via_udma66_info;
533 /* The 66 MHz devices require we enable the clock */ 530 /* The 66 MHz devices require we enable the clock */
534 pci_read_config_dword(pdev, 0x50, &timing); 531 pci_read_config_dword(pdev, 0x50, &timing);
535 timing |= 0x80008; 532 timing |= 0x80008;
536 pci_write_config_dword(pdev, 0x50, timing); 533 pci_write_config_dword(pdev, 0x50, timing);
537 break; 534 break;
538 case VIA_UDMA_100: 535 case VIA_UDMA_100:
539 type = &via_udma100_info; 536 type = via_udma100_info;
540 break; 537 break;
541 case VIA_UDMA_133: 538 case VIA_UDMA_133:
542 type = &via_udma133_info; 539 type = via_udma133_info;
543 break; 540 break;
544 default: 541 default:
545 WARN_ON(1); 542 WARN_ON(1);
@@ -554,10 +551,9 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
554 } 551 }
555 552
556 /* We have established the device type, now fire it up */ 553 /* We have established the device type, now fire it up */
557 type->private_data = (void *)config; 554 type.private_data = (void *)config;
558 555
559 port_info[0] = port_info[1] = type; 556 return ata_pci_init_one(pdev, ppi);
560 return ata_pci_init_one(pdev, port_info, 2);
561} 557}
562 558
563#ifdef CONFIG_PM 559#ifdef CONFIG_PM
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index b3b62e985f19..bda5e7747c21 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -135,10 +135,6 @@ static struct scsi_host_template inic_sht = {
135 .slave_configure = inic_slave_config, 135 .slave_configure = inic_slave_config,
136 .slave_destroy = ata_scsi_slave_destroy, 136 .slave_destroy = ata_scsi_slave_destroy,
137 .bios_param = ata_std_bios_param, 137 .bios_param = ata_std_bios_param,
138#ifdef CONFIG_PM
139 .suspend = ata_scsi_device_suspend,
140 .resume = ata_scsi_device_resume,
141#endif
142}; 138};
143 139
144static const int scr_map[] = { 140static const int scr_map[] = {
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index a097595d4dc7..4cea3ef75226 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -325,10 +325,6 @@ static struct scsi_host_template nv_sht = {
325 .slave_configure = ata_scsi_slave_config, 325 .slave_configure = ata_scsi_slave_config,
326 .slave_destroy = ata_scsi_slave_destroy, 326 .slave_destroy = ata_scsi_slave_destroy,
327 .bios_param = ata_std_bios_param, 327 .bios_param = ata_std_bios_param,
328#ifdef CONFIG_PM
329 .suspend = ata_scsi_device_suspend,
330 .resume = ata_scsi_device_resume,
331#endif
332}; 328};
333 329
334static struct scsi_host_template nv_adma_sht = { 330static struct scsi_host_template nv_adma_sht = {
@@ -347,10 +343,6 @@ static struct scsi_host_template nv_adma_sht = {
347 .slave_configure = nv_adma_slave_config, 343 .slave_configure = nv_adma_slave_config,
348 .slave_destroy = ata_scsi_slave_destroy, 344 .slave_destroy = ata_scsi_slave_destroy,
349 .bios_param = ata_std_bios_param, 345 .bios_param = ata_std_bios_param,
350#ifdef CONFIG_PM
351 .suspend = ata_scsi_device_suspend,
352 .resume = ata_scsi_device_resume,
353#endif
354}; 346};
355 347
356static const struct ata_port_operations nv_generic_ops = { 348static const struct ata_port_operations nv_generic_ops = {
@@ -465,7 +457,7 @@ static const struct ata_port_operations nv_adma_ops = {
465 .host_stop = nv_adma_host_stop, 457 .host_stop = nv_adma_host_stop,
466}; 458};
467 459
468static struct ata_port_info nv_port_info[] = { 460static const struct ata_port_info nv_port_info[] = {
469 /* generic */ 461 /* generic */
470 { 462 {
471 .sht = &nv_sht, 463 .sht = &nv_sht,
@@ -1545,7 +1537,7 @@ static void nv_adma_error_handler(struct ata_port *ap)
1545static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 1537static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1546{ 1538{
1547 static int printed_version = 0; 1539 static int printed_version = 0;
1548 const struct ata_port_info *ppi[2]; 1540 const struct ata_port_info *ppi[] = { NULL, NULL };
1549 struct ata_host *host; 1541 struct ata_host *host;
1550 struct nv_host_priv *hpriv; 1542 struct nv_host_priv *hpriv;
1551 int rc; 1543 int rc;
@@ -1573,8 +1565,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1573 type = ADMA; 1565 type = ADMA;
1574 } 1566 }
1575 1567
1576 ppi[0] = ppi[1] = &nv_port_info[type]; 1568 ppi[0] = &nv_port_info[type];
1577 rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); 1569 rc = ata_pci_prepare_native_host(pdev, ppi, &host);
1578 if (rc) 1570 if (rc)
1579 return rc; 1571 return rc;
1580 1572
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 0a1e417f309c..e8483aadd11b 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -182,10 +182,6 @@ static struct scsi_host_template sil_sht = {
182 .slave_configure = ata_scsi_slave_config, 182 .slave_configure = ata_scsi_slave_config,
183 .slave_destroy = ata_scsi_slave_destroy, 183 .slave_destroy = ata_scsi_slave_destroy,
184 .bios_param = ata_std_bios_param, 184 .bios_param = ata_std_bios_param,
185#ifdef CONFIG_PM
186 .suspend = ata_scsi_device_suspend,
187 .resume = ata_scsi_device_resume,
188#endif
189}; 185};
190 186
191static const struct ata_port_operations sil_ops = { 187static const struct ata_port_operations sil_ops = {
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index b97ee9f31aec..a69d78cd8e9b 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -380,10 +380,6 @@ static struct scsi_host_template sil24_sht = {
380 .slave_configure = ata_scsi_slave_config, 380 .slave_configure = ata_scsi_slave_config,
381 .slave_destroy = ata_scsi_slave_destroy, 381 .slave_destroy = ata_scsi_slave_destroy,
382 .bios_param = ata_std_bios_param, 382 .bios_param = ata_std_bios_param,
383#ifdef CONFIG_PM
384 .suspend = ata_scsi_device_suspend,
385 .resume = ata_scsi_device_resume,
386#endif
387}; 383};
388 384
389static const struct ata_port_operations sil24_ops = { 385static const struct ata_port_operations sil24_ops = {
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index d8ee062e82fc..ee66c5fa7ac8 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -129,7 +129,7 @@ static const struct ata_port_operations sis_ops = {
129 .port_start = ata_port_start, 129 .port_start = ata_port_start,
130}; 130};
131 131
132static struct ata_port_info sis_port_info = { 132static const struct ata_port_info sis_port_info = {
133 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 133 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
134 .pio_mask = 0x1f, 134 .pio_mask = 0x1f,
135 .mwdma_mask = 0x7, 135 .mwdma_mask = 0x7,
@@ -255,7 +255,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
255{ 255{
256 static int printed_version; 256 static int printed_version;
257 struct ata_port_info pi = sis_port_info; 257 struct ata_port_info pi = sis_port_info;
258 const struct ata_port_info *ppi[2] = { &pi, &pi }; 258 const struct ata_port_info *ppi[] = { &pi, NULL };
259 struct ata_host *host; 259 struct ata_host *host;
260 u32 genctl, val; 260 u32 genctl, val;
261 u8 pmr; 261 u8 pmr;
@@ -335,7 +335,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
335 break; 335 break;
336 } 336 }
337 337
338 rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); 338 rc = ata_pci_prepare_native_host(pdev, ppi, &host);
339 if (rc) 339 if (rc)
340 return rc; 340 return rc;
341 341
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index f74e383de083..006f5e352658 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -125,7 +125,7 @@ static const struct ata_port_operations uli_ops = {
125 .port_start = ata_port_start, 125 .port_start = ata_port_start,
126}; 126};
127 127
128static struct ata_port_info uli_port_info = { 128static const struct ata_port_info uli_port_info = {
129 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 129 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
130 ATA_FLAG_IGN_SIMPLEX, 130 ATA_FLAG_IGN_SIMPLEX,
131 .pio_mask = 0x1f, /* pio0-4 */ 131 .pio_mask = 0x1f, /* pio0-4 */
@@ -201,19 +201,33 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
201 n_ports = 2; 201 n_ports = 2;
202 if (board_idx == uli_5287) 202 if (board_idx == uli_5287)
203 n_ports = 4; 203 n_ports = 4;
204 rc = ata_pci_prepare_native_host(pdev, ppi, n_ports, &host); 204
205 if (rc) 205 /* allocate the host */
206 return rc; 206 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
207 if (!host)
208 return -ENOMEM;
207 209
208 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); 210 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
209 if (!hpriv) 211 if (!hpriv)
210 return -ENOMEM; 212 return -ENOMEM;
211 host->private_data = hpriv; 213 host->private_data = hpriv;
212 214
215 /* the first two ports are standard SFF */
216 rc = ata_pci_init_native_host(host);
217 if (rc)
218 return rc;
219
220 rc = ata_pci_init_bmdma(host);
221 if (rc)
222 return rc;
223
213 iomap = host->iomap; 224 iomap = host->iomap;
214 225
215 switch (board_idx) { 226 switch (board_idx) {
216 case uli_5287: 227 case uli_5287:
228 /* If there are four, the last two live right after
229 * the standard SFF ports.
230 */
217 hpriv->scr_cfg_addr[0] = ULI5287_BASE; 231 hpriv->scr_cfg_addr[0] = ULI5287_BASE;
218 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; 232 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
219 233
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 939c9246fdd1..d105d2c189d2 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -116,10 +116,6 @@ static struct scsi_host_template svia_sht = {
116 .slave_configure = ata_scsi_slave_config, 116 .slave_configure = ata_scsi_slave_config,
117 .slave_destroy = ata_scsi_slave_destroy, 117 .slave_destroy = ata_scsi_slave_destroy,
118 .bios_param = ata_std_bios_param, 118 .bios_param = ata_std_bios_param,
119#ifdef CONFIG_PM
120 .suspend = ata_scsi_device_suspend,
121 .resume = ata_scsi_device_resume,
122#endif
123}; 119};
124 120
125static const struct ata_port_operations vt6420_sata_ops = { 121static const struct ata_port_operations vt6420_sata_ops = {
@@ -415,7 +411,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)
415 struct ata_host *host; 411 struct ata_host *host;
416 int rc; 412 int rc;
417 413
418 rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); 414 rc = ata_pci_prepare_native_host(pdev, ppi, &host);
419 if (rc) 415 if (rc)
420 return rc; 416 return rc;
421 *r_host = host; 417 *r_host = host;
diff --git a/drivers/ata/sis.h b/drivers/ata/sis.h
index 231da8fc2200..0f2208d8d5ef 100644
--- a/drivers/ata/sis.h
+++ b/drivers/ata/sis.h
@@ -2,4 +2,4 @@
2struct ata_port_info; 2struct ata_port_info;
3 3
4/* pata_sis.c */ 4/* pata_sis.c */
5extern struct ata_port_info sis_info133; 5extern const struct ata_port_info sis_info133;
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig
index 33687454eb32..f5a47a48c3b4 100644
--- a/drivers/atm/Kconfig
+++ b/drivers/atm/Kconfig
@@ -2,19 +2,22 @@
2# ATM device configuration 2# ATM device configuration
3# 3#
4 4
5menu "ATM drivers" 5menuconfig ATM_DRIVERS
6 bool "ATM drivers"
6 depends on NETDEVICES && ATM 7 depends on NETDEVICES && ATM
8 default y
9
10if ATM_DRIVERS
7 11
8config ATM_DUMMY 12config ATM_DUMMY
9 tristate "Dummy ATM driver" 13 tristate "Dummy ATM driver"
10 depends on ATM
11 help 14 help
12 Dummy ATM driver. Useful for proxy signalling, testing, 15 Dummy ATM driver. Useful for proxy signalling, testing,
13 and development. If unsure, say N. 16 and development. If unsure, say N.
14 17
15config ATM_TCP 18config ATM_TCP
16 tristate "ATM over TCP" 19 tristate "ATM over TCP"
17 depends on INET && ATM 20 depends on INET
18 help 21 help
19 ATM over TCP driver. Useful mainly for development and for 22 ATM over TCP driver. Useful mainly for development and for
20 experiments. If unsure, say N. 23 experiments. If unsure, say N.
@@ -30,7 +33,7 @@ config ATM_LANAI
30 33
31config ATM_ENI 34config ATM_ENI
32 tristate "Efficient Networks ENI155P" 35 tristate "Efficient Networks ENI155P"
33 depends on PCI && ATM 36 depends on PCI
34 ---help--- 37 ---help---
35 Driver for the Efficient Networks ENI155p series and SMC ATM 38 Driver for the Efficient Networks ENI155p series and SMC ATM
36 Power155 155 Mbps ATM adapters. Both, the versions with 512KB and 39 Power155 155 Mbps ATM adapters. Both, the versions with 512KB and
@@ -139,7 +142,7 @@ config ATM_ENI_BURST_RX_2W
139 142
140config ATM_FIRESTREAM 143config ATM_FIRESTREAM
141 tristate "Fujitsu FireStream (FS50/FS155) " 144 tristate "Fujitsu FireStream (FS50/FS155) "
142 depends on PCI && ATM 145 depends on PCI
143 help 146 help
144 Driver for the Fujitsu FireStream 155 (MB86697) and 147 Driver for the Fujitsu FireStream 155 (MB86697) and
145 FireStream 50 (MB86695) ATM PCI chips. 148 FireStream 50 (MB86695) ATM PCI chips.
@@ -149,7 +152,7 @@ config ATM_FIRESTREAM
149 152
150config ATM_ZATM 153config ATM_ZATM
151 tristate "ZeitNet ZN1221/ZN1225" 154 tristate "ZeitNet ZN1221/ZN1225"
152 depends on PCI && ATM 155 depends on PCI
153 help 156 help
154 Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM 157 Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM
155 adapters. 158 adapters.
@@ -169,7 +172,7 @@ config ATM_ZATM_DEBUG
169 172
170config ATM_NICSTAR 173config ATM_NICSTAR
171 tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" 174 tristate "IDT 77201 (NICStAR) (ForeRunnerLE)"
172 depends on PCI && ATM && !64BIT 175 depends on PCI && !64BIT
173 help 176 help
174 The NICStAR chipset family is used in a large number of ATM NICs for 177 The NICStAR chipset family is used in a large number of ATM NICs for
175 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE 178 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE
@@ -202,7 +205,7 @@ config ATM_NICSTAR_USE_IDT77105
202 205
203config ATM_IDT77252 206config ATM_IDT77252
204 tristate "IDT 77252 (NICStAR II)" 207 tristate "IDT 77252 (NICStAR II)"
205 depends on PCI && ATM 208 depends on PCI
206 help 209 help
207 Driver for the IDT 77252 ATM PCI chips. 210 Driver for the IDT 77252 ATM PCI chips.
208 211
@@ -237,7 +240,7 @@ config ATM_IDT77252_USE_SUNI
237 240
238config ATM_AMBASSADOR 241config ATM_AMBASSADOR
239 tristate "Madge Ambassador (Collage PCI 155 Server)" 242 tristate "Madge Ambassador (Collage PCI 155 Server)"
240 depends on PCI && ATM 243 depends on PCI
241 select BITREVERSE 244 select BITREVERSE
242 help 245 help
243 This is a driver for ATMizer based ATM card produced by Madge 246 This is a driver for ATMizer based ATM card produced by Madge
@@ -262,7 +265,7 @@ config ATM_AMBASSADOR_DEBUG
262 265
263config ATM_HORIZON 266config ATM_HORIZON
264 tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)" 267 tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)"
265 depends on PCI && ATM 268 depends on PCI
266 help 269 help
267 This is a driver for the Horizon chipset ATM adapter cards once 270 This is a driver for the Horizon chipset ATM adapter cards once
268 produced by Madge Networks Ltd. Say Y (or M to compile as a module 271 produced by Madge Networks Ltd. Say Y (or M to compile as a module
@@ -286,7 +289,7 @@ config ATM_HORIZON_DEBUG
286 289
287config ATM_IA 290config ATM_IA
288 tristate "Interphase ATM PCI x575/x525/x531" 291 tristate "Interphase ATM PCI x575/x525/x531"
289 depends on PCI && ATM && !64BIT 292 depends on PCI && !64BIT
290 ---help--- 293 ---help---
291 This is a driver for the Interphase (i)ChipSAR adapter cards 294 This is a driver for the Interphase (i)ChipSAR adapter cards
292 which include a variety of variants in term of the size of the 295 which include a variety of variants in term of the size of the
@@ -319,7 +322,7 @@ config ATM_IA_DEBUG
319 322
320config ATM_FORE200E_MAYBE 323config ATM_FORE200E_MAYBE
321 tristate "FORE Systems 200E-series" 324 tristate "FORE Systems 200E-series"
322 depends on (PCI || SBUS) && ATM 325 depends on PCI || SBUS
323 ---help--- 326 ---help---
324 This is a driver for the FORE Systems 200E-series ATM adapter 327 This is a driver for the FORE Systems 200E-series ATM adapter
325 cards. It simultaneously supports PCA-200E and SBA-200E models 328 cards. It simultaneously supports PCA-200E and SBA-200E models
@@ -436,7 +439,7 @@ config ATM_FORE200E
436 439
437config ATM_HE 440config ATM_HE
438 tristate "ForeRunner HE Series" 441 tristate "ForeRunner HE Series"
439 depends on PCI && ATM 442 depends on PCI
440 help 443 help
441 This is a driver for the Marconi ForeRunner HE-series ATM adapter 444 This is a driver for the Marconi ForeRunner HE-series ATM adapter
442 cards. It simultaneously supports the 155 and 622 versions. 445 cards. It simultaneously supports the 155 and 622 versions.
@@ -448,5 +451,4 @@ config ATM_HE_USE_SUNI
448 Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner 451 Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner
449 HE cards. This driver provides carrier detection some statistics. 452 HE cards. This driver provides carrier detection some statistics.
450 453
451endmenu 454endif # ATM
452
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index 3c9684ccd2f9..eac4f9b9f007 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -571,7 +571,7 @@ static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent,
571 * ACPIBASE is bits [15:7] from 0x40-0x43 571 * ACPIBASE is bits [15:7] from 0x40-0x43
572 */ 572 */
573 pci_read_config_dword(pdev, 0x40, &base_address); 573 pci_read_config_dword(pdev, 0x40, &base_address);
574 base_address &= 0x00007f80; 574 base_address &= 0x0000ff80;
575 if (base_address == 0x00000000) { 575 if (base_address == 0x00000000) {
576 /* Something's wrong here, ACPIBASE has to be set */ 576 /* Something's wrong here, ACPIBASE has to be set */
577 printk(KERN_ERR PFX "failed to get TCOBASE address\n"); 577 printk(KERN_ERR PFX "failed to get TCOBASE address\n");
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 08e594d495d7..fb99cd445504 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1898,8 +1898,12 @@ endmenu
1898# Gigabit Ethernet 1898# Gigabit Ethernet
1899# 1899#
1900 1900
1901menu "Ethernet (1000 Mbit)" 1901menuconfig NETDEV_1000
1902 bool "Ethernet (1000 Mbit)"
1902 depends on !UML 1903 depends on !UML
1904 default y
1905
1906if NETDEV_1000
1903 1907
1904config ACENIC 1908config ACENIC
1905 tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" 1909 tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
@@ -2326,14 +2330,18 @@ config ATL1
2326 To compile this driver as a module, choose M here. The module 2330 To compile this driver as a module, choose M here. The module
2327 will be called atl1. 2331 will be called atl1.
2328 2332
2329endmenu 2333endif # NETDEV_1000
2330 2334
2331# 2335#
2332# 10 Gigabit Ethernet 2336# 10 Gigabit Ethernet
2333# 2337#
2334 2338
2335menu "Ethernet (10000 Mbit)" 2339menuconfig NETDEV_10000
2340 bool "Ethernet (10000 Mbit)"
2336 depends on !UML 2341 depends on !UML
2342 default y
2343
2344if NETDEV_10000
2337 2345
2338config CHELSIO_T1 2346config CHELSIO_T1
2339 tristate "Chelsio 10Gb Ethernet support" 2347 tristate "Chelsio 10Gb Ethernet support"
@@ -2507,7 +2515,7 @@ config MLX4_DEBUG
2507 debug_level module parameter (which can also be set after 2515 debug_level module parameter (which can also be set after
2508 the driver is loaded through sysfs). 2516 the driver is loaded through sysfs).
2509 2517
2510endmenu 2518endif # NETDEV_10000
2511 2519
2512source "drivers/net/tokenring/Kconfig" 2520source "drivers/net/tokenring/Kconfig"
2513 2521
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c
index acf1c801a1b8..af016d0ea1c6 100644
--- a/drivers/net/mlx4/eq.c
+++ b/drivers/net/mlx4/eq.c
@@ -623,7 +623,7 @@ int __devinit mlx4_init_eq_table(struct mlx4_dev *dev)
623 priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1; 623 priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1;
624 } else { 624 } else {
625 err = request_irq(dev->pdev->irq, mlx4_interrupt, 625 err = request_irq(dev->pdev->irq, mlx4_interrupt,
626 SA_SHIRQ, DRV_NAME, dev); 626 IRQF_SHARED, DRV_NAME, dev);
627 if (err) 627 if (err)
628 goto err_out_async; 628 goto err_out_async;
629 629
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 4e32bb678ea9..2c5c6d20e6e9 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -735,7 +735,7 @@ static int netxen_nic_open(struct net_device *netdev)
735 } 735 }
736 adapter->irq = adapter->ahw.pdev->irq; 736 adapter->irq = adapter->ahw.pdev->irq;
737 err = request_irq(adapter->ahw.pdev->irq, netxen_intr, 737 err = request_irq(adapter->ahw.pdev->irq, netxen_intr,
738 SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, 738 IRQF_SHARED|IRQF_SAMPLE_RANDOM, netdev->name,
739 adapter); 739 adapter);
740 if (err) { 740 if (err) {
741 printk(KERN_ERR "request_irq failed with: %d\n", err); 741 printk(KERN_ERR "request_irq failed with: %d\n", err);
diff --git a/drivers/net/pcmcia/Kconfig b/drivers/net/pcmcia/Kconfig
index 74f862001247..5d658bc9791c 100644
--- a/drivers/net/pcmcia/Kconfig
+++ b/drivers/net/pcmcia/Kconfig
@@ -2,11 +2,9 @@
2# PCMCIA Network device configuration 2# PCMCIA Network device configuration
3# 3#
4 4
5menu "PCMCIA network device support" 5menuconfig NET_PCMCIA
6 depends on NETDEVICES && PCMCIA!=n
7
8config NET_PCMCIA
9 bool "PCMCIA network device support" 6 bool "PCMCIA network device support"
7 depends on PCMCIA
10 ---help--- 8 ---help---
11 Say Y if you would like to include support for any PCMCIA or CardBus 9 Say Y if you would like to include support for any PCMCIA or CardBus
12 network adapters, then say Y to the driver for your particular card 10 network adapters, then say Y to the driver for your particular card
@@ -21,9 +19,10 @@ config NET_PCMCIA
21 19
22 If unsure, say N. 20 If unsure, say N.
23 21
22if NET_PCMCIA
23
24config PCMCIA_3C589 24config PCMCIA_3C589
25 tristate "3Com 3c589 PCMCIA support" 25 tristate "3Com 3c589 PCMCIA support"
26 depends on NET_PCMCIA && PCMCIA
27 help 26 help
28 Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA 27 Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA
29 (PC-card) Ethernet card to your computer. 28 (PC-card) Ethernet card to your computer.
@@ -33,7 +32,6 @@ config PCMCIA_3C589
33 32
34config PCMCIA_3C574 33config PCMCIA_3C574
35 tristate "3Com 3c574 PCMCIA support" 34 tristate "3Com 3c574 PCMCIA support"
36 depends on NET_PCMCIA && PCMCIA
37 help 35 help
38 Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA 36 Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA
39 (PC-card) Fast Ethernet card to your computer. 37 (PC-card) Fast Ethernet card to your computer.
@@ -43,7 +41,6 @@ config PCMCIA_3C574
43 41
44config PCMCIA_FMVJ18X 42config PCMCIA_FMVJ18X
45 tristate "Fujitsu FMV-J18x PCMCIA support" 43 tristate "Fujitsu FMV-J18x PCMCIA support"
46 depends on NET_PCMCIA && PCMCIA
47 select CRC32 44 select CRC32
48 help 45 help
49 Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible 46 Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible
@@ -54,7 +51,6 @@ config PCMCIA_FMVJ18X
54 51
55config PCMCIA_PCNET 52config PCMCIA_PCNET
56 tristate "NE2000 compatible PCMCIA support" 53 tristate "NE2000 compatible PCMCIA support"
57 depends on NET_PCMCIA && PCMCIA
58 select CRC32 54 select CRC32
59 help 55 help
60 Say Y here if you intend to attach an NE2000 compatible PCMCIA 56 Say Y here if you intend to attach an NE2000 compatible PCMCIA
@@ -65,7 +61,6 @@ config PCMCIA_PCNET
65 61
66config PCMCIA_NMCLAN 62config PCMCIA_NMCLAN
67 tristate "New Media PCMCIA support" 63 tristate "New Media PCMCIA support"
68 depends on NET_PCMCIA && PCMCIA
69 help 64 help
70 Say Y here if you intend to attach a New Media Ethernet or LiveWire 65 Say Y here if you intend to attach a New Media Ethernet or LiveWire
71 PCMCIA (PC-card) Ethernet card to your computer. 66 PCMCIA (PC-card) Ethernet card to your computer.
@@ -75,7 +70,6 @@ config PCMCIA_NMCLAN
75 70
76config PCMCIA_SMC91C92 71config PCMCIA_SMC91C92
77 tristate "SMC 91Cxx PCMCIA support" 72 tristate "SMC 91Cxx PCMCIA support"
78 depends on NET_PCMCIA && PCMCIA
79 select CRC32 73 select CRC32
80 select MII 74 select MII
81 help 75 help
@@ -87,7 +81,6 @@ config PCMCIA_SMC91C92
87 81
88config PCMCIA_XIRC2PS 82config PCMCIA_XIRC2PS
89 tristate "Xircom 16-bit PCMCIA support" 83 tristate "Xircom 16-bit PCMCIA support"
90 depends on NET_PCMCIA && PCMCIA
91 help 84 help
92 Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card) 85 Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card)
93 Ethernet or Fast Ethernet card to your computer. 86 Ethernet or Fast Ethernet card to your computer.
@@ -97,7 +90,6 @@ config PCMCIA_XIRC2PS
97 90
98config PCMCIA_AXNET 91config PCMCIA_AXNET
99 tristate "Asix AX88190 PCMCIA support" 92 tristate "Asix AX88190 PCMCIA support"
100 depends on NET_PCMCIA && PCMCIA
101 ---help--- 93 ---help---
102 Say Y here if you intend to attach an Asix AX88190-based PCMCIA 94 Say Y here if you intend to attach an Asix AX88190-based PCMCIA
103 (PC-card) Fast Ethernet card to your computer. These cards are 95 (PC-card) Fast Ethernet card to your computer. These cards are
@@ -109,7 +101,7 @@ config PCMCIA_AXNET
109 101
110config ARCNET_COM20020_CS 102config ARCNET_COM20020_CS
111 tristate "COM20020 ARCnet PCMCIA support" 103 tristate "COM20020 ARCnet PCMCIA support"
112 depends on NET_PCMCIA && ARCNET_COM20020 && PCMCIA 104 depends on ARCNET_COM20020
113 help 105 help
114 Say Y here if you intend to attach this type of ARCnet PCMCIA card 106 Say Y here if you intend to attach this type of ARCnet PCMCIA card
115 to your computer. 107 to your computer.
@@ -119,7 +111,7 @@ config ARCNET_COM20020_CS
119 111
120config PCMCIA_IBMTR 112config PCMCIA_IBMTR
121 tristate "IBM PCMCIA tokenring adapter support" 113 tristate "IBM PCMCIA tokenring adapter support"
122 depends on NET_PCMCIA && IBMTR!=y && TR && PCMCIA && !64BIT 114 depends on IBMTR!=y && TR && !64BIT
123 help 115 help
124 Say Y here if you intend to attach this type of Token Ring PCMCIA 116 Say Y here if you intend to attach this type of Token Ring PCMCIA
125 card to your computer. You then also need to say Y to "Token Ring 117 card to your computer. You then also need to say Y to "Token Ring
@@ -128,5 +120,4 @@ config PCMCIA_IBMTR
128 To compile this driver as a module, choose M here: the module will be 120 To compile this driver as a module, choose M here: the module will be
129 called ibmtr_cs. 121 called ibmtr_cs.
130 122
131endmenu 123endif # NET_PCMCIA
132
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index c0d3101eb6a0..09b6f259eb92 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -2,70 +2,61 @@
2# PHY Layer Configuration 2# PHY Layer Configuration
3# 3#
4 4
5menu "PHY device support" 5menuconfig PHYLIB
6 depends on !S390
7
8config PHYLIB
9 tristate "PHY Device support and infrastructure" 6 tristate "PHY Device support and infrastructure"
7 depends on !S390
10 depends on NET_ETHERNET && (BROKEN || !S390) 8 depends on NET_ETHERNET && (BROKEN || !S390)
11 help 9 help
12 Ethernet controllers are usually attached to PHY 10 Ethernet controllers are usually attached to PHY
13 devices. This option provides infrastructure for 11 devices. This option provides infrastructure for
14 managing PHY devices. 12 managing PHY devices.
15 13
14if PHYLIB
15
16comment "MII PHY device drivers" 16comment "MII PHY device drivers"
17 depends on PHYLIB
18 17
19config MARVELL_PHY 18config MARVELL_PHY
20 tristate "Drivers for Marvell PHYs" 19 tristate "Drivers for Marvell PHYs"
21 depends on PHYLIB
22 ---help--- 20 ---help---
23 Currently has a driver for the 88E1011S 21 Currently has a driver for the 88E1011S
24 22
25config DAVICOM_PHY 23config DAVICOM_PHY
26 tristate "Drivers for Davicom PHYs" 24 tristate "Drivers for Davicom PHYs"
27 depends on PHYLIB
28 ---help--- 25 ---help---
29 Currently supports dm9161e and dm9131 26 Currently supports dm9161e and dm9131
30 27
31config QSEMI_PHY 28config QSEMI_PHY
32 tristate "Drivers for Quality Semiconductor PHYs" 29 tristate "Drivers for Quality Semiconductor PHYs"
33 depends on PHYLIB
34 ---help--- 30 ---help---
35 Currently supports the qs6612 31 Currently supports the qs6612
36 32
37config LXT_PHY 33config LXT_PHY
38 tristate "Drivers for the Intel LXT PHYs" 34 tristate "Drivers for the Intel LXT PHYs"
39 depends on PHYLIB
40 ---help--- 35 ---help---
41 Currently supports the lxt970, lxt971 36 Currently supports the lxt970, lxt971
42 37
43config CICADA_PHY 38config CICADA_PHY
44 tristate "Drivers for the Cicada PHYs" 39 tristate "Drivers for the Cicada PHYs"
45 depends on PHYLIB
46 ---help--- 40 ---help---
47 Currently supports the cis8204 41 Currently supports the cis8204
42
48config VITESSE_PHY 43config VITESSE_PHY
49 tristate "Drivers for the Vitesse PHYs" 44 tristate "Drivers for the Vitesse PHYs"
50 depends on PHYLIB
51 ---help--- 45 ---help---
52 Currently supports the vsc8244 46 Currently supports the vsc8244
53 47
54config SMSC_PHY 48config SMSC_PHY
55 tristate "Drivers for SMSC PHYs" 49 tristate "Drivers for SMSC PHYs"
56 depends on PHYLIB
57 ---help--- 50 ---help---
58 Currently supports the LAN83C185 PHY 51 Currently supports the LAN83C185 PHY
59 52
60config BROADCOM_PHY 53config BROADCOM_PHY
61 tristate "Drivers for Broadcom PHYs" 54 tristate "Drivers for Broadcom PHYs"
62 depends on PHYLIB
63 ---help--- 55 ---help---
64 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs. 56 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
65 57
66config FIXED_PHY 58config FIXED_PHY
67 tristate "Drivers for PHY emulation on fixed speed/link" 59 tristate "Drivers for PHY emulation on fixed speed/link"
68 depends on PHYLIB
69 ---help--- 60 ---help---
70 Adds the driver to PHY layer to cover the boards that do not have any PHY bound, 61 Adds the driver to PHY layer to cover the boards that do not have any PHY bound,
71 but with the ability to manipulate the speed/link in software. The relevant MII 62 but with the ability to manipulate the speed/link in software. The relevant MII
@@ -80,5 +71,4 @@ config FIXED_MII_100_FDX
80 bool "Emulation for 100M Fdx fixed PHY behavior" 71 bool "Emulation for 100M Fdx fixed PHY behavior"
81 depends on FIXED_PHY 72 depends on FIXED_PHY
82 73
83endmenu 74endif # PHYLIB
84
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index 519baa38be8d..7ed632db00d7 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -139,7 +139,7 @@ static int dm9161_ack_interrupt(struct phy_device *phydev)
139 return (err < 0) ? err : 0; 139 return (err < 0) ? err : 0;
140} 140}
141 141
142static struct phy_driver dm9161_driver = { 142static struct phy_driver dm9161e_driver = {
143 .phy_id = 0x0181b880, 143 .phy_id = 0x0181b880,
144 .name = "Davicom DM9161E", 144 .name = "Davicom DM9161E",
145 .phy_id_mask = 0x0ffffff0, 145 .phy_id_mask = 0x0ffffff0,
@@ -147,7 +147,18 @@ static struct phy_driver dm9161_driver = {
147 .config_init = dm9161_config_init, 147 .config_init = dm9161_config_init,
148 .config_aneg = dm9161_config_aneg, 148 .config_aneg = dm9161_config_aneg,
149 .read_status = genphy_read_status, 149 .read_status = genphy_read_status,
150 .driver = { .owner = THIS_MODULE,}, 150 .driver = { .owner = THIS_MODULE,},
151};
152
153static struct phy_driver dm9161a_driver = {
154 .phy_id = 0x0181b8a0,
155 .name = "Davicom DM9161A",
156 .phy_id_mask = 0x0ffffff0,
157 .features = PHY_BASIC_FEATURES,
158 .config_init = dm9161_config_init,
159 .config_aneg = dm9161_config_aneg,
160 .read_status = genphy_read_status,
161 .driver = { .owner = THIS_MODULE,},
151}; 162};
152 163
153static struct phy_driver dm9131_driver = { 164static struct phy_driver dm9131_driver = {
@@ -160,31 +171,38 @@ static struct phy_driver dm9131_driver = {
160 .read_status = genphy_read_status, 171 .read_status = genphy_read_status,
161 .ack_interrupt = dm9161_ack_interrupt, 172 .ack_interrupt = dm9161_ack_interrupt,
162 .config_intr = dm9161_config_intr, 173 .config_intr = dm9161_config_intr,
163 .driver = { .owner = THIS_MODULE,}, 174 .driver = { .owner = THIS_MODULE,},
164}; 175};
165 176
166static int __init davicom_init(void) 177static int __init davicom_init(void)
167{ 178{
168 int ret; 179 int ret;
169 180
170 ret = phy_driver_register(&dm9161_driver); 181 ret = phy_driver_register(&dm9161e_driver);
171 if (ret) 182 if (ret)
172 goto err1; 183 goto err1;
173 184
174 ret = phy_driver_register(&dm9131_driver); 185 ret = phy_driver_register(&dm9161a_driver);
175 if (ret) 186 if (ret)
176 goto err2; 187 goto err2;
188
189 ret = phy_driver_register(&dm9131_driver);
190 if (ret)
191 goto err3;
177 return 0; 192 return 0;
178 193
179 err2: 194 err3:
180 phy_driver_unregister(&dm9161_driver); 195 phy_driver_unregister(&dm9161a_driver);
196 err2:
197 phy_driver_unregister(&dm9161e_driver);
181 err1: 198 err1:
182 return ret; 199 return ret;
183} 200}
184 201
185static void __exit davicom_exit(void) 202static void __exit davicom_exit(void)
186{ 203{
187 phy_driver_unregister(&dm9161_driver); 204 phy_driver_unregister(&dm9161e_driver);
205 phy_driver_unregister(&dm9161a_driver);
188 phy_driver_unregister(&dm9131_driver); 206 phy_driver_unregister(&dm9131_driver);
189} 207}
190 208
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 290e1c1f30c6..e3e6d410d72c 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -84,7 +84,7 @@
84#include "s2io.h" 84#include "s2io.h"
85#include "s2io-regs.h" 85#include "s2io-regs.h"
86 86
87#define DRV_VERSION "2.0.22.1" 87#define DRV_VERSION "2.0.23.1"
88 88
89/* S2io Driver name & version. */ 89/* S2io Driver name & version. */
90static char s2io_driver_name[] = "Neterion"; 90static char s2io_driver_name[] = "Neterion";
@@ -281,6 +281,28 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = {
281 ("lro_out_of_sequence_pkts"), 281 ("lro_out_of_sequence_pkts"),
282 ("lro_flush_due_to_max_pkts"), 282 ("lro_flush_due_to_max_pkts"),
283 ("lro_avg_aggr_pkts"), 283 ("lro_avg_aggr_pkts"),
284 ("mem_alloc_fail_cnt"),
285 ("watchdog_timer_cnt"),
286 ("mem_allocated"),
287 ("mem_freed"),
288 ("link_up_cnt"),
289 ("link_down_cnt"),
290 ("link_up_time"),
291 ("link_down_time"),
292 ("tx_tcode_buf_abort_cnt"),
293 ("tx_tcode_desc_abort_cnt"),
294 ("tx_tcode_parity_err_cnt"),
295 ("tx_tcode_link_loss_cnt"),
296 ("tx_tcode_list_proc_err_cnt"),
297 ("rx_tcode_parity_err_cnt"),
298 ("rx_tcode_abort_cnt"),
299 ("rx_tcode_parity_abort_cnt"),
300 ("rx_tcode_rda_fail_cnt"),
301 ("rx_tcode_unkn_prot_cnt"),
302 ("rx_tcode_fcs_err_cnt"),
303 ("rx_tcode_buf_size_err_cnt"),
304 ("rx_tcode_rxd_corrupt_cnt"),
305 ("rx_tcode_unkn_err_cnt")
284}; 306};
285 307
286#define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN 308#define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN
@@ -490,6 +512,7 @@ static int init_shared_mem(struct s2io_nic *nic)
490 512
491 struct mac_info *mac_control; 513 struct mac_info *mac_control;
492 struct config_param *config; 514 struct config_param *config;
515 unsigned long long mem_allocated = 0;
493 516
494 mac_control = &nic->mac_control; 517 mac_control = &nic->mac_control;
495 config = &nic->config; 518 config = &nic->config;
@@ -519,6 +542,7 @@ static int init_shared_mem(struct s2io_nic *nic)
519 "Malloc failed for list_info\n"); 542 "Malloc failed for list_info\n");
520 return -ENOMEM; 543 return -ENOMEM;
521 } 544 }
545 mem_allocated += list_holder_size;
522 memset(mac_control->fifos[i].list_info, 0, list_holder_size); 546 memset(mac_control->fifos[i].list_info, 0, list_holder_size);
523 } 547 }
524 for (i = 0; i < config->tx_fifo_num; i++) { 548 for (i = 0; i < config->tx_fifo_num; i++) {
@@ -565,6 +589,7 @@ static int init_shared_mem(struct s2io_nic *nic)
565 DBG_PRINT(INFO_DBG, "failed for TxDL\n"); 589 DBG_PRINT(INFO_DBG, "failed for TxDL\n");
566 return -ENOMEM; 590 return -ENOMEM;
567 } 591 }
592 mem_allocated += PAGE_SIZE;
568 } 593 }
569 while (k < lst_per_page) { 594 while (k < lst_per_page) {
570 int l = (j * lst_per_page) + k; 595 int l = (j * lst_per_page) + k;
@@ -582,6 +607,7 @@ static int init_shared_mem(struct s2io_nic *nic)
582 nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); 607 nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL);
583 if (!nic->ufo_in_band_v) 608 if (!nic->ufo_in_band_v)
584 return -ENOMEM; 609 return -ENOMEM;
610 mem_allocated += (size * sizeof(u64));
585 611
586 /* Allocation and initialization of RXDs in Rings */ 612 /* Allocation and initialization of RXDs in Rings */
587 size = 0; 613 size = 0;
@@ -639,6 +665,7 @@ static int init_shared_mem(struct s2io_nic *nic)
639 rx_blocks->block_virt_addr = tmp_v_addr; 665 rx_blocks->block_virt_addr = tmp_v_addr;
640 return -ENOMEM; 666 return -ENOMEM;
641 } 667 }
668 mem_allocated += size;
642 memset(tmp_v_addr, 0, size); 669 memset(tmp_v_addr, 0, size);
643 rx_blocks->block_virt_addr = tmp_v_addr; 670 rx_blocks->block_virt_addr = tmp_v_addr;
644 rx_blocks->block_dma_addr = tmp_p_addr; 671 rx_blocks->block_dma_addr = tmp_p_addr;
@@ -647,6 +674,8 @@ static int init_shared_mem(struct s2io_nic *nic)
647 GFP_KERNEL); 674 GFP_KERNEL);
648 if (!rx_blocks->rxds) 675 if (!rx_blocks->rxds)
649 return -ENOMEM; 676 return -ENOMEM;
677 mem_allocated +=
678 (sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]);
650 for (l=0; l<rxd_count[nic->rxd_mode];l++) { 679 for (l=0; l<rxd_count[nic->rxd_mode];l++) {
651 rx_blocks->rxds[l].virt_addr = 680 rx_blocks->rxds[l].virt_addr =
652 rx_blocks->block_virt_addr + 681 rx_blocks->block_virt_addr +
@@ -689,6 +718,7 @@ static int init_shared_mem(struct s2io_nic *nic)
689 GFP_KERNEL); 718 GFP_KERNEL);
690 if (!mac_control->rings[i].ba) 719 if (!mac_control->rings[i].ba)
691 return -ENOMEM; 720 return -ENOMEM;
721 mem_allocated +=(sizeof(struct buffAdd *) * blk_cnt);
692 for (j = 0; j < blk_cnt; j++) { 722 for (j = 0; j < blk_cnt; j++) {
693 int k = 0; 723 int k = 0;
694 mac_control->rings[i].ba[j] = 724 mac_control->rings[i].ba[j] =
@@ -697,6 +727,8 @@ static int init_shared_mem(struct s2io_nic *nic)
697 GFP_KERNEL); 727 GFP_KERNEL);
698 if (!mac_control->rings[i].ba[j]) 728 if (!mac_control->rings[i].ba[j])
699 return -ENOMEM; 729 return -ENOMEM;
730 mem_allocated += (sizeof(struct buffAdd) * \
731 (rxd_count[nic->rxd_mode] + 1));
700 while (k != rxd_count[nic->rxd_mode]) { 732 while (k != rxd_count[nic->rxd_mode]) {
701 ba = &mac_control->rings[i].ba[j][k]; 733 ba = &mac_control->rings[i].ba[j][k];
702 734
@@ -704,6 +736,8 @@ static int init_shared_mem(struct s2io_nic *nic)
704 (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); 736 (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL);
705 if (!ba->ba_0_org) 737 if (!ba->ba_0_org)
706 return -ENOMEM; 738 return -ENOMEM;
739 mem_allocated +=
740 (BUF0_LEN + ALIGN_SIZE);
707 tmp = (unsigned long)ba->ba_0_org; 741 tmp = (unsigned long)ba->ba_0_org;
708 tmp += ALIGN_SIZE; 742 tmp += ALIGN_SIZE;
709 tmp &= ~((unsigned long) ALIGN_SIZE); 743 tmp &= ~((unsigned long) ALIGN_SIZE);
@@ -713,6 +747,8 @@ static int init_shared_mem(struct s2io_nic *nic)
713 (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); 747 (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL);
714 if (!ba->ba_1_org) 748 if (!ba->ba_1_org)
715 return -ENOMEM; 749 return -ENOMEM;
750 mem_allocated
751 += (BUF1_LEN + ALIGN_SIZE);
716 tmp = (unsigned long) ba->ba_1_org; 752 tmp = (unsigned long) ba->ba_1_org;
717 tmp += ALIGN_SIZE; 753 tmp += ALIGN_SIZE;
718 tmp &= ~((unsigned long) ALIGN_SIZE); 754 tmp &= ~((unsigned long) ALIGN_SIZE);
@@ -736,6 +772,7 @@ static int init_shared_mem(struct s2io_nic *nic)
736 */ 772 */
737 return -ENOMEM; 773 return -ENOMEM;
738 } 774 }
775 mem_allocated += size;
739 mac_control->stats_mem_sz = size; 776 mac_control->stats_mem_sz = size;
740 777
741 tmp_v_addr = mac_control->stats_mem; 778 tmp_v_addr = mac_control->stats_mem;
@@ -743,7 +780,7 @@ static int init_shared_mem(struct s2io_nic *nic)
743 memset(tmp_v_addr, 0, size); 780 memset(tmp_v_addr, 0, size);
744 DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, 781 DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name,
745 (unsigned long long) tmp_p_addr); 782 (unsigned long long) tmp_p_addr);
746 783 mac_control->stats_info->sw_stat.mem_allocated += mem_allocated;
747 return SUCCESS; 784 return SUCCESS;
748} 785}
749 786
@@ -757,12 +794,14 @@ static int init_shared_mem(struct s2io_nic *nic)
757static void free_shared_mem(struct s2io_nic *nic) 794static void free_shared_mem(struct s2io_nic *nic)
758{ 795{
759 int i, j, blk_cnt, size; 796 int i, j, blk_cnt, size;
797 u32 ufo_size = 0;
760 void *tmp_v_addr; 798 void *tmp_v_addr;
761 dma_addr_t tmp_p_addr; 799 dma_addr_t tmp_p_addr;
762 struct mac_info *mac_control; 800 struct mac_info *mac_control;
763 struct config_param *config; 801 struct config_param *config;
764 int lst_size, lst_per_page; 802 int lst_size, lst_per_page;
765 struct net_device *dev = nic->dev; 803 struct net_device *dev = nic->dev;
804 int page_num = 0;
766 805
767 if (!nic) 806 if (!nic)
768 return; 807 return;
@@ -774,8 +813,9 @@ static void free_shared_mem(struct s2io_nic *nic)
774 lst_per_page = PAGE_SIZE / lst_size; 813 lst_per_page = PAGE_SIZE / lst_size;
775 814
776 for (i = 0; i < config->tx_fifo_num; i++) { 815 for (i = 0; i < config->tx_fifo_num; i++) {
777 int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, 816 ufo_size += config->tx_cfg[i].fifo_len;
778 lst_per_page); 817 page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
818 lst_per_page);
779 for (j = 0; j < page_num; j++) { 819 for (j = 0; j < page_num; j++) {
780 int mem_blks = (j * lst_per_page); 820 int mem_blks = (j * lst_per_page);
781 if (!mac_control->fifos[i].list_info) 821 if (!mac_control->fifos[i].list_info)
@@ -790,6 +830,8 @@ static void free_shared_mem(struct s2io_nic *nic)
790 mac_control->fifos[i]. 830 mac_control->fifos[i].
791 list_info[mem_blks]. 831 list_info[mem_blks].
792 list_phy_addr); 832 list_phy_addr);
833 nic->mac_control.stats_info->sw_stat.mem_freed
834 += PAGE_SIZE;
793 } 835 }
794 /* If we got a zero DMA address during allocation, 836 /* If we got a zero DMA address during allocation,
795 * free the page now 837 * free the page now
@@ -803,8 +845,12 @@ static void free_shared_mem(struct s2io_nic *nic)
803 dev->name); 845 dev->name);
804 DBG_PRINT(INIT_DBG, "Virtual address %p\n", 846 DBG_PRINT(INIT_DBG, "Virtual address %p\n",
805 mac_control->zerodma_virt_addr); 847 mac_control->zerodma_virt_addr);
848 nic->mac_control.stats_info->sw_stat.mem_freed
849 += PAGE_SIZE;
806 } 850 }
807 kfree(mac_control->fifos[i].list_info); 851 kfree(mac_control->fifos[i].list_info);
852 nic->mac_control.stats_info->sw_stat.mem_freed +=
853 (nic->config.tx_cfg[i].fifo_len *sizeof(struct list_info_hold));
808 } 854 }
809 855
810 size = SIZE_OF_BLOCK; 856 size = SIZE_OF_BLOCK;
@@ -819,7 +865,10 @@ static void free_shared_mem(struct s2io_nic *nic)
819 break; 865 break;
820 pci_free_consistent(nic->pdev, size, 866 pci_free_consistent(nic->pdev, size,
821 tmp_v_addr, tmp_p_addr); 867 tmp_v_addr, tmp_p_addr);
868 nic->mac_control.stats_info->sw_stat.mem_freed += size;
822 kfree(mac_control->rings[i].rx_blocks[j].rxds); 869 kfree(mac_control->rings[i].rx_blocks[j].rxds);
870 nic->mac_control.stats_info->sw_stat.mem_freed +=
871 ( sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]);
823 } 872 }
824 } 873 }
825 874
@@ -836,12 +885,20 @@ static void free_shared_mem(struct s2io_nic *nic)
836 struct buffAdd *ba = 885 struct buffAdd *ba =
837 &mac_control->rings[i].ba[j][k]; 886 &mac_control->rings[i].ba[j][k];
838 kfree(ba->ba_0_org); 887 kfree(ba->ba_0_org);
888 nic->mac_control.stats_info->sw_stat.\
889 mem_freed += (BUF0_LEN + ALIGN_SIZE);
839 kfree(ba->ba_1_org); 890 kfree(ba->ba_1_org);
891 nic->mac_control.stats_info->sw_stat.\
892 mem_freed += (BUF1_LEN + ALIGN_SIZE);
840 k++; 893 k++;
841 } 894 }
842 kfree(mac_control->rings[i].ba[j]); 895 kfree(mac_control->rings[i].ba[j]);
896 nic->mac_control.stats_info->sw_stat.mem_freed += (sizeof(struct buffAdd) *
897 (rxd_count[nic->rxd_mode] + 1));
843 } 898 }
844 kfree(mac_control->rings[i].ba); 899 kfree(mac_control->rings[i].ba);
900 nic->mac_control.stats_info->sw_stat.mem_freed +=
901 (sizeof(struct buffAdd *) * blk_cnt);
845 } 902 }
846 } 903 }
847 904
@@ -850,9 +907,14 @@ static void free_shared_mem(struct s2io_nic *nic)
850 mac_control->stats_mem_sz, 907 mac_control->stats_mem_sz,
851 mac_control->stats_mem, 908 mac_control->stats_mem,
852 mac_control->stats_mem_phy); 909 mac_control->stats_mem_phy);
910 nic->mac_control.stats_info->sw_stat.mem_freed +=
911 mac_control->stats_mem_sz;
853 } 912 }
854 if (nic->ufo_in_band_v) 913 if (nic->ufo_in_band_v) {
855 kfree(nic->ufo_in_band_v); 914 kfree(nic->ufo_in_band_v);
915 nic->mac_control.stats_info->sw_stat.mem_freed
916 += (ufo_size * sizeof(u64));
917 }
856} 918}
857 919
858/** 920/**
@@ -2122,10 +2184,12 @@ static void free_tx_buffers(struct s2io_nic *nic)
2122 2184
2123 for (i = 0; i < config->tx_fifo_num; i++) { 2185 for (i = 0; i < config->tx_fifo_num; i++) {
2124 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { 2186 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) {
2125 txdp = (struct TxD *) mac_control->fifos[i].list_info[j]. 2187 txdp = (struct TxD *) \
2126 list_virt_addr; 2188 mac_control->fifos[i].list_info[j].list_virt_addr;
2127 skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); 2189 skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j);
2128 if (skb) { 2190 if (skb) {
2191 nic->mac_control.stats_info->sw_stat.mem_freed
2192 += skb->truesize;
2129 dev_kfree_skb(skb); 2193 dev_kfree_skb(skb);
2130 cnt++; 2194 cnt++;
2131 } 2195 }
@@ -2186,11 +2250,14 @@ static int fill_rxd_3buf(struct s2io_nic *nic, struct RxD_t *rxdp, struct \
2186 /* skb_shinfo(skb)->frag_list will have L4 data payload */ 2250 /* skb_shinfo(skb)->frag_list will have L4 data payload */
2187 skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE); 2251 skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE);
2188 if (skb_shinfo(skb)->frag_list == NULL) { 2252 if (skb_shinfo(skb)->frag_list == NULL) {
2253 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
2189 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name); 2254 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name);
2190 return -ENOMEM ; 2255 return -ENOMEM ;
2191 } 2256 }
2192 frag_list = skb_shinfo(skb)->frag_list; 2257 frag_list = skb_shinfo(skb)->frag_list;
2193 skb->truesize += frag_list->truesize; 2258 skb->truesize += frag_list->truesize;
2259 nic->mac_control.stats_info->sw_stat.mem_allocated
2260 += frag_list->truesize;
2194 frag_list->next = NULL; 2261 frag_list->next = NULL;
2195 tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1); 2262 tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1);
2196 frag_list->data = tmp; 2263 frag_list->data = tmp;
@@ -2319,8 +2386,12 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2319 wmb(); 2386 wmb();
2320 first_rxdp->Control_1 |= RXD_OWN_XENA; 2387 first_rxdp->Control_1 |= RXD_OWN_XENA;
2321 } 2388 }
2389 nic->mac_control.stats_info->sw_stat. \
2390 mem_alloc_fail_cnt++;
2322 return -ENOMEM ; 2391 return -ENOMEM ;
2323 } 2392 }
2393 nic->mac_control.stats_info->sw_stat.mem_allocated
2394 += skb->truesize;
2324 if (nic->rxd_mode == RXD_MODE_1) { 2395 if (nic->rxd_mode == RXD_MODE_1) {
2325 /* 1 buffer mode - normal operation mode */ 2396 /* 1 buffer mode - normal operation mode */
2326 memset(rxdp, 0, sizeof(struct RxD1)); 2397 memset(rxdp, 0, sizeof(struct RxD1));
@@ -2328,7 +2399,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2328 ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single 2399 ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single
2329 (nic->pdev, skb->data, size - NET_IP_ALIGN, 2400 (nic->pdev, skb->data, size - NET_IP_ALIGN,
2330 PCI_DMA_FROMDEVICE); 2401 PCI_DMA_FROMDEVICE);
2331 rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); 2402 rxdp->Control_2 =
2403 SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
2332 2404
2333 } else if (nic->rxd_mode >= RXD_MODE_3A) { 2405 } else if (nic->rxd_mode >= RXD_MODE_3A) {
2334 /* 2406 /*
@@ -2342,7 +2414,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2342 * payload 2414 * payload
2343 */ 2415 */
2344 2416
2345 /* save the buffer pointers to avoid frequent dma mapping */ 2417 /* save buffer pointers to avoid frequent dma mapping */
2346 Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; 2418 Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr;
2347 Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; 2419 Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr;
2348 memset(rxdp, 0, sizeof(struct RxD3)); 2420 memset(rxdp, 0, sizeof(struct RxD3));
@@ -2364,7 +2436,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2364 PCI_DMA_FROMDEVICE); 2436 PCI_DMA_FROMDEVICE);
2365 else 2437 else
2366 pci_dma_sync_single_for_device(nic->pdev, 2438 pci_dma_sync_single_for_device(nic->pdev,
2367 (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, 2439 (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr,
2368 BUF0_LEN, PCI_DMA_FROMDEVICE); 2440 BUF0_LEN, PCI_DMA_FROMDEVICE);
2369 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); 2441 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
2370 if (nic->rxd_mode == RXD_MODE_3B) { 2442 if (nic->rxd_mode == RXD_MODE_3B) {
@@ -2391,6 +2463,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2391 } else { 2463 } else {
2392 /* 3 buffer mode */ 2464 /* 3 buffer mode */
2393 if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) { 2465 if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) {
2466 nic->mac_control.stats_info->sw_stat.\
2467 mem_freed += skb->truesize;
2394 dev_kfree_skb_irq(skb); 2468 dev_kfree_skb_irq(skb);
2395 if (first_rxdp) { 2469 if (first_rxdp) {
2396 wmb(); 2470 wmb();
@@ -2491,6 +2565,7 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk)
2491 PCI_DMA_FROMDEVICE); 2565 PCI_DMA_FROMDEVICE);
2492 memset(rxdp, 0, sizeof(struct RxD3)); 2566 memset(rxdp, 0, sizeof(struct RxD3));
2493 } 2567 }
2568 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
2494 dev_kfree_skb(skb); 2569 dev_kfree_skb(skb);
2495 atomic_dec(&sp->rx_bufs_left[ring_no]); 2570 atomic_dec(&sp->rx_bufs_left[ring_no]);
2496 } 2571 }
@@ -2820,13 +2895,35 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
2820 nic->mac_control.stats_info->sw_stat. 2895 nic->mac_control.stats_info->sw_stat.
2821 parity_err_cnt++; 2896 parity_err_cnt++;
2822 } 2897 }
2823 if ((err >> 48) == 0xA) { 2898
2824 DBG_PRINT(TX_DBG, "TxD returned due \ 2899 /* update t_code statistics */
2825 to loss of link\n"); 2900 err >>= 48;
2826 } 2901 switch(err) {
2827 else { 2902 case 2:
2828 DBG_PRINT(ERR_DBG, "***TxD error %llx\n", err); 2903 nic->mac_control.stats_info->sw_stat.
2829 } 2904 tx_buf_abort_cnt++;
2905 break;
2906
2907 case 3:
2908 nic->mac_control.stats_info->sw_stat.
2909 tx_desc_abort_cnt++;
2910 break;
2911
2912 case 7:
2913 nic->mac_control.stats_info->sw_stat.
2914 tx_parity_err_cnt++;
2915 break;
2916
2917 case 10:
2918 nic->mac_control.stats_info->sw_stat.
2919 tx_link_loss_cnt++;
2920 break;
2921
2922 case 15:
2923 nic->mac_control.stats_info->sw_stat.
2924 tx_list_proc_err_cnt++;
2925 break;
2926 }
2830 } 2927 }
2831 2928
2832 skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); 2929 skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset);
@@ -2839,6 +2936,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
2839 2936
2840 /* Updating the statistics block */ 2937 /* Updating the statistics block */
2841 nic->stats.tx_bytes += skb->len; 2938 nic->stats.tx_bytes += skb->len;
2939 nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
2842 dev_kfree_skb_irq(skb); 2940 dev_kfree_skb_irq(skb);
2843 2941
2844 get_info.offset++; 2942 get_info.offset++;
@@ -3314,7 +3412,9 @@ static void s2io_reset(struct s2io_nic * sp)
3314 u16 subid, pci_cmd; 3412 u16 subid, pci_cmd;
3315 int i; 3413 int i;
3316 u16 val16; 3414 u16 val16;
3317 unsigned long long reset_cnt = 0; 3415 unsigned long long up_cnt, down_cnt, up_time, down_time, reset_cnt;
3416 unsigned long long mem_alloc_cnt, mem_free_cnt, watchdog_cnt;
3417
3318 DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n", 3418 DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n",
3319 __FUNCTION__, sp->dev->name); 3419 __FUNCTION__, sp->dev->name);
3320 3420
@@ -3380,11 +3480,26 @@ new_way:
3380 3480
3381 /* Reset device statistics maintained by OS */ 3481 /* Reset device statistics maintained by OS */
3382 memset(&sp->stats, 0, sizeof (struct net_device_stats)); 3482 memset(&sp->stats, 0, sizeof (struct net_device_stats));
3383 /* save reset count */ 3483
3484 up_cnt = sp->mac_control.stats_info->sw_stat.link_up_cnt;
3485 down_cnt = sp->mac_control.stats_info->sw_stat.link_down_cnt;
3486 up_time = sp->mac_control.stats_info->sw_stat.link_up_time;
3487 down_time = sp->mac_control.stats_info->sw_stat.link_down_time;
3384 reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt; 3488 reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt;
3489 mem_alloc_cnt = sp->mac_control.stats_info->sw_stat.mem_allocated;
3490 mem_free_cnt = sp->mac_control.stats_info->sw_stat.mem_freed;
3491 watchdog_cnt = sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt;
3492 /* save link up/down time/cnt, reset/memory/watchdog cnt */
3385 memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block)); 3493 memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block));
3386 /* restore reset count */ 3494 /* restore link up/down time/cnt, reset/memory/watchdog cnt */
3495 sp->mac_control.stats_info->sw_stat.link_up_cnt = up_cnt;
3496 sp->mac_control.stats_info->sw_stat.link_down_cnt = down_cnt;
3497 sp->mac_control.stats_info->sw_stat.link_up_time = up_time;
3498 sp->mac_control.stats_info->sw_stat.link_down_time = down_time;
3387 sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt; 3499 sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt;
3500 sp->mac_control.stats_info->sw_stat.mem_allocated = mem_alloc_cnt;
3501 sp->mac_control.stats_info->sw_stat.mem_freed = mem_free_cnt;
3502 sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt = watchdog_cnt;
3388 3503
3389 /* SXE-002: Configure link and activity LED to turn it off */ 3504 /* SXE-002: Configure link and activity LED to turn it off */
3390 subid = sp->pdev->subsystem_device; 3505 subid = sp->pdev->subsystem_device;
@@ -3672,19 +3787,29 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3672 nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), 3787 nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
3673 GFP_KERNEL); 3788 GFP_KERNEL);
3674 if (nic->entries == NULL) { 3789 if (nic->entries == NULL) {
3675 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); 3790 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \
3791 __FUNCTION__);
3792 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
3676 return -ENOMEM; 3793 return -ENOMEM;
3677 } 3794 }
3678 memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3795 nic->mac_control.stats_info->sw_stat.mem_allocated
3796 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3797 memset(nic->entries, 0,MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3679 3798
3680 nic->s2io_entries = 3799 nic->s2io_entries =
3681 kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), 3800 kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
3682 GFP_KERNEL); 3801 GFP_KERNEL);
3683 if (nic->s2io_entries == NULL) { 3802 if (nic->s2io_entries == NULL) {
3684 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); 3803 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n",
3804 __FUNCTION__);
3805 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
3685 kfree(nic->entries); 3806 kfree(nic->entries);
3807 nic->mac_control.stats_info->sw_stat.mem_freed
3808 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3686 return -ENOMEM; 3809 return -ENOMEM;
3687 } 3810 }
3811 nic->mac_control.stats_info->sw_stat.mem_allocated
3812 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3688 memset(nic->s2io_entries, 0, 3813 memset(nic->s2io_entries, 0,
3689 MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 3814 MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3690 3815
@@ -3708,7 +3833,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3708 rx_mat = readq(&bar0->rx_mat); 3833 rx_mat = readq(&bar0->rx_mat);
3709 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { 3834 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3710 rx_mat |= RX_MAT_SET(j, msix_indx); 3835 rx_mat |= RX_MAT_SET(j, msix_indx);
3711 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; 3836 nic->s2io_entries[msix_indx].arg
3837 = &nic->mac_control.rings[j];
3712 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; 3838 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3713 nic->s2io_entries[msix_indx].in_use = MSIX_FLG; 3839 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3714 } 3840 }
@@ -3717,7 +3843,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3717 tx_mat = readq(&bar0->tx_mat0_n[7]); 3843 tx_mat = readq(&bar0->tx_mat0_n[7]);
3718 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { 3844 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3719 tx_mat |= TX_MAT_SET(i, msix_indx); 3845 tx_mat |= TX_MAT_SET(i, msix_indx);
3720 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; 3846 nic->s2io_entries[msix_indx].arg
3847 = &nic->mac_control.rings[j];
3721 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; 3848 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3722 nic->s2io_entries[msix_indx].in_use = MSIX_FLG; 3849 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3723 } 3850 }
@@ -3734,7 +3861,11 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3734 if (ret) { 3861 if (ret) {
3735 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); 3862 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name);
3736 kfree(nic->entries); 3863 kfree(nic->entries);
3864 nic->mac_control.stats_info->sw_stat.mem_freed
3865 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3737 kfree(nic->s2io_entries); 3866 kfree(nic->s2io_entries);
3867 nic->mac_control.stats_info->sw_stat.mem_freed
3868 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3738 nic->entries = NULL; 3869 nic->entries = NULL;
3739 nic->s2io_entries = NULL; 3870 nic->s2io_entries = NULL;
3740 nic->avail_msix_vectors = 0; 3871 nic->avail_msix_vectors = 0;
@@ -3802,10 +3933,16 @@ static int s2io_open(struct net_device *dev)
3802 3933
3803hw_init_failed: 3934hw_init_failed:
3804 if (sp->intr_type == MSI_X) { 3935 if (sp->intr_type == MSI_X) {
3805 if (sp->entries) 3936 if (sp->entries) {
3806 kfree(sp->entries); 3937 kfree(sp->entries);
3807 if (sp->s2io_entries) 3938 sp->mac_control.stats_info->sw_stat.mem_freed
3939 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3940 }
3941 if (sp->s2io_entries) {
3808 kfree(sp->s2io_entries); 3942 kfree(sp->s2io_entries);
3943 sp->mac_control.stats_info->sw_stat.mem_freed
3944 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3945 }
3809 } 3946 }
3810 return err; 3947 return err;
3811} 3948}
@@ -3866,6 +4003,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3866 config = &sp->config; 4003 config = &sp->config;
3867 4004
3868 DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); 4005 DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name);
4006
4007 if (unlikely(skb->len <= 0)) {
4008 DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name);
4009 dev_kfree_skb_any(skb);
4010 return 0;
4011}
4012
3869 spin_lock_irqsave(&sp->tx_lock, flags); 4013 spin_lock_irqsave(&sp->tx_lock, flags);
3870 if (atomic_read(&sp->card_state) == CARD_DOWN) { 4014 if (atomic_read(&sp->card_state) == CARD_DOWN) {
3871 DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", 4015 DBG_PRINT(TX_DBG, "%s: Card going down for reset\n",
@@ -3876,7 +4020,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3876 } 4020 }
3877 4021
3878 queue = 0; 4022 queue = 0;
3879
3880 /* Get Fifo number to Transmit based on vlan priority */ 4023 /* Get Fifo number to Transmit based on vlan priority */
3881 if (sp->vlgrp && vlan_tx_tag_present(skb)) { 4024 if (sp->vlgrp && vlan_tx_tag_present(skb)) {
3882 vlan_tag = vlan_tx_tag_get(skb); 4025 vlan_tag = vlan_tx_tag_get(skb);
@@ -3900,14 +4043,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3900 return 0; 4043 return 0;
3901 } 4044 }
3902 4045
3903 /* A buffer with no data will be dropped */
3904 if (!skb->len) {
3905 DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name);
3906 dev_kfree_skb(skb);
3907 spin_unlock_irqrestore(&sp->tx_lock, flags);
3908 return 0;
3909 }
3910
3911 offload_type = s2io_offload_type(skb); 4046 offload_type = s2io_offload_type(skb);
3912 if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { 4047 if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) {
3913 txdp->Control_1 |= TXD_TCP_LSO_EN; 4048 txdp->Control_1 |= TXD_TCP_LSO_EN;
@@ -4003,7 +4138,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4003 put_off, get_off); 4138 put_off, get_off);
4004 netif_stop_queue(dev); 4139 netif_stop_queue(dev);
4005 } 4140 }
4006 4141 mac_control->stats_info->sw_stat.mem_allocated += skb->truesize;
4007 dev->trans_start = jiffies; 4142 dev->trans_start = jiffies;
4008 spin_unlock_irqrestore(&sp->tx_lock, flags); 4143 spin_unlock_irqrestore(&sp->tx_lock, flags);
4009 4144
@@ -4775,6 +4910,40 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data)
4775 return 0; 4910 return 0;
4776} 4911}
4777 4912
4913static void s2io_ethtool_gringparam(struct net_device *dev,
4914 struct ethtool_ringparam *ering)
4915{
4916 struct s2io_nic *sp = dev->priv;
4917 int i,tx_desc_count=0,rx_desc_count=0;
4918
4919 if (sp->rxd_mode == RXD_MODE_1)
4920 ering->rx_max_pending = MAX_RX_DESC_1;
4921 else if (sp->rxd_mode == RXD_MODE_3B)
4922 ering->rx_max_pending = MAX_RX_DESC_2;
4923 else if (sp->rxd_mode == RXD_MODE_3A)
4924 ering->rx_max_pending = MAX_RX_DESC_3;
4925
4926 ering->tx_max_pending = MAX_TX_DESC;
4927 for (i = 0 ; i < sp->config.tx_fifo_num ; i++) {
4928 tx_desc_count += sp->config.tx_cfg[i].fifo_len;
4929 }
4930 DBG_PRINT(INFO_DBG,"\nmax txds : %d\n",sp->config.max_txds);
4931 ering->tx_pending = tx_desc_count;
4932 rx_desc_count = 0;
4933 for (i = 0 ; i < sp->config.rx_ring_num ; i++) {
4934 rx_desc_count += sp->config.rx_cfg[i].num_rxd;
4935 }
4936 ering->rx_pending = rx_desc_count;
4937
4938 ering->rx_mini_max_pending = 0;
4939 ering->rx_mini_pending = 0;
4940 if(sp->rxd_mode == RXD_MODE_1)
4941 ering->rx_jumbo_max_pending = MAX_RX_DESC_1;
4942 else if (sp->rxd_mode == RXD_MODE_3B)
4943 ering->rx_jumbo_max_pending = MAX_RX_DESC_2;
4944 ering->rx_jumbo_pending = rx_desc_count;
4945}
4946
4778/** 4947/**
4779 * s2io_ethtool_getpause_data -Pause frame frame generation and reception. 4948 * s2io_ethtool_getpause_data -Pause frame frame generation and reception.
4780 * @sp : private member of the device structure, which is a pointer to the 4949 * @sp : private member of the device structure, which is a pointer to the
@@ -4981,8 +5150,11 @@ static void s2io_vpd_read(struct s2io_nic *nic)
4981 strcpy(nic->serial_num, "NOT AVAILABLE"); 5150 strcpy(nic->serial_num, "NOT AVAILABLE");
4982 5151
4983 vpd_data = kmalloc(256, GFP_KERNEL); 5152 vpd_data = kmalloc(256, GFP_KERNEL);
4984 if (!vpd_data) 5153 if (!vpd_data) {
5154 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
4985 return; 5155 return;
5156 }
5157 nic->mac_control.stats_info->sw_stat.mem_allocated += 256;
4986 5158
4987 for (i = 0; i < 256; i +=4 ) { 5159 for (i = 0; i < 256; i +=4 ) {
4988 pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); 5160 pci_write_config_byte(nic->pdev, (vpd_addr + 2), i);
@@ -5022,6 +5194,7 @@ static void s2io_vpd_read(struct s2io_nic *nic)
5022 memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); 5194 memcpy(nic->product_name, &vpd_data[3], vpd_data[1]);
5023 } 5195 }
5024 kfree(vpd_data); 5196 kfree(vpd_data);
5197 nic->mac_control.stats_info->sw_stat.mem_freed += 256;
5025} 5198}
5026 5199
5027/** 5200/**
@@ -5742,6 +5915,30 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
5742 } 5915 }
5743 else 5916 else
5744 tmp_stats[i++] = 0; 5917 tmp_stats[i++] = 0;
5918 tmp_stats[i++] = stat_info->sw_stat.mem_alloc_fail_cnt;
5919 tmp_stats[i++] = stat_info->sw_stat.watchdog_timer_cnt;
5920 tmp_stats[i++] = stat_info->sw_stat.mem_allocated;
5921 tmp_stats[i++] = stat_info->sw_stat.mem_freed;
5922 tmp_stats[i++] = stat_info->sw_stat.link_up_cnt;
5923 tmp_stats[i++] = stat_info->sw_stat.link_down_cnt;
5924 tmp_stats[i++] = stat_info->sw_stat.link_up_time;
5925 tmp_stats[i++] = stat_info->sw_stat.link_down_time;
5926
5927 tmp_stats[i++] = stat_info->sw_stat.tx_buf_abort_cnt;
5928 tmp_stats[i++] = stat_info->sw_stat.tx_desc_abort_cnt;
5929 tmp_stats[i++] = stat_info->sw_stat.tx_parity_err_cnt;
5930 tmp_stats[i++] = stat_info->sw_stat.tx_link_loss_cnt;
5931 tmp_stats[i++] = stat_info->sw_stat.tx_list_proc_err_cnt;
5932
5933 tmp_stats[i++] = stat_info->sw_stat.rx_parity_err_cnt;
5934 tmp_stats[i++] = stat_info->sw_stat.rx_abort_cnt;
5935 tmp_stats[i++] = stat_info->sw_stat.rx_parity_abort_cnt;
5936 tmp_stats[i++] = stat_info->sw_stat.rx_rda_fail_cnt;
5937 tmp_stats[i++] = stat_info->sw_stat.rx_unkn_prot_cnt;
5938 tmp_stats[i++] = stat_info->sw_stat.rx_fcs_err_cnt;
5939 tmp_stats[i++] = stat_info->sw_stat.rx_buf_size_err_cnt;
5940 tmp_stats[i++] = stat_info->sw_stat.rx_rxd_corrupt_cnt;
5941 tmp_stats[i++] = stat_info->sw_stat.rx_unkn_err_cnt;
5745} 5942}
5746 5943
5747static int s2io_ethtool_get_regs_len(struct net_device *dev) 5944static int s2io_ethtool_get_regs_len(struct net_device *dev)
@@ -5854,6 +6051,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
5854 .get_eeprom_len = s2io_get_eeprom_len, 6051 .get_eeprom_len = s2io_get_eeprom_len,
5855 .get_eeprom = s2io_ethtool_geeprom, 6052 .get_eeprom = s2io_ethtool_geeprom,
5856 .set_eeprom = s2io_ethtool_seeprom, 6053 .set_eeprom = s2io_ethtool_seeprom,
6054 .get_ringparam = s2io_ethtool_gringparam,
5857 .get_pauseparam = s2io_ethtool_getpause_data, 6055 .get_pauseparam = s2io_ethtool_getpause_data,
5858 .set_pauseparam = s2io_ethtool_setpause_data, 6056 .set_pauseparam = s2io_ethtool_setpause_data,
5859 .get_rx_csum = s2io_ethtool_get_rx_csum, 6057 .get_rx_csum = s2io_ethtool_get_rx_csum,
@@ -5962,7 +6160,7 @@ static void s2io_tasklet(unsigned long dev_addr)
5962 if (ret == -ENOMEM) { 6160 if (ret == -ENOMEM) {
5963 DBG_PRINT(INFO_DBG, "%s: Out of ", 6161 DBG_PRINT(INFO_DBG, "%s: Out of ",
5964 dev->name); 6162 dev->name);
5965 DBG_PRINT(ERR_DBG, "memory in tasklet\n"); 6163 DBG_PRINT(INFO_DBG, "memory in tasklet\n");
5966 break; 6164 break;
5967 } else if (ret == -EFILL) { 6165 } else if (ret == -EFILL) {
5968 DBG_PRINT(INFO_DBG, 6166 DBG_PRINT(INFO_DBG,
@@ -6077,9 +6275,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6077 *skb = dev_alloc_skb(size); 6275 *skb = dev_alloc_skb(size);
6078 if (!(*skb)) { 6276 if (!(*skb)) {
6079 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); 6277 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name);
6080 DBG_PRINT(INFO_DBG, "memory to allocate SKBs\n"); 6278 DBG_PRINT(INFO_DBG, "memory to allocate ");
6279 DBG_PRINT(INFO_DBG, "1 buf mode SKBs\n");
6280 sp->mac_control.stats_info->sw_stat. \
6281 mem_alloc_fail_cnt++;
6081 return -ENOMEM ; 6282 return -ENOMEM ;
6082 } 6283 }
6284 sp->mac_control.stats_info->sw_stat.mem_allocated
6285 += (*skb)->truesize;
6083 /* storing the mapped addr in a temp variable 6286 /* storing the mapped addr in a temp variable
6084 * such it will be used for next rxd whose 6287 * such it will be used for next rxd whose
6085 * Host Control is NULL 6288 * Host Control is NULL
@@ -6099,10 +6302,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6099 } else { 6302 } else {
6100 *skb = dev_alloc_skb(size); 6303 *skb = dev_alloc_skb(size);
6101 if (!(*skb)) { 6304 if (!(*skb)) {
6102 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", 6305 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name);
6103 dev->name); 6306 DBG_PRINT(INFO_DBG, "memory to allocate ");
6307 DBG_PRINT(INFO_DBG, "2 buf mode SKBs\n");
6308 sp->mac_control.stats_info->sw_stat. \
6309 mem_alloc_fail_cnt++;
6104 return -ENOMEM; 6310 return -ENOMEM;
6105 } 6311 }
6312 sp->mac_control.stats_info->sw_stat.mem_allocated
6313 += (*skb)->truesize;
6106 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = 6314 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 =
6107 pci_map_single(sp->pdev, (*skb)->data, 6315 pci_map_single(sp->pdev, (*skb)->data,
6108 dev->mtu + 4, 6316 dev->mtu + 4,
@@ -6126,10 +6334,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6126 } else { 6334 } else {
6127 *skb = dev_alloc_skb(size); 6335 *skb = dev_alloc_skb(size);
6128 if (!(*skb)) { 6336 if (!(*skb)) {
6129 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", 6337 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name);
6130 dev->name); 6338 DBG_PRINT(INFO_DBG, "memory to allocate ");
6339 DBG_PRINT(INFO_DBG, "3 buf mode SKBs\n");
6340 sp->mac_control.stats_info->sw_stat. \
6341 mem_alloc_fail_cnt++;
6131 return -ENOMEM; 6342 return -ENOMEM;
6132 } 6343 }
6344 sp->mac_control.stats_info->sw_stat.mem_allocated
6345 += (*skb)->truesize;
6133 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = 6346 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 =
6134 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, 6347 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6135 PCI_DMA_FROMDEVICE); 6348 PCI_DMA_FROMDEVICE);
@@ -6147,10 +6360,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6147 if (skb_shinfo(*skb)->frag_list == NULL) { 6360 if (skb_shinfo(*skb)->frag_list == NULL) {
6148 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \ 6361 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \
6149 failed\n ", dev->name); 6362 failed\n ", dev->name);
6363 sp->mac_control.stats_info->sw_stat. \
6364 mem_alloc_fail_cnt++;
6150 return -ENOMEM ; 6365 return -ENOMEM ;
6151 } 6366 }
6152 frag_list = skb_shinfo(*skb)->frag_list; 6367 frag_list = skb_shinfo(*skb)->frag_list;
6153 frag_list->next = NULL; 6368 frag_list->next = NULL;
6369 sp->mac_control.stats_info->sw_stat.mem_allocated
6370 += frag_list->truesize;
6154 /* 6371 /*
6155 * Buffer-2 receives L4 data payload 6372 * Buffer-2 receives L4 data payload
6156 */ 6373 */
@@ -6566,6 +6783,7 @@ static void s2io_tx_watchdog(struct net_device *dev)
6566 struct s2io_nic *sp = dev->priv; 6783 struct s2io_nic *sp = dev->priv;
6567 6784
6568 if (netif_carrier_ok(dev)) { 6785 if (netif_carrier_ok(dev)) {
6786 sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt++;
6569 schedule_work(&sp->rst_timer_task); 6787 schedule_work(&sp->rst_timer_task);
6570 sp->mac_control.stats_info->sw_stat.soft_reset_cnt++; 6788 sp->mac_control.stats_info->sw_stat.soft_reset_cnt++;
6571 } 6789 }
@@ -6606,7 +6824,53 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6606 if (err & 0x1) { 6824 if (err & 0x1) {
6607 sp->mac_control.stats_info->sw_stat.parity_err_cnt++; 6825 sp->mac_control.stats_info->sw_stat.parity_err_cnt++;
6608 } 6826 }
6827 err >>= 48;
6828 switch(err) {
6829 case 1:
6830 sp->mac_control.stats_info->sw_stat.
6831 rx_parity_err_cnt++;
6832 break;
6609 6833
6834 case 2:
6835 sp->mac_control.stats_info->sw_stat.
6836 rx_abort_cnt++;
6837 break;
6838
6839 case 3:
6840 sp->mac_control.stats_info->sw_stat.
6841 rx_parity_abort_cnt++;
6842 break;
6843
6844 case 4:
6845 sp->mac_control.stats_info->sw_stat.
6846 rx_rda_fail_cnt++;
6847 break;
6848
6849 case 5:
6850 sp->mac_control.stats_info->sw_stat.
6851 rx_unkn_prot_cnt++;
6852 break;
6853
6854 case 6:
6855 sp->mac_control.stats_info->sw_stat.
6856 rx_fcs_err_cnt++;
6857 break;
6858
6859 case 7:
6860 sp->mac_control.stats_info->sw_stat.
6861 rx_buf_size_err_cnt++;
6862 break;
6863
6864 case 8:
6865 sp->mac_control.stats_info->sw_stat.
6866 rx_rxd_corrupt_cnt++;
6867 break;
6868
6869 case 15:
6870 sp->mac_control.stats_info->sw_stat.
6871 rx_unkn_err_cnt++;
6872 break;
6873 }
6610 /* 6874 /*
6611 * Drop the packet if bad transfer code. Exception being 6875 * Drop the packet if bad transfer code. Exception being
6612 * 0x5, which could be due to unsupported IPv6 extension header. 6876 * 0x5, which could be due to unsupported IPv6 extension header.
@@ -6614,10 +6878,12 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6614 * Note that in this case, since checksum will be incorrect, 6878 * Note that in this case, since checksum will be incorrect,
6615 * stack will validate the same. 6879 * stack will validate the same.
6616 */ 6880 */
6617 if (err && ((err >> 48) != 0x5)) { 6881 if (err != 0x5) {
6618 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", 6882 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n",
6619 dev->name, err); 6883 dev->name, err);
6620 sp->stats.rx_crc_errors++; 6884 sp->stats.rx_crc_errors++;
6885 sp->mac_control.stats_info->sw_stat.mem_freed
6886 += skb->truesize;
6621 dev_kfree_skb(skb); 6887 dev_kfree_skb(skb);
6622 atomic_dec(&sp->rx_bufs_left[ring_no]); 6888 atomic_dec(&sp->rx_bufs_left[ring_no]);
6623 rxdp->Host_Control = 0; 6889 rxdp->Host_Control = 0;
@@ -6627,7 +6893,6 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6627 6893
6628 /* Updating statistics */ 6894 /* Updating statistics */
6629 rxdp->Host_Control = 0; 6895 rxdp->Host_Control = 0;
6630 sp->stats.rx_packets++;
6631 if (sp->rxd_mode == RXD_MODE_1) { 6896 if (sp->rxd_mode == RXD_MODE_1) {
6632 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); 6897 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2);
6633 6898
@@ -6731,7 +6996,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6731 } else { 6996 } else {
6732 skb->ip_summed = CHECKSUM_NONE; 6997 skb->ip_summed = CHECKSUM_NONE;
6733 } 6998 }
6734 6999 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
6735 if (!sp->lro) { 7000 if (!sp->lro) {
6736 skb->protocol = eth_type_trans(skb, dev); 7001 skb->protocol = eth_type_trans(skb, dev);
6737 if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) && 7002 if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) &&
@@ -6780,12 +7045,21 @@ static void s2io_link(struct s2io_nic * sp, int link)
6780 if (link == LINK_DOWN) { 7045 if (link == LINK_DOWN) {
6781 DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); 7046 DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name);
6782 netif_carrier_off(dev); 7047 netif_carrier_off(dev);
7048 if(sp->mac_control.stats_info->sw_stat.link_up_cnt)
7049 sp->mac_control.stats_info->sw_stat.link_up_time =
7050 jiffies - sp->start_time;
7051 sp->mac_control.stats_info->sw_stat.link_down_cnt++;
6783 } else { 7052 } else {
6784 DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); 7053 DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name);
7054 if (sp->mac_control.stats_info->sw_stat.link_down_cnt)
7055 sp->mac_control.stats_info->sw_stat.link_down_time =
7056 jiffies - sp->start_time;
7057 sp->mac_control.stats_info->sw_stat.link_up_cnt++;
6785 netif_carrier_on(dev); 7058 netif_carrier_on(dev);
6786 } 7059 }
6787 } 7060 }
6788 sp->last_link_state = link; 7061 sp->last_link_state = link;
7062 sp->start_time = jiffies;
6789} 7063}
6790 7064
6791/** 7065/**
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index a656d18b33df..54baa0b8ec7c 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -95,6 +95,32 @@ struct swStat {
95 unsigned long long flush_max_pkts; 95 unsigned long long flush_max_pkts;
96 unsigned long long sum_avg_pkts_aggregated; 96 unsigned long long sum_avg_pkts_aggregated;
97 unsigned long long num_aggregations; 97 unsigned long long num_aggregations;
98 /* Other statistics */
99 unsigned long long mem_alloc_fail_cnt;
100 unsigned long long watchdog_timer_cnt;
101 unsigned long long mem_allocated;
102 unsigned long long mem_freed;
103 unsigned long long link_up_cnt;
104 unsigned long long link_down_cnt;
105 unsigned long long link_up_time;
106 unsigned long long link_down_time;
107
108 /* Transfer Code statistics */
109 unsigned long long tx_buf_abort_cnt;
110 unsigned long long tx_desc_abort_cnt;
111 unsigned long long tx_parity_err_cnt;
112 unsigned long long tx_link_loss_cnt;
113 unsigned long long tx_list_proc_err_cnt;
114
115 unsigned long long rx_parity_err_cnt;
116 unsigned long long rx_abort_cnt;
117 unsigned long long rx_parity_abort_cnt;
118 unsigned long long rx_rda_fail_cnt;
119 unsigned long long rx_unkn_prot_cnt;
120 unsigned long long rx_fcs_err_cnt;
121 unsigned long long rx_buf_size_err_cnt;
122 unsigned long long rx_rxd_corrupt_cnt;
123 unsigned long long rx_unkn_err_cnt;
98}; 124};
99 125
100/* Xpak releated alarm and warnings */ 126/* Xpak releated alarm and warnings */
@@ -308,6 +334,11 @@ struct stat_block {
308#define MAX_TX_FIFOS 8 334#define MAX_TX_FIFOS 8
309#define MAX_RX_RINGS 8 335#define MAX_RX_RINGS 8
310 336
337#define MAX_RX_DESC_1 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 127 )
338#define MAX_RX_DESC_2 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 )
339#define MAX_RX_DESC_3 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 )
340#define MAX_TX_DESC (MAX_AVAILABLE_TXDS)
341
311/* FIFO mappings for all possible number of fifos configured */ 342/* FIFO mappings for all possible number of fifos configured */
312static int fifo_map[][MAX_TX_FIFOS] = { 343static int fifo_map[][MAX_TX_FIFOS] = {
313 {0, 0, 0, 0, 0, 0, 0, 0}, 344 {0, 0, 0, 0, 0, 0, 0, 0},
@@ -819,6 +850,7 @@ struct s2io_nic {
819#define LINK_UP 2 850#define LINK_UP 2
820 851
821 int task_flag; 852 int task_flag;
853 unsigned long long start_time;
822#define CARD_DOWN 1 854#define CARD_DOWN 1
823#define CARD_UP 2 855#define CARD_UP 2
824 atomic_t card_state; 856 atomic_t card_state;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index e0489578945d..776692946562 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -3802,6 +3802,9 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
3802 struct skge_hw *hw = pci_get_drvdata(pdev); 3802 struct skge_hw *hw = pci_get_drvdata(pdev);
3803 int i, err, wol = 0; 3803 int i, err, wol = 0;
3804 3804
3805 if (!hw)
3806 return 0;
3807
3805 err = pci_save_state(pdev); 3808 err = pci_save_state(pdev);
3806 if (err) 3809 if (err)
3807 return err; 3810 return err;
@@ -3830,6 +3833,9 @@ static int skge_resume(struct pci_dev *pdev)
3830 struct skge_hw *hw = pci_get_drvdata(pdev); 3833 struct skge_hw *hw = pci_get_drvdata(pdev);
3831 int i, err; 3834 int i, err;
3832 3835
3836 if (!hw)
3837 return 0;
3838
3833 err = pci_set_power_state(pdev, PCI_D0); 3839 err = pci_set_power_state(pdev, PCI_D0);
3834 if (err) 3840 if (err)
3835 goto out; 3841 goto out;
@@ -3868,6 +3874,9 @@ static void skge_shutdown(struct pci_dev *pdev)
3868 struct skge_hw *hw = pci_get_drvdata(pdev); 3874 struct skge_hw *hw = pci_get_drvdata(pdev);
3869 int i, wol = 0; 3875 int i, wol = 0;
3870 3876
3877 if (!hw)
3878 return;
3879
3871 for (i = 0; i < hw->ports; i++) { 3880 for (i = 0; i < hw->ports; i++) {
3872 struct net_device *dev = hw->dev[i]; 3881 struct net_device *dev = hw->dev[i];
3873 struct skge_port *skge = netdev_priv(dev); 3882 struct skge_port *skge = netdev_priv(dev);
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index a307310f13f5..104e20456e6f 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -40,6 +40,7 @@
40#include <linux/if_vlan.h> 40#include <linux/if_vlan.h>
41#include <linux/prefetch.h> 41#include <linux/prefetch.h>
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include <linux/dmi.h>
43 44
44#include <asm/irq.h> 45#include <asm/irq.h>
45 46
@@ -130,7 +131,7 @@ static const struct pci_device_id sky2_id_table[] = {
130 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ 131 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
131 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ 132 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */
132 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ 133 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */
133 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ 134// { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */
134 { 0 } 135 { 0 }
135}; 136};
136 137
@@ -150,6 +151,8 @@ static const char *yukon2_name[] = {
150 "FE", /* 0xb7 */ 151 "FE", /* 0xb7 */
151}; 152};
152 153
154static int dmi_blacklisted;
155
153/* Access to external PHY */ 156/* Access to external PHY */
154static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) 157static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
155{ 158{
@@ -2531,6 +2534,17 @@ static int __devinit sky2_init(struct sky2_hw *hw)
2531 return -EOPNOTSUPP; 2534 return -EOPNOTSUPP;
2532 } 2535 }
2533 2536
2537
2538 /* Some Gigabyte motherboards have 88e8056 but cause problems
2539 * There is some unresolved hardware related problem that causes
2540 * descriptor errors and receive data corruption.
2541 */
2542 if (hw->chip_id == CHIP_ID_YUKON_EC_U && dmi_blacklisted) {
2543 dev_err(&hw->pdev->dev,
2544 "88E8056 on this motherboard not supported\n");
2545 return -EOPNOTSUPP;
2546 }
2547
2534 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); 2548 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
2535 hw->ports = 1; 2549 hw->ports = 1;
2536 t8 = sky2_read8(hw, B2_Y2_HW_RES); 2550 t8 = sky2_read8(hw, B2_Y2_HW_RES);
@@ -3578,17 +3592,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3578 goto err_out; 3592 goto err_out;
3579 } 3593 }
3580 3594
3581 /* Some Gigabyte motherboards have 88e8056 but cause problems
3582 * There is some unresolved hardware related problem that causes
3583 * descriptor errors and receive data corruption.
3584 */
3585 if (pdev->vendor == PCI_VENDOR_ID_MARVELL &&
3586 pdev->device == 0x4364 && pdev->subsystem_vendor == 0x1458) {
3587 dev_err(&pdev->dev,
3588 "88E8056 on Gigabyte motherboards not supported\n");
3589 goto err_out_disable;
3590 }
3591
3592 err = pci_request_regions(pdev, DRV_NAME); 3595 err = pci_request_regions(pdev, DRV_NAME);
3593 if (err) { 3596 if (err) {
3594 dev_err(&pdev->dev, "cannot obtain PCI resources\n"); 3597 dev_err(&pdev->dev, "cannot obtain PCI resources\n");
@@ -3732,6 +3735,7 @@ err_out_free_regions:
3732err_out_disable: 3735err_out_disable:
3733 pci_disable_device(pdev); 3736 pci_disable_device(pdev);
3734err_out: 3737err_out:
3738 pci_set_drvdata(pdev, NULL);
3735 return err; 3739 return err;
3736} 3740}
3737 3741
@@ -3784,6 +3788,9 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
3784 struct sky2_hw *hw = pci_get_drvdata(pdev); 3788 struct sky2_hw *hw = pci_get_drvdata(pdev);
3785 int i, wol = 0; 3789 int i, wol = 0;
3786 3790
3791 if (!hw)
3792 return 0;
3793
3787 del_timer_sync(&hw->idle_timer); 3794 del_timer_sync(&hw->idle_timer);
3788 netif_poll_disable(hw->dev[0]); 3795 netif_poll_disable(hw->dev[0]);
3789 3796
@@ -3815,6 +3822,9 @@ static int sky2_resume(struct pci_dev *pdev)
3815 struct sky2_hw *hw = pci_get_drvdata(pdev); 3822 struct sky2_hw *hw = pci_get_drvdata(pdev);
3816 int i, err; 3823 int i, err;
3817 3824
3825 if (!hw)
3826 return 0;
3827
3818 err = pci_set_power_state(pdev, PCI_D0); 3828 err = pci_set_power_state(pdev, PCI_D0);
3819 if (err) 3829 if (err)
3820 goto out; 3830 goto out;
@@ -3861,6 +3871,9 @@ static void sky2_shutdown(struct pci_dev *pdev)
3861 struct sky2_hw *hw = pci_get_drvdata(pdev); 3871 struct sky2_hw *hw = pci_get_drvdata(pdev);
3862 int i, wol = 0; 3872 int i, wol = 0;
3863 3873
3874 if (!hw)
3875 return;
3876
3864 del_timer_sync(&hw->idle_timer); 3877 del_timer_sync(&hw->idle_timer);
3865 netif_poll_disable(hw->dev[0]); 3878 netif_poll_disable(hw->dev[0]);
3866 3879
@@ -3897,8 +3910,24 @@ static struct pci_driver sky2_driver = {
3897 .shutdown = sky2_shutdown, 3910 .shutdown = sky2_shutdown,
3898}; 3911};
3899 3912
3913static struct dmi_system_id __initdata broken_dmi_table[] = {
3914 {
3915 .ident = "Gigabyte 965P-S3",
3916 .matches = {
3917 DMI_MATCH(DMI_SYS_VENDOR, "Gigabyte Technology Co., Ltd."),
3918 DMI_MATCH(DMI_PRODUCT_NAME, "965P-S3"),
3919
3920 },
3921 },
3922 { }
3923};
3924
3900static int __init sky2_init_module(void) 3925static int __init sky2_init_module(void)
3901{ 3926{
3927 /* Look for sick motherboards */
3928 if (dmi_check_system(broken_dmi_table))
3929 dmi_blacklisted = 1;
3930
3902 return pci_register_driver(&sky2_driver); 3931 return pci_register_driver(&sky2_driver);
3903} 3932}
3904 3933
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index c15e97253ede..108adbf5b5eb 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -175,12 +175,10 @@ spider_net_setup_aneg(struct spider_net_card *card)
175{ 175{
176 struct mii_phy *phy = &card->phy; 176 struct mii_phy *phy = &card->phy;
177 u32 advertise = 0; 177 u32 advertise = 0;
178 u16 bmcr, bmsr, stat1000, estat; 178 u16 bmsr, estat;
179 179
180 bmcr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMCR); 180 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR);
181 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); 181 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS);
182 stat1000 = spider_net_read_phy(card->netdev, phy->mii_id, MII_STAT1000);
183 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS);
184 182
185 if (bmsr & BMSR_10HALF) 183 if (bmsr & BMSR_10HALF)
186 advertise |= ADVERTISED_10baseT_Half; 184 advertise |= ADVERTISED_10baseT_Half;
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 8897f538a7c7..4fc8681bc110 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -2,10 +2,7 @@
2# wan devices configuration 2# wan devices configuration
3# 3#
4 4
5menu "Wan interfaces" 5menuconfig WAN
6 depends on NETDEVICES
7
8config WAN
9 bool "Wan interfaces support" 6 bool "Wan interfaces support"
10 ---help--- 7 ---help---
11 Wide Area Networks (WANs), such as X.25, Frame Relay and leased 8 Wide Area Networks (WANs), such as X.25, Frame Relay and leased
@@ -23,10 +20,12 @@ config WAN
23 20
24 If unsure, say N. 21 If unsure, say N.
25 22
23if WAN
24
26# There is no way to detect a comtrol sv11 - force it modular for now. 25# There is no way to detect a comtrol sv11 - force it modular for now.
27config HOSTESS_SV11 26config HOSTESS_SV11
28 tristate "Comtrol Hostess SV-11 support" 27 tristate "Comtrol Hostess SV-11 support"
29 depends on WAN && ISA && m && ISA_DMA_API && INET 28 depends on ISA && m && ISA_DMA_API && INET
30 help 29 help
31 Driver for Comtrol Hostess SV-11 network card which 30 Driver for Comtrol Hostess SV-11 network card which
32 operates on low speed synchronous serial links at up to 31 operates on low speed synchronous serial links at up to
@@ -38,7 +37,7 @@ config HOSTESS_SV11
38# The COSA/SRP driver has not been tested as non-modular yet. 37# The COSA/SRP driver has not been tested as non-modular yet.
39config COSA 38config COSA
40 tristate "COSA/SRP sync serial boards support" 39 tristate "COSA/SRP sync serial boards support"
41 depends on WAN && ISA && m && ISA_DMA_API 40 depends on ISA && m && ISA_DMA_API
42 ---help--- 41 ---help---
43 Driver for COSA and SRP synchronous serial boards. 42 Driver for COSA and SRP synchronous serial boards.
44 43
@@ -62,7 +61,7 @@ config COSA
62# 61#
63config LANMEDIA 62config LANMEDIA
64 tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" 63 tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards"
65 depends on WAN && PCI 64 depends on PCI
66 ---help--- 65 ---help---
67 Driver for the following Lan Media family of serial boards: 66 Driver for the following Lan Media family of serial boards:
68 67
@@ -89,7 +88,7 @@ config LANMEDIA
89# There is no way to detect a Sealevel board. Force it modular 88# There is no way to detect a Sealevel board. Force it modular
90config SEALEVEL_4021 89config SEALEVEL_4021
91 tristate "Sealevel Systems 4021 support" 90 tristate "Sealevel Systems 4021 support"
92 depends on WAN && ISA && m && ISA_DMA_API && INET 91 depends on ISA && m && ISA_DMA_API && INET
93 help 92 help
94 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 93 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
95 94
@@ -99,7 +98,6 @@ config SEALEVEL_4021
99# Generic HDLC 98# Generic HDLC
100config HDLC 99config HDLC
101 tristate "Generic HDLC layer" 100 tristate "Generic HDLC layer"
102 depends on WAN
103 help 101 help
104 Say Y to this option if your Linux box contains a WAN (Wide Area 102 Say Y to this option if your Linux box contains a WAN (Wide Area
105 Network) card supported by this driver and you are planning to 103 Network) card supported by this driver and you are planning to
@@ -167,7 +165,7 @@ config HDLC_X25
167 If unsure, say N. 165 If unsure, say N.
168 166
169comment "X.25/LAPB support is disabled" 167comment "X.25/LAPB support is disabled"
170 depends on WAN && HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y 168 depends on HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y
171 169
172config PCI200SYN 170config PCI200SYN
173 tristate "Goramo PCI200SYN support" 171 tristate "Goramo PCI200SYN support"
@@ -230,10 +228,10 @@ config PC300_MLPPP
230 Multilink PPP over the PC300 synchronous communication boards. 228 Multilink PPP over the PC300 synchronous communication boards.
231 229
232comment "Cyclades-PC300 MLPPP support is disabled." 230comment "Cyclades-PC300 MLPPP support is disabled."
233 depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) 231 depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
234 232
235comment "Refer to the file README.mlppp, provided by PC300 package." 233comment "Refer to the file README.mlppp, provided by PC300 package."
236 depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) 234 depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
237 235
238config PC300TOO 236config PC300TOO
239 tristate "Cyclades PC300 RSV/X21 alternative support" 237 tristate "Cyclades PC300 RSV/X21 alternative support"
@@ -338,7 +336,6 @@ config DSCC4_PCI_RST
338 336
339config DLCI 337config DLCI
340 tristate "Frame Relay DLCI support" 338 tristate "Frame Relay DLCI support"
341 depends on WAN
342 ---help--- 339 ---help---
343 Support for the Frame Relay protocol. 340 Support for the Frame Relay protocol.
344 341
@@ -385,7 +382,7 @@ config SDLA
385# Wan router core. 382# Wan router core.
386config WAN_ROUTER_DRIVERS 383config WAN_ROUTER_DRIVERS
387 tristate "WAN router drivers" 384 tristate "WAN router drivers"
388 depends on WAN && WAN_ROUTER 385 depends on WAN_ROUTER
389 ---help--- 386 ---help---
390 Connect LAN to WAN via Linux box. 387 Connect LAN to WAN via Linux box.
391 388
@@ -440,7 +437,7 @@ config CYCLOMX_X25
440# X.25 network drivers 437# X.25 network drivers
441config LAPBETHER 438config LAPBETHER
442 tristate "LAPB over Ethernet driver (EXPERIMENTAL)" 439 tristate "LAPB over Ethernet driver (EXPERIMENTAL)"
443 depends on WAN && LAPB && X25 440 depends on LAPB && X25
444 ---help--- 441 ---help---
445 Driver for a pseudo device (typically called /dev/lapb0) which allows 442 Driver for a pseudo device (typically called /dev/lapb0) which allows
446 you to open an LAPB point-to-point connection to some other computer 443 you to open an LAPB point-to-point connection to some other computer
@@ -456,7 +453,7 @@ config LAPBETHER
456 453
457config X25_ASY 454config X25_ASY
458 tristate "X.25 async driver (EXPERIMENTAL)" 455 tristate "X.25 async driver (EXPERIMENTAL)"
459 depends on WAN && LAPB && X25 456 depends on LAPB && X25
460 ---help--- 457 ---help---
461 Send and receive X.25 frames over regular asynchronous serial 458 Send and receive X.25 frames over regular asynchronous serial
462 lines such as telephone lines equipped with ordinary modems. 459 lines such as telephone lines equipped with ordinary modems.
@@ -471,7 +468,7 @@ config X25_ASY
471 468
472config SBNI 469config SBNI
473 tristate "Granch SBNI12 Leased Line adapter support" 470 tristate "Granch SBNI12 Leased Line adapter support"
474 depends on WAN && X86 471 depends on X86
475 ---help--- 472 ---help---
476 Driver for ISA SBNI12-xx cards which are low cost alternatives to 473 Driver for ISA SBNI12-xx cards which are low cost alternatives to
477 leased line modems. 474 leased line modems.
@@ -497,5 +494,4 @@ config SBNI_MULTILINE
497 494
498 If unsure, say N. 495 If unsure, say N.
499 496
500endmenu 497endif # WAN
501
diff --git a/drivers/net/wireless/libertas/Makefile b/drivers/net/wireless/libertas/Makefile
index 19c935071d8e..56a8ea1fbf04 100644
--- a/drivers/net/wireless/libertas/Makefile
+++ b/drivers/net/wireless/libertas/Makefile
@@ -1,5 +1,3 @@
1# EXTRA_CFLAGS += -Wpacked
2
3usb8xxx-objs := main.o fw.o wext.o \ 1usb8xxx-objs := main.o fw.o wext.o \
4 rx.o tx.o cmd.o \ 2 rx.o tx.o cmd.o \
5 cmdresp.o scan.o \ 3 cmdresp.o scan.o \
@@ -7,13 +5,6 @@ usb8xxx-objs := main.o fw.o wext.o \
7 ioctl.o debugfs.o \ 5 ioctl.o debugfs.o \
8 ethtool.o assoc.o 6 ethtool.o assoc.o
9 7
10ifeq ($(CONFIG_LIBERTAS_USB_DEBUG), y)
11EXTRA_CFLAGS += -DDEBUG -DPROC_DEBUG
12endif
13
14
15# This is needed to support the newer boot2 bootloader (v >= 3104)
16EXTRA_CFLAGS += -DSUPPORT_BOOT_COMMAND
17usb8xxx-objs += if_bootcmd.o 8usb8xxx-objs += if_bootcmd.o
18usb8xxx-objs += if_usb.o 9usb8xxx-objs += if_usb.o
19 10
diff --git a/drivers/net/wireless/libertas/README b/drivers/net/wireless/libertas/README
index 688da4c784b1..378577200b56 100644
--- a/drivers/net/wireless/libertas/README
+++ b/drivers/net/wireless/libertas/README
@@ -40,64 +40,11 @@ NAME
40SYNOPSIS 40SYNOPSIS
41 iwpriv <ethX> <command> [sub-command] ... 41 iwpriv <ethX> <command> [sub-command] ...
42 42
43 iwpriv ethX version
44 iwpriv ethX scantype [sub-command]
45 iwpriv ethX getSNR <n>
46 iwpriv ethX getNF <n>
47 iwpriv ethX getRSSI <n>
48 iwpriv ethX setrxant <n>
49 iwpriv ethX getrxant
50 iwpriv ethX settxant <n>
51 iwpriv ethX gettxant
52 iwpriv ethX authalgs <n>
53 iwpriv ethX pre-TBTT <n>
54 iwpriv ethX 8021xauthalgs <n>
55 iwpriv ethX encryptionmode <n>
56 iwpriv ethX setregioncode <n> 43 iwpriv ethX setregioncode <n>
57 iwpriv ethX getregioncode 44 iwpriv ethX getregioncode
58 iwpriv ethX setbcnavg <n>
59 iwpriv ethX getbcnavg
60 iwpriv ethX setdataavg <n>
61 iwpriv ethX setlisteninter <n>
62 iwpriv ethX getlisteninter
63 iwpriv ethX setmultipledtim <n>
64 iwpriv ethX getmultipledtim
65 iwpriv ethX atimwindow <n>
66 iwpriv ethX deauth
67 iwpriv ethX adhocstop
68 iwpriv ethX radioon
69 iwpriv ethX radiooff
70 iwpriv ethX reasso-on
71 iwpriv ethX reasso-off
72 iwpriv ethX scanmode [sub-command]
73 iwpriv ethX setwpaie <n>
74 iwpriv ethX wlanidle-off
75 iwpriv ethX wlanidle-on
76 iwpriv ethX getcis
77 iwpriv ethX getlog
78 iwpriv ethX getadhocstatus
79 iwpriv ethX adhocgrate <n>
80
81Version 4 Command:
82 iwpriv ethX inactvityto <n>
83 iwpriv ethX sleeppd <n>
84 iwpriv ethX enable11d <n>
85 iwpriv ethX tpccfg <n>
86 iwpriv ethX powercfg <n>
87 iwpriv ethX setafc <n>
88 iwpriv ethX getafc
89 45
90Version 5 Command: 46Version 5 Command:
91 iwpriv ethX ledgpio <n> 47 iwpriv ethX ledgpio <n>
92 iwpriv ethX scanprobes <n>
93 iwpriv ethX lolisteninter <n>
94 iwpriv ethX rateadapt <n> <m>
95 iwpriv ethX txcontrol <n>
96 iwpriv ethX psnullinterval <n>
97 iwpriv ethX prescan <n>
98 iwpriv ethX getrxinfo
99 iwpriv ethX gettxrate
100 iwpriv ethX beaconinterval
101 48
102BT Commands: 49BT Commands:
103 The blinding table (BT) contains a list of mac addresses that should be 50 The blinding table (BT) contains a list of mac addresses that should be
@@ -150,114 +97,6 @@ DESCRIPTION
150 The ethX parameter specifies the network device that is to be used to 97 The ethX parameter specifies the network device that is to be used to
151 perform this command on. it could be eth0, eth1 etc. 98 perform this command on. it could be eth0, eth1 etc.
152 99
153version
154 This is used to get the current version of the driver and the firmware.
155
156scantype
157 This command is used to set the scan type to be used by the driver in
158 the scan command. This setting will not be used while performing a scan
159 for a specific SSID, as it is always done with scan type being active.
160
161 where the sub-commands are: -
162 active -- to set the scan type to active
163 passive -- to set the scan type to passive
164 get -- to get the scan type set in the driver
165
166getSNR
167 This command gets the average and non average value of Signal to Noise
168 Ratio of Beacon and Data.
169
170 where value is:-
171 0 -- Beacon non-average.
172 1 -- Beacon average.
173 2 -- Data non-average.
174 3 -- Data average.
175
176 If no value is given, all four values are returned in the order mentioned
177 above.
178
179 Note: This command is available only when STA is connected.
180
181getRSSI
182 This command gets the average and non average value os Receive Signal
183 Strength of Beacon and Data.
184
185 where value is:-
186 0 -- Beacon non-average.
187 1 -- Beacon average.
188 2 -- Data non-average.
189 3 -- Data average.
190
191 Note: This command is available only when STA is connected.
192
193getNF
194 This command gets the average and non average value of Noise Floor of
195 Beacon and Data.
196
197 where value is:-
198 0 -- Beacon non-average.
199 1 -- Beacon average.
200 2 -- Data non-average.
201 3 -- Data average.
202
203 Note: This command is available only when STA is connected.
204
205setrxant
206 This command is used to set the mode for Rx antenna.
207
208 The options that can be sent are:-
209 1 -- Antenna 1.
210 2 -- Antenna 2.
211 0xFFFF -- Diversity.
212
213 Usage:
214 iwpriv ethX setrxant 0x01: select Antenna 1.
215
216getrxant
217 This command is used to get the mode for Rx antenna.
218
219
220settxant
221 This command is used to set the mode for Tx antenna.
222 The options that can be sent are:-
223 1 -- Antenna 1.
224 2 -- Antenna 2.
225 0xFFFF -- Diversity.
226 Usage:
227 iwpriv ethX settxant 0x01: select Antenna 1.
228
229gettxant
230 This command is used to get the mode for Tx antenna.
231
232authalgs
233 This command is used by the WPA supplicant to set the authentication
234 algorithms in the station.
235
2368021xauthalgs
237 This command is used by the WPA supplicant to set the 8021.x authentication algorithm type
238 station.
239
240 where values can be:-
241 1 -- None
242 2 -- LEAP
243 4 -- TLS
244 8 -- TTLs
245 16 -- MD5
246
247
248encryptionmode
249 This command is used by the WPA supplicant to set the encryption algorithm.
250
251 where values can be:-
252 0 -- NONE
253 1 -- WEP40
254 2 -- TKIP
255 3 -- CCMP
256 4 -- WEP104
257
258pre-TBTT
259 This command is used to set pre-TBTT time period where value is in microseconds.
260
261setregioncode 100setregioncode
262 This command is used to set the region code in the station. 101 This command is used to set the region code in the station.
263 where value is 'region code' for various regions like 102 where value is 'region code' for various regions like
@@ -270,114 +109,6 @@ getregioncode
270 This command is used to get the region code information set in the 109 This command is used to get the region code information set in the
271 station. 110 station.
272 111
273setbcnavg
274 Set the weighting factor for calculating RSSI.
275
276getbcnavg
277 Get weighting factor for calculating RSSI.
278
279setdataavg
280 Set the weighting factor for calculating SNR.
281
282setlisteninter
283 This command is used to set the listen interval in the
284 station.
285
286 where the value ranges between 1 - 255
287
288getlisteninter
289 This command is used to get the listen interval value set in the
290 station.
291
292setmultipledtim
293 This command is used to set the multiple dtim value in the
294 station.
295 where the value is 1,2,3,4,5,0xfffe
296 0xfffe means the firmware will use listen interval in association
297 command for waking up
298
299getmultipledtim
300 This command is used to get the multiple dtim value set in the station.
301
302atimwindow
303 This command is used to set the atim value in the
304 station.
305
306 where the value ranges between 0 - 50
307
308deauth
309 This command is used to send the de-authentication to the AP with which
310 the station is associated. This command is valid only when
311 station is in Infrastructure mode.
312
313 Note: This command is available only when STA is connected.
314
315adhocstop
316 This command is used to stop beacon transmission from the station and
317 go into idle state in ad-hoc mode.
318
319 Note: This command is available only when STA is connected.
320
321radioon
322 This command is used to turn on the RF antenna.
323
324radiooff
325 This command is sued to turn off the RF antenna.
326
327scanmode
328 This command is used to set the station to scan for either IBSS
329 networks or BSS networks or both BSS and IBSS networks. This
330 command can be used with sub commands,
331
332 where the value for
333 bss -- Scan All the BSS networks.
334 ibss -- Scan All the IBSS networks.
335 any -- Scan both BSS and IBSS networks.
336
337
338
339setwpaie
340 This command is used by WPA supplicant to send the WPA-IE to the driver.
341
342wlanidle-off
343 This command is used to get into idle state.
344
345 Note: This command is available only when STA is connected.
346
347wlanidle-on
348 This command is used to get off the idle state.
349
350 Note: This command is available only when STA is connected.
351
352
353getlog
354 This command is used to get the 802.11 statistics available in the
355 station.
356
357 Note: This command is available only when STA is connected.
358
359getadhocstatus
360 This command is used to get the ad-hoc Network Status.
361
362 The various status codes are:
363 AdhocStarted
364 AdhocJoined
365 AdhocIdle
366 InfraMode
367 AutoUnknownMode
368
369 Note: This command is available only when STA is connected.
370
371adhocgrate
372 This command is used to enable(1) g_rate, Disable(0) g_rate
373 and request(2) the status which g_rate is disabled/enabled,
374 for Ad-hoc creator.
375
376 where value is:-
377 0 -- Disabled
378 1 -- Enabled
379 2 -- Get
380
381ledgpio 112ledgpio
382 This command is used to set/get LEDs. 113 This command is used to set/get LEDs.
383 114
@@ -400,253 +131,6 @@ ledgpio
400 Note: LED0 is invalid 131 Note: LED0 is invalid
401 Note: Maximum Number of LEDs are 16. 132 Note: Maximum Number of LEDs are 16.
402 133
403inactivityto
404 This command is used by the host to set/get the inactivity timeout value,
405 which specifies when WLAN device is put to sleep.
406
407 Usage:
408 iwpriv ethX inactivityto [<timeout>]
409
410 where the parameter are:
411 timeout: timeout value in milliseconds.
412
413 Example:
414 iwpriv eth1 inactivityto
415 "get the timeout value"
416
417 iwpriv eth1 inactivityto X
418 "set timeout value to X ms"
419
420
421sleeppd
422 This command is used to configure the sleep period of the WLAN device.
423
424 Usage:
425 iwpriv ethX sleeppd [<sleep period>]
426
427 where the parameter are:
428 Period: sleep period in milliseconds. Range 10~60.
429
430 Example:
431 iwpriv eth1 sleeppd 10
432 "set period as 10 ms"
433 iwpriv eth1 sleeppd
434 "get the sleep period configuration"
435
436enable11d
437 This command is used to control 11d
438 where value is:-
439 1 -- Enabled
440 0 -- Disabled
441 2 -- Get
442
443
444
445
446tpccfg
447 Enables or disables automatic transmit power control.
448
449 The first parameter turns this feature on (1) or off (0). When turning
450 on, the user must also supply four more parameters in the following
451 order:
452 -UseSNR (Use SNR (in addition to PER) for TPC algorithm),
453 -P0 (P0 power level for TPC),
454 -P1 (P1 power level for TPC),
455 -P2 (P2 power level for TPC).
456
457 Usage:
458 iwpriv ethX tpccfg: Get current configuration
459 iwpriv ethX tpccfg 0: disable auto TPC
460 iwpriv ethX tpccfg 0x01 0x00 0x05 0x0a 0x0d: enable auto TPC; do not use SNR;
461 P0=0x05; P1=0x0a; P2=0x0d;
462 iwpriv ethX tpccfg 0x01 0x01 0x05 0x0a 0x0d: enable auto TPC; use SNR;
463 P0=0x05; P1=0x0a; P2=0x0d.
464
465powercfg
466 Enables or disables power adaptation.
467
468 The first parameter turns this feature on (1) or off (0). When turning
469 on, the user must also supply three more parameters in the following
470 order:
471 -P0 (P0 power level for Power Adaptation),
472 -P1 (P1 power level for Power Adaptation),
473 -P2 (P2 power level for Power Adaptation).
474
475 Usage:
476 iwpriv ethX powercfg: Get current configuration
477 iwpriv ethX powercfg 0: disable power adaptation
478 iwpriv ethX powercfg 1 0x0d 0x0f 0x12: enable power adaptation;
479 P0=0x0d; P1=0x0f; P2=0x12.
480
481getafc
482 This command returns automatic frequency control parameters. It returns
483 three integers:
484 -P0: automatic is on (1), or off (0),
485 -P1: current timing offset in PPM (part per million), and
486 -P2: current frequency offset in PPM.
487
488setafc
489 Set automatic frequency control options.
490
491 The first parameter turns automatic on (1) or off (0).
492 The user must supply two more parameters in either case, in the following
493 order:
494
495 When auto is on:
496
497 -P0 (automatic adjustment frequency threshold in PPM),
498 -P1 (automatic adjustment period in beacon period),
499
500 When auto is off:
501
502 -P0 (manual adjustment timing offset in PPM), and
503 -P1 (manual adjustment frequency offset in PPM).
504
505 Usage:
506 iwpriv ethX setafc 0 10 10: manual adjustment, both timing and frequcncy
507 offset are 10 PPM.
508
509 iwpriv ethX setafc 1 10 10 enable afc, automatic adjustment,
510 frequency threshold 10 PPM, for every 10 beacon periods.
511
512
513
514scanprobes
515 This command sets number of probe requests per channel.
516
517 Usage:
518 iwpriv ethX scanprobes 3 (set scan probes to 3)
519 iwpriv ethX scanprobes (get scan probes)
520
521lolisteninter
522 This command sets the value of listen interval.
523
524 Usage:
525 iwpriv ethX lolisteninter 234 (set the lolisteninter to 234)
526 iwpriv ethX lolisteninter (get the lolisteninter value)
527
528rateadapt
529 This command sets the data rates bitmap.
530 Where <n>
531 0: Disable auto rate adapt
532 1: Enable auto rate adapt
533
534 <m>
535 data rate bitmap
536 Bit Data rate
537 0 1 Mbps
538 1 2 Mbps
539 2 5.5 Mbps
540 3 11 Mbps
541 4 Reserved
542 5 6 Mbps
543 6 9 Mbps
544 7 12 Mbps
545 8 18 Mbps
546 9 24 Mbps
547 10 36 Mbps
548 11 48 Mbps
549 12 54 Mbps
550 12-15 Reserved
551
552 Usage:
553 iwpriv ethX rateadapt
554 read the currect data rate setting
555 iwpriv ethX rateadapt 1 0x07
556 enable auto data rate adapt and
557 data rates are 1Mbps, 2Mbsp and 5.5Mbps
558
559
560txcontrol
561 This command is used to set the Tx rate, ack policy, and retry limit on a per packet basis.
562
563 Where value <n> is:
564 if bit[4] == 1:
565 bit[3:0] -- 0 1 2 3 4 5 6 7 8 9 10 11 12 13-16
566 Data Rate(Mbps) -- 1 2 5.5 11 Rsv 6 9 12 18 24 36 48 54 Rsv
567
568 bit[12:8]
569 if bit[12] == 1, bit[11:8] specifies the Tx retry limit.
570
571 bit[14:13] specifies per packet ack policy:
572 bit[14:13]
573 1 0 use immediate ack policy for this packet
574 1 1 use no ack policy for this packet
575 0 x use the per-packet ack policy setting
576
577 Usage:
578 iwpriv ethX txcontrol 0x7513
579 Use no-ack policy, 5 retires for Tx, 11Mbps rate
580
581
582
583psnullinterval
584 This command is used to set/request NULL package interval for Power Save
585 under infrastructure mode.
586
587 where value is:-
588 -1 -- Disabled
589 n>0 -- Set interval as n (seconds)
590
591prescan
592 This command is used to enable (1)/disable(0) auto prescan before assoicate to the ap
593
594 where value is:-
595 0 -- Disabled
596 1 -- Enabled
597 2 -- Get
598
599getrxinfo
600 This command gets non average value of Signal to Noise Ratio of Data and rate index.
601
602 The following table shows RateIndex and Rate
603
604 RateIndex Data rate
605 0 1 Mbps
606 1 2 Mbps
607 2 5.5 Mbps
608 3 11 Mbps
609 4 Reserved
610 5 6 Mbps
611 6 9 Mbps
612 7 12 Mbps
613 8 18 Mbps
614 9 24 Mbps
615 10 36 Mbps
616 11 48 Mbps
617 12 54 Mbps
618 13-15 Reserved
619
620gettxrate
621 This command gets current Tx rate index of the first packet associated with Rate Adaptation.
622
623 The following table shows RateIndex and Rate
624
625 RateIndex Data rate
626 0 1 Mbps
627 1 2 Mbps
628 2 5.5 Mbps
629 3 11 Mbps
630 4 Reserved
631 5 6 Mbps
632 6 9 Mbps
633 7 12 Mbps
634 8 18 Mbps
635 9 24 Mbps
636 10 36 Mbps
637 11 48 Mbps
638 12 54 Mbps
639 13-15 Reserved
640
641bcninterval
642 This command is used to sets beacon interval in adhoc mode when an argument is given, and gets current adhoc
643 beacon interval when no argument is given. The valid beacon interval is between 20 - 1000,
644 default beacon interval is 100.
645
646 Usage:
647 iwpriv ethX bcninterval 100 (set adhoc beacon interval to 100)
648 iwpriv ethX bcninterval (get adhoc beacon interval)
649
650fwt_add 134fwt_add
651 This command is used to insert an entry into the FWT table. The list of 135 This command is used to insert an entry into the FWT table. The list of
652 parameters must follow the following structure: 136 parameters must follow the following structure:
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index b55c7f57aca8..c260bd1b3d46 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -23,13 +23,13 @@ static int assoc_helper_essid(wlan_private *priv,
23 ENTER(); 23 ENTER();
24 24
25 lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); 25 lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid);
26 if (assoc_req->mode == wlan802_11infrastructure) { 26 if (assoc_req->mode == IW_MODE_INFRA) {
27 if (adapter->prescan) { 27 if (adapter->prescan) {
28 libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); 28 libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1);
29 } 29 }
30 30
31 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, 31 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid,
32 NULL, wlan802_11infrastructure); 32 NULL, IW_MODE_INFRA);
33 if (i >= 0) { 33 if (i >= 0) {
34 lbs_pr_debug(1, 34 lbs_pr_debug(1,
35 "SSID found in scan list ... associating...\n"); 35 "SSID found in scan list ... associating...\n");
@@ -44,7 +44,7 @@ static int assoc_helper_essid(wlan_private *priv,
44 lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", 44 lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n",
45 assoc_req->ssid.ssid); 45 assoc_req->ssid.ssid);
46 } 46 }
47 } else if (assoc_req->mode == wlan802_11ibss) { 47 } else if (assoc_req->mode == IW_MODE_ADHOC) {
48 /* Scan for the network, do not save previous results. Stale 48 /* Scan for the network, do not save previous results. Stale
49 * scan data will cause us to join a non-existant adhoc network 49 * scan data will cause us to join a non-existant adhoc network
50 */ 50 */
@@ -52,7 +52,7 @@ static int assoc_helper_essid(wlan_private *priv,
52 52
53 /* Search for the requested SSID in the scan table */ 53 /* Search for the requested SSID in the scan table */
54 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, 54 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL,
55 wlan802_11ibss); 55 IW_MODE_ADHOC);
56 if (i >= 0) { 56 if (i >= 0) {
57 lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); 57 lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret);
58 libertas_join_adhoc_network(priv, &adapter->scantable[i]); 58 libertas_join_adhoc_network(priv, &adapter->scantable[i]);
@@ -90,10 +90,10 @@ static int assoc_helper_bssid(wlan_private *priv,
90 goto out; 90 goto out;
91 } 91 }
92 92
93 if (assoc_req->mode == wlan802_11infrastructure) { 93 if (assoc_req->mode == IW_MODE_INFRA) {
94 ret = wlan_associate(priv, &adapter->scantable[i]); 94 ret = wlan_associate(priv, &adapter->scantable[i]);
95 lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); 95 lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret);
96 } else if (assoc_req->mode == wlan802_11ibss) { 96 } else if (assoc_req->mode == IW_MODE_ADHOC) {
97 libertas_join_adhoc_network(priv, &adapter->scantable[i]); 97 libertas_join_adhoc_network(priv, &adapter->scantable[i]);
98 } 98 }
99 memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, 99 memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid,
@@ -142,23 +142,23 @@ static int assoc_helper_mode(wlan_private *priv,
142 142
143 ENTER(); 143 ENTER();
144 144
145 if (assoc_req->mode == adapter->inframode) { 145 if (assoc_req->mode == adapter->mode) {
146 LEAVE(); 146 LEAVE();
147 return 0; 147 return 0;
148 } 148 }
149 149
150 if (assoc_req->mode == wlan802_11infrastructure) { 150 if (assoc_req->mode == IW_MODE_INFRA) {
151 if (adapter->psstate != PS_STATE_FULL_POWER) 151 if (adapter->psstate != PS_STATE_FULL_POWER)
152 libertas_ps_wakeup(priv, cmd_option_waitforrsp); 152 libertas_ps_wakeup(priv, cmd_option_waitforrsp);
153 adapter->psmode = wlan802_11powermodecam; 153 adapter->psmode = wlan802_11powermodecam;
154 } 154 }
155 155
156 adapter->inframode = assoc_req->mode; 156 adapter->mode = assoc_req->mode;
157 ret = libertas_prepare_and_send_command(priv, 157 ret = libertas_prepare_and_send_command(priv,
158 cmd_802_11_snmp_mib, 158 cmd_802_11_snmp_mib,
159 0, cmd_option_waitforrsp, 159 0, cmd_option_waitforrsp,
160 OID_802_11_INFRASTRUCTURE_MODE, 160 OID_802_11_INFRASTRUCTURE_MODE,
161 (void *) assoc_req->mode); 161 (void *) (size_t) assoc_req->mode);
162 162
163 LEAVE(); 163 LEAVE();
164 return ret; 164 return ret;
@@ -196,7 +196,7 @@ static int assoc_helper_wep_keys(wlan_private *priv,
196 goto out; 196 goto out;
197 197
198 /* enable/disable the MAC's WEP packet filter */ 198 /* enable/disable the MAC's WEP packet filter */
199 if (assoc_req->secinfo.WEPstatus == wlan802_11WEPenabled) 199 if (assoc_req->secinfo.wep_enabled)
200 adapter->currentpacketfilter |= cmd_act_mac_wep_enable; 200 adapter->currentpacketfilter |= cmd_act_mac_wep_enable;
201 else 201 else
202 adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable; 202 adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable;
@@ -300,8 +300,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter,
300 } 300 }
301 301
302 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { 302 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
303 if (adapter->secinfo.authmode != 303 if (adapter->secinfo.auth_mode != assoc_req->secinfo.auth_mode) {
304 assoc_req->secinfo.authmode) {
305 lbs_pr_debug(1, "Deauthenticating due to updated security " 304 lbs_pr_debug(1, "Deauthenticating due to updated security "
306 "info in configuration request.\n"); 305 "info in configuration request.\n");
307 return 1; 306 return 1;
@@ -316,7 +315,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter,
316 315
317 /* FIXME: deal with 'auto' mode somehow */ 316 /* FIXME: deal with 'auto' mode somehow */
318 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { 317 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
319 if (assoc_req->mode != wlan802_11infrastructure) 318 if (assoc_req->mode != IW_MODE_INFRA)
320 return 1; 319 return 1;
321 } 320 }
322 321
@@ -333,12 +332,12 @@ static int should_stop_adhoc(wlan_adapter *adapter,
333 if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) 332 if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength)
334 return 1; 333 return 1;
335 if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, 334 if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid,
336 sizeof(struct WLAN_802_11_SSID))) 335 adapter->curbssparams.ssid.ssidlength))
337 return 1; 336 return 1;
338 337
339 /* FIXME: deal with 'auto' mode somehow */ 338 /* FIXME: deal with 'auto' mode somehow */
340 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { 339 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
341 if (assoc_req->mode != wlan802_11ibss) 340 if (assoc_req->mode != IW_MODE_ADHOC)
342 return 1; 341 return 1;
343 } 342 }
344 343
@@ -382,7 +381,7 @@ void wlan_association_worker(struct work_struct *work)
382 } 381 }
383 382
384 if (find_any_ssid) { 383 if (find_any_ssid) {
385 enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; 384 u8 new_mode;
386 385
387 ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, 386 ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid,
388 assoc_req->mode, &new_mode); 387 assoc_req->mode, &new_mode);
@@ -393,7 +392,7 @@ void wlan_association_worker(struct work_struct *work)
393 } 392 }
394 393
395 /* Ensure we switch to the mode of the AP */ 394 /* Ensure we switch to the mode of the AP */
396 if (assoc_req->mode == wlan802_11autounknown) { 395 if (assoc_req->mode == IW_MODE_AUTO) {
397 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); 396 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
398 assoc_req->mode = new_mode; 397 assoc_req->mode = new_mode;
399 } 398 }
@@ -403,7 +402,7 @@ void wlan_association_worker(struct work_struct *work)
403 * Check if the attributes being changing require deauthentication 402 * Check if the attributes being changing require deauthentication
404 * from the currently associated infrastructure access point. 403 * from the currently associated infrastructure access point.
405 */ 404 */
406 if (adapter->inframode == wlan802_11infrastructure) { 405 if (adapter->mode == IW_MODE_INFRA) {
407 if (should_deauth_infrastructure(adapter, assoc_req)) { 406 if (should_deauth_infrastructure(adapter, assoc_req)) {
408 ret = libertas_send_deauthentication(priv); 407 ret = libertas_send_deauthentication(priv);
409 if (ret) { 408 if (ret) {
@@ -412,7 +411,7 @@ void wlan_association_worker(struct work_struct *work)
412 ret); 411 ret);
413 } 412 }
414 } 413 }
415 } else if (adapter->inframode == wlan802_11ibss) { 414 } else if (adapter->mode == IW_MODE_ADHOC) {
416 if (should_stop_adhoc(adapter, assoc_req)) { 415 if (should_stop_adhoc(adapter, assoc_req)) {
417 ret = libertas_stop_adhoc_network(priv); 416 ret = libertas_stop_adhoc_network(priv);
418 if (ret) { 417 if (ret) {
@@ -543,7 +542,7 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter)
543 assoc_req->channel = adapter->curbssparams.channel; 542 assoc_req->channel = adapter->curbssparams.channel;
544 543
545 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) 544 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags))
546 assoc_req->mode = adapter->inframode; 545 assoc_req->mode = adapter->mode;
547 546
548 if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { 547 if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
549 memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, 548 memcpy(&assoc_req->bssid, adapter->curbssparams.bssid,
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index bfdac58b5c06..de9cb46a70ff 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -381,15 +381,16 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
381 switch (cmd_oid) { 381 switch (cmd_oid) {
382 case OID_802_11_INFRASTRUCTURE_MODE: 382 case OID_802_11_INFRASTRUCTURE_MODE:
383 { 383 {
384 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode = 384 u8 mode = (u8) (size_t) pdata_buf;
385 (enum WLAN_802_11_NETWORK_INFRASTRUCTURE) pdata_buf;
386 pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); 385 pSNMPMIB->querytype = cpu_to_le16(cmd_act_set);
387 pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i); 386 pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i);
388 pSNMPMIB->bufsize = sizeof(u8); 387 pSNMPMIB->bufsize = sizeof(u8);
389 if (mode == wlan802_11infrastructure) 388 if (mode == IW_MODE_ADHOC) {
390 ucTemp = SNMP_MIB_VALUE_INFRA;
391 else
392 ucTemp = SNMP_MIB_VALUE_ADHOC; 389 ucTemp = SNMP_MIB_VALUE_ADHOC;
390 } else {
391 /* Infra and Auto modes */
392 ucTemp = SNMP_MIB_VALUE_INFRA;
393 }
393 394
394 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); 395 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8));
395 396
@@ -947,8 +948,8 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u
947 948
948 spin_unlock_irqrestore(&adapter->driver_lock, flags); 949 spin_unlock_irqrestore(&adapter->driver_lock, flags);
949 950
950 lbs_pr_debug(1, "QUEUE_CMD: Inserted node=0x%x, cmd=0x%x in cmdpendingq\n", 951 lbs_pr_debug(1, "QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n",
951 (u32) cmdnode, 952 cmdnode,
952 ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); 953 ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command);
953 954
954done: 955done:
@@ -976,8 +977,8 @@ static int DownloadcommandToStation(wlan_private * priv,
976 ENTER(); 977 ENTER();
977 978
978 if (!adapter || !cmdnode) { 979 if (!adapter || !cmdnode) {
979 lbs_pr_debug(1, "DNLD_CMD: adapter = %#x, cmdnode = %#x\n", 980 lbs_pr_debug(1, "DNLD_CMD: adapter = %p, cmdnode = %p\n",
980 (int)adapter, (int)cmdnode); 981 adapter, cmdnode);
981 if (cmdnode) { 982 if (cmdnode) {
982 spin_lock_irqsave(&adapter->driver_lock, flags); 983 spin_lock_irqsave(&adapter->driver_lock, flags);
983 __libertas_cleanup_and_insert_cmd(priv, cmdnode); 984 __libertas_cleanup_and_insert_cmd(priv, cmdnode);
@@ -1174,8 +1175,8 @@ int libertas_prepare_and_send_command(wlan_private * priv,
1174 1175
1175 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 1176 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1176 1177
1177 lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr =0x%x, command=0x%X\n", 1178 lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr=%p, command=0x%X\n",
1178 (u32) cmdptr, cmd_no); 1179 cmdptr, cmd_no);
1179 1180
1180 if (!cmdptr) { 1181 if (!cmdptr) {
1181 lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); 1182 lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n");
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index cdb012c7e9cf..c86454034b58 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -72,8 +72,6 @@ void libertas_mac_event_disconnected(wlan_private * priv)
72 adapter->secinfo.WPAenabled = 0; 72 adapter->secinfo.WPAenabled = 0;
73 adapter->secinfo.WPA2enabled = 0; 73 adapter->secinfo.WPA2enabled = 0;
74 adapter->wpa_ie_len = 0; 74 adapter->wpa_ie_len = 0;
75 adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE;
76 adapter->secinfo.Encryptionmode = CIPHER_NONE;
77 75
78 adapter->connect_status = libertas_disconnected; 76 adapter->connect_status = libertas_disconnected;
79 77
@@ -811,7 +809,7 @@ int libertas_process_rx_command(wlan_private * priv)
811 if (result) { 809 if (result) {
812 lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", 810 lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n",
813 resp->result); 811 resp->result);
814 if (adapter->inframode == wlan802_11ibss) { 812 if (adapter->mode == IW_MODE_ADHOC) {
815 /* 813 /*
816 * We should not re-try enter-ps command in 814 * We should not re-try enter-ps command in
817 * ad-hoc mode. It takes place in 815 * ad-hoc mode. It takes place in
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 51dfd202f558..7d7bc5e86a56 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -7,6 +7,7 @@
7#include "dev.h" 7#include "dev.h"
8#include "decl.h" 8#include "decl.h"
9#include "host.h" 9#include "host.h"
10#include "debugfs.h"
10 11
11static struct dentry *libertas_dir = NULL; 12static struct dentry *libertas_dir = NULL;
12static char *szStates[] = { 13static char *szStates[] = {
@@ -276,7 +277,7 @@ static void libertas_parse_ssid(char *buf, size_t count,
276 if (!end) 277 if (!end)
277 end = buf + count - 1; 278 end = buf + count - 1;
278 279
279 size = min(IW_ESSID_MAX_SIZE, end - hold); 280 size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold));
280 strncpy(scan_cfg->specificSSID, hold, size); 281 strncpy(scan_cfg->specificSSID, hold, size);
281 282
282 return; 283 return;
@@ -1648,7 +1649,7 @@ struct libertas_debugfs_files {
1648 struct file_operations fops; 1649 struct file_operations fops;
1649}; 1650};
1650 1651
1651struct libertas_debugfs_files debugfs_files[] = { 1652static struct libertas_debugfs_files debugfs_files[] = {
1652 { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), }, 1653 { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), },
1653 { "getscantable", 0444, FOPS(libertas_getscantable, 1654 { "getscantable", 0444, FOPS(libertas_getscantable,
1654 write_file_dummy), }, 1655 write_file_dummy), },
@@ -1658,7 +1659,7 @@ struct libertas_debugfs_files debugfs_files[] = {
1658 { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), }, 1659 { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), },
1659}; 1660};
1660 1661
1661struct libertas_debugfs_files debugfs_events_files[] = { 1662static struct libertas_debugfs_files debugfs_events_files[] = {
1662 {"low_rssi", 0644, FOPS(libertas_lowrssi_read, 1663 {"low_rssi", 0644, FOPS(libertas_lowrssi_read,
1663 libertas_lowrssi_write), }, 1664 libertas_lowrssi_write), },
1664 {"low_snr", 0644, FOPS(libertas_lowsnr_read, 1665 {"low_snr", 0644, FOPS(libertas_lowsnr_read,
@@ -1673,7 +1674,7 @@ struct libertas_debugfs_files debugfs_events_files[] = {
1673 libertas_highsnr_write), }, 1674 libertas_highsnr_write), },
1674}; 1675};
1675 1676
1676struct libertas_debugfs_files debugfs_regs_files[] = { 1677static struct libertas_debugfs_files debugfs_regs_files[] = {
1677 {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), }, 1678 {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), },
1678 {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), }, 1679 {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), },
1679 {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), }, 1680 {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), },
@@ -1778,7 +1779,7 @@ void libertas_debugfs_remove_one(wlan_private *priv)
1778struct debug_data { 1779struct debug_data {
1779 char name[32]; 1780 char name[32];
1780 u32 size; 1781 u32 size;
1781 u32 addr; 1782 size_t addr;
1782}; 1783};
1783 1784
1784/* To debug any member of wlan_adapter, simply add one line here. 1785/* To debug any member of wlan_adapter, simply add one line here.
@@ -1825,6 +1826,8 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf,
1825 val = *((u16 *) d[i].addr); 1826 val = *((u16 *) d[i].addr);
1826 else if (d[i].size == 4) 1827 else if (d[i].size == 4)
1827 val = *((u32 *) d[i].addr); 1828 val = *((u32 *) d[i].addr);
1829 else if (d[i].size == 8)
1830 val = *((u64 *) d[i].addr);
1828 1831
1829 pos += sprintf(p + pos, "%s=%d\n", d[i].name, val); 1832 pos += sprintf(p + pos, "%s=%d\n", d[i].name, val);
1830 } 1833 }
@@ -1844,7 +1847,7 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf,
1844 * @param data data to write 1847 * @param data data to write
1845 * @return number of data 1848 * @return number of data
1846 */ 1849 */
1847static int wlan_debugfs_write(struct file *f, const char __user *buf, 1850static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf,
1848 size_t cnt, loff_t *ppos) 1851 size_t cnt, loff_t *ppos)
1849{ 1852{
1850 int r, i; 1853 int r, i;
@@ -1886,12 +1889,14 @@ static int wlan_debugfs_write(struct file *f, const char __user *buf,
1886 *((u16 *) d[i].addr) = (u16) r; 1889 *((u16 *) d[i].addr) = (u16) r;
1887 else if (d[i].size == 4) 1890 else if (d[i].size == 4)
1888 *((u32 *) d[i].addr) = (u32) r; 1891 *((u32 *) d[i].addr) = (u32) r;
1892 else if (d[i].size == 8)
1893 *((u64 *) d[i].addr) = (u64) r;
1889 break; 1894 break;
1890 } while (1); 1895 } while (1);
1891 } 1896 }
1892 kfree(pdata); 1897 kfree(pdata);
1893 1898
1894 return cnt; 1899 return (ssize_t)cnt;
1895} 1900}
1896 1901
1897static struct file_operations libertas_debug_fops = { 1902static struct file_operations libertas_debug_fops = {
@@ -1916,20 +1921,10 @@ void libertas_debug_init(wlan_private * priv, struct net_device *dev)
1916 return; 1921 return;
1917 1922
1918 for (i = 0; i < num_of_items; i++) 1923 for (i = 0; i < num_of_items; i++)
1919 items[i].addr += (u32) priv->adapter; 1924 items[i].addr += (size_t) priv->adapter;
1920 1925
1921 priv->debugfs_debug = debugfs_create_file("debug", 0644, 1926 priv->debugfs_debug = debugfs_create_file("debug", 0644,
1922 priv->debugfs_dir, &items[0], 1927 priv->debugfs_dir, &items[0],
1923 &libertas_debug_fops); 1928 &libertas_debug_fops);
1924} 1929}
1925 1930
1926/**
1927 * @brief remove proc file
1928 *
1929 * @param priv pointer wlan_private
1930 * @return N/A
1931 */
1932void libertas_debug_remove(wlan_private * priv)
1933{
1934 debugfs_remove(priv->debugfs_debug);
1935}
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index fb1478c1b87d..80dd9ea19c8e 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -9,6 +9,11 @@
9 9
10extern unsigned int libertas_debug; 10extern unsigned int libertas_debug;
11 11
12#ifdef CONFIG_LIBERTAS_DEBUG
13#define DEBUG
14#define PROC_DEBUG
15#endif
16
12#define DRV_NAME "usb8xxx" 17#define DRV_NAME "usb8xxx"
13 18
14#define lbs_pr_info(format, args...) \ 19#define lbs_pr_info(format, args...) \
@@ -223,31 +228,6 @@ enum SNRNF_DATA {
223 MAX_TYPE_AVG 228 MAX_TYPE_AVG
224}; 229};
225 230
226/** WLAN_802_11_AUTH_ALG*/
227enum WLAN_802_11_AUTH_ALG {
228 AUTH_ALG_OPEN_SYSTEM = 1,
229 AUTH_ALG_SHARED_KEY = 2,
230 AUTH_ALG_NETWORK_EAP = 8,
231};
232
233/** WLAN_802_1X_AUTH_ALG */
234enum WLAN_802_1X_AUTH_ALG {
235 WLAN_1X_AUTH_ALG_NONE = 1,
236 WLAN_1X_AUTH_ALG_LEAP = 2,
237 WLAN_1X_AUTH_ALG_TLS = 4,
238 WLAN_1X_AUTH_ALG_TTLS = 8,
239 WLAN_1X_AUTH_ALG_MD5 = 16,
240};
241
242/** WLAN_802_11_ENCRYPTION_MODE */
243enum WLAN_802_11_ENCRYPTION_MODE {
244 CIPHER_NONE,
245 CIPHER_WEP40,
246 CIPHER_TKIP,
247 CIPHER_CCMP,
248 CIPHER_WEP104,
249};
250
251/** WLAN_802_11_POWER_MODE */ 231/** WLAN_802_11_POWER_MODE */
252enum WLAN_802_11_POWER_MODE { 232enum WLAN_802_11_POWER_MODE {
253 wlan802_11powermodecam, 233 wlan802_11powermodecam,
@@ -292,28 +272,6 @@ enum mv_ms_type {
292 MVMS_EVENT 272 MVMS_EVENT
293}; 273};
294 274
295/** WLAN_802_11_NETWORK_INFRASTRUCTURE */
296enum WLAN_802_11_NETWORK_INFRASTRUCTURE {
297 wlan802_11ibss,
298 wlan802_11infrastructure,
299 wlan802_11autounknown,
300 /*defined as upper bound */
301 wlan802_11infrastructuremax
302};
303
304/** WLAN_802_11_AUTHENTICATION_MODE */
305enum WLAN_802_11_AUTHENTICATION_MODE {
306 wlan802_11authmodeopen = 0x00,
307 wlan802_11authmodeshared = 0x01,
308 wlan802_11authmodenetworkEAP = 0x80,
309};
310
311/** WLAN_802_11_WEP_STATUS */
312enum WLAN_802_11_WEP_STATUS {
313 wlan802_11WEPenabled,
314 wlan802_11WEPdisabled,
315};
316
317/** SNMP_MIB_INDEX_e */ 275/** SNMP_MIB_INDEX_e */
318enum SNMP_MIB_INDEX_e { 276enum SNMP_MIB_INDEX_e {
319 desired_bsstype_i = 0, 277 desired_bsstype_i = 0,
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index b1f876f9693b..e8b9020f9bd6 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -10,6 +10,7 @@
10#include <linux/wireless.h> 10#include <linux/wireless.h>
11#include <linux/ethtool.h> 11#include <linux/ethtool.h>
12#include <linux/debugfs.h> 12#include <linux/debugfs.h>
13#include <net/ieee80211.h>
13 14
14#include "defs.h" 15#include "defs.h"
15#include "scan.h" 16#include "scan.h"
@@ -56,10 +57,8 @@ struct region_channel {
56struct wlan_802_11_security { 57struct wlan_802_11_security {
57 u8 WPAenabled; 58 u8 WPAenabled;
58 u8 WPA2enabled; 59 u8 WPA2enabled;
59 enum WLAN_802_11_WEP_STATUS WEPstatus; 60 u8 wep_enabled;
60 enum WLAN_802_11_AUTHENTICATION_MODE authmode; 61 u8 auth_mode;
61 enum WLAN_802_1X_AUTH_ALG auth1xalg;
62 enum WLAN_802_11_ENCRYPTION_MODE Encryptionmode;
63}; 62};
64 63
65/** Current Basic Service Set State Structure */ 64/** Current Basic Service Set State Structure */
@@ -184,7 +183,7 @@ struct assoc_request {
184 183
185 struct WLAN_802_11_SSID ssid; 184 struct WLAN_802_11_SSID ssid;
186 u8 channel; 185 u8 channel;
187 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode; 186 u8 mode;
188 u8 bssid[ETH_ALEN]; 187 u8 bssid[ETH_ALEN];
189 188
190 /** WEP keys */ 189 /** WEP keys */
@@ -198,7 +197,6 @@ struct assoc_request {
198 struct wlan_802_11_security secinfo; 197 struct wlan_802_11_security secinfo;
199 198
200 /** WPA Information Elements*/ 199 /** WPA Information Elements*/
201#define MAX_WPA_IE_LEN 64
202 u8 wpa_ie[MAX_WPA_IE_LEN]; 200 u8 wpa_ie[MAX_WPA_IE_LEN];
203 u8 wpa_ie_len; 201 u8 wpa_ie_len;
204}; 202};
@@ -254,7 +252,8 @@ struct _wlan_adapter {
254 /** current ssid/bssid related parameters*/ 252 /** current ssid/bssid related parameters*/
255 struct current_bss_params curbssparams; 253 struct current_bss_params curbssparams;
256 254
257 enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; 255 /* IW_MODE_* */
256 u8 mode;
258 257
259 struct bss_descriptor *pattemptedbssdesc; 258 struct bss_descriptor *pattemptedbssdesc;
260 259
@@ -339,7 +338,6 @@ struct _wlan_adapter {
339 struct WLAN_802_11_KEY wpa_unicast_key; 338 struct WLAN_802_11_KEY wpa_unicast_key;
340 339
341 /** WPA Information Elements*/ 340 /** WPA Information Elements*/
342#define MAX_WPA_IE_LEN 64
343 u8 wpa_ie[MAX_WPA_IE_LEN]; 341 u8 wpa_ie[MAX_WPA_IE_LEN];
344 u8 wpa_ie_len; 342 u8 wpa_ie_len;
345 343
diff --git a/drivers/net/wireless/libertas/fw.c b/drivers/net/wireless/libertas/fw.c
index b194a4570791..441123c85e62 100644
--- a/drivers/net/wireless/libertas/fw.c
+++ b/drivers/net/wireless/libertas/fw.c
@@ -194,16 +194,13 @@ static void wlan_init_adapter(wlan_private * priv)
194 adapter->scanmode = cmd_bss_type_any; 194 adapter->scanmode = cmd_bss_type_any;
195 195
196 /* 802.11 specific */ 196 /* 802.11 specific */
197 adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; 197 adapter->secinfo.wep_enabled = 0;
198 for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); 198 for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]);
199 i++) 199 i++)
200 memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); 200 memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY));
201 adapter->wep_tx_keyidx = 0; 201 adapter->wep_tx_keyidx = 0;
202 adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; 202 adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
203 adapter->secinfo.authmode = wlan802_11authmodeopen; 203 adapter->mode = IW_MODE_INFRA;
204 adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE;
205 adapter->secinfo.Encryptionmode = CIPHER_NONE;
206 adapter->inframode = wlan802_11infrastructure;
207 204
208 adapter->assoc_req = NULL; 205 adapter->assoc_req = NULL;
209 206
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 695fb6a66ffe..ae6f72a6cdf3 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -388,7 +388,7 @@ static int __if_usb_submit_rx_urb(wlan_private * priv,
388 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, 388 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev,
389 usb_rcvbulkpipe(cardp->udev, 389 usb_rcvbulkpipe(cardp->udev,
390 cardp->bulk_in_endpointAddr), 390 cardp->bulk_in_endpointAddr),
391 skb->tail + IPFIELD_ALIGN_OFFSET, 391 (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET),
392 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, 392 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn,
393 rinfo); 393 rinfo);
394 394
@@ -626,6 +626,7 @@ static void if_usb_receive(struct urb *urb)
626 cardp->usb_event_cause); 626 cardp->usb_event_cause);
627 if (cardp->usb_event_cause & 0xffff0000) { 627 if (cardp->usb_event_cause & 0xffff0000) {
628 libertas_send_tx_feedback(priv); 628 libertas_send_tx_feedback(priv);
629 spin_unlock(&priv->adapter->driver_lock);
629 break; 630 break;
630 } 631 }
631 cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; 632 cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3;
@@ -775,7 +776,6 @@ restart:
775 return -1; 776 return -1;
776 } 777 }
777 778
778#ifdef SUPPORT_BOOT_COMMAND
779 cardp->bootcmdresp = 0; 779 cardp->bootcmdresp = 0;
780 do { 780 do {
781 int j = 0; 781 int j = 0;
@@ -796,7 +796,6 @@ restart:
796 } 796 }
797 return -1; 797 return -1;
798 } 798 }
799#endif
800 799
801 i = 0; 800 i = 0;
802 priv->adapter->fw_ready = 0; 801 priv->adapter->fw_ready = 0;
diff --git a/drivers/net/wireless/libertas/if_usb.h b/drivers/net/wireless/libertas/if_usb.h
index 785116720bc6..170dfe6809f5 100644
--- a/drivers/net/wireless/libertas/if_usb.h
+++ b/drivers/net/wireless/libertas/if_usb.h
@@ -12,7 +12,6 @@
12#define USB8388_VID_2 0x05a3 12#define USB8388_VID_2 0x05a3
13#define USB8388_PID_2 0x8388 13#define USB8388_PID_2 0x8388
14 14
15#ifdef SUPPORT_BOOT_COMMAND
16#define BOOT_CMD_FW_BY_USB 0x01 15#define BOOT_CMD_FW_BY_USB 0x01
17#define BOOT_CMD_FW_IN_EEPROM 0x02 16#define BOOT_CMD_FW_IN_EEPROM 0x02
18#define BOOT_CMD_UPDATE_BOOT2 0x03 17#define BOOT_CMD_UPDATE_BOOT2 0x03
@@ -36,7 +35,6 @@ struct bootcmdrespStr
36 u8 u8result; 35 u8 u8result;
37 u8 au8dumy[2]; 36 u8 au8dumy[2];
38}; 37};
39#endif /* SUPPORT_BOOT_COMMAND */
40 38
41/* read callback private data */ 39/* read callback private data */
42struct read_cb_info { 40struct read_cb_info {
diff --git a/drivers/net/wireless/libertas/ioctl.c b/drivers/net/wireless/libertas/ioctl.c
index 82b39642423a..a8f76c358992 100644
--- a/drivers/net/wireless/libertas/ioctl.c
+++ b/drivers/net/wireless/libertas/ioctl.c
@@ -27,95 +27,6 @@
27 27
28#define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) 28#define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ)
29 29
30static int setrxantenna(wlan_private * priv, int mode)
31{
32 int ret = 0;
33 wlan_adapter *adapter = priv->adapter;
34
35 if (mode != RF_ANTENNA_1 && mode != RF_ANTENNA_2
36 && mode != RF_ANTENNA_AUTO) {
37 return -EINVAL;
38 }
39
40 adapter->rxantennamode = mode;
41
42 lbs_pr_debug(1, "SET RX Antenna mode to 0x%04x\n", adapter->rxantennamode);
43
44 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
45 cmd_act_set_rx,
46 cmd_option_waitforrsp, 0,
47 &adapter->rxantennamode);
48 return ret;
49}
50
51static int settxantenna(wlan_private * priv, int mode)
52{
53 int ret = 0;
54 wlan_adapter *adapter = priv->adapter;
55
56 if ((mode != RF_ANTENNA_1) && (mode != RF_ANTENNA_2)
57 && (mode != RF_ANTENNA_AUTO)) {
58 return -EINVAL;
59 }
60
61 adapter->txantennamode = mode;
62
63 lbs_pr_debug(1, "SET TX Antenna mode to 0x%04x\n", adapter->txantennamode);
64
65 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
66 cmd_act_set_tx,
67 cmd_option_waitforrsp, 0,
68 &adapter->txantennamode);
69
70 return ret;
71}
72
73static int getrxantenna(wlan_private * priv, char *buf)
74{
75 int ret = 0;
76 wlan_adapter *adapter = priv->adapter;
77
78 // clear it, so we will know if the value
79 // returned below is correct or not.
80 adapter->rxantennamode = 0;
81
82 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
83 cmd_act_get_rx,
84 cmd_option_waitforrsp, 0, NULL);
85
86 if (ret) {
87 LEAVE();
88 return ret;
89 }
90
91 lbs_pr_debug(1, "Get Rx Antenna mode:0x%04x\n", adapter->rxantennamode);
92
93 return sprintf(buf, "0x%04x", adapter->rxantennamode) + 1;
94}
95
96static int gettxantenna(wlan_private * priv, char *buf)
97{
98 int ret = 0;
99 wlan_adapter *adapter = priv->adapter;
100
101 // clear it, so we will know if the value
102 // returned below is correct or not.
103 adapter->txantennamode = 0;
104
105 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
106 cmd_act_get_tx,
107 cmd_option_waitforrsp, 0, NULL);
108
109 if (ret) {
110 LEAVE();
111 return ret;
112 }
113
114 lbs_pr_debug(1, "Get Tx Antenna mode:0x%04x\n", adapter->txantennamode);
115
116 return sprintf(buf, "0x%04x", adapter->txantennamode) + 1;
117}
118
119static int wlan_set_region(wlan_private * priv, u16 region_code) 30static int wlan_set_region(wlan_private * priv, u16 region_code)
120{ 31{
121 int i; 32 int i;
@@ -144,998 +55,6 @@ static int wlan_set_region(wlan_private * priv, u16 region_code)
144 return 0; 55 return 0;
145} 56}
146 57
147/**
148 * @brief Get/Set Firmware wakeup method
149 *
150 * @param priv A pointer to wlan_private structure
151 * @param wrq A pointer to user data
152 * @return 0--success, otherwise fail
153 */
154static int wlan_txcontrol(wlan_private * priv, struct iwreq *wrq)
155{
156 wlan_adapter *adapter = priv->adapter;
157 int data;
158 ENTER();
159
160 if ((int)wrq->u.data.length == 0) {
161 if (copy_to_user
162 (wrq->u.data.pointer, &adapter->pkttxctrl, sizeof(u32))) {
163 lbs_pr_alert("copy_to_user failed!\n");
164 return -EFAULT;
165 }
166 } else {
167 if ((int)wrq->u.data.length > 1) {
168 lbs_pr_alert("ioctl too many args!\n");
169 return -EFAULT;
170 }
171 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) {
172 lbs_pr_alert("Copy from user failed\n");
173 return -EFAULT;
174 }
175
176 adapter->pkttxctrl = (u32) data;
177 }
178
179 wrq->u.data.length = 1;
180
181 LEAVE();
182 return 0;
183}
184
185/**
186 * @brief Get/Set NULL Package generation interval
187 *
188 * @param priv A pointer to wlan_private structure
189 * @param wrq A pointer to user data
190 * @return 0--success, otherwise fail
191 */
192static int wlan_null_pkt_interval(wlan_private * priv, struct iwreq *wrq)
193{
194 wlan_adapter *adapter = priv->adapter;
195 int data;
196 ENTER();
197
198 if ((int)wrq->u.data.length == 0) {
199 data = adapter->nullpktinterval;
200
201 if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) {
202 lbs_pr_alert( "copy_to_user failed!\n");
203 return -EFAULT;
204 }
205 } else {
206 if ((int)wrq->u.data.length > 1) {
207 lbs_pr_alert( "ioctl too many args!\n");
208 return -EFAULT;
209 }
210 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) {
211 lbs_pr_debug(1, "Copy from user failed\n");
212 return -EFAULT;
213 }
214
215 adapter->nullpktinterval = data;
216 }
217
218 wrq->u.data.length = 1;
219
220 LEAVE();
221 return 0;
222}
223
224static int wlan_get_rxinfo(wlan_private * priv, struct iwreq *wrq)
225{
226 wlan_adapter *adapter = priv->adapter;
227 int data[2];
228 ENTER();
229 data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG];
230 data[1] = adapter->rxpd_rate;
231 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) {
232 lbs_pr_debug(1, "Copy to user failed\n");
233 return -EFAULT;
234 }
235 wrq->u.data.length = 2;
236 LEAVE();
237 return 0;
238}
239
240static int wlan_get_snr(wlan_private * priv, struct iwreq *wrq)
241{
242 int ret = 0;
243 wlan_adapter *adapter = priv->adapter;
244 int data[4];
245
246 ENTER();
247 memset(data, 0, sizeof(data));
248 if (wrq->u.data.length) {
249 if (copy_from_user(data, wrq->u.data.pointer,
250 min_t(size_t, wrq->u.data.length, 4) * sizeof(int)))
251 return -EFAULT;
252 }
253 if ((wrq->u.data.length == 0) || (data[0] == 0) || (data[0] == 1)) {
254 if (adapter->connect_status == libertas_connected) {
255 ret = libertas_prepare_and_send_command(priv,
256 cmd_802_11_rssi,
257 0,
258 cmd_option_waitforrsp,
259 0, NULL);
260
261 if (ret) {
262 LEAVE();
263 return ret;
264 }
265 }
266 }
267
268 if (wrq->u.data.length == 0) {
269 data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG];
270 data[1] = adapter->SNR[TYPE_BEACON][TYPE_AVG];
271 data[2] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG];
272 data[3] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
273 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 4))
274 return -EFAULT;
275 wrq->u.data.length = 4;
276 } else if (data[0] == 0) {
277 data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG];
278 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
279 return -EFAULT;
280 wrq->u.data.length = 1;
281 } else if (data[0] == 1) {
282 data[0] = adapter->SNR[TYPE_BEACON][TYPE_AVG];
283 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
284 return -EFAULT;
285 wrq->u.data.length = 1;
286 } else if (data[0] == 2) {
287 data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG];
288 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
289 return -EFAULT;
290 wrq->u.data.length = 1;
291 } else if (data[0] == 3) {
292 data[0] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
293 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
294 return -EFAULT;
295 wrq->u.data.length = 1;
296 } else
297 return -ENOTSUPP;
298
299 LEAVE();
300 return 0;
301}
302
303static int wlan_beacon_interval(wlan_private * priv, struct iwreq *wrq)
304{
305 int data;
306 wlan_adapter *adapter = priv->adapter;
307
308 if (wrq->u.data.length > 0) {
309 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int)))
310 return -EFAULT;
311
312 lbs_pr_debug(1, "WLAN SET BEACON INTERVAL: %d\n", data);
313 if ((data > MRVDRV_MAX_BEACON_INTERVAL)
314 || (data < MRVDRV_MIN_BEACON_INTERVAL))
315 return -ENOTSUPP;
316 adapter->beaconperiod = data;
317 }
318 data = adapter->beaconperiod;
319 if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int)))
320 return -EFAULT;
321
322 wrq->u.data.length = 1;
323
324 return 0;
325}
326
327static int wlan_get_rssi(wlan_private * priv, struct iwreq *wrq)
328{
329 int ret = 0;
330 wlan_adapter *adapter = priv->adapter;
331 int temp;
332 int data = 0;
333 int *val;
334
335 ENTER();
336 data = SUBCMD_DATA(wrq);
337 if ((data == 0) || (data == 1)) {
338 ret = libertas_prepare_and_send_command(priv,
339 cmd_802_11_rssi,
340 0, cmd_option_waitforrsp,
341 0, NULL);
342 if (ret) {
343 LEAVE();
344 return ret;
345 }
346 }
347
348 switch (data) {
349 case 0:
350
351 temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG],
352 adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
353 break;
354 case 1:
355 temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG],
356 adapter->NF[TYPE_BEACON][TYPE_AVG]);
357 break;
358 case 2:
359 temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_NOAVG],
360 adapter->NF[TYPE_RXPD][TYPE_NOAVG]);
361 break;
362 case 3:
363 temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
364 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
365 break;
366 default:
367 return -ENOTSUPP;
368 }
369 val = (int *)wrq->u.name;
370 *val = temp;
371
372 LEAVE();
373 return 0;
374}
375
376static int wlan_get_nf(wlan_private * priv, struct iwreq *wrq)
377{
378 int ret = 0;
379 wlan_adapter *adapter = priv->adapter;
380 int temp;
381 int data = 0;
382 int *val;
383
384 data = SUBCMD_DATA(wrq);
385 if ((data == 0) || (data == 1)) {
386 ret = libertas_prepare_and_send_command(priv,
387 cmd_802_11_rssi,
388 0, cmd_option_waitforrsp,
389 0, NULL);
390
391 if (ret) {
392 LEAVE();
393 return ret;
394 }
395 }
396
397 switch (data) {
398 case 0:
399 temp = adapter->NF[TYPE_BEACON][TYPE_NOAVG];
400 break;
401 case 1:
402 temp = adapter->NF[TYPE_BEACON][TYPE_AVG];
403 break;
404 case 2:
405 temp = adapter->NF[TYPE_RXPD][TYPE_NOAVG];
406 break;
407 case 3:
408 temp = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
409 break;
410 default:
411 return -ENOTSUPP;
412 }
413
414 temp = CAL_NF(temp);
415
416 lbs_pr_debug(1, "%s: temp = %d\n", __FUNCTION__, temp);
417 val = (int *)wrq->u.name;
418 *val = temp;
419 return 0;
420}
421
422static int wlan_get_txrate_ioctl(wlan_private * priv, struct ifreq *req)
423{
424 wlan_adapter *adapter = priv->adapter;
425 int *pdata;
426 struct iwreq *wrq = (struct iwreq *)req;
427 int ret = 0;
428 adapter->txrate = 0;
429 lbs_pr_debug(1, "wlan_get_txrate_ioctl\n");
430 ret = libertas_prepare_and_send_command(priv, cmd_802_11_tx_rate_query,
431 cmd_act_get, cmd_option_waitforrsp,
432 0, NULL);
433 if (ret)
434 return ret;
435
436 pdata = (int *)wrq->u.name;
437 *pdata = (int)adapter->txrate;
438 return 0;
439}
440
441static int wlan_get_adhoc_status_ioctl(wlan_private * priv, struct iwreq *wrq)
442{
443 char status[64];
444 wlan_adapter *adapter = priv->adapter;
445
446 memset(status, 0, sizeof(status));
447
448 switch (adapter->inframode) {
449 case wlan802_11ibss:
450 if (adapter->connect_status == libertas_connected) {
451 if (adapter->adhoccreate)
452 memcpy(&status, "AdhocStarted", sizeof(status));
453 else
454 memcpy(&status, "AdhocJoined", sizeof(status));
455 } else {
456 memcpy(&status, "AdhocIdle", sizeof(status));
457 }
458 break;
459 case wlan802_11infrastructure:
460 memcpy(&status, "Inframode", sizeof(status));
461 break;
462 default:
463 memcpy(&status, "AutoUnknownmode", sizeof(status));
464 break;
465 }
466
467 lbs_pr_debug(1, "status = %s\n", status);
468 wrq->u.data.length = strlen(status) + 1;
469
470 if (wrq->u.data.pointer) {
471 if (copy_to_user(wrq->u.data.pointer,
472 &status, wrq->u.data.length))
473 return -EFAULT;
474 }
475
476 LEAVE();
477 return 0;
478}
479
480/**
481 * @brief Set/Get WPA IE
482 * @param priv A pointer to wlan_private structure
483 * @param req A pointer to ifreq structure
484 * @return 0 --success, otherwise fail
485 */
486static int wlan_setwpaie_ioctl(wlan_private * priv, struct ifreq *req)
487{
488 struct iwreq *wrq = (struct iwreq *)req;
489 wlan_adapter *adapter = priv->adapter;
490 int ret = 0;
491
492 ENTER();
493
494 if (wrq->u.data.length) {
495 if (wrq->u.data.length > sizeof(adapter->wpa_ie)) {
496 lbs_pr_debug(1, "failed to copy WPA IE, too big \n");
497 return -EFAULT;
498 }
499 if (copy_from_user(adapter->wpa_ie, wrq->u.data.pointer,
500 wrq->u.data.length)) {
501 lbs_pr_debug(1, "failed to copy WPA IE \n");
502 return -EFAULT;
503 }
504 adapter->wpa_ie_len = wrq->u.data.length;
505 lbs_pr_debug(1, "Set wpa_ie_len=%d IE=%#x\n", adapter->wpa_ie_len,
506 adapter->wpa_ie[0]);
507 lbs_dbg_hex("wpa_ie", adapter->wpa_ie, adapter->wpa_ie_len);
508 if (adapter->wpa_ie[0] == WPA_IE)
509 adapter->secinfo.WPAenabled = 1;
510 else if (adapter->wpa_ie[0] == WPA2_IE)
511 adapter->secinfo.WPA2enabled = 1;
512 else {
513 adapter->secinfo.WPAenabled = 0;
514 adapter->secinfo.WPA2enabled = 0;
515 }
516 } else {
517 memset(adapter->wpa_ie, 0, sizeof(adapter->wpa_ie));
518 adapter->wpa_ie_len = wrq->u.data.length;
519 lbs_pr_debug(1, "Reset wpa_ie_len=%d IE=%#x\n",
520 adapter->wpa_ie_len, adapter->wpa_ie[0]);
521 adapter->secinfo.WPAenabled = 0;
522 adapter->secinfo.WPA2enabled = 0;
523 }
524
525 // enable/disable RSN in firmware if WPA is enabled/disabled
526 // depending on variable adapter->secinfo.WPAenabled is set or not
527 ret = libertas_prepare_and_send_command(priv, cmd_802_11_enable_rsn,
528 cmd_act_set, cmd_option_waitforrsp,
529 0, NULL);
530
531 LEAVE();
532 return ret;
533}
534
535/**
536 * @brief Set Auto prescan
537 * @param priv A pointer to wlan_private structure
538 * @param wrq A pointer to iwreq structure
539 * @return 0 --success, otherwise fail
540 */
541static int wlan_subcmd_setprescan_ioctl(wlan_private * priv, struct iwreq *wrq)
542{
543 int data;
544 wlan_adapter *adapter = priv->adapter;
545 int *val;
546
547 data = SUBCMD_DATA(wrq);
548 lbs_pr_debug(1, "WLAN_SUBCMD_SET_PRESCAN %d\n", data);
549 adapter->prescan = data;
550
551 val = (int *)wrq->u.name;
552 *val = data;
553 return 0;
554}
555
556static int wlan_set_multiple_dtim_ioctl(wlan_private * priv, struct ifreq *req)
557{
558 struct iwreq *wrq = (struct iwreq *)req;
559 u32 mdtim;
560 int idata;
561 int ret = -EINVAL;
562
563 ENTER();
564
565 idata = SUBCMD_DATA(wrq);
566 mdtim = (u32) idata;
567 if (((mdtim >= MRVDRV_MIN_MULTIPLE_DTIM)
568 && (mdtim <= MRVDRV_MAX_MULTIPLE_DTIM))
569 || (mdtim == MRVDRV_IGNORE_MULTIPLE_DTIM)) {
570 priv->adapter->multipledtim = mdtim;
571 ret = 0;
572 }
573 if (ret)
574 lbs_pr_debug(1, "Invalid parameter, multipledtim not changed.\n");
575
576 LEAVE();
577 return ret;
578}
579
580/**
581 * @brief Set authentication mode
582 * @param priv A pointer to wlan_private structure
583 * @param req A pointer to ifreq structure
584 * @return 0 --success, otherwise fail
585 */
586static int wlan_setauthalg_ioctl(wlan_private * priv, struct ifreq *req)
587{
588 int alg;
589 struct iwreq *wrq = (struct iwreq *)req;
590 wlan_adapter *adapter = priv->adapter;
591
592 if (wrq->u.data.flags == 0) {
593 //from iwpriv subcmd
594 alg = SUBCMD_DATA(wrq);
595 } else {
596 //from wpa_supplicant subcmd
597 if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(alg))) {
598 lbs_pr_debug(1, "Copy from user failed\n");
599 return -EFAULT;
600 }
601 }
602
603 lbs_pr_debug(1, "auth alg is %#x\n", alg);
604
605 switch (alg) {
606 case AUTH_ALG_SHARED_KEY:
607 adapter->secinfo.authmode = wlan802_11authmodeshared;
608 break;
609 case AUTH_ALG_NETWORK_EAP:
610 adapter->secinfo.authmode =
611 wlan802_11authmodenetworkEAP;
612 break;
613 case AUTH_ALG_OPEN_SYSTEM:
614 default:
615 adapter->secinfo.authmode = wlan802_11authmodeopen;
616 break;
617 }
618 return 0;
619}
620
621/**
622 * @brief Set 802.1x authentication mode
623 * @param priv A pointer to wlan_private structure
624 * @param req A pointer to ifreq structure
625 * @return 0 --success, otherwise fail
626 */
627static int wlan_set8021xauthalg_ioctl(wlan_private * priv, struct ifreq *req)
628{
629 int alg;
630 struct iwreq *wrq = (struct iwreq *)req;
631
632 if (wrq->u.data.flags == 0) {
633 //from iwpriv subcmd
634 alg = SUBCMD_DATA(wrq);
635 } else {
636 //from wpa_supplicant subcmd
637 if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(int))) {
638 lbs_pr_debug(1, "Copy from user failed\n");
639 return -EFAULT;
640 }
641 }
642 lbs_pr_debug(1, "802.1x auth alg is %#x\n", alg);
643 priv->adapter->secinfo.auth1xalg = alg;
644 return 0;
645}
646
647static int wlan_setencryptionmode_ioctl(wlan_private * priv, struct ifreq *req)
648{
649 int mode;
650 struct iwreq *wrq = (struct iwreq *)req;
651
652 ENTER();
653
654 if (wrq->u.data.flags == 0) {
655 //from iwpriv subcmd
656 mode = SUBCMD_DATA(wrq);
657 } else {
658 //from wpa_supplicant subcmd
659 if (copy_from_user(&mode, wrq->u.data.pointer, sizeof(int))) {
660 lbs_pr_debug(1, "Copy from user failed\n");
661 return -EFAULT;
662 }
663 }
664 lbs_pr_debug(1, "encryption mode is %#x\n", mode);
665 priv->adapter->secinfo.Encryptionmode = mode;
666
667 LEAVE();
668 return 0;
669}
670
671static void adjust_mtu(wlan_private * priv)
672{
673 int mtu_increment = 0;
674
675 if (priv->adapter->linkmode == WLAN_LINKMODE_802_11)
676 mtu_increment += sizeof(struct ieee80211_hdr_4addr);
677
678 if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP)
679 mtu_increment += max(sizeof(struct tx_radiotap_hdr),
680 sizeof(struct rx_radiotap_hdr));
681 priv->wlan_dev.netdev->mtu = ETH_FRAME_LEN
682 - sizeof(struct ethhdr)
683 + mtu_increment;
684}
685
686/**
687 * @brief Set Link-Layer Layer mode
688 * @param priv A pointer to wlan_private structure
689 * @param req A pointer to ifreq structure
690 * @return 0 --success, otherwise fail
691 */
692static int wlan_set_linkmode_ioctl(wlan_private * priv, struct ifreq *req)
693{
694 int mode;
695
696 mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data;
697
698 switch (mode) {
699 case WLAN_LINKMODE_802_3:
700 priv->adapter->linkmode = mode;
701 break;
702 case WLAN_LINKMODE_802_11:
703 priv->adapter->linkmode = mode;
704 break;
705 default:
706 lbs_pr_info("usb8388-5: invalid link-layer mode (%#x)\n",
707 mode);
708 return -EINVAL;
709 break;
710 }
711 lbs_pr_debug(1, "usb8388-5: link-layer mode is %#x\n", mode);
712
713 adjust_mtu(priv);
714
715 return 0;
716}
717
718/**
719 * @brief Set Radio header mode
720 * @param priv A pointer to wlan_private structure
721 * @param req A pointer to ifreq structure
722 * @return 0 --success, otherwise fail
723 */
724static int wlan_set_radiomode_ioctl(wlan_private * priv, struct ifreq *req)
725{
726 int mode;
727
728 mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data;
729
730 switch (mode) {
731 case WLAN_RADIOMODE_NONE:
732 priv->adapter->radiomode = mode;
733 break;
734 case WLAN_RADIOMODE_RADIOTAP:
735 priv->adapter->radiomode = mode;
736 break;
737 default:
738 lbs_pr_debug(1, "usb8388-5: invalid radio header mode (%#x)\n",
739 mode);
740 return -EINVAL;
741 }
742 lbs_pr_debug(1, "usb8388-5: radio-header mode is %#x\n", mode);
743
744 adjust_mtu(priv);
745 return 0;
746}
747
748/**
749 * @brief Set Debug header mode
750 * @param priv A pointer to wlan_private structure
751 * @param req A pointer to ifreq structure
752 * @return 0 --success, otherwise fail
753 */
754static int wlan_set_debugmode_ioctl(wlan_private * priv, struct ifreq *req)
755{
756 priv->adapter->debugmode = (int)((struct ifreq *)
757 ((u8 *) req + 4))->ifr_data;
758 return 0;
759}
760
761static int wlan_subcmd_getrxantenna_ioctl(wlan_private * priv,
762 struct ifreq *req)
763{
764 int len;
765 char buf[8];
766 struct iwreq *wrq = (struct iwreq *)req;
767
768 lbs_pr_debug(1, "WLAN_SUBCMD_GETRXANTENNA\n");
769 len = getrxantenna(priv, buf);
770
771 wrq->u.data.length = len;
772 if (wrq->u.data.pointer) {
773 if (copy_to_user(wrq->u.data.pointer, &buf, len)) {
774 lbs_pr_debug(1, "CopyToUser failed\n");
775 return -EFAULT;
776 }
777 }
778
779 return 0;
780}
781
782static int wlan_subcmd_gettxantenna_ioctl(wlan_private * priv,
783 struct ifreq *req)
784{
785 int len;
786 char buf[8];
787 struct iwreq *wrq = (struct iwreq *)req;
788
789 lbs_pr_debug(1, "WLAN_SUBCMD_GETTXANTENNA\n");
790 len = gettxantenna(priv, buf);
791
792 wrq->u.data.length = len;
793 if (wrq->u.data.pointer) {
794 if (copy_to_user(wrq->u.data.pointer, &buf, len)) {
795 lbs_pr_debug(1, "CopyToUser failed\n");
796 return -EFAULT;
797 }
798 }
799 return 0;
800}
801
802/**
803 * @brief Get the MAC TSF value from the firmware
804 *
805 * @param priv A pointer to wlan_private structure
806 * @param wrq A pointer to iwreq structure containing buffer
807 * space to store a TSF value retrieved from the firmware
808 *
809 * @return 0 if successful; IOCTL error code otherwise
810 */
811static int wlan_get_tsf_ioctl(wlan_private * priv, struct iwreq *wrq)
812{
813 u64 tsfval;
814 int ret;
815
816 ret = libertas_prepare_and_send_command(priv,
817 cmd_get_tsf,
818 0, cmd_option_waitforrsp, 0, &tsfval);
819
820 lbs_pr_debug(1, "IOCTL: Get TSF = 0x%016llx\n", tsfval);
821
822 if (ret != 0) {
823 lbs_pr_debug(1, "IOCTL: Get TSF; command exec failed\n");
824 ret = -EFAULT;
825 } else {
826 if (copy_to_user(wrq->u.data.pointer,
827 &tsfval,
828 min_t(size_t, wrq->u.data.length,
829 sizeof(tsfval))) != 0) {
830
831 lbs_pr_debug(1, "IOCTL: Get TSF; Copy to user failed\n");
832 ret = -EFAULT;
833 } else {
834 ret = 0;
835 }
836 }
837 return ret;
838}
839
840/**
841 * @brief Get/Set adapt rate
842 * @param priv A pointer to wlan_private structure
843 * @param wrq A pointer to iwreq structure
844 * @return 0 --success, otherwise fail
845 */
846static int wlan_adapt_rateset(wlan_private * priv, struct iwreq *wrq)
847{
848 int ret;
849 wlan_adapter *adapter = priv->adapter;
850 int data[2];
851
852 memset(data, 0, sizeof(data));
853 if (!wrq->u.data.length) {
854 lbs_pr_debug(1, "Get ADAPT RATE SET\n");
855 ret = libertas_prepare_and_send_command(priv,
856 cmd_802_11_rate_adapt_rateset,
857 cmd_act_get,
858 cmd_option_waitforrsp, 0, NULL);
859 data[0] = adapter->enablehwauto;
860 data[1] = adapter->ratebitmap;
861 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) {
862 lbs_pr_debug(1, "Copy to user failed\n");
863 return -EFAULT;
864 }
865#define GET_TWO_INT 2
866 wrq->u.data.length = GET_TWO_INT;
867 } else {
868 lbs_pr_debug(1, "Set ADAPT RATE SET\n");
869 if (wrq->u.data.length > 2)
870 return -EINVAL;
871 if (copy_from_user
872 (data, wrq->u.data.pointer,
873 sizeof(int) * wrq->u.data.length)) {
874 lbs_pr_debug(1, "Copy from user failed\n");
875 return -EFAULT;
876 }
877
878 adapter->enablehwauto = data[0];
879 adapter->ratebitmap = data[1];
880 ret = libertas_prepare_and_send_command(priv,
881 cmd_802_11_rate_adapt_rateset,
882 cmd_act_set,
883 cmd_option_waitforrsp, 0, NULL);
884 }
885 return ret;
886}
887
888/**
889 * @brief Get/Set inactivity timeout
890 * @param priv A pointer to wlan_private structure
891 * @param wrq A pointer to iwreq structure
892 * @return 0 --success, otherwise fail
893 */
894static int wlan_inactivity_timeout(wlan_private * priv, struct iwreq *wrq)
895{
896 int ret;
897 int data = 0;
898 u16 timeout = 0;
899
900 ENTER();
901 if (wrq->u.data.length > 1)
902 return -ENOTSUPP;
903
904 if (wrq->u.data.length == 0) {
905 /* Get */
906 ret = libertas_prepare_and_send_command(priv,
907 cmd_802_11_inactivity_timeout,
908 cmd_act_get,
909 cmd_option_waitforrsp, 0,
910 &timeout);
911 data = timeout;
912 if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) {
913 lbs_pr_debug(1, "Copy to user failed\n");
914 return -EFAULT;
915 }
916 } else {
917 /* Set */
918 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) {
919 lbs_pr_debug(1, "Copy from user failed\n");
920 return -EFAULT;
921 }
922
923 timeout = data;
924 ret = libertas_prepare_and_send_command(priv,
925 cmd_802_11_inactivity_timeout,
926 cmd_act_set,
927 cmd_option_waitforrsp, 0,
928 &timeout);
929 }
930
931 wrq->u.data.length = 1;
932
933 LEAVE();
934 return ret;
935}
936
937static int wlan_do_getlog_ioctl(wlan_private * priv, struct iwreq *wrq)
938{
939 int ret;
940 char buf[GETLOG_BUFSIZE - 1];
941 wlan_adapter *adapter = priv->adapter;
942
943 lbs_pr_debug(1, " GET STATS\n");
944
945 ret = libertas_prepare_and_send_command(priv, cmd_802_11_get_log,
946 0, cmd_option_waitforrsp, 0, NULL);
947
948 if (ret) {
949 return ret;
950 }
951
952 if (wrq->u.data.pointer) {
953 sprintf(buf, "\n mcasttxframe %u failed %u retry %u "
954 "multiretry %u framedup %u "
955 "rtssuccess %u rtsfailure %u ackfailure %u\n"
956 "rxfrag %u mcastrxframe %u fcserror %u "
957 "txframe %u wepundecryptable %u ",
958 adapter->logmsg.mcasttxframe,
959 adapter->logmsg.failed,
960 adapter->logmsg.retry,
961 adapter->logmsg.multiretry,
962 adapter->logmsg.framedup,
963 adapter->logmsg.rtssuccess,
964 adapter->logmsg.rtsfailure,
965 adapter->logmsg.ackfailure,
966 adapter->logmsg.rxfrag,
967 adapter->logmsg.mcastrxframe,
968 adapter->logmsg.fcserror,
969 adapter->logmsg.txframe,
970 adapter->logmsg.wepundecryptable);
971 wrq->u.data.length = strlen(buf) + 1;
972 if (copy_to_user(wrq->u.data.pointer, buf, wrq->u.data.length)) {
973 lbs_pr_debug(1, "Copy to user failed\n");
974 return -EFAULT;
975 }
976 }
977
978 return 0;
979}
980
981static int wlan_scan_type_ioctl(wlan_private * priv, struct iwreq *wrq)
982{
983 u8 buf[12];
984 u8 *option[] = { "active", "passive", "get", };
985 int i, max_options = (sizeof(option) / sizeof(option[0]));
986 int ret = 0;
987 wlan_adapter *adapter = priv->adapter;
988
989 if (priv->adapter->enable11d) {
990 lbs_pr_debug(1, "11D: Cannot set scantype when 11D enabled\n");
991 return -EFAULT;
992 }
993
994 memset(buf, 0, sizeof(buf));
995
996 if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf),
997 wrq->u.data.length)))
998 return -EFAULT;
999
1000 lbs_pr_debug(1, "Scan type Option = %s\n", buf);
1001
1002 buf[sizeof(buf) - 1] = '\0';
1003
1004 for (i = 0; i < max_options; i++) {
1005 if (!strcmp(buf, option[i]))
1006 break;
1007 }
1008
1009 switch (i) {
1010 case 0:
1011 adapter->scantype = cmd_scan_type_active;
1012 break;
1013 case 1:
1014 adapter->scantype = cmd_scan_type_passive;
1015 break;
1016 case 2:
1017 wrq->u.data.length = strlen(option[adapter->scantype]) + 1;
1018
1019 if (copy_to_user(wrq->u.data.pointer,
1020 option[adapter->scantype],
1021 wrq->u.data.length)) {
1022 lbs_pr_debug(1, "Copy to user failed\n");
1023 ret = -EFAULT;
1024 }
1025
1026 break;
1027 default:
1028 lbs_pr_debug(1, "Invalid Scan type Ioctl Option\n");
1029 ret = -EINVAL;
1030 break;
1031 }
1032
1033 return ret;
1034}
1035
1036static int wlan_scan_mode_ioctl(wlan_private * priv, struct iwreq *wrq)
1037{
1038 wlan_adapter *adapter = priv->adapter;
1039 u8 buf[12];
1040 u8 *option[] = { "bss", "ibss", "any", "get" };
1041 int i, max_options = (sizeof(option) / sizeof(option[0]));
1042 int ret = 0;
1043
1044 ENTER();
1045
1046 memset(buf, 0, sizeof(buf));
1047
1048 if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf),
1049 wrq->u.data.length))) {
1050 lbs_pr_debug(1, "Copy from user failed\n");
1051 return -EFAULT;
1052 }
1053
1054 lbs_pr_debug(1, "Scan mode Option = %s\n", buf);
1055
1056 buf[sizeof(buf) - 1] = '\0';
1057
1058 for (i = 0; i < max_options; i++) {
1059 if (!strcmp(buf, option[i]))
1060 break;
1061 }
1062
1063 switch (i) {
1064
1065 case 0:
1066 adapter->scanmode = cmd_bss_type_bss;
1067 break;
1068 case 1:
1069 adapter->scanmode = cmd_bss_type_ibss;
1070 break;
1071 case 2:
1072 adapter->scanmode = cmd_bss_type_any;
1073 break;
1074 case 3:
1075
1076 wrq->u.data.length = strlen(option[adapter->scanmode - 1]) + 1;
1077
1078 lbs_pr_debug(1, "Get Scan mode Option = %s\n",
1079 option[adapter->scanmode - 1]);
1080
1081 lbs_pr_debug(1, "Scan mode length %d\n", wrq->u.data.length);
1082
1083 if (copy_to_user(wrq->u.data.pointer,
1084 option[adapter->scanmode - 1],
1085 wrq->u.data.length)) {
1086 lbs_pr_debug(1, "Copy to user failed\n");
1087 ret = -EFAULT;
1088 }
1089 lbs_pr_debug(1, "GET Scan type Option after copy = %s\n",
1090 (char *)wrq->u.data.pointer);
1091
1092 break;
1093
1094 default:
1095 lbs_pr_debug(1, "Invalid Scan mode Ioctl Option\n");
1096 ret = -EINVAL;
1097 break;
1098 }
1099
1100 LEAVE();
1101 return ret;
1102}
1103
1104/**
1105 * @brief Get/Set Adhoc G Rate
1106 *
1107 * @param priv A pointer to wlan_private structure
1108 * @param wrq A pointer to user data
1109 * @return 0--success, otherwise fail
1110 */
1111static int wlan_do_set_grate_ioctl(wlan_private * priv, struct iwreq *wrq)
1112{
1113 wlan_adapter *adapter = priv->adapter;
1114 int data, data1;
1115 int *val;
1116
1117 ENTER();
1118
1119 data1 = SUBCMD_DATA(wrq);
1120 switch (data1) {
1121 case 0:
1122 adapter->adhoc_grate_enabled = 0;
1123 break;
1124 case 1:
1125 adapter->adhoc_grate_enabled = 1;
1126 break;
1127 case 2:
1128 break;
1129 default:
1130 return -EINVAL;
1131 }
1132 data = adapter->adhoc_grate_enabled;
1133 val = (int *)wrq->u.name;
1134 *val = data;
1135 LEAVE();
1136 return 0;
1137}
1138
1139static inline int hex2int(char c) 58static inline int hex2int(char c)
1140{ 59{
1141 if (c >= '0' && c <= '9') 60 if (c >= '0' && c <= '9')
@@ -1761,6 +680,7 @@ static int wlan_fwt_list_neighbor_ioctl(wlan_private * priv, struct ifreq *req)
1761 */ 680 */
1762static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) 681static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
1763{ 682{
683 struct iwreq *wrq = (struct iwreq *)req;
1764 static struct cmd_ds_fwt_access fwt_access; 684 static struct cmd_ds_fwt_access fwt_access;
1765 int ret; 685 int ret;
1766 686
@@ -1776,7 +696,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
1776 (void *)&fwt_access); 696 (void *)&fwt_access);
1777 697
1778 if (ret == 0) 698 if (ret == 0)
1779 req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); 699 wrq->u.param.value = le32_to_cpu(fwt_access.references);
1780 else 700 else
1781 return -EFAULT; 701 return -EFAULT;
1782 702
@@ -1792,6 +712,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
1792 */ 712 */
1793static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) 713static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
1794{ 714{
715 struct iwreq *wrq = (struct iwreq *)req;
1795 static struct cmd_ds_fwt_access fwt_access; 716 static struct cmd_ds_fwt_access fwt_access;
1796 int ret; 717 int ret;
1797 718
@@ -1807,7 +728,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
1807 (void *)&fwt_access); 728 (void *)&fwt_access);
1808 729
1809 if (ret == 0) 730 if (ret == 0)
1810 req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); 731 wrq->u.param.value = le32_to_cpu(fwt_access.references);
1811 else 732 else
1812 return -EFAULT; 733 return -EFAULT;
1813 734
@@ -1823,6 +744,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
1823 */ 744 */
1824static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) 745static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req)
1825{ 746{
747 struct iwreq *wrq = (struct iwreq *)req;
1826 struct cmd_ds_mesh_access mesh_access; 748 struct cmd_ds_mesh_access mesh_access;
1827 int ret; 749 int ret;
1828 750
@@ -1835,9 +757,8 @@ static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req)
1835 cmd_option_waitforrsp, 0, 757 cmd_option_waitforrsp, 0,
1836 (void *)&mesh_access); 758 (void *)&mesh_access);
1837 759
1838 if (ret == 0) { 760 if (ret == 0)
1839 req->ifr_data = (char *)(le32_to_cpu(mesh_access.data[0])); 761 wrq->u.param.value = le32_to_cpu(mesh_access.data[0]);
1840 }
1841 else 762 else
1842 return -EFAULT; 763 return -EFAULT;
1843 764
@@ -1898,36 +819,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1898 819
1899 lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); 820 lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd);
1900 switch (cmd) { 821 switch (cmd) {
1901 case WLANSCAN_TYPE:
1902 lbs_pr_debug(1, "Scan type Ioctl\n");
1903 ret = wlan_scan_type_ioctl(priv, wrq);
1904 break;
1905
1906 case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ 822 case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */
1907 switch (wrq->u.data.flags) { 823 switch (wrq->u.data.flags) {
1908 case WLANDEAUTH:
1909 lbs_pr_debug(1, "Deauth\n");
1910 libertas_send_deauth(priv);
1911 break;
1912
1913 case WLANADHOCSTOP:
1914 lbs_pr_debug(1, "Adhoc stop\n");
1915 ret = libertas_do_adhocstop_ioctl(priv);
1916 break;
1917
1918 case WLANRADIOON:
1919 wlan_radio_ioctl(priv, 1);
1920 break;
1921
1922 case WLANRADIOOFF:
1923 wlan_radio_ioctl(priv, 0);
1924 break;
1925 case WLANWLANIDLEON:
1926 libertas_idle_on(priv);
1927 break;
1928 case WLANWLANIDLEOFF:
1929 libertas_idle_off(priv);
1930 break;
1931 case WLAN_SUBCMD_BT_RESET: /* bt_reset */ 824 case WLAN_SUBCMD_BT_RESET: /* bt_reset */
1932 wlan_bt_reset_ioctl(priv); 825 wlan_bt_reset_ioctl(priv);
1933 break; 826 break;
@@ -1937,162 +830,19 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1937 } /* End of switch */ 830 } /* End of switch */
1938 break; 831 break;
1939 832
1940 case WLANSETWPAIE:
1941 ret = wlan_setwpaie_ioctl(priv, req);
1942 break;
1943 case WLAN_SETINT_GETINT:
1944 /* The first 4 bytes of req->ifr_data is sub-ioctl number
1945 * after 4 bytes sits the payload.
1946 */
1947 subcmd = (int)req->ifr_data; //from iwpriv subcmd
1948 switch (subcmd) {
1949 case WLANNF:
1950 ret = wlan_get_nf(priv, wrq);
1951 break;
1952 case WLANRSSI:
1953 ret = wlan_get_rssi(priv, wrq);
1954 break;
1955 case WLANENABLE11D:
1956 ret = libertas_cmd_enable_11d(priv, wrq);
1957 break;
1958 case WLANADHOCGRATE:
1959 ret = wlan_do_set_grate_ioctl(priv, wrq);
1960 break;
1961 case WLAN_SUBCMD_SET_PRESCAN:
1962 ret = wlan_subcmd_setprescan_ioctl(priv, wrq);
1963 break;
1964 }
1965 break;
1966
1967 case WLAN_SETONEINT_GETONEINT:
1968 switch (wrq->u.data.flags) {
1969 case WLAN_BEACON_INTERVAL:
1970 ret = wlan_beacon_interval(priv, wrq);
1971 break;
1972
1973 case WLAN_LISTENINTRVL:
1974 if (!wrq->u.data.length) {
1975 int data;
1976 lbs_pr_debug(1, "Get locallisteninterval value\n");
1977#define GET_ONE_INT 1
1978 data = adapter->locallisteninterval;
1979 if (copy_to_user(wrq->u.data.pointer,
1980 &data, sizeof(int))) {
1981 lbs_pr_debug(1, "Copy to user failed\n");
1982 return -EFAULT;
1983 }
1984
1985 wrq->u.data.length = GET_ONE_INT;
1986 } else {
1987 int data;
1988 if (copy_from_user
1989 (&data, wrq->u.data.pointer, sizeof(int))) {
1990 lbs_pr_debug(1, "Copy from user failed\n");
1991 return -EFAULT;
1992 }
1993
1994 lbs_pr_debug(1, "Set locallisteninterval = %d\n",
1995 data);
1996#define MAX_U16_VAL 65535
1997 if (data > MAX_U16_VAL) {
1998 lbs_pr_debug(1, "Exceeds U16 value\n");
1999 return -EINVAL;
2000 }
2001 adapter->locallisteninterval = data;
2002 }
2003 break;
2004 case WLAN_TXCONTROL:
2005 ret = wlan_txcontrol(priv, wrq); //adds for txcontrol ioctl
2006 break;
2007
2008 case WLAN_NULLPKTINTERVAL:
2009 ret = wlan_null_pkt_interval(priv, wrq);
2010 break;
2011
2012 default:
2013 ret = -EOPNOTSUPP;
2014 break;
2015 }
2016 break;
2017
2018 case WLAN_SETONEINT_GETNONE: 833 case WLAN_SETONEINT_GETNONE:
2019 /* The first 4 bytes of req->ifr_data is sub-ioctl number 834 /* The first 4 bytes of req->ifr_data is sub-ioctl number
2020 * after 4 bytes sits the payload. 835 * after 4 bytes sits the payload.
2021 */ 836 */
2022 subcmd = wrq->u.data.flags; //from wpa_supplicant subcmd 837 subcmd = wrq->u.data.flags;
2023
2024 if (!subcmd) 838 if (!subcmd)
2025 subcmd = (int)req->ifr_data; //from iwpriv subcmd 839 subcmd = (int)wrq->u.param.value;
2026 840
2027 switch (subcmd) { 841 switch (subcmd) {
2028 case WLAN_SUBCMD_SETRXANTENNA: /* SETRXANTENNA */
2029 idata = SUBCMD_DATA(wrq);
2030 ret = setrxantenna(priv, idata);
2031 break;
2032 case WLAN_SUBCMD_SETTXANTENNA: /* SETTXANTENNA */
2033 idata = SUBCMD_DATA(wrq);
2034 ret = settxantenna(priv, idata);
2035 break;
2036 case WLAN_SET_ATIM_WINDOW:
2037 adapter->atimwindow = SUBCMD_DATA(wrq);
2038 adapter->atimwindow = min_t(__u16, adapter->atimwindow, 50);
2039 break;
2040 case WLANSETBCNAVG:
2041 adapter->bcn_avg_factor = SUBCMD_DATA(wrq);
2042 if (adapter->bcn_avg_factor == 0)
2043 adapter->bcn_avg_factor =
2044 DEFAULT_BCN_AVG_FACTOR;
2045 if (adapter->bcn_avg_factor > DEFAULT_BCN_AVG_FACTOR)
2046 adapter->bcn_avg_factor =
2047 DEFAULT_BCN_AVG_FACTOR;
2048 break;
2049 case WLANSETDATAAVG:
2050 adapter->data_avg_factor = SUBCMD_DATA(wrq);
2051 if (adapter->data_avg_factor == 0)
2052 adapter->data_avg_factor =
2053 DEFAULT_DATA_AVG_FACTOR;
2054 if (adapter->data_avg_factor > DEFAULT_DATA_AVG_FACTOR)
2055 adapter->data_avg_factor =
2056 DEFAULT_DATA_AVG_FACTOR;
2057 break;
2058 case WLANSETREGION: 842 case WLANSETREGION:
2059 idata = SUBCMD_DATA(wrq); 843 idata = SUBCMD_DATA(wrq);
2060 ret = wlan_set_region(priv, (u16) idata); 844 ret = wlan_set_region(priv, (u16) idata);
2061 break; 845 break;
2062
2063 case WLAN_SET_LISTEN_INTERVAL:
2064 idata = SUBCMD_DATA(wrq);
2065 adapter->listeninterval = (u16) idata;
2066 break;
2067
2068 case WLAN_SET_MULTIPLE_DTIM:
2069 ret = wlan_set_multiple_dtim_ioctl(priv, req);
2070 break;
2071
2072 case WLANSETAUTHALG:
2073 ret = wlan_setauthalg_ioctl(priv, req);
2074 break;
2075
2076 case WLANSET8021XAUTHALG:
2077 ret = wlan_set8021xauthalg_ioctl(priv, req);
2078 break;
2079
2080 case WLANSETENCRYPTIONMODE:
2081 ret = wlan_setencryptionmode_ioctl(priv, req);
2082 break;
2083
2084 case WLAN_SET_LINKMODE:
2085 ret = wlan_set_linkmode_ioctl(priv, req);
2086 break;
2087
2088 case WLAN_SET_RADIOMODE:
2089 ret = wlan_set_radiomode_ioctl(priv, req);
2090 break;
2091
2092 case WLAN_SET_DEBUGMODE:
2093 ret = wlan_set_debugmode_ioctl(priv, req);
2094 break;
2095
2096 case WLAN_SUBCMD_MESH_SET_TTL: 846 case WLAN_SUBCMD_MESH_SET_TTL:
2097 idata = SUBCMD_DATA(wrq); 847 idata = SUBCMD_DATA(wrq);
2098 ret = wlan_mesh_set_ttl_ioctl(priv, idata); 848 ret = wlan_mesh_set_ttl_ioctl(priv, idata);
@@ -2105,38 +855,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2105 855
2106 break; 856 break;
2107 857
2108 case WLAN_SETNONE_GETTWELVE_CHAR: /* Get Antenna settings */
2109 /*
2110 * We've not used IW_PRIV_TYPE_FIXED so sub-ioctl number is
2111 * in flags of iwreq structure, otherwise it will be in
2112 * mode member of iwreq structure.
2113 */
2114 switch ((int)wrq->u.data.flags) {
2115 case WLAN_SUBCMD_GETRXANTENNA: /* Get Rx Antenna */
2116 ret = wlan_subcmd_getrxantenna_ioctl(priv, req);
2117 break;
2118
2119 case WLAN_SUBCMD_GETTXANTENNA: /* Get Tx Antenna */
2120 ret = wlan_subcmd_gettxantenna_ioctl(priv, req);
2121 break;
2122
2123 case WLAN_GET_TSF:
2124 ret = wlan_get_tsf_ioctl(priv, wrq);
2125 break;
2126 }
2127 break;
2128
2129 case WLAN_SET128CHAR_GET128CHAR: 858 case WLAN_SET128CHAR_GET128CHAR:
2130 switch ((int)wrq->u.data.flags) { 859 switch ((int)wrq->u.data.flags) {
2131
2132 case WLANSCAN_MODE:
2133 lbs_pr_debug(1, "Scan mode Ioctl\n");
2134 ret = wlan_scan_mode_ioctl(priv, wrq);
2135 break;
2136
2137 case WLAN_GET_ADHOC_STATUS:
2138 ret = wlan_get_adhoc_status_ioctl(priv, wrq);
2139 break;
2140 case WLAN_SUBCMD_BT_ADD: 860 case WLAN_SUBCMD_BT_ADD:
2141 ret = wlan_bt_add_ioctl(priv, req); 861 ret = wlan_bt_add_ioctl(priv, req);
2142 break; 862 break;
@@ -2168,41 +888,11 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2168 break; 888 break;
2169 889
2170 case WLAN_SETNONE_GETONEINT: 890 case WLAN_SETNONE_GETONEINT:
2171 switch ((int)req->ifr_data) { 891 switch (wrq->u.param.value) {
2172 case WLANGETBCNAVG:
2173 pdata = (int *)wrq->u.name;
2174 *pdata = (int)adapter->bcn_avg_factor;
2175 break;
2176
2177 case WLANGETREGION: 892 case WLANGETREGION:
2178 pdata = (int *)wrq->u.name; 893 pdata = (int *)wrq->u.name;
2179 *pdata = (int)adapter->regioncode; 894 *pdata = (int)adapter->regioncode;
2180 break; 895 break;
2181
2182 case WLAN_GET_LISTEN_INTERVAL:
2183 pdata = (int *)wrq->u.name;
2184 *pdata = (int)adapter->listeninterval;
2185 break;
2186
2187 case WLAN_GET_LINKMODE:
2188 req->ifr_data = (char *)((u32) adapter->linkmode);
2189 break;
2190
2191 case WLAN_GET_RADIOMODE:
2192 req->ifr_data = (char *)((u32) adapter->radiomode);
2193 break;
2194
2195 case WLAN_GET_DEBUGMODE:
2196 req->ifr_data = (char *)((u32) adapter->debugmode);
2197 break;
2198
2199 case WLAN_GET_MULTIPLE_DTIM:
2200 pdata = (int *)wrq->u.name;
2201 *pdata = (int)adapter->multipledtim;
2202 break;
2203 case WLAN_GET_TX_RATE:
2204 ret = wlan_get_txrate_ioctl(priv, req);
2205 break;
2206 case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ 896 case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */
2207 ret = wlan_fwt_cleanup_ioctl(priv, req); 897 ret = wlan_fwt_cleanup_ioctl(priv, req);
2208 break; 898 break;
@@ -2222,196 +912,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2222 912
2223 break; 913 break;
2224 914
2225 case WLANGETLOG:
2226 ret = wlan_do_getlog_ioctl(priv, wrq);
2227 break;
2228
2229 case WLAN_SET_GET_SIXTEEN_INT: 915 case WLAN_SET_GET_SIXTEEN_INT:
2230 switch ((int)wrq->u.data.flags) { 916 switch ((int)wrq->u.data.flags) {
2231 case WLAN_TPCCFG:
2232 {
2233 int data[5];
2234 struct cmd_ds_802_11_tpc_cfg cfg;
2235 memset(&cfg, 0, sizeof(cfg));
2236 if ((wrq->u.data.length > 1)
2237 && (wrq->u.data.length != 5))
2238 return -1;
2239
2240 if (wrq->u.data.length == 0) {
2241 cfg.action =
2242 cpu_to_le16
2243 (cmd_act_get);
2244 } else {
2245 if (copy_from_user
2246 (data, wrq->u.data.pointer,
2247 sizeof(int) * 5)) {
2248 lbs_pr_debug(1,
2249 "Copy from user failed\n");
2250 return -EFAULT;
2251 }
2252
2253 cfg.action =
2254 cpu_to_le16
2255 (cmd_act_set);
2256 cfg.enable = data[0];
2257 cfg.usesnr = data[1];
2258 cfg.P0 = data[2];
2259 cfg.P1 = data[3];
2260 cfg.P2 = data[4];
2261 }
2262
2263 ret =
2264 libertas_prepare_and_send_command(priv,
2265 cmd_802_11_tpc_cfg,
2266 0,
2267 cmd_option_waitforrsp,
2268 0, (void *)&cfg);
2269
2270 data[0] = cfg.enable;
2271 data[1] = cfg.usesnr;
2272 data[2] = cfg.P0;
2273 data[3] = cfg.P1;
2274 data[4] = cfg.P2;
2275 if (copy_to_user
2276 (wrq->u.data.pointer, data,
2277 sizeof(int) * 5)) {
2278 lbs_pr_debug(1, "Copy to user failed\n");
2279 return -EFAULT;
2280 }
2281
2282 wrq->u.data.length = 5;
2283 }
2284 break;
2285
2286 case WLAN_POWERCFG:
2287 {
2288 int data[4];
2289 struct cmd_ds_802_11_pwr_cfg cfg;
2290 memset(&cfg, 0, sizeof(cfg));
2291 if ((wrq->u.data.length > 1)
2292 && (wrq->u.data.length != 4))
2293 return -1;
2294 if (wrq->u.data.length == 0) {
2295 cfg.action =
2296 cpu_to_le16
2297 (cmd_act_get);
2298 } else {
2299 if (copy_from_user
2300 (data, wrq->u.data.pointer,
2301 sizeof(int) * 4)) {
2302 lbs_pr_debug(1,
2303 "Copy from user failed\n");
2304 return -EFAULT;
2305 }
2306
2307 cfg.action =
2308 cpu_to_le16
2309 (cmd_act_set);
2310 cfg.enable = data[0];
2311 cfg.PA_P0 = data[1];
2312 cfg.PA_P1 = data[2];
2313 cfg.PA_P2 = data[3];
2314 }
2315 ret =
2316 libertas_prepare_and_send_command(priv,
2317 cmd_802_11_pwr_cfg,
2318 0,
2319 cmd_option_waitforrsp,
2320 0, (void *)&cfg);
2321 data[0] = cfg.enable;
2322 data[1] = cfg.PA_P0;
2323 data[2] = cfg.PA_P1;
2324 data[3] = cfg.PA_P2;
2325 if (copy_to_user
2326 (wrq->u.data.pointer, data,
2327 sizeof(int) * 4)) {
2328 lbs_pr_debug(1, "Copy to user failed\n");
2329 return -EFAULT;
2330 }
2331
2332 wrq->u.data.length = 4;
2333 }
2334 break;
2335 case WLAN_AUTO_FREQ_SET:
2336 {
2337 int data[3];
2338 struct cmd_ds_802_11_afc afc;
2339 memset(&afc, 0, sizeof(afc));
2340 if (wrq->u.data.length != 3)
2341 return -1;
2342 if (copy_from_user
2343 (data, wrq->u.data.pointer,
2344 sizeof(int) * 3)) {
2345 lbs_pr_debug(1, "Copy from user failed\n");
2346 return -EFAULT;
2347 }
2348 afc.afc_auto = data[0];
2349
2350 if (afc.afc_auto != 0) {
2351 afc.threshold = data[1];
2352 afc.period = data[2];
2353 } else {
2354 afc.timing_offset = data[1];
2355 afc.carrier_offset = data[2];
2356 }
2357 ret =
2358 libertas_prepare_and_send_command(priv,
2359 cmd_802_11_set_afc,
2360 0,
2361 cmd_option_waitforrsp,
2362 0, (void *)&afc);
2363 }
2364 break;
2365 case WLAN_AUTO_FREQ_GET:
2366 {
2367 int data[3];
2368 struct cmd_ds_802_11_afc afc;
2369 memset(&afc, 0, sizeof(afc));
2370 ret =
2371 libertas_prepare_and_send_command(priv,
2372 cmd_802_11_get_afc,
2373 0,
2374 cmd_option_waitforrsp,
2375 0, (void *)&afc);
2376 data[0] = afc.afc_auto;
2377 data[1] = afc.timing_offset;
2378 data[2] = afc.carrier_offset;
2379 if (copy_to_user
2380 (wrq->u.data.pointer, data,
2381 sizeof(int) * 3)) {
2382 lbs_pr_debug(1, "Copy to user failed\n");
2383 return -EFAULT;
2384 }
2385
2386 wrq->u.data.length = 3;
2387 }
2388 break;
2389 case WLAN_SCANPROBES:
2390 {
2391 int data;
2392 if (wrq->u.data.length > 0) {
2393 if (copy_from_user
2394 (&data, wrq->u.data.pointer,
2395 sizeof(int))) {
2396 lbs_pr_debug(1,
2397 "Copy from user failed\n");
2398 return -EFAULT;
2399 }
2400
2401 adapter->scanprobes = data;
2402 } else {
2403 data = adapter->scanprobes;
2404 if (copy_to_user
2405 (wrq->u.data.pointer, &data,
2406 sizeof(int))) {
2407 lbs_pr_debug(1,
2408 "Copy to user failed\n");
2409 return -EFAULT;
2410 }
2411 }
2412 wrq->u.data.length = 1;
2413 }
2414 break;
2415 case WLAN_LED_GPIO_CTRL: 917 case WLAN_LED_GPIO_CTRL:
2416 { 918 {
2417 int i; 919 int i;
@@ -2475,17 +977,6 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2475 wrq->u.data.length = gpio->header.len; 977 wrq->u.data.length = gpio->header.len;
2476 } 978 }
2477 break; 979 break;
2478 case WLAN_ADAPT_RATESET:
2479 ret = wlan_adapt_rateset(priv, wrq);
2480 break;
2481 case WLAN_INACTIVITY_TIMEOUT:
2482 ret = wlan_inactivity_timeout(priv, wrq);
2483 break;
2484 case WLANSNR:
2485 ret = wlan_get_snr(priv, wrq);
2486 break;
2487 case WLAN_GET_RXINFO:
2488 ret = wlan_get_rxinfo(priv, wrq);
2489 } 980 }
2490 break; 981 break;
2491 982
diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c
index 11682cbe752b..d4926b83e145 100644
--- a/drivers/net/wireless/libertas/join.c
+++ b/drivers/net/wireless/libertas/join.c
@@ -15,6 +15,8 @@
15#include "join.h" 15#include "join.h"
16#include "dev.h" 16#include "dev.h"
17 17
18#define AD_HOC_CAP_PRIVACY_ON 1
19
18/** 20/**
19 * @brief This function finds out the common rates between rate1 and rate2. 21 * @brief This function finds out the common rates between rate1 and rate2.
20 * 22 *
@@ -85,7 +87,7 @@ int libertas_send_deauth(wlan_private * priv)
85 wlan_adapter *adapter = priv->adapter; 87 wlan_adapter *adapter = priv->adapter;
86 int ret = 0; 88 int ret = 0;
87 89
88 if (adapter->inframode == wlan802_11infrastructure && 90 if (adapter->mode == IW_MODE_INFRA &&
89 adapter->connect_status == libertas_connected) 91 adapter->connect_status == libertas_connected)
90 ret = libertas_send_deauthentication(priv); 92 ret = libertas_send_deauthentication(priv);
91 else 93 else
@@ -94,20 +96,6 @@ int libertas_send_deauth(wlan_private * priv)
94 return ret; 96 return ret;
95} 97}
96 98
97int libertas_do_adhocstop_ioctl(wlan_private * priv)
98{
99 wlan_adapter *adapter = priv->adapter;
100 int ret = 0;
101
102 if (adapter->inframode == wlan802_11ibss &&
103 adapter->connect_status == libertas_connected)
104 ret = libertas_stop_adhoc_network(priv);
105 else
106 ret = -ENOTSUPP;
107
108 return ret;
109}
110
111/** 99/**
112 * @brief Associate to a specific BSS discovered in a scan 100 * @brief Associate to a specific BSS discovered in a scan
113 * 101 *
@@ -207,8 +195,7 @@ int libertas_join_adhoc_network(wlan_private * priv, struct bss_descriptor * pbs
207 /* check if the requested SSID is already joined */ 195 /* check if the requested SSID is already joined */
208 if (adapter->curbssparams.ssid.ssidlength 196 if (adapter->curbssparams.ssid.ssidlength
209 && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) 197 && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid)
210 && (adapter->curbssparams.bssdescriptor.inframode == 198 && (adapter->mode == IW_MODE_ADHOC)) {
211 wlan802_11ibss)) {
212 199
213 lbs_pr_debug(1, 200 lbs_pr_debug(1,
214 "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " 201 "ADHOC_J_CMD: New ad-hoc SSID is the same as current, "
@@ -261,130 +248,6 @@ int libertas_send_deauthentication(wlan_private * priv)
261} 248}
262 249
263/** 250/**
264 * @brief Set Idle Off
265 *
266 * @param priv A pointer to wlan_private structure
267 * @return 0 --success, otherwise fail
268 */
269int libertas_idle_off(wlan_private * priv)
270{
271 wlan_adapter *adapter = priv->adapter;
272 int ret = 0;
273 const u8 zeromac[] = { 0, 0, 0, 0, 0, 0 };
274 int i;
275
276 ENTER();
277
278 if (adapter->connect_status == libertas_disconnected) {
279 if (adapter->inframode == wlan802_11infrastructure) {
280 if (memcmp(adapter->previousbssid, zeromac,
281 sizeof(zeromac)) != 0) {
282
283 lbs_pr_debug(1, "Previous SSID = %s\n",
284 adapter->previousssid.ssid);
285 lbs_pr_debug(1, "Previous BSSID = "
286 "%02x:%02x:%02x:%02x:%02x:%02x:\n",
287 adapter->previousbssid[0],
288 adapter->previousbssid[1],
289 adapter->previousbssid[2],
290 adapter->previousbssid[3],
291 adapter->previousbssid[4],
292 adapter->previousbssid[5]);
293
294 i = libertas_find_SSID_in_list(adapter,
295 &adapter->previousssid,
296 adapter->previousbssid,
297 adapter->inframode);
298
299 if (i < 0) {
300 libertas_send_specific_BSSID_scan(priv,
301 adapter->
302 previousbssid,
303 1);
304 i = libertas_find_SSID_in_list(adapter,
305 &adapter->
306 previousssid,
307 adapter->
308 previousbssid,
309 adapter->
310 inframode);
311 }
312
313 if (i < 0) {
314 /* If the BSSID could not be found, try just the SSID */
315 i = libertas_find_SSID_in_list(adapter,
316 &adapter->
317 previousssid, NULL,
318 adapter->
319 inframode);
320 }
321
322 if (i < 0) {
323 libertas_send_specific_SSID_scan(priv,
324 &adapter->
325 previousssid,
326 1);
327 i = libertas_find_SSID_in_list(adapter,
328 &adapter->
329 previousssid, NULL,
330 adapter->
331 inframode);
332 }
333
334 if (i >= 0) {
335 ret =
336 wlan_associate(priv,
337 &adapter->
338 scantable[i]);
339 }
340 }
341 } else if (adapter->inframode == wlan802_11ibss) {
342 ret = libertas_prepare_and_send_command(priv,
343 cmd_802_11_ad_hoc_start,
344 0,
345 cmd_option_waitforrsp,
346 0, &adapter->previousssid);
347 }
348 }
349 /* else it is connected */
350
351 lbs_pr_debug(1, "\nwlanidle is off");
352 LEAVE();
353 return ret;
354}
355
356/**
357 * @brief Set Idle On
358 *
359 * @param priv A pointer to wlan_private structure
360 * @return 0 --success, otherwise fail
361 */
362int libertas_idle_on(wlan_private * priv)
363{
364 wlan_adapter *adapter = priv->adapter;
365 int ret = 0;
366
367 if (adapter->connect_status == libertas_connected) {
368 if (adapter->inframode == wlan802_11infrastructure) {
369 lbs_pr_debug(1, "Previous SSID = %s\n",
370 adapter->previousssid.ssid);
371 memmove(&adapter->previousssid,
372 &adapter->curbssparams.ssid,
373 sizeof(struct WLAN_802_11_SSID));
374 libertas_send_deauth(priv);
375
376 } else if (adapter->inframode == wlan802_11ibss) {
377 ret = libertas_stop_adhoc_network(priv);
378 }
379
380 }
381
382 lbs_pr_debug(1, "\nwlanidle is on");
383
384 return ret;
385}
386
387/**
388 * @brief This function prepares command of authenticate. 251 * @brief This function prepares command of authenticate.
389 * 252 *
390 * @param priv A pointer to wlan_private structure 253 * @param priv A pointer to wlan_private structure
@@ -398,22 +261,39 @@ int libertas_cmd_80211_authenticate(wlan_private * priv,
398 void *pdata_buf) 261 void *pdata_buf)
399{ 262{
400 wlan_adapter *adapter = priv->adapter; 263 wlan_adapter *adapter = priv->adapter;
401 struct cmd_ds_802_11_authenticate *pauthenticate = 264 struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth;
402 &cmd->params.auth; 265 int ret = -1;
403 u8 *bssid = pdata_buf; 266 u8 *bssid = pdata_buf;
404 267
405 cmd->command = cpu_to_le16(cmd_802_11_authenticate); 268 cmd->command = cpu_to_le16(cmd_802_11_authenticate);
406 cmd->size = 269 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate)
407 cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) 270 + S_DS_GEN);
408 + S_DS_GEN); 271
272 /* translate auth mode to 802.11 defined wire value */
273 switch (adapter->secinfo.auth_mode) {
274 case IW_AUTH_ALG_OPEN_SYSTEM:
275 pauthenticate->authtype = 0x00;
276 break;
277 case IW_AUTH_ALG_SHARED_KEY:
278 pauthenticate->authtype = 0x01;
279 break;
280 case IW_AUTH_ALG_LEAP:
281 pauthenticate->authtype = 0x80;
282 break;
283 default:
284 lbs_pr_debug(1, "AUTH_CMD: invalid auth alg 0x%X\n",
285 adapter->secinfo.auth_mode);
286 goto out;
287 }
409 288
410 pauthenticate->authtype = adapter->secinfo.authmode;
411 memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); 289 memcpy(pauthenticate->macaddr, bssid, ETH_ALEN);
412 290
413 lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", 291 lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n",
414 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); 292 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
293 ret = 0;
415 294
416 return 0; 295out:
296 return ret;
417} 297}
418 298
419int libertas_cmd_80211_deauthenticate(wlan_private * priv, 299int libertas_cmd_80211_deauthenticate(wlan_private * priv,
@@ -550,7 +430,7 @@ int libertas_cmd_80211_associate(wlan_private * priv,
550 lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); 430 lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len);
551 431
552 /* set IBSS field */ 432 /* set IBSS field */
553 if (pbssdesc->inframode == wlan802_11infrastructure) { 433 if (pbssdesc->mode == IW_MODE_INFRA) {
554#define CAPINFO_ESS_MODE 1 434#define CAPINFO_ESS_MODE 1
555 passo->capinfo.ess = CAPINFO_ESS_MODE; 435 passo->capinfo.ess = CAPINFO_ESS_MODE;
556 } 436 }
@@ -624,7 +504,7 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv,
624 504
625 /* set the BSS type */ 505 /* set the BSS type */
626 adhs->bsstype = cmd_bss_type_ibss; 506 adhs->bsstype = cmd_bss_type_ibss;
627 pbssdesc->inframode = wlan802_11ibss; 507 pbssdesc->mode = IW_MODE_ADHOC;
628 adhs->beaconperiod = adapter->beaconperiod; 508 adhs->beaconperiod = adapter->beaconperiod;
629 509
630 /* set Physical param set */ 510 /* set Physical param set */
@@ -666,15 +546,12 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv,
666 adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); 546 adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time);
667 547
668 /* set up privacy in adapter->scantable[i] */ 548 /* set up privacy in adapter->scantable[i] */
669 if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { 549 if (adapter->secinfo.wep_enabled) {
670 550 lbs_pr_debug(1, "ADHOC_S_CMD: WEP enabled, setting privacy on\n");
671#define AD_HOC_CAP_PRIVACY_ON 1
672 lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus set, privacy to WEP\n");
673 pbssdesc->privacy = wlan802_11privfilter8021xWEP; 551 pbssdesc->privacy = wlan802_11privfilter8021xWEP;
674 adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; 552 adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON;
675 } else { 553 } else {
676 lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus NOT set, Setting " 554 lbs_pr_debug(1, "ADHOC_S_CMD: WEP disabled, setting privacy off\n");
677 "privacy to ACCEPT ALL\n");
678 pbssdesc->privacy = wlan802_11privfilteracceptall; 555 pbssdesc->privacy = wlan802_11privfilteracceptall;
679 } 556 }
680 557
@@ -786,9 +663,6 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv,
786 padhocjoin->bssdescriptor.BSSID[5], 663 padhocjoin->bssdescriptor.BSSID[5],
787 padhocjoin->bssdescriptor.SSID); 664 padhocjoin->bssdescriptor.SSID);
788 665
789 lbs_pr_debug(1, "ADHOC_J_CMD: Data Rate = %x\n",
790 (u32) padhocjoin->bssdescriptor.datarates);
791
792 /* failtimeout */ 666 /* failtimeout */
793 padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); 667 padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT);
794 668
@@ -832,7 +706,7 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv,
832 padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = 706 padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow =
833 cpu_to_le16(pbssdesc->atimwindow); 707 cpu_to_le16(pbssdesc->atimwindow);
834 708
835 if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { 709 if (adapter->secinfo.wep_enabled) {
836 padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; 710 padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON;
837 } 711 }
838 712
diff --git a/drivers/net/wireless/libertas/join.h b/drivers/net/wireless/libertas/join.h
index 8efa2455af9a..115f5a8ba346 100644
--- a/drivers/net/wireless/libertas/join.h
+++ b/drivers/net/wireless/libertas/join.h
@@ -1,6 +1,3 @@
1/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
2/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */
3
4/** 1/**
5 * Interface for the wlan infrastructure and adhoc join routines 2 * Interface for the wlan infrastructure and adhoc join routines
6 * 3 *
@@ -40,10 +37,6 @@ extern int libertas_ret_80211_disassociate(wlan_private * priv,
40extern int libertas_ret_80211_associate(wlan_private * priv, 37extern int libertas_ret_80211_associate(wlan_private * priv,
41 struct cmd_ds_command *resp); 38 struct cmd_ds_command *resp);
42 39
43extern int libertas_idle_on(wlan_private * priv);
44extern int libertas_idle_off(wlan_private * priv);
45
46extern int libertas_do_adhocstop_ioctl(wlan_private * priv);
47extern int libertas_reassociation_thread(void *data); 40extern int libertas_reassociation_thread(void *data);
48 41
49struct WLAN_802_11_SSID; 42struct WLAN_802_11_SSID;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index dcbf102a057e..b9b25ce65919 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -21,6 +21,13 @@
21#include "debugfs.h" 21#include "debugfs.h"
22#include "assoc.h" 22#include "assoc.h"
23 23
24#define DRIVER_RELEASE_VERSION "320.p0"
25const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
26#ifdef DEBUG
27 "-dbg"
28#endif
29 "";
30
24#ifdef ENABLE_PM 31#ifdef ENABLE_PM
25static struct pm_dev *wlan_pm_dev = NULL; 32static struct pm_dev *wlan_pm_dev = NULL;
26#endif 33#endif
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index 7e3f78f092dc..d17924f764e5 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -210,7 +210,7 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb)
210 goto done; 210 goto done;
211 } 211 }
212 212
213 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", 213 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n",
214 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 214 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
215 215
216 lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, 216 lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr,
@@ -364,7 +364,7 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb)
364 priv->stats.rx_errors++; 364 priv->stats.rx_errors++;
365 } 365 }
366 366
367 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", 367 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n",
368 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 368 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
369 369
370 /* create the exported radio header */ 370 /* create the exported radio header */
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index e18706238951..3c0b1a2a1727 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -1,6 +1,3 @@
1/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
2/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */
3
4/** 1/**
5 * Functions implementing wlan scan IOCTL and firmware command APIs 2 * Functions implementing wlan scan IOCTL and firmware command APIs
6 * 3 *
@@ -87,118 +84,95 @@
87 * 84 *
88 * @return Index in scantable, or error code if negative 85 * @return Index in scantable, or error code if negative
89 */ 86 */
90static int is_network_compatible(wlan_adapter * adapter, int index, int mode) 87static int is_network_compatible(wlan_adapter * adapter, int index, u8 mode)
91{ 88{
92 ENTER(); 89 ENTER();
93 90
94 if (adapter->scantable[index].inframode == mode) { 91 if (adapter->scantable[index].mode == mode) {
95 if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 92 if ( !adapter->secinfo.wep_enabled
96 && !adapter->secinfo.WPAenabled 93 && !adapter->secinfo.WPAenabled
97 && !adapter->secinfo.WPA2enabled 94 && !adapter->secinfo.WPA2enabled
98 && adapter->scantable[index].wpa_supplicant.wpa_ie[0] != 95 && adapter->scantable[index].wpa_ie[0] != WPA_IE
99 WPA_IE 96 && adapter->scantable[index].rsn_ie[0] != WPA2_IE
100 && adapter->scantable[index].wpa2_supplicant.wpa_ie[0] !=
101 WPA2_IE && adapter->secinfo.Encryptionmode == CIPHER_NONE
102 && !adapter->scantable[index].privacy) { 97 && !adapter->scantable[index].privacy) {
103 /* no security */ 98 /* no security */
104 LEAVE(); 99 LEAVE();
105 return index; 100 return index;
106 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled 101 } else if ( adapter->secinfo.wep_enabled
107 && !adapter->secinfo.WPAenabled 102 && !adapter->secinfo.WPAenabled
108 && !adapter->secinfo.WPA2enabled 103 && !adapter->secinfo.WPA2enabled
109 && adapter->scantable[index].privacy) { 104 && adapter->scantable[index].privacy) {
110 /* static WEP enabled */ 105 /* static WEP enabled */
111 LEAVE(); 106 LEAVE();
112 return index; 107 return index;
113 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 108 } else if ( !adapter->secinfo.wep_enabled
114 && adapter->secinfo.WPAenabled 109 && adapter->secinfo.WPAenabled
115 && !adapter->secinfo.WPA2enabled 110 && !adapter->secinfo.WPA2enabled
116 && (adapter->scantable[index].wpa_supplicant. 111 && (adapter->scantable[index].wpa_ie[0] == WPA_IE)
117 wpa_ie[0]
118 == WPA_IE)
119 /* privacy bit may NOT be set in some APs like LinkSys WRT54G 112 /* privacy bit may NOT be set in some APs like LinkSys WRT54G
120 && adapter->scantable[index].privacy */ 113 && adapter->scantable[index].privacy */
121 ) { 114 ) {
122 /* WPA enabled */ 115 /* WPA enabled */
123 lbs_pr_debug(1, 116 lbs_pr_debug(1,
124 "is_network_compatible() WPA: index=%d wpa_ie=%#x " 117 "is_network_compatible() WPA: index=%d wpa_ie=%#x "
125 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " 118 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s "
126 "privacy=%#x\n", index, 119 "privacy=%#x\n", index,
127 adapter->scantable[index].wpa_supplicant. 120 adapter->scantable[index].wpa_ie[0],
128 wpa_ie[0], 121 adapter->scantable[index].rsn_ie[0],
129 adapter->scantable[index].wpa2_supplicant. 122 adapter->secinfo.wep_enabled ? "e" : "d",
130 wpa_ie[0], 123 adapter->secinfo.WPAenabled ? "e" : "d",
131 (adapter->secinfo.WEPstatus == 124 adapter->secinfo.WPA2enabled ? "e" : "d",
132 wlan802_11WEPenabled) ? "e" : "d",
133 (adapter->secinfo.WPAenabled) ? "e" : "d",
134 (adapter->secinfo.WPA2enabled) ? "e" : "d",
135 adapter->secinfo.Encryptionmode,
136 adapter->scantable[index].privacy); 125 adapter->scantable[index].privacy);
137 LEAVE(); 126 LEAVE();
138 return index; 127 return index;
139 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 128 } else if ( !adapter->secinfo.wep_enabled
140 && !adapter->secinfo.WPAenabled 129 && !adapter->secinfo.WPAenabled
141 && adapter->secinfo.WPA2enabled 130 && adapter->secinfo.WPA2enabled
142 && (adapter->scantable[index].wpa2_supplicant. 131 && (adapter->scantable[index].rsn_ie[0] == WPA2_IE)
143 wpa_ie[0]
144 == WPA2_IE)
145 /* privacy bit may NOT be set in some APs like LinkSys WRT54G 132 /* privacy bit may NOT be set in some APs like LinkSys WRT54G
146 && adapter->scantable[index].privacy */ 133 && adapter->scantable[index].privacy */
147 ) { 134 ) {
148 /* WPA2 enabled */ 135 /* WPA2 enabled */
149 lbs_pr_debug(1, 136 lbs_pr_debug(1,
150 "is_network_compatible() WPA2: index=%d wpa_ie=%#x " 137 "is_network_compatible() WPA2: index=%d wpa_ie=%#x "
151 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " 138 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s "
152 "privacy=%#x\n", index, 139 "privacy=%#x\n", index,
153 adapter->scantable[index].wpa_supplicant. 140 adapter->scantable[index].wpa_ie[0],
154 wpa_ie[0], 141 adapter->scantable[index].rsn_ie[0],
155 adapter->scantable[index].wpa2_supplicant. 142 adapter->secinfo.wep_enabled ? "e" : "d",
156 wpa_ie[0], 143 adapter->secinfo.WPAenabled ? "e" : "d",
157 (adapter->secinfo.WEPstatus == 144 adapter->secinfo.WPA2enabled ? "e" : "d",
158 wlan802_11WEPenabled) ? "e" : "d",
159 (adapter->secinfo.WPAenabled) ? "e" : "d",
160 (adapter->secinfo.WPA2enabled) ? "e" : "d",
161 adapter->secinfo.Encryptionmode,
162 adapter->scantable[index].privacy); 145 adapter->scantable[index].privacy);
163 LEAVE(); 146 LEAVE();
164 return index; 147 return index;
165 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 148 } else if ( !adapter->secinfo.wep_enabled
166 && !adapter->secinfo.WPAenabled 149 && !adapter->secinfo.WPAenabled
167 && !adapter->secinfo.WPA2enabled 150 && !adapter->secinfo.WPA2enabled
168 && (adapter->scantable[index].wpa_supplicant. 151 && (adapter->scantable[index].wpa_ie[0] != WPA_IE)
169 wpa_ie[0] 152 && (adapter->scantable[index].rsn_ie[0] != WPA2_IE)
170 != WPA_IE)
171 && (adapter->scantable[index].wpa2_supplicant.
172 wpa_ie[0]
173 != WPA2_IE)
174 && adapter->secinfo.Encryptionmode != CIPHER_NONE
175 && adapter->scantable[index].privacy) { 153 && adapter->scantable[index].privacy) {
176 /* dynamic WEP enabled */ 154 /* dynamic WEP enabled */
177 lbs_pr_debug(1, 155 lbs_pr_debug(1,
178 "is_network_compatible() dynamic WEP: index=%d " 156 "is_network_compatible() dynamic WEP: index=%d "
179 "wpa_ie=%#x wpa2_ie=%#x Encmode=%#x privacy=%#x\n", 157 "wpa_ie=%#x wpa2_ie=%#x privacy=%#x\n",
180 index, 158 index,
181 adapter->scantable[index].wpa_supplicant. 159 adapter->scantable[index].wpa_ie[0],
182 wpa_ie[0], 160 adapter->scantable[index].rsn_ie[0],
183 adapter->scantable[index].wpa2_supplicant.
184 wpa_ie[0], adapter->secinfo.Encryptionmode,
185 adapter->scantable[index].privacy); 161 adapter->scantable[index].privacy);
186 LEAVE(); 162 LEAVE();
187 return index; 163 return index;
188 } 164 }
189 165
190 /* security doesn't match */ 166 /* security doesn't match */
191 lbs_pr_debug(1, 167 lbs_pr_debug(1,
192 "is_network_compatible() FAILED: index=%d wpa_ie=%#x " 168 "is_network_compatible() FAILED: index=%d wpa_ie=%#x "
193 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x privacy=%#x\n", 169 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s privacy=%#x\n",
194 index, 170 index,
195 adapter->scantable[index].wpa_supplicant.wpa_ie[0], 171 adapter->scantable[index].wpa_ie[0],
196 adapter->scantable[index].wpa2_supplicant.wpa_ie[0], 172 adapter->scantable[index].rsn_ie[0],
197 (adapter->secinfo.WEPstatus == 173 adapter->secinfo.wep_enabled ? "e" : "d",
198 wlan802_11WEPenabled) ? "e" : "d", 174 adapter->secinfo.WPAenabled ? "e" : "d",
199 (adapter->secinfo.WPAenabled) ? "e" : "d", 175 adapter->secinfo.WPA2enabled ? "e" : "d",
200 (adapter->secinfo.WPA2enabled) ? "e" : "d",
201 adapter->secinfo.Encryptionmode,
202 adapter->scantable[index].privacy); 176 adapter->scantable[index].privacy);
203 LEAVE(); 177 LEAVE();
204 return -ECONNREFUSED; 178 return -ECONNREFUSED;
@@ -924,8 +898,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
924 u8 founddatarateie; 898 u8 founddatarateie;
925 int bytesleftforcurrentbeacon; 899 int bytesleftforcurrentbeacon;
926 900
927 struct WPA_SUPPLICANT *pwpa_supplicant;
928 struct WPA_SUPPLICANT *pwpa2_supplicant;
929 struct IE_WPA *pIe; 901 struct IE_WPA *pIe;
930 const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; 902 const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 };
931 903
@@ -962,9 +934,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
962 934
963 bytesleftforcurrentbeacon = beaconsize; 935 bytesleftforcurrentbeacon = beaconsize;
964 936
965 pwpa_supplicant = &pBSSEntry->wpa_supplicant;
966 pwpa2_supplicant = &pBSSEntry->wpa2_supplicant;
967
968 memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); 937 memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN);
969 lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", 938 lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n",
970 pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], 939 pBSSEntry->macaddress[0], pBSSEntry->macaddress[1],
@@ -1027,9 +996,9 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
1027 } 996 }
1028 997
1029 if (pcap->ibss == 1) { 998 if (pcap->ibss == 1) {
1030 pBSSEntry->inframode = wlan802_11ibss; 999 pBSSEntry->mode = IW_MODE_ADHOC;
1031 } else { 1000 } else {
1032 pBSSEntry->inframode = wlan802_11infrastructure; 1001 pBSSEntry->mode = IW_MODE_INFRA;
1033 } 1002 }
1034 1003
1035 /* process variable IE */ 1004 /* process variable IE */
@@ -1116,7 +1085,7 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
1116 sizeof(pcountryinfo->countrycode) 1085 sizeof(pcountryinfo->countrycode)
1117 || pcountryinfo->len > 254) { 1086 || pcountryinfo->len > 254) {
1118 lbs_pr_debug(1, "InterpretIE: 11D- Err " 1087 lbs_pr_debug(1, "InterpretIE: 11D- Err "
1119 "CountryInfo len =%d min=%d max=254\n", 1088 "CountryInfo len =%d min=%zd max=254\n",
1120 pcountryinfo->len, 1089 pcountryinfo->len,
1121 sizeof(pcountryinfo->countrycode)); 1090 sizeof(pcountryinfo->countrycode));
1122 LEAVE(); 1091 LEAVE();
@@ -1160,27 +1129,27 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
1160#define IE_ID_LEN_FIELDS_BYTES 2 1129#define IE_ID_LEN_FIELDS_BYTES 2
1161 pIe = (struct IE_WPA *)pcurrentptr; 1130 pIe = (struct IE_WPA *)pcurrentptr;
1162 1131
1163 if (!memcmp(pIe->oui, oui01, sizeof(oui01))) { 1132 if (memcmp(pIe->oui, oui01, sizeof(oui01)))
1164 pwpa_supplicant->wpa_ie_len 1133 break;
1165 = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, 1134
1166 sizeof(pwpa_supplicant->wpa_ie)); 1135 pBSSEntry->wpa_ie_len = min_t(size_t,
1167 memcpy(pwpa_supplicant->wpa_ie, 1136 elemlen + IE_ID_LEN_FIELDS_BYTES,
1168 pcurrentptr, 1137 sizeof(pBSSEntry->wpa_ie));
1169 pwpa_supplicant->wpa_ie_len); 1138 memcpy(pBSSEntry->wpa_ie, pcurrentptr,
1170 lbs_dbg_hex("InterpretIE: Resp WPA_IE", 1139 pBSSEntry->wpa_ie_len);
1171 pwpa_supplicant->wpa_ie, elemlen); 1140 lbs_dbg_hex("InterpretIE: Resp WPA_IE",
1172 } 1141 pBSSEntry->wpa_ie, elemlen);
1173 break; 1142 break;
1174 case WPA2_IE: 1143 case WPA2_IE:
1175 pIe = (struct IE_WPA *)pcurrentptr; 1144 pIe = (struct IE_WPA *)pcurrentptr;
1176 pwpa2_supplicant->wpa_ie_len
1177 = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES,
1178 sizeof(pwpa2_supplicant->wpa_ie));
1179 memcpy(pwpa2_supplicant->wpa_ie,
1180 pcurrentptr, pwpa2_supplicant->wpa_ie_len);
1181 1145
1146 pBSSEntry->rsn_ie_len = min_t(size_t,
1147 elemlen + IE_ID_LEN_FIELDS_BYTES,
1148 sizeof(pBSSEntry->rsn_ie));
1149 memcpy(pBSSEntry->rsn_ie, pcurrentptr,
1150 pBSSEntry->rsn_ie_len);
1182 lbs_dbg_hex("InterpretIE: Resp WPA2_IE", 1151 lbs_dbg_hex("InterpretIE: Resp WPA2_IE",
1183 pwpa2_supplicant->wpa_ie, elemlen); 1152 pBSSEntry->rsn_ie, elemlen);
1184 break; 1153 break;
1185 case TIM: 1154 case TIM:
1186 break; 1155 break;
@@ -1227,7 +1196,7 @@ int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *s
1227 * 1196 *
1228 * @return index in BSSID list, or error return code (< 0) 1197 * @return index in BSSID list, or error return code (< 0)
1229 */ 1198 */
1230int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) 1199int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode)
1231{ 1200{
1232 int ret = -ENETUNREACH; 1201 int ret = -ENETUNREACH;
1233 int i; 1202 int i;
@@ -1247,8 +1216,8 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode)
1247 for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { 1216 for (i = 0; ret < 0 && i < adapter->numinscantable; i++) {
1248 if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { 1217 if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) {
1249 switch (mode) { 1218 switch (mode) {
1250 case wlan802_11infrastructure: 1219 case IW_MODE_INFRA:
1251 case wlan802_11ibss: 1220 case IW_MODE_ADHOC:
1252 ret = is_network_compatible(adapter, i, mode); 1221 ret = is_network_compatible(adapter, i, mode);
1253 break; 1222 break;
1254 default: 1223 default:
@@ -1272,7 +1241,7 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode)
1272 * @return index in BSSID list 1241 * @return index in BSSID list
1273 */ 1242 */
1274int libertas_find_SSID_in_list(wlan_adapter * adapter, 1243int libertas_find_SSID_in_list(wlan_adapter * adapter,
1275 struct WLAN_802_11_SSID *ssid, u8 * bssid, int mode) 1244 struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode)
1276{ 1245{
1277 int net = -ENETUNREACH; 1246 int net = -ENETUNREACH;
1278 u8 bestrssi = 0; 1247 u8 bestrssi = 0;
@@ -1287,8 +1256,8 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter,
1287 !memcmp(adapter->scantable[i]. 1256 !memcmp(adapter->scantable[i].
1288 macaddress, bssid, ETH_ALEN))) { 1257 macaddress, bssid, ETH_ALEN))) {
1289 switch (mode) { 1258 switch (mode) {
1290 case wlan802_11infrastructure: 1259 case IW_MODE_INFRA:
1291 case wlan802_11ibss: 1260 case IW_MODE_ADHOC:
1292 j = is_network_compatible(adapter, i, mode); 1261 j = is_network_compatible(adapter, i, mode);
1293 1262
1294 if (j >= 0) { 1263 if (j >= 0) {
@@ -1311,7 +1280,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter,
1311 } 1280 }
1312 } 1281 }
1313 break; 1282 break;
1314 case wlan802_11autounknown: 1283 case IW_MODE_AUTO:
1315 default: 1284 default:
1316 if (SCAN_RSSI(adapter->scantable[i].rssi) 1285 if (SCAN_RSSI(adapter->scantable[i].rssi)
1317 > bestrssi) { 1286 > bestrssi) {
@@ -1338,8 +1307,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter,
1338 * 1307 *
1339 * @return index in BSSID list 1308 * @return index in BSSID list
1340 */ 1309 */
1341int libertas_find_best_SSID_in_list(wlan_adapter * adapter, 1310int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode)
1342 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode)
1343{ 1311{
1344 int bestnet = -ENETUNREACH; 1312 int bestnet = -ENETUNREACH;
1345 u8 bestrssi = 0; 1313 u8 bestrssi = 0;
@@ -1351,8 +1319,8 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter,
1351 1319
1352 for (i = 0; i < adapter->numinscantable; i++) { 1320 for (i = 0; i < adapter->numinscantable; i++) {
1353 switch (mode) { 1321 switch (mode) {
1354 case wlan802_11infrastructure: 1322 case IW_MODE_INFRA:
1355 case wlan802_11ibss: 1323 case IW_MODE_ADHOC:
1356 if (is_network_compatible(adapter, i, mode) >= 0) { 1324 if (is_network_compatible(adapter, i, mode) >= 0) {
1357 if (SCAN_RSSI(adapter->scantable[i].rssi) > 1325 if (SCAN_RSSI(adapter->scantable[i].rssi) >
1358 bestrssi) { 1326 bestrssi) {
@@ -1363,7 +1331,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter,
1363 } 1331 }
1364 } 1332 }
1365 break; 1333 break;
1366 case wlan802_11autounknown: 1334 case IW_MODE_AUTO:
1367 default: 1335 default:
1368 if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { 1336 if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) {
1369 bestrssi = 1337 bestrssi =
@@ -1388,8 +1356,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter,
1388 */ 1356 */
1389int libertas_find_best_network_SSID(wlan_private * priv, 1357int libertas_find_best_network_SSID(wlan_private * priv,
1390 struct WLAN_802_11_SSID *pSSID, 1358 struct WLAN_802_11_SSID *pSSID,
1391 enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, 1359 u8 preferred_mode, u8 *out_mode)
1392 enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode)
1393{ 1360{
1394 wlan_adapter *adapter = priv->adapter; 1361 wlan_adapter *adapter = priv->adapter;
1395 int ret = 0; 1362 int ret = 0;
@@ -1414,7 +1381,7 @@ int libertas_find_best_network_SSID(wlan_private * priv,
1414 preqbssid = &adapter->scantable[i]; 1381 preqbssid = &adapter->scantable[i];
1415 memcpy(pSSID, &preqbssid->ssid, 1382 memcpy(pSSID, &preqbssid->ssid,
1416 sizeof(struct WLAN_802_11_SSID)); 1383 sizeof(struct WLAN_802_11_SSID));
1417 *out_mode = preqbssid->inframode; 1384 *out_mode = preqbssid->mode;
1418 1385
1419 if (!pSSID->ssidlength) { 1386 if (!pSSID->ssidlength) {
1420 ret = -1; 1387 ret = -1;
@@ -1584,7 +1551,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1584 for (i = 0; i < adapter->numinscantable; i++) { 1551 for (i = 0; i < adapter->numinscantable; i++) {
1585 if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { 1552 if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) {
1586 lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " 1553 lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p "
1587 "MAX_SCAN_CELL_SIZE=%d\n", 1554 "MAX_SCAN_CELL_SIZE=%zd\n",
1588 i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); 1555 i, current_ev, end_buf, MAX_SCAN_CELL_SIZE);
1589 break; 1556 break;
1590 } 1557 }
@@ -1632,7 +1599,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1632 1599
1633 //Add mode 1600 //Add mode
1634 iwe.cmd = SIOCGIWMODE; 1601 iwe.cmd = SIOCGIWMODE;
1635 iwe.u.mode = adapter->scantable[i].inframode + 1; 1602 iwe.u.mode = adapter->scantable[i].mode;
1636 iwe.len = IW_EV_UINT_LEN; 1603 iwe.len = IW_EV_UINT_LEN;
1637 current_ev = 1604 current_ev =
1638 iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); 1605 iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len);
@@ -1666,7 +1633,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1666 iwe.u.qual.noise = 1633 iwe.u.qual.noise =
1667 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 1634 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1668 } 1635 }
1669 if ((adapter->inframode == wlan802_11ibss) && 1636 if ((adapter->mode == IW_MODE_ADHOC) &&
1670 !libertas_SSID_cmp(&adapter->curbssparams.ssid, 1637 !libertas_SSID_cmp(&adapter->curbssparams.ssid,
1671 &adapter->scantable[i].ssid) 1638 &adapter->scantable[i].ssid)
1672 && adapter->adhoccreate) { 1639 && adapter->adhoccreate) {
@@ -1731,7 +1698,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1731 end_buf, &iwe, iwe.len); 1698 end_buf, &iwe, iwe.len);
1732 1699
1733 } 1700 }
1734 if ((adapter->scantable[i].inframode == wlan802_11ibss) 1701 if ((adapter->scantable[i].mode == IW_MODE_ADHOC)
1735 && !libertas_SSID_cmp(&adapter->curbssparams.ssid, 1702 && !libertas_SSID_cmp(&adapter->curbssparams.ssid,
1736 &adapter->scantable[i].ssid) 1703 &adapter->scantable[i].ssid)
1737 && adapter->adhoccreate) { 1704 && adapter->adhoccreate) {
@@ -1745,30 +1712,24 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1745 /* Add new value to event */ 1712 /* Add new value to event */
1746 current_val = current_ev + IW_EV_LCP_LEN; 1713 current_val = current_ev + IW_EV_LCP_LEN;
1747 1714
1748 if (adapter->scantable[i].wpa2_supplicant.wpa_ie[0] == WPA2_IE) { 1715 if (adapter->scantable[i].rsn_ie[0] == WPA2_IE) {
1749 memset(&iwe, 0, sizeof(iwe)); 1716 memset(&iwe, 0, sizeof(iwe));
1750 memset(buf, 0, sizeof(buf)); 1717 memset(buf, 0, sizeof(buf));
1751 memcpy(buf, adapter->scantable[i]. 1718 memcpy(buf, adapter->scantable[i].rsn_ie,
1752 wpa2_supplicant.wpa_ie, 1719 adapter->scantable[i].rsn_ie_len);
1753 adapter->scantable[i].wpa2_supplicant.
1754 wpa_ie_len);
1755 iwe.cmd = IWEVGENIE; 1720 iwe.cmd = IWEVGENIE;
1756 iwe.u.data.length = adapter->scantable[i]. 1721 iwe.u.data.length = adapter->scantable[i].rsn_ie_len;
1757 wpa2_supplicant.wpa_ie_len;
1758 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1722 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
1759 current_ev = iwe_stream_add_point(current_ev, end_buf, 1723 current_ev = iwe_stream_add_point(current_ev, end_buf,
1760 &iwe, buf); 1724 &iwe, buf);
1761 } 1725 }
1762 if (adapter->scantable[i].wpa_supplicant.wpa_ie[0] == WPA_IE) { 1726 if (adapter->scantable[i].wpa_ie[0] == WPA_IE) {
1763 memset(&iwe, 0, sizeof(iwe)); 1727 memset(&iwe, 0, sizeof(iwe));
1764 memset(buf, 0, sizeof(buf)); 1728 memset(buf, 0, sizeof(buf));
1765 memcpy(buf, adapter->scantable[i]. 1729 memcpy(buf, adapter->scantable[i].wpa_ie,
1766 wpa_supplicant.wpa_ie, 1730 adapter->scantable[i].wpa_ie_len);
1767 adapter->scantable[i].wpa_supplicant.
1768 wpa_ie_len);
1769 iwe.cmd = IWEVGENIE; 1731 iwe.cmd = IWEVGENIE;
1770 iwe.u.data.length = adapter->scantable[i]. 1732 iwe.u.data.length = adapter->scantable[i].wpa_ie_len;
1771 wpa_supplicant.wpa_ie_len;
1772 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1733 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
1773 current_ev = iwe_stream_add_point(current_ev, end_buf, 1734 current_ev = iwe_stream_add_point(current_ev, end_buf,
1774 &iwe, buf); 1735 &iwe, buf);
diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h
index d93aa7fa44fd..405f4f0fe575 100644
--- a/drivers/net/wireless/libertas/scan.h
+++ b/drivers/net/wireless/libertas/scan.h
@@ -1,6 +1,3 @@
1/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
2/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */
3
4/** 1/**
5 * Interface for the wlan network scan routines 2 * Interface for the wlan network scan routines
6 * 3 *
@@ -10,6 +7,7 @@
10#ifndef _WLAN_SCAN_H 7#ifndef _WLAN_SCAN_H
11#define _WLAN_SCAN_H 8#define _WLAN_SCAN_H
12 9
10#include <net/ieee80211.h>
13#include "hostcmd.h" 11#include "hostcmd.h"
14 12
15/** 13/**
@@ -155,7 +153,7 @@ struct bss_descriptor {
155 153
156 u32 atimwindow; 154 u32 atimwindow;
157 155
158 enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; 156 u8 mode;
159 u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; 157 u8 libertas_supported_rates[WLAN_SUPPORTED_RATES];
160 158
161 int extra_ie; 159 int extra_ie;
@@ -170,22 +168,22 @@ struct bss_descriptor {
170 168
171 struct ieeetypes_countryinfofullset countryinfo; 169 struct ieeetypes_countryinfofullset countryinfo;
172 170
173 struct WPA_SUPPLICANT wpa_supplicant; 171 u8 wpa_ie[MAX_WPA_IE_LEN];
174 struct WPA_SUPPLICANT wpa2_supplicant; 172 size_t wpa_ie_len;
175 173 u8 rsn_ie[MAX_WPA_IE_LEN];
174 size_t rsn_ie_len;
176}; 175};
177 176
178extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, 177extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1,
179 struct WLAN_802_11_SSID *ssid2); 178 struct WLAN_802_11_SSID *ssid2);
180extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, 179extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid,
181 u8 * bssid, int mode); 180 u8 * bssid, u8 mode);
182int libertas_find_best_SSID_in_list(wlan_adapter * adapter, enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode); 181int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode);
183extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode); 182extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode);
184 183
185int libertas_find_best_network_SSID(wlan_private * priv, 184int libertas_find_best_network_SSID(wlan_private * priv,
186 struct WLAN_802_11_SSID *pSSID, 185 struct WLAN_802_11_SSID *pSSID,
187 enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, 186 u8 preferred_mode, u8 *out_mode);
188 enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode);
189 187
190extern int libertas_send_specific_SSID_scan(wlan_private * priv, 188extern int libertas_send_specific_SSID_scan(wlan_private * priv,
191 struct WLAN_802_11_SSID *prequestedssid, 189 struct WLAN_802_11_SSID *prequestedssid,
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c
index 82d06223043e..d4b13478c9a7 100644
--- a/drivers/net/wireless/libertas/tx.c
+++ b/drivers/net/wireless/libertas/tx.c
@@ -78,7 +78,7 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
78 min_t(unsigned int, skb->len, 100)); 78 min_t(unsigned int, skb->len, 100));
79 79
80 if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { 80 if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) {
81 lbs_pr_debug(1, "Tx error: Bad skb length %d : %d\n", 81 lbs_pr_debug(1, "Tx error: Bad skb length %d : %zd\n",
82 skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); 82 skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE);
83 ret = -1; 83 ret = -1;
84 goto done; 84 goto done;
diff --git a/drivers/net/wireless/libertas/version.h b/drivers/net/wireless/libertas/version.h
index e86f65ae79b8..8b137891791f 100644
--- a/drivers/net/wireless/libertas/version.h
+++ b/drivers/net/wireless/libertas/version.h
@@ -1,8 +1 @@
1#define DRIVER_RELEASE_VERSION "320.p0"
2const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
3#ifdef DEBUG
4 "-dbg"
5#endif
6 "";
7
8
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 4a52336bc0f6..69f52b6e59c8 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -17,7 +17,6 @@
17#include "defs.h" 17#include "defs.h"
18#include "dev.h" 18#include "dev.h"
19#include "join.h" 19#include "join.h"
20#include "version.h"
21#include "wext.h" 20#include "wext.h"
22#include "assoc.h" 21#include "assoc.h"
23 22
@@ -233,7 +232,7 @@ static int changeadhocchannel(wlan_private * priv, int channel)
233 232
234 // find out the BSSID that matches the current SSID 233 // find out the BSSID that matches the current SSID
235 i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, 234 i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL,
236 wlan802_11ibss); 235 IW_MODE_ADHOC);
237 236
238 if (i >= 0) { 237 if (i >= 0) {
239 lbs_pr_debug(1, "SSID found at %d in List," 238 lbs_pr_debug(1, "SSID found at %d in List,"
@@ -316,13 +315,11 @@ static int get_active_data_rates(wlan_adapter * adapter,
316 ENTER(); 315 ENTER();
317 316
318 if (adapter->connect_status != libertas_connected) { 317 if (adapter->connect_status != libertas_connected) {
319 if (adapter->inframode == wlan802_11infrastructure) { 318 if (adapter->mode == IW_MODE_INFRA) {
320 //Infra. mode
321 lbs_pr_debug(1, "Infra\n"); 319 lbs_pr_debug(1, "Infra\n");
322 k = copyrates(rates, k, libertas_supported_rates, 320 k = copyrates(rates, k, libertas_supported_rates,
323 sizeof(libertas_supported_rates)); 321 sizeof(libertas_supported_rates));
324 } else { 322 } else {
325 //ad-hoc mode
326 lbs_pr_debug(1, "Adhoc G\n"); 323 lbs_pr_debug(1, "Adhoc G\n");
327 k = copyrates(rates, k, libertas_adhoc_rates_g, 324 k = copyrates(rates, k, libertas_adhoc_rates_g,
328 sizeof(libertas_adhoc_rates_g)); 325 sizeof(libertas_adhoc_rates_g));
@@ -586,20 +583,7 @@ static int wlan_get_mode(struct net_device *dev,
586 583
587 ENTER(); 584 ENTER();
588 585
589 switch (adapter->inframode) { 586 *uwrq = adapter->mode;
590 case wlan802_11ibss:
591 *uwrq = IW_MODE_ADHOC;
592 break;
593
594 case wlan802_11infrastructure:
595 *uwrq = IW_MODE_INFRA;
596 break;
597
598 default:
599 case wlan802_11autounknown:
600 *uwrq = IW_MODE_AUTO;
601 break;
602 }
603 587
604 LEAVE(); 588 LEAVE();
605 return 0; 589 return 0;
@@ -1002,149 +986,18 @@ static const struct iw_priv_args wlan_private_args[] = {
1002 /* 986 /*
1003 * { cmd, set_args, get_args, name } 987 * { cmd, set_args, get_args, name }
1004 */ 988 */
1005 {
1006 WLANSCAN_TYPE,
1007 IW_PRIV_TYPE_CHAR | 8,
1008 IW_PRIV_TYPE_CHAR | 8,
1009 "scantype"},
1010
1011 {
1012 WLAN_SETINT_GETINT,
1013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1015 ""},
1016 {
1017 WLANNF,
1018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1020 "getNF"},
1021 {
1022 WLANRSSI,
1023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1025 "getRSSI"},
1026 {
1027 WLANENABLE11D,
1028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1030 "enable11d"},
1031 {
1032 WLANADHOCGRATE,
1033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1035 "adhocgrate"},
1036
1037 {
1038 WLAN_SUBCMD_SET_PRESCAN,
1039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1041 "prescan"},
1042 {
1043 WLAN_SETONEINT_GETONEINT,
1044 IW_PRIV_TYPE_INT | 1,
1045 IW_PRIV_TYPE_INT | 1,
1046 ""},
1047 {
1048 WLAN_BEACON_INTERVAL,
1049 IW_PRIV_TYPE_INT | 1,
1050 IW_PRIV_TYPE_INT | 1,
1051 "bcninterval"},
1052 {
1053 WLAN_LISTENINTRVL,
1054 IW_PRIV_TYPE_INT | 1,
1055 IW_PRIV_TYPE_INT | 1,
1056 "lolisteninter"},
1057 {
1058 WLAN_TXCONTROL,
1059 IW_PRIV_TYPE_INT | 1,
1060 IW_PRIV_TYPE_INT | 1,
1061 "txcontrol"},
1062 {
1063 WLAN_NULLPKTINTERVAL,
1064 IW_PRIV_TYPE_INT | 1,
1065 IW_PRIV_TYPE_INT | 1,
1066 "psnullinterval"},
1067 /* Using iwpriv sub-command feature */ 989 /* Using iwpriv sub-command feature */
1068 { 990 {
1069 WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */ 991 WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */
1070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1071 IW_PRIV_TYPE_NONE, 993 IW_PRIV_TYPE_NONE,
1072 ""}, 994 ""},
1073
1074 {
1075 WLAN_SUBCMD_SETRXANTENNA,
1076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1077 IW_PRIV_TYPE_NONE,
1078 "setrxant"},
1079 {
1080 WLAN_SUBCMD_SETTXANTENNA,
1081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1082 IW_PRIV_TYPE_NONE,
1083 "settxant"},
1084 {
1085 WLANSETAUTHALG,
1086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1087 IW_PRIV_TYPE_NONE,
1088 "authalgs",
1089 },
1090 {
1091 WLANSET8021XAUTHALG,
1092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1093 IW_PRIV_TYPE_NONE,
1094 "8021xauthalgs",
1095 },
1096 {
1097 WLANSETENCRYPTIONMODE,
1098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1099 IW_PRIV_TYPE_NONE,
1100 "encryptionmode",
1101 },
1102 { 995 {
1103 WLANSETREGION, 996 WLANSETREGION,
1104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1105 IW_PRIV_TYPE_NONE, 998 IW_PRIV_TYPE_NONE,
1106 "setregioncode"}, 999 "setregioncode"},
1107 { 1000 {
1108 WLAN_SET_LISTEN_INTERVAL,
1109 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1110 IW_PRIV_TYPE_NONE,
1111 "setlisteninter"},
1112 {
1113 WLAN_SET_MULTIPLE_DTIM,
1114 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1115 IW_PRIV_TYPE_NONE,
1116 "setmultipledtim"},
1117 {
1118 WLAN_SET_ATIM_WINDOW,
1119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1120 IW_PRIV_TYPE_NONE,
1121 "atimwindow"},
1122 {
1123 WLANSETBCNAVG,
1124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1125 IW_PRIV_TYPE_NONE,
1126 "setbcnavg"},
1127 {
1128 WLANSETDATAAVG,
1129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1130 IW_PRIV_TYPE_NONE,
1131 "setdataavg"},
1132 {
1133 WLAN_SET_LINKMODE,
1134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1135 IW_PRIV_TYPE_NONE,
1136 "linkmode"},
1137 {
1138 WLAN_SET_RADIOMODE,
1139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1140 IW_PRIV_TYPE_NONE,
1141 "radiomode"},
1142 {
1143 WLAN_SET_DEBUGMODE,
1144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1145 IW_PRIV_TYPE_NONE,
1146 "debugmode"},
1147 {
1148 WLAN_SUBCMD_MESH_SET_TTL, 1001 WLAN_SUBCMD_MESH_SET_TTL,
1149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1150 IW_PRIV_TYPE_NONE, 1003 IW_PRIV_TYPE_NONE,
@@ -1160,41 +1013,6 @@ static const struct iw_priv_args wlan_private_args[] = {
1160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1161 "getregioncode"}, 1014 "getregioncode"},
1162 { 1015 {
1163 WLAN_GET_LISTEN_INTERVAL,
1164 IW_PRIV_TYPE_NONE,
1165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1166 "getlisteninter"},
1167 {
1168 WLAN_GET_MULTIPLE_DTIM,
1169 IW_PRIV_TYPE_NONE,
1170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1171 "getmultipledtim"},
1172 {
1173 WLAN_GET_TX_RATE,
1174 IW_PRIV_TYPE_NONE,
1175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1176 "gettxrate"},
1177 {
1178 WLANGETBCNAVG,
1179 IW_PRIV_TYPE_NONE,
1180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1181 "getbcnavg"},
1182 {
1183 WLAN_GET_LINKMODE,
1184 IW_PRIV_TYPE_NONE,
1185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1186 "get_linkmode"},
1187 {
1188 WLAN_GET_RADIOMODE,
1189 IW_PRIV_TYPE_NONE,
1190 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1191 "get_radiomode"},
1192 {
1193 WLAN_GET_DEBUGMODE,
1194 IW_PRIV_TYPE_NONE,
1195 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1196 "get_debugmode"},
1197 {
1198 WLAN_SUBCMD_FWT_CLEANUP, 1016 WLAN_SUBCMD_FWT_CLEANUP,
1199 IW_PRIV_TYPE_NONE, 1017 IW_PRIV_TYPE_NONE,
1200 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
@@ -1210,61 +1028,11 @@ static const struct iw_priv_args wlan_private_args[] = {
1210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1211 "mesh_get_ttl"}, 1029 "mesh_get_ttl"},
1212 { 1030 {
1213 WLAN_SETNONE_GETTWELVE_CHAR,
1214 IW_PRIV_TYPE_NONE,
1215 IW_PRIV_TYPE_CHAR | 12,
1216 ""},
1217 {
1218 WLAN_SUBCMD_GETRXANTENNA,
1219 IW_PRIV_TYPE_NONE,
1220 IW_PRIV_TYPE_CHAR | 12,
1221 "getrxant"},
1222 {
1223 WLAN_SUBCMD_GETTXANTENNA,
1224 IW_PRIV_TYPE_NONE,
1225 IW_PRIV_TYPE_CHAR | 12,
1226 "gettxant"},
1227 {
1228 WLAN_GET_TSF,
1229 IW_PRIV_TYPE_NONE,
1230 IW_PRIV_TYPE_CHAR | 12,
1231 "gettsf"},
1232 {
1233 WLAN_SETNONE_GETNONE, 1031 WLAN_SETNONE_GETNONE,
1234 IW_PRIV_TYPE_NONE, 1032 IW_PRIV_TYPE_NONE,
1235 IW_PRIV_TYPE_NONE, 1033 IW_PRIV_TYPE_NONE,
1236 ""}, 1034 ""},
1237 { 1035 {
1238 WLANDEAUTH,
1239 IW_PRIV_TYPE_NONE,
1240 IW_PRIV_TYPE_NONE,
1241 "deauth"},
1242 {
1243 WLANADHOCSTOP,
1244 IW_PRIV_TYPE_NONE,
1245 IW_PRIV_TYPE_NONE,
1246 "adhocstop"},
1247 {
1248 WLANRADIOON,
1249 IW_PRIV_TYPE_NONE,
1250 IW_PRIV_TYPE_NONE,
1251 "radioon"},
1252 {
1253 WLANRADIOOFF,
1254 IW_PRIV_TYPE_NONE,
1255 IW_PRIV_TYPE_NONE,
1256 "radiooff"},
1257 {
1258 WLANWLANIDLEON,
1259 IW_PRIV_TYPE_NONE,
1260 IW_PRIV_TYPE_NONE,
1261 "wlanidle-on"},
1262 {
1263 WLANWLANIDLEOFF,
1264 IW_PRIV_TYPE_NONE,
1265 IW_PRIV_TYPE_NONE,
1266 "wlanidle-off"},
1267 {
1268 WLAN_SUBCMD_FWT_RESET, 1036 WLAN_SUBCMD_FWT_RESET,
1269 IW_PRIV_TYPE_NONE, 1037 IW_PRIV_TYPE_NONE,
1270 IW_PRIV_TYPE_NONE, 1038 IW_PRIV_TYPE_NONE,
@@ -1327,90 +1095,15 @@ static const struct iw_priv_args wlan_private_args[] = {
1327 IW_PRIV_TYPE_CHAR | 128, 1095 IW_PRIV_TYPE_CHAR | 128,
1328 "fwt_list_route"}, 1096 "fwt_list_route"},
1329 { 1097 {
1330 WLANSCAN_MODE,
1331 IW_PRIV_TYPE_CHAR | 128,
1332 IW_PRIV_TYPE_CHAR | 128,
1333 "scanmode"},
1334 {
1335 WLAN_GET_ADHOC_STATUS,
1336 IW_PRIV_TYPE_CHAR | 128,
1337 IW_PRIV_TYPE_CHAR | 128,
1338 "getadhocstatus"},
1339 {
1340 WLAN_SETNONE_GETWORDCHAR,
1341 IW_PRIV_TYPE_NONE,
1342 IW_PRIV_TYPE_CHAR | 128,
1343 ""},
1344 {
1345 WLANSETWPAIE,
1346 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 24,
1347 IW_PRIV_TYPE_NONE,
1348 "setwpaie"},
1349 {
1350 WLANGETLOG,
1351 IW_PRIV_TYPE_NONE,
1352 IW_PRIV_TYPE_CHAR | GETLOG_BUFSIZE,
1353 "getlog"},
1354 {
1355 WLAN_SET_GET_SIXTEEN_INT, 1098 WLAN_SET_GET_SIXTEEN_INT,
1356 IW_PRIV_TYPE_INT | 16, 1099 IW_PRIV_TYPE_INT | 16,
1357 IW_PRIV_TYPE_INT | 16, 1100 IW_PRIV_TYPE_INT | 16,
1358 ""}, 1101 ""},
1359 { 1102 {
1360 WLAN_TPCCFG,
1361 IW_PRIV_TYPE_INT | 16,
1362 IW_PRIV_TYPE_INT | 16,
1363 "tpccfg"},
1364 {
1365 WLAN_POWERCFG,
1366 IW_PRIV_TYPE_INT | 16,
1367 IW_PRIV_TYPE_INT | 16,
1368 "powercfg"},
1369 {
1370 WLAN_AUTO_FREQ_SET,
1371 IW_PRIV_TYPE_INT | 16,
1372 IW_PRIV_TYPE_INT | 16,
1373 "setafc"},
1374 {
1375 WLAN_AUTO_FREQ_GET,
1376 IW_PRIV_TYPE_INT | 16,
1377 IW_PRIV_TYPE_INT | 16,
1378 "getafc"},
1379 {
1380 WLAN_SCANPROBES,
1381 IW_PRIV_TYPE_INT | 16,
1382 IW_PRIV_TYPE_INT | 16,
1383 "scanprobes"},
1384 {
1385 WLAN_LED_GPIO_CTRL, 1103 WLAN_LED_GPIO_CTRL,
1386 IW_PRIV_TYPE_INT | 16, 1104 IW_PRIV_TYPE_INT | 16,
1387 IW_PRIV_TYPE_INT | 16, 1105 IW_PRIV_TYPE_INT | 16,
1388 "ledgpio"}, 1106 "ledgpio"},
1389 {
1390 WLAN_ADAPT_RATESET,
1391 IW_PRIV_TYPE_INT | 16,
1392 IW_PRIV_TYPE_INT | 16,
1393 "rateadapt"},
1394 {
1395 WLAN_INACTIVITY_TIMEOUT,
1396 IW_PRIV_TYPE_INT | 16,
1397 IW_PRIV_TYPE_INT | 16,
1398 "inactivityto"},
1399 {
1400 WLANSNR,
1401 IW_PRIV_TYPE_INT | 16,
1402 IW_PRIV_TYPE_INT | 16,
1403 "getSNR"},
1404 {
1405 WLAN_GET_RATE,
1406 IW_PRIV_TYPE_INT | 16,
1407 IW_PRIV_TYPE_INT | 16,
1408 "getrate"},
1409 {
1410 WLAN_GET_RXINFO,
1411 IW_PRIV_TYPE_INT | 16,
1412 IW_PRIV_TYPE_INT | 16,
1413 "getrxinfo"},
1414}; 1107};
1415 1108
1416static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) 1109static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
@@ -1434,7 +1127,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
1434 1127
1435 ENTER(); 1128 ENTER();
1436 1129
1437 priv->wstats.status = adapter->inframode; 1130 priv->wstats.status = adapter->mode;
1438 1131
1439 /* If we're not associated, all quality values are meaningless */ 1132 /* If we're not associated, all quality values are meaningless */
1440 if (adapter->connect_status != libertas_connected) 1133 if (adapter->connect_status != libertas_connected)
@@ -1568,13 +1261,12 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
1568 if (!cfp) { 1261 if (!cfp) {
1569 rc = -EINVAL; 1262 rc = -EINVAL;
1570 } else { 1263 } else {
1571 if (adapter->inframode == wlan802_11ibss) { 1264 if (adapter->mode == IW_MODE_ADHOC) {
1572 rc = changeadhocchannel(priv, channel); 1265 rc = changeadhocchannel(priv, channel);
1573 /* If station is WEP enabled, send the 1266 /* If station is WEP enabled, send the
1574 * command to set WEP in firmware 1267 * command to set WEP in firmware
1575 */ 1268 */
1576 if (adapter->secinfo.WEPstatus == 1269 if (adapter->secinfo.wep_enabled) {
1577 wlan802_11WEPenabled) {
1578 lbs_pr_debug(1, "set_freq: WEP enabled\n"); 1270 lbs_pr_debug(1, "set_freq: WEP enabled\n");
1579 ret = libertas_prepare_and_send_command(priv, 1271 ret = libertas_prepare_and_send_command(priv,
1580 cmd_802_11_set_wep, 1272 cmd_802_11_set_wep,
@@ -1716,49 +1408,31 @@ static int wlan_set_mode(struct net_device *dev,
1716 wlan_private *priv = dev->priv; 1408 wlan_private *priv = dev->priv;
1717 wlan_adapter *adapter = priv->adapter; 1409 wlan_adapter *adapter = priv->adapter;
1718 struct assoc_request * assoc_req; 1410 struct assoc_request * assoc_req;
1719 enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode;
1720 1411
1721 ENTER(); 1412 ENTER();
1722 1413
1723 switch (*uwrq) { 1414 if ( (*uwrq != IW_MODE_ADHOC)
1724 case IW_MODE_ADHOC: 1415 && (*uwrq != IW_MODE_INFRA)
1725 lbs_pr_debug(1, "Wanted mode is ad-hoc: current datarate=%#x\n", 1416 && (*uwrq != IW_MODE_AUTO)) {
1726 adapter->datarate); 1417 lbs_pr_debug(1, "Invalid mode: 0x%x\n", *uwrq);
1727 new_mode = wlan802_11ibss; 1418 ret = -EINVAL;
1728 adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL; 1419 goto out;
1729 break;
1730
1731 case IW_MODE_INFRA:
1732 lbs_pr_debug(1, "Wanted mode is Infrastructure\n");
1733 new_mode = wlan802_11infrastructure;
1734 break;
1735
1736 case IW_MODE_AUTO:
1737 lbs_pr_debug(1, "Wanted mode is Auto\n");
1738 new_mode = wlan802_11autounknown;
1739 break;
1740
1741 default:
1742 lbs_pr_debug(1, "Wanted mode is Unknown: 0x%x\n", *uwrq);
1743 return -EINVAL;
1744 } 1420 }
1745 1421
1746 mutex_lock(&adapter->lock); 1422 mutex_lock(&adapter->lock);
1747 assoc_req = wlan_get_association_request(adapter); 1423 assoc_req = wlan_get_association_request(adapter);
1748 if (!assoc_req) { 1424 if (!assoc_req) {
1749 ret = -ENOMEM; 1425 ret = -ENOMEM;
1426 wlan_cancel_association_work(priv);
1750 } else { 1427 } else {
1751 assoc_req->mode = new_mode; 1428 assoc_req->mode = *uwrq;
1752 }
1753
1754 if (ret == 0) {
1755 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); 1429 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
1756 wlan_postpone_association_work(priv); 1430 wlan_postpone_association_work(priv);
1757 } else { 1431 lbs_pr_debug(1, "Switching to mode: 0x%x\n", *uwrq);
1758 wlan_cancel_association_work(priv);
1759 } 1432 }
1760 mutex_unlock(&adapter->lock); 1433 mutex_unlock(&adapter->lock);
1761 1434
1435out:
1762 LEAVE(); 1436 LEAVE();
1763 return ret; 1437 return ret;
1764} 1438}
@@ -1789,13 +1463,13 @@ static int wlan_get_encode(struct net_device *dev,
1789 dwrq->flags = 0; 1463 dwrq->flags = 0;
1790 1464
1791 /* Authentication method */ 1465 /* Authentication method */
1792 switch (adapter->secinfo.authmode) { 1466 switch (adapter->secinfo.auth_mode) {
1793 case wlan802_11authmodeopen: 1467 case IW_AUTH_ALG_OPEN_SYSTEM:
1794 dwrq->flags = IW_ENCODE_OPEN; 1468 dwrq->flags = IW_ENCODE_OPEN;
1795 break; 1469 break;
1796 1470
1797 case wlan802_11authmodeshared: 1471 case IW_AUTH_ALG_SHARED_KEY:
1798 case wlan802_11authmodenetworkEAP: 1472 case IW_AUTH_ALG_LEAP:
1799 dwrq->flags = IW_ENCODE_RESTRICTED; 1473 dwrq->flags = IW_ENCODE_RESTRICTED;
1800 break; 1474 break;
1801 default: 1475 default:
@@ -1803,8 +1477,9 @@ static int wlan_get_encode(struct net_device *dev,
1803 break; 1477 break;
1804 } 1478 }
1805 1479
1806 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) 1480 if ( adapter->secinfo.wep_enabled
1807 || adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) { 1481 || adapter->secinfo.WPAenabled
1482 || adapter->secinfo.WPA2enabled) {
1808 dwrq->flags &= ~IW_ENCODE_DISABLED; 1483 dwrq->flags &= ~IW_ENCODE_DISABLED;
1809 } else { 1484 } else {
1810 dwrq->flags |= IW_ENCODE_DISABLED; 1485 dwrq->flags |= IW_ENCODE_DISABLED;
@@ -1818,8 +1493,7 @@ static int wlan_get_encode(struct net_device *dev,
1818 if (index < 0) 1493 if (index < 0)
1819 index = adapter->wep_tx_keyidx; 1494 index = adapter->wep_tx_keyidx;
1820 1495
1821 if ((adapter->wep_keys[index].len) && 1496 if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) {
1822 (adapter->secinfo.WEPstatus == wlan802_11WEPenabled)) {
1823 memcpy(extra, adapter->wep_keys[index].key, 1497 memcpy(extra, adapter->wep_keys[index].key,
1824 adapter->wep_keys[index].len); 1498 adapter->wep_keys[index].len);
1825 dwrq->length = adapter->wep_keys[index].len; 1499 dwrq->length = adapter->wep_keys[index].len;
@@ -1903,7 +1577,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req,
1903 assoc_req->wep_tx_keyidx = index; 1577 assoc_req->wep_tx_keyidx = index;
1904 } 1578 }
1905 1579
1906 assoc_req->secinfo.WEPstatus = wlan802_11WEPenabled; 1580 assoc_req->secinfo.wep_enabled = 1;
1907 1581
1908 LEAVE(); 1582 LEAVE();
1909 return 0; 1583 return 0;
@@ -1932,10 +1606,10 @@ static void disable_wep(struct assoc_request *assoc_req)
1932 int i; 1606 int i;
1933 1607
1934 /* Set Open System auth mode */ 1608 /* Set Open System auth mode */
1935 assoc_req->secinfo.authmode = wlan802_11authmodeopen; 1609 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1936 1610
1937 /* Clear WEP keys and mark WEP as disabled */ 1611 /* Clear WEP keys and mark WEP as disabled */
1938 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 1612 assoc_req->secinfo.wep_enabled = 0;
1939 for (i = 0; i < 4; i++) 1613 for (i = 0; i < 4; i++)
1940 assoc_req->wep_keys[i].len = 0; 1614 assoc_req->wep_keys[i].len = 0;
1941 1615
@@ -1987,8 +1661,7 @@ static int wlan_set_encode(struct net_device *dev,
1987 /* If WEP isn't enabled, or if there is no key data but a valid 1661 /* If WEP isn't enabled, or if there is no key data but a valid
1988 * index, set the TX key. 1662 * index, set the TX key.
1989 */ 1663 */
1990 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) 1664 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
1991 || (dwrq->length == 0 && !is_default))
1992 set_tx_key = 1; 1665 set_tx_key = 1;
1993 1666
1994 ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); 1667 ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
@@ -2001,9 +1674,9 @@ static int wlan_set_encode(struct net_device *dev,
2001 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); 1674 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
2002 1675
2003 if (dwrq->flags & IW_ENCODE_RESTRICTED) { 1676 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
2004 assoc_req->secinfo.authmode = wlan802_11authmodeshared; 1677 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
2005 } else if (dwrq->flags & IW_ENCODE_OPEN) { 1678 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2006 assoc_req->secinfo.authmode = wlan802_11authmodeopen; 1679 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2007 } 1680 }
2008 1681
2009out: 1682out:
@@ -2056,30 +1729,31 @@ static int wlan_get_encodeext(struct net_device *dev,
2056 1729
2057 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && 1730 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
2058 ext->alg != IW_ENCODE_ALG_WEP) { 1731 ext->alg != IW_ENCODE_ALG_WEP) {
2059 if (index != 0 || adapter->inframode != wlan802_11infrastructure) 1732 if (index != 0 || adapter->mode != IW_MODE_INFRA)
2060 goto out; 1733 goto out;
2061 } 1734 }
2062 1735
2063 dwrq->flags = index + 1; 1736 dwrq->flags = index + 1;
2064 memset(ext, 0, sizeof(*ext)); 1737 memset(ext, 0, sizeof(*ext));
2065 1738
2066 if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) 1739 if ( !adapter->secinfo.wep_enabled
2067 && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) { 1740 && !adapter->secinfo.WPAenabled
1741 && !adapter->secinfo.WPA2enabled) {
2068 ext->alg = IW_ENCODE_ALG_NONE; 1742 ext->alg = IW_ENCODE_ALG_NONE;
2069 ext->key_len = 0; 1743 ext->key_len = 0;
2070 dwrq->flags |= IW_ENCODE_DISABLED; 1744 dwrq->flags |= IW_ENCODE_DISABLED;
2071 } else { 1745 } else {
2072 u8 *key = NULL; 1746 u8 *key = NULL;
2073 1747
2074 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) 1748 if ( adapter->secinfo.wep_enabled
2075 && !adapter->secinfo.WPAenabled 1749 && !adapter->secinfo.WPAenabled
2076 && !adapter->secinfo.WPA2enabled) { 1750 && !adapter->secinfo.WPA2enabled) {
2077 ext->alg = IW_ENCODE_ALG_WEP; 1751 ext->alg = IW_ENCODE_ALG_WEP;
2078 ext->key_len = adapter->wep_keys[index].len; 1752 ext->key_len = adapter->wep_keys[index].len;
2079 key = &adapter->wep_keys[index].key[0]; 1753 key = &adapter->wep_keys[index].key[0];
2080 } else if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) && 1754 } else if ( !adapter->secinfo.wep_enabled
2081 (adapter->secinfo.WPAenabled || 1755 && (adapter->secinfo.WPAenabled ||
2082 adapter->secinfo.WPA2enabled)) { 1756 adapter->secinfo.WPA2enabled)) {
2083 /* WPA */ 1757 /* WPA */
2084 ext->alg = IW_ENCODE_ALG_TKIP; 1758 ext->alg = IW_ENCODE_ALG_TKIP;
2085 ext->key_len = 0; 1759 ext->key_len = 0;
@@ -2149,7 +1823,7 @@ static int wlan_set_encodeext(struct net_device *dev,
2149 /* If WEP isn't enabled, or if there is no key data but a valid 1823 /* If WEP isn't enabled, or if there is no key data but a valid
2150 * index, or if the set-TX-key flag was passed, set the TX key. 1824 * index, or if the set-TX-key flag was passed, set the TX key.
2151 */ 1825 */
2152 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) 1826 if ( !assoc_req->secinfo.wep_enabled
2153 || (dwrq->length == 0 && !is_default) 1827 || (dwrq->length == 0 && !is_default)
2154 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) 1828 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
2155 set_tx_key = 1; 1829 set_tx_key = 1;
@@ -2161,11 +1835,9 @@ static int wlan_set_encodeext(struct net_device *dev,
2161 goto out; 1835 goto out;
2162 1836
2163 if (dwrq->flags & IW_ENCODE_RESTRICTED) { 1837 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
2164 assoc_req->secinfo.authmode = 1838 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
2165 wlan802_11authmodeshared;
2166 } else if (dwrq->flags & IW_ENCODE_OPEN) { 1839 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2167 assoc_req->secinfo.authmode = 1840 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2168 wlan802_11authmodeopen;
2169 } 1841 }
2170 1842
2171 /* Mark the various WEP bits as modified */ 1843 /* Mark the various WEP bits as modified */
@@ -2350,15 +2022,13 @@ static int wlan_set_auth(struct net_device *dev,
2350 } 2022 }
2351 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { 2023 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
2352 assoc_req->secinfo.WPAenabled = 1; 2024 assoc_req->secinfo.WPAenabled = 1;
2353 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 2025 assoc_req->secinfo.wep_enabled = 0;
2354 assoc_req->secinfo.authmode = 2026 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2355 wlan802_11authmodeopen;
2356 } 2027 }
2357 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { 2028 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
2358 assoc_req->secinfo.WPA2enabled = 1; 2029 assoc_req->secinfo.WPA2enabled = 1;
2359 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 2030 assoc_req->secinfo.wep_enabled = 0;
2360 assoc_req->secinfo.authmode = 2031 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2361 wlan802_11authmodeopen;
2362 } 2032 }
2363 updated = 1; 2033 updated = 1;
2364 break; 2034 break;
@@ -2376,14 +2046,11 @@ static int wlan_set_auth(struct net_device *dev,
2376 2046
2377 case IW_AUTH_80211_AUTH_ALG: 2047 case IW_AUTH_80211_AUTH_ALG:
2378 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { 2048 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
2379 assoc_req->secinfo.authmode = 2049 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
2380 wlan802_11authmodeshared;
2381 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { 2050 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
2382 assoc_req->secinfo.authmode = 2051 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2383 wlan802_11authmodeopen;
2384 } else if (dwrq->value & IW_AUTH_ALG_LEAP) { 2052 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
2385 assoc_req->secinfo.authmode = 2053 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
2386 wlan802_11authmodenetworkEAP;
2387 } else { 2054 } else {
2388 ret = -EINVAL; 2055 ret = -EINVAL;
2389 } 2056 }
@@ -2396,9 +2063,8 @@ static int wlan_set_auth(struct net_device *dev,
2396 !assoc_req->secinfo.WPA2enabled) { 2063 !assoc_req->secinfo.WPA2enabled) {
2397 assoc_req->secinfo.WPAenabled = 1; 2064 assoc_req->secinfo.WPAenabled = 1;
2398 assoc_req->secinfo.WPA2enabled = 1; 2065 assoc_req->secinfo.WPA2enabled = 1;
2399 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 2066 assoc_req->secinfo.wep_enabled = 0;
2400 assoc_req->secinfo.authmode = 2067 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2401 wlan802_11authmodeopen;
2402 } 2068 }
2403 } else { 2069 } else {
2404 assoc_req->secinfo.WPAenabled = 0; 2070 assoc_req->secinfo.WPAenabled = 0;
@@ -2455,19 +2121,7 @@ static int wlan_get_auth(struct net_device *dev,
2455 break; 2121 break;
2456 2122
2457 case IW_AUTH_80211_AUTH_ALG: 2123 case IW_AUTH_80211_AUTH_ALG:
2458 switch (adapter->secinfo.authmode) { 2124 dwrq->value = adapter->secinfo.auth_mode;
2459 case wlan802_11authmodeshared:
2460 dwrq->value = IW_AUTH_ALG_SHARED_KEY;
2461 break;
2462 case wlan802_11authmodeopen:
2463 dwrq->value = IW_AUTH_ALG_OPEN_SYSTEM;
2464 break;
2465 case wlan802_11authmodenetworkEAP:
2466 dwrq->value = IW_AUTH_ALG_LEAP;
2467 break;
2468 default:
2469 break;
2470 }
2471 break; 2125 break;
2472 2126
2473 case IW_AUTH_WPA_ENABLED: 2127 case IW_AUTH_WPA_ENABLED:
diff --git a/drivers/net/wireless/libertas/wext.h b/drivers/net/wireless/libertas/wext.h
index 39f367c38d90..15cfaaf0797f 100644
--- a/drivers/net/wireless/libertas/wext.h
+++ b/drivers/net/wireless/libertas/wext.h
@@ -10,88 +10,22 @@
10/** PRIVATE CMD ID */ 10/** PRIVATE CMD ID */
11#define WLANIOCTL SIOCIWFIRSTPRIV 11#define WLANIOCTL SIOCIWFIRSTPRIV
12 12
13#define WLANSETWPAIE (WLANIOCTL + 0)
14
15#define WLAN_SETINT_GETINT (WLANIOCTL + 7)
16#define WLANNF 1
17#define WLANRSSI 2
18#define WLANENABLE11D 5
19#define WLANADHOCGRATE 6
20#define WLAN_SUBCMD_SET_PRESCAN 11
21
22#define WLAN_SETNONE_GETNONE (WLANIOCTL + 8) 13#define WLAN_SETNONE_GETNONE (WLANIOCTL + 8)
23#define WLANDEAUTH 1
24#define WLANRADIOON 2
25#define WLANRADIOOFF 3
26#define WLANREMOVEADHOCAES 4
27#define WLANADHOCSTOP 5
28#define WLANCIPHERTEST 6
29#define WLANCRYPTOTEST 7
30
31#define WLANWLANIDLEON 10
32#define WLANWLANIDLEOFF 11
33#define WLAN_SUBCMD_BT_RESET 13 14#define WLAN_SUBCMD_BT_RESET 13
34#define WLAN_SUBCMD_FWT_RESET 14 15#define WLAN_SUBCMD_FWT_RESET 14
35 16
36#define WLANGETLOG (WLANIOCTL + 9)
37#define GETLOG_BUFSIZE 300
38
39#define WLANSCAN_TYPE (WLANIOCTL + 11)
40
41#define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15) 17#define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15)
42#define WLANGETREGION 1 18#define WLANGETREGION 1
43#define WLAN_GET_LISTEN_INTERVAL 2
44#define WLAN_GET_MULTIPLE_DTIM 3
45#define WLAN_GET_TX_RATE 4
46#define WLANGETBCNAVG 5
47 19
48#define WLAN_GET_LINKMODE 6
49#define WLAN_GET_RADIOMODE 7
50#define WLAN_GET_DEBUGMODE 8
51#define WLAN_SUBCMD_FWT_CLEANUP 15 20#define WLAN_SUBCMD_FWT_CLEANUP 15
52#define WLAN_SUBCMD_FWT_TIME 16 21#define WLAN_SUBCMD_FWT_TIME 16
53#define WLAN_SUBCMD_MESH_GET_TTL 17 22#define WLAN_SUBCMD_MESH_GET_TTL 17
54 23
55#define WLANREGCFRDWR (WLANIOCTL + 18)
56
57#define WLAN_SETNONE_GETTWELVE_CHAR (WLANIOCTL + 19)
58#define WLAN_SUBCMD_GETRXANTENNA 1
59#define WLAN_SUBCMD_GETTXANTENNA 2
60#define WLAN_GET_TSF 3
61
62#define WLAN_SETNONE_GETWORDCHAR (WLANIOCTL + 21)
63#define WLANGETADHOCAES 1
64
65#define WLAN_SETONEINT_GETONEINT (WLANIOCTL + 23)
66#define WLAN_BEACON_INTERVAL 1
67#define WLAN_LISTENINTRVL 4
68
69#define WLAN_TXCONTROL 6
70#define WLAN_NULLPKTINTERVAL 7
71
72#define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) 24#define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24)
73#define WLAN_SUBCMD_SETRXANTENNA 1
74#define WLAN_SUBCMD_SETTXANTENNA 2
75#define WLANSETAUTHALG 5
76#define WLANSET8021XAUTHALG 6
77#define WLANSETENCRYPTIONMODE 7
78#define WLANSETREGION 8 25#define WLANSETREGION 8
79#define WLAN_SET_LISTEN_INTERVAL 9
80
81#define WLAN_SET_MULTIPLE_DTIM 10
82#define WLAN_SET_ATIM_WINDOW 11
83#define WLANSETBCNAVG 13
84#define WLANSETDATAAVG 14
85#define WLAN_SET_LINKMODE 15
86#define WLAN_SET_RADIOMODE 16
87#define WLAN_SET_DEBUGMODE 17
88#define WLAN_SUBCMD_MESH_SET_TTL 18 26#define WLAN_SUBCMD_MESH_SET_TTL 18
89 27
90#define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) 28#define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25)
91#define WLANSCAN_MODE 6
92
93#define WLAN_GET_ADHOC_STATUS 9
94
95#define WLAN_SUBCMD_BT_ADD 18 29#define WLAN_SUBCMD_BT_ADD 18
96#define WLAN_SUBCMD_BT_DEL 19 30#define WLAN_SUBCMD_BT_DEL 19
97#define WLAN_SUBCMD_BT_LIST 20 31#define WLAN_SUBCMD_BT_LIST 20
@@ -103,27 +37,8 @@
103#define WLAN_SUBCMD_FWT_LIST_ROUTE 26 37#define WLAN_SUBCMD_FWT_LIST_ROUTE 26
104 38
105#define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) 39#define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29)
106#define WLAN_TPCCFG 1
107#define WLAN_POWERCFG 2
108
109#define WLAN_AUTO_FREQ_SET 3
110#define WLAN_AUTO_FREQ_GET 4
111#define WLAN_LED_GPIO_CTRL 5 40#define WLAN_LED_GPIO_CTRL 5
112#define WLAN_SCANPROBES 6
113#define WLAN_ADAPT_RATESET 8
114#define WLAN_INACTIVITY_TIMEOUT 9
115#define WLANSNR 10
116#define WLAN_GET_RATE 11
117#define WLAN_GET_RXINFO 12
118
119#define WLANCMD52RDWR (WLANIOCTL + 30)
120#define WLANCMD53RDWR (WLANIOCTL + 31)
121#define CMD53BUFLEN 32
122 41
123#define REG_MAC 0x19
124#define REG_BBP 0x1a
125#define REG_RF 0x1b
126#define REG_EEPROM 0x59
127#define WLAN_LINKMODE_802_3 0 42#define WLAN_LINKMODE_802_3 0
128#define WLAN_LINKMODE_802_11 2 43#define WLAN_LINKMODE_802_11 2
129#define WLAN_RADIOMODE_NONE 0 44#define WLAN_RADIOMODE_NONE 0
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index e6740d1a0824..d9cbd586ae4b 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -549,8 +549,10 @@ static int msi_free_irqs(struct pci_dev* dev)
549{ 549{
550 struct msi_desc *entry, *tmp; 550 struct msi_desc *entry, *tmp;
551 551
552 list_for_each_entry(entry, &dev->msi_list, list) 552 list_for_each_entry(entry, &dev->msi_list, list) {
553 BUG_ON(irq_has_action(entry->irq)); 553 if (entry->irq)
554 BUG_ON(irq_has_action(entry->irq));
555 }
554 556
555 arch_teardown_msi_irqs(dev); 557 arch_teardown_msi_irqs(dev);
556 558
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 147d86f8edbf..6ccc2e95930a 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -875,6 +875,7 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev)
875 } 875 }
876} 876}
877DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); 877DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata);
878DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_sb600_sata);
878 879
879/* 880/*
880 * Serverworks CSB5 IDE does not fully support native mode 881 * Serverworks CSB5 IDE does not fully support native mode
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 7906d750aa77..27d936279574 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -140,7 +140,6 @@ enum {
140 140
141 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ 141 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */
142 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ 142 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */
143 ATA_DFLAG_SUSPENDED = (1 << 10), /* device suspended */
144 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 143 ATA_DFLAG_INIT_MASK = (1 << 16) - 1,
145 144
146 ATA_DFLAG_DETACH = (1 << 16), 145 ATA_DFLAG_DETACH = (1 << 16),
@@ -191,6 +190,7 @@ enum {
191 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ 190 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */
192 ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ 191 ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */
193 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ 192 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */
193 ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */
194 194
195 ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */ 195 ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */
196 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ 196 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */
@@ -254,10 +254,6 @@ enum {
254 ATA_DMA_PAD_SZ = 4, 254 ATA_DMA_PAD_SZ = 4,
255 ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, 255 ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,
256 256
257 /* masks for port functions */
258 ATA_PORT_PRIMARY = (1 << 0),
259 ATA_PORT_SECONDARY = (1 << 1),
260
261 /* ering size */ 257 /* ering size */
262 ATA_ERING_SIZE = 32, 258 ATA_ERING_SIZE = 32,
263 259
@@ -268,13 +264,9 @@ enum {
268 ATA_EH_REVALIDATE = (1 << 0), 264 ATA_EH_REVALIDATE = (1 << 0),
269 ATA_EH_SOFTRESET = (1 << 1), 265 ATA_EH_SOFTRESET = (1 << 1),
270 ATA_EH_HARDRESET = (1 << 2), 266 ATA_EH_HARDRESET = (1 << 2),
271 ATA_EH_SUSPEND = (1 << 3),
272 ATA_EH_RESUME = (1 << 4),
273 ATA_EH_PM_FREEZE = (1 << 5),
274 267
275 ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 268 ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
276 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_SUSPEND | 269 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE,
277 ATA_EH_RESUME | ATA_EH_PM_FREEZE,
278 270
279 /* ata_eh_info->flags */ 271 /* ata_eh_info->flags */
280 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 272 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -466,7 +458,7 @@ struct ata_device {
466 struct ata_ering ering; 458 struct ata_ering ering;
467 int spdn_cnt; 459 int spdn_cnt;
468 unsigned int horkage; /* List of broken features */ 460 unsigned int horkage; /* List of broken features */
469#ifdef CONFIG_SATA_ACPI 461#ifdef CONFIG_ATA_ACPI
470 /* ACPI objects info */ 462 /* ACPI objects info */
471 acpi_handle obj_handle; 463 acpi_handle obj_handle;
472#endif 464#endif
@@ -693,8 +685,8 @@ extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes);
693extern void ata_port_disable(struct ata_port *); 685extern void ata_port_disable(struct ata_port *);
694extern void ata_std_ports(struct ata_ioports *ioaddr); 686extern void ata_std_ports(struct ata_ioports *ioaddr);
695#ifdef CONFIG_PCI 687#ifdef CONFIG_PCI
696extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 688extern int ata_pci_init_one (struct pci_dev *pdev,
697 unsigned int n_ports); 689 const struct ata_port_info * const * ppi);
698extern void ata_pci_remove_one (struct pci_dev *pdev); 690extern void ata_pci_remove_one (struct pci_dev *pdev);
699#ifdef CONFIG_PM 691#ifdef CONFIG_PM
700extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); 692extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
@@ -736,8 +728,6 @@ extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val);
736extern int ata_port_online(struct ata_port *ap); 728extern int ata_port_online(struct ata_port *ap);
737extern int ata_port_offline(struct ata_port *ap); 729extern int ata_port_offline(struct ata_port *ap);
738#ifdef CONFIG_PM 730#ifdef CONFIG_PM
739extern int ata_scsi_device_resume(struct scsi_device *);
740extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg);
741extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 731extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
742extern void ata_host_resume(struct ata_host *host); 732extern void ata_host_resume(struct ata_host *host);
743#endif 733#endif
@@ -861,11 +851,11 @@ struct pci_bits {
861 unsigned long val; 851 unsigned long val;
862}; 852};
863 853
864extern int ata_pci_init_native_host(struct ata_host *host, 854extern int ata_pci_init_native_host(struct ata_host *host);
865 unsigned int port_mask); 855extern int ata_pci_init_bmdma(struct ata_host *host);
866extern int ata_pci_prepare_native_host(struct pci_dev *pdev, 856extern int ata_pci_prepare_native_host(struct pci_dev *pdev,
867 const struct ata_port_info * const * ppi, 857 const struct ata_port_info * const * ppi,
868 int n_ports, struct ata_host **r_host); 858 struct ata_host **r_host);
869extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 859extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
870extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); 860extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long);
871#endif /* CONFIG_PCI */ 861#endif /* CONFIG_PCI */
@@ -1008,11 +998,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
1008 return ata_class_absent(dev->class); 998 return ata_class_absent(dev->class);
1009} 999}
1010 1000
1011static inline unsigned int ata_dev_ready(const struct ata_device *dev)
1012{
1013 return ata_dev_enabled(dev) && !(dev->flags & ATA_DFLAG_SUSPENDED);
1014}
1015
1016/* 1001/*
1017 * port helpers 1002 * port helpers
1018 */ 1003 */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ae849f0d4430..ccd85e4d3b8f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -370,6 +370,7 @@
370#define PCI_DEVICE_ID_ATI_IXP600_SATA 0x4380 370#define PCI_DEVICE_ID_ATI_IXP600_SATA 0x4380
371#define PCI_DEVICE_ID_ATI_IXP600_SMBUS 0x4385 371#define PCI_DEVICE_ID_ATI_IXP600_SMBUS 0x4385
372#define PCI_DEVICE_ID_ATI_IXP600_IDE 0x438c 372#define PCI_DEVICE_ID_ATI_IXP600_IDE 0x438c
373#define PCI_DEVICE_ID_ATI_IXP700_SATA 0x4390
373 374
374#define PCI_VENDOR_ID_VLSI 0x1004 375#define PCI_VENDOR_ID_VLSI 0x1004
375#define PCI_DEVICE_ID_VLSI_82C592 0x0005 376#define PCI_DEVICE_ID_VLSI_82C592 0x0005