diff --git a/[refs] b/[refs] index 42ca3be0a310..e076ba1d5905 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c5b7bede71853d92fc747cdc12fa5234b6045731 +refs/heads/master: 0c12fe5697f12c7d1d203d8152dc6382244ec1d3 diff --git a/trunk/Documentation/feature-removal-schedule.txt b/trunk/Documentation/feature-removal-schedule.txt index 498ff31f3aa1..c6322c760348 100644 --- a/trunk/Documentation/feature-removal-schedule.txt +++ b/trunk/Documentation/feature-removal-schedule.txt @@ -328,22 +328,3 @@ Who: Adrian Bunk --------------------------- -What: libata.spindown_compat module parameter -When: Dec 2008 -Why: halt(8) synchronizes caches for and spins down libata disks - because libata didn't use to spin down disk on system halt - (only synchronized caches). - Spin down on system halt is now implemented and can be tested - using sysfs node /sys/class/scsi_disk/h:c:i:l/manage_start_stop. - Because issuing spin down command to an already spun down disk - makes some disks spin up just to spin down again, the old - behavior needs to be maintained till userspace tool is updated - to check the sysfs node and not to spin down disks with the - node set to one. - This module parameter is to give userspace tool the time to - get updated and should be removed after userspace is - reasonably updated. -Who: Tejun Heo - ---------------------------- - diff --git a/trunk/arch/powerpc/mm/hash_native_64.c b/trunk/arch/powerpc/mm/hash_native_64.c index 7d722eea4ea8..59502c3222e3 100644 --- a/trunk/arch/powerpc/mm/hash_native_64.c +++ b/trunk/arch/powerpc/mm/hash_native_64.c @@ -395,7 +395,7 @@ static void hpte_decode(hpte_t *hpte, unsigned long slot, vpi = (vsid ^ (vsid << 25) ^ pteg) & htab_hash_mask; break; default: - avpn = vpi = psize = 0; + avpn = vpi = size = 0; } avpn |= (vpi << mmu_psize_defs[size].shift); } diff --git a/trunk/drivers/ata/Kconfig b/trunk/drivers/ata/Kconfig index ad1f59c1b3fc..f031b8732330 100644 --- a/trunk/drivers/ata/Kconfig +++ b/trunk/drivers/ata/Kconfig @@ -2,9 +2,11 @@ # SATA/PATA driver configuration # -menuconfig ATA - tristate "Serial ATA (prod) and Parallel ATA (experimental) drivers" +menu "Serial ATA (prod) and Parallel ATA (experimental) drivers" depends on HAS_IOMEM + +config ATA + tristate "ATA device support" depends on BLOCK depends on !(M32R || M68K) || BROKEN depends on !SUN4 || BROKEN @@ -22,19 +24,6 @@ config ATA_NONSTANDARD bool default n -config ATA_ACPI - bool - depends on ACPI && PCI - default y - help - This option adds support for ATA-related ACPI objects. - These ACPI objects add the ability to retrieve taskfiles - from the ACPI BIOS and write them to the disk controller. - These objects may be related to performance, security, - power management, or other areas. - You can disable this at kernel boot time by using the - option libata.noacpi=1 - config SATA_AHCI tristate "AHCI SATA support" depends on PCI @@ -168,6 +157,19 @@ config SATA_INIC162X help This option enables support for Initio 162x Serial ATA. +config SATA_ACPI + bool + depends on ACPI && PCI + default y + help + This option adds support for SATA-related ACPI objects. + These ACPI objects add the ability to retrieve taskfiles + from the ACPI BIOS and write them to the disk controller. + These objects may be related to performance, security, + power management, or other areas. + You can disable this at kernel boot time by using the + option libata.noacpi=1 + config PATA_ALI tristate "ALi PATA support (Experimental)" depends on PCI && EXPERIMENTAL @@ -583,4 +585,6 @@ config PATA_SCC If unsure, say N. -endif # ATA +endif +endmenu + diff --git a/trunk/drivers/ata/Makefile b/trunk/drivers/ata/Makefile index 8149c68ac2c7..6f42a0e2812d 100644 --- a/trunk/drivers/ata/Makefile +++ b/trunk/drivers/ata/Makefile @@ -69,4 +69,4 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o -libata-$(CONFIG_ATA_ACPI) += libata-acpi.o +libata-$(CONFIG_SATA_ACPI) += libata-acpi.o diff --git a/trunk/drivers/ata/ahci.c b/trunk/drivers/ata/ahci.c index 1ae443d7ab92..d9617892fc23 100644 --- a/trunk/drivers/ata/ahci.c +++ b/trunk/drivers/ata/ahci.c @@ -250,6 +250,10 @@ static struct scsi_host_template ahci_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static const struct ata_port_operations ahci_ops = { @@ -396,7 +400,6 @@ static const struct pci_device_id ahci_pci_tbl[] = { /* ATI */ { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ - { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 */ /* VIA */ { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ diff --git a/trunk/drivers/ata/ata_generic.c b/trunk/drivers/ata/ata_generic.c index c3d753296bc6..92a491ddd030 100644 --- a/trunk/drivers/ata/ata_generic.c +++ b/trunk/drivers/ata/ata_generic.c @@ -54,7 +54,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) for (i = 0; i < ATA_MAX_DEVICES; i++) { struct ata_device *dev = &ap->device[i]; - if (ata_dev_enabled(dev)) { + if (ata_dev_ready(dev)) { /* We don't really care */ dev->pio_mode = XFER_PIO_0; dev->dma_mode = XFER_MW_DMA_0; @@ -90,6 +90,10 @@ static struct scsi_host_template generic_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations generic_port_ops = { @@ -141,7 +145,7 @@ static int all_generic_ide; /* Set to claim all devices */ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) { u16 command; - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &generic_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -149,7 +153,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id .udma_mask = 0x3f, .port_ops = &generic_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; /* Don't use the generic entry unless instructed to do so */ if (id->driver_data == 1 && all_generic_ide == 0) @@ -175,7 +179,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id if (dev->vendor == PCI_VENDOR_ID_AL) ata_pci_clear_simplex(dev); - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, port_info, 2); } static struct pci_device_id ata_generic[] = { diff --git a/trunk/drivers/ata/ata_piix.c b/trunk/drivers/ata/ata_piix.c index 13b6b1df2ac4..4a795fdb6a02 100644 --- a/trunk/drivers/ata/ata_piix.c +++ b/trunk/drivers/ata/ata_piix.c @@ -275,6 +275,10 @@ static struct scsi_host_template piix_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations piix_pata_ops = { @@ -1030,7 +1034,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) static int printed_version; struct device *dev = &pdev->dev; struct ata_port_info port_info[2]; - const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; + struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; struct piix_host_priv *hpriv; unsigned long port_flags; @@ -1089,7 +1093,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) port_info[1].mwdma_mask = 0; port_info[1].udma_mask = 0; } - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, ppinfo, 2); } static int __init piix_init(void) diff --git a/trunk/drivers/ata/libata-acpi.c b/trunk/drivers/ata/libata-acpi.c index ed4138e24b0c..cb3eab6e379d 100644 --- a/trunk/drivers/ata/libata-acpi.c +++ b/trunk/drivers/ata/libata-acpi.c @@ -270,7 +270,8 @@ static int get_sata_adr(struct device *dev, acpi_handle handle, /** * do_drive_get_GTF - get the drive bootup default taskfile settings - * @dev: target ATA device + * @ap: the ata_port for the drive + * @ix: target ata_device (drive) index * @gtf_length: number of bytes of _GTF data returned at @gtf_address * @gtf_address: buffer containing _GTF taskfile arrays * @@ -285,19 +286,20 @@ static int get_sata_adr(struct device *dev, acpi_handle handle, * The returned @gtf_length and @gtf_address are only valid if the * function return value is 0. */ -static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, - unsigned long *gtf_address, unsigned long *obj_loc) +static int do_drive_get_GTF(struct ata_port *ap, int ix, + unsigned int *gtf_length, unsigned long *gtf_address, + unsigned long *obj_loc) { - struct ata_port *ap = dev->ap; - acpi_status status; - acpi_handle dev_handle = NULL; - acpi_handle chan_handle, drive_handle; - acpi_integer pcidevfn = 0; - u32 dev_adr; - struct acpi_buffer output; - union acpi_object *out_obj; - struct device *gdev = ap->host->dev; - int err = -ENODEV; + acpi_status status; + acpi_handle dev_handle = NULL; + acpi_handle chan_handle, drive_handle; + acpi_integer pcidevfn = 0; + u32 dev_adr; + struct acpi_buffer output; + union acpi_object *out_obj; + struct device *dev = ap->host->dev; + struct ata_device *atadev = &ap->device[ix]; + int err = -ENODEV; *gtf_length = 0; *gtf_address = 0UL; @@ -307,14 +309,14 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, return 0; if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", + ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", __FUNCTION__, ap->port_no); - if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) { + if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: " + ata_dev_printk(atadev, KERN_DEBUG, "%s: ERR: " "ata_dev_present: %d, PORT_DISABLED: %lu\n", - __FUNCTION__, ata_dev_enabled(dev), + __FUNCTION__, ata_dev_enabled(atadev), ap->flags & ATA_FLAG_DISABLED); goto out; } @@ -322,19 +324,19 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, /* Don't continue if device has no _ADR method. * _GTF is intended for known motherboard devices. */ if (!(ap->cbl == ATA_CBL_SATA)) { - err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn); + err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: pata_get_dev_handle failed (%d)\n", __FUNCTION__, err); goto out; } } else { - err = sata_get_dev_handle(gdev, &dev_handle, &pcidevfn); + err = sata_get_dev_handle(dev, &dev_handle, &pcidevfn); if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: sata_get_dev_handle failed (%d\n", __FUNCTION__, err); goto out; @@ -342,7 +344,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, } /* Get this drive's _ADR info. if not already known. */ - if (!dev->obj_handle) { + if (!atadev->obj_handle) { if (!(ap->cbl == ATA_CBL_SATA)) { /* get child objects of dev_handle == channel objects, * + _their_ children == drive objects */ @@ -350,7 +352,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, chan_handle = acpi_get_child(dev_handle, ap->port_no); if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: chan adr=%d: chan_handle=0x%p\n", __FUNCTION__, ap->port_no, chan_handle); @@ -359,26 +361,26 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, goto out; } /* TBD: could also check ACPI object VALID bits */ - drive_handle = acpi_get_child(chan_handle, dev->devno); + drive_handle = acpi_get_child(chan_handle, ix); if (!drive_handle) { err = -ENODEV; goto out; } - dev_adr = dev->devno; - dev->obj_handle = drive_handle; + dev_adr = ix; + atadev->obj_handle = drive_handle; } else { /* for SATA mode */ dev_adr = SATA_ADR_RSVD; - err = get_sata_adr(gdev, dev_handle, pcidevfn, 0, - ap, dev, &dev_adr); + err = get_sata_adr(dev, dev_handle, pcidevfn, 0, + ap, atadev, &dev_adr); } if (err < 0 || dev_adr == SATA_ADR_RSVD || - !dev->obj_handle) { + !atadev->obj_handle) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: get_sata/pata_adr failed: " "err=%d, dev_adr=%u, obj_handle=0x%p\n", __FUNCTION__, err, dev_adr, - dev->obj_handle); + atadev->obj_handle); goto out; } } @@ -389,11 +391,11 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, /* _GTF has no input parameters */ err = -EIO; - status = acpi_evaluate_object(dev->obj_handle, "_GTF", + status = acpi_evaluate_object(atadev->obj_handle, "_GTF", NULL, &output); if (ACPI_FAILURE(status)) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF error: status = 0x%x\n", __FUNCTION__, status); goto out; @@ -401,7 +403,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, if (!output.length || !output.pointer) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " + ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " "length or ptr is NULL (0x%llx, 0x%p)\n", __FUNCTION__, (unsigned long long)output.length, @@ -414,7 +416,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, if (out_obj->type != ACPI_TYPE_BUFFER) { kfree(output.pointer); if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " + ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " "error: expected object type of " " ACPI_TYPE_BUFFER, got 0x%x\n", __FUNCTION__, out_obj->type); @@ -425,7 +427,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, if (!out_obj->buffer.length || !out_obj->buffer.pointer || out_obj->buffer.length % REGS_PER_GTF) { if (ata_msg_drv(ap)) - ata_dev_printk(dev, KERN_ERR, + ata_dev_printk(atadev, KERN_ERR, "%s: unexpected GTF length (%d) or addr (0x%p)\n", __FUNCTION__, out_obj->buffer.length, out_obj->buffer.pointer); @@ -437,7 +439,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, *gtf_address = (unsigned long)out_obj->buffer.pointer; *obj_loc = (unsigned long)out_obj; if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: returning " + ata_dev_printk(atadev, KERN_DEBUG, "%s: returning " "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); err = 0; @@ -447,7 +449,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, /** * taskfile_load_raw - send taskfile registers to host controller - * @dev: target ATA device + * @ap: Port to which output is sent * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) * * Outputs ATA taskfile to standard ATA host controller using MMIO @@ -464,15 +466,15 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, * LOCKING: TBD: * Inherited from caller. */ -static void taskfile_load_raw(struct ata_device *dev, - const struct taskfile_array *gtf) +static void taskfile_load_raw(struct ata_port *ap, + struct ata_device *atadev, + const struct taskfile_array *gtf) { - struct ata_port *ap = dev->ap; struct ata_taskfile tf; unsigned int err; if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " + ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " "%02x %02x %02x %02x %02x %02x %02x\n", __FUNCTION__, gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], @@ -483,7 +485,7 @@ static void taskfile_load_raw(struct ata_device *dev, && (gtf->tfa[6] == 0)) return; - ata_tf_init(dev, &tf); + ata_tf_init(atadev, &tf); /* convert gtf to tf */ tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ @@ -496,16 +498,17 @@ static void taskfile_load_raw(struct ata_device *dev, tf.device = gtf->tfa[5]; /* 0x1f6 */ tf.command = gtf->tfa[6]; /* 0x1f7 */ - err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); + err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); if (err && ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_ERR, + ata_dev_printk(atadev, KERN_ERR, "%s: ata_exec_internal failed: %u\n", __FUNCTION__, err); } /** * do_drive_set_taskfiles - write the drive taskfile settings from _GTF - * @dev: target ATA device + * @ap: the ata_port for the drive + * @atadev: target ata_device * @gtf_length: total number of bytes of _GTF taskfiles * @gtf_address: location of _GTF taskfile arrays * @@ -514,31 +517,30 @@ static void taskfile_load_raw(struct ata_device *dev, * Write {gtf_address, length gtf_length} in groups of * REGS_PER_GTF bytes. */ -static int do_drive_set_taskfiles(struct ata_device *dev, - unsigned int gtf_length, - unsigned long gtf_address) +static int do_drive_set_taskfiles(struct ata_port *ap, + struct ata_device *atadev, unsigned int gtf_length, + unsigned long gtf_address) { - struct ata_port *ap = dev->ap; - int err = -ENODEV; - int gtf_count = gtf_length / REGS_PER_GTF; - int ix; + int err = -ENODEV; + int gtf_count = gtf_length / REGS_PER_GTF; + int ix; struct taskfile_array *gtf; if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", + ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", __FUNCTION__, ap->port_no); if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) return 0; - if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) + if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) goto out; if (!gtf_count) /* shouldn't be here */ goto out; if (gtf_length % REGS_PER_GTF) { if (ata_msg_drv(ap)) - ata_dev_printk(dev, KERN_ERR, + ata_dev_printk(atadev, KERN_ERR, "%s: unexpected GTF length (%d)\n", __FUNCTION__, gtf_length); goto out; @@ -549,7 +551,7 @@ static int do_drive_set_taskfiles(struct ata_device *dev, (gtf_address + ix * REGS_PER_GTF); /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ - taskfile_load_raw(dev, gtf); + taskfile_load_raw(ap, atadev, gtf); } err = 0; @@ -565,11 +567,11 @@ static int do_drive_set_taskfiles(struct ata_device *dev, */ int ata_acpi_exec_tfs(struct ata_port *ap) { - int ix; - int ret = 0; - unsigned int gtf_length; - unsigned long gtf_address; - unsigned long obj_loc; + int ix; + int ret =0; + unsigned int gtf_length; + unsigned long gtf_address; + unsigned long obj_loc; if (libata_noacpi) return 0; @@ -582,13 +584,11 @@ int ata_acpi_exec_tfs(struct ata_port *ap) return 0; for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { - struct ata_device *dev = &ap->device[ix]; - - if (!ata_dev_enabled(dev)) + if (!ata_dev_enabled(&ap->device[ix])) continue; - ret = do_drive_get_GTF(dev, >f_length, >f_address, - &obj_loc); + ret = do_drive_get_GTF(ap, ix, + >f_length, >f_address, &obj_loc); if (ret < 0) { if (ata_msg_probe(ap)) ata_port_printk(ap, KERN_DEBUG, @@ -597,7 +597,8 @@ int ata_acpi_exec_tfs(struct ata_port *ap) break; } - ret = do_drive_set_taskfiles(dev, gtf_length, gtf_address); + ret = do_drive_set_taskfiles(ap, &ap->device[ix], + gtf_length, gtf_address); kfree((void *)obj_loc); if (ret < 0) { if (ata_msg_probe(ap)) @@ -613,7 +614,8 @@ int ata_acpi_exec_tfs(struct ata_port *ap) /** * ata_acpi_push_id - send Identify data to drive - * @dev: target ATA device + * @ap: the ata_port for the drive + * @ix: drive index * * _SDD ACPI object: for SATA mode only * Must be after Identify (Packet) Device -- uses its data @@ -621,57 +623,57 @@ int ata_acpi_exec_tfs(struct ata_port *ap) * method and if it fails for whatever reason, we should still * just keep going. */ -int ata_acpi_push_id(struct ata_device *dev) +int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) { - struct ata_port *ap = dev->ap; - acpi_handle handle; - acpi_integer pcidevfn; - int err; - struct device *gdev = ap->host->dev; - u32 dev_adr; - acpi_status status; - struct acpi_object_list input; - union acpi_object in_params[1]; + acpi_handle handle; + acpi_integer pcidevfn; + int err; + struct device *dev = ap->host->dev; + struct ata_device *atadev = &ap->device[ix]; + u32 dev_adr; + acpi_status status; + struct acpi_object_list input; + union acpi_object in_params[1]; if (libata_noacpi) return 0; if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", - __FUNCTION__, dev->devno, ap->port_no); + ata_dev_printk(atadev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", + __FUNCTION__, ix, ap->port_no); /* Don't continue if not a SATA device. */ if (!(ap->cbl == ATA_CBL_SATA)) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: Not a SATA device\n", __FUNCTION__); goto out; } /* Don't continue if device has no _ADR method. * _SDD is intended for known motherboard devices. */ - err = sata_get_dev_handle(gdev, &handle, &pcidevfn); + err = sata_get_dev_handle(dev, &handle, &pcidevfn); if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: sata_get_dev_handle failed (%d\n", __FUNCTION__, err); goto out; } /* Get this drive's _ADR info, if not already known */ - if (!dev->obj_handle) { + if (!atadev->obj_handle) { dev_adr = SATA_ADR_RSVD; - err = get_sata_adr(gdev, handle, pcidevfn, dev->devno, ap, dev, + err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev, &dev_adr); if (err < 0 || dev_adr == SATA_ADR_RSVD || - !dev->obj_handle) { + !atadev->obj_handle) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s: get_sata_adr failed: " "err=%d, dev_adr=%u, obj_handle=0x%p\n", __FUNCTION__, err, dev_adr, - dev->obj_handle); + atadev->obj_handle); goto out; } } @@ -681,19 +683,19 @@ int ata_acpi_push_id(struct ata_device *dev) input.count = 1; input.pointer = in_params; in_params[0].type = ACPI_TYPE_BUFFER; - in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS; - in_params[0].buffer.pointer = (u8 *)dev->id; + in_params[0].buffer.length = sizeof(atadev->id[0]) * ATA_ID_WORDS; + in_params[0].buffer.pointer = (u8 *)atadev->id; /* Output buffer: _SDD has no output */ /* It's OK for _SDD to be missing too. */ - swap_buf_le16(dev->id, ATA_ID_WORDS); - status = acpi_evaluate_object(dev->obj_handle, "_SDD", &input, NULL); - swap_buf_le16(dev->id, ATA_ID_WORDS); + swap_buf_le16(atadev->id, ATA_ID_WORDS); + status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL); + swap_buf_le16(atadev->id, ATA_ID_WORDS); err = ACPI_FAILURE(status) ? -EIO : 0; if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, + ata_dev_printk(atadev, KERN_DEBUG, "%s _SDD error: status = 0x%x\n", __FUNCTION__, status); } diff --git a/trunk/drivers/ata/libata-core.c b/trunk/drivers/ata/libata-core.c index 4166407eb47c..4595d1f8cf60 100644 --- a/trunk/drivers/ata/libata-core.c +++ b/trunk/drivers/ata/libata-core.c @@ -101,12 +101,6 @@ int libata_noacpi = 1; module_param_named(noacpi, libata_noacpi, int, 0444); MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); -int ata_spindown_compat = 1; -module_param_named(spindown_compat, ata_spindown_compat, int, 0644); -MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown " - "behavior. Will be removed. More info can be found in " - "Documentation/feature-removal-schedule.txt\n"); - MODULE_AUTHOR("Jeff Garzik"); MODULE_DESCRIPTION("Library module for ATA devices"); MODULE_LICENSE("GPL"); @@ -1660,7 +1654,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, struct ata_taskfile tf; unsigned int err_mask = 0; const char *reason; - int may_fallback = 1, tried_spinup = 0; + int tried_spinup = 0; int rc; if (ata_msg_ctl(ap)) @@ -1704,31 +1698,11 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, return -ENOENT; } - /* Device or controller might have reported the wrong - * device class. Give a shot at the other IDENTIFY if - * the current one is aborted by the device. - */ - if (may_fallback && - (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { - may_fallback = 0; - - if (class == ATA_DEV_ATA) - class = ATA_DEV_ATAPI; - else - class = ATA_DEV_ATA; - goto retry; - } - rc = -EIO; reason = "I/O error"; goto err_out; } - /* Falling back doesn't make sense if ID data was read - * successfully at least once. - */ - may_fallback = 0; - swap_buf_le16(id, ATA_ID_WORDS); /* sanity check */ @@ -1869,7 +1843,7 @@ int ata_dev_configure(struct ata_device *dev) ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); /* set _SDD */ - rc = ata_acpi_push_id(dev); + rc = ata_acpi_push_id(ap, dev->devno); if (rc) { ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", rc); @@ -2886,7 +2860,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) dev = &ap->device[i]; /* don't update suspended devices' xfer mode */ - if (!ata_dev_enabled(dev)) + if (!ata_dev_ready(dev)) continue; rc = ata_dev_set_mode(dev); @@ -5871,11 +5845,37 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg, */ int ata_host_suspend(struct ata_host *host, pm_message_t mesg) { - int rc; + int i, j, rc; rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); - if (rc == 0) - host->dev->power.power_state = mesg; + if (rc) + goto fail; + + /* EH is quiescent now. Fail if we have any ready device. + * This happens if hotplug occurs between completion of device + * suspension and here. + */ + for (i = 0; i < host->n_ports; i++) { + struct ata_port *ap = host->ports[i]; + + for (j = 0; j < ATA_MAX_DEVICES; j++) { + struct ata_device *dev = &ap->device[j]; + + if (ata_dev_ready(dev)) { + ata_port_printk(ap, KERN_WARNING, + "suspend failed, device %d " + "still active\n", dev->devno); + rc = -EBUSY; + goto fail; + } + } + } + + host->dev->power.power_state = mesg; + return 0; + + fail: + ata_host_resume(host); return rc; } @@ -5984,7 +5984,6 @@ struct ata_port *ata_port_alloc(struct ata_host *host) if (!ap) return NULL; - ap->pflags |= ATA_PFLAG_INITIALIZING; ap->lock = &host->lock; ap->flags = ATA_FLAG_DISABLED; ap->print_id = -1; @@ -6353,7 +6352,6 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) ehi->action |= ATA_EH_SOFTRESET; ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; - ap->pflags &= ~ATA_PFLAG_INITIALIZING; ap->pflags |= ATA_PFLAG_LOADING; ata_port_schedule_eh(ap); @@ -6878,7 +6876,6 @@ EXPORT_SYMBOL_GPL(ata_timing_merge); #ifdef CONFIG_PCI EXPORT_SYMBOL_GPL(pci_test_config_bits); EXPORT_SYMBOL_GPL(ata_pci_init_native_host); -EXPORT_SYMBOL_GPL(ata_pci_init_bmdma); EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); EXPORT_SYMBOL_GPL(ata_pci_init_one); EXPORT_SYMBOL_GPL(ata_pci_remove_one); @@ -6892,6 +6889,11 @@ EXPORT_SYMBOL_GPL(ata_pci_default_filter); EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); #endif /* CONFIG_PCI */ +#ifdef CONFIG_PM +EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); +EXPORT_SYMBOL_GPL(ata_scsi_device_resume); +#endif /* CONFIG_PM */ + EXPORT_SYMBOL_GPL(ata_eng_timeout); EXPORT_SYMBOL_GPL(ata_port_schedule_eh); EXPORT_SYMBOL_GPL(ata_port_abort); diff --git a/trunk/drivers/ata/libata-eh.c b/trunk/drivers/ata/libata-eh.c index 5309c312f517..8256655ce7d9 100644 --- a/trunk/drivers/ata/libata-eh.c +++ b/trunk/drivers/ata/libata-eh.c @@ -77,12 +77,29 @@ static void ata_eh_finish(struct ata_port *ap); #ifdef CONFIG_PM static void ata_eh_handle_port_suspend(struct ata_port *ap); static void ata_eh_handle_port_resume(struct ata_port *ap); +static int ata_eh_suspend(struct ata_port *ap, + struct ata_device **r_failed_dev); +static void ata_eh_prep_resume(struct ata_port *ap); +static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev); #else /* CONFIG_PM */ static void ata_eh_handle_port_suspend(struct ata_port *ap) { } static void ata_eh_handle_port_resume(struct ata_port *ap) { } + +static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) +{ + return 0; +} + +static void ata_eh_prep_resume(struct ata_port *ap) +{ } + +static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) +{ + return 0; +} #endif /* CONFIG_PM */ static void ata_ering_record(struct ata_ering *ering, int is_io, @@ -551,9 +568,6 @@ void ata_port_schedule_eh(struct ata_port *ap) { WARN_ON(!ap->ops->error_handler); - if (ap->pflags & ATA_PFLAG_INITIALIZING) - return; - ap->pflags |= ATA_PFLAG_EH_PENDING; scsi_schedule_eh(ap->scsi_host); @@ -1777,7 +1791,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, if (ehc->i.flags & ATA_EHI_DID_RESET) readid_flags |= ATA_READID_POSTRESET; - if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { + if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { if (ata_port_offline(ap)) { rc = -EIO; goto err; @@ -1858,6 +1872,166 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, return rc; } +#ifdef CONFIG_PM +/** + * ata_eh_suspend - handle suspend EH action + * @ap: target host port + * @r_failed_dev: result parameter to indicate failing device + * + * Handle suspend EH action. Disk devices are spinned down and + * other types of devices are just marked suspended. Once + * suspended, no EH action to the device is allowed until it is + * resumed. + * + * LOCKING: + * Kernel thread context (may sleep). + * + * RETURNS: + * 0 on success, -errno otherwise + */ +static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) +{ + struct ata_device *dev; + int i, rc = 0; + + DPRINTK("ENTER\n"); + + for (i = 0; i < ATA_MAX_DEVICES; i++) { + unsigned long flags; + unsigned int action, err_mask; + + dev = &ap->device[i]; + action = ata_eh_dev_action(dev); + + if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND)) + continue; + + WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED); + + ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND); + + if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { + /* flush cache */ + rc = ata_flush_cache(dev); + if (rc) + break; + + /* spin down */ + err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); + if (err_mask) { + ata_dev_printk(dev, KERN_ERR, "failed to " + "spin down (err_mask=0x%x)\n", + err_mask); + rc = -EIO; + break; + } + } + + spin_lock_irqsave(ap->lock, flags); + dev->flags |= ATA_DFLAG_SUSPENDED; + spin_unlock_irqrestore(ap->lock, flags); + + ata_eh_done(ap, dev, ATA_EH_SUSPEND); + } + + if (rc) + *r_failed_dev = dev; + + DPRINTK("EXIT\n"); + return rc; +} + +/** + * ata_eh_prep_resume - prep for resume EH action + * @ap: target host port + * + * Clear SUSPENDED in preparation for scheduled resume actions. + * This allows other parts of EH to access the devices being + * resumed. + * + * LOCKING: + * Kernel thread context (may sleep). + */ +static void ata_eh_prep_resume(struct ata_port *ap) +{ + struct ata_device *dev; + unsigned long flags; + int i; + + DPRINTK("ENTER\n"); + + for (i = 0; i < ATA_MAX_DEVICES; i++) { + unsigned int action; + + dev = &ap->device[i]; + action = ata_eh_dev_action(dev); + + if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) + continue; + + spin_lock_irqsave(ap->lock, flags); + dev->flags &= ~ATA_DFLAG_SUSPENDED; + spin_unlock_irqrestore(ap->lock, flags); + } + + DPRINTK("EXIT\n"); +} + +/** + * ata_eh_resume - handle resume EH action + * @ap: target host port + * @r_failed_dev: result parameter to indicate failing device + * + * Handle resume EH action. Target devices are already reset and + * revalidated. Spinning up is the only operation left. + * + * LOCKING: + * Kernel thread context (may sleep). + * + * RETURNS: + * 0 on success, -errno otherwise + */ +static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) +{ + struct ata_device *dev; + int i, rc = 0; + + DPRINTK("ENTER\n"); + + for (i = 0; i < ATA_MAX_DEVICES; i++) { + unsigned int action, err_mask; + + dev = &ap->device[i]; + action = ata_eh_dev_action(dev); + + if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) + continue; + + ata_eh_about_to_do(ap, dev, ATA_EH_RESUME); + + if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { + err_mask = ata_do_simple_cmd(dev, + ATA_CMD_IDLEIMMEDIATE); + if (err_mask) { + ata_dev_printk(dev, KERN_ERR, "failed to " + "spin up (err_mask=0x%x)\n", + err_mask); + rc = -EIO; + break; + } + } + + ata_eh_done(ap, dev, ATA_EH_RESUME); + } + + if (rc) + *r_failed_dev = dev; + + DPRINTK("EXIT\n"); + return 0; +} +#endif /* CONFIG_PM */ + static int ata_port_nr_enabled(struct ata_port *ap) { int i, cnt = 0; @@ -1883,6 +2057,17 @@ static int ata_eh_skip_recovery(struct ata_port *ap) struct ata_eh_context *ehc = &ap->eh_context; int i; + /* skip if all possible devices are suspended */ + for (i = 0; i < ata_port_max_devices(ap); i++) { + struct ata_device *dev = &ap->device[i]; + + if (!(dev->flags & ATA_DFLAG_SUSPENDED)) + break; + } + + if (i == ata_port_max_devices(ap)) + return 1; + /* thaw frozen port, resume link and recover failed devices */ if ((ap->pflags & ATA_PFLAG_FROZEN) || (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) @@ -1962,6 +2147,9 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, if (ap->pflags & ATA_PFLAG_UNLOADING) goto out; + /* prep for resume */ + ata_eh_prep_resume(ap); + /* skip EH if possible. */ if (ata_eh_skip_recovery(ap)) ehc->i.action = 0; @@ -1989,6 +2177,11 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, if (rc) goto dev_fail; + /* resume devices */ + rc = ata_eh_resume(ap, &dev); + if (rc) + goto dev_fail; + /* configure transfer mode if necessary */ if (ehc->i.flags & ATA_EHI_SETMODE) { rc = ata_set_mode(ap, &dev); @@ -1997,16 +2190,25 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ehc->i.flags &= ~ATA_EHI_SETMODE; } + /* suspend devices */ + rc = ata_eh_suspend(ap, &dev); + if (rc) + goto dev_fail; + goto out; dev_fail: ehc->tries[dev->devno]--; switch (rc) { + case -EINVAL: + /* eeek, something went very wrong, give up */ + ehc->tries[dev->devno] = 0; + break; + case -ENODEV: /* device missing or wrong IDENTIFY data, schedule probing */ ehc->i.probe_mask |= (1 << dev->devno); - case -EINVAL: /* give it just one more chance */ ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); case -EIO: @@ -2188,13 +2390,22 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap) * * Resume @ap. * + * This function also waits upto one second until all devices + * hanging off this port requests resume EH action. This is to + * prevent invoking EH and thus reset multiple times on resume. + * + * On DPM resume, where some of devices might not be resumed + * together, this may delay port resume upto one second, but such + * DPM resumes are rare and 1 sec delay isn't too bad. + * * LOCKING: * Kernel thread context (may sleep). */ static void ata_eh_handle_port_resume(struct ata_port *ap) { + unsigned long timeout; unsigned long flags; - int rc = 0; + int i, rc = 0; /* are we resuming? */ spin_lock_irqsave(ap->lock, flags); @@ -2205,12 +2416,31 @@ static void ata_eh_handle_port_resume(struct ata_port *ap) } spin_unlock_irqrestore(ap->lock, flags); - WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); + /* spurious? */ + if (!(ap->pflags & ATA_PFLAG_SUSPENDED)) + goto done; if (ap->ops->port_resume) rc = ap->ops->port_resume(ap); - /* report result */ + /* give devices time to request EH */ + timeout = jiffies + HZ; /* 1s max */ + while (1) { + for (i = 0; i < ATA_MAX_DEVICES; i++) { + struct ata_device *dev = &ap->device[i]; + unsigned int action = ata_eh_dev_action(dev); + + if ((dev->flags & ATA_DFLAG_SUSPENDED) && + !(action & ATA_EH_RESUME)) + break; + } + + if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout)) + break; + msleep(10); + } + + done: spin_lock_irqsave(ap->lock, flags); ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); if (ap->pm_result) { diff --git a/trunk/drivers/ata/libata-scsi.c b/trunk/drivers/ata/libata-scsi.c index dd81fa78cdcf..9afba2ba489e 100644 --- a/trunk/drivers/ata/libata-scsi.c +++ b/trunk/drivers/ata/libata-scsi.c @@ -510,6 +510,133 @@ static void ata_dump_status(unsigned id, struct ata_taskfile *tf) } } +#ifdef CONFIG_PM +/** + * ata_scsi_device_suspend - suspend ATA device associated with sdev + * @sdev: the SCSI device to suspend + * @mesg: target power management message + * + * Request suspend EH action on the ATA device associated with + * @sdev and wait for the operation to complete. + * + * LOCKING: + * Kernel thread context (may sleep). + * + * RETURNS: + * 0 on success, -errno otherwise. + */ +int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg) +{ + struct ata_port *ap = ata_shost_to_port(sdev->host); + struct ata_device *dev = ata_scsi_find_dev(ap, sdev); + unsigned long flags; + unsigned int action; + int rc = 0; + + if (!dev) + goto out; + + spin_lock_irqsave(ap->lock, flags); + + /* wait for the previous resume to complete */ + while (dev->flags & ATA_DFLAG_SUSPENDED) { + spin_unlock_irqrestore(ap->lock, flags); + ata_port_wait_eh(ap); + spin_lock_irqsave(ap->lock, flags); + } + + /* if @sdev is already detached, nothing to do */ + if (sdev->sdev_state == SDEV_OFFLINE || + sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) + goto out_unlock; + + /* request suspend */ + action = ATA_EH_SUSPEND; + if (mesg.event != PM_EVENT_SUSPEND) + action |= ATA_EH_PM_FREEZE; + ap->eh_info.dev_action[dev->devno] |= action; + ap->eh_info.flags |= ATA_EHI_QUIET; + ata_port_schedule_eh(ap); + + spin_unlock_irqrestore(ap->lock, flags); + + /* wait for EH to do the job */ + ata_port_wait_eh(ap); + + spin_lock_irqsave(ap->lock, flags); + + /* If @sdev is still attached but the associated ATA device + * isn't suspended, the operation failed. + */ + if (sdev->sdev_state != SDEV_OFFLINE && + sdev->sdev_state != SDEV_CANCEL && sdev->sdev_state != SDEV_DEL && + !(dev->flags & ATA_DFLAG_SUSPENDED)) + rc = -EIO; + + out_unlock: + spin_unlock_irqrestore(ap->lock, flags); + out: + if (rc == 0) + sdev->sdev_gendev.power.power_state = mesg; + return rc; +} + +/** + * ata_scsi_device_resume - resume ATA device associated with sdev + * @sdev: the SCSI device to resume + * + * Request resume EH action on the ATA device associated with + * @sdev and return immediately. This enables parallel + * wakeup/spinup of devices. + * + * LOCKING: + * Kernel thread context (may sleep). + * + * RETURNS: + * 0. + */ +int ata_scsi_device_resume(struct scsi_device *sdev) +{ + struct ata_port *ap = ata_shost_to_port(sdev->host); + struct ata_device *dev = ata_scsi_find_dev(ap, sdev); + struct ata_eh_info *ehi = &ap->eh_info; + unsigned long flags; + unsigned int action; + + if (!dev) + goto out; + + spin_lock_irqsave(ap->lock, flags); + + /* if @sdev is already detached, nothing to do */ + if (sdev->sdev_state == SDEV_OFFLINE || + sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) + goto out_unlock; + + /* request resume */ + action = ATA_EH_RESUME; + if (sdev->sdev_gendev.power.power_state.event == PM_EVENT_SUSPEND) + __ata_ehi_hotplugged(ehi); + else + action |= ATA_EH_PM_FREEZE | ATA_EH_SOFTRESET; + ehi->dev_action[dev->devno] |= action; + + /* We don't want autopsy and verbose EH messages. Disable + * those if we're the only device on this link. + */ + if (ata_port_max_devices(ap) == 1) + ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; + + ata_port_schedule_eh(ap); + + out_unlock: + spin_unlock_irqrestore(ap->lock, flags); + out: + sdev->sdev_gendev.power.power_state = PMSG_ON; + return 0; +} +#endif /* CONFIG_PM */ + /** * ata_to_sense_error - convert ATA error to SCSI error * @id: ATA device number @@ -802,8 +929,6 @@ int ata_scsi_slave_config(struct scsi_device *sdev) blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); - sdev->manage_start_stop = 1; - if (dev) ata_scsi_dev_config(sdev, dev); @@ -944,35 +1069,9 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) } tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ - } else { - /* XXX: This is for backward compatibility, will be - * removed. Read Documentation/feature-removal-schedule.txt - * for more info. - */ - if (ata_spindown_compat && - (system_state == SYSTEM_HALT || - system_state == SYSTEM_POWER_OFF)) { - static int warned = 0; - - if (!warned) { - spin_unlock_irq(qc->ap->lock); - ata_dev_printk(qc->dev, KERN_WARNING, - "DISK MIGHT NOT BE SPUN DOWN PROPERLY. " - "UPDATE SHUTDOWN UTILITY\n"); - ata_dev_printk(qc->dev, KERN_WARNING, - "For more info, visit " - "http://linux-ata.org/shutdown.html\n"); - warned = 1; - ssleep(5); - spin_lock_irq(qc->ap->lock); - } - scmd->result = SAM_STAT_GOOD; - return 1; - } - + } else /* Issue ATA STANDBY IMMEDIATE command */ tf->command = ATA_CMD_STANDBYNOW1; - } /* * Standby and Idle condition timers could be implemented but that diff --git a/trunk/drivers/ata/libata-sff.c b/trunk/drivers/ata/libata-sff.c index e35d13466c69..d211db6b35a2 100644 --- a/trunk/drivers/ata/libata-sff.c +++ b/trunk/drivers/ata/libata-sff.c @@ -544,7 +544,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port) * RETURNS: * 0 on success, -errno otherwise. */ -int ata_pci_init_bmdma(struct ata_host *host) +static int ata_pci_init_bmdma(struct ata_host *host) { struct device *gdev = host->dev; struct pci_dev *pdev = to_pci_dev(gdev); @@ -566,7 +566,7 @@ int ata_pci_init_bmdma(struct ata_host *host) } host->iomap = pcim_iomap_table(pdev); - for (i = 0; i < 2; i++) { + for (i = 0; i < host->n_ports; i++) { struct ata_port *ap = host->ports[i]; void __iomem *bmdma = host->iomap[4] + 8 * i; @@ -585,52 +585,54 @@ int ata_pci_init_bmdma(struct ata_host *host) /** * ata_pci_init_native_host - acquire native ATA resources and init host * @host: target ATA host + * @port_mask: ports to consider * - * Acquire native PCI ATA resources for @host and initialize the - * first two ports of @host accordingly. Ports marked dummy are - * skipped and allocation failure makes the port dummy. + * Acquire native PCI ATA resources for @host and initialize + * @host accordoingly. * * LOCKING: * Inherited from calling layer (may sleep). * * RETURNS: - * 0 if at least one port is initialized, -ENODEV if no port is - * available. + * 0 on success, -errno otherwise. */ -int ata_pci_init_native_host(struct ata_host *host) +int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) { struct device *gdev = host->dev; struct pci_dev *pdev = to_pci_dev(gdev); - unsigned int mask = 0; int i, rc; + /* Discard disabled ports. Some controllers show their unused + * channels this way. Disabled ports are made dummy. + */ + for (i = 0; i < 2; i++) { + if ((port_mask & (1 << i)) && !ata_resources_present(pdev, i)) { + host->ports[i]->ops = &ata_dummy_port_ops; + port_mask &= ~(1 << i); + } + } + + if (!port_mask) { + dev_printk(KERN_ERR, gdev, "no available port\n"); + return -ENODEV; + } + /* request, iomap BARs and init port addresses accordingly */ for (i = 0; i < 2; i++) { struct ata_port *ap = host->ports[i]; int base = i * 2; void __iomem * const *iomap; - if (ata_port_is_dummy(ap)) - continue; - - /* Discard disabled ports. Some controllers show - * their unused channels this way. Disabled ports are - * made dummy. - */ - if (!ata_resources_present(pdev, i)) { - ap->ops = &ata_dummy_port_ops; + if (!(port_mask & (1 << i))) continue; - } rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); if (rc) { - dev_printk(KERN_WARNING, gdev, - "failed to request/iomap BARs for port %d " - "(errno=%d)\n", i, rc); + dev_printk(KERN_ERR, gdev, "failed to request/iomap " + "BARs for port %d (errno=%d)\n", i, rc); if (rc == -EBUSY) pcim_pin_device(pdev); - ap->ops = &ata_dummy_port_ops; - continue; + return rc; } host->iomap = iomap = pcim_iomap_table(pdev); @@ -639,13 +641,6 @@ int ata_pci_init_native_host(struct ata_host *host) ap->ioaddr.ctl_addr = (void __iomem *) ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); ata_std_ports(&ap->ioaddr); - - mask |= 1 << i; - } - - if (!mask) { - dev_printk(KERN_ERR, gdev, "no available native port\n"); - return -ENODEV; } return 0; @@ -654,7 +649,8 @@ int ata_pci_init_native_host(struct ata_host *host) /** * ata_pci_prepare_native_host - helper to prepare native PCI ATA host * @pdev: target PCI device - * @ppi: array of port_info, must be enough for two ports + * @ppi: array of port_info + * @n_ports: number of ports to allocate * @r_host: out argument for the initialized ATA host * * Helper to allocate ATA host for @pdev, acquire all native PCI @@ -668,9 +664,10 @@ int ata_pci_init_native_host(struct ata_host *host) */ int ata_pci_prepare_native_host(struct pci_dev *pdev, const struct ata_port_info * const * ppi, - struct ata_host **r_host) + int n_ports, struct ata_host **r_host) { struct ata_host *host; + unsigned int port_mask; int rc; if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) @@ -684,7 +681,11 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev, goto err_out; } - rc = ata_pci_init_native_host(host); + port_mask = ATA_PORT_PRIMARY; + if (n_ports > 1) + port_mask |= ATA_PORT_SECONDARY; + + rc = ata_pci_init_native_host(host, port_mask); if (rc) goto err_out; @@ -776,11 +777,8 @@ static int ata_init_legacy_port(struct ata_port *ap, /* iomap cmd and ctl ports */ legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); - if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) { - dev_printk(KERN_WARNING, host->dev, - "failed to map cmd/ctl ports\n"); + if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) return -ENOMEM; - } /* init IO addresses */ ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; @@ -794,20 +792,19 @@ static int ata_init_legacy_port(struct ata_port *ap, /** * ata_init_legacy_host - acquire legacy ATA resources and init ATA host * @host: target ATA host + * @legacy_mask: out parameter, mask indicating ports is in legacy mode * @was_busy: out parameter, indicates whether any port was busy * - * Acquire legacy ATA resources for the first two ports of @host - * and initialize it accordingly. Ports marked dummy are skipped - * and resource acquistion failure makes the port dummy. + * Acquire legacy ATA resources for ports. * * LOCKING: * Inherited from calling layer (may sleep). * * RETURNS: - * 0 if at least one port is initialized, -ENODEV if no port is - * available. + * 0 on success, -errno otherwise. */ -static int ata_init_legacy_host(struct ata_host *host, int *was_busy) +static int ata_init_legacy_host(struct ata_host *host, + unsigned int *legacy_mask, int *was_busy) { struct device *gdev = host->dev; struct ata_legacy_devres *legacy_dr; @@ -824,23 +821,22 @@ static int ata_init_legacy_host(struct ata_host *host, int *was_busy) devres_add(gdev, legacy_dr); for (i = 0; i < 2; i++) { - if (ata_port_is_dummy(host->ports[i])) - continue; - + *legacy_mask &= ~(1 << i); rc = ata_init_legacy_port(host->ports[i], legacy_dr); if (rc == 0) legacy_dr->mask |= 1 << i; - else { - if (rc == -EBUSY) - (*was_busy)++; - host->ports[i]->ops = &ata_dummy_port_ops; - } + else if (rc == -EBUSY) + (*was_busy)++; } - if (!legacy_dr->mask) { - dev_printk(KERN_ERR, gdev, "no available legacy port\n"); - return -ENODEV; - } + if (!legacy_dr->mask) + return -EBUSY; + + for (i = 0; i < 2; i++) + if (!(legacy_dr->mask & (1 << i))) + host->ports[i]->ops = &ata_dummy_port_ops; + + *legacy_mask |= legacy_dr->mask; devres_remove_group(gdev, NULL); return 0; @@ -879,7 +875,7 @@ static int ata_request_legacy_irqs(struct ata_host *host, legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); BUG_ON(!legacy_dr); - for (i = 0; i < 2; i++) { + for (i = 0; i < host->n_ports; i++) { unsigned int irq; /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ @@ -927,7 +923,8 @@ static int ata_request_legacy_irqs(struct ata_host *host, /** * ata_pci_init_one - Initialize/register PCI IDE host controller * @pdev: Controller to be initialized - * @ppi: array of port_info, must be enough for two ports + * @port_info: Information from low-level host driver + * @n_ports: Number of ports attached to host controller * * This is a helper function which can be called from a driver's * xxx_init_one() probe function if the hardware uses traditional @@ -947,35 +944,27 @@ static int ata_request_legacy_irqs(struct ata_host *host, * RETURNS: * Zero on success, negative on errno-based value on error. */ -int ata_pci_init_one(struct pci_dev *pdev, - const struct ata_port_info * const * ppi) + +int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, + unsigned int n_ports) { struct device *dev = &pdev->dev; - const struct ata_port_info *pi = NULL; struct ata_host *host = NULL; + const struct ata_port_info *port[2]; u8 mask; - int legacy_mode = 0; - int i, rc; + unsigned int legacy_mode = 0; + int rc; DPRINTK("ENTER\n"); - /* look up the first valid port_info */ - for (i = 0; i < 2 && ppi[i]; i++) { - if (ppi[i]->port_ops != &ata_dummy_port_ops) { - pi = ppi[i]; - break; - } - } - - if (!pi) { - dev_printk(KERN_ERR, &pdev->dev, - "no valid port_info specified\n"); - return -EINVAL; - } - if (!devres_open_group(dev, NULL, GFP_KERNEL)) return -ENOMEM; + BUG_ON(n_ports < 1 || n_ports > 2); + + port[0] = port_info[0]; + port[1] = (n_ports > 1) ? port_info[1] : NULL; + /* FIXME: Really for ATA it isn't safe because the device may be multi-purpose and we want to leave it alone if it was already enabled. Secondly for shared use as Arjan says we want refcounting @@ -995,7 +984,7 @@ int ata_pci_init_one(struct pci_dev *pdev, pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); mask = (1 << 2) | (1 << 0); if ((tmp8 & mask) != mask) - legacy_mode = 1; + legacy_mode = (1 << 3); #if defined(CONFIG_NO_ATA_LEGACY) /* Some platforms with PCI limits cannot address compat port space. In that case we punt if their firmware has @@ -1009,7 +998,7 @@ int ata_pci_init_one(struct pci_dev *pdev, } /* alloc and init host */ - host = ata_host_alloc_pinfo(dev, ppi, 2); + host = ata_host_alloc_pinfo(dev, port, n_ports); if (!host) { dev_printk(KERN_ERR, &pdev->dev, "failed to allocate ATA host\n"); @@ -1018,13 +1007,19 @@ int ata_pci_init_one(struct pci_dev *pdev, } if (!legacy_mode) { - rc = ata_pci_init_native_host(host); + unsigned int port_mask; + + port_mask = ATA_PORT_PRIMARY; + if (n_ports > 1) + port_mask |= ATA_PORT_SECONDARY; + + rc = ata_pci_init_native_host(host, port_mask); if (rc) goto err_out; } else { int was_busy = 0; - rc = ata_init_legacy_host(host, &was_busy); + rc = ata_init_legacy_host(host, &legacy_mode, &was_busy); if (was_busy) pcim_pin_device(pdev); if (rc) @@ -1045,7 +1040,8 @@ int ata_pci_init_one(struct pci_dev *pdev, goto err_out; if (!legacy_mode) - rc = devm_request_irq(dev, pdev->irq, pi->port_ops->irq_handler, + rc = devm_request_irq(dev, pdev->irq, + port_info[0]->port_ops->irq_handler, IRQF_SHARED, DRV_NAME, host); else { irq_handler_t handler[2] = { host->ops->irq_handler, @@ -1059,7 +1055,7 @@ int ata_pci_init_one(struct pci_dev *pdev, goto err_out; /* register */ - rc = ata_host_register(host, pi->sht); + rc = ata_host_register(host, port_info[0]->sht); if (rc) goto err_out; diff --git a/trunk/drivers/ata/libata.h b/trunk/drivers/ata/libata.h index 8b71b73a199c..5f4d40cd3288 100644 --- a/trunk/drivers/ata/libata.h +++ b/trunk/drivers/ata/libata.h @@ -58,7 +58,6 @@ extern int atapi_enabled; extern int atapi_dmadir; extern int libata_fua; extern int libata_noacpi; -extern int ata_spindown_compat; extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, u64 block, u32 n_block, unsigned int tf_flags, @@ -97,15 +96,15 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); extern struct ata_port *ata_port_alloc(struct ata_host *host); /* libata-acpi.c */ -#ifdef CONFIG_ATA_ACPI +#ifdef CONFIG_SATA_ACPI extern int ata_acpi_exec_tfs(struct ata_port *ap); -extern int ata_acpi_push_id(struct ata_device *dev); +extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix); #else static inline int ata_acpi_exec_tfs(struct ata_port *ap) { return 0; } -static inline int ata_acpi_push_id(struct ata_device *dev) +static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) { return 0; } diff --git a/trunk/drivers/ata/pata_ali.c b/trunk/drivers/ata/pata_ali.c index 3c55a5ff74c7..d40edebb510a 100644 --- a/trunk/drivers/ata/pata_ali.c +++ b/trunk/drivers/ata/pata_ali.c @@ -291,6 +291,10 @@ static struct scsi_host_template ali_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; /* @@ -518,14 +522,14 @@ static void ali_init_chipset(struct pci_dev *pdev) static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info_early = { + static struct ata_port_info info_early = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &ali_early_port_ops }; /* Revision 0x20 added DMA */ - static const struct ata_port_info info_20 = { + static struct ata_port_info info_20 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -533,7 +537,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_20_port_ops }; /* Revision 0x20 with support logic added UDMA */ - static const struct ata_port_info info_20_udma = { + static struct ata_port_info info_20_udma = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -542,7 +546,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_20_port_ops }; /* Revision 0xC2 adds UDMA66 */ - static const struct ata_port_info info_c2 = { + static struct ata_port_info info_c2 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -551,7 +555,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c2_port_ops }; /* Revision 0xC3 is UDMA100 */ - static const struct ata_port_info info_c3 = { + static struct ata_port_info info_c3 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -560,7 +564,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c2_port_ops }; /* Revision 0xC4 is UDMA133 */ - static const struct ata_port_info info_c4 = { + static struct ata_port_info info_c4 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -569,7 +573,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c2_port_ops }; /* Revision 0xC5 is UDMA133 with LBA48 DMA */ - static const struct ata_port_info info_c5 = { + static struct ata_port_info info_c5 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -578,7 +582,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c5_port_ops }; - const struct ata_port_info *ppi[] = { NULL, NULL }; + static struct ata_port_info *port_info[2]; u8 rev, tmp; struct pci_dev *isa_bridge; @@ -590,17 +594,17 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) */ if (rev < 0x20) { - ppi[0] = &info_early; + port_info[0] = port_info[1] = &info_early; } else if (rev < 0xC2) { - ppi[0] = &info_20; + port_info[0] = port_info[1] = &info_20; } else if (rev == 0xC2) { - ppi[0] = &info_c2; + port_info[0] = port_info[1] = &info_c2; } else if (rev == 0xC3) { - ppi[0] = &info_c3; + port_info[0] = port_info[1] = &info_c3; } else if (rev == 0xC4) { - ppi[0] = &info_c4; + port_info[0] = port_info[1] = &info_c4; } else - ppi[0] = &info_c5; + port_info[0] = port_info[1] = &info_c5; ali_init_chipset(pdev); @@ -609,10 +613,10 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) /* Are we paired with a UDMA capable chip */ pci_read_config_byte(isa_bridge, 0x5E, &tmp); if ((tmp & 0x1E) == 0x12) - ppi[0] = &info_20_udma; + port_info[0] = port_info[1] = &info_20_udma; pci_dev_put(isa_bridge); } - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_amd.c b/trunk/drivers/ata/pata_amd.c index b439351f1fd3..67c7e87dec04 100644 --- a/trunk/drivers/ata/pata_amd.c +++ b/trunk/drivers/ata/pata_amd.c @@ -324,6 +324,10 @@ static struct scsi_host_template amd_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations amd33_port_ops = { @@ -538,7 +542,7 @@ static struct ata_port_operations nv133_port_ops = { static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info[10] = { + static struct ata_port_info info[10] = { { /* 0: AMD 7401 */ .sht = &amd_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -620,7 +624,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &amd100_port_ops } }; - const struct ata_port_info *ppi[] = { NULL, NULL }; + static struct ata_port_info *port_info[2]; static int printed_version; int type = id->driver_data; u8 rev; @@ -652,8 +656,9 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ata_pci_clear_simplex(pdev); /* And fire it up */ - ppi[0] = &info[type]; - return ata_pci_init_one(pdev, ppi); + + port_info[0] = port_info[1] = &info[type]; + return ata_pci_init_one(pdev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_artop.c b/trunk/drivers/ata/pata_artop.c index 9861059dd673..ef51940c3adb 100644 --- a/trunk/drivers/ata/pata_artop.c +++ b/trunk/drivers/ata/pata_artop.c @@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = { static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) { static int printed_version; - static const struct ata_port_info info_6210 = { + static struct ata_port_info info_6210 = { .sht = &artop_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = ATA_UDMA2, .port_ops = &artop6210_ops, }; - static const struct ata_port_info info_626x = { + static struct ata_port_info info_626x = { .sht = &artop_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = ATA_UDMA4, .port_ops = &artop6260_ops, }; - static const struct ata_port_info info_626x_fast = { + static struct ata_port_info info_626x_fast = { .sht = &artop_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -438,30 +438,32 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = ATA_UDMA5, .port_ops = &artop6260_ops, }; - const struct ata_port_info *ppi[] = { NULL, NULL }; + struct ata_port_info *port_info[2]; + struct ata_port_info *info = NULL; + int ports = 2; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); if (id->driver_data == 0) { /* 6210 variant */ - ppi[0] = &info_6210; - ppi[1] = &ata_dummy_port_info; + info = &info_6210; /* BIOS may have left us in UDMA, clear it before libata probe */ pci_write_config_byte(pdev, 0x54, 0); /* For the moment (also lacks dsc) */ printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); + ports = 1; } else if (id->driver_data == 1) /* 6260 */ - ppi[0] = &info_626x; + info = &info_626x; else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ unsigned long io = pci_resource_start(pdev, 4); u8 reg; - ppi[0] = &info_626x; + info = &info_626x; if (inb(io) & 0x10) - ppi[0] = &info_626x_fast; + info = &info_626x_fast; /* Mac systems come up with some registers not set as we will need them */ @@ -482,9 +484,10 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) } - BUG_ON(ppi[0] == NULL); + BUG_ON(info == NULL); - return ata_pci_init_one(pdev, ppi); + port_info[0] = port_info[1] = info; + return ata_pci_init_one(pdev, port_info, ports); } static const struct pci_device_id artop_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_atiixp.c b/trunk/drivers/ata/pata_atiixp.c index 844914681a2a..21515381b5b3 100644 --- a/trunk/drivers/ata/pata_atiixp.c +++ b/trunk/drivers/ata/pata_atiixp.c @@ -229,6 +229,10 @@ static struct scsi_host_template atiixp_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations atiixp_port_ops = { @@ -268,7 +272,7 @@ static struct ata_port_operations atiixp_port_ops = { static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &atiixp_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -276,8 +280,8 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x3F, .port_ops = &atiixp_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; - return ata_pci_init_one(dev, ppi); + static struct ata_port_info *port_info[2] = { &info, &info }; + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id atiixp[] = { diff --git a/trunk/drivers/ata/pata_cmd640.c b/trunk/drivers/ata/pata_cmd640.c index ed00fa9d53be..2105985a8013 100644 --- a/trunk/drivers/ata/pata_cmd640.c +++ b/trunk/drivers/ata/pata_cmd640.c @@ -181,6 +181,10 @@ static struct scsi_host_template cmd640_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations cmd640_port_ops = { @@ -249,16 +253,17 @@ static void cmd640_hardware_init(struct pci_dev *pdev) static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &cmd640_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &cmd640_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; + + static struct ata_port_info *port_info[2] = { &info, &info }; cmd640_hardware_init(pdev); - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } static int cmd640_reinit_one(struct pci_dev *pdev) diff --git a/trunk/drivers/ata/pata_cmd64x.c b/trunk/drivers/ata/pata_cmd64x.c index 2a79b335cfcc..3989cc577fcd 100644 --- a/trunk/drivers/ata/pata_cmd64x.c +++ b/trunk/drivers/ata/pata_cmd64x.c @@ -266,6 +266,10 @@ static struct scsi_host_template cmd64x_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations cmd64x_port_ops = { @@ -377,7 +381,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { u32 class_rev; - static const struct ata_port_info cmd_info[6] = { + static struct ata_port_info cmd_info[6] = { { /* CMD 643 - no UDMA */ .sht = &cmd64x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -424,9 +428,11 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &cmd648_port_ops } }; - const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL }; + static struct ata_port_info *port_info[2], *info; u8 mrdmode; + info = &cmd_info[id->driver_data]; + pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); class_rev &= 0xFF; @@ -436,10 +442,10 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) if (pdev->device == PCI_DEVICE_ID_CMD_646) { /* Does UDMA work ? */ if (class_rev > 4) - ppi[0] = &cmd_info[2]; + info = &cmd_info[2]; /* Early rev with other problems ? */ else if (class_rev == 1) - ppi[0] = &cmd_info[3]; + info = &cmd_info[3]; } pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); @@ -455,7 +461,8 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) pci_write_config_byte(pdev, UDIDETCR0, 0xF0); #endif - return ata_pci_init_one(pdev, ppi); + port_info[0] = port_info[1] = info; + return ata_pci_init_one(pdev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_cs5520.c b/trunk/drivers/ata/pata_cs5520.c index 83bcc5b32597..79bef0d1fad3 100644 --- a/trunk/drivers/ata/pata_cs5520.c +++ b/trunk/drivers/ata/pata_cs5520.c @@ -155,6 +155,10 @@ static struct scsi_host_template cs5520_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations cs5520_port_ops = { diff --git a/trunk/drivers/ata/pata_cs5530.c b/trunk/drivers/ata/pata_cs5530.c index 1b67923d7a4e..29642d5ee189 100644 --- a/trunk/drivers/ata/pata_cs5530.c +++ b/trunk/drivers/ata/pata_cs5530.c @@ -176,6 +176,10 @@ static struct scsi_host_template cs5530_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations cs5530_port_ops = { @@ -335,7 +339,7 @@ static int cs5530_init_chip(void) static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &cs5530_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -344,23 +348,23 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &cs5530_port_ops }; /* The docking connector doesn't do UDMA, and it seems not MWDMA */ - static const struct ata_port_info info_palmax_secondary = { + static struct ata_port_info info_palmax_secondary = { .sht = &cs5530_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &cs5530_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; /* Chip initialisation */ if (cs5530_init_chip()) return -ENODEV; if (cs5530_is_palmax()) - ppi[1] = &info_palmax_secondary; + port_info[1] = &info_palmax_secondary; /* Now kick off ATA set up */ - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_cs5535.c b/trunk/drivers/ata/pata_cs5535.c index f37d4cd812a1..22006ae71941 100644 --- a/trunk/drivers/ata/pata_cs5535.c +++ b/trunk/drivers/ata/pata_cs5535.c @@ -173,6 +173,10 @@ static struct scsi_host_template cs5535_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations cs5535_port_ops = { @@ -223,7 +227,7 @@ static struct ata_port_operations cs5535_port_ops = { static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &cs5535_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -231,7 +235,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x1f, .port_ops = &cs5535_port_ops }; - const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; + struct ata_port_info *ports[1] = { &info }; u32 timings, dummy; @@ -243,7 +247,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) rdmsr(ATAC_CH0D1_PIO, timings, dummy); if (CS5535_BAD_PIO(timings)) wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, ports, 1); } static const struct pci_device_id cs5535[] = { diff --git a/trunk/drivers/ata/pata_cypress.c b/trunk/drivers/ata/pata_cypress.c index 27b9f29c01e3..6ec049c3b1dc 100644 --- a/trunk/drivers/ata/pata_cypress.c +++ b/trunk/drivers/ata/pata_cypress.c @@ -125,6 +125,10 @@ static struct scsi_host_template cy82c693_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations cy82c693_port_ops = { @@ -165,14 +169,14 @@ static struct ata_port_operations cy82c693_port_ops = { static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &cy82c693_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &cy82c693_port_ops }; - const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; + static struct ata_port_info *port_info[1] = { &info }; /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. For the moment we don't handle the secondary. FIXME */ @@ -180,7 +184,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i if (PCI_FUNC(pdev->devfn) != 1) return -ENODEV; - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 1); } static const struct pci_device_id cy82c693[] = { diff --git a/trunk/drivers/ata/pata_efar.c b/trunk/drivers/ata/pata_efar.c index 079248a9b460..d0f52e034906 100644 --- a/trunk/drivers/ata/pata_efar.c +++ b/trunk/drivers/ata/pata_efar.c @@ -247,6 +247,10 @@ static struct scsi_host_template efar_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations efar_ops = { @@ -301,7 +305,7 @@ static const struct ata_port_operations efar_ops = { static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &efar_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -309,13 +313,13 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) .udma_mask = 0x0f, /* UDMA 66 */ .port_ops = &efar_ops, }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } static const struct pci_device_id efar_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_hpt366.c b/trunk/drivers/ata/pata_hpt366.c index c6c8a8bb06d0..e64e05e5c7fe 100644 --- a/trunk/drivers/ata/pata_hpt366.c +++ b/trunk/drivers/ata/pata_hpt366.c @@ -331,6 +331,10 @@ static struct scsi_host_template hpt36x_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; /* @@ -417,7 +421,7 @@ static void hpt36x_init_chipset(struct pci_dev *dev) static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info_hpt366 = { + static struct ata_port_info info_hpt366 = { .sht = &hpt36x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -425,8 +429,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x1f, .port_ops = &hpt366_port_ops }; - struct ata_port_info info = info_hpt366; - const struct ata_port_info *ppi[] = { &info, NULL }; + struct ata_port_info *port_info[2] = {&info_hpt366, &info_hpt366}; u32 class_rev; u32 reg1; @@ -447,17 +450,17 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) /* info_hpt366 is safe against re-entry so we can scribble on it */ switch((reg1 & 0x700) >> 8) { case 5: - info.private_data = &hpt366_40; + info_hpt366.private_data = &hpt366_40; break; case 9: - info.private_data = &hpt366_25; + info_hpt366.private_data = &hpt366_25; break; default: - info.private_data = &hpt366_33; + info_hpt366.private_data = &hpt366_33; break; } /* Now kick off ATA set up */ - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_hpt37x.c b/trunk/drivers/ata/pata_hpt37x.c index 5a0a410654e2..1614e8c822a4 100644 --- a/trunk/drivers/ata/pata_hpt37x.c +++ b/trunk/drivers/ata/pata_hpt37x.c @@ -887,7 +887,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev) static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) { /* HPT370 - UDMA100 */ - static const struct ata_port_info info_hpt370 = { + static struct ata_port_info info_hpt370 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -896,7 +896,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370_port_ops }; /* HPT370A - UDMA100 */ - static const struct ata_port_info info_hpt370a = { + static struct ata_port_info info_hpt370a = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -905,7 +905,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370a_port_ops }; /* HPT370 - UDMA100 */ - static const struct ata_port_info info_hpt370_33 = { + static struct ata_port_info info_hpt370_33 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -914,7 +914,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370_port_ops }; /* HPT370A - UDMA100 */ - static const struct ata_port_info info_hpt370a_33 = { + static struct ata_port_info info_hpt370a_33 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -923,7 +923,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370a_port_ops }; /* HPT371, 372 and friends - UDMA133 */ - static const struct ata_port_info info_hpt372 = { + static struct ata_port_info info_hpt372 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -932,7 +932,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt372_port_ops }; /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ - static const struct ata_port_info info_hpt372_50 = { + static struct ata_port_info info_hpt372_50 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -941,7 +941,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt372_port_ops }; /* HPT374 - UDMA133 */ - static const struct ata_port_info info_hpt374 = { + static struct ata_port_info info_hpt374 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -951,10 +951,9 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) }; static const int MHz[4] = { 33, 40, 50, 66 }; - const struct ata_port_info *port; - void *private_data = NULL; - struct ata_port_info port_info; - const struct ata_port_info *ppi[] = { &port_info, NULL }; + + struct ata_port_info *port_info[2]; + struct ata_port_info *port; u8 irqmask; u32 class_rev; @@ -1125,13 +1124,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) return -ENODEV; } if (clock_slot == 3) - private_data = (void *)hpt37x_timings_66; + port->private_data = (void *)hpt37x_timings_66; else - private_data = (void *)hpt37x_timings_50; + port->private_data = (void *)hpt37x_timings_50; printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); } else { - private_data = (void *)chip_table->clocks[clock_slot]; + port->private_data = (void *)chip_table->clocks[clock_slot]; /* * Perform a final fixup. Note that we will have used the * DPLL on the HPT372 which means we don't have to worry @@ -1145,11 +1144,9 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); } + port_info[0] = port_info[1] = port; /* Now kick off ATA set up */ - port_info = *port; - port_info.private_data = private_data; - - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id hpt37x[] = { diff --git a/trunk/drivers/ata/pata_hpt3x2n.c b/trunk/drivers/ata/pata_hpt3x2n.c index f25154aed75d..ea1037d67860 100644 --- a/trunk/drivers/ata/pata_hpt3x2n.c +++ b/trunk/drivers/ata/pata_hpt3x2n.c @@ -488,7 +488,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev) static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) { /* HPT372N and friends - UDMA133 */ - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &hpt3x2n_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -496,8 +496,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x7f, .port_ops = &hpt3x2n_port_ops }; - struct ata_port_info port = info; - const struct ata_port_info *ppi[] = { &port, NULL }; + struct ata_port_info *port_info[2]; + struct ata_port_info *port = &info; u8 irqmask; u32 class_rev; @@ -585,9 +585,9 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) /* Set our private data up. We only need a few flags so we use it directly */ - port.private_data = NULL; + port->private_data = NULL; if (pci_mhz > 60) { - port.private_data = (void *)PCI66; + port->private_data = (void *)PCI66; /* * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in * the MISC. register to stretch the UltraDMA Tss timing. @@ -598,7 +598,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) } /* Now kick off ATA set up */ - return ata_pci_init_one(dev, ppi); + port_info[0] = port_info[1] = port; + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id hpt3x2n[] = { diff --git a/trunk/drivers/ata/pata_hpt3x3.c b/trunk/drivers/ata/pata_hpt3x3.c index bbabe7902fbb..ac28ec8c50aa 100644 --- a/trunk/drivers/ata/pata_hpt3x3.c +++ b/trunk/drivers/ata/pata_hpt3x3.c @@ -100,6 +100,10 @@ static struct scsi_host_template hpt3x3_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations hpt3x3_port_ops = { @@ -171,7 +175,7 @@ static void hpt3x3_init_chipset(struct pci_dev *dev) static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &hpt3x3_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -179,11 +183,11 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x07, .port_ops = &hpt3x3_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; hpt3x3_init_chipset(dev); /* Now kick off ATA set up */ - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_it8213.c b/trunk/drivers/ata/pata_it8213.c index a769952646e1..17bf9f3ed013 100644 --- a/trunk/drivers/ata/pata_it8213.c +++ b/trunk/drivers/ata/pata_it8213.c @@ -257,6 +257,10 @@ static struct scsi_host_template it8213_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations it8213_ops = { @@ -311,7 +315,7 @@ static const struct ata_port_operations it8213_ops = { static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &it8213_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -319,14 +323,14 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en .udma_mask = 0x1f, /* UDMA 100 */ .port_ops = &it8213_ops, }; - /* Current IT8213 stuff is single port */ - const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; + static struct ata_port_info *port_info[2] = { &info, &info }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(pdev, ppi); + /* Current IT8213 stuff is single port */ + return ata_pci_init_one(pdev, port_info, 1); } static const struct pci_device_id it8213_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_it821x.c b/trunk/drivers/ata/pata_it821x.c index ff9a6fd36657..f1f8cec8c224 100644 --- a/trunk/drivers/ata/pata_it821x.c +++ b/trunk/drivers/ata/pata_it821x.c @@ -620,6 +620,10 @@ static struct scsi_host_template it821x_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations it821x_smart_port_ops = { @@ -718,14 +722,14 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { u8 conf; - static const struct ata_port_info info_smart = { + static struct ata_port_info info_smart = { .sht = &it821x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &it821x_smart_port_ops }; - static const struct ata_port_info info_passthru = { + static struct ata_port_info info_passthru = { .sht = &it821x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -733,8 +737,8 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x7f, .port_ops = &it821x_passthru_port_ops }; + static struct ata_port_info *port_info[2]; - const struct ata_port_info *ppi[] = { NULL, NULL }; static char *mode[2] = { "pass through", "smart" }; /* Force the card into bypass mode if so requested */ @@ -747,11 +751,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); if (conf == 0) - ppi[0] = &info_passthru; + port_info[0] = port_info[1] = &info_passthru; else - ppi[0] = &info_smart; + port_info[0] = port_info[1] = &info_smart; - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_ixp4xx_cf.c b/trunk/drivers/ata/pata_ixp4xx_cf.c index b994351fbcd0..420c343e5711 100644 --- a/trunk/drivers/ata/pata_ixp4xx_cf.c +++ b/trunk/drivers/ata/pata_ixp4xx_cf.c @@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) for (i = 0; i < ATA_MAX_DEVICES; i++) { struct ata_device *dev = &ap->device[i]; - if (ata_dev_enabled(dev)) { + if (ata_dev_ready(dev)) { ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); dev->pio_mode = XFER_PIO_0; dev->xfer_mode = XFER_PIO_0; diff --git a/trunk/drivers/ata/pata_jmicron.c b/trunk/drivers/ata/pata_jmicron.c index 8d799e87f752..1daf78ac6efb 100644 --- a/trunk/drivers/ata/pata_jmicron.c +++ b/trunk/drivers/ata/pata_jmicron.c @@ -138,6 +138,10 @@ static struct scsi_host_template jmicron_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static const struct ata_port_operations jmicron_ops = { @@ -191,7 +195,7 @@ static const struct ata_port_operations jmicron_ops = { static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &jmicron_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -201,9 +205,9 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i .port_ops = &jmicron_ops, }; - const struct ata_port_info *ppi[] = { &info, NULL }; + struct ata_port_info *port_info[2] = { &info, &info }; - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } static const struct pci_device_id jmicron_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_marvell.c b/trunk/drivers/ata/pata_marvell.c index edbfe0dbbf78..837b7fe77dc7 100644 --- a/trunk/drivers/ata/pata_marvell.c +++ b/trunk/drivers/ata/pata_marvell.c @@ -107,6 +107,10 @@ static struct scsi_host_template marvell_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations marvell_ops = { @@ -161,7 +165,7 @@ static const struct ata_port_operations marvell_ops = { static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &marvell_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -171,7 +175,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i .port_ops = &marvell_ops, }; - static const struct ata_port_info info_sata = { + static struct ata_port_info info_sata = { .sht = &marvell_sht, /* Slave possible as its magically mapped not real */ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -182,12 +186,13 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i .port_ops = &marvell_ops, }; - const struct ata_port_info *ppi[] = { &info, &info_sata }; + struct ata_port_info *port_info[2] = { &info, &info_sata }; + int n_port = 2; if (pdev->device == 0x6101) - ppi[1] = &ata_dummy_port_info; + n_port = 1; - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, n_port); } static const struct pci_device_id marvell_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_mpc52xx.c b/trunk/drivers/ata/pata_mpc52xx.c index 368fac7d168b..9587a89f9683 100644 --- a/trunk/drivers/ata/pata_mpc52xx.c +++ b/trunk/drivers/ata/pata_mpc52xx.c @@ -280,6 +280,10 @@ static struct scsi_host_template mpc52xx_ata_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static struct ata_port_operations mpc52xx_ata_port_ops = { diff --git a/trunk/drivers/ata/pata_mpiix.c b/trunk/drivers/ata/pata_mpiix.c index 4ea42838297e..3bfbd495f643 100644 --- a/trunk/drivers/ata/pata_mpiix.c +++ b/trunk/drivers/ata/pata_mpiix.c @@ -165,6 +165,10 @@ static struct scsi_host_template mpiix_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations mpiix_port_ops = { diff --git a/trunk/drivers/ata/pata_netcell.c b/trunk/drivers/ata/pata_netcell.c index 81f563458666..dbba5b77d79c 100644 --- a/trunk/drivers/ata/pata_netcell.c +++ b/trunk/drivers/ata/pata_netcell.c @@ -37,6 +37,10 @@ static struct scsi_host_template netcell_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations netcell_ops = { @@ -92,7 +96,7 @@ static const struct ata_port_operations netcell_ops = { static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &netcell_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, /* Actually we don't really care about these as the @@ -102,7 +106,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e .udma_mask = 0x3f, /* UDMA 133 */ .port_ops = &netcell_ops, }; - const struct ata_port_info *port_info[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, @@ -112,7 +116,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e ata_pci_clear_simplex(pdev); /* And let the library code do the work */ - return ata_pci_init_one(pdev, port_info); + return ata_pci_init_one(pdev, port_info, 2); } static const struct pci_device_id netcell_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_ns87410.c b/trunk/drivers/ata/pata_ns87410.c index ea70ec744879..ebc58a907d26 100644 --- a/trunk/drivers/ata/pata_ns87410.c +++ b/trunk/drivers/ata/pata_ns87410.c @@ -158,6 +158,10 @@ static struct scsi_host_template ns87410_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations ns87410_port_ops = { @@ -191,14 +195,14 @@ static struct ata_port_operations ns87410_port_ops = { static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &ns87410_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x0F, .port_ops = &ns87410_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; - return ata_pci_init_one(dev, ppi); + static struct ata_port_info *port_info[2] = {&info, &info}; + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id ns87410[] = { diff --git a/trunk/drivers/ata/pata_oldpiix.c b/trunk/drivers/ata/pata_oldpiix.c index 29c23ddd6550..4d75d32e5826 100644 --- a/trunk/drivers/ata/pata_oldpiix.c +++ b/trunk/drivers/ata/pata_oldpiix.c @@ -234,6 +234,10 @@ static struct scsi_host_template oldpiix_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations oldpiix_pata_ops = { @@ -289,20 +293,20 @@ static const struct ata_port_operations oldpiix_pata_ops = { static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &oldpiix_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .mwdma_mask = 0x07, /* mwdma1-2 */ .port_ops = &oldpiix_pata_ops, }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } static const struct pci_device_id oldpiix_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_opti.c b/trunk/drivers/ata/pata_opti.c index 1c44653e1e06..0af8a2c77cc9 100644 --- a/trunk/drivers/ata/pata_opti.c +++ b/trunk/drivers/ata/pata_opti.c @@ -179,6 +179,10 @@ static struct scsi_host_template opti_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations opti_port_ops = { @@ -216,19 +220,19 @@ static struct ata_port_operations opti_port_ops = { static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &opti_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &opti_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; static int printed_version; if (!printed_version++) dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id opti[] = { diff --git a/trunk/drivers/ata/pata_optidma.c b/trunk/drivers/ata/pata_optidma.c index 3093b02286ce..2843e480f216 100644 --- a/trunk/drivers/ata/pata_optidma.c +++ b/trunk/drivers/ata/pata_optidma.c @@ -363,6 +363,10 @@ static struct scsi_host_template optidma_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations optidma_port_ops = { @@ -482,14 +486,14 @@ static int optiplus_with_udma(struct pci_dev *pdev) static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info_82c700 = { + static struct ata_port_info info_82c700 = { .sht = &optidma_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &optidma_port_ops }; - static const struct ata_port_info info_82c700_udma = { + static struct ata_port_info info_82c700_udma = { .sht = &optidma_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -497,7 +501,8 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x07, .port_ops = &optiplus_port_ops }; - const struct ata_port_info *ppi[] = { &info_82c700, NULL }; + static struct ata_port_info *port_info[2]; + struct ata_port_info *info = &info_82c700; static int printed_version; if (!printed_version++) @@ -509,9 +514,10 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ if (optiplus_with_udma(dev)) - ppi[0] = &info_82c700_udma; + info = &info_82c700_udma; - return ata_pci_init_one(dev, ppi); + port_info[0] = port_info[1] = info; + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id optidma[] = { diff --git a/trunk/drivers/ata/pata_pcmcia.c b/trunk/drivers/ata/pata_pcmcia.c index 4d44c7555db1..11245e331f77 100644 --- a/trunk/drivers/ata/pata_pcmcia.c +++ b/trunk/drivers/ata/pata_pcmcia.c @@ -397,7 +397,6 @@ static struct pcmcia_device_id pcmcia_devices[] = { PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), - PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), diff --git a/trunk/drivers/ata/pata_pdc202xx_old.c b/trunk/drivers/ata/pata_pdc202xx_old.c index edbaf9d653b8..ee636beb05e1 100644 --- a/trunk/drivers/ata/pata_pdc202xx_old.c +++ b/trunk/drivers/ata/pata_pdc202xx_old.c @@ -244,6 +244,10 @@ static struct scsi_host_template pdc202xx_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations pdc2024x_port_ops = { @@ -317,7 +321,7 @@ static struct ata_port_operations pdc2026x_port_ops = { static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info[3] = { + static struct ata_port_info info[3] = { { .sht = &pdc202xx_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -344,7 +348,9 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id } }; - const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; + static struct ata_port_info *port_info[2]; + + port_info[0] = port_info[1] = &info[id->driver_data]; if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { struct pci_dev *bridge = dev->bus->self; @@ -356,7 +362,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id return -ENODEV; } } - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id pdc202xx[] = { diff --git a/trunk/drivers/ata/pata_platform.c b/trunk/drivers/ata/pata_platform.c index 1f6384895a4f..a0a650c7f272 100644 --- a/trunk/drivers/ata/pata_platform.c +++ b/trunk/drivers/ata/pata_platform.c @@ -48,8 +48,6 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse return 0; } -static int ata_dummy_ret0(struct ata_port *ap) { return 0; } - static struct scsi_host_template pata_platform_sht = { .module = THIS_MODULE, .name = DRV_NAME, @@ -93,7 +91,7 @@ static struct ata_port_operations pata_platform_port_ops = { .irq_on = ata_irq_on, .irq_ack = ata_irq_ack, - .port_start = ata_dummy_ret0, + .port_start = ata_port_start, }; static void pata_platform_setup_port(struct ata_ioports *ioaddr, diff --git a/trunk/drivers/ata/pata_radisys.c b/trunk/drivers/ata/pata_radisys.c index ba96b54f5b87..1c54673e008d 100644 --- a/trunk/drivers/ata/pata_radisys.c +++ b/trunk/drivers/ata/pata_radisys.c @@ -200,6 +200,10 @@ static struct scsi_host_template radisys_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations radisys_pata_ops = { @@ -255,7 +259,7 @@ static const struct ata_port_operations radisys_pata_ops = { static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &radisys_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -263,13 +267,13 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e .udma_mask = 0x14, /* UDMA33/66 only */ .port_ops = &radisys_pata_ops, }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } static const struct pci_device_id radisys_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_rz1000.c b/trunk/drivers/ata/pata_rz1000.c index 2bfd7ef42af5..85c45290eeee 100644 --- a/trunk/drivers/ata/pata_rz1000.c +++ b/trunk/drivers/ata/pata_rz1000.c @@ -40,7 +40,7 @@ static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused) for (i = 0; i < ATA_MAX_DEVICES; i++) { struct ata_device *dev = &ap->device[i]; - if (ata_dev_enabled(dev)) { + if (ata_dev_ready(dev)) { /* We don't really care */ dev->pio_mode = XFER_PIO_0; dev->xfer_mode = XFER_PIO_0; @@ -69,6 +69,10 @@ static struct scsi_host_template rz1000_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations rz1000_port_ops = { @@ -131,20 +135,22 @@ static int rz1000_fifo_disable(struct pci_dev *pdev) static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static const struct ata_port_info info = { + struct ata_port_info *port_info[2]; + static struct ata_port_info info = { .sht = &rz1000_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &rz1000_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; if (!printed_version++) printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); - if (rz1000_fifo_disable(pdev) == 0) - return ata_pci_init_one(pdev, ppi); - + if (rz1000_fifo_disable(pdev) == 0) { + port_info[0] = &info; + port_info[1] = &info; + return ata_pci_init_one(pdev, port_info, 2); + } printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); /* Not safe to use so skip */ return -ENODEV; diff --git a/trunk/drivers/ata/pata_sc1200.c b/trunk/drivers/ata/pata_sc1200.c index 225013ecf4b6..66e8ff467c8d 100644 --- a/trunk/drivers/ata/pata_sc1200.c +++ b/trunk/drivers/ata/pata_sc1200.c @@ -194,6 +194,10 @@ static struct scsi_host_template sc1200_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations sc1200_port_ops = { @@ -243,7 +247,7 @@ static struct ata_port_operations sc1200_port_ops = { static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &sc1200_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -251,10 +255,10 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x07, .port_ops = &sc1200_port_ops }; - /* Can't enable port 2 yet, see top comments */ - const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; + static struct ata_port_info *port_info[2] = { &info, &info }; - return ata_pci_init_one(dev, ppi); + /* Can't enable port 2 yet, see top comments */ + return ata_pci_init_one(dev, port_info, 1); } static const struct pci_device_id sc1200[] = { diff --git a/trunk/drivers/ata/pata_scc.c b/trunk/drivers/ata/pata_scc.c index cca3aa225efe..203f463ac39f 100644 --- a/trunk/drivers/ata/pata_scc.c +++ b/trunk/drivers/ata/pata_scc.c @@ -984,6 +984,10 @@ static struct scsi_host_template scc_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations scc_pata_ops = { diff --git a/trunk/drivers/ata/pata_serverworks.c b/trunk/drivers/ata/pata_serverworks.c index dee6e211949d..b6e020383dd9 100644 --- a/trunk/drivers/ata/pata_serverworks.c +++ b/trunk/drivers/ata/pata_serverworks.c @@ -315,6 +315,10 @@ static struct scsi_host_template serverworks_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations serverworks_osb4_port_ops = { @@ -475,7 +479,8 @@ static void serverworks_fixup_ht1000(struct pci_dev *pdev) static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info[4] = { + int ports = 2; + static struct ata_port_info info[4] = { { /* OSB4 */ .sht = &serverworks_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -506,7 +511,8 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id .port_ops = &serverworks_csb_port_ops } }; - const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; + static struct ata_port_info *port_info[2]; + struct ata_port_info *devinfo = &info[id->driver_data]; /* Force master latency timer to 64 PCI clocks */ pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); @@ -515,7 +521,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { /* Select non UDMA capable OSB4 if we can't do fixups */ if ( serverworks_fixup_osb4(pdev) < 0) - ppi[0] = &info[1]; + devinfo = &info[1]; } /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || @@ -525,11 +531,11 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id /* If the returned btr is the newer revision then select the right info block */ if (serverworks_fixup_csb(pdev) == 3) - ppi[0] = &info[3]; + devinfo = &info[3]; /* Is this the 3rd channel CSB6 IDE ? */ if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) - ppi[1] = &ata_dummy_port_info; + ports = 1; } /* setup HT1000E */ else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) @@ -538,7 +544,8 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ata_pci_clear_simplex(pdev); - return ata_pci_init_one(pdev, ppi); + port_info[0] = port_info[1] = devinfo; + return ata_pci_init_one(pdev, port_info, ports); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_sil680.c b/trunk/drivers/ata/pata_sil680.c index 440e2cb6ee75..a5886f061c0b 100644 --- a/trunk/drivers/ata/pata_sil680.c +++ b/trunk/drivers/ata/pata_sil680.c @@ -232,6 +232,10 @@ static struct scsi_host_template sil680_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static struct ata_port_operations sil680_port_ops = { @@ -341,7 +345,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev) static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &sil680_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -349,7 +353,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x7f, .port_ops = &sil680_port_ops }; - static const struct ata_port_info info_slow = { + static struct ata_port_info info_slow = { .sht = &sil680_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -357,7 +361,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x3f, .port_ops = &sil680_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = {&info, &info}; static int printed_version; if (!printed_version++) @@ -366,12 +370,12 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) switch(sil680_init_chip(pdev)) { case 0: - ppi[0] = &info_slow; + port_info[0] = port_info[1] = &info_slow; break; case 0x30: return -ENODEV; } - return ata_pci_init_one(pdev, ppi); + return ata_pci_init_one(pdev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/pata_sis.c b/trunk/drivers/ata/pata_sis.c index f2231267e011..f5838cc11728 100644 --- a/trunk/drivers/ata/pata_sis.c +++ b/trunk/drivers/ata/pata_sis.c @@ -38,8 +38,8 @@ #define DRV_VERSION "0.5.1" struct sis_chipset { - u16 device; /* PCI host ID */ - const struct ata_port_info *info; /* Info block */ + u16 device; /* PCI host ID */ + struct ata_port_info *info; /* Info block */ /* Probably add family, cable detect type etc here to clean up code later */ }; @@ -524,6 +524,10 @@ static struct scsi_host_template sis_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static const struct ata_port_operations sis_133_ops = { @@ -696,7 +700,7 @@ static const struct ata_port_operations sis_old_ops = { .port_start = ata_port_start, }; -static const struct ata_port_info sis_info = { +static struct ata_port_info sis_info = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -704,7 +708,7 @@ static const struct ata_port_info sis_info = { .udma_mask = 0, .port_ops = &sis_old_ops, }; -static const struct ata_port_info sis_info33 = { +static struct ata_port_info sis_info33 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -712,35 +716,35 @@ static const struct ata_port_info sis_info33 = { .udma_mask = ATA_UDMA2, /* UDMA 33 */ .port_ops = &sis_old_ops, }; -static const struct ata_port_info sis_info66 = { +static struct ata_port_info sis_info66 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .udma_mask = ATA_UDMA4, /* UDMA 66 */ .port_ops = &sis_66_ops, }; -static const struct ata_port_info sis_info100 = { +static struct ata_port_info sis_info100 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .udma_mask = ATA_UDMA5, .port_ops = &sis_100_ops, }; -static const struct ata_port_info sis_info100_early = { +static struct ata_port_info sis_info100_early = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .udma_mask = ATA_UDMA5, .pio_mask = 0x1f, /* pio0-4 */ .port_ops = &sis_66_ops, }; -const struct ata_port_info sis_info133 = { +struct ata_port_info sis_info133 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .udma_mask = ATA_UDMA6, .port_ops = &sis_133_ops, }; -static const struct ata_port_info sis_info133_early = { +static struct ata_port_info sis_info133_early = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -823,8 +827,8 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis) static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - struct ata_port_info port; - const struct ata_port_info *ppi[] = { &port, NULL }; + static struct ata_port_info *port_info[2]; + struct ata_port_info *port; struct pci_dev *host = NULL; struct sis_chipset *chipset = NULL; struct sis_chipset *sets; @@ -964,12 +968,13 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) if (chipset == NULL) return -ENODEV; - port = *chipset->info; - port.private_data = chipset; + port = chipset->info; + port->private_data = chipset; sis_fixup(pdev, chipset); - return ata_pci_init_one(pdev, ppi); + port_info[0] = port_info[1] = port; + return ata_pci_init_one(pdev, port_info, 2); } static const struct pci_device_id sis_pci_tbl[] = { diff --git a/trunk/drivers/ata/pata_sl82c105.c b/trunk/drivers/ata/pata_sl82c105.c index f48491ad5f3a..9aeffdbe2829 100644 --- a/trunk/drivers/ata/pata_sl82c105.c +++ b/trunk/drivers/ata/pata_sl82c105.c @@ -301,22 +301,20 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev) static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info_dma = { + static struct ata_port_info info_dma = { .sht = &sl82c105_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &sl82c105_port_ops }; - static const struct ata_port_info info_early = { + static struct ata_port_info info_early = { .sht = &sl82c105_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &sl82c105_port_ops }; - /* for now use only the first port */ - const struct ata_port_info *ppi[] = { &info_early, - &ata_dummy_port_info }; + static struct ata_port_info *port_info[2] = { &info_early, &info_early }; u32 val; int rev; @@ -326,14 +324,17 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); else if (rev <= 5) dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); - else - ppi[0] = &info_dma; + else { + port_info[0] = &info_dma; + port_info[1] = &info_dma; + } pci_read_config_dword(dev, 0x40, &val); val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; pci_write_config_dword(dev, 0x40, val); - return ata_pci_init_one(dev, ppi); + + return ata_pci_init_one(dev, port_info, 1); /* For now */ } static const struct pci_device_id sl82c105[] = { diff --git a/trunk/drivers/ata/pata_triflex.c b/trunk/drivers/ata/pata_triflex.c index b1d3076dfe51..349887bf5b93 100644 --- a/trunk/drivers/ata/pata_triflex.c +++ b/trunk/drivers/ata/pata_triflex.c @@ -194,6 +194,10 @@ static struct scsi_host_template triflex_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations triflex_port_ops = { @@ -233,20 +237,20 @@ static struct ata_port_operations triflex_port_ops = { static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static const struct ata_port_info info = { + static struct ata_port_info info = { .sht = &triflex_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &triflex_port_ops }; - const struct ata_port_info *ppi[] = { &info, NULL }; + static struct ata_port_info *port_info[2] = { &info, &info }; static int printed_version; if (!printed_version++) dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(dev, ppi); + return ata_pci_init_one(dev, port_info, 2); } static const struct pci_device_id triflex[] = { diff --git a/trunk/drivers/ata/pata_via.c b/trunk/drivers/ata/pata_via.c index e4c71f76bd55..362beb2f489c 100644 --- a/trunk/drivers/ata/pata_via.c +++ b/trunk/drivers/ata/pata_via.c @@ -301,6 +301,10 @@ static struct scsi_host_template via_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, +#endif }; static struct ata_port_operations via_port_ops = { @@ -421,7 +425,7 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags) static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { /* Early VIA without UDMA support */ - static const struct ata_port_info via_mwdma_info = { + static struct ata_port_info via_mwdma_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -429,7 +433,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* Ditto with IRQ masking required */ - static const struct ata_port_info via_mwdma_info_borked = { + static struct ata_port_info via_mwdma_info_borked = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -437,7 +441,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops_noirq, }; /* VIA UDMA 33 devices (and borked 66) */ - static const struct ata_port_info via_udma33_info = { + static struct ata_port_info via_udma33_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -446,7 +450,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* VIA UDMA 66 devices */ - static const struct ata_port_info via_udma66_info = { + static struct ata_port_info via_udma66_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -455,7 +459,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* VIA UDMA 100 devices */ - static const struct ata_port_info via_udma100_info = { + static struct ata_port_info via_udma100_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -464,7 +468,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* UDMA133 with bad AST (All current 133) */ - static const struct ata_port_info via_udma133_info = { + static struct ata_port_info via_udma133_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -472,8 +476,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x7f, /* FIXME: should check north bridge */ .port_ops = &via_port_ops }; - struct ata_port_info type; - const struct ata_port_info *ppi[] = { &type, NULL }; + struct ata_port_info *port_info[2], *type; struct pci_dev *isa = NULL; const struct via_isa_bridge *config; static int printed_version; @@ -518,25 +521,25 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) switch(config->flags & VIA_UDMA) { case VIA_UDMA_NONE: if (config->flags & VIA_NO_UNMASK) - type = via_mwdma_info_borked; + type = &via_mwdma_info_borked; else - type = via_mwdma_info; + type = &via_mwdma_info; break; case VIA_UDMA_33: - type = via_udma33_info; + type = &via_udma33_info; break; case VIA_UDMA_66: - type = via_udma66_info; + type = &via_udma66_info; /* The 66 MHz devices require we enable the clock */ pci_read_config_dword(pdev, 0x50, &timing); timing |= 0x80008; pci_write_config_dword(pdev, 0x50, timing); break; case VIA_UDMA_100: - type = via_udma100_info; + type = &via_udma100_info; break; case VIA_UDMA_133: - type = via_udma133_info; + type = &via_udma133_info; break; default: WARN_ON(1); @@ -551,9 +554,10 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) } /* We have established the device type, now fire it up */ - type.private_data = (void *)config; + type->private_data = (void *)config; - return ata_pci_init_one(pdev, ppi); + port_info[0] = port_info[1] = type; + return ata_pci_init_one(pdev, port_info, 2); } #ifdef CONFIG_PM diff --git a/trunk/drivers/ata/sata_inic162x.c b/trunk/drivers/ata/sata_inic162x.c index bda5e7747c21..b3b62e985f19 100644 --- a/trunk/drivers/ata/sata_inic162x.c +++ b/trunk/drivers/ata/sata_inic162x.c @@ -135,6 +135,10 @@ static struct scsi_host_template inic_sht = { .slave_configure = inic_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static const int scr_map[] = { diff --git a/trunk/drivers/ata/sata_nv.c b/trunk/drivers/ata/sata_nv.c index 4cea3ef75226..a097595d4dc7 100644 --- a/trunk/drivers/ata/sata_nv.c +++ b/trunk/drivers/ata/sata_nv.c @@ -325,6 +325,10 @@ static struct scsi_host_template nv_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static struct scsi_host_template nv_adma_sht = { @@ -343,6 +347,10 @@ static struct scsi_host_template nv_adma_sht = { .slave_configure = nv_adma_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static const struct ata_port_operations nv_generic_ops = { @@ -457,7 +465,7 @@ static const struct ata_port_operations nv_adma_ops = { .host_stop = nv_adma_host_stop, }; -static const struct ata_port_info nv_port_info[] = { +static struct ata_port_info nv_port_info[] = { /* generic */ { .sht = &nv_sht, @@ -1537,7 +1545,7 @@ static void nv_adma_error_handler(struct ata_port *ap) static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version = 0; - const struct ata_port_info *ppi[] = { NULL, NULL }; + const struct ata_port_info *ppi[2]; struct ata_host *host; struct nv_host_priv *hpriv; int rc; @@ -1565,8 +1573,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) type = ADMA; } - ppi[0] = &nv_port_info[type]; - rc = ata_pci_prepare_native_host(pdev, ppi, &host); + ppi[0] = ppi[1] = &nv_port_info[type]; + rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); if (rc) return rc; diff --git a/trunk/drivers/ata/sata_sil.c b/trunk/drivers/ata/sata_sil.c index e8483aadd11b..0a1e417f309c 100644 --- a/trunk/drivers/ata/sata_sil.c +++ b/trunk/drivers/ata/sata_sil.c @@ -182,6 +182,10 @@ static struct scsi_host_template sil_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static const struct ata_port_operations sil_ops = { diff --git a/trunk/drivers/ata/sata_sil24.c b/trunk/drivers/ata/sata_sil24.c index a69d78cd8e9b..b97ee9f31aec 100644 --- a/trunk/drivers/ata/sata_sil24.c +++ b/trunk/drivers/ata/sata_sil24.c @@ -380,6 +380,10 @@ static struct scsi_host_template sil24_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static const struct ata_port_operations sil24_ops = { diff --git a/trunk/drivers/ata/sata_sis.c b/trunk/drivers/ata/sata_sis.c index ee66c5fa7ac8..d8ee062e82fc 100644 --- a/trunk/drivers/ata/sata_sis.c +++ b/trunk/drivers/ata/sata_sis.c @@ -129,7 +129,7 @@ static const struct ata_port_operations sis_ops = { .port_start = ata_port_start, }; -static const struct ata_port_info sis_port_info = { +static struct ata_port_info sis_port_info = { .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, .pio_mask = 0x1f, .mwdma_mask = 0x7, @@ -255,7 +255,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; struct ata_port_info pi = sis_port_info; - const struct ata_port_info *ppi[] = { &pi, NULL }; + const struct ata_port_info *ppi[2] = { &pi, &pi }; struct ata_host *host; u32 genctl, val; u8 pmr; @@ -335,7 +335,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) break; } - rc = ata_pci_prepare_native_host(pdev, ppi, &host); + rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); if (rc) return rc; diff --git a/trunk/drivers/ata/sata_uli.c b/trunk/drivers/ata/sata_uli.c index 006f5e352658..f74e383de083 100644 --- a/trunk/drivers/ata/sata_uli.c +++ b/trunk/drivers/ata/sata_uli.c @@ -125,7 +125,7 @@ static const struct ata_port_operations uli_ops = { .port_start = ata_port_start, }; -static const struct ata_port_info uli_port_info = { +static struct ata_port_info uli_port_info = { .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_IGN_SIMPLEX, .pio_mask = 0x1f, /* pio0-4 */ @@ -201,33 +201,19 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) n_ports = 2; if (board_idx == uli_5287) n_ports = 4; - - /* allocate the host */ - host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); - if (!host) - return -ENOMEM; + rc = ata_pci_prepare_native_host(pdev, ppi, n_ports, &host); + if (rc) + return rc; hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); if (!hpriv) return -ENOMEM; host->private_data = hpriv; - /* the first two ports are standard SFF */ - rc = ata_pci_init_native_host(host); - if (rc) - return rc; - - rc = ata_pci_init_bmdma(host); - if (rc) - return rc; - iomap = host->iomap; switch (board_idx) { case uli_5287: - /* If there are four, the last two live right after - * the standard SFF ports. - */ hpriv->scr_cfg_addr[0] = ULI5287_BASE; hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; diff --git a/trunk/drivers/ata/sata_via.c b/trunk/drivers/ata/sata_via.c index d105d2c189d2..939c9246fdd1 100644 --- a/trunk/drivers/ata/sata_via.c +++ b/trunk/drivers/ata/sata_via.c @@ -116,6 +116,10 @@ static struct scsi_host_template svia_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, +#ifdef CONFIG_PM + .suspend = ata_scsi_device_suspend, + .resume = ata_scsi_device_resume, +#endif }; static const struct ata_port_operations vt6420_sata_ops = { @@ -411,7 +415,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) struct ata_host *host; int rc; - rc = ata_pci_prepare_native_host(pdev, ppi, &host); + rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); if (rc) return rc; *r_host = host; diff --git a/trunk/drivers/ata/sis.h b/trunk/drivers/ata/sis.h index 0f2208d8d5ef..231da8fc2200 100644 --- a/trunk/drivers/ata/sis.h +++ b/trunk/drivers/ata/sis.h @@ -2,4 +2,4 @@ struct ata_port_info; /* pata_sis.c */ -extern const struct ata_port_info sis_info133; +extern struct ata_port_info sis_info133; diff --git a/trunk/drivers/atm/Kconfig b/trunk/drivers/atm/Kconfig index f5a47a48c3b4..33687454eb32 100644 --- a/trunk/drivers/atm/Kconfig +++ b/trunk/drivers/atm/Kconfig @@ -2,22 +2,19 @@ # ATM device configuration # -menuconfig ATM_DRIVERS - bool "ATM drivers" +menu "ATM drivers" depends on NETDEVICES && ATM - default y - -if ATM_DRIVERS config ATM_DUMMY tristate "Dummy ATM driver" + depends on ATM help Dummy ATM driver. Useful for proxy signalling, testing, and development. If unsure, say N. config ATM_TCP tristate "ATM over TCP" - depends on INET + depends on INET && ATM help ATM over TCP driver. Useful mainly for development and for experiments. If unsure, say N. @@ -33,7 +30,7 @@ config ATM_LANAI config ATM_ENI tristate "Efficient Networks ENI155P" - depends on PCI + depends on PCI && ATM ---help--- Driver for the Efficient Networks ENI155p series and SMC ATM Power155 155 Mbps ATM adapters. Both, the versions with 512KB and @@ -142,7 +139,7 @@ config ATM_ENI_BURST_RX_2W config ATM_FIRESTREAM tristate "Fujitsu FireStream (FS50/FS155) " - depends on PCI + depends on PCI && ATM help Driver for the Fujitsu FireStream 155 (MB86697) and FireStream 50 (MB86695) ATM PCI chips. @@ -152,7 +149,7 @@ config ATM_FIRESTREAM config ATM_ZATM tristate "ZeitNet ZN1221/ZN1225" - depends on PCI + depends on PCI && ATM help Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM adapters. @@ -172,7 +169,7 @@ config ATM_ZATM_DEBUG config ATM_NICSTAR tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" - depends on PCI && !64BIT + depends on PCI && ATM && !64BIT help The NICStAR chipset family is used in a large number of ATM NICs for 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE @@ -205,7 +202,7 @@ config ATM_NICSTAR_USE_IDT77105 config ATM_IDT77252 tristate "IDT 77252 (NICStAR II)" - depends on PCI + depends on PCI && ATM help Driver for the IDT 77252 ATM PCI chips. @@ -240,7 +237,7 @@ config ATM_IDT77252_USE_SUNI config ATM_AMBASSADOR tristate "Madge Ambassador (Collage PCI 155 Server)" - depends on PCI + depends on PCI && ATM select BITREVERSE help This is a driver for ATMizer based ATM card produced by Madge @@ -265,7 +262,7 @@ config ATM_AMBASSADOR_DEBUG config ATM_HORIZON tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)" - depends on PCI + depends on PCI && ATM help This is a driver for the Horizon chipset ATM adapter cards once produced by Madge Networks Ltd. Say Y (or M to compile as a module @@ -289,7 +286,7 @@ config ATM_HORIZON_DEBUG config ATM_IA tristate "Interphase ATM PCI x575/x525/x531" - depends on PCI && !64BIT + depends on PCI && ATM && !64BIT ---help--- This is a driver for the Interphase (i)ChipSAR adapter cards which include a variety of variants in term of the size of the @@ -322,7 +319,7 @@ config ATM_IA_DEBUG config ATM_FORE200E_MAYBE tristate "FORE Systems 200E-series" - depends on PCI || SBUS + depends on (PCI || SBUS) && ATM ---help--- This is a driver for the FORE Systems 200E-series ATM adapter cards. It simultaneously supports PCA-200E and SBA-200E models @@ -439,7 +436,7 @@ config ATM_FORE200E config ATM_HE tristate "ForeRunner HE Series" - depends on PCI + depends on PCI && ATM help This is a driver for the Marconi ForeRunner HE-series ATM adapter cards. It simultaneously supports the 155 and 622 versions. @@ -451,4 +448,5 @@ config ATM_HE_USE_SUNI Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner HE cards. This driver provides carrier detection some statistics. -endif # ATM +endmenu + diff --git a/trunk/drivers/char/watchdog/iTCO_wdt.c b/trunk/drivers/char/watchdog/iTCO_wdt.c index eac4f9b9f007..3c9684ccd2f9 100644 --- a/trunk/drivers/char/watchdog/iTCO_wdt.c +++ b/trunk/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, * ACPIBASE is bits [15:7] from 0x40-0x43 */ pci_read_config_dword(pdev, 0x40, &base_address); - base_address &= 0x0000ff80; + base_address &= 0x00007f80; if (base_address == 0x00000000) { /* Something's wrong here, ACPIBASE has to be set */ printk(KERN_ERR PFX "failed to get TCOBASE address\n"); diff --git a/trunk/drivers/net/Kconfig b/trunk/drivers/net/Kconfig index 8a7f9e9fb8d8..fa489b10c38c 100644 --- a/trunk/drivers/net/Kconfig +++ b/trunk/drivers/net/Kconfig @@ -1898,12 +1898,8 @@ endmenu # Gigabit Ethernet # -menuconfig NETDEV_1000 - bool "Ethernet (1000 Mbit)" +menu "Ethernet (1000 Mbit)" depends on !UML - default y - -if NETDEV_1000 config ACENIC tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" @@ -2330,18 +2326,14 @@ config ATL1 To compile this driver as a module, choose M here. The module will be called atl1. -endif # NETDEV_1000 +endmenu # # 10 Gigabit Ethernet # -menuconfig NETDEV_10000 - bool "Ethernet (10000 Mbit)" +menu "Ethernet (10000 Mbit)" depends on !UML - default y - -if NETDEV_10000 config CHELSIO_T1 tristate "Chelsio 10Gb Ethernet support" @@ -2515,7 +2507,7 @@ config MLX4_DEBUG debug_level module parameter (which can also be set after the driver is loaded through sysfs). -endif # NETDEV_10000 +endmenu source "drivers/net/tokenring/Kconfig" diff --git a/trunk/drivers/net/mlx4/eq.c b/trunk/drivers/net/mlx4/eq.c index af016d0ea1c6..acf1c801a1b8 100644 --- a/trunk/drivers/net/mlx4/eq.c +++ b/trunk/drivers/net/mlx4/eq.c @@ -623,7 +623,7 @@ int __devinit mlx4_init_eq_table(struct mlx4_dev *dev) priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1; } else { err = request_irq(dev->pdev->irq, mlx4_interrupt, - IRQF_SHARED, DRV_NAME, dev); + SA_SHIRQ, DRV_NAME, dev); if (err) goto err_out_async; diff --git a/trunk/drivers/net/netxen/netxen_nic_main.c b/trunk/drivers/net/netxen/netxen_nic_main.c index 2c5c6d20e6e9..4e32bb678ea9 100644 --- a/trunk/drivers/net/netxen/netxen_nic_main.c +++ b/trunk/drivers/net/netxen/netxen_nic_main.c @@ -735,7 +735,7 @@ static int netxen_nic_open(struct net_device *netdev) } adapter->irq = adapter->ahw.pdev->irq; err = request_irq(adapter->ahw.pdev->irq, netxen_intr, - IRQF_SHARED|IRQF_SAMPLE_RANDOM, netdev->name, + SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, adapter); if (err) { printk(KERN_ERR "request_irq failed with: %d\n", err); diff --git a/trunk/drivers/net/pcmcia/Kconfig b/trunk/drivers/net/pcmcia/Kconfig index 5d658bc9791c..74f862001247 100644 --- a/trunk/drivers/net/pcmcia/Kconfig +++ b/trunk/drivers/net/pcmcia/Kconfig @@ -2,9 +2,11 @@ # PCMCIA Network device configuration # -menuconfig NET_PCMCIA +menu "PCMCIA network device support" + depends on NETDEVICES && PCMCIA!=n + +config NET_PCMCIA bool "PCMCIA network device support" - depends on PCMCIA ---help--- Say Y if you would like to include support for any PCMCIA or CardBus network adapters, then say Y to the driver for your particular card @@ -19,10 +21,9 @@ menuconfig NET_PCMCIA If unsure, say N. -if NET_PCMCIA - config PCMCIA_3C589 tristate "3Com 3c589 PCMCIA support" + depends on NET_PCMCIA && PCMCIA help Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA (PC-card) Ethernet card to your computer. @@ -32,6 +33,7 @@ config PCMCIA_3C589 config PCMCIA_3C574 tristate "3Com 3c574 PCMCIA support" + depends on NET_PCMCIA && PCMCIA help Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA (PC-card) Fast Ethernet card to your computer. @@ -41,6 +43,7 @@ config PCMCIA_3C574 config PCMCIA_FMVJ18X tristate "Fujitsu FMV-J18x PCMCIA support" + depends on NET_PCMCIA && PCMCIA select CRC32 help Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible @@ -51,6 +54,7 @@ config PCMCIA_FMVJ18X config PCMCIA_PCNET tristate "NE2000 compatible PCMCIA support" + depends on NET_PCMCIA && PCMCIA select CRC32 help Say Y here if you intend to attach an NE2000 compatible PCMCIA @@ -61,6 +65,7 @@ config PCMCIA_PCNET config PCMCIA_NMCLAN tristate "New Media PCMCIA support" + depends on NET_PCMCIA && PCMCIA help Say Y here if you intend to attach a New Media Ethernet or LiveWire PCMCIA (PC-card) Ethernet card to your computer. @@ -70,6 +75,7 @@ config PCMCIA_NMCLAN config PCMCIA_SMC91C92 tristate "SMC 91Cxx PCMCIA support" + depends on NET_PCMCIA && PCMCIA select CRC32 select MII help @@ -81,6 +87,7 @@ config PCMCIA_SMC91C92 config PCMCIA_XIRC2PS tristate "Xircom 16-bit PCMCIA support" + depends on NET_PCMCIA && PCMCIA help Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card) Ethernet or Fast Ethernet card to your computer. @@ -90,6 +97,7 @@ config PCMCIA_XIRC2PS config PCMCIA_AXNET tristate "Asix AX88190 PCMCIA support" + depends on NET_PCMCIA && PCMCIA ---help--- Say Y here if you intend to attach an Asix AX88190-based PCMCIA (PC-card) Fast Ethernet card to your computer. These cards are @@ -101,7 +109,7 @@ config PCMCIA_AXNET config ARCNET_COM20020_CS tristate "COM20020 ARCnet PCMCIA support" - depends on ARCNET_COM20020 + depends on NET_PCMCIA && ARCNET_COM20020 && PCMCIA help Say Y here if you intend to attach this type of ARCnet PCMCIA card to your computer. @@ -111,7 +119,7 @@ config ARCNET_COM20020_CS config PCMCIA_IBMTR tristate "IBM PCMCIA tokenring adapter support" - depends on IBMTR!=y && TR && !64BIT + depends on NET_PCMCIA && IBMTR!=y && TR && PCMCIA && !64BIT help Say Y here if you intend to attach this type of Token Ring PCMCIA card to your computer. You then also need to say Y to "Token Ring @@ -120,4 +128,5 @@ config PCMCIA_IBMTR To compile this driver as a module, choose M here: the module will be called ibmtr_cs. -endif # NET_PCMCIA +endmenu + diff --git a/trunk/drivers/net/phy/Kconfig b/trunk/drivers/net/phy/Kconfig index 09b6f259eb92..c0d3101eb6a0 100644 --- a/trunk/drivers/net/phy/Kconfig +++ b/trunk/drivers/net/phy/Kconfig @@ -2,61 +2,70 @@ # PHY Layer Configuration # -menuconfig PHYLIB - tristate "PHY Device support and infrastructure" +menu "PHY device support" depends on !S390 + +config PHYLIB + tristate "PHY Device support and infrastructure" depends on NET_ETHERNET && (BROKEN || !S390) help Ethernet controllers are usually attached to PHY devices. This option provides infrastructure for managing PHY devices. -if PHYLIB - comment "MII PHY device drivers" + depends on PHYLIB config MARVELL_PHY tristate "Drivers for Marvell PHYs" + depends on PHYLIB ---help--- Currently has a driver for the 88E1011S config DAVICOM_PHY tristate "Drivers for Davicom PHYs" + depends on PHYLIB ---help--- Currently supports dm9161e and dm9131 config QSEMI_PHY tristate "Drivers for Quality Semiconductor PHYs" + depends on PHYLIB ---help--- Currently supports the qs6612 config LXT_PHY tristate "Drivers for the Intel LXT PHYs" + depends on PHYLIB ---help--- Currently supports the lxt970, lxt971 config CICADA_PHY tristate "Drivers for the Cicada PHYs" + depends on PHYLIB ---help--- Currently supports the cis8204 - config VITESSE_PHY tristate "Drivers for the Vitesse PHYs" + depends on PHYLIB ---help--- Currently supports the vsc8244 config SMSC_PHY tristate "Drivers for SMSC PHYs" + depends on PHYLIB ---help--- Currently supports the LAN83C185 PHY config BROADCOM_PHY tristate "Drivers for Broadcom PHYs" + depends on PHYLIB ---help--- Currently supports the BCM5411, BCM5421 and BCM5461 PHYs. config FIXED_PHY tristate "Drivers for PHY emulation on fixed speed/link" + depends on PHYLIB ---help--- Adds the driver to PHY layer to cover the boards that do not have any PHY bound, but with the ability to manipulate the speed/link in software. The relevant MII @@ -71,4 +80,5 @@ config FIXED_MII_100_FDX bool "Emulation for 100M Fdx fixed PHY behavior" depends on FIXED_PHY -endif # PHYLIB +endmenu + diff --git a/trunk/drivers/net/phy/davicom.c b/trunk/drivers/net/phy/davicom.c index 7ed632db00d7..519baa38be8d 100644 --- a/trunk/drivers/net/phy/davicom.c +++ b/trunk/drivers/net/phy/davicom.c @@ -139,7 +139,7 @@ static int dm9161_ack_interrupt(struct phy_device *phydev) return (err < 0) ? err : 0; } -static struct phy_driver dm9161e_driver = { +static struct phy_driver dm9161_driver = { .phy_id = 0x0181b880, .name = "Davicom DM9161E", .phy_id_mask = 0x0ffffff0, @@ -147,18 +147,7 @@ static struct phy_driver dm9161e_driver = { .config_init = dm9161_config_init, .config_aneg = dm9161_config_aneg, .read_status = genphy_read_status, - .driver = { .owner = THIS_MODULE,}, -}; - -static struct phy_driver dm9161a_driver = { - .phy_id = 0x0181b8a0, - .name = "Davicom DM9161A", - .phy_id_mask = 0x0ffffff0, - .features = PHY_BASIC_FEATURES, - .config_init = dm9161_config_init, - .config_aneg = dm9161_config_aneg, - .read_status = genphy_read_status, - .driver = { .owner = THIS_MODULE,}, + .driver = { .owner = THIS_MODULE,}, }; static struct phy_driver dm9131_driver = { @@ -171,38 +160,31 @@ static struct phy_driver dm9131_driver = { .read_status = genphy_read_status, .ack_interrupt = dm9161_ack_interrupt, .config_intr = dm9161_config_intr, - .driver = { .owner = THIS_MODULE,}, + .driver = { .owner = THIS_MODULE,}, }; static int __init davicom_init(void) { int ret; - ret = phy_driver_register(&dm9161e_driver); + ret = phy_driver_register(&dm9161_driver); if (ret) goto err1; - ret = phy_driver_register(&dm9161a_driver); - if (ret) - goto err2; - ret = phy_driver_register(&dm9131_driver); if (ret) - goto err3; + goto err2; return 0; - err3: - phy_driver_unregister(&dm9161a_driver); - err2: - phy_driver_unregister(&dm9161e_driver); + err2: + phy_driver_unregister(&dm9161_driver); err1: return ret; } static void __exit davicom_exit(void) { - phy_driver_unregister(&dm9161e_driver); - phy_driver_unregister(&dm9161a_driver); + phy_driver_unregister(&dm9161_driver); phy_driver_unregister(&dm9131_driver); } diff --git a/trunk/drivers/net/s2io.c b/trunk/drivers/net/s2io.c index e3e6d410d72c..290e1c1f30c6 100644 --- a/trunk/drivers/net/s2io.c +++ b/trunk/drivers/net/s2io.c @@ -84,7 +84,7 @@ #include "s2io.h" #include "s2io-regs.h" -#define DRV_VERSION "2.0.23.1" +#define DRV_VERSION "2.0.22.1" /* S2io Driver name & version. */ static char s2io_driver_name[] = "Neterion"; @@ -281,28 +281,6 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = { ("lro_out_of_sequence_pkts"), ("lro_flush_due_to_max_pkts"), ("lro_avg_aggr_pkts"), - ("mem_alloc_fail_cnt"), - ("watchdog_timer_cnt"), - ("mem_allocated"), - ("mem_freed"), - ("link_up_cnt"), - ("link_down_cnt"), - ("link_up_time"), - ("link_down_time"), - ("tx_tcode_buf_abort_cnt"), - ("tx_tcode_desc_abort_cnt"), - ("tx_tcode_parity_err_cnt"), - ("tx_tcode_link_loss_cnt"), - ("tx_tcode_list_proc_err_cnt"), - ("rx_tcode_parity_err_cnt"), - ("rx_tcode_abort_cnt"), - ("rx_tcode_parity_abort_cnt"), - ("rx_tcode_rda_fail_cnt"), - ("rx_tcode_unkn_prot_cnt"), - ("rx_tcode_fcs_err_cnt"), - ("rx_tcode_buf_size_err_cnt"), - ("rx_tcode_rxd_corrupt_cnt"), - ("rx_tcode_unkn_err_cnt") }; #define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN @@ -512,7 +490,6 @@ static int init_shared_mem(struct s2io_nic *nic) struct mac_info *mac_control; struct config_param *config; - unsigned long long mem_allocated = 0; mac_control = &nic->mac_control; config = &nic->config; @@ -542,7 +519,6 @@ static int init_shared_mem(struct s2io_nic *nic) "Malloc failed for list_info\n"); return -ENOMEM; } - mem_allocated += list_holder_size; memset(mac_control->fifos[i].list_info, 0, list_holder_size); } for (i = 0; i < config->tx_fifo_num; i++) { @@ -589,7 +565,6 @@ static int init_shared_mem(struct s2io_nic *nic) DBG_PRINT(INFO_DBG, "failed for TxDL\n"); return -ENOMEM; } - mem_allocated += PAGE_SIZE; } while (k < lst_per_page) { int l = (j * lst_per_page) + k; @@ -607,7 +582,6 @@ static int init_shared_mem(struct s2io_nic *nic) nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); if (!nic->ufo_in_band_v) return -ENOMEM; - mem_allocated += (size * sizeof(u64)); /* Allocation and initialization of RXDs in Rings */ size = 0; @@ -665,7 +639,6 @@ static int init_shared_mem(struct s2io_nic *nic) rx_blocks->block_virt_addr = tmp_v_addr; return -ENOMEM; } - mem_allocated += size; memset(tmp_v_addr, 0, size); rx_blocks->block_virt_addr = tmp_v_addr; rx_blocks->block_dma_addr = tmp_p_addr; @@ -674,8 +647,6 @@ static int init_shared_mem(struct s2io_nic *nic) GFP_KERNEL); if (!rx_blocks->rxds) return -ENOMEM; - mem_allocated += - (sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]); for (l=0; lrxd_mode];l++) { rx_blocks->rxds[l].virt_addr = rx_blocks->block_virt_addr + @@ -718,7 +689,6 @@ static int init_shared_mem(struct s2io_nic *nic) GFP_KERNEL); if (!mac_control->rings[i].ba) return -ENOMEM; - mem_allocated +=(sizeof(struct buffAdd *) * blk_cnt); for (j = 0; j < blk_cnt; j++) { int k = 0; mac_control->rings[i].ba[j] = @@ -727,8 +697,6 @@ static int init_shared_mem(struct s2io_nic *nic) GFP_KERNEL); if (!mac_control->rings[i].ba[j]) return -ENOMEM; - mem_allocated += (sizeof(struct buffAdd) * \ - (rxd_count[nic->rxd_mode] + 1)); while (k != rxd_count[nic->rxd_mode]) { ba = &mac_control->rings[i].ba[j][k]; @@ -736,8 +704,6 @@ static int init_shared_mem(struct s2io_nic *nic) (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); if (!ba->ba_0_org) return -ENOMEM; - mem_allocated += - (BUF0_LEN + ALIGN_SIZE); tmp = (unsigned long)ba->ba_0_org; tmp += ALIGN_SIZE; tmp &= ~((unsigned long) ALIGN_SIZE); @@ -747,8 +713,6 @@ static int init_shared_mem(struct s2io_nic *nic) (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); if (!ba->ba_1_org) return -ENOMEM; - mem_allocated - += (BUF1_LEN + ALIGN_SIZE); tmp = (unsigned long) ba->ba_1_org; tmp += ALIGN_SIZE; tmp &= ~((unsigned long) ALIGN_SIZE); @@ -772,7 +736,6 @@ static int init_shared_mem(struct s2io_nic *nic) */ return -ENOMEM; } - mem_allocated += size; mac_control->stats_mem_sz = size; tmp_v_addr = mac_control->stats_mem; @@ -780,7 +743,7 @@ static int init_shared_mem(struct s2io_nic *nic) memset(tmp_v_addr, 0, size); DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, (unsigned long long) tmp_p_addr); - mac_control->stats_info->sw_stat.mem_allocated += mem_allocated; + return SUCCESS; } @@ -794,14 +757,12 @@ static int init_shared_mem(struct s2io_nic *nic) static void free_shared_mem(struct s2io_nic *nic) { int i, j, blk_cnt, size; - u32 ufo_size = 0; void *tmp_v_addr; dma_addr_t tmp_p_addr; struct mac_info *mac_control; struct config_param *config; int lst_size, lst_per_page; struct net_device *dev = nic->dev; - int page_num = 0; if (!nic) return; @@ -813,9 +774,8 @@ static void free_shared_mem(struct s2io_nic *nic) lst_per_page = PAGE_SIZE / lst_size; for (i = 0; i < config->tx_fifo_num; i++) { - ufo_size += config->tx_cfg[i].fifo_len; - page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, - lst_per_page); + int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, + lst_per_page); for (j = 0; j < page_num; j++) { int mem_blks = (j * lst_per_page); if (!mac_control->fifos[i].list_info) @@ -830,8 +790,6 @@ static void free_shared_mem(struct s2io_nic *nic) mac_control->fifos[i]. list_info[mem_blks]. list_phy_addr); - nic->mac_control.stats_info->sw_stat.mem_freed - += PAGE_SIZE; } /* If we got a zero DMA address during allocation, * free the page now @@ -845,12 +803,8 @@ static void free_shared_mem(struct s2io_nic *nic) dev->name); DBG_PRINT(INIT_DBG, "Virtual address %p\n", mac_control->zerodma_virt_addr); - nic->mac_control.stats_info->sw_stat.mem_freed - += PAGE_SIZE; } kfree(mac_control->fifos[i].list_info); - nic->mac_control.stats_info->sw_stat.mem_freed += - (nic->config.tx_cfg[i].fifo_len *sizeof(struct list_info_hold)); } size = SIZE_OF_BLOCK; @@ -865,10 +819,7 @@ static void free_shared_mem(struct s2io_nic *nic) break; pci_free_consistent(nic->pdev, size, tmp_v_addr, tmp_p_addr); - nic->mac_control.stats_info->sw_stat.mem_freed += size; kfree(mac_control->rings[i].rx_blocks[j].rxds); - nic->mac_control.stats_info->sw_stat.mem_freed += - ( sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]); } } @@ -885,20 +836,12 @@ static void free_shared_mem(struct s2io_nic *nic) struct buffAdd *ba = &mac_control->rings[i].ba[j][k]; kfree(ba->ba_0_org); - nic->mac_control.stats_info->sw_stat.\ - mem_freed += (BUF0_LEN + ALIGN_SIZE); kfree(ba->ba_1_org); - nic->mac_control.stats_info->sw_stat.\ - mem_freed += (BUF1_LEN + ALIGN_SIZE); k++; } kfree(mac_control->rings[i].ba[j]); - nic->mac_control.stats_info->sw_stat.mem_freed += (sizeof(struct buffAdd) * - (rxd_count[nic->rxd_mode] + 1)); } kfree(mac_control->rings[i].ba); - nic->mac_control.stats_info->sw_stat.mem_freed += - (sizeof(struct buffAdd *) * blk_cnt); } } @@ -907,14 +850,9 @@ static void free_shared_mem(struct s2io_nic *nic) mac_control->stats_mem_sz, mac_control->stats_mem, mac_control->stats_mem_phy); - nic->mac_control.stats_info->sw_stat.mem_freed += - mac_control->stats_mem_sz; } - if (nic->ufo_in_band_v) { + if (nic->ufo_in_band_v) kfree(nic->ufo_in_band_v); - nic->mac_control.stats_info->sw_stat.mem_freed - += (ufo_size * sizeof(u64)); - } } /** @@ -2184,12 +2122,10 @@ static void free_tx_buffers(struct s2io_nic *nic) for (i = 0; i < config->tx_fifo_num; i++) { for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { - txdp = (struct TxD *) \ - mac_control->fifos[i].list_info[j].list_virt_addr; + txdp = (struct TxD *) mac_control->fifos[i].list_info[j]. + list_virt_addr; skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); if (skb) { - nic->mac_control.stats_info->sw_stat.mem_freed - += skb->truesize; dev_kfree_skb(skb); cnt++; } @@ -2250,14 +2186,11 @@ static int fill_rxd_3buf(struct s2io_nic *nic, struct RxD_t *rxdp, struct \ /* skb_shinfo(skb)->frag_list will have L4 data payload */ skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE); if (skb_shinfo(skb)->frag_list == NULL) { - nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name); return -ENOMEM ; } frag_list = skb_shinfo(skb)->frag_list; skb->truesize += frag_list->truesize; - nic->mac_control.stats_info->sw_stat.mem_allocated - += frag_list->truesize; frag_list->next = NULL; tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1); frag_list->data = tmp; @@ -2386,12 +2319,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) wmb(); first_rxdp->Control_1 |= RXD_OWN_XENA; } - nic->mac_control.stats_info->sw_stat. \ - mem_alloc_fail_cnt++; return -ENOMEM ; } - nic->mac_control.stats_info->sw_stat.mem_allocated - += skb->truesize; if (nic->rxd_mode == RXD_MODE_1) { /* 1 buffer mode - normal operation mode */ memset(rxdp, 0, sizeof(struct RxD1)); @@ -2399,8 +2328,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single (nic->pdev, skb->data, size - NET_IP_ALIGN, PCI_DMA_FROMDEVICE); - rxdp->Control_2 = - SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); + rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); } else if (nic->rxd_mode >= RXD_MODE_3A) { /* @@ -2414,7 +2342,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) * payload */ - /* save buffer pointers to avoid frequent dma mapping */ + /* save the buffer pointers to avoid frequent dma mapping */ Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; memset(rxdp, 0, sizeof(struct RxD3)); @@ -2436,7 +2364,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) PCI_DMA_FROMDEVICE); else pci_dma_sync_single_for_device(nic->pdev, - (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, + (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, BUF0_LEN, PCI_DMA_FROMDEVICE); rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); if (nic->rxd_mode == RXD_MODE_3B) { @@ -2463,8 +2391,6 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) } else { /* 3 buffer mode */ if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) { - nic->mac_control.stats_info->sw_stat.\ - mem_freed += skb->truesize; dev_kfree_skb_irq(skb); if (first_rxdp) { wmb(); @@ -2565,7 +2491,6 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk) PCI_DMA_FROMDEVICE); memset(rxdp, 0, sizeof(struct RxD3)); } - sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; dev_kfree_skb(skb); atomic_dec(&sp->rx_bufs_left[ring_no]); } @@ -2895,35 +2820,13 @@ static void tx_intr_handler(struct fifo_info *fifo_data) nic->mac_control.stats_info->sw_stat. parity_err_cnt++; } - - /* update t_code statistics */ - err >>= 48; - switch(err) { - case 2: - nic->mac_control.stats_info->sw_stat. - tx_buf_abort_cnt++; - break; - - case 3: - nic->mac_control.stats_info->sw_stat. - tx_desc_abort_cnt++; - break; - - case 7: - nic->mac_control.stats_info->sw_stat. - tx_parity_err_cnt++; - break; - - case 10: - nic->mac_control.stats_info->sw_stat. - tx_link_loss_cnt++; - break; - - case 15: - nic->mac_control.stats_info->sw_stat. - tx_list_proc_err_cnt++; - break; - } + if ((err >> 48) == 0xA) { + DBG_PRINT(TX_DBG, "TxD returned due \ + to loss of link\n"); + } + else { + DBG_PRINT(ERR_DBG, "***TxD error %llx\n", err); + } } skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); @@ -2936,7 +2839,6 @@ static void tx_intr_handler(struct fifo_info *fifo_data) /* Updating the statistics block */ nic->stats.tx_bytes += skb->len; - nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; dev_kfree_skb_irq(skb); get_info.offset++; @@ -3412,9 +3314,7 @@ static void s2io_reset(struct s2io_nic * sp) u16 subid, pci_cmd; int i; u16 val16; - unsigned long long up_cnt, down_cnt, up_time, down_time, reset_cnt; - unsigned long long mem_alloc_cnt, mem_free_cnt, watchdog_cnt; - + unsigned long long reset_cnt = 0; DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n", __FUNCTION__, sp->dev->name); @@ -3480,26 +3380,11 @@ static void s2io_reset(struct s2io_nic * sp) /* Reset device statistics maintained by OS */ memset(&sp->stats, 0, sizeof (struct net_device_stats)); - - up_cnt = sp->mac_control.stats_info->sw_stat.link_up_cnt; - down_cnt = sp->mac_control.stats_info->sw_stat.link_down_cnt; - up_time = sp->mac_control.stats_info->sw_stat.link_up_time; - down_time = sp->mac_control.stats_info->sw_stat.link_down_time; + /* save reset count */ reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt; - mem_alloc_cnt = sp->mac_control.stats_info->sw_stat.mem_allocated; - mem_free_cnt = sp->mac_control.stats_info->sw_stat.mem_freed; - watchdog_cnt = sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt; - /* save link up/down time/cnt, reset/memory/watchdog cnt */ memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block)); - /* restore link up/down time/cnt, reset/memory/watchdog cnt */ - sp->mac_control.stats_info->sw_stat.link_up_cnt = up_cnt; - sp->mac_control.stats_info->sw_stat.link_down_cnt = down_cnt; - sp->mac_control.stats_info->sw_stat.link_up_time = up_time; - sp->mac_control.stats_info->sw_stat.link_down_time = down_time; + /* restore reset count */ sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt; - sp->mac_control.stats_info->sw_stat.mem_allocated = mem_alloc_cnt; - sp->mac_control.stats_info->sw_stat.mem_freed = mem_free_cnt; - sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt = watchdog_cnt; /* SXE-002: Configure link and activity LED to turn it off */ subid = sp->pdev->subsystem_device; @@ -3787,29 +3672,19 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), GFP_KERNEL); if (nic->entries == NULL) { - DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \ - __FUNCTION__); - nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; + DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); return -ENOMEM; } - nic->mac_control.stats_info->sw_stat.mem_allocated - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); - memset(nic->entries, 0,MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); + memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); nic->s2io_entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), GFP_KERNEL); if (nic->s2io_entries == NULL) { - DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", - __FUNCTION__); - nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; + DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); kfree(nic->entries); - nic->mac_control.stats_info->sw_stat.mem_freed - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); return -ENOMEM; } - nic->mac_control.stats_info->sw_stat.mem_allocated - += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); memset(nic->s2io_entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); @@ -3833,8 +3708,7 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) rx_mat = readq(&bar0->rx_mat); for (j=0; jconfig.rx_ring_num; j++, msix_indx++) { rx_mat |= RX_MAT_SET(j, msix_indx); - nic->s2io_entries[msix_indx].arg - = &nic->mac_control.rings[j]; + nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; nic->s2io_entries[msix_indx].in_use = MSIX_FLG; } @@ -3843,8 +3717,7 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) tx_mat = readq(&bar0->tx_mat0_n[7]); for (j=0; jconfig.rx_ring_num; j++, msix_indx++) { tx_mat |= TX_MAT_SET(i, msix_indx); - nic->s2io_entries[msix_indx].arg - = &nic->mac_control.rings[j]; + nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; nic->s2io_entries[msix_indx].in_use = MSIX_FLG; } @@ -3861,11 +3734,7 @@ static int s2io_enable_msi_x(struct s2io_nic *nic) if (ret) { DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); kfree(nic->entries); - nic->mac_control.stats_info->sw_stat.mem_freed - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); kfree(nic->s2io_entries); - nic->mac_control.stats_info->sw_stat.mem_freed - += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); nic->entries = NULL; nic->s2io_entries = NULL; nic->avail_msix_vectors = 0; @@ -3933,16 +3802,10 @@ static int s2io_open(struct net_device *dev) hw_init_failed: if (sp->intr_type == MSI_X) { - if (sp->entries) { + if (sp->entries) kfree(sp->entries); - sp->mac_control.stats_info->sw_stat.mem_freed - += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); - } - if (sp->s2io_entries) { + if (sp->s2io_entries) kfree(sp->s2io_entries); - sp->mac_control.stats_info->sw_stat.mem_freed - += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); - } } return err; } @@ -4003,13 +3866,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) config = &sp->config; DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); - - if (unlikely(skb->len <= 0)) { - DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); - dev_kfree_skb_any(skb); - return 0; -} - spin_lock_irqsave(&sp->tx_lock, flags); if (atomic_read(&sp->card_state) == CARD_DOWN) { DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", @@ -4020,6 +3876,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) } queue = 0; + /* Get Fifo number to Transmit based on vlan priority */ if (sp->vlgrp && vlan_tx_tag_present(skb)) { vlan_tag = vlan_tx_tag_get(skb); @@ -4043,6 +3900,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) return 0; } + /* A buffer with no data will be dropped */ + if (!skb->len) { + DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); + dev_kfree_skb(skb); + spin_unlock_irqrestore(&sp->tx_lock, flags); + return 0; + } + offload_type = s2io_offload_type(skb); if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { txdp->Control_1 |= TXD_TCP_LSO_EN; @@ -4138,7 +4003,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) put_off, get_off); netif_stop_queue(dev); } - mac_control->stats_info->sw_stat.mem_allocated += skb->truesize; + dev->trans_start = jiffies; spin_unlock_irqrestore(&sp->tx_lock, flags); @@ -4910,40 +4775,6 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data) return 0; } -static void s2io_ethtool_gringparam(struct net_device *dev, - struct ethtool_ringparam *ering) -{ - struct s2io_nic *sp = dev->priv; - int i,tx_desc_count=0,rx_desc_count=0; - - if (sp->rxd_mode == RXD_MODE_1) - ering->rx_max_pending = MAX_RX_DESC_1; - else if (sp->rxd_mode == RXD_MODE_3B) - ering->rx_max_pending = MAX_RX_DESC_2; - else if (sp->rxd_mode == RXD_MODE_3A) - ering->rx_max_pending = MAX_RX_DESC_3; - - ering->tx_max_pending = MAX_TX_DESC; - for (i = 0 ; i < sp->config.tx_fifo_num ; i++) { - tx_desc_count += sp->config.tx_cfg[i].fifo_len; - } - DBG_PRINT(INFO_DBG,"\nmax txds : %d\n",sp->config.max_txds); - ering->tx_pending = tx_desc_count; - rx_desc_count = 0; - for (i = 0 ; i < sp->config.rx_ring_num ; i++) { - rx_desc_count += sp->config.rx_cfg[i].num_rxd; - } - ering->rx_pending = rx_desc_count; - - ering->rx_mini_max_pending = 0; - ering->rx_mini_pending = 0; - if(sp->rxd_mode == RXD_MODE_1) - ering->rx_jumbo_max_pending = MAX_RX_DESC_1; - else if (sp->rxd_mode == RXD_MODE_3B) - ering->rx_jumbo_max_pending = MAX_RX_DESC_2; - ering->rx_jumbo_pending = rx_desc_count; -} - /** * s2io_ethtool_getpause_data -Pause frame frame generation and reception. * @sp : private member of the device structure, which is a pointer to the @@ -5150,11 +4981,8 @@ static void s2io_vpd_read(struct s2io_nic *nic) strcpy(nic->serial_num, "NOT AVAILABLE"); vpd_data = kmalloc(256, GFP_KERNEL); - if (!vpd_data) { - nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++; + if (!vpd_data) return; - } - nic->mac_control.stats_info->sw_stat.mem_allocated += 256; for (i = 0; i < 256; i +=4 ) { pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); @@ -5194,7 +5022,6 @@ static void s2io_vpd_read(struct s2io_nic *nic) memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); } kfree(vpd_data); - nic->mac_control.stats_info->sw_stat.mem_freed += 256; } /** @@ -5915,30 +5742,6 @@ static void s2io_get_ethtool_stats(struct net_device *dev, } else tmp_stats[i++] = 0; - tmp_stats[i++] = stat_info->sw_stat.mem_alloc_fail_cnt; - tmp_stats[i++] = stat_info->sw_stat.watchdog_timer_cnt; - tmp_stats[i++] = stat_info->sw_stat.mem_allocated; - tmp_stats[i++] = stat_info->sw_stat.mem_freed; - tmp_stats[i++] = stat_info->sw_stat.link_up_cnt; - tmp_stats[i++] = stat_info->sw_stat.link_down_cnt; - tmp_stats[i++] = stat_info->sw_stat.link_up_time; - tmp_stats[i++] = stat_info->sw_stat.link_down_time; - - tmp_stats[i++] = stat_info->sw_stat.tx_buf_abort_cnt; - tmp_stats[i++] = stat_info->sw_stat.tx_desc_abort_cnt; - tmp_stats[i++] = stat_info->sw_stat.tx_parity_err_cnt; - tmp_stats[i++] = stat_info->sw_stat.tx_link_loss_cnt; - tmp_stats[i++] = stat_info->sw_stat.tx_list_proc_err_cnt; - - tmp_stats[i++] = stat_info->sw_stat.rx_parity_err_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_abort_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_parity_abort_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_rda_fail_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_unkn_prot_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_fcs_err_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_buf_size_err_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_rxd_corrupt_cnt; - tmp_stats[i++] = stat_info->sw_stat.rx_unkn_err_cnt; } static int s2io_ethtool_get_regs_len(struct net_device *dev) @@ -6051,7 +5854,6 @@ static const struct ethtool_ops netdev_ethtool_ops = { .get_eeprom_len = s2io_get_eeprom_len, .get_eeprom = s2io_ethtool_geeprom, .set_eeprom = s2io_ethtool_seeprom, - .get_ringparam = s2io_ethtool_gringparam, .get_pauseparam = s2io_ethtool_getpause_data, .set_pauseparam = s2io_ethtool_setpause_data, .get_rx_csum = s2io_ethtool_get_rx_csum, @@ -6160,7 +5962,7 @@ static void s2io_tasklet(unsigned long dev_addr) if (ret == -ENOMEM) { DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); - DBG_PRINT(INFO_DBG, "memory in tasklet\n"); + DBG_PRINT(ERR_DBG, "memory in tasklet\n"); break; } else if (ret == -EFILL) { DBG_PRINT(INFO_DBG, @@ -6275,14 +6077,9 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, *skb = dev_alloc_skb(size); if (!(*skb)) { DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); - DBG_PRINT(INFO_DBG, "memory to allocate "); - DBG_PRINT(INFO_DBG, "1 buf mode SKBs\n"); - sp->mac_control.stats_info->sw_stat. \ - mem_alloc_fail_cnt++; + DBG_PRINT(INFO_DBG, "memory to allocate SKBs\n"); return -ENOMEM ; } - sp->mac_control.stats_info->sw_stat.mem_allocated - += (*skb)->truesize; /* storing the mapped addr in a temp variable * such it will be used for next rxd whose * Host Control is NULL @@ -6302,15 +6099,10 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, } else { *skb = dev_alloc_skb(size); if (!(*skb)) { - DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); - DBG_PRINT(INFO_DBG, "memory to allocate "); - DBG_PRINT(INFO_DBG, "2 buf mode SKBs\n"); - sp->mac_control.stats_info->sw_stat. \ - mem_alloc_fail_cnt++; + DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", + dev->name); return -ENOMEM; } - sp->mac_control.stats_info->sw_stat.mem_allocated - += (*skb)->truesize; ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = pci_map_single(sp->pdev, (*skb)->data, dev->mtu + 4, @@ -6334,15 +6126,10 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, } else { *skb = dev_alloc_skb(size); if (!(*skb)) { - DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); - DBG_PRINT(INFO_DBG, "memory to allocate "); - DBG_PRINT(INFO_DBG, "3 buf mode SKBs\n"); - sp->mac_control.stats_info->sw_stat. \ - mem_alloc_fail_cnt++; + DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", + dev->name); return -ENOMEM; } - sp->mac_control.stats_info->sw_stat.mem_allocated - += (*skb)->truesize; ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, PCI_DMA_FROMDEVICE); @@ -6360,14 +6147,10 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, if (skb_shinfo(*skb)->frag_list == NULL) { DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \ failed\n ", dev->name); - sp->mac_control.stats_info->sw_stat. \ - mem_alloc_fail_cnt++; return -ENOMEM ; } frag_list = skb_shinfo(*skb)->frag_list; frag_list->next = NULL; - sp->mac_control.stats_info->sw_stat.mem_allocated - += frag_list->truesize; /* * Buffer-2 receives L4 data payload */ @@ -6783,7 +6566,6 @@ static void s2io_tx_watchdog(struct net_device *dev) struct s2io_nic *sp = dev->priv; if (netif_carrier_ok(dev)) { - sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt++; schedule_work(&sp->rst_timer_task); sp->mac_control.stats_info->sw_stat.soft_reset_cnt++; } @@ -6824,53 +6606,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) if (err & 0x1) { sp->mac_control.stats_info->sw_stat.parity_err_cnt++; } - err >>= 48; - switch(err) { - case 1: - sp->mac_control.stats_info->sw_stat. - rx_parity_err_cnt++; - break; - case 2: - sp->mac_control.stats_info->sw_stat. - rx_abort_cnt++; - break; - - case 3: - sp->mac_control.stats_info->sw_stat. - rx_parity_abort_cnt++; - break; - - case 4: - sp->mac_control.stats_info->sw_stat. - rx_rda_fail_cnt++; - break; - - case 5: - sp->mac_control.stats_info->sw_stat. - rx_unkn_prot_cnt++; - break; - - case 6: - sp->mac_control.stats_info->sw_stat. - rx_fcs_err_cnt++; - break; - - case 7: - sp->mac_control.stats_info->sw_stat. - rx_buf_size_err_cnt++; - break; - - case 8: - sp->mac_control.stats_info->sw_stat. - rx_rxd_corrupt_cnt++; - break; - - case 15: - sp->mac_control.stats_info->sw_stat. - rx_unkn_err_cnt++; - break; - } /* * Drop the packet if bad transfer code. Exception being * 0x5, which could be due to unsupported IPv6 extension header. @@ -6878,12 +6614,10 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) * Note that in this case, since checksum will be incorrect, * stack will validate the same. */ - if (err != 0x5) { + if (err && ((err >> 48) != 0x5)) { DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", dev->name, err); sp->stats.rx_crc_errors++; - sp->mac_control.stats_info->sw_stat.mem_freed - += skb->truesize; dev_kfree_skb(skb); atomic_dec(&sp->rx_bufs_left[ring_no]); rxdp->Host_Control = 0; @@ -6893,6 +6627,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) /* Updating statistics */ rxdp->Host_Control = 0; + sp->stats.rx_packets++; if (sp->rxd_mode == RXD_MODE_1) { int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); @@ -6996,7 +6731,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) } else { skb->ip_summed = CHECKSUM_NONE; } - sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; + if (!sp->lro) { skb->protocol = eth_type_trans(skb, dev); if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) && @@ -7045,21 +6780,12 @@ static void s2io_link(struct s2io_nic * sp, int link) if (link == LINK_DOWN) { DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); netif_carrier_off(dev); - if(sp->mac_control.stats_info->sw_stat.link_up_cnt) - sp->mac_control.stats_info->sw_stat.link_up_time = - jiffies - sp->start_time; - sp->mac_control.stats_info->sw_stat.link_down_cnt++; } else { DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); - if (sp->mac_control.stats_info->sw_stat.link_down_cnt) - sp->mac_control.stats_info->sw_stat.link_down_time = - jiffies - sp->start_time; - sp->mac_control.stats_info->sw_stat.link_up_cnt++; netif_carrier_on(dev); } } sp->last_link_state = link; - sp->start_time = jiffies; } /** diff --git a/trunk/drivers/net/s2io.h b/trunk/drivers/net/s2io.h index 54baa0b8ec7c..a656d18b33df 100644 --- a/trunk/drivers/net/s2io.h +++ b/trunk/drivers/net/s2io.h @@ -95,32 +95,6 @@ struct swStat { unsigned long long flush_max_pkts; unsigned long long sum_avg_pkts_aggregated; unsigned long long num_aggregations; - /* Other statistics */ - unsigned long long mem_alloc_fail_cnt; - unsigned long long watchdog_timer_cnt; - unsigned long long mem_allocated; - unsigned long long mem_freed; - unsigned long long link_up_cnt; - unsigned long long link_down_cnt; - unsigned long long link_up_time; - unsigned long long link_down_time; - - /* Transfer Code statistics */ - unsigned long long tx_buf_abort_cnt; - unsigned long long tx_desc_abort_cnt; - unsigned long long tx_parity_err_cnt; - unsigned long long tx_link_loss_cnt; - unsigned long long tx_list_proc_err_cnt; - - unsigned long long rx_parity_err_cnt; - unsigned long long rx_abort_cnt; - unsigned long long rx_parity_abort_cnt; - unsigned long long rx_rda_fail_cnt; - unsigned long long rx_unkn_prot_cnt; - unsigned long long rx_fcs_err_cnt; - unsigned long long rx_buf_size_err_cnt; - unsigned long long rx_rxd_corrupt_cnt; - unsigned long long rx_unkn_err_cnt; }; /* Xpak releated alarm and warnings */ @@ -334,11 +308,6 @@ struct stat_block { #define MAX_TX_FIFOS 8 #define MAX_RX_RINGS 8 -#define MAX_RX_DESC_1 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 127 ) -#define MAX_RX_DESC_2 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 ) -#define MAX_RX_DESC_3 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 ) -#define MAX_TX_DESC (MAX_AVAILABLE_TXDS) - /* FIFO mappings for all possible number of fifos configured */ static int fifo_map[][MAX_TX_FIFOS] = { {0, 0, 0, 0, 0, 0, 0, 0}, @@ -850,7 +819,6 @@ struct s2io_nic { #define LINK_UP 2 int task_flag; - unsigned long long start_time; #define CARD_DOWN 1 #define CARD_UP 2 atomic_t card_state; diff --git a/trunk/drivers/net/skge.c b/trunk/drivers/net/skge.c index 776692946562..e0489578945d 100644 --- a/trunk/drivers/net/skge.c +++ b/trunk/drivers/net/skge.c @@ -3802,9 +3802,6 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state) struct skge_hw *hw = pci_get_drvdata(pdev); int i, err, wol = 0; - if (!hw) - return 0; - err = pci_save_state(pdev); if (err) return err; @@ -3833,9 +3830,6 @@ static int skge_resume(struct pci_dev *pdev) struct skge_hw *hw = pci_get_drvdata(pdev); int i, err; - if (!hw) - return 0; - err = pci_set_power_state(pdev, PCI_D0); if (err) goto out; @@ -3874,9 +3868,6 @@ static void skge_shutdown(struct pci_dev *pdev) struct skge_hw *hw = pci_get_drvdata(pdev); int i, wol = 0; - if (!hw) - return; - for (i = 0; i < hw->ports; i++) { struct net_device *dev = hw->dev[i]; struct skge_port *skge = netdev_priv(dev); diff --git a/trunk/drivers/net/sky2.c b/trunk/drivers/net/sky2.c index 104e20456e6f..a307310f13f5 100644 --- a/trunk/drivers/net/sky2.c +++ b/trunk/drivers/net/sky2.c @@ -40,7 +40,6 @@ #include #include #include -#include #include @@ -131,7 +130,7 @@ static const struct pci_device_id sky2_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ -// { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ { 0 } }; @@ -151,8 +150,6 @@ static const char *yukon2_name[] = { "FE", /* 0xb7 */ }; -static int dmi_blacklisted; - /* Access to external PHY */ static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) { @@ -2534,17 +2531,6 @@ static int __devinit sky2_init(struct sky2_hw *hw) return -EOPNOTSUPP; } - - /* Some Gigabyte motherboards have 88e8056 but cause problems - * There is some unresolved hardware related problem that causes - * descriptor errors and receive data corruption. - */ - if (hw->chip_id == CHIP_ID_YUKON_EC_U && dmi_blacklisted) { - dev_err(&hw->pdev->dev, - "88E8056 on this motherboard not supported\n"); - return -EOPNOTSUPP; - } - hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); hw->ports = 1; t8 = sky2_read8(hw, B2_Y2_HW_RES); @@ -3592,6 +3578,17 @@ static int __devinit sky2_probe(struct pci_dev *pdev, goto err_out; } + /* Some Gigabyte motherboards have 88e8056 but cause problems + * There is some unresolved hardware related problem that causes + * descriptor errors and receive data corruption. + */ + if (pdev->vendor == PCI_VENDOR_ID_MARVELL && + pdev->device == 0x4364 && pdev->subsystem_vendor == 0x1458) { + dev_err(&pdev->dev, + "88E8056 on Gigabyte motherboards not supported\n"); + goto err_out_disable; + } + err = pci_request_regions(pdev, DRV_NAME); if (err) { dev_err(&pdev->dev, "cannot obtain PCI resources\n"); @@ -3735,7 +3732,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev, err_out_disable: pci_disable_device(pdev); err_out: - pci_set_drvdata(pdev, NULL); return err; } @@ -3788,9 +3784,6 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) struct sky2_hw *hw = pci_get_drvdata(pdev); int i, wol = 0; - if (!hw) - return 0; - del_timer_sync(&hw->idle_timer); netif_poll_disable(hw->dev[0]); @@ -3822,9 +3815,6 @@ static int sky2_resume(struct pci_dev *pdev) struct sky2_hw *hw = pci_get_drvdata(pdev); int i, err; - if (!hw) - return 0; - err = pci_set_power_state(pdev, PCI_D0); if (err) goto out; @@ -3871,9 +3861,6 @@ static void sky2_shutdown(struct pci_dev *pdev) struct sky2_hw *hw = pci_get_drvdata(pdev); int i, wol = 0; - if (!hw) - return; - del_timer_sync(&hw->idle_timer); netif_poll_disable(hw->dev[0]); @@ -3910,24 +3897,8 @@ static struct pci_driver sky2_driver = { .shutdown = sky2_shutdown, }; -static struct dmi_system_id __initdata broken_dmi_table[] = { - { - .ident = "Gigabyte 965P-S3", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Gigabyte Technology Co., Ltd."), - DMI_MATCH(DMI_PRODUCT_NAME, "965P-S3"), - - }, - }, - { } -}; - static int __init sky2_init_module(void) { - /* Look for sick motherboards */ - if (dmi_check_system(broken_dmi_table)) - dmi_blacklisted = 1; - return pci_register_driver(&sky2_driver); } diff --git a/trunk/drivers/net/spider_net.c b/trunk/drivers/net/spider_net.c index 108adbf5b5eb..c15e97253ede 100644 --- a/trunk/drivers/net/spider_net.c +++ b/trunk/drivers/net/spider_net.c @@ -175,10 +175,12 @@ spider_net_setup_aneg(struct spider_net_card *card) { struct mii_phy *phy = &card->phy; u32 advertise = 0; - u16 bmsr, estat; + u16 bmcr, bmsr, stat1000, estat; - bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); - estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); + bmcr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMCR); + bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); + stat1000 = spider_net_read_phy(card->netdev, phy->mii_id, MII_STAT1000); + estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); if (bmsr & BMSR_10HALF) advertise |= ADVERTISED_10baseT_Half; diff --git a/trunk/drivers/net/wan/Kconfig b/trunk/drivers/net/wan/Kconfig index 4fc8681bc110..8897f538a7c7 100644 --- a/trunk/drivers/net/wan/Kconfig +++ b/trunk/drivers/net/wan/Kconfig @@ -2,7 +2,10 @@ # wan devices configuration # -menuconfig WAN +menu "Wan interfaces" + depends on NETDEVICES + +config WAN bool "Wan interfaces support" ---help--- Wide Area Networks (WANs), such as X.25, Frame Relay and leased @@ -20,12 +23,10 @@ menuconfig WAN If unsure, say N. -if WAN - # There is no way to detect a comtrol sv11 - force it modular for now. config HOSTESS_SV11 tristate "Comtrol Hostess SV-11 support" - depends on ISA && m && ISA_DMA_API && INET + depends on WAN && ISA && m && ISA_DMA_API && INET help Driver for Comtrol Hostess SV-11 network card which operates on low speed synchronous serial links at up to @@ -37,7 +38,7 @@ config HOSTESS_SV11 # The COSA/SRP driver has not been tested as non-modular yet. config COSA tristate "COSA/SRP sync serial boards support" - depends on ISA && m && ISA_DMA_API + depends on WAN && ISA && m && ISA_DMA_API ---help--- Driver for COSA and SRP synchronous serial boards. @@ -61,7 +62,7 @@ config COSA # config LANMEDIA tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" - depends on PCI + depends on WAN && PCI ---help--- Driver for the following Lan Media family of serial boards: @@ -88,7 +89,7 @@ config LANMEDIA # There is no way to detect a Sealevel board. Force it modular config SEALEVEL_4021 tristate "Sealevel Systems 4021 support" - depends on ISA && m && ISA_DMA_API && INET + depends on WAN && ISA && m && ISA_DMA_API && INET help This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. @@ -98,6 +99,7 @@ config SEALEVEL_4021 # Generic HDLC config HDLC tristate "Generic HDLC layer" + depends on WAN help Say Y to this option if your Linux box contains a WAN (Wide Area Network) card supported by this driver and you are planning to @@ -165,7 +167,7 @@ config HDLC_X25 If unsure, say N. comment "X.25/LAPB support is disabled" - depends on HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y + depends on WAN && HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y config PCI200SYN tristate "Goramo PCI200SYN support" @@ -228,10 +230,10 @@ config PC300_MLPPP Multilink PPP over the PC300 synchronous communication boards. comment "Cyclades-PC300 MLPPP support is disabled." - depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) + depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) comment "Refer to the file README.mlppp, provided by PC300 package." - depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) + depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) config PC300TOO tristate "Cyclades PC300 RSV/X21 alternative support" @@ -336,6 +338,7 @@ config DSCC4_PCI_RST config DLCI tristate "Frame Relay DLCI support" + depends on WAN ---help--- Support for the Frame Relay protocol. @@ -382,7 +385,7 @@ config SDLA # Wan router core. config WAN_ROUTER_DRIVERS tristate "WAN router drivers" - depends on WAN_ROUTER + depends on WAN && WAN_ROUTER ---help--- Connect LAN to WAN via Linux box. @@ -437,7 +440,7 @@ config CYCLOMX_X25 # X.25 network drivers config LAPBETHER tristate "LAPB over Ethernet driver (EXPERIMENTAL)" - depends on LAPB && X25 + depends on WAN && LAPB && X25 ---help--- Driver for a pseudo device (typically called /dev/lapb0) which allows you to open an LAPB point-to-point connection to some other computer @@ -453,7 +456,7 @@ config LAPBETHER config X25_ASY tristate "X.25 async driver (EXPERIMENTAL)" - depends on LAPB && X25 + depends on WAN && LAPB && X25 ---help--- Send and receive X.25 frames over regular asynchronous serial lines such as telephone lines equipped with ordinary modems. @@ -468,7 +471,7 @@ config X25_ASY config SBNI tristate "Granch SBNI12 Leased Line adapter support" - depends on X86 + depends on WAN && X86 ---help--- Driver for ISA SBNI12-xx cards which are low cost alternatives to leased line modems. @@ -494,4 +497,5 @@ config SBNI_MULTILINE If unsure, say N. -endif # WAN +endmenu + diff --git a/trunk/drivers/net/wireless/libertas/Makefile b/trunk/drivers/net/wireless/libertas/Makefile index 56a8ea1fbf04..19c935071d8e 100644 --- a/trunk/drivers/net/wireless/libertas/Makefile +++ b/trunk/drivers/net/wireless/libertas/Makefile @@ -1,3 +1,5 @@ +# EXTRA_CFLAGS += -Wpacked + usb8xxx-objs := main.o fw.o wext.o \ rx.o tx.o cmd.o \ cmdresp.o scan.o \ @@ -5,6 +7,13 @@ usb8xxx-objs := main.o fw.o wext.o \ ioctl.o debugfs.o \ ethtool.o assoc.o +ifeq ($(CONFIG_LIBERTAS_USB_DEBUG), y) +EXTRA_CFLAGS += -DDEBUG -DPROC_DEBUG +endif + + +# This is needed to support the newer boot2 bootloader (v >= 3104) +EXTRA_CFLAGS += -DSUPPORT_BOOT_COMMAND usb8xxx-objs += if_bootcmd.o usb8xxx-objs += if_usb.o diff --git a/trunk/drivers/net/wireless/libertas/README b/trunk/drivers/net/wireless/libertas/README index 378577200b56..688da4c784b1 100644 --- a/trunk/drivers/net/wireless/libertas/README +++ b/trunk/drivers/net/wireless/libertas/README @@ -40,11 +40,64 @@ NAME SYNOPSIS iwpriv [sub-command] ... + iwpriv ethX version + iwpriv ethX scantype [sub-command] + iwpriv ethX getSNR + iwpriv ethX getNF + iwpriv ethX getRSSI + iwpriv ethX setrxant + iwpriv ethX getrxant + iwpriv ethX settxant + iwpriv ethX gettxant + iwpriv ethX authalgs + iwpriv ethX pre-TBTT + iwpriv ethX 8021xauthalgs + iwpriv ethX encryptionmode iwpriv ethX setregioncode iwpriv ethX getregioncode + iwpriv ethX setbcnavg + iwpriv ethX getbcnavg + iwpriv ethX setdataavg + iwpriv ethX setlisteninter + iwpriv ethX getlisteninter + iwpriv ethX setmultipledtim + iwpriv ethX getmultipledtim + iwpriv ethX atimwindow + iwpriv ethX deauth + iwpriv ethX adhocstop + iwpriv ethX radioon + iwpriv ethX radiooff + iwpriv ethX reasso-on + iwpriv ethX reasso-off + iwpriv ethX scanmode [sub-command] + iwpriv ethX setwpaie + iwpriv ethX wlanidle-off + iwpriv ethX wlanidle-on + iwpriv ethX getcis + iwpriv ethX getlog + iwpriv ethX getadhocstatus + iwpriv ethX adhocgrate + +Version 4 Command: + iwpriv ethX inactvityto + iwpriv ethX sleeppd + iwpriv ethX enable11d + iwpriv ethX tpccfg + iwpriv ethX powercfg + iwpriv ethX setafc + iwpriv ethX getafc Version 5 Command: iwpriv ethX ledgpio + iwpriv ethX scanprobes + iwpriv ethX lolisteninter + iwpriv ethX rateadapt + iwpriv ethX txcontrol + iwpriv ethX psnullinterval + iwpriv ethX prescan + iwpriv ethX getrxinfo + iwpriv ethX gettxrate + iwpriv ethX beaconinterval BT Commands: The blinding table (BT) contains a list of mac addresses that should be @@ -97,6 +150,114 @@ DESCRIPTION The ethX parameter specifies the network device that is to be used to perform this command on. it could be eth0, eth1 etc. +version + This is used to get the current version of the driver and the firmware. + +scantype + This command is used to set the scan type to be used by the driver in + the scan command. This setting will not be used while performing a scan + for a specific SSID, as it is always done with scan type being active. + + where the sub-commands are: - + active -- to set the scan type to active + passive -- to set the scan type to passive + get -- to get the scan type set in the driver + +getSNR + This command gets the average and non average value of Signal to Noise + Ratio of Beacon and Data. + + where value is:- + 0 -- Beacon non-average. + 1 -- Beacon average. + 2 -- Data non-average. + 3 -- Data average. + + If no value is given, all four values are returned in the order mentioned + above. + + Note: This command is available only when STA is connected. + +getRSSI + This command gets the average and non average value os Receive Signal + Strength of Beacon and Data. + + where value is:- + 0 -- Beacon non-average. + 1 -- Beacon average. + 2 -- Data non-average. + 3 -- Data average. + + Note: This command is available only when STA is connected. + +getNF + This command gets the average and non average value of Noise Floor of + Beacon and Data. + + where value is:- + 0 -- Beacon non-average. + 1 -- Beacon average. + 2 -- Data non-average. + 3 -- Data average. + + Note: This command is available only when STA is connected. + +setrxant + This command is used to set the mode for Rx antenna. + + The options that can be sent are:- + 1 -- Antenna 1. + 2 -- Antenna 2. + 0xFFFF -- Diversity. + + Usage: + iwpriv ethX setrxant 0x01: select Antenna 1. + +getrxant + This command is used to get the mode for Rx antenna. + + +settxant + This command is used to set the mode for Tx antenna. + The options that can be sent are:- + 1 -- Antenna 1. + 2 -- Antenna 2. + 0xFFFF -- Diversity. + Usage: + iwpriv ethX settxant 0x01: select Antenna 1. + +gettxant + This command is used to get the mode for Tx antenna. + +authalgs + This command is used by the WPA supplicant to set the authentication + algorithms in the station. + +8021xauthalgs + This command is used by the WPA supplicant to set the 8021.x authentication algorithm type + station. + + where values can be:- + 1 -- None + 2 -- LEAP + 4 -- TLS + 8 -- TTLs + 16 -- MD5 + + +encryptionmode + This command is used by the WPA supplicant to set the encryption algorithm. + + where values can be:- + 0 -- NONE + 1 -- WEP40 + 2 -- TKIP + 3 -- CCMP + 4 -- WEP104 + +pre-TBTT + This command is used to set pre-TBTT time period where value is in microseconds. + setregioncode This command is used to set the region code in the station. where value is 'region code' for various regions like @@ -109,6 +270,114 @@ getregioncode This command is used to get the region code information set in the station. +setbcnavg + Set the weighting factor for calculating RSSI. + +getbcnavg + Get weighting factor for calculating RSSI. + +setdataavg + Set the weighting factor for calculating SNR. + +setlisteninter + This command is used to set the listen interval in the + station. + + where the value ranges between 1 - 255 + +getlisteninter + This command is used to get the listen interval value set in the + station. + +setmultipledtim + This command is used to set the multiple dtim value in the + station. + where the value is 1,2,3,4,5,0xfffe + 0xfffe means the firmware will use listen interval in association + command for waking up + +getmultipledtim + This command is used to get the multiple dtim value set in the station. + +atimwindow + This command is used to set the atim value in the + station. + + where the value ranges between 0 - 50 + +deauth + This command is used to send the de-authentication to the AP with which + the station is associated. This command is valid only when + station is in Infrastructure mode. + + Note: This command is available only when STA is connected. + +adhocstop + This command is used to stop beacon transmission from the station and + go into idle state in ad-hoc mode. + + Note: This command is available only when STA is connected. + +radioon + This command is used to turn on the RF antenna. + +radiooff + This command is sued to turn off the RF antenna. + +scanmode + This command is used to set the station to scan for either IBSS + networks or BSS networks or both BSS and IBSS networks. This + command can be used with sub commands, + + where the value for + bss -- Scan All the BSS networks. + ibss -- Scan All the IBSS networks. + any -- Scan both BSS and IBSS networks. + + + +setwpaie + This command is used by WPA supplicant to send the WPA-IE to the driver. + +wlanidle-off + This command is used to get into idle state. + + Note: This command is available only when STA is connected. + +wlanidle-on + This command is used to get off the idle state. + + Note: This command is available only when STA is connected. + + +getlog + This command is used to get the 802.11 statistics available in the + station. + + Note: This command is available only when STA is connected. + +getadhocstatus + This command is used to get the ad-hoc Network Status. + + The various status codes are: + AdhocStarted + AdhocJoined + AdhocIdle + InfraMode + AutoUnknownMode + + Note: This command is available only when STA is connected. + +adhocgrate + This command is used to enable(1) g_rate, Disable(0) g_rate + and request(2) the status which g_rate is disabled/enabled, + for Ad-hoc creator. + + where value is:- + 0 -- Disabled + 1 -- Enabled + 2 -- Get + ledgpio This command is used to set/get LEDs. @@ -131,6 +400,253 @@ ledgpio Note: LED0 is invalid Note: Maximum Number of LEDs are 16. +inactivityto + This command is used by the host to set/get the inactivity timeout value, + which specifies when WLAN device is put to sleep. + + Usage: + iwpriv ethX inactivityto [] + + where the parameter are: + timeout: timeout value in milliseconds. + + Example: + iwpriv eth1 inactivityto + "get the timeout value" + + iwpriv eth1 inactivityto X + "set timeout value to X ms" + + +sleeppd + This command is used to configure the sleep period of the WLAN device. + + Usage: + iwpriv ethX sleeppd [] + + where the parameter are: + Period: sleep period in milliseconds. Range 10~60. + + Example: + iwpriv eth1 sleeppd 10 + "set period as 10 ms" + iwpriv eth1 sleeppd + "get the sleep period configuration" + +enable11d + This command is used to control 11d + where value is:- + 1 -- Enabled + 0 -- Disabled + 2 -- Get + + + + +tpccfg + Enables or disables automatic transmit power control. + + The first parameter turns this feature on (1) or off (0). When turning + on, the user must also supply four more parameters in the following + order: + -UseSNR (Use SNR (in addition to PER) for TPC algorithm), + -P0 (P0 power level for TPC), + -P1 (P1 power level for TPC), + -P2 (P2 power level for TPC). + + Usage: + iwpriv ethX tpccfg: Get current configuration + iwpriv ethX tpccfg 0: disable auto TPC + iwpriv ethX tpccfg 0x01 0x00 0x05 0x0a 0x0d: enable auto TPC; do not use SNR; + P0=0x05; P1=0x0a; P2=0x0d; + iwpriv ethX tpccfg 0x01 0x01 0x05 0x0a 0x0d: enable auto TPC; use SNR; + P0=0x05; P1=0x0a; P2=0x0d. + +powercfg + Enables or disables power adaptation. + + The first parameter turns this feature on (1) or off (0). When turning + on, the user must also supply three more parameters in the following + order: + -P0 (P0 power level for Power Adaptation), + -P1 (P1 power level for Power Adaptation), + -P2 (P2 power level for Power Adaptation). + + Usage: + iwpriv ethX powercfg: Get current configuration + iwpriv ethX powercfg 0: disable power adaptation + iwpriv ethX powercfg 1 0x0d 0x0f 0x12: enable power adaptation; + P0=0x0d; P1=0x0f; P2=0x12. + +getafc + This command returns automatic frequency control parameters. It returns + three integers: + -P0: automatic is on (1), or off (0), + -P1: current timing offset in PPM (part per million), and + -P2: current frequency offset in PPM. + +setafc + Set automatic frequency control options. + + The first parameter turns automatic on (1) or off (0). + The user must supply two more parameters in either case, in the following + order: + + When auto is on: + + -P0 (automatic adjustment frequency threshold in PPM), + -P1 (automatic adjustment period in beacon period), + + When auto is off: + + -P0 (manual adjustment timing offset in PPM), and + -P1 (manual adjustment frequency offset in PPM). + + Usage: + iwpriv ethX setafc 0 10 10: manual adjustment, both timing and frequcncy + offset are 10 PPM. + + iwpriv ethX setafc 1 10 10 enable afc, automatic adjustment, + frequency threshold 10 PPM, for every 10 beacon periods. + + + +scanprobes + This command sets number of probe requests per channel. + + Usage: + iwpriv ethX scanprobes 3 (set scan probes to 3) + iwpriv ethX scanprobes (get scan probes) + +lolisteninter + This command sets the value of listen interval. + + Usage: + iwpriv ethX lolisteninter 234 (set the lolisteninter to 234) + iwpriv ethX lolisteninter (get the lolisteninter value) + +rateadapt + This command sets the data rates bitmap. + Where + 0: Disable auto rate adapt + 1: Enable auto rate adapt + + + data rate bitmap + Bit Data rate + 0 1 Mbps + 1 2 Mbps + 2 5.5 Mbps + 3 11 Mbps + 4 Reserved + 5 6 Mbps + 6 9 Mbps + 7 12 Mbps + 8 18 Mbps + 9 24 Mbps + 10 36 Mbps + 11 48 Mbps + 12 54 Mbps + 12-15 Reserved + + Usage: + iwpriv ethX rateadapt + read the currect data rate setting + iwpriv ethX rateadapt 1 0x07 + enable auto data rate adapt and + data rates are 1Mbps, 2Mbsp and 5.5Mbps + + +txcontrol + This command is used to set the Tx rate, ack policy, and retry limit on a per packet basis. + + Where value is: + if bit[4] == 1: + bit[3:0] -- 0 1 2 3 4 5 6 7 8 9 10 11 12 13-16 + Data Rate(Mbps) -- 1 2 5.5 11 Rsv 6 9 12 18 24 36 48 54 Rsv + + bit[12:8] + if bit[12] == 1, bit[11:8] specifies the Tx retry limit. + + bit[14:13] specifies per packet ack policy: + bit[14:13] + 1 0 use immediate ack policy for this packet + 1 1 use no ack policy for this packet + 0 x use the per-packet ack policy setting + + Usage: + iwpriv ethX txcontrol 0x7513 + Use no-ack policy, 5 retires for Tx, 11Mbps rate + + + +psnullinterval + This command is used to set/request NULL package interval for Power Save + under infrastructure mode. + + where value is:- + -1 -- Disabled + n>0 -- Set interval as n (seconds) + +prescan + This command is used to enable (1)/disable(0) auto prescan before assoicate to the ap + + where value is:- + 0 -- Disabled + 1 -- Enabled + 2 -- Get + +getrxinfo + This command gets non average value of Signal to Noise Ratio of Data and rate index. + + The following table shows RateIndex and Rate + + RateIndex Data rate + 0 1 Mbps + 1 2 Mbps + 2 5.5 Mbps + 3 11 Mbps + 4 Reserved + 5 6 Mbps + 6 9 Mbps + 7 12 Mbps + 8 18 Mbps + 9 24 Mbps + 10 36 Mbps + 11 48 Mbps + 12 54 Mbps + 13-15 Reserved + +gettxrate + This command gets current Tx rate index of the first packet associated with Rate Adaptation. + + The following table shows RateIndex and Rate + + RateIndex Data rate + 0 1 Mbps + 1 2 Mbps + 2 5.5 Mbps + 3 11 Mbps + 4 Reserved + 5 6 Mbps + 6 9 Mbps + 7 12 Mbps + 8 18 Mbps + 9 24 Mbps + 10 36 Mbps + 11 48 Mbps + 12 54 Mbps + 13-15 Reserved + +bcninterval + This command is used to sets beacon interval in adhoc mode when an argument is given, and gets current adhoc + beacon interval when no argument is given. The valid beacon interval is between 20 - 1000, + default beacon interval is 100. + + Usage: + iwpriv ethX bcninterval 100 (set adhoc beacon interval to 100) + iwpriv ethX bcninterval (get adhoc beacon interval) + fwt_add This command is used to insert an entry into the FWT table. The list of parameters must follow the following structure: diff --git a/trunk/drivers/net/wireless/libertas/assoc.c b/trunk/drivers/net/wireless/libertas/assoc.c index c260bd1b3d46..b55c7f57aca8 100644 --- a/trunk/drivers/net/wireless/libertas/assoc.c +++ b/trunk/drivers/net/wireless/libertas/assoc.c @@ -23,13 +23,13 @@ static int assoc_helper_essid(wlan_private *priv, ENTER(); lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); - if (assoc_req->mode == IW_MODE_INFRA) { + if (assoc_req->mode == wlan802_11infrastructure) { if (adapter->prescan) { libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); } i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, - NULL, IW_MODE_INFRA); + NULL, wlan802_11infrastructure); if (i >= 0) { lbs_pr_debug(1, "SSID found in scan list ... associating...\n"); @@ -44,7 +44,7 @@ static int assoc_helper_essid(wlan_private *priv, lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", assoc_req->ssid.ssid); } - } else if (assoc_req->mode == IW_MODE_ADHOC) { + } else if (assoc_req->mode == wlan802_11ibss) { /* Scan for the network, do not save previous results. Stale * scan data will cause us to join a non-existant adhoc network */ @@ -52,7 +52,7 @@ static int assoc_helper_essid(wlan_private *priv, /* Search for the requested SSID in the scan table */ i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, - IW_MODE_ADHOC); + wlan802_11ibss); if (i >= 0) { lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); libertas_join_adhoc_network(priv, &adapter->scantable[i]); @@ -90,10 +90,10 @@ static int assoc_helper_bssid(wlan_private *priv, goto out; } - if (assoc_req->mode == IW_MODE_INFRA) { + if (assoc_req->mode == wlan802_11infrastructure) { ret = wlan_associate(priv, &adapter->scantable[i]); lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); - } else if (assoc_req->mode == IW_MODE_ADHOC) { + } else if (assoc_req->mode == wlan802_11ibss) { libertas_join_adhoc_network(priv, &adapter->scantable[i]); } memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, @@ -142,23 +142,23 @@ static int assoc_helper_mode(wlan_private *priv, ENTER(); - if (assoc_req->mode == adapter->mode) { + if (assoc_req->mode == adapter->inframode) { LEAVE(); return 0; } - if (assoc_req->mode == IW_MODE_INFRA) { + if (assoc_req->mode == wlan802_11infrastructure) { if (adapter->psstate != PS_STATE_FULL_POWER) libertas_ps_wakeup(priv, cmd_option_waitforrsp); adapter->psmode = wlan802_11powermodecam; } - adapter->mode = assoc_req->mode; + adapter->inframode = assoc_req->mode; ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib, 0, cmd_option_waitforrsp, OID_802_11_INFRASTRUCTURE_MODE, - (void *) (size_t) assoc_req->mode); + (void *) assoc_req->mode); LEAVE(); return ret; @@ -196,7 +196,7 @@ static int assoc_helper_wep_keys(wlan_private *priv, goto out; /* enable/disable the MAC's WEP packet filter */ - if (assoc_req->secinfo.wep_enabled) + if (assoc_req->secinfo.WEPstatus == wlan802_11WEPenabled) adapter->currentpacketfilter |= cmd_act_mac_wep_enable; else adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable; @@ -300,7 +300,8 @@ static int should_deauth_infrastructure(wlan_adapter *adapter, } if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { - if (adapter->secinfo.auth_mode != assoc_req->secinfo.auth_mode) { + if (adapter->secinfo.authmode != + assoc_req->secinfo.authmode) { lbs_pr_debug(1, "Deauthenticating due to updated security " "info in configuration request.\n"); return 1; @@ -315,7 +316,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter, /* FIXME: deal with 'auto' mode somehow */ if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { - if (assoc_req->mode != IW_MODE_INFRA) + if (assoc_req->mode != wlan802_11infrastructure) return 1; } @@ -332,12 +333,12 @@ static int should_stop_adhoc(wlan_adapter *adapter, if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) return 1; if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, - adapter->curbssparams.ssid.ssidlength)) + sizeof(struct WLAN_802_11_SSID))) return 1; /* FIXME: deal with 'auto' mode somehow */ if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { - if (assoc_req->mode != IW_MODE_ADHOC) + if (assoc_req->mode != wlan802_11ibss) return 1; } @@ -381,7 +382,7 @@ void wlan_association_worker(struct work_struct *work) } if (find_any_ssid) { - u8 new_mode; + enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, assoc_req->mode, &new_mode); @@ -392,7 +393,7 @@ void wlan_association_worker(struct work_struct *work) } /* Ensure we switch to the mode of the AP */ - if (assoc_req->mode == IW_MODE_AUTO) { + if (assoc_req->mode == wlan802_11autounknown) { set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); assoc_req->mode = new_mode; } @@ -402,7 +403,7 @@ void wlan_association_worker(struct work_struct *work) * Check if the attributes being changing require deauthentication * from the currently associated infrastructure access point. */ - if (adapter->mode == IW_MODE_INFRA) { + if (adapter->inframode == wlan802_11infrastructure) { if (should_deauth_infrastructure(adapter, assoc_req)) { ret = libertas_send_deauthentication(priv); if (ret) { @@ -411,7 +412,7 @@ void wlan_association_worker(struct work_struct *work) ret); } } - } else if (adapter->mode == IW_MODE_ADHOC) { + } else if (adapter->inframode == wlan802_11ibss) { if (should_stop_adhoc(adapter, assoc_req)) { ret = libertas_stop_adhoc_network(priv); if (ret) { @@ -542,7 +543,7 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter) assoc_req->channel = adapter->curbssparams.channel; if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) - assoc_req->mode = adapter->mode; + assoc_req->mode = adapter->inframode; if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, diff --git a/trunk/drivers/net/wireless/libertas/cmd.c b/trunk/drivers/net/wireless/libertas/cmd.c index de9cb46a70ff..bfdac58b5c06 100644 --- a/trunk/drivers/net/wireless/libertas/cmd.c +++ b/trunk/drivers/net/wireless/libertas/cmd.c @@ -381,16 +381,15 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv, switch (cmd_oid) { case OID_802_11_INFRASTRUCTURE_MODE: { - u8 mode = (u8) (size_t) pdata_buf; + enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode = + (enum WLAN_802_11_NETWORK_INFRASTRUCTURE) pdata_buf; pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i); pSNMPMIB->bufsize = sizeof(u8); - if (mode == IW_MODE_ADHOC) { - ucTemp = SNMP_MIB_VALUE_ADHOC; - } else { - /* Infra and Auto modes */ + if (mode == wlan802_11infrastructure) ucTemp = SNMP_MIB_VALUE_INFRA; - } + else + ucTemp = SNMP_MIB_VALUE_ADHOC; memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); @@ -948,8 +947,8 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u spin_unlock_irqrestore(&adapter->driver_lock, flags); - lbs_pr_debug(1, "QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n", - cmdnode, + lbs_pr_debug(1, "QUEUE_CMD: Inserted node=0x%x, cmd=0x%x in cmdpendingq\n", + (u32) cmdnode, ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); done: @@ -977,8 +976,8 @@ static int DownloadcommandToStation(wlan_private * priv, ENTER(); if (!adapter || !cmdnode) { - lbs_pr_debug(1, "DNLD_CMD: adapter = %p, cmdnode = %p\n", - adapter, cmdnode); + lbs_pr_debug(1, "DNLD_CMD: adapter = %#x, cmdnode = %#x\n", + (int)adapter, (int)cmdnode); if (cmdnode) { spin_lock_irqsave(&adapter->driver_lock, flags); __libertas_cleanup_and_insert_cmd(priv, cmdnode); @@ -1175,8 +1174,8 @@ int libertas_prepare_and_send_command(wlan_private * priv, cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; - lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr=%p, command=0x%X\n", - cmdptr, cmd_no); + lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr =0x%x, command=0x%X\n", + (u32) cmdptr, cmd_no); if (!cmdptr) { lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); diff --git a/trunk/drivers/net/wireless/libertas/cmdresp.c b/trunk/drivers/net/wireless/libertas/cmdresp.c index c86454034b58..cdb012c7e9cf 100644 --- a/trunk/drivers/net/wireless/libertas/cmdresp.c +++ b/trunk/drivers/net/wireless/libertas/cmdresp.c @@ -72,6 +72,8 @@ void libertas_mac_event_disconnected(wlan_private * priv) adapter->secinfo.WPAenabled = 0; adapter->secinfo.WPA2enabled = 0; adapter->wpa_ie_len = 0; + adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE; + adapter->secinfo.Encryptionmode = CIPHER_NONE; adapter->connect_status = libertas_disconnected; @@ -809,7 +811,7 @@ int libertas_process_rx_command(wlan_private * priv) if (result) { lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", resp->result); - if (adapter->mode == IW_MODE_ADHOC) { + if (adapter->inframode == wlan802_11ibss) { /* * We should not re-try enter-ps command in * ad-hoc mode. It takes place in diff --git a/trunk/drivers/net/wireless/libertas/debugfs.c b/trunk/drivers/net/wireless/libertas/debugfs.c index 7d7bc5e86a56..51dfd202f558 100644 --- a/trunk/drivers/net/wireless/libertas/debugfs.c +++ b/trunk/drivers/net/wireless/libertas/debugfs.c @@ -7,7 +7,6 @@ #include "dev.h" #include "decl.h" #include "host.h" -#include "debugfs.h" static struct dentry *libertas_dir = NULL; static char *szStates[] = { @@ -277,7 +276,7 @@ static void libertas_parse_ssid(char *buf, size_t count, if (!end) end = buf + count - 1; - size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold)); + size = min(IW_ESSID_MAX_SIZE, end - hold); strncpy(scan_cfg->specificSSID, hold, size); return; @@ -1649,7 +1648,7 @@ struct libertas_debugfs_files { struct file_operations fops; }; -static struct libertas_debugfs_files debugfs_files[] = { +struct libertas_debugfs_files debugfs_files[] = { { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), }, { "getscantable", 0444, FOPS(libertas_getscantable, write_file_dummy), }, @@ -1659,7 +1658,7 @@ static struct libertas_debugfs_files debugfs_files[] = { { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), }, }; -static struct libertas_debugfs_files debugfs_events_files[] = { +struct libertas_debugfs_files debugfs_events_files[] = { {"low_rssi", 0644, FOPS(libertas_lowrssi_read, libertas_lowrssi_write), }, {"low_snr", 0644, FOPS(libertas_lowsnr_read, @@ -1674,7 +1673,7 @@ static struct libertas_debugfs_files debugfs_events_files[] = { libertas_highsnr_write), }, }; -static struct libertas_debugfs_files debugfs_regs_files[] = { +struct libertas_debugfs_files debugfs_regs_files[] = { {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), }, {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), }, {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), }, @@ -1779,7 +1778,7 @@ void libertas_debugfs_remove_one(wlan_private *priv) struct debug_data { char name[32]; u32 size; - size_t addr; + u32 addr; }; /* To debug any member of wlan_adapter, simply add one line here. @@ -1826,8 +1825,6 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf, val = *((u16 *) d[i].addr); else if (d[i].size == 4) val = *((u32 *) d[i].addr); - else if (d[i].size == 8) - val = *((u64 *) d[i].addr); pos += sprintf(p + pos, "%s=%d\n", d[i].name, val); } @@ -1847,7 +1844,7 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf, * @param data data to write * @return number of data */ -static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf, +static int wlan_debugfs_write(struct file *f, const char __user *buf, size_t cnt, loff_t *ppos) { int r, i; @@ -1889,14 +1886,12 @@ static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf, *((u16 *) d[i].addr) = (u16) r; else if (d[i].size == 4) *((u32 *) d[i].addr) = (u32) r; - else if (d[i].size == 8) - *((u64 *) d[i].addr) = (u64) r; break; } while (1); } kfree(pdata); - return (ssize_t)cnt; + return cnt; } static struct file_operations libertas_debug_fops = { @@ -1921,10 +1916,20 @@ void libertas_debug_init(wlan_private * priv, struct net_device *dev) return; for (i = 0; i < num_of_items; i++) - items[i].addr += (size_t) priv->adapter; + items[i].addr += (u32) priv->adapter; priv->debugfs_debug = debugfs_create_file("debug", 0644, priv->debugfs_dir, &items[0], &libertas_debug_fops); } +/** + * @brief remove proc file + * + * @param priv pointer wlan_private + * @return N/A + */ +void libertas_debug_remove(wlan_private * priv) +{ + debugfs_remove(priv->debugfs_debug); +} diff --git a/trunk/drivers/net/wireless/libertas/defs.h b/trunk/drivers/net/wireless/libertas/defs.h index 80dd9ea19c8e..fb1478c1b87d 100644 --- a/trunk/drivers/net/wireless/libertas/defs.h +++ b/trunk/drivers/net/wireless/libertas/defs.h @@ -9,11 +9,6 @@ extern unsigned int libertas_debug; -#ifdef CONFIG_LIBERTAS_DEBUG -#define DEBUG -#define PROC_DEBUG -#endif - #define DRV_NAME "usb8xxx" #define lbs_pr_info(format, args...) \ @@ -228,6 +223,31 @@ enum SNRNF_DATA { MAX_TYPE_AVG }; +/** WLAN_802_11_AUTH_ALG*/ +enum WLAN_802_11_AUTH_ALG { + AUTH_ALG_OPEN_SYSTEM = 1, + AUTH_ALG_SHARED_KEY = 2, + AUTH_ALG_NETWORK_EAP = 8, +}; + +/** WLAN_802_1X_AUTH_ALG */ +enum WLAN_802_1X_AUTH_ALG { + WLAN_1X_AUTH_ALG_NONE = 1, + WLAN_1X_AUTH_ALG_LEAP = 2, + WLAN_1X_AUTH_ALG_TLS = 4, + WLAN_1X_AUTH_ALG_TTLS = 8, + WLAN_1X_AUTH_ALG_MD5 = 16, +}; + +/** WLAN_802_11_ENCRYPTION_MODE */ +enum WLAN_802_11_ENCRYPTION_MODE { + CIPHER_NONE, + CIPHER_WEP40, + CIPHER_TKIP, + CIPHER_CCMP, + CIPHER_WEP104, +}; + /** WLAN_802_11_POWER_MODE */ enum WLAN_802_11_POWER_MODE { wlan802_11powermodecam, @@ -272,6 +292,28 @@ enum mv_ms_type { MVMS_EVENT }; +/** WLAN_802_11_NETWORK_INFRASTRUCTURE */ +enum WLAN_802_11_NETWORK_INFRASTRUCTURE { + wlan802_11ibss, + wlan802_11infrastructure, + wlan802_11autounknown, + /*defined as upper bound */ + wlan802_11infrastructuremax +}; + +/** WLAN_802_11_AUTHENTICATION_MODE */ +enum WLAN_802_11_AUTHENTICATION_MODE { + wlan802_11authmodeopen = 0x00, + wlan802_11authmodeshared = 0x01, + wlan802_11authmodenetworkEAP = 0x80, +}; + +/** WLAN_802_11_WEP_STATUS */ +enum WLAN_802_11_WEP_STATUS { + wlan802_11WEPenabled, + wlan802_11WEPdisabled, +}; + /** SNMP_MIB_INDEX_e */ enum SNMP_MIB_INDEX_e { desired_bsstype_i = 0, diff --git a/trunk/drivers/net/wireless/libertas/dev.h b/trunk/drivers/net/wireless/libertas/dev.h index e8b9020f9bd6..b1f876f9693b 100644 --- a/trunk/drivers/net/wireless/libertas/dev.h +++ b/trunk/drivers/net/wireless/libertas/dev.h @@ -10,7 +10,6 @@ #include #include #include -#include #include "defs.h" #include "scan.h" @@ -57,8 +56,10 @@ struct region_channel { struct wlan_802_11_security { u8 WPAenabled; u8 WPA2enabled; - u8 wep_enabled; - u8 auth_mode; + enum WLAN_802_11_WEP_STATUS WEPstatus; + enum WLAN_802_11_AUTHENTICATION_MODE authmode; + enum WLAN_802_1X_AUTH_ALG auth1xalg; + enum WLAN_802_11_ENCRYPTION_MODE Encryptionmode; }; /** Current Basic Service Set State Structure */ @@ -183,7 +184,7 @@ struct assoc_request { struct WLAN_802_11_SSID ssid; u8 channel; - u8 mode; + enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode; u8 bssid[ETH_ALEN]; /** WEP keys */ @@ -197,6 +198,7 @@ struct assoc_request { struct wlan_802_11_security secinfo; /** WPA Information Elements*/ +#define MAX_WPA_IE_LEN 64 u8 wpa_ie[MAX_WPA_IE_LEN]; u8 wpa_ie_len; }; @@ -252,8 +254,7 @@ struct _wlan_adapter { /** current ssid/bssid related parameters*/ struct current_bss_params curbssparams; - /* IW_MODE_* */ - u8 mode; + enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; struct bss_descriptor *pattemptedbssdesc; @@ -338,6 +339,7 @@ struct _wlan_adapter { struct WLAN_802_11_KEY wpa_unicast_key; /** WPA Information Elements*/ +#define MAX_WPA_IE_LEN 64 u8 wpa_ie[MAX_WPA_IE_LEN]; u8 wpa_ie_len; diff --git a/trunk/drivers/net/wireless/libertas/fw.c b/trunk/drivers/net/wireless/libertas/fw.c index 441123c85e62..b194a4570791 100644 --- a/trunk/drivers/net/wireless/libertas/fw.c +++ b/trunk/drivers/net/wireless/libertas/fw.c @@ -194,13 +194,16 @@ static void wlan_init_adapter(wlan_private * priv) adapter->scanmode = cmd_bss_type_any; /* 802.11 specific */ - adapter->secinfo.wep_enabled = 0; + adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); i++) memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); adapter->wep_tx_keyidx = 0; - adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; - adapter->mode = IW_MODE_INFRA; + adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; + adapter->secinfo.authmode = wlan802_11authmodeopen; + adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE; + adapter->secinfo.Encryptionmode = CIPHER_NONE; + adapter->inframode = wlan802_11infrastructure; adapter->assoc_req = NULL; diff --git a/trunk/drivers/net/wireless/libertas/if_usb.c b/trunk/drivers/net/wireless/libertas/if_usb.c index ae6f72a6cdf3..695fb6a66ffe 100644 --- a/trunk/drivers/net/wireless/libertas/if_usb.c +++ b/trunk/drivers/net/wireless/libertas/if_usb.c @@ -388,7 +388,7 @@ static int __if_usb_submit_rx_urb(wlan_private * priv, usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, usb_rcvbulkpipe(cardp->udev, cardp->bulk_in_endpointAddr), - (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET), + skb->tail + IPFIELD_ALIGN_OFFSET, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, rinfo); @@ -626,7 +626,6 @@ static void if_usb_receive(struct urb *urb) cardp->usb_event_cause); if (cardp->usb_event_cause & 0xffff0000) { libertas_send_tx_feedback(priv); - spin_unlock(&priv->adapter->driver_lock); break; } cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; @@ -776,6 +775,7 @@ int libertas_sbi_prog_firmware(wlan_private * priv) return -1; } +#ifdef SUPPORT_BOOT_COMMAND cardp->bootcmdresp = 0; do { int j = 0; @@ -796,6 +796,7 @@ int libertas_sbi_prog_firmware(wlan_private * priv) } return -1; } +#endif i = 0; priv->adapter->fw_ready = 0; diff --git a/trunk/drivers/net/wireless/libertas/if_usb.h b/trunk/drivers/net/wireless/libertas/if_usb.h index 170dfe6809f5..785116720bc6 100644 --- a/trunk/drivers/net/wireless/libertas/if_usb.h +++ b/trunk/drivers/net/wireless/libertas/if_usb.h @@ -12,6 +12,7 @@ #define USB8388_VID_2 0x05a3 #define USB8388_PID_2 0x8388 +#ifdef SUPPORT_BOOT_COMMAND #define BOOT_CMD_FW_BY_USB 0x01 #define BOOT_CMD_FW_IN_EEPROM 0x02 #define BOOT_CMD_UPDATE_BOOT2 0x03 @@ -35,6 +36,7 @@ struct bootcmdrespStr u8 u8result; u8 au8dumy[2]; }; +#endif /* SUPPORT_BOOT_COMMAND */ /* read callback private data */ struct read_cb_info { diff --git a/trunk/drivers/net/wireless/libertas/ioctl.c b/trunk/drivers/net/wireless/libertas/ioctl.c index a8f76c358992..82b39642423a 100644 --- a/trunk/drivers/net/wireless/libertas/ioctl.c +++ b/trunk/drivers/net/wireless/libertas/ioctl.c @@ -27,31 +27,1112 @@ #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) +static int setrxantenna(wlan_private * priv, int mode) +{ + int ret = 0; + wlan_adapter *adapter = priv->adapter; + + if (mode != RF_ANTENNA_1 && mode != RF_ANTENNA_2 + && mode != RF_ANTENNA_AUTO) { + return -EINVAL; + } + + adapter->rxantennamode = mode; + + lbs_pr_debug(1, "SET RX Antenna mode to 0x%04x\n", adapter->rxantennamode); + + ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, + cmd_act_set_rx, + cmd_option_waitforrsp, 0, + &adapter->rxantennamode); + return ret; +} + +static int settxantenna(wlan_private * priv, int mode) +{ + int ret = 0; + wlan_adapter *adapter = priv->adapter; + + if ((mode != RF_ANTENNA_1) && (mode != RF_ANTENNA_2) + && (mode != RF_ANTENNA_AUTO)) { + return -EINVAL; + } + + adapter->txantennamode = mode; + + lbs_pr_debug(1, "SET TX Antenna mode to 0x%04x\n", adapter->txantennamode); + + ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, + cmd_act_set_tx, + cmd_option_waitforrsp, 0, + &adapter->txantennamode); + + return ret; +} + +static int getrxantenna(wlan_private * priv, char *buf) +{ + int ret = 0; + wlan_adapter *adapter = priv->adapter; + + // clear it, so we will know if the value + // returned below is correct or not. + adapter->rxantennamode = 0; + + ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, + cmd_act_get_rx, + cmd_option_waitforrsp, 0, NULL); + + if (ret) { + LEAVE(); + return ret; + } + + lbs_pr_debug(1, "Get Rx Antenna mode:0x%04x\n", adapter->rxantennamode); + + return sprintf(buf, "0x%04x", adapter->rxantennamode) + 1; +} + +static int gettxantenna(wlan_private * priv, char *buf) +{ + int ret = 0; + wlan_adapter *adapter = priv->adapter; + + // clear it, so we will know if the value + // returned below is correct or not. + adapter->txantennamode = 0; + + ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, + cmd_act_get_tx, + cmd_option_waitforrsp, 0, NULL); + + if (ret) { + LEAVE(); + return ret; + } + + lbs_pr_debug(1, "Get Tx Antenna mode:0x%04x\n", adapter->txantennamode); + + return sprintf(buf, "0x%04x", adapter->txantennamode) + 1; +} + static int wlan_set_region(wlan_private * priv, u16 region_code) { int i; - for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { - // use the region code to search for the index - if (region_code == libertas_region_code_to_index[i]) { - priv->adapter->regiontableindex = (u16) i; - priv->adapter->regioncode = region_code; + for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { + // use the region code to search for the index + if (region_code == libertas_region_code_to_index[i]) { + priv->adapter->regiontableindex = (u16) i; + priv->adapter->regioncode = region_code; + break; + } + } + + // if it's unidentified region code + if (i >= MRVDRV_MAX_REGION_CODE) { + lbs_pr_debug(1, "region Code not identified\n"); + LEAVE(); + return -1; + } + + if (libertas_set_regiontable(priv, priv->adapter->regioncode, 0)) { + LEAVE(); + return -EINVAL; + } + + return 0; +} + +/** + * @brief Get/Set Firmware wakeup method + * + * @param priv A pointer to wlan_private structure + * @param wrq A pointer to user data + * @return 0--success, otherwise fail + */ +static int wlan_txcontrol(wlan_private * priv, struct iwreq *wrq) +{ + wlan_adapter *adapter = priv->adapter; + int data; + ENTER(); + + if ((int)wrq->u.data.length == 0) { + if (copy_to_user + (wrq->u.data.pointer, &adapter->pkttxctrl, sizeof(u32))) { + lbs_pr_alert("copy_to_user failed!\n"); + return -EFAULT; + } + } else { + if ((int)wrq->u.data.length > 1) { + lbs_pr_alert("ioctl too many args!\n"); + return -EFAULT; + } + if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { + lbs_pr_alert("Copy from user failed\n"); + return -EFAULT; + } + + adapter->pkttxctrl = (u32) data; + } + + wrq->u.data.length = 1; + + LEAVE(); + return 0; +} + +/** + * @brief Get/Set NULL Package generation interval + * + * @param priv A pointer to wlan_private structure + * @param wrq A pointer to user data + * @return 0--success, otherwise fail + */ +static int wlan_null_pkt_interval(wlan_private * priv, struct iwreq *wrq) +{ + wlan_adapter *adapter = priv->adapter; + int data; + ENTER(); + + if ((int)wrq->u.data.length == 0) { + data = adapter->nullpktinterval; + + if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { + lbs_pr_alert( "copy_to_user failed!\n"); + return -EFAULT; + } + } else { + if ((int)wrq->u.data.length > 1) { + lbs_pr_alert( "ioctl too many args!\n"); + return -EFAULT; + } + if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + + adapter->nullpktinterval = data; + } + + wrq->u.data.length = 1; + + LEAVE(); + return 0; +} + +static int wlan_get_rxinfo(wlan_private * priv, struct iwreq *wrq) +{ + wlan_adapter *adapter = priv->adapter; + int data[2]; + ENTER(); + data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; + data[1] = adapter->rxpd_rate; + if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } + wrq->u.data.length = 2; + LEAVE(); + return 0; +} + +static int wlan_get_snr(wlan_private * priv, struct iwreq *wrq) +{ + int ret = 0; + wlan_adapter *adapter = priv->adapter; + int data[4]; + + ENTER(); + memset(data, 0, sizeof(data)); + if (wrq->u.data.length) { + if (copy_from_user(data, wrq->u.data.pointer, + min_t(size_t, wrq->u.data.length, 4) * sizeof(int))) + return -EFAULT; + } + if ((wrq->u.data.length == 0) || (data[0] == 0) || (data[0] == 1)) { + if (adapter->connect_status == libertas_connected) { + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_rssi, + 0, + cmd_option_waitforrsp, + 0, NULL); + + if (ret) { + LEAVE(); + return ret; + } + } + } + + if (wrq->u.data.length == 0) { + data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; + data[1] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; + data[2] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; + data[3] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; + if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 4)) + return -EFAULT; + wrq->u.data.length = 4; + } else if (data[0] == 0) { + data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; + if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) + return -EFAULT; + wrq->u.data.length = 1; + } else if (data[0] == 1) { + data[0] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; + if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) + return -EFAULT; + wrq->u.data.length = 1; + } else if (data[0] == 2) { + data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; + if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) + return -EFAULT; + wrq->u.data.length = 1; + } else if (data[0] == 3) { + data[0] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; + if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) + return -EFAULT; + wrq->u.data.length = 1; + } else + return -ENOTSUPP; + + LEAVE(); + return 0; +} + +static int wlan_beacon_interval(wlan_private * priv, struct iwreq *wrq) +{ + int data; + wlan_adapter *adapter = priv->adapter; + + if (wrq->u.data.length > 0) { + if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) + return -EFAULT; + + lbs_pr_debug(1, "WLAN SET BEACON INTERVAL: %d\n", data); + if ((data > MRVDRV_MAX_BEACON_INTERVAL) + || (data < MRVDRV_MIN_BEACON_INTERVAL)) + return -ENOTSUPP; + adapter->beaconperiod = data; + } + data = adapter->beaconperiod; + if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) + return -EFAULT; + + wrq->u.data.length = 1; + + return 0; +} + +static int wlan_get_rssi(wlan_private * priv, struct iwreq *wrq) +{ + int ret = 0; + wlan_adapter *adapter = priv->adapter; + int temp; + int data = 0; + int *val; + + ENTER(); + data = SUBCMD_DATA(wrq); + if ((data == 0) || (data == 1)) { + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_rssi, + 0, cmd_option_waitforrsp, + 0, NULL); + if (ret) { + LEAVE(); + return ret; + } + } + + switch (data) { + case 0: + + temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], + adapter->NF[TYPE_BEACON][TYPE_NOAVG]); + break; + case 1: + temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG], + adapter->NF[TYPE_BEACON][TYPE_AVG]); + break; + case 2: + temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_NOAVG], + adapter->NF[TYPE_RXPD][TYPE_NOAVG]); + break; + case 3: + temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, + adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); + break; + default: + return -ENOTSUPP; + } + val = (int *)wrq->u.name; + *val = temp; + + LEAVE(); + return 0; +} + +static int wlan_get_nf(wlan_private * priv, struct iwreq *wrq) +{ + int ret = 0; + wlan_adapter *adapter = priv->adapter; + int temp; + int data = 0; + int *val; + + data = SUBCMD_DATA(wrq); + if ((data == 0) || (data == 1)) { + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_rssi, + 0, cmd_option_waitforrsp, + 0, NULL); + + if (ret) { + LEAVE(); + return ret; + } + } + + switch (data) { + case 0: + temp = adapter->NF[TYPE_BEACON][TYPE_NOAVG]; + break; + case 1: + temp = adapter->NF[TYPE_BEACON][TYPE_AVG]; + break; + case 2: + temp = adapter->NF[TYPE_RXPD][TYPE_NOAVG]; + break; + case 3: + temp = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; + break; + default: + return -ENOTSUPP; + } + + temp = CAL_NF(temp); + + lbs_pr_debug(1, "%s: temp = %d\n", __FUNCTION__, temp); + val = (int *)wrq->u.name; + *val = temp; + return 0; +} + +static int wlan_get_txrate_ioctl(wlan_private * priv, struct ifreq *req) +{ + wlan_adapter *adapter = priv->adapter; + int *pdata; + struct iwreq *wrq = (struct iwreq *)req; + int ret = 0; + adapter->txrate = 0; + lbs_pr_debug(1, "wlan_get_txrate_ioctl\n"); + ret = libertas_prepare_and_send_command(priv, cmd_802_11_tx_rate_query, + cmd_act_get, cmd_option_waitforrsp, + 0, NULL); + if (ret) + return ret; + + pdata = (int *)wrq->u.name; + *pdata = (int)adapter->txrate; + return 0; +} + +static int wlan_get_adhoc_status_ioctl(wlan_private * priv, struct iwreq *wrq) +{ + char status[64]; + wlan_adapter *adapter = priv->adapter; + + memset(status, 0, sizeof(status)); + + switch (adapter->inframode) { + case wlan802_11ibss: + if (adapter->connect_status == libertas_connected) { + if (adapter->adhoccreate) + memcpy(&status, "AdhocStarted", sizeof(status)); + else + memcpy(&status, "AdhocJoined", sizeof(status)); + } else { + memcpy(&status, "AdhocIdle", sizeof(status)); + } + break; + case wlan802_11infrastructure: + memcpy(&status, "Inframode", sizeof(status)); + break; + default: + memcpy(&status, "AutoUnknownmode", sizeof(status)); + break; + } + + lbs_pr_debug(1, "status = %s\n", status); + wrq->u.data.length = strlen(status) + 1; + + if (wrq->u.data.pointer) { + if (copy_to_user(wrq->u.data.pointer, + &status, wrq->u.data.length)) + return -EFAULT; + } + + LEAVE(); + return 0; +} + +/** + * @brief Set/Get WPA IE + * @param priv A pointer to wlan_private structure + * @param req A pointer to ifreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_setwpaie_ioctl(wlan_private * priv, struct ifreq *req) +{ + struct iwreq *wrq = (struct iwreq *)req; + wlan_adapter *adapter = priv->adapter; + int ret = 0; + + ENTER(); + + if (wrq->u.data.length) { + if (wrq->u.data.length > sizeof(adapter->wpa_ie)) { + lbs_pr_debug(1, "failed to copy WPA IE, too big \n"); + return -EFAULT; + } + if (copy_from_user(adapter->wpa_ie, wrq->u.data.pointer, + wrq->u.data.length)) { + lbs_pr_debug(1, "failed to copy WPA IE \n"); + return -EFAULT; + } + adapter->wpa_ie_len = wrq->u.data.length; + lbs_pr_debug(1, "Set wpa_ie_len=%d IE=%#x\n", adapter->wpa_ie_len, + adapter->wpa_ie[0]); + lbs_dbg_hex("wpa_ie", adapter->wpa_ie, adapter->wpa_ie_len); + if (adapter->wpa_ie[0] == WPA_IE) + adapter->secinfo.WPAenabled = 1; + else if (adapter->wpa_ie[0] == WPA2_IE) + adapter->secinfo.WPA2enabled = 1; + else { + adapter->secinfo.WPAenabled = 0; + adapter->secinfo.WPA2enabled = 0; + } + } else { + memset(adapter->wpa_ie, 0, sizeof(adapter->wpa_ie)); + adapter->wpa_ie_len = wrq->u.data.length; + lbs_pr_debug(1, "Reset wpa_ie_len=%d IE=%#x\n", + adapter->wpa_ie_len, adapter->wpa_ie[0]); + adapter->secinfo.WPAenabled = 0; + adapter->secinfo.WPA2enabled = 0; + } + + // enable/disable RSN in firmware if WPA is enabled/disabled + // depending on variable adapter->secinfo.WPAenabled is set or not + ret = libertas_prepare_and_send_command(priv, cmd_802_11_enable_rsn, + cmd_act_set, cmd_option_waitforrsp, + 0, NULL); + + LEAVE(); + return ret; +} + +/** + * @brief Set Auto prescan + * @param priv A pointer to wlan_private structure + * @param wrq A pointer to iwreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_subcmd_setprescan_ioctl(wlan_private * priv, struct iwreq *wrq) +{ + int data; + wlan_adapter *adapter = priv->adapter; + int *val; + + data = SUBCMD_DATA(wrq); + lbs_pr_debug(1, "WLAN_SUBCMD_SET_PRESCAN %d\n", data); + adapter->prescan = data; + + val = (int *)wrq->u.name; + *val = data; + return 0; +} + +static int wlan_set_multiple_dtim_ioctl(wlan_private * priv, struct ifreq *req) +{ + struct iwreq *wrq = (struct iwreq *)req; + u32 mdtim; + int idata; + int ret = -EINVAL; + + ENTER(); + + idata = SUBCMD_DATA(wrq); + mdtim = (u32) idata; + if (((mdtim >= MRVDRV_MIN_MULTIPLE_DTIM) + && (mdtim <= MRVDRV_MAX_MULTIPLE_DTIM)) + || (mdtim == MRVDRV_IGNORE_MULTIPLE_DTIM)) { + priv->adapter->multipledtim = mdtim; + ret = 0; + } + if (ret) + lbs_pr_debug(1, "Invalid parameter, multipledtim not changed.\n"); + + LEAVE(); + return ret; +} + +/** + * @brief Set authentication mode + * @param priv A pointer to wlan_private structure + * @param req A pointer to ifreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_setauthalg_ioctl(wlan_private * priv, struct ifreq *req) +{ + int alg; + struct iwreq *wrq = (struct iwreq *)req; + wlan_adapter *adapter = priv->adapter; + + if (wrq->u.data.flags == 0) { + //from iwpriv subcmd + alg = SUBCMD_DATA(wrq); + } else { + //from wpa_supplicant subcmd + if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(alg))) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + } + + lbs_pr_debug(1, "auth alg is %#x\n", alg); + + switch (alg) { + case AUTH_ALG_SHARED_KEY: + adapter->secinfo.authmode = wlan802_11authmodeshared; + break; + case AUTH_ALG_NETWORK_EAP: + adapter->secinfo.authmode = + wlan802_11authmodenetworkEAP; + break; + case AUTH_ALG_OPEN_SYSTEM: + default: + adapter->secinfo.authmode = wlan802_11authmodeopen; + break; + } + return 0; +} + +/** + * @brief Set 802.1x authentication mode + * @param priv A pointer to wlan_private structure + * @param req A pointer to ifreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_set8021xauthalg_ioctl(wlan_private * priv, struct ifreq *req) +{ + int alg; + struct iwreq *wrq = (struct iwreq *)req; + + if (wrq->u.data.flags == 0) { + //from iwpriv subcmd + alg = SUBCMD_DATA(wrq); + } else { + //from wpa_supplicant subcmd + if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(int))) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + } + lbs_pr_debug(1, "802.1x auth alg is %#x\n", alg); + priv->adapter->secinfo.auth1xalg = alg; + return 0; +} + +static int wlan_setencryptionmode_ioctl(wlan_private * priv, struct ifreq *req) +{ + int mode; + struct iwreq *wrq = (struct iwreq *)req; + + ENTER(); + + if (wrq->u.data.flags == 0) { + //from iwpriv subcmd + mode = SUBCMD_DATA(wrq); + } else { + //from wpa_supplicant subcmd + if (copy_from_user(&mode, wrq->u.data.pointer, sizeof(int))) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + } + lbs_pr_debug(1, "encryption mode is %#x\n", mode); + priv->adapter->secinfo.Encryptionmode = mode; + + LEAVE(); + return 0; +} + +static void adjust_mtu(wlan_private * priv) +{ + int mtu_increment = 0; + + if (priv->adapter->linkmode == WLAN_LINKMODE_802_11) + mtu_increment += sizeof(struct ieee80211_hdr_4addr); + + if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP) + mtu_increment += max(sizeof(struct tx_radiotap_hdr), + sizeof(struct rx_radiotap_hdr)); + priv->wlan_dev.netdev->mtu = ETH_FRAME_LEN + - sizeof(struct ethhdr) + + mtu_increment; +} + +/** + * @brief Set Link-Layer Layer mode + * @param priv A pointer to wlan_private structure + * @param req A pointer to ifreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_set_linkmode_ioctl(wlan_private * priv, struct ifreq *req) +{ + int mode; + + mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; + + switch (mode) { + case WLAN_LINKMODE_802_3: + priv->adapter->linkmode = mode; + break; + case WLAN_LINKMODE_802_11: + priv->adapter->linkmode = mode; + break; + default: + lbs_pr_info("usb8388-5: invalid link-layer mode (%#x)\n", + mode); + return -EINVAL; + break; + } + lbs_pr_debug(1, "usb8388-5: link-layer mode is %#x\n", mode); + + adjust_mtu(priv); + + return 0; +} + +/** + * @brief Set Radio header mode + * @param priv A pointer to wlan_private structure + * @param req A pointer to ifreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_set_radiomode_ioctl(wlan_private * priv, struct ifreq *req) +{ + int mode; + + mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; + + switch (mode) { + case WLAN_RADIOMODE_NONE: + priv->adapter->radiomode = mode; + break; + case WLAN_RADIOMODE_RADIOTAP: + priv->adapter->radiomode = mode; + break; + default: + lbs_pr_debug(1, "usb8388-5: invalid radio header mode (%#x)\n", + mode); + return -EINVAL; + } + lbs_pr_debug(1, "usb8388-5: radio-header mode is %#x\n", mode); + + adjust_mtu(priv); + return 0; +} + +/** + * @brief Set Debug header mode + * @param priv A pointer to wlan_private structure + * @param req A pointer to ifreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_set_debugmode_ioctl(wlan_private * priv, struct ifreq *req) +{ + priv->adapter->debugmode = (int)((struct ifreq *) + ((u8 *) req + 4))->ifr_data; + return 0; +} + +static int wlan_subcmd_getrxantenna_ioctl(wlan_private * priv, + struct ifreq *req) +{ + int len; + char buf[8]; + struct iwreq *wrq = (struct iwreq *)req; + + lbs_pr_debug(1, "WLAN_SUBCMD_GETRXANTENNA\n"); + len = getrxantenna(priv, buf); + + wrq->u.data.length = len; + if (wrq->u.data.pointer) { + if (copy_to_user(wrq->u.data.pointer, &buf, len)) { + lbs_pr_debug(1, "CopyToUser failed\n"); + return -EFAULT; + } + } + + return 0; +} + +static int wlan_subcmd_gettxantenna_ioctl(wlan_private * priv, + struct ifreq *req) +{ + int len; + char buf[8]; + struct iwreq *wrq = (struct iwreq *)req; + + lbs_pr_debug(1, "WLAN_SUBCMD_GETTXANTENNA\n"); + len = gettxantenna(priv, buf); + + wrq->u.data.length = len; + if (wrq->u.data.pointer) { + if (copy_to_user(wrq->u.data.pointer, &buf, len)) { + lbs_pr_debug(1, "CopyToUser failed\n"); + return -EFAULT; + } + } + return 0; +} + +/** + * @brief Get the MAC TSF value from the firmware + * + * @param priv A pointer to wlan_private structure + * @param wrq A pointer to iwreq structure containing buffer + * space to store a TSF value retrieved from the firmware + * + * @return 0 if successful; IOCTL error code otherwise + */ +static int wlan_get_tsf_ioctl(wlan_private * priv, struct iwreq *wrq) +{ + u64 tsfval; + int ret; + + ret = libertas_prepare_and_send_command(priv, + cmd_get_tsf, + 0, cmd_option_waitforrsp, 0, &tsfval); + + lbs_pr_debug(1, "IOCTL: Get TSF = 0x%016llx\n", tsfval); + + if (ret != 0) { + lbs_pr_debug(1, "IOCTL: Get TSF; command exec failed\n"); + ret = -EFAULT; + } else { + if (copy_to_user(wrq->u.data.pointer, + &tsfval, + min_t(size_t, wrq->u.data.length, + sizeof(tsfval))) != 0) { + + lbs_pr_debug(1, "IOCTL: Get TSF; Copy to user failed\n"); + ret = -EFAULT; + } else { + ret = 0; + } + } + return ret; +} + +/** + * @brief Get/Set adapt rate + * @param priv A pointer to wlan_private structure + * @param wrq A pointer to iwreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_adapt_rateset(wlan_private * priv, struct iwreq *wrq) +{ + int ret; + wlan_adapter *adapter = priv->adapter; + int data[2]; + + memset(data, 0, sizeof(data)); + if (!wrq->u.data.length) { + lbs_pr_debug(1, "Get ADAPT RATE SET\n"); + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_rate_adapt_rateset, + cmd_act_get, + cmd_option_waitforrsp, 0, NULL); + data[0] = adapter->enablehwauto; + data[1] = adapter->ratebitmap; + if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } +#define GET_TWO_INT 2 + wrq->u.data.length = GET_TWO_INT; + } else { + lbs_pr_debug(1, "Set ADAPT RATE SET\n"); + if (wrq->u.data.length > 2) + return -EINVAL; + if (copy_from_user + (data, wrq->u.data.pointer, + sizeof(int) * wrq->u.data.length)) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + + adapter->enablehwauto = data[0]; + adapter->ratebitmap = data[1]; + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_rate_adapt_rateset, + cmd_act_set, + cmd_option_waitforrsp, 0, NULL); + } + return ret; +} + +/** + * @brief Get/Set inactivity timeout + * @param priv A pointer to wlan_private structure + * @param wrq A pointer to iwreq structure + * @return 0 --success, otherwise fail + */ +static int wlan_inactivity_timeout(wlan_private * priv, struct iwreq *wrq) +{ + int ret; + int data = 0; + u16 timeout = 0; + + ENTER(); + if (wrq->u.data.length > 1) + return -ENOTSUPP; + + if (wrq->u.data.length == 0) { + /* Get */ + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_inactivity_timeout, + cmd_act_get, + cmd_option_waitforrsp, 0, + &timeout); + data = timeout; + if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } + } else { + /* Set */ + if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + + timeout = data; + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_inactivity_timeout, + cmd_act_set, + cmd_option_waitforrsp, 0, + &timeout); + } + + wrq->u.data.length = 1; + + LEAVE(); + return ret; +} + +static int wlan_do_getlog_ioctl(wlan_private * priv, struct iwreq *wrq) +{ + int ret; + char buf[GETLOG_BUFSIZE - 1]; + wlan_adapter *adapter = priv->adapter; + + lbs_pr_debug(1, " GET STATS\n"); + + ret = libertas_prepare_and_send_command(priv, cmd_802_11_get_log, + 0, cmd_option_waitforrsp, 0, NULL); + + if (ret) { + return ret; + } + + if (wrq->u.data.pointer) { + sprintf(buf, "\n mcasttxframe %u failed %u retry %u " + "multiretry %u framedup %u " + "rtssuccess %u rtsfailure %u ackfailure %u\n" + "rxfrag %u mcastrxframe %u fcserror %u " + "txframe %u wepundecryptable %u ", + adapter->logmsg.mcasttxframe, + adapter->logmsg.failed, + adapter->logmsg.retry, + adapter->logmsg.multiretry, + adapter->logmsg.framedup, + adapter->logmsg.rtssuccess, + adapter->logmsg.rtsfailure, + adapter->logmsg.ackfailure, + adapter->logmsg.rxfrag, + adapter->logmsg.mcastrxframe, + adapter->logmsg.fcserror, + adapter->logmsg.txframe, + adapter->logmsg.wepundecryptable); + wrq->u.data.length = strlen(buf) + 1; + if (copy_to_user(wrq->u.data.pointer, buf, wrq->u.data.length)) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } + } + + return 0; +} + +static int wlan_scan_type_ioctl(wlan_private * priv, struct iwreq *wrq) +{ + u8 buf[12]; + u8 *option[] = { "active", "passive", "get", }; + int i, max_options = (sizeof(option) / sizeof(option[0])); + int ret = 0; + wlan_adapter *adapter = priv->adapter; + + if (priv->adapter->enable11d) { + lbs_pr_debug(1, "11D: Cannot set scantype when 11D enabled\n"); + return -EFAULT; + } + + memset(buf, 0, sizeof(buf)); + + if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), + wrq->u.data.length))) + return -EFAULT; + + lbs_pr_debug(1, "Scan type Option = %s\n", buf); + + buf[sizeof(buf) - 1] = '\0'; + + for (i = 0; i < max_options; i++) { + if (!strcmp(buf, option[i])) + break; + } + + switch (i) { + case 0: + adapter->scantype = cmd_scan_type_active; + break; + case 1: + adapter->scantype = cmd_scan_type_passive; + break; + case 2: + wrq->u.data.length = strlen(option[adapter->scantype]) + 1; + + if (copy_to_user(wrq->u.data.pointer, + option[adapter->scantype], + wrq->u.data.length)) { + lbs_pr_debug(1, "Copy to user failed\n"); + ret = -EFAULT; + } + + break; + default: + lbs_pr_debug(1, "Invalid Scan type Ioctl Option\n"); + ret = -EINVAL; + break; + } + + return ret; +} + +static int wlan_scan_mode_ioctl(wlan_private * priv, struct iwreq *wrq) +{ + wlan_adapter *adapter = priv->adapter; + u8 buf[12]; + u8 *option[] = { "bss", "ibss", "any", "get" }; + int i, max_options = (sizeof(option) / sizeof(option[0])); + int ret = 0; + + ENTER(); + + memset(buf, 0, sizeof(buf)); + + if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), + wrq->u.data.length))) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + + lbs_pr_debug(1, "Scan mode Option = %s\n", buf); + + buf[sizeof(buf) - 1] = '\0'; + + for (i = 0; i < max_options; i++) { + if (!strcmp(buf, option[i])) break; - } } - // if it's unidentified region code - if (i >= MRVDRV_MAX_REGION_CODE) { - lbs_pr_debug(1, "region Code not identified\n"); - LEAVE(); - return -1; + switch (i) { + + case 0: + adapter->scanmode = cmd_bss_type_bss; + break; + case 1: + adapter->scanmode = cmd_bss_type_ibss; + break; + case 2: + adapter->scanmode = cmd_bss_type_any; + break; + case 3: + + wrq->u.data.length = strlen(option[adapter->scanmode - 1]) + 1; + + lbs_pr_debug(1, "Get Scan mode Option = %s\n", + option[adapter->scanmode - 1]); + + lbs_pr_debug(1, "Scan mode length %d\n", wrq->u.data.length); + + if (copy_to_user(wrq->u.data.pointer, + option[adapter->scanmode - 1], + wrq->u.data.length)) { + lbs_pr_debug(1, "Copy to user failed\n"); + ret = -EFAULT; + } + lbs_pr_debug(1, "GET Scan type Option after copy = %s\n", + (char *)wrq->u.data.pointer); + + break; + + default: + lbs_pr_debug(1, "Invalid Scan mode Ioctl Option\n"); + ret = -EINVAL; + break; } - if (libertas_set_regiontable(priv, priv->adapter->regioncode, 0)) { - LEAVE(); + LEAVE(); + return ret; +} + +/** + * @brief Get/Set Adhoc G Rate + * + * @param priv A pointer to wlan_private structure + * @param wrq A pointer to user data + * @return 0--success, otherwise fail + */ +static int wlan_do_set_grate_ioctl(wlan_private * priv, struct iwreq *wrq) +{ + wlan_adapter *adapter = priv->adapter; + int data, data1; + int *val; + + ENTER(); + + data1 = SUBCMD_DATA(wrq); + switch (data1) { + case 0: + adapter->adhoc_grate_enabled = 0; + break; + case 1: + adapter->adhoc_grate_enabled = 1; + break; + case 2: + break; + default: return -EINVAL; } - + data = adapter->adhoc_grate_enabled; + val = (int *)wrq->u.name; + *val = data; + LEAVE(); return 0; } @@ -680,7 +1761,6 @@ static int wlan_fwt_list_neighbor_ioctl(wlan_private * priv, struct ifreq *req) */ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) { - struct iwreq *wrq = (struct iwreq *)req; static struct cmd_ds_fwt_access fwt_access; int ret; @@ -696,7 +1776,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) (void *)&fwt_access); if (ret == 0) - wrq->u.param.value = le32_to_cpu(fwt_access.references); + req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); else return -EFAULT; @@ -712,7 +1792,6 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) */ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) { - struct iwreq *wrq = (struct iwreq *)req; static struct cmd_ds_fwt_access fwt_access; int ret; @@ -728,7 +1807,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) (void *)&fwt_access); if (ret == 0) - wrq->u.param.value = le32_to_cpu(fwt_access.references); + req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); else return -EFAULT; @@ -744,7 +1823,6 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) */ static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) { - struct iwreq *wrq = (struct iwreq *)req; struct cmd_ds_mesh_access mesh_access; int ret; @@ -757,8 +1835,9 @@ static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) cmd_option_waitforrsp, 0, (void *)&mesh_access); - if (ret == 0) - wrq->u.param.value = le32_to_cpu(mesh_access.data[0]); + if (ret == 0) { + req->ifr_data = (char *)(le32_to_cpu(mesh_access.data[0])); + } else return -EFAULT; @@ -819,8 +1898,36 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); switch (cmd) { + case WLANSCAN_TYPE: + lbs_pr_debug(1, "Scan type Ioctl\n"); + ret = wlan_scan_type_ioctl(priv, wrq); + break; + case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ switch (wrq->u.data.flags) { + case WLANDEAUTH: + lbs_pr_debug(1, "Deauth\n"); + libertas_send_deauth(priv); + break; + + case WLANADHOCSTOP: + lbs_pr_debug(1, "Adhoc stop\n"); + ret = libertas_do_adhocstop_ioctl(priv); + break; + + case WLANRADIOON: + wlan_radio_ioctl(priv, 1); + break; + + case WLANRADIOOFF: + wlan_radio_ioctl(priv, 0); + break; + case WLANWLANIDLEON: + libertas_idle_on(priv); + break; + case WLANWLANIDLEOFF: + libertas_idle_off(priv); + break; case WLAN_SUBCMD_BT_RESET: /* bt_reset */ wlan_bt_reset_ioctl(priv); break; @@ -830,19 +1937,162 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) } /* End of switch */ break; + case WLANSETWPAIE: + ret = wlan_setwpaie_ioctl(priv, req); + break; + case WLAN_SETINT_GETINT: + /* The first 4 bytes of req->ifr_data is sub-ioctl number + * after 4 bytes sits the payload. + */ + subcmd = (int)req->ifr_data; //from iwpriv subcmd + switch (subcmd) { + case WLANNF: + ret = wlan_get_nf(priv, wrq); + break; + case WLANRSSI: + ret = wlan_get_rssi(priv, wrq); + break; + case WLANENABLE11D: + ret = libertas_cmd_enable_11d(priv, wrq); + break; + case WLANADHOCGRATE: + ret = wlan_do_set_grate_ioctl(priv, wrq); + break; + case WLAN_SUBCMD_SET_PRESCAN: + ret = wlan_subcmd_setprescan_ioctl(priv, wrq); + break; + } + break; + + case WLAN_SETONEINT_GETONEINT: + switch (wrq->u.data.flags) { + case WLAN_BEACON_INTERVAL: + ret = wlan_beacon_interval(priv, wrq); + break; + + case WLAN_LISTENINTRVL: + if (!wrq->u.data.length) { + int data; + lbs_pr_debug(1, "Get locallisteninterval value\n"); +#define GET_ONE_INT 1 + data = adapter->locallisteninterval; + if (copy_to_user(wrq->u.data.pointer, + &data, sizeof(int))) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } + + wrq->u.data.length = GET_ONE_INT; + } else { + int data; + if (copy_from_user + (&data, wrq->u.data.pointer, sizeof(int))) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + + lbs_pr_debug(1, "Set locallisteninterval = %d\n", + data); +#define MAX_U16_VAL 65535 + if (data > MAX_U16_VAL) { + lbs_pr_debug(1, "Exceeds U16 value\n"); + return -EINVAL; + } + adapter->locallisteninterval = data; + } + break; + case WLAN_TXCONTROL: + ret = wlan_txcontrol(priv, wrq); //adds for txcontrol ioctl + break; + + case WLAN_NULLPKTINTERVAL: + ret = wlan_null_pkt_interval(priv, wrq); + break; + + default: + ret = -EOPNOTSUPP; + break; + } + break; + case WLAN_SETONEINT_GETNONE: /* The first 4 bytes of req->ifr_data is sub-ioctl number * after 4 bytes sits the payload. */ - subcmd = wrq->u.data.flags; + subcmd = wrq->u.data.flags; //from wpa_supplicant subcmd + if (!subcmd) - subcmd = (int)wrq->u.param.value; + subcmd = (int)req->ifr_data; //from iwpriv subcmd switch (subcmd) { + case WLAN_SUBCMD_SETRXANTENNA: /* SETRXANTENNA */ + idata = SUBCMD_DATA(wrq); + ret = setrxantenna(priv, idata); + break; + case WLAN_SUBCMD_SETTXANTENNA: /* SETTXANTENNA */ + idata = SUBCMD_DATA(wrq); + ret = settxantenna(priv, idata); + break; + case WLAN_SET_ATIM_WINDOW: + adapter->atimwindow = SUBCMD_DATA(wrq); + adapter->atimwindow = min_t(__u16, adapter->atimwindow, 50); + break; + case WLANSETBCNAVG: + adapter->bcn_avg_factor = SUBCMD_DATA(wrq); + if (adapter->bcn_avg_factor == 0) + adapter->bcn_avg_factor = + DEFAULT_BCN_AVG_FACTOR; + if (adapter->bcn_avg_factor > DEFAULT_BCN_AVG_FACTOR) + adapter->bcn_avg_factor = + DEFAULT_BCN_AVG_FACTOR; + break; + case WLANSETDATAAVG: + adapter->data_avg_factor = SUBCMD_DATA(wrq); + if (adapter->data_avg_factor == 0) + adapter->data_avg_factor = + DEFAULT_DATA_AVG_FACTOR; + if (adapter->data_avg_factor > DEFAULT_DATA_AVG_FACTOR) + adapter->data_avg_factor = + DEFAULT_DATA_AVG_FACTOR; + break; case WLANSETREGION: idata = SUBCMD_DATA(wrq); ret = wlan_set_region(priv, (u16) idata); break; + + case WLAN_SET_LISTEN_INTERVAL: + idata = SUBCMD_DATA(wrq); + adapter->listeninterval = (u16) idata; + break; + + case WLAN_SET_MULTIPLE_DTIM: + ret = wlan_set_multiple_dtim_ioctl(priv, req); + break; + + case WLANSETAUTHALG: + ret = wlan_setauthalg_ioctl(priv, req); + break; + + case WLANSET8021XAUTHALG: + ret = wlan_set8021xauthalg_ioctl(priv, req); + break; + + case WLANSETENCRYPTIONMODE: + ret = wlan_setencryptionmode_ioctl(priv, req); + break; + + case WLAN_SET_LINKMODE: + ret = wlan_set_linkmode_ioctl(priv, req); + break; + + case WLAN_SET_RADIOMODE: + ret = wlan_set_radiomode_ioctl(priv, req); + break; + + case WLAN_SET_DEBUGMODE: + ret = wlan_set_debugmode_ioctl(priv, req); + break; + case WLAN_SUBCMD_MESH_SET_TTL: idata = SUBCMD_DATA(wrq); ret = wlan_mesh_set_ttl_ioctl(priv, idata); @@ -855,8 +2105,38 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) break; + case WLAN_SETNONE_GETTWELVE_CHAR: /* Get Antenna settings */ + /* + * We've not used IW_PRIV_TYPE_FIXED so sub-ioctl number is + * in flags of iwreq structure, otherwise it will be in + * mode member of iwreq structure. + */ + switch ((int)wrq->u.data.flags) { + case WLAN_SUBCMD_GETRXANTENNA: /* Get Rx Antenna */ + ret = wlan_subcmd_getrxantenna_ioctl(priv, req); + break; + + case WLAN_SUBCMD_GETTXANTENNA: /* Get Tx Antenna */ + ret = wlan_subcmd_gettxantenna_ioctl(priv, req); + break; + + case WLAN_GET_TSF: + ret = wlan_get_tsf_ioctl(priv, wrq); + break; + } + break; + case WLAN_SET128CHAR_GET128CHAR: switch ((int)wrq->u.data.flags) { + + case WLANSCAN_MODE: + lbs_pr_debug(1, "Scan mode Ioctl\n"); + ret = wlan_scan_mode_ioctl(priv, wrq); + break; + + case WLAN_GET_ADHOC_STATUS: + ret = wlan_get_adhoc_status_ioctl(priv, wrq); + break; case WLAN_SUBCMD_BT_ADD: ret = wlan_bt_add_ioctl(priv, req); break; @@ -888,11 +2168,41 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) break; case WLAN_SETNONE_GETONEINT: - switch (wrq->u.param.value) { + switch ((int)req->ifr_data) { + case WLANGETBCNAVG: + pdata = (int *)wrq->u.name; + *pdata = (int)adapter->bcn_avg_factor; + break; + case WLANGETREGION: pdata = (int *)wrq->u.name; *pdata = (int)adapter->regioncode; break; + + case WLAN_GET_LISTEN_INTERVAL: + pdata = (int *)wrq->u.name; + *pdata = (int)adapter->listeninterval; + break; + + case WLAN_GET_LINKMODE: + req->ifr_data = (char *)((u32) adapter->linkmode); + break; + + case WLAN_GET_RADIOMODE: + req->ifr_data = (char *)((u32) adapter->radiomode); + break; + + case WLAN_GET_DEBUGMODE: + req->ifr_data = (char *)((u32) adapter->debugmode); + break; + + case WLAN_GET_MULTIPLE_DTIM: + pdata = (int *)wrq->u.name; + *pdata = (int)adapter->multipledtim; + break; + case WLAN_GET_TX_RATE: + ret = wlan_get_txrate_ioctl(priv, req); + break; case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ ret = wlan_fwt_cleanup_ioctl(priv, req); break; @@ -912,8 +2222,196 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) break; + case WLANGETLOG: + ret = wlan_do_getlog_ioctl(priv, wrq); + break; + case WLAN_SET_GET_SIXTEEN_INT: switch ((int)wrq->u.data.flags) { + case WLAN_TPCCFG: + { + int data[5]; + struct cmd_ds_802_11_tpc_cfg cfg; + memset(&cfg, 0, sizeof(cfg)); + if ((wrq->u.data.length > 1) + && (wrq->u.data.length != 5)) + return -1; + + if (wrq->u.data.length == 0) { + cfg.action = + cpu_to_le16 + (cmd_act_get); + } else { + if (copy_from_user + (data, wrq->u.data.pointer, + sizeof(int) * 5)) { + lbs_pr_debug(1, + "Copy from user failed\n"); + return -EFAULT; + } + + cfg.action = + cpu_to_le16 + (cmd_act_set); + cfg.enable = data[0]; + cfg.usesnr = data[1]; + cfg.P0 = data[2]; + cfg.P1 = data[3]; + cfg.P2 = data[4]; + } + + ret = + libertas_prepare_and_send_command(priv, + cmd_802_11_tpc_cfg, + 0, + cmd_option_waitforrsp, + 0, (void *)&cfg); + + data[0] = cfg.enable; + data[1] = cfg.usesnr; + data[2] = cfg.P0; + data[3] = cfg.P1; + data[4] = cfg.P2; + if (copy_to_user + (wrq->u.data.pointer, data, + sizeof(int) * 5)) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } + + wrq->u.data.length = 5; + } + break; + + case WLAN_POWERCFG: + { + int data[4]; + struct cmd_ds_802_11_pwr_cfg cfg; + memset(&cfg, 0, sizeof(cfg)); + if ((wrq->u.data.length > 1) + && (wrq->u.data.length != 4)) + return -1; + if (wrq->u.data.length == 0) { + cfg.action = + cpu_to_le16 + (cmd_act_get); + } else { + if (copy_from_user + (data, wrq->u.data.pointer, + sizeof(int) * 4)) { + lbs_pr_debug(1, + "Copy from user failed\n"); + return -EFAULT; + } + + cfg.action = + cpu_to_le16 + (cmd_act_set); + cfg.enable = data[0]; + cfg.PA_P0 = data[1]; + cfg.PA_P1 = data[2]; + cfg.PA_P2 = data[3]; + } + ret = + libertas_prepare_and_send_command(priv, + cmd_802_11_pwr_cfg, + 0, + cmd_option_waitforrsp, + 0, (void *)&cfg); + data[0] = cfg.enable; + data[1] = cfg.PA_P0; + data[2] = cfg.PA_P1; + data[3] = cfg.PA_P2; + if (copy_to_user + (wrq->u.data.pointer, data, + sizeof(int) * 4)) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } + + wrq->u.data.length = 4; + } + break; + case WLAN_AUTO_FREQ_SET: + { + int data[3]; + struct cmd_ds_802_11_afc afc; + memset(&afc, 0, sizeof(afc)); + if (wrq->u.data.length != 3) + return -1; + if (copy_from_user + (data, wrq->u.data.pointer, + sizeof(int) * 3)) { + lbs_pr_debug(1, "Copy from user failed\n"); + return -EFAULT; + } + afc.afc_auto = data[0]; + + if (afc.afc_auto != 0) { + afc.threshold = data[1]; + afc.period = data[2]; + } else { + afc.timing_offset = data[1]; + afc.carrier_offset = data[2]; + } + ret = + libertas_prepare_and_send_command(priv, + cmd_802_11_set_afc, + 0, + cmd_option_waitforrsp, + 0, (void *)&afc); + } + break; + case WLAN_AUTO_FREQ_GET: + { + int data[3]; + struct cmd_ds_802_11_afc afc; + memset(&afc, 0, sizeof(afc)); + ret = + libertas_prepare_and_send_command(priv, + cmd_802_11_get_afc, + 0, + cmd_option_waitforrsp, + 0, (void *)&afc); + data[0] = afc.afc_auto; + data[1] = afc.timing_offset; + data[2] = afc.carrier_offset; + if (copy_to_user + (wrq->u.data.pointer, data, + sizeof(int) * 3)) { + lbs_pr_debug(1, "Copy to user failed\n"); + return -EFAULT; + } + + wrq->u.data.length = 3; + } + break; + case WLAN_SCANPROBES: + { + int data; + if (wrq->u.data.length > 0) { + if (copy_from_user + (&data, wrq->u.data.pointer, + sizeof(int))) { + lbs_pr_debug(1, + "Copy from user failed\n"); + return -EFAULT; + } + + adapter->scanprobes = data; + } else { + data = adapter->scanprobes; + if (copy_to_user + (wrq->u.data.pointer, &data, + sizeof(int))) { + lbs_pr_debug(1, + "Copy to user failed\n"); + return -EFAULT; + } + } + wrq->u.data.length = 1; + } + break; case WLAN_LED_GPIO_CTRL: { int i; @@ -977,6 +2475,17 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) wrq->u.data.length = gpio->header.len; } break; + case WLAN_ADAPT_RATESET: + ret = wlan_adapt_rateset(priv, wrq); + break; + case WLAN_INACTIVITY_TIMEOUT: + ret = wlan_inactivity_timeout(priv, wrq); + break; + case WLANSNR: + ret = wlan_get_snr(priv, wrq); + break; + case WLAN_GET_RXINFO: + ret = wlan_get_rxinfo(priv, wrq); } break; diff --git a/trunk/drivers/net/wireless/libertas/join.c b/trunk/drivers/net/wireless/libertas/join.c index d4926b83e145..11682cbe752b 100644 --- a/trunk/drivers/net/wireless/libertas/join.c +++ b/trunk/drivers/net/wireless/libertas/join.c @@ -15,8 +15,6 @@ #include "join.h" #include "dev.h" -#define AD_HOC_CAP_PRIVACY_ON 1 - /** * @brief This function finds out the common rates between rate1 and rate2. * @@ -87,7 +85,7 @@ int libertas_send_deauth(wlan_private * priv) wlan_adapter *adapter = priv->adapter; int ret = 0; - if (adapter->mode == IW_MODE_INFRA && + if (adapter->inframode == wlan802_11infrastructure && adapter->connect_status == libertas_connected) ret = libertas_send_deauthentication(priv); else @@ -96,6 +94,20 @@ int libertas_send_deauth(wlan_private * priv) return ret; } +int libertas_do_adhocstop_ioctl(wlan_private * priv) +{ + wlan_adapter *adapter = priv->adapter; + int ret = 0; + + if (adapter->inframode == wlan802_11ibss && + adapter->connect_status == libertas_connected) + ret = libertas_stop_adhoc_network(priv); + else + ret = -ENOTSUPP; + + return ret; +} + /** * @brief Associate to a specific BSS discovered in a scan * @@ -195,7 +207,8 @@ int libertas_join_adhoc_network(wlan_private * priv, struct bss_descriptor * pbs /* check if the requested SSID is already joined */ if (adapter->curbssparams.ssid.ssidlength && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) - && (adapter->mode == IW_MODE_ADHOC)) { + && (adapter->curbssparams.bssdescriptor.inframode == + wlan802_11ibss)) { lbs_pr_debug(1, "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " @@ -247,6 +260,130 @@ int libertas_send_deauthentication(wlan_private * priv) 0, cmd_option_waitforrsp, 0, NULL); } +/** + * @brief Set Idle Off + * + * @param priv A pointer to wlan_private structure + * @return 0 --success, otherwise fail + */ +int libertas_idle_off(wlan_private * priv) +{ + wlan_adapter *adapter = priv->adapter; + int ret = 0; + const u8 zeromac[] = { 0, 0, 0, 0, 0, 0 }; + int i; + + ENTER(); + + if (adapter->connect_status == libertas_disconnected) { + if (adapter->inframode == wlan802_11infrastructure) { + if (memcmp(adapter->previousbssid, zeromac, + sizeof(zeromac)) != 0) { + + lbs_pr_debug(1, "Previous SSID = %s\n", + adapter->previousssid.ssid); + lbs_pr_debug(1, "Previous BSSID = " + "%02x:%02x:%02x:%02x:%02x:%02x:\n", + adapter->previousbssid[0], + adapter->previousbssid[1], + adapter->previousbssid[2], + adapter->previousbssid[3], + adapter->previousbssid[4], + adapter->previousbssid[5]); + + i = libertas_find_SSID_in_list(adapter, + &adapter->previousssid, + adapter->previousbssid, + adapter->inframode); + + if (i < 0) { + libertas_send_specific_BSSID_scan(priv, + adapter-> + previousbssid, + 1); + i = libertas_find_SSID_in_list(adapter, + &adapter-> + previousssid, + adapter-> + previousbssid, + adapter-> + inframode); + } + + if (i < 0) { + /* If the BSSID could not be found, try just the SSID */ + i = libertas_find_SSID_in_list(adapter, + &adapter-> + previousssid, NULL, + adapter-> + inframode); + } + + if (i < 0) { + libertas_send_specific_SSID_scan(priv, + &adapter-> + previousssid, + 1); + i = libertas_find_SSID_in_list(adapter, + &adapter-> + previousssid, NULL, + adapter-> + inframode); + } + + if (i >= 0) { + ret = + wlan_associate(priv, + &adapter-> + scantable[i]); + } + } + } else if (adapter->inframode == wlan802_11ibss) { + ret = libertas_prepare_and_send_command(priv, + cmd_802_11_ad_hoc_start, + 0, + cmd_option_waitforrsp, + 0, &adapter->previousssid); + } + } + /* else it is connected */ + + lbs_pr_debug(1, "\nwlanidle is off"); + LEAVE(); + return ret; +} + +/** + * @brief Set Idle On + * + * @param priv A pointer to wlan_private structure + * @return 0 --success, otherwise fail + */ +int libertas_idle_on(wlan_private * priv) +{ + wlan_adapter *adapter = priv->adapter; + int ret = 0; + + if (adapter->connect_status == libertas_connected) { + if (adapter->inframode == wlan802_11infrastructure) { + lbs_pr_debug(1, "Previous SSID = %s\n", + adapter->previousssid.ssid); + memmove(&adapter->previousssid, + &adapter->curbssparams.ssid, + sizeof(struct WLAN_802_11_SSID)); + libertas_send_deauth(priv); + + } else if (adapter->inframode == wlan802_11ibss) { + ret = libertas_stop_adhoc_network(priv); + } + + } + + lbs_pr_debug(1, "\nwlanidle is on"); + + return ret; +} + /** * @brief This function prepares command of authenticate. * @@ -261,39 +398,22 @@ int libertas_cmd_80211_authenticate(wlan_private * priv, void *pdata_buf) { wlan_adapter *adapter = priv->adapter; - struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth; - int ret = -1; + struct cmd_ds_802_11_authenticate *pauthenticate = + &cmd->params.auth; u8 *bssid = pdata_buf; cmd->command = cpu_to_le16(cmd_802_11_authenticate); - cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) - + S_DS_GEN); - - /* translate auth mode to 802.11 defined wire value */ - switch (adapter->secinfo.auth_mode) { - case IW_AUTH_ALG_OPEN_SYSTEM: - pauthenticate->authtype = 0x00; - break; - case IW_AUTH_ALG_SHARED_KEY: - pauthenticate->authtype = 0x01; - break; - case IW_AUTH_ALG_LEAP: - pauthenticate->authtype = 0x80; - break; - default: - lbs_pr_debug(1, "AUTH_CMD: invalid auth alg 0x%X\n", - adapter->secinfo.auth_mode); - goto out; - } + cmd->size = + cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) + + S_DS_GEN); + pauthenticate->authtype = adapter->secinfo.authmode; memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); - ret = 0; -out: - return ret; + return 0; } int libertas_cmd_80211_deauthenticate(wlan_private * priv, @@ -430,7 +550,7 @@ int libertas_cmd_80211_associate(wlan_private * priv, lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); /* set IBSS field */ - if (pbssdesc->mode == IW_MODE_INFRA) { + if (pbssdesc->inframode == wlan802_11infrastructure) { #define CAPINFO_ESS_MODE 1 passo->capinfo.ess = CAPINFO_ESS_MODE; } @@ -504,7 +624,7 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, /* set the BSS type */ adhs->bsstype = cmd_bss_type_ibss; - pbssdesc->mode = IW_MODE_ADHOC; + pbssdesc->inframode = wlan802_11ibss; adhs->beaconperiod = adapter->beaconperiod; /* set Physical param set */ @@ -546,12 +666,15 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); /* set up privacy in adapter->scantable[i] */ - if (adapter->secinfo.wep_enabled) { - lbs_pr_debug(1, "ADHOC_S_CMD: WEP enabled, setting privacy on\n"); + if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { + +#define AD_HOC_CAP_PRIVACY_ON 1 + lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus set, privacy to WEP\n"); pbssdesc->privacy = wlan802_11privfilter8021xWEP; adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; } else { - lbs_pr_debug(1, "ADHOC_S_CMD: WEP disabled, setting privacy off\n"); + lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus NOT set, Setting " + "privacy to ACCEPT ALL\n"); pbssdesc->privacy = wlan802_11privfilteracceptall; } @@ -663,6 +786,9 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv, padhocjoin->bssdescriptor.BSSID[5], padhocjoin->bssdescriptor.SSID); + lbs_pr_debug(1, "ADHOC_J_CMD: Data Rate = %x\n", + (u32) padhocjoin->bssdescriptor.datarates); + /* failtimeout */ padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); @@ -706,7 +832,7 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv, padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = cpu_to_le16(pbssdesc->atimwindow); - if (adapter->secinfo.wep_enabled) { + if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; } diff --git a/trunk/drivers/net/wireless/libertas/join.h b/trunk/drivers/net/wireless/libertas/join.h index 115f5a8ba346..8efa2455af9a 100644 --- a/trunk/drivers/net/wireless/libertas/join.h +++ b/trunk/drivers/net/wireless/libertas/join.h @@ -1,3 +1,6 @@ +/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ +/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ + /** * Interface for the wlan infrastructure and adhoc join routines * @@ -37,6 +40,10 @@ extern int libertas_ret_80211_disassociate(wlan_private * priv, extern int libertas_ret_80211_associate(wlan_private * priv, struct cmd_ds_command *resp); +extern int libertas_idle_on(wlan_private * priv); +extern int libertas_idle_off(wlan_private * priv); + +extern int libertas_do_adhocstop_ioctl(wlan_private * priv); extern int libertas_reassociation_thread(void *data); struct WLAN_802_11_SSID; diff --git a/trunk/drivers/net/wireless/libertas/main.c b/trunk/drivers/net/wireless/libertas/main.c index b9b25ce65919..dcbf102a057e 100644 --- a/trunk/drivers/net/wireless/libertas/main.c +++ b/trunk/drivers/net/wireless/libertas/main.c @@ -21,13 +21,6 @@ #include "debugfs.h" #include "assoc.h" -#define DRIVER_RELEASE_VERSION "320.p0" -const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION -#ifdef DEBUG - "-dbg" -#endif - ""; - #ifdef ENABLE_PM static struct pm_dev *wlan_pm_dev = NULL; #endif diff --git a/trunk/drivers/net/wireless/libertas/rx.c b/trunk/drivers/net/wireless/libertas/rx.c index d17924f764e5..7e3f78f092dc 100644 --- a/trunk/drivers/net/wireless/libertas/rx.c +++ b/trunk/drivers/net/wireless/libertas/rx.c @@ -210,7 +210,7 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb) goto done; } - lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", + lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 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) priv->stats.rx_errors++; } - lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", + lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); /* create the exported radio header */ diff --git a/trunk/drivers/net/wireless/libertas/scan.c b/trunk/drivers/net/wireless/libertas/scan.c index 3c0b1a2a1727..e18706238951 100644 --- a/trunk/drivers/net/wireless/libertas/scan.c +++ b/trunk/drivers/net/wireless/libertas/scan.c @@ -1,3 +1,6 @@ +/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ +/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ + /** * Functions implementing wlan scan IOCTL and firmware command APIs * @@ -84,95 +87,118 @@ * * @return Index in scantable, or error code if negative */ -static int is_network_compatible(wlan_adapter * adapter, int index, u8 mode) +static int is_network_compatible(wlan_adapter * adapter, int index, int mode) { ENTER(); - if (adapter->scantable[index].mode == mode) { - if ( !adapter->secinfo.wep_enabled + if (adapter->scantable[index].inframode == mode) { + if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled - && adapter->scantable[index].wpa_ie[0] != WPA_IE - && adapter->scantable[index].rsn_ie[0] != WPA2_IE + && adapter->scantable[index].wpa_supplicant.wpa_ie[0] != + WPA_IE + && adapter->scantable[index].wpa2_supplicant.wpa_ie[0] != + WPA2_IE && adapter->secinfo.Encryptionmode == CIPHER_NONE && !adapter->scantable[index].privacy) { /* no security */ LEAVE(); return index; - } else if ( adapter->secinfo.wep_enabled + } else if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled && adapter->scantable[index].privacy) { /* static WEP enabled */ LEAVE(); return index; - } else if ( !adapter->secinfo.wep_enabled + } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled && adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled - && (adapter->scantable[index].wpa_ie[0] == WPA_IE) + && (adapter->scantable[index].wpa_supplicant. + wpa_ie[0] + == WPA_IE) /* privacy bit may NOT be set in some APs like LinkSys WRT54G && adapter->scantable[index].privacy */ ) { /* WPA enabled */ - lbs_pr_debug(1, + lbs_pr_debug(1, "is_network_compatible() WPA: index=%d wpa_ie=%#x " - "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " + "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " "privacy=%#x\n", index, - adapter->scantable[index].wpa_ie[0], - adapter->scantable[index].rsn_ie[0], - adapter->secinfo.wep_enabled ? "e" : "d", - adapter->secinfo.WPAenabled ? "e" : "d", - adapter->secinfo.WPA2enabled ? "e" : "d", + adapter->scantable[index].wpa_supplicant. + wpa_ie[0], + adapter->scantable[index].wpa2_supplicant. + wpa_ie[0], + (adapter->secinfo.WEPstatus == + wlan802_11WEPenabled) ? "e" : "d", + (adapter->secinfo.WPAenabled) ? "e" : "d", + (adapter->secinfo.WPA2enabled) ? "e" : "d", + adapter->secinfo.Encryptionmode, adapter->scantable[index].privacy); LEAVE(); return index; - } else if ( !adapter->secinfo.wep_enabled + } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled && !adapter->secinfo.WPAenabled && adapter->secinfo.WPA2enabled - && (adapter->scantable[index].rsn_ie[0] == WPA2_IE) + && (adapter->scantable[index].wpa2_supplicant. + wpa_ie[0] + == WPA2_IE) /* privacy bit may NOT be set in some APs like LinkSys WRT54G && adapter->scantable[index].privacy */ ) { /* WPA2 enabled */ - lbs_pr_debug(1, + lbs_pr_debug(1, "is_network_compatible() WPA2: index=%d wpa_ie=%#x " - "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " + "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " "privacy=%#x\n", index, - adapter->scantable[index].wpa_ie[0], - adapter->scantable[index].rsn_ie[0], - adapter->secinfo.wep_enabled ? "e" : "d", - adapter->secinfo.WPAenabled ? "e" : "d", - adapter->secinfo.WPA2enabled ? "e" : "d", + adapter->scantable[index].wpa_supplicant. + wpa_ie[0], + adapter->scantable[index].wpa2_supplicant. + wpa_ie[0], + (adapter->secinfo.WEPstatus == + wlan802_11WEPenabled) ? "e" : "d", + (adapter->secinfo.WPAenabled) ? "e" : "d", + (adapter->secinfo.WPA2enabled) ? "e" : "d", + adapter->secinfo.Encryptionmode, adapter->scantable[index].privacy); LEAVE(); return index; - } else if ( !adapter->secinfo.wep_enabled + } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled - && (adapter->scantable[index].wpa_ie[0] != WPA_IE) - && (adapter->scantable[index].rsn_ie[0] != WPA2_IE) + && (adapter->scantable[index].wpa_supplicant. + wpa_ie[0] + != WPA_IE) + && (adapter->scantable[index].wpa2_supplicant. + wpa_ie[0] + != WPA2_IE) + && adapter->secinfo.Encryptionmode != CIPHER_NONE && adapter->scantable[index].privacy) { /* dynamic WEP enabled */ - lbs_pr_debug(1, + lbs_pr_debug(1, "is_network_compatible() dynamic WEP: index=%d " - "wpa_ie=%#x wpa2_ie=%#x privacy=%#x\n", + "wpa_ie=%#x wpa2_ie=%#x Encmode=%#x privacy=%#x\n", index, - adapter->scantable[index].wpa_ie[0], - adapter->scantable[index].rsn_ie[0], + adapter->scantable[index].wpa_supplicant. + wpa_ie[0], + adapter->scantable[index].wpa2_supplicant. + wpa_ie[0], adapter->secinfo.Encryptionmode, adapter->scantable[index].privacy); LEAVE(); return index; } /* security doesn't match */ - lbs_pr_debug(1, + lbs_pr_debug(1, "is_network_compatible() FAILED: index=%d wpa_ie=%#x " - "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s privacy=%#x\n", + "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x privacy=%#x\n", index, - adapter->scantable[index].wpa_ie[0], - adapter->scantable[index].rsn_ie[0], - adapter->secinfo.wep_enabled ? "e" : "d", - adapter->secinfo.WPAenabled ? "e" : "d", - adapter->secinfo.WPA2enabled ? "e" : "d", + adapter->scantable[index].wpa_supplicant.wpa_ie[0], + adapter->scantable[index].wpa2_supplicant.wpa_ie[0], + (adapter->secinfo.WEPstatus == + wlan802_11WEPenabled) ? "e" : "d", + (adapter->secinfo.WPAenabled) ? "e" : "d", + (adapter->secinfo.WPA2enabled) ? "e" : "d", + adapter->secinfo.Encryptionmode, adapter->scantable[index].privacy); LEAVE(); return -ECONNREFUSED; @@ -898,6 +924,8 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, u8 founddatarateie; int bytesleftforcurrentbeacon; + struct WPA_SUPPLICANT *pwpa_supplicant; + struct WPA_SUPPLICANT *pwpa2_supplicant; struct IE_WPA *pIe; const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; @@ -934,6 +962,9 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, bytesleftforcurrentbeacon = beaconsize; + pwpa_supplicant = &pBSSEntry->wpa_supplicant; + pwpa2_supplicant = &pBSSEntry->wpa2_supplicant; + memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], @@ -996,9 +1027,9 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, } if (pcap->ibss == 1) { - pBSSEntry->mode = IW_MODE_ADHOC; + pBSSEntry->inframode = wlan802_11ibss; } else { - pBSSEntry->mode = IW_MODE_INFRA; + pBSSEntry->inframode = wlan802_11infrastructure; } /* process variable IE */ @@ -1085,7 +1116,7 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, sizeof(pcountryinfo->countrycode) || pcountryinfo->len > 254) { lbs_pr_debug(1, "InterpretIE: 11D- Err " - "CountryInfo len =%d min=%zd max=254\n", + "CountryInfo len =%d min=%d max=254\n", pcountryinfo->len, sizeof(pcountryinfo->countrycode)); LEAVE(); @@ -1129,27 +1160,27 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, #define IE_ID_LEN_FIELDS_BYTES 2 pIe = (struct IE_WPA *)pcurrentptr; - if (memcmp(pIe->oui, oui01, sizeof(oui01))) - break; - - pBSSEntry->wpa_ie_len = min_t(size_t, - elemlen + IE_ID_LEN_FIELDS_BYTES, - sizeof(pBSSEntry->wpa_ie)); - memcpy(pBSSEntry->wpa_ie, pcurrentptr, - pBSSEntry->wpa_ie_len); - lbs_dbg_hex("InterpretIE: Resp WPA_IE", - pBSSEntry->wpa_ie, elemlen); + if (!memcmp(pIe->oui, oui01, sizeof(oui01))) { + pwpa_supplicant->wpa_ie_len + = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, + sizeof(pwpa_supplicant->wpa_ie)); + memcpy(pwpa_supplicant->wpa_ie, + pcurrentptr, + pwpa_supplicant->wpa_ie_len); + lbs_dbg_hex("InterpretIE: Resp WPA_IE", + pwpa_supplicant->wpa_ie, elemlen); + } break; case WPA2_IE: pIe = (struct IE_WPA *)pcurrentptr; + pwpa2_supplicant->wpa_ie_len + = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, + sizeof(pwpa2_supplicant->wpa_ie)); + memcpy(pwpa2_supplicant->wpa_ie, + pcurrentptr, pwpa2_supplicant->wpa_ie_len); - pBSSEntry->rsn_ie_len = min_t(size_t, - elemlen + IE_ID_LEN_FIELDS_BYTES, - sizeof(pBSSEntry->rsn_ie)); - memcpy(pBSSEntry->rsn_ie, pcurrentptr, - pBSSEntry->rsn_ie_len); lbs_dbg_hex("InterpretIE: Resp WPA2_IE", - pBSSEntry->rsn_ie, elemlen); + pwpa2_supplicant->wpa_ie, elemlen); break; case TIM: break; @@ -1196,7 +1227,7 @@ int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *s * * @return index in BSSID list, or error return code (< 0) */ -int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode) +int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) { int ret = -ENETUNREACH; int i; @@ -1216,8 +1247,8 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode) for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { switch (mode) { - case IW_MODE_INFRA: - case IW_MODE_ADHOC: + case wlan802_11infrastructure: + case wlan802_11ibss: ret = is_network_compatible(adapter, i, mode); break; default: @@ -1241,7 +1272,7 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode) * @return index in BSSID list */ int libertas_find_SSID_in_list(wlan_adapter * adapter, - struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode) + struct WLAN_802_11_SSID *ssid, u8 * bssid, int mode) { int net = -ENETUNREACH; u8 bestrssi = 0; @@ -1256,8 +1287,8 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, !memcmp(adapter->scantable[i]. macaddress, bssid, ETH_ALEN))) { switch (mode) { - case IW_MODE_INFRA: - case IW_MODE_ADHOC: + case wlan802_11infrastructure: + case wlan802_11ibss: j = is_network_compatible(adapter, i, mode); if (j >= 0) { @@ -1280,7 +1311,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, } } break; - case IW_MODE_AUTO: + case wlan802_11autounknown: default: if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { @@ -1307,7 +1338,8 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter, * * @return index in BSSID list */ -int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode) +int libertas_find_best_SSID_in_list(wlan_adapter * adapter, + enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode) { int bestnet = -ENETUNREACH; u8 bestrssi = 0; @@ -1319,8 +1351,8 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode) for (i = 0; i < adapter->numinscantable; i++) { switch (mode) { - case IW_MODE_INFRA: - case IW_MODE_ADHOC: + case wlan802_11infrastructure: + case wlan802_11ibss: if (is_network_compatible(adapter, i, mode) >= 0) { if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { @@ -1331,7 +1363,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode) } } break; - case IW_MODE_AUTO: + case wlan802_11autounknown: default: if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { bestrssi = @@ -1356,7 +1388,8 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode) */ int libertas_find_best_network_SSID(wlan_private * priv, struct WLAN_802_11_SSID *pSSID, - u8 preferred_mode, u8 *out_mode) + enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, + enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode) { wlan_adapter *adapter = priv->adapter; int ret = 0; @@ -1381,7 +1414,7 @@ int libertas_find_best_network_SSID(wlan_private * priv, preqbssid = &adapter->scantable[i]; memcpy(pSSID, &preqbssid->ssid, sizeof(struct WLAN_802_11_SSID)); - *out_mode = preqbssid->mode; + *out_mode = preqbssid->inframode; if (!pSSID->ssidlength) { ret = -1; @@ -1551,7 +1584,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, for (i = 0; i < adapter->numinscantable; i++) { if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " - "MAX_SCAN_CELL_SIZE=%zd\n", + "MAX_SCAN_CELL_SIZE=%d\n", i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); break; } @@ -1599,7 +1632,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, //Add mode iwe.cmd = SIOCGIWMODE; - iwe.u.mode = adapter->scantable[i].mode; + iwe.u.mode = adapter->scantable[i].inframode + 1; iwe.len = IW_EV_UINT_LEN; current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); @@ -1633,7 +1666,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, iwe.u.qual.noise = CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); } - if ((adapter->mode == IW_MODE_ADHOC) && + if ((adapter->inframode == wlan802_11ibss) && !libertas_SSID_cmp(&adapter->curbssparams.ssid, &adapter->scantable[i].ssid) && adapter->adhoccreate) { @@ -1698,7 +1731,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, end_buf, &iwe, iwe.len); } - if ((adapter->scantable[i].mode == IW_MODE_ADHOC) + if ((adapter->scantable[i].inframode == wlan802_11ibss) && !libertas_SSID_cmp(&adapter->curbssparams.ssid, &adapter->scantable[i].ssid) && adapter->adhoccreate) { @@ -1712,24 +1745,30 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, /* Add new value to event */ current_val = current_ev + IW_EV_LCP_LEN; - if (adapter->scantable[i].rsn_ie[0] == WPA2_IE) { + if (adapter->scantable[i].wpa2_supplicant.wpa_ie[0] == WPA2_IE) { memset(&iwe, 0, sizeof(iwe)); memset(buf, 0, sizeof(buf)); - memcpy(buf, adapter->scantable[i].rsn_ie, - adapter->scantable[i].rsn_ie_len); + memcpy(buf, adapter->scantable[i]. + wpa2_supplicant.wpa_ie, + adapter->scantable[i].wpa2_supplicant. + wpa_ie_len); iwe.cmd = IWEVGENIE; - iwe.u.data.length = adapter->scantable[i].rsn_ie_len; + iwe.u.data.length = adapter->scantable[i]. + wpa2_supplicant.wpa_ie_len; iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf); } - if (adapter->scantable[i].wpa_ie[0] == WPA_IE) { + if (adapter->scantable[i].wpa_supplicant.wpa_ie[0] == WPA_IE) { memset(&iwe, 0, sizeof(iwe)); memset(buf, 0, sizeof(buf)); - memcpy(buf, adapter->scantable[i].wpa_ie, - adapter->scantable[i].wpa_ie_len); + memcpy(buf, adapter->scantable[i]. + wpa_supplicant.wpa_ie, + adapter->scantable[i].wpa_supplicant. + wpa_ie_len); iwe.cmd = IWEVGENIE; - iwe.u.data.length = adapter->scantable[i].wpa_ie_len; + iwe.u.data.length = adapter->scantable[i]. + wpa_supplicant.wpa_ie_len; iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf); diff --git a/trunk/drivers/net/wireless/libertas/scan.h b/trunk/drivers/net/wireless/libertas/scan.h index 405f4f0fe575..d93aa7fa44fd 100644 --- a/trunk/drivers/net/wireless/libertas/scan.h +++ b/trunk/drivers/net/wireless/libertas/scan.h @@ -1,3 +1,6 @@ +/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ +/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */ + /** * Interface for the wlan network scan routines * @@ -7,7 +10,6 @@ #ifndef _WLAN_SCAN_H #define _WLAN_SCAN_H -#include #include "hostcmd.h" /** @@ -153,7 +155,7 @@ struct bss_descriptor { u32 atimwindow; - u8 mode; + enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; int extra_ie; @@ -168,22 +170,22 @@ struct bss_descriptor { struct ieeetypes_countryinfofullset countryinfo; - u8 wpa_ie[MAX_WPA_IE_LEN]; - size_t wpa_ie_len; - u8 rsn_ie[MAX_WPA_IE_LEN]; - size_t rsn_ie_len; + struct WPA_SUPPLICANT wpa_supplicant; + struct WPA_SUPPLICANT wpa2_supplicant; + }; extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *ssid2); extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, - u8 * bssid, u8 mode); -int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode); -extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode); + u8 * bssid, int mode); +int libertas_find_best_SSID_in_list(wlan_adapter * adapter, enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode); +extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode); int libertas_find_best_network_SSID(wlan_private * priv, struct WLAN_802_11_SSID *pSSID, - u8 preferred_mode, u8 *out_mode); + enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, + enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode); extern int libertas_send_specific_SSID_scan(wlan_private * priv, struct WLAN_802_11_SSID *prequestedssid, diff --git a/trunk/drivers/net/wireless/libertas/tx.c b/trunk/drivers/net/wireless/libertas/tx.c index d4b13478c9a7..82d06223043e 100644 --- a/trunk/drivers/net/wireless/libertas/tx.c +++ b/trunk/drivers/net/wireless/libertas/tx.c @@ -78,7 +78,7 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb) min_t(unsigned int, skb->len, 100)); if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { - lbs_pr_debug(1, "Tx error: Bad skb length %d : %zd\n", + lbs_pr_debug(1, "Tx error: Bad skb length %d : %d\n", skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); ret = -1; goto done; diff --git a/trunk/drivers/net/wireless/libertas/version.h b/trunk/drivers/net/wireless/libertas/version.h index 8b137891791f..e86f65ae79b8 100644 --- a/trunk/drivers/net/wireless/libertas/version.h +++ b/trunk/drivers/net/wireless/libertas/version.h @@ -1 +1,8 @@ +#define DRIVER_RELEASE_VERSION "320.p0" +const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION +#ifdef DEBUG + "-dbg" +#endif + ""; + diff --git a/trunk/drivers/net/wireless/libertas/wext.c b/trunk/drivers/net/wireless/libertas/wext.c index 69f52b6e59c8..4a52336bc0f6 100644 --- a/trunk/drivers/net/wireless/libertas/wext.c +++ b/trunk/drivers/net/wireless/libertas/wext.c @@ -17,6 +17,7 @@ #include "defs.h" #include "dev.h" #include "join.h" +#include "version.h" #include "wext.h" #include "assoc.h" @@ -232,7 +233,7 @@ static int changeadhocchannel(wlan_private * priv, int channel) // find out the BSSID that matches the current SSID i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, - IW_MODE_ADHOC); + wlan802_11ibss); if (i >= 0) { lbs_pr_debug(1, "SSID found at %d in List," @@ -315,11 +316,13 @@ static int get_active_data_rates(wlan_adapter * adapter, ENTER(); if (adapter->connect_status != libertas_connected) { - if (adapter->mode == IW_MODE_INFRA) { + if (adapter->inframode == wlan802_11infrastructure) { + //Infra. mode lbs_pr_debug(1, "Infra\n"); k = copyrates(rates, k, libertas_supported_rates, sizeof(libertas_supported_rates)); } else { + //ad-hoc mode lbs_pr_debug(1, "Adhoc G\n"); k = copyrates(rates, k, libertas_adhoc_rates_g, sizeof(libertas_adhoc_rates_g)); @@ -583,7 +586,20 @@ static int wlan_get_mode(struct net_device *dev, ENTER(); - *uwrq = adapter->mode; + switch (adapter->inframode) { + case wlan802_11ibss: + *uwrq = IW_MODE_ADHOC; + break; + + case wlan802_11infrastructure: + *uwrq = IW_MODE_INFRA; + break; + + default: + case wlan802_11autounknown: + *uwrq = IW_MODE_AUTO; + break; + } LEAVE(); return 0; @@ -986,17 +1002,148 @@ static const struct iw_priv_args wlan_private_args[] = { /* * { cmd, set_args, get_args, name } */ + { + WLANSCAN_TYPE, + IW_PRIV_TYPE_CHAR | 8, + IW_PRIV_TYPE_CHAR | 8, + "scantype"}, + + { + WLAN_SETINT_GETINT, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + ""}, + { + WLANNF, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "getNF"}, + { + WLANRSSI, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "getRSSI"}, + { + WLANENABLE11D, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "enable11d"}, + { + WLANADHOCGRATE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "adhocgrate"}, + + { + WLAN_SUBCMD_SET_PRESCAN, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "prescan"}, + { + WLAN_SETONEINT_GETONEINT, + IW_PRIV_TYPE_INT | 1, + IW_PRIV_TYPE_INT | 1, + ""}, + { + WLAN_BEACON_INTERVAL, + IW_PRIV_TYPE_INT | 1, + IW_PRIV_TYPE_INT | 1, + "bcninterval"}, + { + WLAN_LISTENINTRVL, + IW_PRIV_TYPE_INT | 1, + IW_PRIV_TYPE_INT | 1, + "lolisteninter"}, + { + WLAN_TXCONTROL, + IW_PRIV_TYPE_INT | 1, + IW_PRIV_TYPE_INT | 1, + "txcontrol"}, + { + WLAN_NULLPKTINTERVAL, + IW_PRIV_TYPE_INT | 1, + IW_PRIV_TYPE_INT | 1, + "psnullinterval"}, /* Using iwpriv sub-command feature */ { WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, ""}, + + { + WLAN_SUBCMD_SETRXANTENNA, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "setrxant"}, + { + WLAN_SUBCMD_SETTXANTENNA, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "settxant"}, + { + WLANSETAUTHALG, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "authalgs", + }, + { + WLANSET8021XAUTHALG, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "8021xauthalgs", + }, + { + WLANSETENCRYPTIONMODE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "encryptionmode", + }, { WLANSETREGION, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "setregioncode"}, + { + WLAN_SET_LISTEN_INTERVAL, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "setlisteninter"}, + { + WLAN_SET_MULTIPLE_DTIM, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "setmultipledtim"}, + { + WLAN_SET_ATIM_WINDOW, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "atimwindow"}, + { + WLANSETBCNAVG, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "setbcnavg"}, + { + WLANSETDATAAVG, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "setdataavg"}, + { + WLAN_SET_LINKMODE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "linkmode"}, + { + WLAN_SET_RADIOMODE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "radiomode"}, + { + WLAN_SET_DEBUGMODE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, + "debugmode"}, { WLAN_SUBCMD_MESH_SET_TTL, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, @@ -1012,6 +1159,41 @@ static const struct iw_priv_args wlan_private_args[] = { IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getregioncode"}, + { + WLAN_GET_LISTEN_INTERVAL, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "getlisteninter"}, + { + WLAN_GET_MULTIPLE_DTIM, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "getmultipledtim"}, + { + WLAN_GET_TX_RATE, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "gettxrate"}, + { + WLANGETBCNAVG, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "getbcnavg"}, + { + WLAN_GET_LINKMODE, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "get_linkmode"}, + { + WLAN_GET_RADIOMODE, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "get_radiomode"}, + { + WLAN_GET_DEBUGMODE, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "get_debugmode"}, { WLAN_SUBCMD_FWT_CLEANUP, IW_PRIV_TYPE_NONE, @@ -1027,11 +1209,61 @@ static const struct iw_priv_args wlan_private_args[] = { IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "mesh_get_ttl"}, + { + WLAN_SETNONE_GETTWELVE_CHAR, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | 12, + ""}, + { + WLAN_SUBCMD_GETRXANTENNA, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | 12, + "getrxant"}, + { + WLAN_SUBCMD_GETTXANTENNA, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | 12, + "gettxant"}, + { + WLAN_GET_TSF, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | 12, + "gettsf"}, { WLAN_SETNONE_GETNONE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_NONE, ""}, + { + WLANDEAUTH, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_NONE, + "deauth"}, + { + WLANADHOCSTOP, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_NONE, + "adhocstop"}, + { + WLANRADIOON, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_NONE, + "radioon"}, + { + WLANRADIOOFF, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_NONE, + "radiooff"}, + { + WLANWLANIDLEON, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_NONE, + "wlanidle-on"}, + { + WLANWLANIDLEOFF, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_NONE, + "wlanidle-off"}, { WLAN_SUBCMD_FWT_RESET, IW_PRIV_TYPE_NONE, @@ -1094,16 +1326,91 @@ static const struct iw_priv_args wlan_private_args[] = { IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | 128, "fwt_list_route"}, + { + WLANSCAN_MODE, + IW_PRIV_TYPE_CHAR | 128, + IW_PRIV_TYPE_CHAR | 128, + "scanmode"}, + { + WLAN_GET_ADHOC_STATUS, + IW_PRIV_TYPE_CHAR | 128, + IW_PRIV_TYPE_CHAR | 128, + "getadhocstatus"}, + { + WLAN_SETNONE_GETWORDCHAR, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | 128, + ""}, + { + WLANSETWPAIE, + IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 24, + IW_PRIV_TYPE_NONE, + "setwpaie"}, + { + WLANGETLOG, + IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | GETLOG_BUFSIZE, + "getlog"}, { WLAN_SET_GET_SIXTEEN_INT, IW_PRIV_TYPE_INT | 16, IW_PRIV_TYPE_INT | 16, ""}, + { + WLAN_TPCCFG, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "tpccfg"}, + { + WLAN_POWERCFG, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "powercfg"}, + { + WLAN_AUTO_FREQ_SET, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "setafc"}, + { + WLAN_AUTO_FREQ_GET, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "getafc"}, + { + WLAN_SCANPROBES, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "scanprobes"}, { WLAN_LED_GPIO_CTRL, IW_PRIV_TYPE_INT | 16, IW_PRIV_TYPE_INT | 16, "ledgpio"}, + { + WLAN_ADAPT_RATESET, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "rateadapt"}, + { + WLAN_INACTIVITY_TIMEOUT, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "inactivityto"}, + { + WLANSNR, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "getSNR"}, + { + WLAN_GET_RATE, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "getrate"}, + { + WLAN_GET_RXINFO, + IW_PRIV_TYPE_INT | 16, + IW_PRIV_TYPE_INT | 16, + "getrxinfo"}, }; static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) @@ -1127,7 +1434,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) ENTER(); - priv->wstats.status = adapter->mode; + priv->wstats.status = adapter->inframode; /* If we're not associated, all quality values are meaningless */ if (adapter->connect_status != libertas_connected) @@ -1261,12 +1568,13 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info, if (!cfp) { rc = -EINVAL; } else { - if (adapter->mode == IW_MODE_ADHOC) { + if (adapter->inframode == wlan802_11ibss) { rc = changeadhocchannel(priv, channel); /* If station is WEP enabled, send the * command to set WEP in firmware */ - if (adapter->secinfo.wep_enabled) { + if (adapter->secinfo.WEPstatus == + wlan802_11WEPenabled) { lbs_pr_debug(1, "set_freq: WEP enabled\n"); ret = libertas_prepare_and_send_command(priv, cmd_802_11_set_wep, @@ -1408,31 +1716,49 @@ static int wlan_set_mode(struct net_device *dev, wlan_private *priv = dev->priv; wlan_adapter *adapter = priv->adapter; struct assoc_request * assoc_req; + enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; ENTER(); - if ( (*uwrq != IW_MODE_ADHOC) - && (*uwrq != IW_MODE_INFRA) - && (*uwrq != IW_MODE_AUTO)) { - lbs_pr_debug(1, "Invalid mode: 0x%x\n", *uwrq); - ret = -EINVAL; - goto out; + switch (*uwrq) { + case IW_MODE_ADHOC: + lbs_pr_debug(1, "Wanted mode is ad-hoc: current datarate=%#x\n", + adapter->datarate); + new_mode = wlan802_11ibss; + adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL; + break; + + case IW_MODE_INFRA: + lbs_pr_debug(1, "Wanted mode is Infrastructure\n"); + new_mode = wlan802_11infrastructure; + break; + + case IW_MODE_AUTO: + lbs_pr_debug(1, "Wanted mode is Auto\n"); + new_mode = wlan802_11autounknown; + break; + + default: + lbs_pr_debug(1, "Wanted mode is Unknown: 0x%x\n", *uwrq); + return -EINVAL; } mutex_lock(&adapter->lock); assoc_req = wlan_get_association_request(adapter); if (!assoc_req) { ret = -ENOMEM; - wlan_cancel_association_work(priv); } else { - assoc_req->mode = *uwrq; + assoc_req->mode = new_mode; + } + + if (ret == 0) { set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); wlan_postpone_association_work(priv); - lbs_pr_debug(1, "Switching to mode: 0x%x\n", *uwrq); + } else { + wlan_cancel_association_work(priv); } mutex_unlock(&adapter->lock); -out: LEAVE(); return ret; } @@ -1463,13 +1789,13 @@ static int wlan_get_encode(struct net_device *dev, dwrq->flags = 0; /* Authentication method */ - switch (adapter->secinfo.auth_mode) { - case IW_AUTH_ALG_OPEN_SYSTEM: + switch (adapter->secinfo.authmode) { + case wlan802_11authmodeopen: dwrq->flags = IW_ENCODE_OPEN; break; - case IW_AUTH_ALG_SHARED_KEY: - case IW_AUTH_ALG_LEAP: + case wlan802_11authmodeshared: + case wlan802_11authmodenetworkEAP: dwrq->flags = IW_ENCODE_RESTRICTED; break; default: @@ -1477,9 +1803,8 @@ static int wlan_get_encode(struct net_device *dev, break; } - if ( adapter->secinfo.wep_enabled - || adapter->secinfo.WPAenabled - || adapter->secinfo.WPA2enabled) { + if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) + || adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) { dwrq->flags &= ~IW_ENCODE_DISABLED; } else { dwrq->flags |= IW_ENCODE_DISABLED; @@ -1493,7 +1818,8 @@ static int wlan_get_encode(struct net_device *dev, if (index < 0) index = adapter->wep_tx_keyidx; - if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) { + if ((adapter->wep_keys[index].len) && + (adapter->secinfo.WEPstatus == wlan802_11WEPenabled)) { memcpy(extra, adapter->wep_keys[index].key, adapter->wep_keys[index].len); dwrq->length = adapter->wep_keys[index].len; @@ -1577,7 +1903,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req, assoc_req->wep_tx_keyidx = index; } - assoc_req->secinfo.wep_enabled = 1; + assoc_req->secinfo.WEPstatus = wlan802_11WEPenabled; LEAVE(); return 0; @@ -1606,10 +1932,10 @@ static void disable_wep(struct assoc_request *assoc_req) int i; /* Set Open System auth mode */ - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; + assoc_req->secinfo.authmode = wlan802_11authmodeopen; /* Clear WEP keys and mark WEP as disabled */ - assoc_req->secinfo.wep_enabled = 0; + assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; for (i = 0; i < 4; i++) assoc_req->wep_keys[i].len = 0; @@ -1661,7 +1987,8 @@ static int wlan_set_encode(struct net_device *dev, /* If WEP isn't enabled, or if there is no key data but a valid * index, set the TX key. */ - if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default)) + if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) + || (dwrq->length == 0 && !is_default)) set_tx_key = 1; ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); @@ -1674,9 +2001,9 @@ static int wlan_set_encode(struct net_device *dev, set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); if (dwrq->flags & IW_ENCODE_RESTRICTED) { - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; + assoc_req->secinfo.authmode = wlan802_11authmodeshared; } else if (dwrq->flags & IW_ENCODE_OPEN) { - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; + assoc_req->secinfo.authmode = wlan802_11authmodeopen; } out: @@ -1729,31 +2056,30 @@ static int wlan_get_encodeext(struct net_device *dev, if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && ext->alg != IW_ENCODE_ALG_WEP) { - if (index != 0 || adapter->mode != IW_MODE_INFRA) + if (index != 0 || adapter->inframode != wlan802_11infrastructure) goto out; } dwrq->flags = index + 1; memset(ext, 0, sizeof(*ext)); - if ( !adapter->secinfo.wep_enabled - && !adapter->secinfo.WPAenabled - && !adapter->secinfo.WPA2enabled) { + if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) + && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) { ext->alg = IW_ENCODE_ALG_NONE; ext->key_len = 0; dwrq->flags |= IW_ENCODE_DISABLED; } else { u8 *key = NULL; - if ( adapter->secinfo.wep_enabled + if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) { ext->alg = IW_ENCODE_ALG_WEP; ext->key_len = adapter->wep_keys[index].len; key = &adapter->wep_keys[index].key[0]; - } else if ( !adapter->secinfo.wep_enabled - && (adapter->secinfo.WPAenabled || - adapter->secinfo.WPA2enabled)) { + } else if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) && + (adapter->secinfo.WPAenabled || + adapter->secinfo.WPA2enabled)) { /* WPA */ ext->alg = IW_ENCODE_ALG_TKIP; ext->key_len = 0; @@ -1823,7 +2149,7 @@ static int wlan_set_encodeext(struct net_device *dev, /* If WEP isn't enabled, or if there is no key data but a valid * index, or if the set-TX-key flag was passed, set the TX key. */ - if ( !assoc_req->secinfo.wep_enabled + if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) || (dwrq->length == 0 && !is_default) || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) set_tx_key = 1; @@ -1835,9 +2161,11 @@ static int wlan_set_encodeext(struct net_device *dev, goto out; if (dwrq->flags & IW_ENCODE_RESTRICTED) { - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; + assoc_req->secinfo.authmode = + wlan802_11authmodeshared; } else if (dwrq->flags & IW_ENCODE_OPEN) { - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; + assoc_req->secinfo.authmode = + wlan802_11authmodeopen; } /* Mark the various WEP bits as modified */ @@ -2022,13 +2350,15 @@ static int wlan_set_auth(struct net_device *dev, } if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { assoc_req->secinfo.WPAenabled = 1; - assoc_req->secinfo.wep_enabled = 0; - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; + assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; + assoc_req->secinfo.authmode = + wlan802_11authmodeopen; } if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { assoc_req->secinfo.WPA2enabled = 1; - assoc_req->secinfo.wep_enabled = 0; - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; + assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; + assoc_req->secinfo.authmode = + wlan802_11authmodeopen; } updated = 1; break; @@ -2046,11 +2376,14 @@ static int wlan_set_auth(struct net_device *dev, case IW_AUTH_80211_AUTH_ALG: if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; + assoc_req->secinfo.authmode = + wlan802_11authmodeshared; } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; + assoc_req->secinfo.authmode = + wlan802_11authmodeopen; } else if (dwrq->value & IW_AUTH_ALG_LEAP) { - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP; + assoc_req->secinfo.authmode = + wlan802_11authmodenetworkEAP; } else { ret = -EINVAL; } @@ -2063,8 +2396,9 @@ static int wlan_set_auth(struct net_device *dev, !assoc_req->secinfo.WPA2enabled) { assoc_req->secinfo.WPAenabled = 1; assoc_req->secinfo.WPA2enabled = 1; - assoc_req->secinfo.wep_enabled = 0; - assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; + assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; + assoc_req->secinfo.authmode = + wlan802_11authmodeopen; } } else { assoc_req->secinfo.WPAenabled = 0; @@ -2121,7 +2455,19 @@ static int wlan_get_auth(struct net_device *dev, break; case IW_AUTH_80211_AUTH_ALG: - dwrq->value = adapter->secinfo.auth_mode; + switch (adapter->secinfo.authmode) { + case wlan802_11authmodeshared: + dwrq->value = IW_AUTH_ALG_SHARED_KEY; + break; + case wlan802_11authmodeopen: + dwrq->value = IW_AUTH_ALG_OPEN_SYSTEM; + break; + case wlan802_11authmodenetworkEAP: + dwrq->value = IW_AUTH_ALG_LEAP; + break; + default: + break; + } break; case IW_AUTH_WPA_ENABLED: diff --git a/trunk/drivers/net/wireless/libertas/wext.h b/trunk/drivers/net/wireless/libertas/wext.h index 15cfaaf0797f..39f367c38d90 100644 --- a/trunk/drivers/net/wireless/libertas/wext.h +++ b/trunk/drivers/net/wireless/libertas/wext.h @@ -10,22 +10,88 @@ /** PRIVATE CMD ID */ #define WLANIOCTL SIOCIWFIRSTPRIV +#define WLANSETWPAIE (WLANIOCTL + 0) + +#define WLAN_SETINT_GETINT (WLANIOCTL + 7) +#define WLANNF 1 +#define WLANRSSI 2 +#define WLANENABLE11D 5 +#define WLANADHOCGRATE 6 +#define WLAN_SUBCMD_SET_PRESCAN 11 + #define WLAN_SETNONE_GETNONE (WLANIOCTL + 8) +#define WLANDEAUTH 1 +#define WLANRADIOON 2 +#define WLANRADIOOFF 3 +#define WLANREMOVEADHOCAES 4 +#define WLANADHOCSTOP 5 +#define WLANCIPHERTEST 6 +#define WLANCRYPTOTEST 7 + +#define WLANWLANIDLEON 10 +#define WLANWLANIDLEOFF 11 #define WLAN_SUBCMD_BT_RESET 13 #define WLAN_SUBCMD_FWT_RESET 14 +#define WLANGETLOG (WLANIOCTL + 9) +#define GETLOG_BUFSIZE 300 + +#define WLANSCAN_TYPE (WLANIOCTL + 11) + #define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15) #define WLANGETREGION 1 +#define WLAN_GET_LISTEN_INTERVAL 2 +#define WLAN_GET_MULTIPLE_DTIM 3 +#define WLAN_GET_TX_RATE 4 +#define WLANGETBCNAVG 5 +#define WLAN_GET_LINKMODE 6 +#define WLAN_GET_RADIOMODE 7 +#define WLAN_GET_DEBUGMODE 8 #define WLAN_SUBCMD_FWT_CLEANUP 15 #define WLAN_SUBCMD_FWT_TIME 16 #define WLAN_SUBCMD_MESH_GET_TTL 17 +#define WLANREGCFRDWR (WLANIOCTL + 18) + +#define WLAN_SETNONE_GETTWELVE_CHAR (WLANIOCTL + 19) +#define WLAN_SUBCMD_GETRXANTENNA 1 +#define WLAN_SUBCMD_GETTXANTENNA 2 +#define WLAN_GET_TSF 3 + +#define WLAN_SETNONE_GETWORDCHAR (WLANIOCTL + 21) +#define WLANGETADHOCAES 1 + +#define WLAN_SETONEINT_GETONEINT (WLANIOCTL + 23) +#define WLAN_BEACON_INTERVAL 1 +#define WLAN_LISTENINTRVL 4 + +#define WLAN_TXCONTROL 6 +#define WLAN_NULLPKTINTERVAL 7 + #define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) +#define WLAN_SUBCMD_SETRXANTENNA 1 +#define WLAN_SUBCMD_SETTXANTENNA 2 +#define WLANSETAUTHALG 5 +#define WLANSET8021XAUTHALG 6 +#define WLANSETENCRYPTIONMODE 7 #define WLANSETREGION 8 +#define WLAN_SET_LISTEN_INTERVAL 9 + +#define WLAN_SET_MULTIPLE_DTIM 10 +#define WLAN_SET_ATIM_WINDOW 11 +#define WLANSETBCNAVG 13 +#define WLANSETDATAAVG 14 +#define WLAN_SET_LINKMODE 15 +#define WLAN_SET_RADIOMODE 16 +#define WLAN_SET_DEBUGMODE 17 #define WLAN_SUBCMD_MESH_SET_TTL 18 #define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) +#define WLANSCAN_MODE 6 + +#define WLAN_GET_ADHOC_STATUS 9 + #define WLAN_SUBCMD_BT_ADD 18 #define WLAN_SUBCMD_BT_DEL 19 #define WLAN_SUBCMD_BT_LIST 20 @@ -37,8 +103,27 @@ #define WLAN_SUBCMD_FWT_LIST_ROUTE 26 #define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) +#define WLAN_TPCCFG 1 +#define WLAN_POWERCFG 2 + +#define WLAN_AUTO_FREQ_SET 3 +#define WLAN_AUTO_FREQ_GET 4 #define WLAN_LED_GPIO_CTRL 5 +#define WLAN_SCANPROBES 6 +#define WLAN_ADAPT_RATESET 8 +#define WLAN_INACTIVITY_TIMEOUT 9 +#define WLANSNR 10 +#define WLAN_GET_RATE 11 +#define WLAN_GET_RXINFO 12 + +#define WLANCMD52RDWR (WLANIOCTL + 30) +#define WLANCMD53RDWR (WLANIOCTL + 31) +#define CMD53BUFLEN 32 +#define REG_MAC 0x19 +#define REG_BBP 0x1a +#define REG_RF 0x1b +#define REG_EEPROM 0x59 #define WLAN_LINKMODE_802_3 0 #define WLAN_LINKMODE_802_11 2 #define WLAN_RADIOMODE_NONE 0 diff --git a/trunk/drivers/pci/msi.c b/trunk/drivers/pci/msi.c index d9cbd586ae4b..e6740d1a0824 100644 --- a/trunk/drivers/pci/msi.c +++ b/trunk/drivers/pci/msi.c @@ -549,10 +549,8 @@ static int msi_free_irqs(struct pci_dev* dev) { struct msi_desc *entry, *tmp; - list_for_each_entry(entry, &dev->msi_list, list) { - if (entry->irq) - BUG_ON(irq_has_action(entry->irq)); - } + list_for_each_entry(entry, &dev->msi_list, list) + BUG_ON(irq_has_action(entry->irq)); arch_teardown_msi_irqs(dev); diff --git a/trunk/drivers/pci/quirks.c b/trunk/drivers/pci/quirks.c index 6ccc2e95930a..147d86f8edbf 100644 --- a/trunk/drivers/pci/quirks.c +++ b/trunk/drivers/pci/quirks.c @@ -875,7 +875,6 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev) } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_sb600_sata); /* * Serverworks CSB5 IDE does not fully support native mode diff --git a/trunk/include/linux/libata.h b/trunk/include/linux/libata.h index 27d936279574..7906d750aa77 100644 --- a/trunk/include/linux/libata.h +++ b/trunk/include/linux/libata.h @@ -140,6 +140,7 @@ enum { ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ + ATA_DFLAG_SUSPENDED = (1 << 10), /* device suspended */ ATA_DFLAG_INIT_MASK = (1 << 16) - 1, ATA_DFLAG_DETACH = (1 << 16), @@ -190,7 +191,6 @@ enum { ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ - ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */ ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */ ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ @@ -254,6 +254,10 @@ enum { ATA_DMA_PAD_SZ = 4, ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, + /* masks for port functions */ + ATA_PORT_PRIMARY = (1 << 0), + ATA_PORT_SECONDARY = (1 << 1), + /* ering size */ ATA_ERING_SIZE = 32, @@ -264,9 +268,13 @@ enum { ATA_EH_REVALIDATE = (1 << 0), ATA_EH_SOFTRESET = (1 << 1), ATA_EH_HARDRESET = (1 << 2), + ATA_EH_SUSPEND = (1 << 3), + ATA_EH_RESUME = (1 << 4), + ATA_EH_PM_FREEZE = (1 << 5), ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, - ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, + ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_SUSPEND | + ATA_EH_RESUME | ATA_EH_PM_FREEZE, /* ata_eh_info->flags */ ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ @@ -458,7 +466,7 @@ struct ata_device { struct ata_ering ering; int spdn_cnt; unsigned int horkage; /* List of broken features */ -#ifdef CONFIG_ATA_ACPI +#ifdef CONFIG_SATA_ACPI /* ACPI objects info */ acpi_handle obj_handle; #endif @@ -685,8 +693,8 @@ extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); extern void ata_port_disable(struct ata_port *); extern void ata_std_ports(struct ata_ioports *ioaddr); #ifdef CONFIG_PCI -extern int ata_pci_init_one (struct pci_dev *pdev, - const struct ata_port_info * const * ppi); +extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, + unsigned int n_ports); extern void ata_pci_remove_one (struct pci_dev *pdev); #ifdef CONFIG_PM extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); @@ -728,6 +736,8 @@ extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); extern int ata_port_online(struct ata_port *ap); extern int ata_port_offline(struct ata_port *ap); #ifdef CONFIG_PM +extern int ata_scsi_device_resume(struct scsi_device *); +extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg); extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); extern void ata_host_resume(struct ata_host *host); #endif @@ -851,11 +861,11 @@ struct pci_bits { unsigned long val; }; -extern int ata_pci_init_native_host(struct ata_host *host); -extern int ata_pci_init_bmdma(struct ata_host *host); +extern int ata_pci_init_native_host(struct ata_host *host, + unsigned int port_mask); extern int ata_pci_prepare_native_host(struct pci_dev *pdev, const struct ata_port_info * const * ppi, - struct ata_host **r_host); + int n_ports, struct ata_host **r_host); extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); #endif /* CONFIG_PCI */ @@ -998,6 +1008,11 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev) return ata_class_absent(dev->class); } +static inline unsigned int ata_dev_ready(const struct ata_device *dev) +{ + return ata_dev_enabled(dev) && !(dev->flags & ATA_DFLAG_SUSPENDED); +} + /* * port helpers */ diff --git a/trunk/include/linux/pci_ids.h b/trunk/include/linux/pci_ids.h index ccd85e4d3b8f..ae849f0d4430 100644 --- a/trunk/include/linux/pci_ids.h +++ b/trunk/include/linux/pci_ids.h @@ -370,7 +370,6 @@ #define PCI_DEVICE_ID_ATI_IXP600_SATA 0x4380 #define PCI_DEVICE_ID_ATI_IXP600_SMBUS 0x4385 #define PCI_DEVICE_ID_ATI_IXP600_IDE 0x438c -#define PCI_DEVICE_ID_ATI_IXP700_SATA 0x4390 #define PCI_VENDOR_ID_VLSI 0x1004 #define PCI_DEVICE_ID_VLSI_82C592 0x0005