aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/processor_throttling.c10
-rw-r--r--drivers/ata/ahci.c4
-rw-r--r--drivers/ata/libata-core.c1
-rw-r--r--drivers/ata/libata-scsi.c15
-rw-r--r--drivers/ata/sata_mv.c31
-rw-r--r--drivers/atm/iphase.c7
-rw-r--r--drivers/atm/nicstar.c117
-rw-r--r--drivers/atm/nicstar.h12
-rw-r--r--drivers/base/attribute_container.c77
-rw-r--r--drivers/base/bus.c17
-rw-r--r--drivers/base/class.c8
-rw-r--r--drivers/base/core.c60
-rw-r--r--drivers/base/cpu.c52
-rw-r--r--drivers/base/dd.c14
-rw-r--r--drivers/base/firmware_class.c18
-rw-r--r--drivers/base/memory.c33
-rw-r--r--drivers/base/node.c29
-rw-r--r--drivers/base/power/main.c106
-rw-r--r--drivers/base/power/power.h23
-rw-r--r--drivers/base/power/sysfs.c2
-rw-r--r--drivers/base/sys.c18
-rw-r--r--drivers/base/topology.c41
-rw-r--r--drivers/base/transport_class.c14
-rw-r--r--drivers/block/cryptoloop.c1
-rw-r--r--drivers/block/viodasd.c2
-rw-r--r--drivers/bluetooth/hci_usb.c24
-rw-r--r--drivers/bluetooth/hci_usb.h5
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/drm/drmP.h1
-rw-r--r--drivers/char/generic_serial.c1
-rw-r--r--drivers/char/hvc_beat.c4
-rw-r--r--drivers/char/hw_random/core.c10
-rw-r--r--drivers/char/hw_random/omap-rng.c26
-rw-r--r--drivers/char/keyboard.c3
-rw-r--r--drivers/char/misc.c13
-rw-r--r--drivers/char/mwave/tp3780i.c14
-rw-r--r--drivers/char/pcmcia/synclink_cs.c10
-rw-r--r--drivers/char/rio/rioboot.c1
-rw-r--r--drivers/char/rio/riocmd.c1
-rw-r--r--drivers/char/rio/rioctrl.c1
-rw-r--r--drivers/char/rio/rioinit.c1
-rw-r--r--drivers/char/rio/riointr.c1
-rw-r--r--drivers/char/rio/rioparam.c1
-rw-r--r--drivers/char/rio/rioroute.c1
-rw-r--r--drivers/char/rio/riotable.c1
-rw-r--r--drivers/char/rio/riotty.c1
-rw-r--r--drivers/char/snsc.h2
-rw-r--r--drivers/char/specialix.c10
-rw-r--r--drivers/char/stallion.c2
-rw-r--r--drivers/char/synclink.c21
-rw-r--r--drivers/char/synclink_gt.c13
-rw-r--r--drivers/char/synclinkmp.c22
-rw-r--r--drivers/char/tpm/tpm_tis.c2
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.c22
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.h5
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.c31
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.h1
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c63
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.h24
-rw-r--r--drivers/clocksource/Makefile1
-rw-r--r--drivers/clocksource/tcb_clksrc.c302
-rw-r--r--drivers/crypto/Kconfig14
-rw-r--r--drivers/crypto/padlock-aes.c320
-rw-r--r--drivers/firewire/fw-device.c3
-rw-r--r--drivers/firewire/fw-transaction.c1
-rw-r--r--drivers/firmware/Kconfig20
-rw-r--r--drivers/firmware/Makefile2
-rw-r--r--drivers/firmware/dcdbas.c5
-rw-r--r--drivers/firmware/iscsi_ibft.c982
-rw-r--r--drivers/firmware/iscsi_ibft_find.c84
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-pxa.c1
-rw-r--r--drivers/i2c/chips/Kconfig1
-rw-r--r--drivers/i2c/chips/tps65010.c101
-rw-r--r--drivers/i2c/i2c-core.c2
-rw-r--r--drivers/ieee1394/nodemgr.c2
-rw-r--r--drivers/infiniband/core/sysfs.c76
-rw-r--r--drivers/infiniband/core/ucm.c62
-rw-r--r--drivers/infiniband/core/user_mad.c111
-rw-r--r--drivers/infiniband/core/uverbs.h4
-rw-r--r--drivers/infiniband/core/uverbs_main.c51
-rw-r--r--drivers/infiniband/hw/amso1100/c2.h1
-rw-r--r--drivers/infiniband/hw/amso1100/c2_provider.c48
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c75
-rw-r--r--drivers/infiniband/hw/ipath/ipath_diag.c10
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c44
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c37
-rw-r--r--drivers/infiniband/hw/mlx4/main.c49
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c48
-rw-r--r--drivers/infiniband/hw/nes/nes.h1
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c48
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c181
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h4
-rw-r--r--drivers/input/keyboard/Kconfig9
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/corgikbd.c1
-rw-r--r--drivers/input/keyboard/sh_keysc.c280
-rw-r--r--drivers/input/keyboard/spitzkbd.c1
-rw-r--r--drivers/input/serio/hp_sdc_mlc.c2
-rw-r--r--drivers/input/touchscreen/ads7846.c40
-rw-r--r--drivers/input/touchscreen/corgi_ts.c1
-rw-r--r--drivers/isdn/hisax/asuscom.c5
-rw-r--r--drivers/isdn/hisax/avm_a1.c27
-rw-r--r--drivers/isdn/hisax/bkm_a4t.c19
-rw-r--r--drivers/isdn/hisax/bkm_a8.c31
-rw-r--r--drivers/isdn/hisax/config.c14
-rw-r--r--drivers/isdn/hisax/elsa.c4
-rw-r--r--drivers/isdn/hisax/elsa_ser.c4
-rw-r--r--drivers/isdn/hisax/gazel.c5
-rw-r--r--drivers/isdn/hisax/hfc_pci.c2
-rw-r--r--drivers/isdn/hisax/hfc_sx.c2
-rw-r--r--drivers/isdn/hisax/hisax.h2
-rw-r--r--drivers/isdn/hisax/hisax_cfg.h2
-rw-r--r--drivers/isdn/hisax/isurf.c13
-rw-r--r--drivers/isdn/hisax/ix1_micro.c9
-rw-r--r--drivers/isdn/hisax/mic.c5
-rw-r--r--drivers/isdn/hisax/netjet.h2
-rw-r--r--drivers/isdn/hisax/niccy.c19
-rw-r--r--drivers/isdn/hisax/nj_s.c3
-rw-r--r--drivers/isdn/hisax/nj_u.c4
-rw-r--r--drivers/isdn/hisax/s0box.c13
-rw-r--r--drivers/isdn/hisax/saphir.c8
-rw-r--r--drivers/isdn/hisax/sportster.c11
-rw-r--r--drivers/isdn/hisax/teleint.c5
-rw-r--r--drivers/isdn/hisax/telespci.c5
-rw-r--r--drivers/isdn/hisax/w6692.c2
-rw-r--r--drivers/leds/Kconfig7
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/led-class.c11
-rw-r--r--drivers/leds/leds-tosa.c132
-rw-r--r--drivers/lguest/lg.h1
-rw-r--r--drivers/macintosh/adb.c2
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c2
-rw-r--r--drivers/media/radio/radio-aimslab.c1
-rw-r--r--drivers/media/video/ir-kbd-i2c.c1
-rw-r--r--drivers/media/video/ov511.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c1
-rw-r--r--drivers/memstick/core/memstick.c33
-rw-r--r--drivers/memstick/core/mspro_block.c4
-rw-r--r--drivers/memstick/host/jmb38x_ms.c16
-rw-r--r--drivers/message/fusion/mptscsih.c122
-rw-r--r--drivers/message/fusion/mptscsih.h2
-rw-r--r--drivers/mfd/Kconfig16
-rw-r--r--drivers/mfd/Makefile3
-rw-r--r--drivers/mfd/htc-egpio.c440
-rw-r--r--drivers/mfd/htc-pasic3.c265
-rw-r--r--drivers/mfd/ucb1x00-ts.c1
-rw-r--r--drivers/misc/Kconfig33
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/atmel_tclib.c161
-rw-r--r--drivers/misc/enclosure.c118
-rw-r--r--drivers/mtd/nand/Kconfig2
-rw-r--r--drivers/mtd/nand/fsl_elbc_nand.c219
-rw-r--r--drivers/mtd/nand/orion_nand.c2
-rw-r--r--drivers/net/3c527.c2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/Makefile3
-rw-r--r--drivers/net/appletalk/cops.c3
-rw-r--r--drivers/net/arm/at91_ether.c4
-rw-r--r--drivers/net/cxgb3/adapter.h1
-rw-r--r--drivers/net/cxgb3/t3cdev.h1
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/ibmveth.c1
-rw-r--r--drivers/net/irda/pxaficp_ir.c11
-rw-r--r--drivers/net/iseries_veth.c3
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h1
-rw-r--r--drivers/net/pasemi_mac.c355
-rw-r--r--drivers/net/pasemi_mac.h35
-rw-r--r--drivers/net/pasemi_mac_ethtool.c159
-rw-r--r--drivers/net/ps3_gelic_net.c81
-rw-r--r--drivers/net/ps3_gelic_net.h20
-rw-r--r--drivers/net/tg3.c52
-rw-r--r--drivers/net/tg3.h1
-rw-r--r--drivers/net/ucc_geth.c8
-rw-r--r--drivers/net/ucc_geth_mii.c11
-rw-r--r--drivers/net/usb/kaweth.c1
-rw-r--r--drivers/net/wireless/b43/leds.c5
-rw-r--r--drivers/net/wireless/b43/main.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c18
-rw-r--r--drivers/of/Kconfig12
-rw-r--r--drivers/of/Makefile2
-rw-r--r--drivers/of/base.c26
-rw-r--r--drivers/of/gpio.c242
-rw-r--r--drivers/of/of_i2c.c115
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/pci/pci-driver.c9
-rw-r--r--drivers/pci/pci-sysfs.c20
-rw-r--r--drivers/pci/probe.c27
-rw-r--r--drivers/pcmcia/Kconfig1
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x270.c1
-rw-r--r--drivers/ps3/ps3-sys-manager.c74
-rw-r--r--drivers/ps3/sys-manager-core.c16
-rw-r--r--drivers/rtc/rtc-sh.c296
-rw-r--r--drivers/s390/cio/ccwgroup.c1
-rw-r--r--drivers/s390/cio/qdio.c2
-rw-r--r--drivers/scsi/3w-9xxx.c9
-rw-r--r--drivers/scsi/3w-xxxx.c9
-rw-r--r--drivers/scsi/aacraid/aachba.c3
-rw-r--r--drivers/scsi/aacraid/aacraid.h4
-rw-r--r--drivers/scsi/aacraid/commctrl.c2
-rw-r--r--drivers/scsi/aacraid/comminit.c1
-rw-r--r--drivers/scsi/aacraid/commsup.c2
-rw-r--r--drivers/scsi/aacraid/dpcsup.c2
-rw-r--r--drivers/scsi/aacraid/linit.c94
-rw-r--r--drivers/scsi/aacraid/rx.c1
-rw-r--r--drivers/scsi/aacraid/sa.c1
-rw-r--r--drivers/scsi/arcmsr/arcmsr.h4
-rw-r--r--drivers/scsi/arcmsr/arcmsr_attr.c163
-rw-r--r--drivers/scsi/ch.c13
-rw-r--r--drivers/scsi/dpt/dpti_i2o.h1
-rw-r--r--drivers/scsi/hosts.c34
-rw-r--r--drivers/scsi/hptiop.c14
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c44
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c25
-rw-r--r--drivers/scsi/ipr.c140
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c484
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h4
-rw-r--r--drivers/scsi/megaraid/mega_common.h1
-rw-r--r--drivers/scsi/megaraid/megaraid_ioctl.h2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c13
-rw-r--r--drivers/scsi/ncr53c8xx.c7
-rw-r--r--drivers/scsi/osst.c76
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c14
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c177
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h4
-rw-r--r--drivers/scsi/raid_class.c73
-rw-r--r--drivers/scsi/scsi_sas_internal.h24
-rw-r--r--drivers/scsi/scsi_sysfs.c150
-rw-r--r--drivers/scsi/scsi_transport_fc.c385
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c107
-rw-r--r--drivers/scsi/scsi_transport_sas.c157
-rw-r--r--drivers/scsi/scsi_transport_spi.c185
-rw-r--r--drivers/scsi/scsi_transport_srp.c26
-rw-r--r--drivers/scsi/sd.c78
-rw-r--r--drivers/scsi/ses.c28
-rw-r--r--drivers/scsi/sg.c36
-rw-r--r--drivers/scsi/st.c82
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h3
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c19
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c14
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c52
-rw-r--r--drivers/serial/imx.c111
-rw-r--r--drivers/serial/mcfserial.c1
-rw-r--r--drivers/serial/of_serial.c4
-rw-r--r--drivers/serial/serial_core.c2
-rw-r--r--drivers/serial/sh-sci.c7
-rw-r--r--drivers/serial/sh-sci.h60
-rw-r--r--drivers/serial/ucc_uart.c16
-rw-r--r--drivers/uio/Kconfig23
-rw-r--r--drivers/uio/Makefile1
-rw-r--r--drivers/uio/uio.c36
-rw-r--r--drivers/uio/uio_cif.c6
-rw-r--r--drivers/uio/uio_smx.c140
-rw-r--r--drivers/usb/atm/usbatm.h1
-rw-r--r--drivers/usb/core/hub.c1
-rw-r--r--drivers/usb/gadget/Kconfig4
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c156
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.h9
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--drivers/usb/host/ehci-orion.c37
-rw-r--r--drivers/usb/misc/appledisplay.c1
-rw-r--r--drivers/usb/serial/io_ti.c1
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c1
-rw-r--r--drivers/video/pxafb.c1
-rw-r--r--drivers/watchdog/sc1200wdt.c2
270 files changed, 7310 insertions, 3625 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1b8e592a8241..0bba3a914e86 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -838,10 +838,10 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
838 * Migrate task to the cpu pointed by pr. 838 * Migrate task to the cpu pointed by pr.
839 */ 839 */
840 saved_mask = current->cpus_allowed; 840 saved_mask = current->cpus_allowed;
841 set_cpus_allowed(current, cpumask_of_cpu(pr->id)); 841 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
842 ret = pr->throttling.acpi_processor_get_throttling(pr); 842 ret = pr->throttling.acpi_processor_get_throttling(pr);
843 /* restore the previous state */ 843 /* restore the previous state */
844 set_cpus_allowed(current, saved_mask); 844 set_cpus_allowed_ptr(current, &saved_mask);
845 845
846 return ret; 846 return ret;
847} 847}
@@ -1025,7 +1025,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1025 * it can be called only for the cpu pointed by pr. 1025 * it can be called only for the cpu pointed by pr.
1026 */ 1026 */
1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1028 set_cpus_allowed(current, cpumask_of_cpu(pr->id)); 1028 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
1029 ret = p_throttling->acpi_processor_set_throttling(pr, 1029 ret = p_throttling->acpi_processor_set_throttling(pr,
1030 t_state.target_state); 1030 t_state.target_state);
1031 } else { 1031 } else {
@@ -1056,7 +1056,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1056 continue; 1056 continue;
1057 } 1057 }
1058 t_state.cpu = i; 1058 t_state.cpu = i;
1059 set_cpus_allowed(current, cpumask_of_cpu(i)); 1059 set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
1060 ret = match_pr->throttling. 1060 ret = match_pr->throttling.
1061 acpi_processor_set_throttling( 1061 acpi_processor_set_throttling(
1062 match_pr, t_state.target_state); 1062 match_pr, t_state.target_state);
@@ -1074,7 +1074,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1074 &t_state); 1074 &t_state);
1075 } 1075 }
1076 /* restore the previous state */ 1076 /* restore the previous state */
1077 set_cpus_allowed(current, saved_mask); 1077 set_cpus_allowed_ptr(current, &saved_mask);
1078 return ret; 1078 return ret;
1079} 1079}
1080 1080
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 739ba3f222e8..986e3324e302 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -273,8 +273,8 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
273static int ahci_pci_device_resume(struct pci_dev *pdev); 273static int ahci_pci_device_resume(struct pci_dev *pdev);
274#endif 274#endif
275 275
276static struct class_device_attribute *ahci_shost_attrs[] = { 276static struct device_attribute *ahci_shost_attrs[] = {
277 &class_device_attr_link_power_management_policy, 277 &dev_attr_link_power_management_policy,
278 NULL 278 NULL
279}; 279};
280 280
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 733eb94d055e..b0b00af90d0e 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -61,7 +61,6 @@
61#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
62#include <scsi/scsi_host.h> 62#include <scsi/scsi_host.h>
63#include <linux/libata.h> 63#include <linux/libata.h>
64#include <asm/semaphore.h>
65#include <asm/byteorder.h> 64#include <asm/byteorder.h>
66#include <linux/cdrom.h> 65#include <linux/cdrom.h>
67 66
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index f3c69a8c1103..a34f32442edf 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -131,10 +131,11 @@ static const char *ata_scsi_lpm_get(enum link_pm policy)
131 return NULL; 131 return NULL;
132} 132}
133 133
134static ssize_t ata_scsi_lpm_put(struct class_device *class_dev, 134static ssize_t ata_scsi_lpm_put(struct device *dev,
135 const char *buf, size_t count) 135 struct device_attribute *attr,
136 const char *buf, size_t count)
136{ 137{
137 struct Scsi_Host *shost = class_to_shost(class_dev); 138 struct Scsi_Host *shost = class_to_shost(dev);
138 struct ata_port *ap = ata_shost_to_port(shost); 139 struct ata_port *ap = ata_shost_to_port(shost);
139 enum link_pm policy = 0; 140 enum link_pm policy = 0;
140 int i; 141 int i;
@@ -162,9 +163,9 @@ static ssize_t ata_scsi_lpm_put(struct class_device *class_dev,
162} 163}
163 164
164static ssize_t 165static ssize_t
165ata_scsi_lpm_show(struct class_device *class_dev, char *buf) 166ata_scsi_lpm_show(struct device *dev, struct device_attribute *attr, char *buf)
166{ 167{
167 struct Scsi_Host *shost = class_to_shost(class_dev); 168 struct Scsi_Host *shost = class_to_shost(dev);
168 struct ata_port *ap = ata_shost_to_port(shost); 169 struct ata_port *ap = ata_shost_to_port(shost);
169 const char *policy = 170 const char *policy =
170 ata_scsi_lpm_get(ap->pm_policy); 171 ata_scsi_lpm_get(ap->pm_policy);
@@ -174,9 +175,9 @@ ata_scsi_lpm_show(struct class_device *class_dev, char *buf)
174 175
175 return snprintf(buf, 23, "%s\n", policy); 176 return snprintf(buf, 23, "%s\n", policy);
176} 177}
177CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, 178DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
178 ata_scsi_lpm_show, ata_scsi_lpm_put); 179 ata_scsi_lpm_show, ata_scsi_lpm_put);
179EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy); 180EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy);
180 181
181static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 182static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
182 void (*done)(struct scsi_cmnd *)) 183 void (*done)(struct scsi_cmnd *))
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 05ff8c776497..d52ce1188327 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -76,6 +76,7 @@
76#include <linux/device.h> 76#include <linux/device.h>
77#include <linux/platform_device.h> 77#include <linux/platform_device.h>
78#include <linux/ata_platform.h> 78#include <linux/ata_platform.h>
79#include <linux/mbus.h>
79#include <scsi/scsi_host.h> 80#include <scsi/scsi_host.h>
80#include <scsi/scsi_cmnd.h> 81#include <scsi/scsi_cmnd.h>
81#include <scsi/scsi_device.h> 82#include <scsi/scsi_device.h>
@@ -370,6 +371,9 @@ enum {
370#define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) 371#define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE)
371#define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC)) 372#define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC))
372 373
374#define WINDOW_CTRL(i) (0x20030 + ((i) << 4))
375#define WINDOW_BASE(i) (0x20034 + ((i) << 4))
376
373enum { 377enum {
374 /* DMA boundary 0xffff is required by the s/g splitting 378 /* DMA boundary 0xffff is required by the s/g splitting
375 * we need on /length/ in mv_fill-sg(). 379 * we need on /length/ in mv_fill-sg().
@@ -2769,6 +2773,27 @@ static int mv_create_dma_pools(struct mv_host_priv *hpriv, struct device *dev)
2769 return 0; 2773 return 0;
2770} 2774}
2771 2775
2776static void mv_conf_mbus_windows(struct mv_host_priv *hpriv,
2777 struct mbus_dram_target_info *dram)
2778{
2779 int i;
2780
2781 for (i = 0; i < 4; i++) {
2782 writel(0, hpriv->base + WINDOW_CTRL(i));
2783 writel(0, hpriv->base + WINDOW_BASE(i));
2784 }
2785
2786 for (i = 0; i < dram->num_cs; i++) {
2787 struct mbus_dram_window *cs = dram->cs + i;
2788
2789 writel(((cs->size - 1) & 0xffff0000) |
2790 (cs->mbus_attr << 8) |
2791 (dram->mbus_dram_target_id << 4) | 1,
2792 hpriv->base + WINDOW_CTRL(i));
2793 writel(cs->base, hpriv->base + WINDOW_BASE(i));
2794 }
2795}
2796
2772/** 2797/**
2773 * mv_platform_probe - handle a positive probe of an soc Marvell 2798 * mv_platform_probe - handle a positive probe of an soc Marvell
2774 * host 2799 * host
@@ -2823,6 +2848,12 @@ static int mv_platform_probe(struct platform_device *pdev)
2823 res->end - res->start + 1); 2848 res->end - res->start + 1);
2824 hpriv->base -= MV_SATAHC0_REG_BASE; 2849 hpriv->base -= MV_SATAHC0_REG_BASE;
2825 2850
2851 /*
2852 * (Re-)program MBUS remapping windows if we are asked to.
2853 */
2854 if (mv_platform_data->dram != NULL)
2855 mv_conf_mbus_windows(hpriv, mv_platform_data->dram);
2856
2826 rc = mv_create_dma_pools(hpriv, &pdev->dev); 2857 rc = mv_create_dma_pools(hpriv, &pdev->dev);
2827 if (rc) 2858 if (rc)
2828 return rc; 2859 return rc;
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 670c093ed25f..5c28ca7380ff 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -60,7 +60,8 @@
60#include <asm/uaccess.h> 60#include <asm/uaccess.h>
61#include <asm/string.h> 61#include <asm/string.h>
62#include <asm/byteorder.h> 62#include <asm/byteorder.h>
63#include <linux/vmalloc.h> 63#include <linux/vmalloc.h>
64#include <linux/jiffies.h>
64#include "iphase.h" 65#include "iphase.h"
65#include "suni.h" 66#include "suni.h"
66#define swap(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8)) 67#define swap(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
@@ -189,7 +190,7 @@ static u16 get_desc (IADEV *dev, struct ia_vcc *iavcc) {
189 int ltimeout; 190 int ltimeout;
190 191
191 ia_hack_tcq (dev); 192 ia_hack_tcq (dev);
192 if(((jiffies - timer)>50)||((dev->ffL.tcq_rd==dev->host_tcq_wr))){ 193 if((time_after(jiffies,timer+50)) || ((dev->ffL.tcq_rd==dev->host_tcq_wr))) {
193 timer = jiffies; 194 timer = jiffies;
194 i=0; 195 i=0;
195 while (i < dev->num_tx_desc) { 196 while (i < dev->num_tx_desc) {
@@ -1225,7 +1226,7 @@ static void rx_intr(struct atm_dev *dev)
1225 iadev->rx_tmp_jif = jiffies; 1226 iadev->rx_tmp_jif = jiffies;
1226 iadev->rxing = 0; 1227 iadev->rxing = 0;
1227 } 1228 }
1228 else if (((jiffies - iadev->rx_tmp_jif) > 50) && 1229 else if ((time_after(jiffies, iadev->rx_tmp_jif + 50)) &&
1229 ((iadev->rx_pkt_cnt - iadev->rx_tmp_cnt) == 0)) { 1230 ((iadev->rx_pkt_cnt - iadev->rx_tmp_cnt) == 0)) {
1230 for (i = 1; i <= iadev->num_rx_desc; i++) 1231 for (i = 1; i <= iadev->num_rx_desc; i++)
1231 free_desc(dev, i); 1232 free_desc(dev, i);
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 0c205b000e8b..38c769f8d2b7 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -125,85 +125,6 @@
125#define ATM_SKB(s) (&(s)->atm) 125#define ATM_SKB(s) (&(s)->atm)
126#endif 126#endif
127 127
128 /* Spinlock debugging stuff */
129#ifdef NS_DEBUG_SPINLOCKS /* See nicstar.h */
130#define ns_grab_int_lock(card,flags) \
131 do { \
132 unsigned long nsdsf, nsdsf2; \
133 local_irq_save(flags); \
134 save_flags(nsdsf); cli();\
135 if (nsdsf & (1<<9)) printk ("nicstar.c: ints %sabled -> enabled.\n", \
136 (flags)&(1<<9)?"en":"dis"); \
137 if (spin_is_locked(&(card)->int_lock) && \
138 (card)->cpu_int == smp_processor_id()) { \
139 printk("nicstar.c: line %d (cpu %d) int_lock already locked at line %d (cpu %d)\n", \
140 __LINE__, smp_processor_id(), (card)->has_int_lock, \
141 (card)->cpu_int); \
142 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
143 } \
144 if (spin_is_locked(&(card)->res_lock) && \
145 (card)->cpu_res == smp_processor_id()) { \
146 printk("nicstar.c: line %d (cpu %d) res_lock locked at line %d (cpu %d)(trying int)\n", \
147 __LINE__, smp_processor_id(), (card)->has_res_lock, \
148 (card)->cpu_res); \
149 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
150 } \
151 spin_lock_irq(&(card)->int_lock); \
152 (card)->has_int_lock = __LINE__; \
153 (card)->cpu_int = smp_processor_id(); \
154 restore_flags(nsdsf); } while (0)
155#define ns_grab_res_lock(card,flags) \
156 do { \
157 unsigned long nsdsf, nsdsf2; \
158 local_irq_save(flags); \
159 save_flags(nsdsf); cli();\
160 if (nsdsf & (1<<9)) printk ("nicstar.c: ints %sabled -> enabled.\n", \
161 (flags)&(1<<9)?"en":"dis"); \
162 if (spin_is_locked(&(card)->res_lock) && \
163 (card)->cpu_res == smp_processor_id()) { \
164 printk("nicstar.c: line %d (cpu %d) res_lock already locked at line %d (cpu %d)\n", \
165 __LINE__, smp_processor_id(), (card)->has_res_lock, \
166 (card)->cpu_res); \
167 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
168 } \
169 spin_lock_irq(&(card)->res_lock); \
170 (card)->has_res_lock = __LINE__; \
171 (card)->cpu_res = smp_processor_id(); \
172 restore_flags(nsdsf); } while (0)
173#define ns_grab_scq_lock(card,scq,flags) \
174 do { \
175 unsigned long nsdsf, nsdsf2; \
176 local_irq_save(flags); \
177 save_flags(nsdsf); cli();\
178 if (nsdsf & (1<<9)) printk ("nicstar.c: ints %sabled -> enabled.\n", \
179 (flags)&(1<<9)?"en":"dis"); \
180 if (spin_is_locked(&(scq)->lock) && \
181 (scq)->cpu_lock == smp_processor_id()) { \
182 printk("nicstar.c: line %d (cpu %d) this scq_lock already locked at line %d (cpu %d)\n", \
183 __LINE__, smp_processor_id(), (scq)->has_lock, \
184 (scq)->cpu_lock); \
185 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
186 } \
187 if (spin_is_locked(&(card)->res_lock) && \
188 (card)->cpu_res == smp_processor_id()) { \
189 printk("nicstar.c: line %d (cpu %d) res_lock locked at line %d (cpu %d)(trying scq)\n", \
190 __LINE__, smp_processor_id(), (card)->has_res_lock, \
191 (card)->cpu_res); \
192 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
193 } \
194 spin_lock_irq(&(scq)->lock); \
195 (scq)->has_lock = __LINE__; \
196 (scq)->cpu_lock = smp_processor_id(); \
197 restore_flags(nsdsf); } while (0)
198#else /* !NS_DEBUG_SPINLOCKS */
199#define ns_grab_int_lock(card,flags) \
200 spin_lock_irqsave(&(card)->int_lock,(flags))
201#define ns_grab_res_lock(card,flags) \
202 spin_lock_irqsave(&(card)->res_lock,(flags))
203#define ns_grab_scq_lock(card,scq,flags) \
204 spin_lock_irqsave(&(scq)->lock,flags)
205#endif /* NS_DEBUG_SPINLOCKS */
206
207 128
208/* Function declarations ******************************************************/ 129/* Function declarations ******************************************************/
209 130
@@ -422,7 +343,7 @@ static u32 ns_read_sram(ns_dev *card, u32 sram_address)
422 sram_address <<= 2; 343 sram_address <<= 2;
423 sram_address &= 0x0007FFFC; /* address must be dword aligned */ 344 sram_address &= 0x0007FFFC; /* address must be dword aligned */
424 sram_address |= 0x50000000; /* SRAM read command */ 345 sram_address |= 0x50000000; /* SRAM read command */
425 ns_grab_res_lock(card, flags); 346 spin_lock_irqsave(&card->res_lock, flags);
426 while (CMD_BUSY(card)); 347 while (CMD_BUSY(card));
427 writel(sram_address, card->membase + CMD); 348 writel(sram_address, card->membase + CMD);
428 while (CMD_BUSY(card)); 349 while (CMD_BUSY(card));
@@ -440,7 +361,7 @@ static void ns_write_sram(ns_dev *card, u32 sram_address, u32 *value, int count)
440 count--; /* count range now is 0..3 instead of 1..4 */ 361 count--; /* count range now is 0..3 instead of 1..4 */
441 c = count; 362 c = count;
442 c <<= 2; /* to use increments of 4 */ 363 c <<= 2; /* to use increments of 4 */
443 ns_grab_res_lock(card, flags); 364 spin_lock_irqsave(&card->res_lock, flags);
444 while (CMD_BUSY(card)); 365 while (CMD_BUSY(card));
445 for (i = 0; i <= c; i += 4) 366 for (i = 0; i <= c; i += 4)
446 writel(*(value++), card->membase + i); 367 writel(*(value++), card->membase + i);
@@ -1166,7 +1087,7 @@ static void push_rxbufs(ns_dev *card, struct sk_buff *skb)
1166 card->lbfqc += 2; 1087 card->lbfqc += 2;
1167 } 1088 }
1168 1089
1169 ns_grab_res_lock(card, flags); 1090 spin_lock_irqsave(&card->res_lock, flags);
1170 1091
1171 while (CMD_BUSY(card)); 1092 while (CMD_BUSY(card));
1172 writel(addr2, card->membase + DR3); 1093 writel(addr2, card->membase + DR3);
@@ -1206,7 +1127,7 @@ static irqreturn_t ns_irq_handler(int irq, void *dev_id)
1206 1127
1207 PRINTK("nicstar%d: NICStAR generated an interrupt\n", card->index); 1128 PRINTK("nicstar%d: NICStAR generated an interrupt\n", card->index);
1208 1129
1209 ns_grab_int_lock(card, flags); 1130 spin_lock_irqsave(&card->int_lock, flags);
1210 1131
1211 stat_r = readl(card->membase + STAT); 1132 stat_r = readl(card->membase + STAT);
1212 1133
@@ -1585,7 +1506,7 @@ static void ns_close(struct atm_vcc *vcc)
1585 unsigned long flags; 1506 unsigned long flags;
1586 1507
1587 addr = NS_RCT + (vcc->vpi << card->vcibits | vcc->vci) * NS_RCT_ENTRY_SIZE; 1508 addr = NS_RCT + (vcc->vpi << card->vcibits | vcc->vci) * NS_RCT_ENTRY_SIZE;
1588 ns_grab_res_lock(card, flags); 1509 spin_lock_irqsave(&card->res_lock, flags);
1589 while(CMD_BUSY(card)); 1510 while(CMD_BUSY(card));
1590 writel(NS_CMD_CLOSE_CONNECTION | addr << 2, card->membase + CMD); 1511 writel(NS_CMD_CLOSE_CONNECTION | addr << 2, card->membase + CMD);
1591 spin_unlock_irqrestore(&card->res_lock, flags); 1512 spin_unlock_irqrestore(&card->res_lock, flags);
@@ -1607,7 +1528,7 @@ static void ns_close(struct atm_vcc *vcc)
1607 NS_SKB(iovb)->iovcnt); 1528 NS_SKB(iovb)->iovcnt);
1608 NS_SKB(iovb)->iovcnt = 0; 1529 NS_SKB(iovb)->iovcnt = 0;
1609 NS_SKB(iovb)->vcc = NULL; 1530 NS_SKB(iovb)->vcc = NULL;
1610 ns_grab_int_lock(card, flags); 1531 spin_lock_irqsave(&card->int_lock, flags);
1611 recycle_iov_buf(card, iovb); 1532 recycle_iov_buf(card, iovb);
1612 spin_unlock_irqrestore(&card->int_lock, flags); 1533 spin_unlock_irqrestore(&card->int_lock, flags);
1613 vc->rx_iov = NULL; 1534 vc->rx_iov = NULL;
@@ -1629,7 +1550,7 @@ static void ns_close(struct atm_vcc *vcc)
1629 1550
1630 for (;;) 1551 for (;;)
1631 { 1552 {
1632 ns_grab_scq_lock(card, scq, flags); 1553 spin_lock_irqsave(&scq->lock, flags);
1633 scqep = scq->next; 1554 scqep = scq->next;
1634 if (scqep == scq->base) 1555 if (scqep == scq->base)
1635 scqep = scq->last; 1556 scqep = scq->last;
@@ -1691,7 +1612,7 @@ static void ns_close(struct atm_vcc *vcc)
1691 unsigned long flags; 1612 unsigned long flags;
1692 scq_info *scq = card->scq0; 1613 scq_info *scq = card->scq0;
1693 1614
1694 ns_grab_scq_lock(card, scq, flags); 1615 spin_lock_irqsave(&scq->lock, flags);
1695 1616
1696 for(i = 0; i < scq->num_entries; i++) { 1617 for(i = 0; i < scq->num_entries; i++) {
1697 if(scq->skb[i] && ATM_SKB(scq->skb[i])->vcc == vcc) { 1618 if(scq->skb[i] && ATM_SKB(scq->skb[i])->vcc == vcc) {
@@ -1892,7 +1813,7 @@ static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
1892 u32 data; 1813 u32 data;
1893 int index; 1814 int index;
1894 1815
1895 ns_grab_scq_lock(card, scq, flags); 1816 spin_lock_irqsave(&scq->lock, flags);
1896 while (scq->tail == scq->next) 1817 while (scq->tail == scq->next)
1897 { 1818 {
1898 if (in_interrupt()) { 1819 if (in_interrupt()) {
@@ -1904,7 +1825,7 @@ static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
1904 scq->full = 1; 1825 scq->full = 1;
1905 spin_unlock_irqrestore(&scq->lock, flags); 1826 spin_unlock_irqrestore(&scq->lock, flags);
1906 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT); 1827 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT);
1907 ns_grab_scq_lock(card, scq, flags); 1828 spin_lock_irqsave(&scq->lock, flags);
1908 1829
1909 if (scq->full) { 1830 if (scq->full) {
1910 spin_unlock_irqrestore(&scq->lock, flags); 1831 spin_unlock_irqrestore(&scq->lock, flags);
@@ -1953,7 +1874,7 @@ static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
1953 if (has_run++) break; 1874 if (has_run++) break;
1954 spin_unlock_irqrestore(&scq->lock, flags); 1875 spin_unlock_irqrestore(&scq->lock, flags);
1955 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT); 1876 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT);
1956 ns_grab_scq_lock(card, scq, flags); 1877 spin_lock_irqsave(&scq->lock, flags);
1957 } 1878 }
1958 1879
1959 if (!scq->full) 1880 if (!scq->full)
@@ -2090,7 +2011,7 @@ static void drain_scq(ns_dev *card, scq_info *scq, int pos)
2090 return; 2011 return;
2091 } 2012 }
2092 2013
2093 ns_grab_scq_lock(card, scq, flags); 2014 spin_lock_irqsave(&scq->lock, flags);
2094 i = (int) (scq->tail - scq->base); 2015 i = (int) (scq->tail - scq->base);
2095 if (++i == scq->num_entries) 2016 if (++i == scq->num_entries)
2096 i = 0; 2017 i = 0;
@@ -2898,7 +2819,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2898 { 2819 {
2899 struct sk_buff *hb; 2820 struct sk_buff *hb;
2900 2821
2901 ns_grab_int_lock(card, flags); 2822 spin_lock_irqsave(&card->int_lock, flags);
2902 hb = skb_dequeue(&card->hbpool.queue); 2823 hb = skb_dequeue(&card->hbpool.queue);
2903 card->hbpool.count--; 2824 card->hbpool.count--;
2904 spin_unlock_irqrestore(&card->int_lock, flags); 2825 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2917,7 +2838,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2917 if (hb == NULL) 2838 if (hb == NULL)
2918 return -ENOMEM; 2839 return -ENOMEM;
2919 NS_SKB_CB(hb)->buf_type = BUF_NONE; 2840 NS_SKB_CB(hb)->buf_type = BUF_NONE;
2920 ns_grab_int_lock(card, flags); 2841 spin_lock_irqsave(&card->int_lock, flags);
2921 skb_queue_tail(&card->hbpool.queue, hb); 2842 skb_queue_tail(&card->hbpool.queue, hb);
2922 card->hbpool.count++; 2843 card->hbpool.count++;
2923 spin_unlock_irqrestore(&card->int_lock, flags); 2844 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2929,7 +2850,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2929 { 2850 {
2930 struct sk_buff *iovb; 2851 struct sk_buff *iovb;
2931 2852
2932 ns_grab_int_lock(card, flags); 2853 spin_lock_irqsave(&card->int_lock, flags);
2933 iovb = skb_dequeue(&card->iovpool.queue); 2854 iovb = skb_dequeue(&card->iovpool.queue);
2934 card->iovpool.count--; 2855 card->iovpool.count--;
2935 spin_unlock_irqrestore(&card->int_lock, flags); 2856 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2948,7 +2869,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2948 if (iovb == NULL) 2869 if (iovb == NULL)
2949 return -ENOMEM; 2870 return -ENOMEM;
2950 NS_SKB_CB(iovb)->buf_type = BUF_NONE; 2871 NS_SKB_CB(iovb)->buf_type = BUF_NONE;
2951 ns_grab_int_lock(card, flags); 2872 spin_lock_irqsave(&card->int_lock, flags);
2952 skb_queue_tail(&card->iovpool.queue, iovb); 2873 skb_queue_tail(&card->iovpool.queue, iovb);
2953 card->iovpool.count++; 2874 card->iovpool.count++;
2954 spin_unlock_irqrestore(&card->int_lock, flags); 2875 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2995,7 +2916,7 @@ static void ns_poll(unsigned long arg)
2995 /* Probably it isn't worth spinning */ 2916 /* Probably it isn't worth spinning */
2996 continue; 2917 continue;
2997 } 2918 }
2998 ns_grab_int_lock(card, flags); 2919 spin_lock_irqsave(&card->int_lock, flags);
2999 2920
3000 stat_w = 0; 2921 stat_w = 0;
3001 stat_r = readl(card->membase + STAT); 2922 stat_r = readl(card->membase + STAT);
@@ -3062,7 +2983,7 @@ static void ns_phy_put(struct atm_dev *dev, unsigned char value,
3062 unsigned long flags; 2983 unsigned long flags;
3063 2984
3064 card = dev->dev_data; 2985 card = dev->dev_data;
3065 ns_grab_res_lock(card, flags); 2986 spin_lock_irqsave(&card->res_lock, flags);
3066 while(CMD_BUSY(card)); 2987 while(CMD_BUSY(card));
3067 writel((unsigned long) value, card->membase + DR0); 2988 writel((unsigned long) value, card->membase + DR0);
3068 writel(NS_CMD_WRITE_UTILITY | 0x00000200 | (addr & 0x000000FF), 2989 writel(NS_CMD_WRITE_UTILITY | 0x00000200 | (addr & 0x000000FF),
@@ -3079,7 +3000,7 @@ static unsigned char ns_phy_get(struct atm_dev *dev, unsigned long addr)
3079 unsigned long data; 3000 unsigned long data;
3080 3001
3081 card = dev->dev_data; 3002 card = dev->dev_data;
3082 ns_grab_res_lock(card, flags); 3003 spin_lock_irqsave(&card->res_lock, flags);
3083 while(CMD_BUSY(card)); 3004 while(CMD_BUSY(card));
3084 writel(NS_CMD_READ_UTILITY | 0x00000200 | (addr & 0x000000FF), 3005 writel(NS_CMD_READ_UTILITY | 0x00000200 | (addr & 0x000000FF),
3085 card->membase + CMD); 3006 card->membase + CMD);
diff --git a/drivers/atm/nicstar.h b/drivers/atm/nicstar.h
index 5997bcb45b59..6010e3daa6a2 100644
--- a/drivers/atm/nicstar.h
+++ b/drivers/atm/nicstar.h
@@ -28,8 +28,6 @@
28 28
29/* Options ********************************************************************/ 29/* Options ********************************************************************/
30 30
31#undef NS_DEBUG_SPINLOCKS
32
33#define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards 31#define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards
34 controlled by the device driver. Must 32 controlled by the device driver. Must
35 be <= 5 */ 33 be <= 5 */
@@ -721,10 +719,6 @@ typedef struct scq_info
721 wait_queue_head_t scqfull_waitq; 719 wait_queue_head_t scqfull_waitq;
722 volatile char full; /* SCQ full indicator */ 720 volatile char full; /* SCQ full indicator */
723 spinlock_t lock; /* SCQ spinlock */ 721 spinlock_t lock; /* SCQ spinlock */
724#ifdef NS_DEBUG_SPINLOCKS
725 volatile long has_lock;
726 volatile int cpu_lock;
727#endif /* NS_DEBUG_SPINLOCKS */
728} scq_info; 722} scq_info;
729 723
730 724
@@ -810,12 +804,6 @@ typedef struct ns_dev
810 unsigned intcnt; /* Interrupt counter */ 804 unsigned intcnt; /* Interrupt counter */
811 spinlock_t int_lock; /* Interrupt lock */ 805 spinlock_t int_lock; /* Interrupt lock */
812 spinlock_t res_lock; /* Card resource lock */ 806 spinlock_t res_lock; /* Card resource lock */
813#ifdef NS_DEBUG_SPINLOCKS
814 volatile long has_int_lock;
815 volatile int cpu_int;
816 volatile long has_res_lock;
817 volatile int cpu_res;
818#endif /* NS_DEBUG_SPINLOCKS */
819} ns_dev; 807} ns_dev;
820 808
821 809
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
index 3b43e8a9f87e..f57652db0a2a 100644
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -27,21 +27,21 @@
27struct internal_container { 27struct internal_container {
28 struct klist_node node; 28 struct klist_node node;
29 struct attribute_container *cont; 29 struct attribute_container *cont;
30 struct class_device classdev; 30 struct device classdev;
31}; 31};
32 32
33static void internal_container_klist_get(struct klist_node *n) 33static void internal_container_klist_get(struct klist_node *n)
34{ 34{
35 struct internal_container *ic = 35 struct internal_container *ic =
36 container_of(n, struct internal_container, node); 36 container_of(n, struct internal_container, node);
37 class_device_get(&ic->classdev); 37 get_device(&ic->classdev);
38} 38}
39 39
40static void internal_container_klist_put(struct klist_node *n) 40static void internal_container_klist_put(struct klist_node *n)
41{ 41{
42 struct internal_container *ic = 42 struct internal_container *ic =
43 container_of(n, struct internal_container, node); 43 container_of(n, struct internal_container, node);
44 class_device_put(&ic->classdev); 44 put_device(&ic->classdev);
45} 45}
46 46
47 47
@@ -53,7 +53,7 @@ static void internal_container_klist_put(struct klist_node *n)
53 * Returns the container associated with this classdev. 53 * Returns the container associated with this classdev.
54 */ 54 */
55struct attribute_container * 55struct attribute_container *
56attribute_container_classdev_to_container(struct class_device *classdev) 56attribute_container_classdev_to_container(struct device *classdev)
57{ 57{
58 struct internal_container *ic = 58 struct internal_container *ic =
59 container_of(classdev, struct internal_container, classdev); 59 container_of(classdev, struct internal_container, classdev);
@@ -110,11 +110,11 @@ attribute_container_unregister(struct attribute_container *cont)
110EXPORT_SYMBOL_GPL(attribute_container_unregister); 110EXPORT_SYMBOL_GPL(attribute_container_unregister);
111 111
112/* private function used as class release */ 112/* private function used as class release */
113static void attribute_container_release(struct class_device *classdev) 113static void attribute_container_release(struct device *classdev)
114{ 114{
115 struct internal_container *ic 115 struct internal_container *ic
116 = container_of(classdev, struct internal_container, classdev); 116 = container_of(classdev, struct internal_container, classdev);
117 struct device *dev = classdev->dev; 117 struct device *dev = classdev->parent;
118 118
119 kfree(ic); 119 kfree(ic);
120 put_device(dev); 120 put_device(dev);
@@ -129,12 +129,12 @@ static void attribute_container_release(struct class_device *classdev)
129 * This function allocates storage for the class device(s) to be 129 * This function allocates storage for the class device(s) to be
130 * attached to dev (one for each matching attribute_container). If no 130 * attached to dev (one for each matching attribute_container). If no
131 * fn is provided, the code will simply register the class device via 131 * fn is provided, the code will simply register the class device via
132 * class_device_add. If a function is provided, it is expected to add 132 * device_add. If a function is provided, it is expected to add
133 * the class device at the appropriate time. One of the things that 133 * the class device at the appropriate time. One of the things that
134 * might be necessary is to allocate and initialise the classdev and 134 * might be necessary is to allocate and initialise the classdev and
135 * then add it a later time. To do this, call this routine for 135 * then add it a later time. To do this, call this routine for
136 * allocation and initialisation and then use 136 * allocation and initialisation and then use
137 * attribute_container_device_trigger() to call class_device_add() on 137 * attribute_container_device_trigger() to call device_add() on
138 * it. Note: after this, the class device contains a reference to dev 138 * it. Note: after this, the class device contains a reference to dev
139 * which is not relinquished until the release of the classdev. 139 * which is not relinquished until the release of the classdev.
140 */ 140 */
@@ -142,7 +142,7 @@ void
142attribute_container_add_device(struct device *dev, 142attribute_container_add_device(struct device *dev,
143 int (*fn)(struct attribute_container *, 143 int (*fn)(struct attribute_container *,
144 struct device *, 144 struct device *,
145 struct class_device *)) 145 struct device *))
146{ 146{
147 struct attribute_container *cont; 147 struct attribute_container *cont;
148 148
@@ -163,11 +163,11 @@ attribute_container_add_device(struct device *dev,
163 } 163 }
164 164
165 ic->cont = cont; 165 ic->cont = cont;
166 class_device_initialize(&ic->classdev); 166 device_initialize(&ic->classdev);
167 ic->classdev.dev = get_device(dev); 167 ic->classdev.parent = get_device(dev);
168 ic->classdev.class = cont->class; 168 ic->classdev.class = cont->class;
169 cont->class->release = attribute_container_release; 169 cont->class->dev_release = attribute_container_release;
170 strcpy(ic->classdev.class_id, dev->bus_id); 170 strcpy(ic->classdev.bus_id, dev->bus_id);
171 if (fn) 171 if (fn)
172 fn(cont, dev, &ic->classdev); 172 fn(cont, dev, &ic->classdev);
173 else 173 else
@@ -195,20 +195,19 @@ attribute_container_add_device(struct device *dev,
195 * @fn: A function to call to remove the device 195 * @fn: A function to call to remove the device
196 * 196 *
197 * This routine triggers device removal. If fn is NULL, then it is 197 * This routine triggers device removal. If fn is NULL, then it is
198 * simply done via class_device_unregister (note that if something 198 * simply done via device_unregister (note that if something
199 * still has a reference to the classdev, then the memory occupied 199 * still has a reference to the classdev, then the memory occupied
200 * will not be freed until the classdev is released). If you want a 200 * will not be freed until the classdev is released). If you want a
201 * two phase release: remove from visibility and then delete the 201 * two phase release: remove from visibility and then delete the
202 * device, then you should use this routine with a fn that calls 202 * device, then you should use this routine with a fn that calls
203 * class_device_del() and then use 203 * device_del() and then use attribute_container_device_trigger()
204 * attribute_container_device_trigger() to do the final put on the 204 * to do the final put on the classdev.
205 * classdev.
206 */ 205 */
207void 206void
208attribute_container_remove_device(struct device *dev, 207attribute_container_remove_device(struct device *dev,
209 void (*fn)(struct attribute_container *, 208 void (*fn)(struct attribute_container *,
210 struct device *, 209 struct device *,
211 struct class_device *)) 210 struct device *))
212{ 211{
213 struct attribute_container *cont; 212 struct attribute_container *cont;
214 213
@@ -224,14 +223,14 @@ attribute_container_remove_device(struct device *dev,
224 continue; 223 continue;
225 224
226 klist_for_each_entry(ic, &cont->containers, node, &iter) { 225 klist_for_each_entry(ic, &cont->containers, node, &iter) {
227 if (dev != ic->classdev.dev) 226 if (dev != ic->classdev.parent)
228 continue; 227 continue;
229 klist_del(&ic->node); 228 klist_del(&ic->node);
230 if (fn) 229 if (fn)
231 fn(cont, dev, &ic->classdev); 230 fn(cont, dev, &ic->classdev);
232 else { 231 else {
233 attribute_container_remove_attrs(&ic->classdev); 232 attribute_container_remove_attrs(&ic->classdev);
234 class_device_unregister(&ic->classdev); 233 device_unregister(&ic->classdev);
235 } 234 }
236 } 235 }
237 } 236 }
@@ -252,7 +251,7 @@ void
252attribute_container_device_trigger(struct device *dev, 251attribute_container_device_trigger(struct device *dev,
253 int (*fn)(struct attribute_container *, 252 int (*fn)(struct attribute_container *,
254 struct device *, 253 struct device *,
255 struct class_device *)) 254 struct device *))
256{ 255{
257 struct attribute_container *cont; 256 struct attribute_container *cont;
258 257
@@ -270,7 +269,7 @@ attribute_container_device_trigger(struct device *dev,
270 } 269 }
271 270
272 klist_for_each_entry(ic, &cont->containers, node, &iter) { 271 klist_for_each_entry(ic, &cont->containers, node, &iter) {
273 if (dev == ic->classdev.dev) 272 if (dev == ic->classdev.parent)
274 fn(cont, dev, &ic->classdev); 273 fn(cont, dev, &ic->classdev);
275 } 274 }
276 } 275 }
@@ -313,11 +312,11 @@ attribute_container_trigger(struct device *dev,
313 * attributes listed in the container 312 * attributes listed in the container
314 */ 313 */
315int 314int
316attribute_container_add_attrs(struct class_device *classdev) 315attribute_container_add_attrs(struct device *classdev)
317{ 316{
318 struct attribute_container *cont = 317 struct attribute_container *cont =
319 attribute_container_classdev_to_container(classdev); 318 attribute_container_classdev_to_container(classdev);
320 struct class_device_attribute **attrs = cont->attrs; 319 struct device_attribute **attrs = cont->attrs;
321 int i, error; 320 int i, error;
322 321
323 BUG_ON(attrs && cont->grp); 322 BUG_ON(attrs && cont->grp);
@@ -329,7 +328,7 @@ attribute_container_add_attrs(struct class_device *classdev)
329 return sysfs_create_group(&classdev->kobj, cont->grp); 328 return sysfs_create_group(&classdev->kobj, cont->grp);
330 329
331 for (i = 0; attrs[i]; i++) { 330 for (i = 0; attrs[i]; i++) {
332 error = class_device_create_file(classdev, attrs[i]); 331 error = device_create_file(classdev, attrs[i]);
333 if (error) 332 if (error)
334 return error; 333 return error;
335 } 334 }
@@ -338,18 +337,18 @@ attribute_container_add_attrs(struct class_device *classdev)
338} 337}
339 338
340/** 339/**
341 * attribute_container_add_class_device - same function as class_device_add 340 * attribute_container_add_class_device - same function as device_add
342 * 341 *
343 * @classdev: the class device to add 342 * @classdev: the class device to add
344 * 343 *
345 * This performs essentially the same function as class_device_add except for 344 * This performs essentially the same function as device_add except for
346 * attribute containers, namely add the classdev to the system and then 345 * attribute containers, namely add the classdev to the system and then
347 * create the attribute files 346 * create the attribute files
348 */ 347 */
349int 348int
350attribute_container_add_class_device(struct class_device *classdev) 349attribute_container_add_class_device(struct device *classdev)
351{ 350{
352 int error = class_device_add(classdev); 351 int error = device_add(classdev);
353 if (error) 352 if (error)
354 return error; 353 return error;
355 return attribute_container_add_attrs(classdev); 354 return attribute_container_add_attrs(classdev);
@@ -364,7 +363,7 @@ attribute_container_add_class_device(struct class_device *classdev)
364int 363int
365attribute_container_add_class_device_adapter(struct attribute_container *cont, 364attribute_container_add_class_device_adapter(struct attribute_container *cont,
366 struct device *dev, 365 struct device *dev,
367 struct class_device *classdev) 366 struct device *classdev)
368{ 367{
369 return attribute_container_add_class_device(classdev); 368 return attribute_container_add_class_device(classdev);
370} 369}
@@ -376,11 +375,11 @@ attribute_container_add_class_device_adapter(struct attribute_container *cont,
376 * 375 *
377 */ 376 */
378void 377void
379attribute_container_remove_attrs(struct class_device *classdev) 378attribute_container_remove_attrs(struct device *classdev)
380{ 379{
381 struct attribute_container *cont = 380 struct attribute_container *cont =
382 attribute_container_classdev_to_container(classdev); 381 attribute_container_classdev_to_container(classdev);
383 struct class_device_attribute **attrs = cont->attrs; 382 struct device_attribute **attrs = cont->attrs;
384 int i; 383 int i;
385 384
386 if (!attrs && !cont->grp) 385 if (!attrs && !cont->grp)
@@ -392,7 +391,7 @@ attribute_container_remove_attrs(struct class_device *classdev)
392 } 391 }
393 392
394 for (i = 0; attrs[i]; i++) 393 for (i = 0; attrs[i]; i++)
395 class_device_remove_file(classdev, attrs[i]); 394 device_remove_file(classdev, attrs[i]);
396} 395}
397 396
398/** 397/**
@@ -401,13 +400,13 @@ attribute_container_remove_attrs(struct class_device *classdev)
401 * @classdev: the class device 400 * @classdev: the class device
402 * 401 *
403 * This function simply removes all the attribute files and then calls 402 * This function simply removes all the attribute files and then calls
404 * class_device_del. 403 * device_del.
405 */ 404 */
406void 405void
407attribute_container_class_device_del(struct class_device *classdev) 406attribute_container_class_device_del(struct device *classdev)
408{ 407{
409 attribute_container_remove_attrs(classdev); 408 attribute_container_remove_attrs(classdev);
410 class_device_del(classdev); 409 device_del(classdev);
411} 410}
412 411
413/** 412/**
@@ -419,16 +418,16 @@ attribute_container_class_device_del(struct class_device *classdev)
419 * Looks up the device in the container's list of class devices and returns 418 * Looks up the device in the container's list of class devices and returns
420 * the corresponding class_device. 419 * the corresponding class_device.
421 */ 420 */
422struct class_device * 421struct device *
423attribute_container_find_class_device(struct attribute_container *cont, 422attribute_container_find_class_device(struct attribute_container *cont,
424 struct device *dev) 423 struct device *dev)
425{ 424{
426 struct class_device *cdev = NULL; 425 struct device *cdev = NULL;
427 struct internal_container *ic; 426 struct internal_container *ic;
428 struct klist_iter iter; 427 struct klist_iter iter;
429 428
430 klist_for_each_entry(ic, &cont->containers, node, &iter) { 429 klist_for_each_entry(ic, &cont->containers, node, &iter) {
431 if (ic->classdev.dev == dev) { 430 if (ic->classdev.parent == dev) {
432 cdev = &ic->classdev; 431 cdev = &ic->classdev;
433 /* FIXME: must exit iterator then break */ 432 /* FIXME: must exit iterator then break */
434 klist_iter_exit(&iter); 433 klist_iter_exit(&iter);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 2d207ad30336..be1cc5143354 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -79,7 +79,7 @@ static void driver_release(struct kobject *kobj)
79{ 79{
80 struct driver_private *drv_priv = to_driver(kobj); 80 struct driver_private *drv_priv = to_driver(kobj);
81 81
82 pr_debug("driver: '%s': %s\n", kobject_name(kobj), __FUNCTION__); 82 pr_debug("driver: '%s': %s\n", kobject_name(kobj), __func__);
83 kfree(drv_priv); 83 kfree(drv_priv);
84} 84}
85 85
@@ -505,14 +505,11 @@ void bus_attach_device(struct device *dev)
505 int ret = 0; 505 int ret = 0;
506 506
507 if (bus) { 507 if (bus) {
508 dev->is_registered = 1;
509 if (bus->p->drivers_autoprobe) 508 if (bus->p->drivers_autoprobe)
510 ret = device_attach(dev); 509 ret = device_attach(dev);
511 WARN_ON(ret < 0); 510 WARN_ON(ret < 0);
512 if (ret >= 0) 511 if (ret >= 0)
513 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); 512 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
514 else
515 dev->is_registered = 0;
516 } 513 }
517} 514}
518 515
@@ -533,10 +530,8 @@ void bus_remove_device(struct device *dev)
533 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 530 sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
534 dev->bus_id); 531 dev->bus_id);
535 device_remove_attrs(dev->bus, dev); 532 device_remove_attrs(dev->bus, dev);
536 if (dev->is_registered) { 533 klist_del(&dev->knode_bus);
537 dev->is_registered = 0; 534
538 klist_del(&dev->knode_bus);
539 }
540 pr_debug("bus: '%s': remove device %s\n", 535 pr_debug("bus: '%s': remove device %s\n",
541 dev->bus->name, dev->bus_id); 536 dev->bus->name, dev->bus_id);
542 device_release_driver(dev); 537 device_release_driver(dev);
@@ -682,19 +677,19 @@ int bus_add_driver(struct device_driver *drv)
682 error = driver_create_file(drv, &driver_attr_uevent); 677 error = driver_create_file(drv, &driver_attr_uevent);
683 if (error) { 678 if (error) {
684 printk(KERN_ERR "%s: uevent attr (%s) failed\n", 679 printk(KERN_ERR "%s: uevent attr (%s) failed\n",
685 __FUNCTION__, drv->name); 680 __func__, drv->name);
686 } 681 }
687 error = driver_add_attrs(bus, drv); 682 error = driver_add_attrs(bus, drv);
688 if (error) { 683 if (error) {
689 /* How the hell do we get out of this pickle? Give up */ 684 /* How the hell do we get out of this pickle? Give up */
690 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", 685 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
691 __FUNCTION__, drv->name); 686 __func__, drv->name);
692 } 687 }
693 error = add_bind_files(drv); 688 error = add_bind_files(drv);
694 if (error) { 689 if (error) {
695 /* Ditto */ 690 /* Ditto */
696 printk(KERN_ERR "%s: add_bind_files(%s) failed\n", 691 printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
697 __FUNCTION__, drv->name); 692 __func__, drv->name);
698 } 693 }
699 694
700 kobject_uevent(&priv->kobj, KOBJ_ADD); 695 kobject_uevent(&priv->kobj, KOBJ_ADD);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 9d915376c313..b4901799308b 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -175,13 +175,13 @@ void class_unregister(struct class *cls)
175 175
176static void class_create_release(struct class *cls) 176static void class_create_release(struct class *cls)
177{ 177{
178 pr_debug("%s called for %s\n", __FUNCTION__, cls->name); 178 pr_debug("%s called for %s\n", __func__, cls->name);
179 kfree(cls); 179 kfree(cls);
180} 180}
181 181
182static void class_device_create_release(struct class_device *class_dev) 182static void class_device_create_release(struct class_device *class_dev)
183{ 183{
184 pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); 184 pr_debug("%s called for %s\n", __func__, class_dev->class_id);
185 kfree(class_dev); 185 kfree(class_dev);
186} 186}
187 187
@@ -189,7 +189,7 @@ static void class_device_create_release(struct class_device *class_dev)
189static int class_device_create_uevent(struct class_device *class_dev, 189static int class_device_create_uevent(struct class_device *class_dev,
190 struct kobj_uevent_env *env) 190 struct kobj_uevent_env *env)
191{ 191{
192 pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); 192 pr_debug("%s called for %s\n", __func__, class_dev->class_id);
193 return 0; 193 return 0;
194} 194}
195 195
@@ -415,7 +415,7 @@ static int class_uevent(struct kset *kset, struct kobject *kobj,
415 struct device *dev = class_dev->dev; 415 struct device *dev = class_dev->dev;
416 int retval = 0; 416 int retval = 0;
417 417
418 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); 418 pr_debug("%s - name = %s\n", __func__, class_dev->class_id);
419 419
420 if (MAJOR(class_dev->devt)) { 420 if (MAJOR(class_dev->devt)) {
421 add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt)); 421 add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt));
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 24198ad01976..9248e0927d08 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -20,7 +20,7 @@
20#include <linux/notifier.h> 20#include <linux/notifier.h>
21#include <linux/genhd.h> 21#include <linux/genhd.h>
22#include <linux/kallsyms.h> 22#include <linux/kallsyms.h>
23#include <asm/semaphore.h> 23#include <linux/semaphore.h>
24 24
25#include "base.h" 25#include "base.h"
26#include "power/power.h" 26#include "power/power.h"
@@ -207,7 +207,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
207 retval = dev->bus->uevent(dev, env); 207 retval = dev->bus->uevent(dev, env);
208 if (retval) 208 if (retval)
209 pr_debug("device: '%s': %s: bus uevent() returned %d\n", 209 pr_debug("device: '%s': %s: bus uevent() returned %d\n",
210 dev->bus_id, __FUNCTION__, retval); 210 dev->bus_id, __func__, retval);
211 } 211 }
212 212
213 /* have the class specific function add its stuff */ 213 /* have the class specific function add its stuff */
@@ -216,7 +216,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
216 if (retval) 216 if (retval)
217 pr_debug("device: '%s': %s: class uevent() " 217 pr_debug("device: '%s': %s: class uevent() "
218 "returned %d\n", dev->bus_id, 218 "returned %d\n", dev->bus_id,
219 __FUNCTION__, retval); 219 __func__, retval);
220 } 220 }
221 221
222 /* have the device type specific fuction add its stuff */ 222 /* have the device type specific fuction add its stuff */
@@ -225,7 +225,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
225 if (retval) 225 if (retval)
226 pr_debug("device: '%s': %s: dev_type uevent() " 226 pr_debug("device: '%s': %s: dev_type uevent() "
227 "returned %d\n", dev->bus_id, 227 "returned %d\n", dev->bus_id,
228 __FUNCTION__, retval); 228 __func__, retval);
229 } 229 }
230 230
231 return retval; 231 return retval;
@@ -782,7 +782,7 @@ int device_add(struct device *dev)
782 goto Done; 782 goto Done;
783 } 783 }
784 784
785 pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); 785 pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
786 786
787 parent = get_device(dev->parent); 787 parent = get_device(dev->parent);
788 setup_parent(dev, parent); 788 setup_parent(dev, parent);
@@ -817,13 +817,12 @@ int device_add(struct device *dev)
817 error = device_add_attrs(dev); 817 error = device_add_attrs(dev);
818 if (error) 818 if (error)
819 goto AttrsError; 819 goto AttrsError;
820 error = dpm_sysfs_add(dev);
821 if (error)
822 goto PMError;
823 device_pm_add(dev);
824 error = bus_add_device(dev); 820 error = bus_add_device(dev);
825 if (error) 821 if (error)
826 goto BusError; 822 goto BusError;
823 error = device_pm_add(dev);
824 if (error)
825 goto PMError;
827 kobject_uevent(&dev->kobj, KOBJ_ADD); 826 kobject_uevent(&dev->kobj, KOBJ_ADD);
828 bus_attach_device(dev); 827 bus_attach_device(dev);
829 if (parent) 828 if (parent)
@@ -843,9 +842,9 @@ int device_add(struct device *dev)
843 Done: 842 Done:
844 put_device(dev); 843 put_device(dev);
845 return error; 844 return error;
846 BusError:
847 device_pm_remove(dev);
848 PMError: 845 PMError:
846 bus_remove_device(dev);
847 BusError:
849 if (dev->bus) 848 if (dev->bus)
850 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 849 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
851 BUS_NOTIFY_DEL_DEVICE, dev); 850 BUS_NOTIFY_DEL_DEVICE, dev);
@@ -981,7 +980,7 @@ void device_del(struct device *dev)
981 */ 980 */
982void device_unregister(struct device *dev) 981void device_unregister(struct device *dev)
983{ 982{
984 pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); 983 pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
985 device_del(dev); 984 device_del(dev);
986 put_device(dev); 985 put_device(dev);
987} 986}
@@ -1076,7 +1075,7 @@ EXPORT_SYMBOL_GPL(device_remove_file);
1076 1075
1077static void device_create_release(struct device *dev) 1076static void device_create_release(struct device *dev)
1078{ 1077{
1079 pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); 1078 pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
1080 kfree(dev); 1079 kfree(dev);
1081} 1080}
1082 1081
@@ -1164,35 +1163,6 @@ void device_destroy(struct class *class, dev_t devt)
1164} 1163}
1165EXPORT_SYMBOL_GPL(device_destroy); 1164EXPORT_SYMBOL_GPL(device_destroy);
1166 1165
1167#ifdef CONFIG_PM_SLEEP
1168/**
1169 * destroy_suspended_device - asks the PM core to remove a suspended device
1170 * @class: pointer to the struct class that this device was registered with
1171 * @devt: the dev_t of the device that was previously registered
1172 *
1173 * This call notifies the PM core of the necessity to unregister a suspended
1174 * device created with a call to device_create() (devices cannot be
1175 * unregistered directly while suspended, since the PM core holds their
1176 * semaphores at that time).
1177 *
1178 * It can only be called within the scope of a system sleep transition. In
1179 * practice this means it has to be directly or indirectly invoked either by
1180 * a suspend or resume method, or by the PM core (e.g. via
1181 * disable_nonboot_cpus() or enable_nonboot_cpus()).
1182 */
1183void destroy_suspended_device(struct class *class, dev_t devt)
1184{
1185 struct device *dev;
1186
1187 dev = class_find_device(class, &devt, __match_devt);
1188 if (dev) {
1189 device_pm_schedule_removal(dev);
1190 put_device(dev);
1191 }
1192}
1193EXPORT_SYMBOL_GPL(destroy_suspended_device);
1194#endif /* CONFIG_PM_SLEEP */
1195
1196/** 1166/**
1197 * device_rename - renames a device 1167 * device_rename - renames a device
1198 * @dev: the pointer to the struct device to be renamed 1168 * @dev: the pointer to the struct device to be renamed
@@ -1210,7 +1180,7 @@ int device_rename(struct device *dev, char *new_name)
1210 return -EINVAL; 1180 return -EINVAL;
1211 1181
1212 pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id, 1182 pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id,
1213 __FUNCTION__, new_name); 1183 __func__, new_name);
1214 1184
1215#ifdef CONFIG_SYSFS_DEPRECATED 1185#ifdef CONFIG_SYSFS_DEPRECATED
1216 if ((dev->class) && (dev->parent)) 1186 if ((dev->class) && (dev->parent))
@@ -1249,7 +1219,7 @@ int device_rename(struct device *dev, char *new_name)
1249 dev->bus_id); 1219 dev->bus_id);
1250 if (error) { 1220 if (error) {
1251 dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", 1221 dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n",
1252 __FUNCTION__, error); 1222 __func__, error);
1253 } 1223 }
1254 } 1224 }
1255#endif 1225#endif
@@ -1325,7 +1295,7 @@ int device_move(struct device *dev, struct device *new_parent)
1325 new_parent_kobj = get_device_parent(dev, new_parent); 1295 new_parent_kobj = get_device_parent(dev, new_parent);
1326 1296
1327 pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, 1297 pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id,
1328 __FUNCTION__, new_parent ? new_parent->bus_id : "<NULL>"); 1298 __func__, new_parent ? new_parent->bus_id : "<NULL>");
1329 error = kobject_move(&dev->kobj, new_parent_kobj); 1299 error = kobject_move(&dev->kobj, new_parent_kobj);
1330 if (error) { 1300 if (error) {
1331 cleanup_glue_dir(dev, new_parent_kobj); 1301 cleanup_glue_dir(dev, new_parent_kobj);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 499b003f9278..6fe417429977 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -28,7 +28,7 @@ static ssize_t show_online(struct sys_device *dev, char *buf)
28 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); 28 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id));
29} 29}
30 30
31static ssize_t store_online(struct sys_device *dev, const char *buf, 31static ssize_t __ref store_online(struct sys_device *dev, const char *buf,
32 size_t count) 32 size_t count)
33{ 33{
34 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 34 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
@@ -55,7 +55,7 @@ static ssize_t store_online(struct sys_device *dev, const char *buf,
55} 55}
56static SYSDEV_ATTR(online, 0644, show_online, store_online); 56static SYSDEV_ATTR(online, 0644, show_online, store_online);
57 57
58static void __devinit register_cpu_control(struct cpu *cpu) 58static void __cpuinit register_cpu_control(struct cpu *cpu)
59{ 59{
60 sysdev_create_file(&cpu->sysdev, &attr_online); 60 sysdev_create_file(&cpu->sysdev, &attr_online);
61} 61}
@@ -103,6 +103,51 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
103#endif 103#endif
104 104
105/* 105/*
106 * Print cpu online, possible, present, and system maps
107 */
108static ssize_t print_cpus_map(char *buf, cpumask_t *map)
109{
110 int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *map);
111
112 buf[n++] = '\n';
113 buf[n] = '\0';
114 return n;
115}
116
117#define print_cpus_func(type) \
118static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \
119{ \
120 return print_cpus_map(buf, &cpu_##type##_map); \
121} \
122struct sysdev_class_attribute attr_##type##_map = \
123 _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)
124
125print_cpus_func(online);
126print_cpus_func(possible);
127print_cpus_func(present);
128
129struct sysdev_class_attribute *cpu_state_attr[] = {
130 &attr_online_map,
131 &attr_possible_map,
132 &attr_present_map,
133};
134
135static int cpu_states_init(void)
136{
137 int i;
138 int err = 0;
139
140 for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) {
141 int ret;
142 ret = sysdev_class_create_file(&cpu_sysdev_class,
143 cpu_state_attr[i]);
144 if (!err)
145 err = ret;
146 }
147 return err;
148}
149
150/*
106 * register_cpu - Setup a sysfs device for a CPU. 151 * register_cpu - Setup a sysfs device for a CPU.
107 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in 152 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
108 * sysfs for this CPU. 153 * sysfs for this CPU.
@@ -147,6 +192,9 @@ int __init cpu_dev_init(void)
147 int err; 192 int err;
148 193
149 err = sysdev_class_register(&cpu_sysdev_class); 194 err = sysdev_class_register(&cpu_sysdev_class);
195 if (!err)
196 err = cpu_states_init();
197
150#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 198#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
151 if (!err) 199 if (!err)
152 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); 200 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a5cde94bb982..3ac443b2ac08 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -30,12 +30,12 @@ static void driver_bound(struct device *dev)
30{ 30{
31 if (klist_node_attached(&dev->knode_driver)) { 31 if (klist_node_attached(&dev->knode_driver)) {
32 printk(KERN_WARNING "%s: device %s already bound\n", 32 printk(KERN_WARNING "%s: device %s already bound\n",
33 __FUNCTION__, kobject_name(&dev->kobj)); 33 __func__, kobject_name(&dev->kobj));
34 return; 34 return;
35 } 35 }
36 36
37 pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id, 37 pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id,
38 __FUNCTION__, dev->driver->name); 38 __func__, dev->driver->name);
39 39
40 if (dev->bus) 40 if (dev->bus)
41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
@@ -104,13 +104,13 @@ static int really_probe(struct device *dev, struct device_driver *drv)
104 104
105 atomic_inc(&probe_count); 105 atomic_inc(&probe_count);
106 pr_debug("bus: '%s': %s: probing driver %s with device %s\n", 106 pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
107 drv->bus->name, __FUNCTION__, drv->name, dev->bus_id); 107 drv->bus->name, __func__, drv->name, dev->bus_id);
108 WARN_ON(!list_empty(&dev->devres_head)); 108 WARN_ON(!list_empty(&dev->devres_head));
109 109
110 dev->driver = drv; 110 dev->driver = drv;
111 if (driver_sysfs_add(dev)) { 111 if (driver_sysfs_add(dev)) {
112 printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", 112 printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
113 __FUNCTION__, dev->bus_id); 113 __func__, dev->bus_id);
114 goto probe_failed; 114 goto probe_failed;
115 } 115 }
116 116
@@ -127,7 +127,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
127 driver_bound(dev); 127 driver_bound(dev);
128 ret = 1; 128 ret = 1;
129 pr_debug("bus: '%s': %s: bound device %s to driver %s\n", 129 pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
130 drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); 130 drv->bus->name, __func__, dev->bus_id, drv->name);
131 goto done; 131 goto done;
132 132
133probe_failed: 133probe_failed:
@@ -160,7 +160,7 @@ done:
160 */ 160 */
161int driver_probe_done(void) 161int driver_probe_done(void)
162{ 162{
163 pr_debug("%s: probe_count = %d\n", __FUNCTION__, 163 pr_debug("%s: probe_count = %d\n", __func__,
164 atomic_read(&probe_count)); 164 atomic_read(&probe_count));
165 if (atomic_read(&probe_count)) 165 if (atomic_read(&probe_count))
166 return -EBUSY; 166 return -EBUSY;
@@ -194,7 +194,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
194 goto done; 194 goto done;
195 195
196 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 196 pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
197 drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); 197 drv->bus->name, __func__, dev->bus_id, drv->name);
198 198
199 ret = really_probe(dev, drv); 199 ret = really_probe(dev, drv);
200 200
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 4a1b9bfc5471..1fef7df8c9d6 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -156,7 +156,7 @@ static ssize_t firmware_loading_store(struct device *dev,
156 } 156 }
157 /* fallthrough */ 157 /* fallthrough */
158 default: 158 default:
159 printk(KERN_ERR "%s: unexpected value (%d)\n", __FUNCTION__, 159 printk(KERN_ERR "%s: unexpected value (%d)\n", __func__,
160 loading); 160 loading);
161 /* fallthrough */ 161 /* fallthrough */
162 case -1: 162 case -1:
@@ -209,7 +209,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
209 new_size = ALIGN(min_size, PAGE_SIZE); 209 new_size = ALIGN(min_size, PAGE_SIZE);
210 new_data = vmalloc(new_size); 210 new_data = vmalloc(new_size);
211 if (!new_data) { 211 if (!new_data) {
212 printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__); 212 printk(KERN_ERR "%s: unable to alloc buffer\n", __func__);
213 /* Make sure that we don't keep incomplete data */ 213 /* Make sure that we don't keep incomplete data */
214 fw_load_abort(fw_priv); 214 fw_load_abort(fw_priv);
215 return -ENOMEM; 215 return -ENOMEM;
@@ -307,7 +307,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
307 *dev_p = NULL; 307 *dev_p = NULL;
308 308
309 if (!fw_priv || !f_dev) { 309 if (!fw_priv || !f_dev) {
310 printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__); 310 printk(KERN_ERR "%s: kmalloc failed\n", __func__);
311 retval = -ENOMEM; 311 retval = -ENOMEM;
312 goto error_kfree; 312 goto error_kfree;
313 } 313 }
@@ -328,7 +328,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
328 retval = device_register(f_dev); 328 retval = device_register(f_dev);
329 if (retval) { 329 if (retval) {
330 printk(KERN_ERR "%s: device_register failed\n", 330 printk(KERN_ERR "%s: device_register failed\n",
331 __FUNCTION__); 331 __func__);
332 goto error_kfree; 332 goto error_kfree;
333 } 333 }
334 *dev_p = f_dev; 334 *dev_p = f_dev;
@@ -362,14 +362,14 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
362 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); 362 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
363 if (retval) { 363 if (retval) {
364 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", 364 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
365 __FUNCTION__); 365 __func__);
366 goto error_unreg; 366 goto error_unreg;
367 } 367 }
368 368
369 retval = device_create_file(f_dev, &dev_attr_loading); 369 retval = device_create_file(f_dev, &dev_attr_loading);
370 if (retval) { 370 if (retval) {
371 printk(KERN_ERR "%s: device_create_file failed\n", 371 printk(KERN_ERR "%s: device_create_file failed\n",
372 __FUNCTION__); 372 __func__);
373 goto error_unreg; 373 goto error_unreg;
374 } 374 }
375 375
@@ -399,7 +399,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
399 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); 399 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
400 if (!firmware) { 400 if (!firmware) {
401 printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", 401 printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n",
402 __FUNCTION__); 402 __func__);
403 retval = -ENOMEM; 403 retval = -ENOMEM;
404 goto out; 404 goto out;
405 } 405 }
@@ -570,13 +570,13 @@ firmware_class_init(void)
570 int error; 570 int error;
571 error = class_register(&firmware_class); 571 error = class_register(&firmware_class);
572 if (error) { 572 if (error) {
573 printk(KERN_ERR "%s: class_register failed\n", __FUNCTION__); 573 printk(KERN_ERR "%s: class_register failed\n", __func__);
574 return error; 574 return error;
575 } 575 }
576 error = class_create_file(&firmware_class, &class_attr_timeout); 576 error = class_create_file(&firmware_class, &class_attr_timeout);
577 if (error) { 577 if (error) {
578 printk(KERN_ERR "%s: class_create_file failed\n", 578 printk(KERN_ERR "%s: class_create_file failed\n",
579 __FUNCTION__); 579 __func__);
580 class_unregister(&firmware_class); 580 class_unregister(&firmware_class);
581 } 581 }
582 return error; 582 return error;
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 7ae413fdd5fc..8ce6de5a7e28 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -20,6 +20,7 @@
20#include <linux/kobject.h> 20#include <linux/kobject.h>
21#include <linux/memory_hotplug.h> 21#include <linux/memory_hotplug.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/mutex.h>
23#include <asm/atomic.h> 24#include <asm/atomic.h>
24#include <asm/uaccess.h> 25#include <asm/uaccess.h>
25 26
@@ -61,8 +62,8 @@ void unregister_memory_notifier(struct notifier_block *nb)
61/* 62/*
62 * register_memory - Setup a sysfs device for a memory block 63 * register_memory - Setup a sysfs device for a memory block
63 */ 64 */
64int register_memory(struct memory_block *memory, struct mem_section *section, 65static
65 struct node *root) 66int register_memory(struct memory_block *memory, struct mem_section *section)
66{ 67{
67 int error; 68 int error;
68 69
@@ -70,26 +71,18 @@ int register_memory(struct memory_block *memory, struct mem_section *section,
70 memory->sysdev.id = __section_nr(section); 71 memory->sysdev.id = __section_nr(section);
71 72
72 error = sysdev_register(&memory->sysdev); 73 error = sysdev_register(&memory->sysdev);
73
74 if (root && !error)
75 error = sysfs_create_link(&root->sysdev.kobj,
76 &memory->sysdev.kobj,
77 kobject_name(&memory->sysdev.kobj));
78
79 return error; 74 return error;
80} 75}
81 76
82static void 77static void
83unregister_memory(struct memory_block *memory, struct mem_section *section, 78unregister_memory(struct memory_block *memory, struct mem_section *section)
84 struct node *root)
85{ 79{
86 BUG_ON(memory->sysdev.cls != &memory_sysdev_class); 80 BUG_ON(memory->sysdev.cls != &memory_sysdev_class);
87 BUG_ON(memory->sysdev.id != __section_nr(section)); 81 BUG_ON(memory->sysdev.id != __section_nr(section));
88 82
83 /* drop the ref. we got in remove_memory_block() */
84 kobject_put(&memory->sysdev.kobj);
89 sysdev_unregister(&memory->sysdev); 85 sysdev_unregister(&memory->sysdev);
90 if (root)
91 sysfs_remove_link(&root->sysdev.kobj,
92 kobject_name(&memory->sysdev.kobj));
93} 86}
94 87
95/* 88/*
@@ -193,7 +186,7 @@ memory_block_action(struct memory_block *mem, unsigned long action)
193 break; 186 break;
194 default: 187 default:
195 printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", 188 printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n",
196 __FUNCTION__, mem, action, action); 189 __func__, mem, action, action);
197 WARN_ON(1); 190 WARN_ON(1);
198 ret = -EINVAL; 191 ret = -EINVAL;
199 } 192 }
@@ -205,7 +198,7 @@ static int memory_block_change_state(struct memory_block *mem,
205 unsigned long to_state, unsigned long from_state_req) 198 unsigned long to_state, unsigned long from_state_req)
206{ 199{
207 int ret = 0; 200 int ret = 0;
208 down(&mem->state_sem); 201 mutex_lock(&mem->state_mutex);
209 202
210 if (mem->state != from_state_req) { 203 if (mem->state != from_state_req) {
211 ret = -EINVAL; 204 ret = -EINVAL;
@@ -217,7 +210,7 @@ static int memory_block_change_state(struct memory_block *mem,
217 mem->state = to_state; 210 mem->state = to_state;
218 211
219out: 212out:
220 up(&mem->state_sem); 213 mutex_unlock(&mem->state_mutex);
221 return ret; 214 return ret;
222} 215}
223 216
@@ -341,10 +334,10 @@ static int add_memory_block(unsigned long node_id, struct mem_section *section,
341 334
342 mem->phys_index = __section_nr(section); 335 mem->phys_index = __section_nr(section);
343 mem->state = state; 336 mem->state = state;
344 init_MUTEX(&mem->state_sem); 337 mutex_init(&mem->state_mutex);
345 mem->phys_device = phys_device; 338 mem->phys_device = phys_device;
346 339
347 ret = register_memory(mem, section, NULL); 340 ret = register_memory(mem, section);
348 if (!ret) 341 if (!ret)
349 ret = mem_create_simple_file(mem, phys_index); 342 ret = mem_create_simple_file(mem, phys_index);
350 if (!ret) 343 if (!ret)
@@ -395,7 +388,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section,
395 mem_remove_simple_file(mem, phys_index); 388 mem_remove_simple_file(mem, phys_index);
396 mem_remove_simple_file(mem, state); 389 mem_remove_simple_file(mem, state);
397 mem_remove_simple_file(mem, phys_device); 390 mem_remove_simple_file(mem, phys_device);
398 unregister_memory(mem, section, NULL); 391 unregister_memory(mem, section);
399 392
400 return 0; 393 return 0;
401} 394}
@@ -451,6 +444,6 @@ int __init memory_dev_init(void)
451 ret = err; 444 ret = err;
452out: 445out:
453 if (ret) 446 if (ret)
454 printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret); 447 printk(KERN_ERR "%s() failed: %d\n", __func__, ret);
455 return ret; 448 return ret;
456} 449}
diff --git a/drivers/base/node.c b/drivers/base/node.c
index e59861f18ce5..12fde2d03d69 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -19,21 +19,34 @@ static struct sysdev_class node_class = {
19}; 19};
20 20
21 21
22static ssize_t node_read_cpumap(struct sys_device * dev, char * buf) 22static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf)
23{ 23{
24 struct node *node_dev = to_node(dev); 24 struct node *node_dev = to_node(dev);
25 cpumask_t mask = node_to_cpumask(node_dev->sysdev.id); 25 node_to_cpumask_ptr(mask, node_dev->sysdev.id);
26 int len; 26 int len;
27 27
28 /* 2004/06/03: buf currently PAGE_SIZE, need > 1 char per 4 bits. */ 28 /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */
29 BUILD_BUG_ON(MAX_NUMNODES/4 > PAGE_SIZE/2); 29 BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1));
30 30
31 len = cpumask_scnprintf(buf, PAGE_SIZE-1, mask); 31 len = type?
32 len += sprintf(buf + len, "\n"); 32 cpulist_scnprintf(buf, PAGE_SIZE-2, *mask):
33 cpumask_scnprintf(buf, PAGE_SIZE-2, *mask);
34 buf[len++] = '\n';
35 buf[len] = '\0';
33 return len; 36 return len;
34} 37}
35 38
36static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumap, NULL); 39static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf)
40{
41 return node_read_cpumap(dev, 0, buf);
42}
43static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf)
44{
45 return node_read_cpumap(dev, 1, buf);
46}
47
48static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL);
49static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
37 50
38#define K(x) ((x) << (PAGE_SHIFT - 10)) 51#define K(x) ((x) << (PAGE_SHIFT - 10))
39static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) 52static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
@@ -149,6 +162,7 @@ int register_node(struct node *node, int num, struct node *parent)
149 162
150 if (!error){ 163 if (!error){
151 sysdev_create_file(&node->sysdev, &attr_cpumap); 164 sysdev_create_file(&node->sysdev, &attr_cpumap);
165 sysdev_create_file(&node->sysdev, &attr_cpulist);
152 sysdev_create_file(&node->sysdev, &attr_meminfo); 166 sysdev_create_file(&node->sysdev, &attr_meminfo);
153 sysdev_create_file(&node->sysdev, &attr_numastat); 167 sysdev_create_file(&node->sysdev, &attr_numastat);
154 sysdev_create_file(&node->sysdev, &attr_distance); 168 sysdev_create_file(&node->sysdev, &attr_distance);
@@ -166,6 +180,7 @@ int register_node(struct node *node, int num, struct node *parent)
166void unregister_node(struct node *node) 180void unregister_node(struct node *node)
167{ 181{
168 sysdev_remove_file(&node->sysdev, &attr_cpumap); 182 sysdev_remove_file(&node->sysdev, &attr_cpumap);
183 sysdev_remove_file(&node->sysdev, &attr_cpulist);
169 sysdev_remove_file(&node->sysdev, &attr_meminfo); 184 sysdev_remove_file(&node->sysdev, &attr_meminfo);
170 sysdev_remove_file(&node->sysdev, &attr_numastat); 185 sysdev_remove_file(&node->sysdev, &attr_numastat);
171 sysdev_remove_file(&node->sysdev, &attr_distance); 186 sysdev_remove_file(&node->sysdev, &attr_distance);
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index d887d5cb5bef..c4568b82875b 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -50,26 +50,40 @@
50LIST_HEAD(dpm_active); 50LIST_HEAD(dpm_active);
51static LIST_HEAD(dpm_off); 51static LIST_HEAD(dpm_off);
52static LIST_HEAD(dpm_off_irq); 52static LIST_HEAD(dpm_off_irq);
53static LIST_HEAD(dpm_destroy);
54 53
55static DEFINE_MUTEX(dpm_list_mtx); 54static DEFINE_MUTEX(dpm_list_mtx);
56 55
57static DECLARE_RWSEM(pm_sleep_rwsem); 56/* 'true' if all devices have been suspended, protected by dpm_list_mtx */
58 57static bool all_sleeping;
59int (*platform_enable_wakeup)(struct device *dev, int is_on);
60 58
61/** 59/**
62 * device_pm_add - add a device to the list of active devices 60 * device_pm_add - add a device to the list of active devices
63 * @dev: Device to be added to the list 61 * @dev: Device to be added to the list
64 */ 62 */
65void device_pm_add(struct device *dev) 63int device_pm_add(struct device *dev)
66{ 64{
65 int error = 0;
66
67 pr_debug("PM: Adding info for %s:%s\n", 67 pr_debug("PM: Adding info for %s:%s\n",
68 dev->bus ? dev->bus->name : "No Bus", 68 dev->bus ? dev->bus->name : "No Bus",
69 kobject_name(&dev->kobj)); 69 kobject_name(&dev->kobj));
70 mutex_lock(&dpm_list_mtx); 70 mutex_lock(&dpm_list_mtx);
71 list_add_tail(&dev->power.entry, &dpm_active); 71 if ((dev->parent && dev->parent->power.sleeping) || all_sleeping) {
72 if (dev->parent->power.sleeping)
73 dev_warn(dev,
74 "parent %s is sleeping, will not add\n",
75 dev->parent->bus_id);
76 else
77 dev_warn(dev, "devices are sleeping, will not add\n");
78 WARN_ON(true);
79 error = -EBUSY;
80 } else {
81 error = dpm_sysfs_add(dev);
82 if (!error)
83 list_add_tail(&dev->power.entry, &dpm_active);
84 }
72 mutex_unlock(&dpm_list_mtx); 85 mutex_unlock(&dpm_list_mtx);
86 return error;
73} 87}
74 88
75/** 89/**
@@ -89,50 +103,6 @@ void device_pm_remove(struct device *dev)
89 mutex_unlock(&dpm_list_mtx); 103 mutex_unlock(&dpm_list_mtx);
90} 104}
91 105
92/**
93 * device_pm_schedule_removal - schedule the removal of a suspended device
94 * @dev: Device to destroy
95 *
96 * Moves the device to the dpm_destroy list for further processing by
97 * unregister_dropped_devices().
98 */
99void device_pm_schedule_removal(struct device *dev)
100{
101 pr_debug("PM: Preparing for removal: %s:%s\n",
102 dev->bus ? dev->bus->name : "No Bus",
103 kobject_name(&dev->kobj));
104 mutex_lock(&dpm_list_mtx);
105 list_move_tail(&dev->power.entry, &dpm_destroy);
106 mutex_unlock(&dpm_list_mtx);
107}
108EXPORT_SYMBOL_GPL(device_pm_schedule_removal);
109
110/**
111 * pm_sleep_lock - mutual exclusion for registration and suspend
112 *
113 * Returns 0 if no suspend is underway and device registration
114 * may proceed, otherwise -EBUSY.
115 */
116int pm_sleep_lock(void)
117{
118 if (down_read_trylock(&pm_sleep_rwsem))
119 return 0;
120
121 return -EBUSY;
122}
123
124/**
125 * pm_sleep_unlock - mutual exclusion for registration and suspend
126 *
127 * This routine undoes the effect of device_pm_add_lock
128 * when a device's registration is complete.
129 */
130void pm_sleep_unlock(void)
131{
132 up_read(&pm_sleep_rwsem);
133}
134
135
136/*------------------------- Resume routines -------------------------*/ 106/*------------------------- Resume routines -------------------------*/
137 107
138/** 108/**
@@ -242,11 +212,13 @@ static int resume_device(struct device *dev)
242static void dpm_resume(void) 212static void dpm_resume(void)
243{ 213{
244 mutex_lock(&dpm_list_mtx); 214 mutex_lock(&dpm_list_mtx);
215 all_sleeping = false;
245 while(!list_empty(&dpm_off)) { 216 while(!list_empty(&dpm_off)) {
246 struct list_head *entry = dpm_off.next; 217 struct list_head *entry = dpm_off.next;
247 struct device *dev = to_device(entry); 218 struct device *dev = to_device(entry);
248 219
249 list_move_tail(entry, &dpm_active); 220 list_move_tail(entry, &dpm_active);
221 dev->power.sleeping = false;
250 mutex_unlock(&dpm_list_mtx); 222 mutex_unlock(&dpm_list_mtx);
251 resume_device(dev); 223 resume_device(dev);
252 mutex_lock(&dpm_list_mtx); 224 mutex_lock(&dpm_list_mtx);
@@ -255,26 +227,6 @@ static void dpm_resume(void)
255} 227}
256 228
257/** 229/**
258 * unregister_dropped_devices - Unregister devices scheduled for removal
259 *
260 * Unregister all devices on the dpm_destroy list.
261 */
262static void unregister_dropped_devices(void)
263{
264 mutex_lock(&dpm_list_mtx);
265 while (!list_empty(&dpm_destroy)) {
266 struct list_head *entry = dpm_destroy.next;
267 struct device *dev = to_device(entry);
268
269 mutex_unlock(&dpm_list_mtx);
270 /* This also removes the device from the list */
271 device_unregister(dev);
272 mutex_lock(&dpm_list_mtx);
273 }
274 mutex_unlock(&dpm_list_mtx);
275}
276
277/**
278 * device_resume - Restore state of each device in system. 230 * device_resume - Restore state of each device in system.
279 * 231 *
280 * Resume all the devices, unlock them all, and allow new 232 * Resume all the devices, unlock them all, and allow new
@@ -284,8 +236,6 @@ void device_resume(void)
284{ 236{
285 might_sleep(); 237 might_sleep();
286 dpm_resume(); 238 dpm_resume();
287 unregister_dropped_devices();
288 up_write(&pm_sleep_rwsem);
289} 239}
290EXPORT_SYMBOL_GPL(device_resume); 240EXPORT_SYMBOL_GPL(device_resume);
291 241
@@ -377,11 +327,6 @@ static int suspend_device(struct device *dev, pm_message_t state)
377 327
378 down(&dev->sem); 328 down(&dev->sem);
379 329
380 if (dev->power.power_state.event) {
381 dev_dbg(dev, "PM: suspend %d-->%d\n",
382 dev->power.power_state.event, state.event);
383 }
384
385 if (dev->class && dev->class->suspend) { 330 if (dev->class && dev->class->suspend) {
386 suspend_device_dbg(dev, state, "class "); 331 suspend_device_dbg(dev, state, "class ");
387 error = dev->class->suspend(dev, state); 332 error = dev->class->suspend(dev, state);
@@ -426,6 +371,9 @@ static int dpm_suspend(pm_message_t state)
426 struct list_head *entry = dpm_active.prev; 371 struct list_head *entry = dpm_active.prev;
427 struct device *dev = to_device(entry); 372 struct device *dev = to_device(entry);
428 373
374 WARN_ON(dev->parent && dev->parent->power.sleeping);
375
376 dev->power.sleeping = true;
429 mutex_unlock(&dpm_list_mtx); 377 mutex_unlock(&dpm_list_mtx);
430 error = suspend_device(dev, state); 378 error = suspend_device(dev, state);
431 mutex_lock(&dpm_list_mtx); 379 mutex_lock(&dpm_list_mtx);
@@ -437,11 +385,14 @@ static int dpm_suspend(pm_message_t state)
437 (error == -EAGAIN ? 385 (error == -EAGAIN ?
438 " (please convert to suspend_late)" : 386 " (please convert to suspend_late)" :
439 "")); 387 ""));
388 dev->power.sleeping = false;
440 break; 389 break;
441 } 390 }
442 if (!list_empty(&dev->power.entry)) 391 if (!list_empty(&dev->power.entry))
443 list_move(&dev->power.entry, &dpm_off); 392 list_move(&dev->power.entry, &dpm_off);
444 } 393 }
394 if (!error)
395 all_sleeping = true;
445 mutex_unlock(&dpm_list_mtx); 396 mutex_unlock(&dpm_list_mtx);
446 397
447 return error; 398 return error;
@@ -459,7 +410,6 @@ int device_suspend(pm_message_t state)
459 int error; 410 int error;
460 411
461 might_sleep(); 412 might_sleep();
462 down_write(&pm_sleep_rwsem);
463 error = dpm_suspend(state); 413 error = dpm_suspend(state);
464 if (error) 414 if (error)
465 device_resume(); 415 device_resume();
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index e32d3bdb92c1..a6894f2a4b99 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -11,30 +11,13 @@ static inline struct device *to_device(struct list_head *entry)
11 return container_of(entry, struct device, power.entry); 11 return container_of(entry, struct device, power.entry);
12} 12}
13 13
14extern void device_pm_add(struct device *); 14extern int device_pm_add(struct device *);
15extern void device_pm_remove(struct device *); 15extern void device_pm_remove(struct device *);
16extern int pm_sleep_lock(void);
17extern void pm_sleep_unlock(void);
18 16
19#else /* CONFIG_PM_SLEEP */ 17#else /* CONFIG_PM_SLEEP */
20 18
21 19static inline int device_pm_add(struct device *dev) { return 0; }
22static inline void device_pm_add(struct device *dev) 20static inline void device_pm_remove(struct device *dev) {}
23{
24}
25
26static inline void device_pm_remove(struct device *dev)
27{
28}
29
30static inline int pm_sleep_lock(void)
31{
32 return 0;
33}
34
35static inline void pm_sleep_unlock(void)
36{
37}
38 21
39#endif 22#endif
40 23
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index f2ed179cd695..d11f74b038db 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -6,6 +6,8 @@
6#include <linux/string.h> 6#include <linux/string.h>
7#include "power.h" 7#include "power.h"
8 8
9int (*platform_enable_wakeup)(struct device *dev, int is_on);
10
9 11
10/* 12/*
11 * wakeup - Report/change current wakeup option for device 13 * wakeup - Report/change current wakeup option for device
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 8e13fd942163..4fbb56bcb1ee 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -167,6 +167,22 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
167{ 167{
168 int err = 0; 168 int err = 0;
169 169
170 if (!cls) {
171 printk(KERN_WARNING "sysdev: invalid class passed to "
172 "sysdev_driver_register!\n");
173 WARN_ON(1);
174 return -EINVAL;
175 }
176
177 /* Check whether this driver has already been added to a class. */
178 if ((drv->entry.next != drv->entry.prev) ||
179 (drv->entry.next != NULL)) {
180 printk(KERN_WARNING "sysdev: class %s: driver (%p) has already"
181 " been registered to a class, something is wrong, but "
182 "will forge on!\n", cls->name, drv);
183 WARN_ON(1);
184 }
185
170 mutex_lock(&sysdev_drivers_lock); 186 mutex_lock(&sysdev_drivers_lock);
171 if (cls && kset_get(&cls->kset)) { 187 if (cls && kset_get(&cls->kset)) {
172 list_add_tail(&drv->entry, &cls->drivers); 188 list_add_tail(&drv->entry, &cls->drivers);
@@ -179,7 +195,7 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
179 } 195 }
180 } else { 196 } else {
181 err = -EINVAL; 197 err = -EINVAL;
182 printk(KERN_ERR "%s: invalid device class\n", __FUNCTION__); 198 printk(KERN_ERR "%s: invalid device class\n", __func__);
183 WARN_ON(1); 199 WARN_ON(1);
184 } 200 }
185 mutex_unlock(&sysdev_drivers_lock); 201 mutex_unlock(&sysdev_drivers_lock);
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index e1d3ad4db2f0..fdf4044d2e74 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -40,15 +40,38 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 40 return sprintf(buf, "%d\n", topology_##name(cpu)); \
41} 41}
42 42
43#define define_siblings_show_func(name) \ 43static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
44static ssize_t show_##name(struct sys_device *dev, char *buf) \ 44{
45 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
46 int n = 0;
47
48 if (len > 1) {
49 n = type?
50 cpulist_scnprintf(buf, len-2, *mask):
51 cpumask_scnprintf(buf, len-2, *mask);
52 buf[n++] = '\n';
53 buf[n] = '\0';
54 }
55 return n;
56}
57
58#define define_siblings_show_map(name) \
59static inline ssize_t show_##name(struct sys_device *dev, char *buf) \
45{ \ 60{ \
46 ssize_t len = -1; \
47 unsigned int cpu = dev->id; \ 61 unsigned int cpu = dev->id; \
48 len = cpumask_scnprintf(buf, NR_CPUS+1, topology_##name(cpu)); \ 62 return show_cpumap(0, &(topology_##name(cpu)), buf); \
49 return (len + sprintf(buf + len, "\n")); \
50} 63}
51 64
65#define define_siblings_show_list(name) \
66static inline ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
67{ \
68 unsigned int cpu = dev->id; \
69 return show_cpumap(1, &(topology_##name(cpu)), buf); \
70}
71
72#define define_siblings_show_func(name) \
73 define_siblings_show_map(name); define_siblings_show_list(name)
74
52#ifdef topology_physical_package_id 75#ifdef topology_physical_package_id
53define_id_show_func(physical_package_id); 76define_id_show_func(physical_package_id);
54define_one_ro(physical_package_id); 77define_one_ro(physical_package_id);
@@ -68,7 +91,9 @@ define_one_ro(core_id);
68#ifdef topology_thread_siblings 91#ifdef topology_thread_siblings
69define_siblings_show_func(thread_siblings); 92define_siblings_show_func(thread_siblings);
70define_one_ro(thread_siblings); 93define_one_ro(thread_siblings);
71#define ref_thread_siblings_attr &attr_thread_siblings.attr, 94define_one_ro(thread_siblings_list);
95#define ref_thread_siblings_attr \
96 &attr_thread_siblings.attr, &attr_thread_siblings_list.attr,
72#else 97#else
73#define ref_thread_siblings_attr 98#define ref_thread_siblings_attr
74#endif 99#endif
@@ -76,7 +101,9 @@ define_one_ro(thread_siblings);
76#ifdef topology_core_siblings 101#ifdef topology_core_siblings
77define_siblings_show_func(core_siblings); 102define_siblings_show_func(core_siblings);
78define_one_ro(core_siblings); 103define_one_ro(core_siblings);
79#define ref_core_siblings_attr &attr_core_siblings.attr, 104define_one_ro(core_siblings_list);
105#define ref_core_siblings_attr \
106 &attr_core_siblings.attr, &attr_core_siblings_list.attr,
80#else 107#else
81#define ref_core_siblings_attr 108#define ref_core_siblings_attr
82#endif 109#endif
diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c
index cabd0edf2156..84997efdb23d 100644
--- a/drivers/base/transport_class.c
+++ b/drivers/base/transport_class.c
@@ -66,7 +66,7 @@ EXPORT_SYMBOL_GPL(transport_class_unregister);
66 66
67static int anon_transport_dummy_function(struct transport_container *tc, 67static int anon_transport_dummy_function(struct transport_container *tc,
68 struct device *dev, 68 struct device *dev,
69 struct class_device *cdev) 69 struct device *cdev)
70{ 70{
71 /* do nothing */ 71 /* do nothing */
72 return 0; 72 return 0;
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(anon_transport_class_unregister);
115 115
116static int transport_setup_classdev(struct attribute_container *cont, 116static int transport_setup_classdev(struct attribute_container *cont,
117 struct device *dev, 117 struct device *dev,
118 struct class_device *classdev) 118 struct device *classdev)
119{ 119{
120 struct transport_class *tclass = class_to_transport_class(cont->class); 120 struct transport_class *tclass = class_to_transport_class(cont->class);
121 struct transport_container *tcont = attribute_container_to_transport_container(cont); 121 struct transport_container *tcont = attribute_container_to_transport_container(cont);
@@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(transport_setup_device);
149 149
150static int transport_add_class_device(struct attribute_container *cont, 150static int transport_add_class_device(struct attribute_container *cont,
151 struct device *dev, 151 struct device *dev,
152 struct class_device *classdev) 152 struct device *classdev)
153{ 153{
154 int error = attribute_container_add_class_device(classdev); 154 int error = attribute_container_add_class_device(classdev);
155 struct transport_container *tcont = 155 struct transport_container *tcont =
@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(transport_add_device);
181 181
182static int transport_configure(struct attribute_container *cont, 182static int transport_configure(struct attribute_container *cont,
183 struct device *dev, 183 struct device *dev,
184 struct class_device *cdev) 184 struct device *cdev)
185{ 185{
186 struct transport_class *tclass = class_to_transport_class(cont->class); 186 struct transport_class *tclass = class_to_transport_class(cont->class);
187 struct transport_container *tcont = attribute_container_to_transport_container(cont); 187 struct transport_container *tcont = attribute_container_to_transport_container(cont);
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(transport_configure_device);
212 212
213static int transport_remove_classdev(struct attribute_container *cont, 213static int transport_remove_classdev(struct attribute_container *cont,
214 struct device *dev, 214 struct device *dev,
215 struct class_device *classdev) 215 struct device *classdev)
216{ 216{
217 struct transport_container *tcont = 217 struct transport_container *tcont =
218 attribute_container_to_transport_container(cont); 218 attribute_container_to_transport_container(cont);
@@ -251,12 +251,12 @@ EXPORT_SYMBOL_GPL(transport_remove_device);
251 251
252static void transport_destroy_classdev(struct attribute_container *cont, 252static void transport_destroy_classdev(struct attribute_container *cont,
253 struct device *dev, 253 struct device *dev,
254 struct class_device *classdev) 254 struct device *classdev)
255{ 255{
256 struct transport_class *tclass = class_to_transport_class(cont->class); 256 struct transport_class *tclass = class_to_transport_class(cont->class);
257 257
258 if (tclass->remove != anon_transport_dummy_function) 258 if (tclass->remove != anon_transport_dummy_function)
259 class_device_put(classdev); 259 put_device(classdev);
260} 260}
261 261
262 262
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 241167878edf..8b6bb764b0a3 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -27,7 +27,6 @@
27#include <linux/blkdev.h> 27#include <linux/blkdev.h>
28#include <linux/loop.h> 28#include <linux/loop.h>
29#include <linux/scatterlist.h> 29#include <linux/scatterlist.h>
30#include <asm/semaphore.h>
31#include <asm/uaccess.h> 30#include <asm/uaccess.h>
32 31
33MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index 41ca721d2523..ebfe038d859e 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -69,7 +69,7 @@ MODULE_LICENSE("GPL");
69enum { 69enum {
70 PARTITION_SHIFT = 3, 70 PARTITION_SHIFT = 3,
71 MAX_DISKNO = HVMAXARCHITECTEDVIRTUALDISKS, 71 MAX_DISKNO = HVMAXARCHITECTEDVIRTUALDISKS,
72 MAX_DISK_NAME = sizeof(((struct gendisk *)0)->disk_name) 72 MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name)
73}; 73};
74 74
75static DEFINE_SPINLOCK(viodasd_spinlock); 75static DEFINE_SPINLOCK(viodasd_spinlock);
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 8b884f87d8b7..192522ebb771 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -62,13 +62,13 @@
62#define URB_ZERO_PACKET 0 62#define URB_ZERO_PACKET 0
63#endif 63#endif
64 64
65static int ignore = 0; 65static int ignore;
66static int ignore_dga = 0; 66static int ignore_dga;
67static int ignore_csr = 0; 67static int ignore_csr;
68static int ignore_sniffer = 0; 68static int ignore_sniffer;
69static int disable_scofix = 0; 69static int disable_scofix;
70static int force_scofix = 0; 70static int force_scofix;
71static int reset = 0; 71static int reset;
72 72
73#ifdef CONFIG_BT_HCIUSB_SCO 73#ifdef CONFIG_BT_HCIUSB_SCO
74static int isoc = 2; 74static int isoc = 2;
@@ -265,7 +265,7 @@ static int hci_usb_intr_rx_submit(struct hci_usb *husb)
265 BT_ERR("%s intr rx submit failed urb %p err %d", 265 BT_ERR("%s intr rx submit failed urb %p err %d",
266 husb->hdev->name, urb, err); 266 husb->hdev->name, urb, err);
267 _urb_unlink(_urb); 267 _urb_unlink(_urb);
268 _urb_free(_urb); 268 kfree(_urb);
269 kfree(buf); 269 kfree(buf);
270 } 270 }
271 return err; 271 return err;
@@ -302,7 +302,7 @@ static int hci_usb_bulk_rx_submit(struct hci_usb *husb)
302 BT_ERR("%s bulk rx submit failed urb %p err %d", 302 BT_ERR("%s bulk rx submit failed urb %p err %d",
303 husb->hdev->name, urb, err); 303 husb->hdev->name, urb, err);
304 _urb_unlink(_urb); 304 _urb_unlink(_urb);
305 _urb_free(_urb); 305 kfree(_urb);
306 kfree(buf); 306 kfree(buf);
307 } 307 }
308 return err; 308 return err;
@@ -353,7 +353,7 @@ static int hci_usb_isoc_rx_submit(struct hci_usb *husb)
353 BT_ERR("%s isoc rx submit failed urb %p err %d", 353 BT_ERR("%s isoc rx submit failed urb %p err %d",
354 husb->hdev->name, urb, err); 354 husb->hdev->name, urb, err);
355 _urb_unlink(_urb); 355 _urb_unlink(_urb);
356 _urb_free(_urb); 356 kfree(_urb);
357 kfree(buf); 357 kfree(buf);
358 } 358 }
359 return err; 359 return err;
@@ -431,7 +431,7 @@ static void hci_usb_unlink_urbs(struct hci_usb *husb)
431 husb->hdev->name, _urb, _urb->type, urb); 431 husb->hdev->name, _urb, _urb->type, urb);
432 kfree(urb->setup_packet); 432 kfree(urb->setup_packet);
433 kfree(urb->transfer_buffer); 433 kfree(urb->transfer_buffer);
434 _urb_free(_urb); 434 kfree(_urb);
435 } 435 }
436 } 436 }
437} 437}
@@ -490,7 +490,7 @@ static inline int hci_usb_send_ctrl(struct hci_usb *husb, struct sk_buff *skb)
490 490
491 dr = kmalloc(sizeof(*dr), GFP_ATOMIC); 491 dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
492 if (!dr) { 492 if (!dr) {
493 _urb_free(_urb); 493 kfree(_urb);
494 return -ENOMEM; 494 return -ENOMEM;
495 } 495 }
496 } else 496 } else
diff --git a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h
index 56cd3a92ceca..414080a4e8ff 100644
--- a/drivers/bluetooth/hci_usb.h
+++ b/drivers/bluetooth/hci_usb.h
@@ -60,11 +60,6 @@ struct _urb {
60 struct urb urb; 60 struct urb urb;
61}; 61};
62 62
63static inline void _urb_free(struct _urb *_urb)
64{
65 kfree(_urb);
66}
67
68static inline void _urb_queue_init(struct _urb_queue *q) 63static inline void _urb_queue_init(struct _urb_queue *q)
69{ 64{
70 INIT_LIST_HEAD(&q->head); 65 INIT_LIST_HEAD(&q->head);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 47c6be84fc84..a87b89db08e9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -706,7 +706,7 @@ config NVRAM
706 706
707config RTC 707config RTC
708 tristate "Enhanced Real Time Clock Support" 708 tristate "Enhanced Real Time Clock Support"
709 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 709 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !AVR32
710 ---help--- 710 ---help---
711 If you say Y here and create a character special file /dev/rtc with 711 If you say Y here and create a character special file /dev/rtc with
712 major number 10 and minor number 135 using mknod ("man mknod"), you 712 major number 10 and minor number 135 using mknod ("man mknod"), you
@@ -776,7 +776,7 @@ config SGI_IP27_RTC
776 776
777config GEN_RTC 777config GEN_RTC
778 tristate "Generic /dev/rtc emulation" 778 tristate "Generic /dev/rtc emulation"
779 depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH 779 depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32
780 ---help--- 780 ---help---
781 If you say Y here and create a character special file /dev/rtc with 781 If you say Y here and create a character special file /dev/rtc with
782 major number 10 and minor number 135 using mknod ("man mknod"), you 782 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index 8ea9dd1717a9..6540948d5176 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -640,7 +640,6 @@ struct drm_head {
640 struct drm_device *dev; 640 struct drm_device *dev;
641 struct proc_dir_entry *dev_root; /**< proc directory entry */ 641 struct proc_dir_entry *dev_root; /**< proc directory entry */
642 dev_t device; /**< Device number for mknod */ 642 dev_t device; /**< Device number for mknod */
643 struct class_device *dev_class;
644}; 643};
645 644
646/** 645/**
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index 8facf3e25c49..7ed7da1d99cf 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -28,7 +28,6 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/tty_flip.h> 29#include <linux/tty_flip.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <asm/semaphore.h>
32#include <asm/uaccess.h> 31#include <asm/uaccess.h>
33 32
34#define DEBUG 33#define DEBUG
diff --git a/drivers/char/hvc_beat.c b/drivers/char/hvc_beat.c
index e74bb949c289..91cdb35a9204 100644
--- a/drivers/char/hvc_beat.c
+++ b/drivers/char/hvc_beat.c
@@ -78,8 +78,8 @@ static int hvc_beat_put_chars(uint32_t vtermno, const char *buf, int cnt)
78 for (rest = cnt; rest > 0; rest -= nlen) { 78 for (rest = cnt; rest > 0; rest -= nlen) {
79 nlen = (rest > 16) ? 16 : rest; 79 nlen = (rest > 16) ? 16 : rest;
80 memcpy(kb, buf, nlen); 80 memcpy(kb, buf, nlen);
81 beat_put_term_char(vtermno, rest, kb[0], kb[1]); 81 beat_put_term_char(vtermno, nlen, kb[0], kb[1]);
82 rest -= nlen; 82 buf += nlen;
83 } 83 }
84 return cnt; 84 return cnt;
85} 85}
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 349b6edc5794..662d60e44e9a 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -238,11 +238,11 @@ static DEVICE_ATTR(rng_available, S_IRUGO,
238 NULL); 238 NULL);
239 239
240 240
241static void unregister_miscdev(bool suspended) 241static void unregister_miscdev(void)
242{ 242{
243 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available); 243 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available);
244 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); 244 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
245 __misc_deregister(&rng_miscdev, suspended); 245 misc_deregister(&rng_miscdev);
246} 246}
247 247
248static int register_miscdev(void) 248static int register_miscdev(void)
@@ -317,7 +317,7 @@ out:
317} 317}
318EXPORT_SYMBOL_GPL(hwrng_register); 318EXPORT_SYMBOL_GPL(hwrng_register);
319 319
320void __hwrng_unregister(struct hwrng *rng, bool suspended) 320void hwrng_unregister(struct hwrng *rng)
321{ 321{
322 int err; 322 int err;
323 323
@@ -336,11 +336,11 @@ void __hwrng_unregister(struct hwrng *rng, bool suspended)
336 } 336 }
337 } 337 }
338 if (list_empty(&rng_list)) 338 if (list_empty(&rng_list))
339 unregister_miscdev(suspended); 339 unregister_miscdev();
340 340
341 mutex_unlock(&rng_mutex); 341 mutex_unlock(&rng_mutex);
342} 342}
343EXPORT_SYMBOL_GPL(__hwrng_unregister); 343EXPORT_SYMBOL_GPL(hwrng_unregister);
344 344
345 345
346MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver"); 346MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index 7e319951fa41..51738bdd834e 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * drivers/char/hw_random/omap-rng.c 2 * omap-rng.c - RNG driver for TI OMAP CPU family
3 *
4 * RNG driver for TI OMAP CPU family
5 * 3 *
6 * Author: Deepak Saxena <dsaxena@plexity.net> 4 * Author: Deepak Saxena <dsaxena@plexity.net>
7 * 5 *
@@ -15,11 +13,6 @@
15 * This file is licensed under the terms of the GNU General Public 13 * This file is licensed under the terms of the GNU General Public
16 * License version 2. This program is licensed "as is" without any 14 * License version 2. This program is licensed "as is" without any
17 * warranty of any kind, whether express or implied. 15 * warranty of any kind, whether express or implied.
18 *
19 * TODO:
20 *
21 * - Make status updated be interrupt driven so we don't poll
22 *
23 */ 16 */
24 17
25#include <linux/module.h> 18#include <linux/module.h>
@@ -55,17 +48,16 @@ static void __iomem *rng_base;
55static struct clk *rng_ick; 48static struct clk *rng_ick;
56static struct platform_device *rng_dev; 49static struct platform_device *rng_dev;
57 50
58static u32 omap_rng_read_reg(int reg) 51static inline u32 omap_rng_read_reg(int reg)
59{ 52{
60 return __raw_readl(rng_base + reg); 53 return __raw_readl(rng_base + reg);
61} 54}
62 55
63static void omap_rng_write_reg(int reg, u32 val) 56static inline void omap_rng_write_reg(int reg, u32 val)
64{ 57{
65 __raw_writel(val, rng_base + reg); 58 __raw_writel(val, rng_base + reg);
66} 59}
67 60
68/* REVISIT: Does the status bit really work on 16xx? */
69static int omap_rng_data_present(struct hwrng *rng, int wait) 61static int omap_rng_data_present(struct hwrng *rng, int wait)
70{ 62{
71 int data, i; 63 int data, i;
@@ -74,6 +66,11 @@ static int omap_rng_data_present(struct hwrng *rng, int wait)
74 data = omap_rng_read_reg(RNG_STAT_REG) ? 0 : 1; 66 data = omap_rng_read_reg(RNG_STAT_REG) ? 0 : 1;
75 if (data || !wait) 67 if (data || !wait)
76 break; 68 break;
69 /* RNG produces data fast enough (2+ MBit/sec, even
70 * during "rngtest" loads, that these delays don't
71 * seem to trigger. We *could* use the RNG IRQ, but
72 * that'd be higher overhead ... so why bother?
73 */
77 udelay(10); 74 udelay(10);
78 } 75 }
79 return data; 76 return data;
@@ -101,7 +98,8 @@ static int __init omap_rng_probe(struct platform_device *pdev)
101 * A bit ugly, and it will never actually happen but there can 98 * A bit ugly, and it will never actually happen but there can
102 * be only one RNG and this catches any bork 99 * be only one RNG and this catches any bork
103 */ 100 */
104 BUG_ON(rng_dev); 101 if (rng_dev)
102 return -EBUSY;
105 103
106 if (cpu_is_omap24xx()) { 104 if (cpu_is_omap24xx()) {
107 rng_ick = clk_get(NULL, "rng_ick"); 105 rng_ick = clk_get(NULL, "rng_ick");
@@ -124,7 +122,7 @@ static int __init omap_rng_probe(struct platform_device *pdev)
124 return -EBUSY; 122 return -EBUSY;
125 123
126 dev_set_drvdata(&pdev->dev, mem); 124 dev_set_drvdata(&pdev->dev, mem);
127 rng_base = (u32 __iomem *)io_p2v(res->start); 125 rng_base = (u32 __force __iomem *)io_p2v(res->start);
128 126
129 ret = hwrng_register(&omap_rng_ops); 127 ret = hwrng_register(&omap_rng_ops);
130 if (ret) { 128 if (ret) {
@@ -182,6 +180,8 @@ static int omap_rng_resume(struct platform_device *pdev)
182 180
183#endif 181#endif
184 182
183/* work with hotplug and coldplug */
184MODULE_ALIAS("platform:omap_rng");
185 185
186static struct platform_driver omap_rng_driver = { 186static struct platform_driver omap_rng_driver = {
187 .driver = { 187 .driver = {
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 4dbd3425e928..9769bf8279a6 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1033,7 +1033,8 @@ DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
1033#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\ 1033#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
1034 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\ 1034 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
1035 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\ 1035 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
1036 (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) 1036 (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) ||\
1037 defined(CONFIG_AVR32)
1037 1038
1038#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\ 1039#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
1039 ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001)) 1040 ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index a39101feb2ed..4d058dadbfcc 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -232,9 +232,8 @@ int misc_register(struct miscdevice * misc)
232} 232}
233 233
234/** 234/**
235 * __misc_deregister - unregister a miscellaneous device 235 * misc_deregister - unregister a miscellaneous device
236 * @misc: device to unregister 236 * @misc: device to unregister
237 * @suspended: to be set if the function is used during suspend/resume
238 * 237 *
239 * Unregister a miscellaneous device that was previously 238 * Unregister a miscellaneous device that was previously
240 * successfully registered with misc_register(). Success 239 * successfully registered with misc_register(). Success
@@ -242,7 +241,7 @@ int misc_register(struct miscdevice * misc)
242 * indicates an error. 241 * indicates an error.
243 */ 242 */
244 243
245int __misc_deregister(struct miscdevice *misc, bool suspended) 244int misc_deregister(struct miscdevice *misc)
246{ 245{
247 int i = misc->minor; 246 int i = misc->minor;
248 247
@@ -251,11 +250,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended)
251 250
252 mutex_lock(&misc_mtx); 251 mutex_lock(&misc_mtx);
253 list_del(&misc->list); 252 list_del(&misc->list);
254 if (suspended) 253 device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
255 destroy_suspended_device(misc_class,
256 MKDEV(MISC_MAJOR, misc->minor));
257 else
258 device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
259 if (i < DYNAMIC_MINORS && i>0) { 254 if (i < DYNAMIC_MINORS && i>0) {
260 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 255 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
261 } 256 }
@@ -264,7 +259,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended)
264} 259}
265 260
266EXPORT_SYMBOL(misc_register); 261EXPORT_SYMBOL(misc_register);
267EXPORT_SYMBOL(__misc_deregister); 262EXPORT_SYMBOL(misc_deregister);
268 263
269static int __init misc_init(void) 264static int __init misc_init(void)
270{ 265{
diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
index f282976daaac..37fe80df0b91 100644
--- a/drivers/char/mwave/tp3780i.c
+++ b/drivers/char/mwave/tp3780i.c
@@ -97,20 +97,24 @@ static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
97 97
98static irqreturn_t UartInterrupt(int irq, void *dev_id) 98static irqreturn_t UartInterrupt(int irq, void *dev_id)
99{ 99{
100 int irqno = (int)(unsigned long) dev_id;
101
100 PRINTK_3(TRACE_TP3780I, 102 PRINTK_3(TRACE_TP3780I,
101 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irq, dev_id); 103 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irqno, dev_id);
102 return IRQ_HANDLED; 104 return IRQ_HANDLED;
103} 105}
104 106
105static irqreturn_t DspInterrupt(int irq, void *dev_id) 107static irqreturn_t DspInterrupt(int irq, void *dev_id)
106{ 108{
109 int irqno = (int)(unsigned long) dev_id;
110
107 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; 111 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
108 DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings; 112 DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings;
109 unsigned short usDspBaseIO = pSettings->usDspBaseIO; 113 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
110 unsigned short usIPCSource = 0, usIsolationMask, usPCNum; 114 unsigned short usIPCSource = 0, usIsolationMask, usPCNum;
111 115
112 PRINTK_3(TRACE_TP3780I, 116 PRINTK_3(TRACE_TP3780I,
113 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irq, dev_id); 117 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irqno, dev_id);
114 118
115 if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) { 119 if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) {
116 PRINTK_2(TRACE_TP3780I, 120 PRINTK_2(TRACE_TP3780I,
@@ -361,14 +365,16 @@ int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData)
361 pSettings->bPllBypass = TP_CFG_PllBypass; 365 pSettings->bPllBypass = TP_CFG_PllBypass;
362 pSettings->usChipletEnable = TP_CFG_ChipletEnable; 366 pSettings->usChipletEnable = TP_CFG_ChipletEnable;
363 367
364 if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", NULL)) { 368 if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart",
369 (void *)(unsigned long) pSettings->usUartIrq)) {
365 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq); 370 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq);
366 goto exit_cleanup; 371 goto exit_cleanup;
367 } else { /* no conflict just release */ 372 } else { /* no conflict just release */
368 free_irq(pSettings->usUartIrq, NULL); 373 free_irq(pSettings->usUartIrq, NULL);
369 } 374 }
370 375
371 if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", NULL)) { 376 if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i",
377 (void *)(unsigned long) pSettings->usDspIrq)) {
372 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq); 378 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq);
373 goto exit_cleanup; 379 goto exit_cleanup;
374 } else { 380 } else {
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 279ff5005cec..4e84d233e5a2 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -1225,17 +1225,15 @@ static void ri_change(MGSLPC_INFO *info)
1225 * irq interrupt number that caused interrupt 1225 * irq interrupt number that caused interrupt
1226 * dev_id device ID supplied during interrupt registration 1226 * dev_id device ID supplied during interrupt registration
1227 */ 1227 */
1228static irqreturn_t mgslpc_isr(int irq, void *dev_id) 1228static irqreturn_t mgslpc_isr(int dummy, void *dev_id)
1229{ 1229{
1230 MGSLPC_INFO * info = (MGSLPC_INFO *)dev_id; 1230 MGSLPC_INFO *info = dev_id;
1231 unsigned short isr; 1231 unsigned short isr;
1232 unsigned char gis, pis; 1232 unsigned char gis, pis;
1233 int count=0; 1233 int count=0;
1234 1234
1235 if (debug_level >= DEBUG_LEVEL_ISR) 1235 if (debug_level >= DEBUG_LEVEL_ISR)
1236 printk("mgslpc_isr(%d) entry.\n", irq); 1236 printk("mgslpc_isr(%d) entry.\n", info->irq_level);
1237 if (!info)
1238 return IRQ_NONE;
1239 1237
1240 if (!(info->p_dev->_locked)) 1238 if (!(info->p_dev->_locked))
1241 return IRQ_HANDLED; 1239 return IRQ_HANDLED;
@@ -1327,7 +1325,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id)
1327 1325
1328 if (debug_level >= DEBUG_LEVEL_ISR) 1326 if (debug_level >= DEBUG_LEVEL_ISR)
1329 printk("%s(%d):mgslpc_isr(%d)exit.\n", 1327 printk("%s(%d):mgslpc_isr(%d)exit.\n",
1330 __FILE__,__LINE__,irq); 1328 __FILE__, __LINE__, info->irq_level);
1331 1329
1332 return IRQ_HANDLED; 1330 return IRQ_HANDLED;
1333} 1331}
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
index eca2b95343e2..d956dd316005 100644
--- a/drivers/char/rio/rioboot.c
+++ b/drivers/char/rio/rioboot.c
@@ -35,7 +35,6 @@
35#include <linux/termios.h> 35#include <linux/termios.h>
36#include <linux/serial.h> 36#include <linux/serial.h>
37#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
38#include <asm/semaphore.h>
39#include <linux/generic_serial.h> 38#include <linux/generic_serial.h>
40#include <linux/errno.h> 39#include <linux/errno.h>
41#include <linux/interrupt.h> 40#include <linux/interrupt.h>
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 7321d002c34f..bf36959fc121 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -41,7 +41,6 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h>
45#include <asm/uaccess.h> 44#include <asm/uaccess.h>
46 45
47#include <linux/termios.h> 46#include <linux/termios.h>
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index 7ce77619707c..d8eb2bcbe015 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -40,7 +40,6 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/system.h> 41#include <asm/system.h>
42#include <asm/string.h> 42#include <asm/string.h>
43#include <asm/semaphore.h>
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
45 44
46#include <linux/termios.h> 45#include <linux/termios.h>
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 0794844369d6..add1718295ef 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -40,7 +40,6 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/system.h> 41#include <asm/system.h>
42#include <asm/string.h> 42#include <asm/string.h>
43#include <asm/semaphore.h>
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
45 44
46#include <linux/termios.h> 45#include <linux/termios.h>
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index ebc76342712c..4734e26e1ccd 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -42,7 +42,6 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/string.h> 44#include <asm/string.h>
45#include <asm/semaphore.h>
46#include <asm/uaccess.h> 45#include <asm/uaccess.h>
47 46
48#include <linux/termios.h> 47#include <linux/termios.h>
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index bb498d24adcc..da276ed57b3f 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -41,7 +41,6 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h>
45#include <asm/uaccess.h> 44#include <asm/uaccess.h>
46 45
47#include <linux/termios.h> 46#include <linux/termios.h>
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index a99f3d9d7d65..85091ff74d96 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -39,7 +39,6 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
39#include <asm/io.h> 39#include <asm/io.h>
40#include <asm/system.h> 40#include <asm/system.h>
41#include <asm/string.h> 41#include <asm/string.h>
42#include <asm/semaphore.h>
43#include <asm/uaccess.h> 42#include <asm/uaccess.h>
44 43
45#include <linux/termios.h> 44#include <linux/termios.h>
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index 9b52892a501f..2b24488e95f2 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -42,7 +42,6 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/string.h> 44#include <asm/string.h>
45#include <asm/semaphore.h>
46#include <asm/uaccess.h> 45#include <asm/uaccess.h>
47 46
48#include <linux/termios.h> 47#include <linux/termios.h>
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index cfa54361473f..1cb8580a161d 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -44,7 +44,6 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
44#include <asm/io.h> 44#include <asm/io.h>
45#include <asm/system.h> 45#include <asm/system.h>
46#include <asm/string.h> 46#include <asm/string.h>
47#include <asm/semaphore.h>
48#include <asm/uaccess.h> 47#include <asm/uaccess.h>
49 48
50#include <linux/termios.h> 49#include <linux/termios.h>
diff --git a/drivers/char/snsc.h b/drivers/char/snsc.h
index 8a98169b60c1..4be62eda9fbc 100644
--- a/drivers/char/snsc.h
+++ b/drivers/char/snsc.h
@@ -22,8 +22,8 @@
22#include <linux/kobject.h> 22#include <linux/kobject.h>
23#include <linux/fs.h> 23#include <linux/fs.h>
24#include <linux/cdev.h> 24#include <linux/cdev.h>
25#include <linux/semaphore.h>
25#include <asm/sn/types.h> 26#include <asm/sn/types.h>
26#include <asm/semaphore.h>
27 27
28#define CHUNKSIZE 127 28#define CHUNKSIZE 127
29 29
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 5ff83df67b44..4b5b5b78acb4 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -443,8 +443,7 @@ void missed_irq (unsigned long data)
443 spin_unlock_irqrestore(&bp->lock, flags); 443 spin_unlock_irqrestore(&bp->lock, flags);
444 if (irq) { 444 if (irq) {
445 printk (KERN_INFO "Missed interrupt... Calling int from timer. \n"); 445 printk (KERN_INFO "Missed interrupt... Calling int from timer. \n");
446 sx_interrupt (((struct specialix_board *)data)->irq, 446 sx_interrupt (-1, bp);
447 (void*)data);
448 } 447 }
449 mod_timer(&missed_irq_timer, jiffies + sx_poll); 448 mod_timer(&missed_irq_timer, jiffies + sx_poll);
450} 449}
@@ -862,23 +861,22 @@ static inline void sx_check_modem(struct specialix_board * bp)
862 861
863 862
864/* The main interrupt processing routine */ 863/* The main interrupt processing routine */
865static irqreturn_t sx_interrupt(int irq, void *dev_id) 864static irqreturn_t sx_interrupt(int dummy, void *dev_id)
866{ 865{
867 unsigned char status; 866 unsigned char status;
868 unsigned char ack; 867 unsigned char ack;
869 struct specialix_board *bp; 868 struct specialix_board *bp = dev_id;
870 unsigned long loop = 0; 869 unsigned long loop = 0;
871 int saved_reg; 870 int saved_reg;
872 unsigned long flags; 871 unsigned long flags;
873 872
874 func_enter(); 873 func_enter();
875 874
876 bp = dev_id;
877 spin_lock_irqsave(&bp->lock, flags); 875 spin_lock_irqsave(&bp->lock, flags);
878 876
879 dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __FUNCTION__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1); 877 dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __FUNCTION__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
880 if (!(bp->flags & SX_BOARD_ACTIVE)) { 878 if (!(bp->flags & SX_BOARD_ACTIVE)) {
881 dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", irq); 879 dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", bp->irq);
882 spin_unlock_irqrestore(&bp->lock, flags); 880 spin_unlock_irqrestore(&bp->lock, flags);
883 func_exit(); 881 func_exit();
884 return IRQ_NONE; 882 return IRQ_NONE;
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index feac54e32a12..874aaa08e956 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -1645,7 +1645,7 @@ static irqreturn_t stl_intr(int irq, void *dev_id)
1645{ 1645{
1646 struct stlbrd *brdp = dev_id; 1646 struct stlbrd *brdp = dev_id;
1647 1647
1648 pr_debug("stl_intr(brdp=%p,irq=%d)\n", brdp, irq); 1648 pr_debug("stl_intr(brdp=%p,irq=%d)\n", brdp, brdp->irq);
1649 1649
1650 return IRQ_RETVAL((* brdp->isr)(brdp)); 1650 return IRQ_RETVAL((* brdp->isr)(brdp));
1651} 1651}
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index ddc74d1f4f1b..a3237d48a584 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -1695,20 +1695,16 @@ static void mgsl_isr_transmit_dma( struct mgsl_struct *info )
1695 * 1695 *
1696 * Return Value: None 1696 * Return Value: None
1697 */ 1697 */
1698static irqreturn_t mgsl_interrupt(int irq, void *dev_id) 1698static irqreturn_t mgsl_interrupt(int dummy, void *dev_id)
1699{ 1699{
1700 struct mgsl_struct * info; 1700 struct mgsl_struct *info = dev_id;
1701 u16 UscVector; 1701 u16 UscVector;
1702 u16 DmaVector; 1702 u16 DmaVector;
1703 1703
1704 if ( debug_level >= DEBUG_LEVEL_ISR ) 1704 if ( debug_level >= DEBUG_LEVEL_ISR )
1705 printk("%s(%d):mgsl_interrupt(%d)entry.\n", 1705 printk(KERN_DEBUG "%s(%d):mgsl_interrupt(%d)entry.\n",
1706 __FILE__,__LINE__,irq); 1706 __FILE__, __LINE__, info->irq_level);
1707 1707
1708 info = (struct mgsl_struct *)dev_id;
1709 if (!info)
1710 return IRQ_NONE;
1711
1712 spin_lock(&info->irq_spinlock); 1708 spin_lock(&info->irq_spinlock);
1713 1709
1714 for(;;) { 1710 for(;;) {
@@ -1732,8 +1728,8 @@ static irqreturn_t mgsl_interrupt(int irq, void *dev_id)
1732 mgsl_isr_receive_dma(info); 1728 mgsl_isr_receive_dma(info);
1733 1729
1734 if ( info->isr_overflow ) { 1730 if ( info->isr_overflow ) {
1735 printk(KERN_ERR"%s(%d):%s isr overflow irq=%d\n", 1731 printk(KERN_ERR "%s(%d):%s isr overflow irq=%d\n",
1736 __FILE__,__LINE__,info->device_name, irq); 1732 __FILE__, __LINE__, info->device_name, info->irq_level);
1737 usc_DisableMasterIrqBit(info); 1733 usc_DisableMasterIrqBit(info);
1738 usc_DisableDmaInterrupts(info,DICR_MASTER); 1734 usc_DisableDmaInterrupts(info,DICR_MASTER);
1739 break; 1735 break;
@@ -1755,8 +1751,9 @@ static irqreturn_t mgsl_interrupt(int irq, void *dev_id)
1755 spin_unlock(&info->irq_spinlock); 1751 spin_unlock(&info->irq_spinlock);
1756 1752
1757 if ( debug_level >= DEBUG_LEVEL_ISR ) 1753 if ( debug_level >= DEBUG_LEVEL_ISR )
1758 printk("%s(%d):mgsl_interrupt(%d)exit.\n", 1754 printk(KERN_DEBUG "%s(%d):mgsl_interrupt(%d)exit.\n",
1759 __FILE__,__LINE__,irq); 1755 __FILE__, __LINE__, info->irq_level);
1756
1760 return IRQ_HANDLED; 1757 return IRQ_HANDLED;
1761} /* end of mgsl_interrupt() */ 1758} /* end of mgsl_interrupt() */
1762 1759
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 1f954acf2bac..3c89266c8255 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -491,7 +491,6 @@ static void isr_serial(struct slgt_info *info);
491static void isr_rdma(struct slgt_info *info); 491static void isr_rdma(struct slgt_info *info);
492static void isr_txeom(struct slgt_info *info, unsigned short status); 492static void isr_txeom(struct slgt_info *info, unsigned short status);
493static void isr_tdma(struct slgt_info *info); 493static void isr_tdma(struct slgt_info *info);
494static irqreturn_t slgt_interrupt(int irq, void *dev_id);
495 494
496static int alloc_dma_bufs(struct slgt_info *info); 495static int alloc_dma_bufs(struct slgt_info *info);
497static void free_dma_bufs(struct slgt_info *info); 496static void free_dma_bufs(struct slgt_info *info);
@@ -2326,17 +2325,13 @@ static void isr_gpio(struct slgt_info *info, unsigned int changed, unsigned int
2326 * irq interrupt number 2325 * irq interrupt number
2327 * dev_id device ID supplied during interrupt registration 2326 * dev_id device ID supplied during interrupt registration
2328 */ 2327 */
2329static irqreturn_t slgt_interrupt(int irq, void *dev_id) 2328static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
2330{ 2329{
2331 struct slgt_info *info; 2330 struct slgt_info *info = dev_id;
2332 unsigned int gsr; 2331 unsigned int gsr;
2333 unsigned int i; 2332 unsigned int i;
2334 2333
2335 DBGISR(("slgt_interrupt irq=%d entry\n", irq)); 2334 DBGISR(("slgt_interrupt irq=%d entry\n", info->irq_level));
2336
2337 info = dev_id;
2338 if (!info)
2339 return IRQ_NONE;
2340 2335
2341 spin_lock(&info->lock); 2336 spin_lock(&info->lock);
2342 2337
@@ -2385,7 +2380,7 @@ static irqreturn_t slgt_interrupt(int irq, void *dev_id)
2385 2380
2386 spin_unlock(&info->lock); 2381 spin_unlock(&info->lock);
2387 2382
2388 DBGISR(("slgt_interrupt irq=%d exit\n", irq)); 2383 DBGISR(("slgt_interrupt irq=%d exit\n", info->irq_level));
2389 return IRQ_HANDLED; 2384 return IRQ_HANDLED;
2390} 2385}
2391 2386
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index f3e7807f78d9..c96062ea72b4 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -2586,9 +2586,9 @@ void isr_io_pin( SLMP_INFO *info, u16 status )
2586 * dev_id device ID supplied during interrupt registration 2586 * dev_id device ID supplied during interrupt registration
2587 * regs interrupted processor context 2587 * regs interrupted processor context
2588 */ 2588 */
2589static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id) 2589static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
2590{ 2590{
2591 SLMP_INFO * info; 2591 SLMP_INFO *info = dev_id;
2592 unsigned char status, status0, status1=0; 2592 unsigned char status, status0, status1=0;
2593 unsigned char dmastatus, dmastatus0, dmastatus1=0; 2593 unsigned char dmastatus, dmastatus0, dmastatus1=0;
2594 unsigned char timerstatus0, timerstatus1=0; 2594 unsigned char timerstatus0, timerstatus1=0;
@@ -2597,12 +2597,8 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id)
2597 unsigned short tmp; 2597 unsigned short tmp;
2598 2598
2599 if ( debug_level >= DEBUG_LEVEL_ISR ) 2599 if ( debug_level >= DEBUG_LEVEL_ISR )
2600 printk("%s(%d): synclinkmp_interrupt(%d)entry.\n", 2600 printk(KERN_DEBUG "%s(%d): synclinkmp_interrupt(%d)entry.\n",
2601 __FILE__,__LINE__,irq); 2601 __FILE__, __LINE__, info->irq_level);
2602
2603 info = (SLMP_INFO *)dev_id;
2604 if (!info)
2605 return IRQ_NONE;
2606 2602
2607 spin_lock(&info->lock); 2603 spin_lock(&info->lock);
2608 2604
@@ -2615,9 +2611,9 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id)
2615 timerstatus0 = read_reg(info, ISR2); 2611 timerstatus0 = read_reg(info, ISR2);
2616 2612
2617 if ( debug_level >= DEBUG_LEVEL_ISR ) 2613 if ( debug_level >= DEBUG_LEVEL_ISR )
2618 printk("%s(%d):%s status0=%02x, dmastatus0=%02x, timerstatus0=%02x\n", 2614 printk(KERN_DEBUG "%s(%d):%s status0=%02x, dmastatus0=%02x, timerstatus0=%02x\n",
2619 __FILE__,__LINE__,info->device_name, 2615 __FILE__, __LINE__, info->device_name,
2620 status0,dmastatus0,timerstatus0); 2616 status0, dmastatus0, timerstatus0);
2621 2617
2622 if (info->port_count == 4) { 2618 if (info->port_count == 4) {
2623 /* get status for SCA1 (ports 2-3) */ 2619 /* get status for SCA1 (ports 2-3) */
@@ -2702,8 +2698,8 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id)
2702 spin_unlock(&info->lock); 2698 spin_unlock(&info->lock);
2703 2699
2704 if ( debug_level >= DEBUG_LEVEL_ISR ) 2700 if ( debug_level >= DEBUG_LEVEL_ISR )
2705 printk("%s(%d):synclinkmp_interrupt(%d)exit.\n", 2701 printk(KERN_DEBUG "%s(%d):synclinkmp_interrupt(%d)exit.\n",
2706 __FILE__,__LINE__,irq); 2702 __FILE__, __LINE__, info->irq_level);
2707 return IRQ_HANDLED; 2703 return IRQ_HANDLED;
2708} 2704}
2709 2705
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 81503d94fecc..13a4bdd4e4d6 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -399,7 +399,7 @@ static irqreturn_t tis_int_probe(int irq, void *dev_id)
399 return IRQ_HANDLED; 399 return IRQ_HANDLED;
400} 400}
401 401
402static irqreturn_t tis_int_handler(int irq, void *dev_id) 402static irqreturn_t tis_int_handler(int dummy, void *dev_id)
403{ 403{
404 struct tpm_chip *chip = dev_id; 404 struct tpm_chip *chip = dev_id;
405 u32 interrupt; 405 u32 interrupt;
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.c b/drivers/char/xilinx_hwicap/buffer_icap.c
index f577daedb630..aa7f7962a9a0 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.c
+++ b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -74,7 +74,7 @@
74 74
75/** 75/**
76 * buffer_icap_get_status - Get the contents of the status register. 76 * buffer_icap_get_status - Get the contents of the status register.
77 * @base_address: is the base address of the device 77 * @drvdata: a pointer to the drvdata.
78 * 78 *
79 * The status register contains the ICAP status and the done bit. 79 * The status register contains the ICAP status and the done bit.
80 * 80 *
@@ -88,9 +88,9 @@
88 * D1 - Always 1 88 * D1 - Always 1
89 * D0 - Done bit 89 * D0 - Done bit
90 **/ 90 **/
91static inline u32 buffer_icap_get_status(void __iomem *base_address) 91u32 buffer_icap_get_status(struct hwicap_drvdata *drvdata)
92{ 92{
93 return in_be32(base_address + XHI_STATUS_REG_OFFSET); 93 return in_be32(drvdata->base_address + XHI_STATUS_REG_OFFSET);
94} 94}
95 95
96/** 96/**
@@ -117,20 +117,8 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address,
117 **/ 117 **/
118static inline bool buffer_icap_busy(void __iomem *base_address) 118static inline bool buffer_icap_busy(void __iomem *base_address)
119{ 119{
120 return (buffer_icap_get_status(base_address) & 1) == XHI_NOT_FINISHED; 120 u32 status = in_be32(base_address + XHI_STATUS_REG_OFFSET);
121} 121 return (status & 1) == XHI_NOT_FINISHED;
122
123/**
124 * buffer_icap_busy - Return true if the icap device is not busy
125 * @base_address: is the base address of the device
126 *
127 * The queries the low order bit of the status register, which
128 * indicates whether the current configuration or readback operation
129 * has completed.
130 **/
131static inline bool buffer_icap_done(void __iomem *base_address)
132{
133 return (buffer_icap_get_status(base_address) & 1) == XHI_FINISHED;
134} 122}
135 123
136/** 124/**
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.h b/drivers/char/xilinx_hwicap/buffer_icap.h
index 03184959fa00..c5b1840906b2 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.h
+++ b/drivers/char/xilinx_hwicap/buffer_icap.h
@@ -44,8 +44,6 @@
44#include <asm/io.h> 44#include <asm/io.h>
45#include "xilinx_hwicap.h" 45#include "xilinx_hwicap.h"
46 46
47void buffer_icap_reset(struct hwicap_drvdata *drvdata);
48
49/* Loads a partial bitstream from system memory. */ 47/* Loads a partial bitstream from system memory. */
50int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data, 48int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
51 u32 Size); 49 u32 Size);
@@ -54,4 +52,7 @@ int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
54int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data, 52int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data,
55 u32 Size); 53 u32 Size);
56 54
55u32 buffer_icap_get_status(struct hwicap_drvdata *drvdata);
56void buffer_icap_reset(struct hwicap_drvdata *drvdata);
57
57#endif 58#endif
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.c b/drivers/char/xilinx_hwicap/fifo_icap.c
index 6f45dbd47125..776b50528478 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.c
+++ b/drivers/char/xilinx_hwicap/fifo_icap.c
@@ -78,13 +78,6 @@
78#define XHI_CR_READ_MASK 0x00000002 /* Read from ICAP to FIFO */ 78#define XHI_CR_READ_MASK 0x00000002 /* Read from ICAP to FIFO */
79#define XHI_CR_WRITE_MASK 0x00000001 /* Write from FIFO to ICAP */ 79#define XHI_CR_WRITE_MASK 0x00000001 /* Write from FIFO to ICAP */
80 80
81/* Status Register (SR) */
82#define XHI_SR_CFGERR_N_MASK 0x00000100 /* Config Error Mask */
83#define XHI_SR_DALIGN_MASK 0x00000080 /* Data Alignment Mask */
84#define XHI_SR_RIP_MASK 0x00000040 /* Read back Mask */
85#define XHI_SR_IN_ABORT_N_MASK 0x00000020 /* Select Map Abort Mask */
86#define XHI_SR_DONE_MASK 0x00000001 /* Done bit Mask */
87
88 81
89#define XHI_WFO_MAX_VACANCY 1024 /* Max Write FIFO Vacancy, in words */ 82#define XHI_WFO_MAX_VACANCY 1024 /* Max Write FIFO Vacancy, in words */
90#define XHI_RFO_MAX_OCCUPANCY 256 /* Max Read FIFO Occupancy, in words */ 83#define XHI_RFO_MAX_OCCUPANCY 256 /* Max Read FIFO Occupancy, in words */
@@ -152,13 +145,35 @@ static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
152} 145}
153 146
154/** 147/**
148 * fifo_icap_get_status - Get the contents of the status register.
149 * @drvdata: a pointer to the drvdata.
150 *
151 * The status register contains the ICAP status and the done bit.
152 *
153 * D8 - cfgerr
154 * D7 - dalign
155 * D6 - rip
156 * D5 - in_abort_l
157 * D4 - Always 1
158 * D3 - Always 1
159 * D2 - Always 1
160 * D1 - Always 1
161 * D0 - Done bit
162 **/
163u32 fifo_icap_get_status(struct hwicap_drvdata *drvdata)
164{
165 u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET);
166 dev_dbg(drvdata->dev, "Getting status = %x\n", status);
167 return status;
168}
169
170/**
155 * fifo_icap_busy - Return true if the ICAP is still processing a transaction. 171 * fifo_icap_busy - Return true if the ICAP is still processing a transaction.
156 * @drvdata: a pointer to the drvdata. 172 * @drvdata: a pointer to the drvdata.
157 **/ 173 **/
158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata) 174static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
159{ 175{
160 u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET); 176 u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET);
161 dev_dbg(drvdata->dev, "Getting status = %x\n", status);
162 return (status & XHI_SR_DONE_MASK) ? 0 : 1; 177 return (status & XHI_SR_DONE_MASK) ? 0 : 1;
163} 178}
164 179
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.h b/drivers/char/xilinx_hwicap/fifo_icap.h
index 4d3068dd0405..ffabd3ba2bd8 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.h
+++ b/drivers/char/xilinx_hwicap/fifo_icap.h
@@ -56,6 +56,7 @@ int fifo_icap_set_configuration(
56 u32 *FrameBuffer, 56 u32 *FrameBuffer,
57 u32 NumWords); 57 u32 NumWords);
58 58
59u32 fifo_icap_get_status(struct hwicap_drvdata *drvdata);
59void fifo_icap_reset(struct hwicap_drvdata *drvdata); 60void fifo_icap_reset(struct hwicap_drvdata *drvdata);
60void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata); 61void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata);
61 62
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 2284fa2a5a57..016f90567a52 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -36,7 +36,7 @@
36 *****************************************************************************/ 36 *****************************************************************************/
37 37
38/* 38/*
39 * This is the code behind /dev/xilinx_icap -- it allows a user-space 39 * This is the code behind /dev/icap* -- it allows a user-space
40 * application to use the Xilinx ICAP subsystem. 40 * application to use the Xilinx ICAP subsystem.
41 * 41 *
42 * The following operations are possible: 42 * The following operations are possible:
@@ -67,7 +67,7 @@
67 * user-space application code that uses this device. The simplest 67 * user-space application code that uses this device. The simplest
68 * way to use this interface is simply: 68 * way to use this interface is simply:
69 * 69 *
70 * cp foo.bit /dev/xilinx_icap 70 * cp foo.bit /dev/icap0
71 * 71 *
72 * Note that unless foo.bit is an appropriately constructed partial 72 * Note that unless foo.bit is an appropriately constructed partial
73 * bitstream, this has a high likelyhood of overwriting the design 73 * bitstream, this has a high likelyhood of overwriting the design
@@ -105,18 +105,14 @@
105#include "buffer_icap.h" 105#include "buffer_icap.h"
106#include "fifo_icap.h" 106#include "fifo_icap.h"
107 107
108#define DRIVER_NAME "xilinx_icap" 108#define DRIVER_NAME "icap"
109 109
110#define HWICAP_REGS (0x10000) 110#define HWICAP_REGS (0x10000)
111 111
112/* dynamically allocate device number */ 112#define XHWICAP_MAJOR 259
113static int xhwicap_major; 113#define XHWICAP_MINOR 0
114static int xhwicap_minor;
115#define HWICAP_DEVICES 1 114#define HWICAP_DEVICES 1
116 115
117module_param(xhwicap_major, int, S_IRUGO);
118module_param(xhwicap_minor, int, S_IRUGO);
119
120/* An array, which is set to true when the device is registered. */ 116/* An array, which is set to true when the device is registered. */
121static bool probed_devices[HWICAP_DEVICES]; 117static bool probed_devices[HWICAP_DEVICES];
122static struct mutex icap_sem; 118static struct mutex icap_sem;
@@ -250,8 +246,26 @@ static int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
250 * Create the data to be written to the ICAP. 246 * Create the data to be written to the ICAP.
251 */ 247 */
252 buffer[index++] = XHI_DUMMY_PACKET; 248 buffer[index++] = XHI_DUMMY_PACKET;
249 buffer[index++] = XHI_NOOP_PACKET;
253 buffer[index++] = XHI_SYNC_PACKET; 250 buffer[index++] = XHI_SYNC_PACKET;
254 buffer[index++] = XHI_NOOP_PACKET; 251 buffer[index++] = XHI_NOOP_PACKET;
252 buffer[index++] = XHI_NOOP_PACKET;
253
254 /*
255 * Write the data to the FIFO and initiate the transfer of data present
256 * in the FIFO to the ICAP device.
257 */
258 status = drvdata->config->set_configuration(drvdata,
259 &buffer[0], index);
260 if (status)
261 return status;
262
263 /* If the syncword was not found, then we need to start over. */
264 status = drvdata->config->get_status(drvdata);
265 if ((status & XHI_SR_DALIGN_MASK) != XHI_SR_DALIGN_MASK)
266 return -EIO;
267
268 index = 0;
255 buffer[index++] = hwicap_type_1_read(reg) | 1; 269 buffer[index++] = hwicap_type_1_read(reg) | 1;
256 buffer[index++] = XHI_NOOP_PACKET; 270 buffer[index++] = XHI_NOOP_PACKET;
257 buffer[index++] = XHI_NOOP_PACKET; 271 buffer[index++] = XHI_NOOP_PACKET;
@@ -587,7 +601,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
587 probed_devices[id] = 1; 601 probed_devices[id] = 1;
588 mutex_unlock(&icap_sem); 602 mutex_unlock(&icap_sem);
589 603
590 devt = MKDEV(xhwicap_major, xhwicap_minor + id); 604 devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR + id);
591 605
592 drvdata = kzalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); 606 drvdata = kzalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL);
593 if (!drvdata) { 607 if (!drvdata) {
@@ -664,12 +678,14 @@ static int __devinit hwicap_setup(struct device *dev, int id,
664static struct hwicap_driver_config buffer_icap_config = { 678static struct hwicap_driver_config buffer_icap_config = {
665 .get_configuration = buffer_icap_get_configuration, 679 .get_configuration = buffer_icap_get_configuration,
666 .set_configuration = buffer_icap_set_configuration, 680 .set_configuration = buffer_icap_set_configuration,
681 .get_status = buffer_icap_get_status,
667 .reset = buffer_icap_reset, 682 .reset = buffer_icap_reset,
668}; 683};
669 684
670static struct hwicap_driver_config fifo_icap_config = { 685static struct hwicap_driver_config fifo_icap_config = {
671 .get_configuration = fifo_icap_get_configuration, 686 .get_configuration = fifo_icap_get_configuration,
672 .set_configuration = fifo_icap_set_configuration, 687 .set_configuration = fifo_icap_set_configuration,
688 .get_status = fifo_icap_get_status,
673 .reset = fifo_icap_reset, 689 .reset = fifo_icap_reset,
674}; 690};
675 691
@@ -690,7 +706,7 @@ static int __devexit hwicap_remove(struct device *dev)
690 dev_set_drvdata(dev, NULL); 706 dev_set_drvdata(dev, NULL);
691 707
692 mutex_lock(&icap_sem); 708 mutex_lock(&icap_sem);
693 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0; 709 probed_devices[MINOR(dev->devt)-XHWICAP_MINOR] = 0;
694 mutex_unlock(&icap_sem); 710 mutex_unlock(&icap_sem);
695 return 0; /* success */ 711 return 0; /* success */
696} 712}
@@ -830,23 +846,12 @@ static int __init hwicap_module_init(void)
830 icap_class = class_create(THIS_MODULE, "xilinx_config"); 846 icap_class = class_create(THIS_MODULE, "xilinx_config");
831 mutex_init(&icap_sem); 847 mutex_init(&icap_sem);
832 848
833 if (xhwicap_major) { 849 devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
834 devt = MKDEV(xhwicap_major, xhwicap_minor); 850 retval = register_chrdev_region(devt,
835 retval = register_chrdev_region( 851 HWICAP_DEVICES,
836 devt, 852 DRIVER_NAME);
837 HWICAP_DEVICES, 853 if (retval < 0)
838 DRIVER_NAME); 854 return retval;
839 if (retval < 0)
840 return retval;
841 } else {
842 retval = alloc_chrdev_region(&devt,
843 xhwicap_minor,
844 HWICAP_DEVICES,
845 DRIVER_NAME);
846 if (retval < 0)
847 return retval;
848 xhwicap_major = MAJOR(devt);
849 }
850 855
851 retval = platform_driver_register(&hwicap_platform_driver); 856 retval = platform_driver_register(&hwicap_platform_driver);
852 857
@@ -871,7 +876,7 @@ static int __init hwicap_module_init(void)
871 876
872static void __exit hwicap_module_cleanup(void) 877static void __exit hwicap_module_cleanup(void)
873{ 878{
874 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor); 879 dev_t devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
875 880
876 class_destroy(icap_class); 881 class_destroy(icap_class);
877 882
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
index 405fee7e189b..1f9c8b082dbe 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
@@ -65,10 +65,27 @@ struct hwicap_drvdata {
65}; 65};
66 66
67struct hwicap_driver_config { 67struct hwicap_driver_config {
68 /* Read configuration data given by size into the data buffer.
69 Return 0 if successful. */
68 int (*get_configuration)(struct hwicap_drvdata *drvdata, u32 *data, 70 int (*get_configuration)(struct hwicap_drvdata *drvdata, u32 *data,
69 u32 size); 71 u32 size);
72 /* Write configuration data given by size from the data buffer.
73 Return 0 if successful. */
70 int (*set_configuration)(struct hwicap_drvdata *drvdata, u32 *data, 74 int (*set_configuration)(struct hwicap_drvdata *drvdata, u32 *data,
71 u32 size); 75 u32 size);
76 /* Get the status register, bit pattern given by:
77 * D8 - 0 = configuration error
78 * D7 - 1 = alignment found
79 * D6 - 1 = readback in progress
80 * D5 - 0 = abort in progress
81 * D4 - Always 1
82 * D3 - Always 1
83 * D2 - Always 1
84 * D1 - Always 1
85 * D0 - 1 = operation completed
86 */
87 u32 (*get_status)(struct hwicap_drvdata *drvdata);
88 /* Reset the hw */
72 void (*reset)(struct hwicap_drvdata *drvdata); 89 void (*reset)(struct hwicap_drvdata *drvdata);
73}; 90};
74 91
@@ -163,6 +180,13 @@ struct config_registers {
163/* Constant to use for CRC check when CRC has been disabled */ 180/* Constant to use for CRC check when CRC has been disabled */
164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL 181#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL
165 182
183/* Meanings of the bits returned by get_status */
184#define XHI_SR_CFGERR_N_MASK 0x00000100 /* Config Error Mask */
185#define XHI_SR_DALIGN_MASK 0x00000080 /* Data Alignment Mask */
186#define XHI_SR_RIP_MASK 0x00000040 /* Read back Mask */
187#define XHI_SR_IN_ABORT_N_MASK 0x00000020 /* Select Map Abort Mask */
188#define XHI_SR_DONE_MASK 0x00000001 /* Done bit Mask */
189
166/** 190/**
167 * hwicap_type_1_read - Generates a Type 1 read packet header. 191 * hwicap_type_1_read - Generates a Type 1 read packet header.
168 * @reg: is the address of the register to be read back. 192 * @reg: is the address of the register to be read back.
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index a52225470225..1525882190fd 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -1,3 +1,4 @@
1obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
1obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o 2obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
2obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o 3obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
3obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o 4obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
new file mode 100644
index 000000000000..f450588e5858
--- /dev/null
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -0,0 +1,302 @@
1#include <linux/init.h>
2#include <linux/clocksource.h>
3#include <linux/clockchips.h>
4#include <linux/interrupt.h>
5#include <linux/irq.h>
6
7#include <linux/clk.h>
8#include <linux/err.h>
9#include <linux/ioport.h>
10#include <linux/io.h>
11#include <linux/platform_device.h>
12#include <linux/atmel_tc.h>
13
14
15/*
16 * We're configured to use a specific TC block, one that's not hooked
17 * up to external hardware, to provide a time solution:
18 *
19 * - Two channels combine to create a free-running 32 bit counter
20 * with a base rate of 5+ MHz, packaged as a clocksource (with
21 * resolution better than 200 nsec).
22 *
23 * - The third channel may be used to provide a 16-bit clockevent
24 * source, used in either periodic or oneshot mode. This runs
25 * at 32 KiHZ, and can handle delays of up to two seconds.
26 *
27 * A boot clocksource and clockevent source are also currently needed,
28 * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
29 * this code can be used when init_timers() is called, well before most
30 * devices are set up. (Some low end AT91 parts, which can run uClinux,
31 * have only the timers in one TC block... they currently don't support
32 * the tclib code, because of that initialization issue.)
33 *
34 * REVISIT behavior during system suspend states... we should disable
35 * all clocks and save the power. Easily done for clockevent devices,
36 * but clocksources won't necessarily get the needed notifications.
37 * For deeper system sleep states, this will be mandatory...
38 */
39
40static void __iomem *tcaddr;
41
42static cycle_t tc_get_cycles(void)
43{
44 unsigned long flags;
45 u32 lower, upper;
46
47 raw_local_irq_save(flags);
48 do {
49 upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV));
50 lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
51 } while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)));
52
53 raw_local_irq_restore(flags);
54 return (upper << 16) | lower;
55}
56
57static struct clocksource clksrc = {
58 .name = "tcb_clksrc",
59 .rating = 200,
60 .read = tc_get_cycles,
61 .mask = CLOCKSOURCE_MASK(32),
62 .shift = 18,
63 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
64};
65
66#ifdef CONFIG_GENERIC_CLOCKEVENTS
67
68struct tc_clkevt_device {
69 struct clock_event_device clkevt;
70 struct clk *clk;
71 void __iomem *regs;
72};
73
74static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt)
75{
76 return container_of(clkevt, struct tc_clkevt_device, clkevt);
77}
78
79/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
80 * because using one of the divided clocks would usually mean the
81 * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
82 *
83 * A divided clock could be good for high resolution timers, since
84 * 30.5 usec resolution can seem "low".
85 */
86static u32 timer_clock;
87
88static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
89{
90 struct tc_clkevt_device *tcd = to_tc_clkevt(d);
91 void __iomem *regs = tcd->regs;
92
93 if (tcd->clkevt.mode == CLOCK_EVT_MODE_PERIODIC
94 || tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
95 __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
96 __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
97 clk_disable(tcd->clk);
98 }
99
100 switch (m) {
101
102 /* By not making the gentime core emulate periodic mode on top
103 * of oneshot, we get lower overhead and improved accuracy.
104 */
105 case CLOCK_EVT_MODE_PERIODIC:
106 clk_enable(tcd->clk);
107
108 /* slow clock, count up to RC, then irq and restart */
109 __raw_writel(timer_clock
110 | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
111 regs + ATMEL_TC_REG(2, CMR));
112 __raw_writel((32768 + HZ/2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
113
114 /* Enable clock and interrupts on RC compare */
115 __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
116
117 /* go go gadget! */
118 __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
119 regs + ATMEL_TC_REG(2, CCR));
120 break;
121
122 case CLOCK_EVT_MODE_ONESHOT:
123 clk_enable(tcd->clk);
124
125 /* slow clock, count up to RC, then irq and stop */
126 __raw_writel(timer_clock | ATMEL_TC_CPCSTOP
127 | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
128 regs + ATMEL_TC_REG(2, CMR));
129 __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
130
131 /* set_next_event() configures and starts the timer */
132 break;
133
134 default:
135 break;
136 }
137}
138
139static int tc_next_event(unsigned long delta, struct clock_event_device *d)
140{
141 __raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));
142
143 /* go go gadget! */
144 __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
145 tcaddr + ATMEL_TC_REG(2, CCR));
146 return 0;
147}
148
149static struct tc_clkevt_device clkevt = {
150 .clkevt = {
151 .name = "tc_clkevt",
152 .features = CLOCK_EVT_FEAT_PERIODIC
153 | CLOCK_EVT_FEAT_ONESHOT,
154 .shift = 32,
155 /* Should be lower than at91rm9200's system timer */
156 .rating = 125,
157 .cpumask = CPU_MASK_CPU0,
158 .set_next_event = tc_next_event,
159 .set_mode = tc_mode,
160 },
161};
162
163static irqreturn_t ch2_irq(int irq, void *handle)
164{
165 struct tc_clkevt_device *dev = handle;
166 unsigned int sr;
167
168 sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR));
169 if (sr & ATMEL_TC_CPCS) {
170 dev->clkevt.event_handler(&dev->clkevt);
171 return IRQ_HANDLED;
172 }
173
174 return IRQ_NONE;
175}
176
177static struct irqaction tc_irqaction = {
178 .name = "tc_clkevt",
179 .flags = IRQF_TIMER | IRQF_DISABLED,
180 .handler = ch2_irq,
181};
182
183static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
184{
185 struct clk *t2_clk = tc->clk[2];
186 int irq = tc->irq[2];
187
188 clkevt.regs = tc->regs;
189 clkevt.clk = t2_clk;
190 tc_irqaction.dev_id = &clkevt;
191
192 timer_clock = clk32k_divisor_idx;
193
194 clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
195 clkevt.clkevt.max_delta_ns
196 = clockevent_delta2ns(0xffff, &clkevt.clkevt);
197 clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
198
199 setup_irq(irq, &tc_irqaction);
200
201 clockevents_register_device(&clkevt.clkevt);
202}
203
204#else /* !CONFIG_GENERIC_CLOCKEVENTS */
205
206static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
207{
208 /* NOTHING */
209}
210
211#endif
212
213static int __init tcb_clksrc_init(void)
214{
215 static char bootinfo[] __initdata
216 = KERN_DEBUG "%s: tc%d at %d.%03d MHz\n";
217
218 struct platform_device *pdev;
219 struct atmel_tc *tc;
220 struct clk *t0_clk;
221 u32 rate, divided_rate = 0;
222 int best_divisor_idx = -1;
223 int clk32k_divisor_idx = -1;
224 int i;
225
226 tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK, clksrc.name);
227 if (!tc) {
228 pr_debug("can't alloc TC for clocksource\n");
229 return -ENODEV;
230 }
231 tcaddr = tc->regs;
232 pdev = tc->pdev;
233
234 t0_clk = tc->clk[0];
235 clk_enable(t0_clk);
236
237 /* How fast will we be counting? Pick something over 5 MHz. */
238 rate = (u32) clk_get_rate(t0_clk);
239 for (i = 0; i < 5; i++) {
240 unsigned divisor = atmel_tc_divisors[i];
241 unsigned tmp;
242
243 /* remember 32 KiHz clock for later */
244 if (!divisor) {
245 clk32k_divisor_idx = i;
246 continue;
247 }
248
249 tmp = rate / divisor;
250 pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
251 if (best_divisor_idx > 0) {
252 if (tmp < 5 * 1000 * 1000)
253 continue;
254 }
255 divided_rate = tmp;
256 best_divisor_idx = i;
257 }
258
259 clksrc.mult = clocksource_hz2mult(divided_rate, clksrc.shift);
260
261 printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
262 divided_rate / 1000000,
263 ((divided_rate + 500000) % 1000000) / 1000);
264
265 /* tclib will give us three clocks no matter what the
266 * underlying platform supports.
267 */
268 clk_enable(tc->clk[1]);
269
270 /* channel 0: waveform mode, input mclk/8, clock TIOA0 on overflow */
271 __raw_writel(best_divisor_idx /* likely divide-by-8 */
272 | ATMEL_TC_WAVE
273 | ATMEL_TC_WAVESEL_UP /* free-run */
274 | ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */
275 | ATMEL_TC_ACPC_CLEAR, /* (duty cycle 50%) */
276 tcaddr + ATMEL_TC_REG(0, CMR));
277 __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA));
278 __raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC));
279 __raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */
280 __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
281
282 /* channel 1: waveform mode, input TIOA0 */
283 __raw_writel(ATMEL_TC_XC1 /* input: TIOA0 */
284 | ATMEL_TC_WAVE
285 | ATMEL_TC_WAVESEL_UP, /* free-run */
286 tcaddr + ATMEL_TC_REG(1, CMR));
287 __raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR)); /* no irqs */
288 __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR));
289
290 /* chain channel 0 to channel 1, then reset all the timers */
291 __raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR);
292 __raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
293
294 /* and away we go! */
295 clocksource_register(&clksrc);
296
297 /* channel 2: periodic and oneshot timer support */
298 setup_clkevents(tc, clk32k_divisor_idx);
299
300 return 0;
301}
302arch_initcall(tcb_clksrc_init);
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 6d2f0c8d419a..43b71b69daa5 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -27,6 +27,7 @@ config CRYPTO_DEV_PADLOCK_AES
27 tristate "PadLock driver for AES algorithm" 27 tristate "PadLock driver for AES algorithm"
28 depends on CRYPTO_DEV_PADLOCK 28 depends on CRYPTO_DEV_PADLOCK
29 select CRYPTO_BLKCIPHER 29 select CRYPTO_BLKCIPHER
30 select CRYPTO_AES
30 help 31 help
31 Use VIA PadLock for AES algorithm. 32 Use VIA PadLock for AES algorithm.
32 33
@@ -101,6 +102,19 @@ config CRYPTO_SHA256_S390
101 This version of SHA implements a 256 bit hash with 128 bits of 102 This version of SHA implements a 256 bit hash with 128 bits of
102 security against collision attacks. 103 security against collision attacks.
103 104
105config CRYPTO_SHA512_S390
106 tristate "SHA384 and SHA512 digest algorithm"
107 depends on S390
108 select CRYPTO_ALGAPI
109 help
110 This is the s390 hardware accelerated implementation of the
111 SHA512 secure hash standard.
112
113 This version of SHA implements a 512 bit hash with 256 bits of
114 security against collision attacks. The code also includes SHA-384,
115 a 384 bit hash with 192 bits of security against collision attacks.
116
117
104config CRYPTO_DES_S390 118config CRYPTO_DES_S390
105 tristate "DES and Triple DES cipher algorithms" 119 tristate "DES and Triple DES cipher algorithms"
106 depends on S390 120 depends on S390
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 2f3ad3f7dfea..bb30eb9b93ef 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -5,42 +5,6 @@
5 * 5 *
6 * Copyright (c) 2004 Michal Ludvig <michal@logix.cz> 6 * Copyright (c) 2004 Michal Ludvig <michal@logix.cz>
7 * 7 *
8 * Key expansion routine taken from crypto/aes_generic.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * ---------------------------------------------------------------------------
16 * Copyright (c) 2002, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
17 * All rights reserved.
18 *
19 * LICENSE TERMS
20 *
21 * The free distribution and use of this software in both source and binary
22 * form is allowed (with or without changes) provided that:
23 *
24 * 1. distributions of this source code include the above copyright
25 * notice, this list of conditions and the following disclaimer;
26 *
27 * 2. distributions in binary form include the above copyright
28 * notice, this list of conditions and the following disclaimer
29 * in the documentation and/or other associated materials;
30 *
31 * 3. the copyright holder's name is not used to endorse products
32 * built using this software without specific written permission.
33 *
34 * ALTERNATIVELY, provided that this notice is retained in full, this product
35 * may be distributed under the terms of the GNU General Public License (GPL),
36 * in which case the provisions of the GPL apply INSTEAD OF those given above.
37 *
38 * DISCLAIMER
39 *
40 * This software is provided 'as is' with no explicit or implied warranties
41 * in respect of its properties, including, but not limited to, correctness
42 * and/or fitness for purpose.
43 * ---------------------------------------------------------------------------
44 */ 8 */
45 9
46#include <crypto/algapi.h> 10#include <crypto/algapi.h>
@@ -54,9 +18,6 @@
54#include <asm/byteorder.h> 18#include <asm/byteorder.h>
55#include "padlock.h" 19#include "padlock.h"
56 20
57#define AES_EXTENDED_KEY_SIZE 64 /* in uint32_t units */
58#define AES_EXTENDED_KEY_SIZE_B (AES_EXTENDED_KEY_SIZE * sizeof(uint32_t))
59
60/* Control word. */ 21/* Control word. */
61struct cword { 22struct cword {
62 unsigned int __attribute__ ((__packed__)) 23 unsigned int __attribute__ ((__packed__))
@@ -70,218 +31,23 @@ struct cword {
70 31
71/* Whenever making any changes to the following 32/* Whenever making any changes to the following
72 * structure *make sure* you keep E, d_data 33 * structure *make sure* you keep E, d_data
73 * and cword aligned on 16 Bytes boundaries!!! */ 34 * and cword aligned on 16 Bytes boundaries and
35 * the Hardware can access 16 * 16 bytes of E and d_data
36 * (only the first 15 * 16 bytes matter but the HW reads
37 * more).
38 */
74struct aes_ctx { 39struct aes_ctx {
40 u32 E[AES_MAX_KEYLENGTH_U32]
41 __attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
42 u32 d_data[AES_MAX_KEYLENGTH_U32]
43 __attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
75 struct { 44 struct {
76 struct cword encrypt; 45 struct cword encrypt;
77 struct cword decrypt; 46 struct cword decrypt;
78 } cword; 47 } cword;
79 u32 *D; 48 u32 *D;
80 int key_length;
81 u32 E[AES_EXTENDED_KEY_SIZE]
82 __attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
83 u32 d_data[AES_EXTENDED_KEY_SIZE]
84 __attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
85}; 49};
86 50
87/* ====== Key management routines ====== */
88
89static inline uint32_t
90generic_rotr32 (const uint32_t x, const unsigned bits)
91{
92 const unsigned n = bits % 32;
93 return (x >> n) | (x << (32 - n));
94}
95
96static inline uint32_t
97generic_rotl32 (const uint32_t x, const unsigned bits)
98{
99 const unsigned n = bits % 32;
100 return (x << n) | (x >> (32 - n));
101}
102
103#define rotl generic_rotl32
104#define rotr generic_rotr32
105
106/*
107 * #define byte(x, nr) ((unsigned char)((x) >> (nr*8)))
108 */
109static inline uint8_t
110byte(const uint32_t x, const unsigned n)
111{
112 return x >> (n << 3);
113}
114
115#define E_KEY ctx->E
116#define D_KEY ctx->D
117
118static uint8_t pow_tab[256];
119static uint8_t log_tab[256];
120static uint8_t sbx_tab[256];
121static uint8_t isb_tab[256];
122static uint32_t rco_tab[10];
123static uint32_t ft_tab[4][256];
124static uint32_t it_tab[4][256];
125
126static uint32_t fl_tab[4][256];
127static uint32_t il_tab[4][256];
128
129static inline uint8_t
130f_mult (uint8_t a, uint8_t b)
131{
132 uint8_t aa = log_tab[a], cc = aa + log_tab[b];
133
134 return pow_tab[cc + (cc < aa ? 1 : 0)];
135}
136
137#define ff_mult(a,b) (a && b ? f_mult(a, b) : 0)
138
139#define f_rn(bo, bi, n, k) \
140 bo[n] = ft_tab[0][byte(bi[n],0)] ^ \
141 ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
142 ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
143 ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
144
145#define i_rn(bo, bi, n, k) \
146 bo[n] = it_tab[0][byte(bi[n],0)] ^ \
147 it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
148 it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
149 it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
150
151#define ls_box(x) \
152 ( fl_tab[0][byte(x, 0)] ^ \
153 fl_tab[1][byte(x, 1)] ^ \
154 fl_tab[2][byte(x, 2)] ^ \
155 fl_tab[3][byte(x, 3)] )
156
157#define f_rl(bo, bi, n, k) \
158 bo[n] = fl_tab[0][byte(bi[n],0)] ^ \
159 fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
160 fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
161 fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
162
163#define i_rl(bo, bi, n, k) \
164 bo[n] = il_tab[0][byte(bi[n],0)] ^ \
165 il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
166 il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
167 il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
168
169static void
170gen_tabs (void)
171{
172 uint32_t i, t;
173 uint8_t p, q;
174
175 /* log and power tables for GF(2**8) finite field with
176 0x011b as modular polynomial - the simplest prmitive
177 root is 0x03, used here to generate the tables */
178
179 for (i = 0, p = 1; i < 256; ++i) {
180 pow_tab[i] = (uint8_t) p;
181 log_tab[p] = (uint8_t) i;
182
183 p ^= (p << 1) ^ (p & 0x80 ? 0x01b : 0);
184 }
185
186 log_tab[1] = 0;
187
188 for (i = 0, p = 1; i < 10; ++i) {
189 rco_tab[i] = p;
190
191 p = (p << 1) ^ (p & 0x80 ? 0x01b : 0);
192 }
193
194 for (i = 0; i < 256; ++i) {
195 p = (i ? pow_tab[255 - log_tab[i]] : 0);
196 q = ((p >> 7) | (p << 1)) ^ ((p >> 6) | (p << 2));
197 p ^= 0x63 ^ q ^ ((q >> 6) | (q << 2));
198 sbx_tab[i] = p;
199 isb_tab[p] = (uint8_t) i;
200 }
201
202 for (i = 0; i < 256; ++i) {
203 p = sbx_tab[i];
204
205 t = p;
206 fl_tab[0][i] = t;
207 fl_tab[1][i] = rotl (t, 8);
208 fl_tab[2][i] = rotl (t, 16);
209 fl_tab[3][i] = rotl (t, 24);
210
211 t = ((uint32_t) ff_mult (2, p)) |
212 ((uint32_t) p << 8) |
213 ((uint32_t) p << 16) | ((uint32_t) ff_mult (3, p) << 24);
214
215 ft_tab[0][i] = t;
216 ft_tab[1][i] = rotl (t, 8);
217 ft_tab[2][i] = rotl (t, 16);
218 ft_tab[3][i] = rotl (t, 24);
219
220 p = isb_tab[i];
221
222 t = p;
223 il_tab[0][i] = t;
224 il_tab[1][i] = rotl (t, 8);
225 il_tab[2][i] = rotl (t, 16);
226 il_tab[3][i] = rotl (t, 24);
227
228 t = ((uint32_t) ff_mult (14, p)) |
229 ((uint32_t) ff_mult (9, p) << 8) |
230 ((uint32_t) ff_mult (13, p) << 16) |
231 ((uint32_t) ff_mult (11, p) << 24);
232
233 it_tab[0][i] = t;
234 it_tab[1][i] = rotl (t, 8);
235 it_tab[2][i] = rotl (t, 16);
236 it_tab[3][i] = rotl (t, 24);
237 }
238}
239
240#define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
241
242#define imix_col(y,x) \
243 u = star_x(x); \
244 v = star_x(u); \
245 w = star_x(v); \
246 t = w ^ (x); \
247 (y) = u ^ v ^ w; \
248 (y) ^= rotr(u ^ t, 8) ^ \
249 rotr(v ^ t, 16) ^ \
250 rotr(t,24)
251
252/* initialise the key schedule from the user supplied key */
253
254#define loop4(i) \
255{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
256 t ^= E_KEY[4 * i]; E_KEY[4 * i + 4] = t; \
257 t ^= E_KEY[4 * i + 1]; E_KEY[4 * i + 5] = t; \
258 t ^= E_KEY[4 * i + 2]; E_KEY[4 * i + 6] = t; \
259 t ^= E_KEY[4 * i + 3]; E_KEY[4 * i + 7] = t; \
260}
261
262#define loop6(i) \
263{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
264 t ^= E_KEY[6 * i]; E_KEY[6 * i + 6] = t; \
265 t ^= E_KEY[6 * i + 1]; E_KEY[6 * i + 7] = t; \
266 t ^= E_KEY[6 * i + 2]; E_KEY[6 * i + 8] = t; \
267 t ^= E_KEY[6 * i + 3]; E_KEY[6 * i + 9] = t; \
268 t ^= E_KEY[6 * i + 4]; E_KEY[6 * i + 10] = t; \
269 t ^= E_KEY[6 * i + 5]; E_KEY[6 * i + 11] = t; \
270}
271
272#define loop8(i) \
273{ t = rotr(t, 8); ; t = ls_box(t) ^ rco_tab[i]; \
274 t ^= E_KEY[8 * i]; E_KEY[8 * i + 8] = t; \
275 t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t; \
276 t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t; \
277 t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t; \
278 t = E_KEY[8 * i + 4] ^ ls_box(t); \
279 E_KEY[8 * i + 12] = t; \
280 t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t; \
281 t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t; \
282 t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \
283}
284
285/* Tells whether the ACE is capable to generate 51/* Tells whether the ACE is capable to generate
286 the extended key for a given key_len. */ 52 the extended key for a given key_len. */
287static inline int 53static inline int
@@ -321,17 +87,13 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
321 struct aes_ctx *ctx = aes_ctx(tfm); 87 struct aes_ctx *ctx = aes_ctx(tfm);
322 const __le32 *key = (const __le32 *)in_key; 88 const __le32 *key = (const __le32 *)in_key;
323 u32 *flags = &tfm->crt_flags; 89 u32 *flags = &tfm->crt_flags;
324 uint32_t i, t, u, v, w; 90 struct crypto_aes_ctx gen_aes;
325 uint32_t P[AES_EXTENDED_KEY_SIZE];
326 uint32_t rounds;
327 91
328 if (key_len % 8) { 92 if (key_len % 8) {
329 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; 93 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
330 return -EINVAL; 94 return -EINVAL;
331 } 95 }
332 96
333 ctx->key_length = key_len;
334
335 /* 97 /*
336 * If the hardware is capable of generating the extended key 98 * If the hardware is capable of generating the extended key
337 * itself we must supply the plain key for both encryption 99 * itself we must supply the plain key for both encryption
@@ -339,10 +101,10 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
339 */ 101 */
340 ctx->D = ctx->E; 102 ctx->D = ctx->E;
341 103
342 E_KEY[0] = le32_to_cpu(key[0]); 104 ctx->E[0] = le32_to_cpu(key[0]);
343 E_KEY[1] = le32_to_cpu(key[1]); 105 ctx->E[1] = le32_to_cpu(key[1]);
344 E_KEY[2] = le32_to_cpu(key[2]); 106 ctx->E[2] = le32_to_cpu(key[2]);
345 E_KEY[3] = le32_to_cpu(key[3]); 107 ctx->E[3] = le32_to_cpu(key[3]);
346 108
347 /* Prepare control words. */ 109 /* Prepare control words. */
348 memset(&ctx->cword, 0, sizeof(ctx->cword)); 110 memset(&ctx->cword, 0, sizeof(ctx->cword));
@@ -361,56 +123,13 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
361 ctx->cword.encrypt.keygen = 1; 123 ctx->cword.encrypt.keygen = 1;
362 ctx->cword.decrypt.keygen = 1; 124 ctx->cword.decrypt.keygen = 1;
363 125
364 switch (key_len) { 126 if (crypto_aes_expand_key(&gen_aes, in_key, key_len)) {
365 case 16: 127 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
366 t = E_KEY[3]; 128 return -EINVAL;
367 for (i = 0; i < 10; ++i)
368 loop4 (i);
369 break;
370
371 case 24:
372 E_KEY[4] = le32_to_cpu(key[4]);
373 t = E_KEY[5] = le32_to_cpu(key[5]);
374 for (i = 0; i < 8; ++i)
375 loop6 (i);
376 break;
377
378 case 32:
379 E_KEY[4] = le32_to_cpu(key[4]);
380 E_KEY[5] = le32_to_cpu(key[5]);
381 E_KEY[6] = le32_to_cpu(key[6]);
382 t = E_KEY[7] = le32_to_cpu(key[7]);
383 for (i = 0; i < 7; ++i)
384 loop8 (i);
385 break;
386 }
387
388 D_KEY[0] = E_KEY[0];
389 D_KEY[1] = E_KEY[1];
390 D_KEY[2] = E_KEY[2];
391 D_KEY[3] = E_KEY[3];
392
393 for (i = 4; i < key_len + 24; ++i) {
394 imix_col (D_KEY[i], E_KEY[i]);
395 }
396
397 /* PadLock needs a different format of the decryption key. */
398 rounds = 10 + (key_len - 16) / 4;
399
400 for (i = 0; i < rounds; i++) {
401 P[((i + 1) * 4) + 0] = D_KEY[((rounds - i - 1) * 4) + 0];
402 P[((i + 1) * 4) + 1] = D_KEY[((rounds - i - 1) * 4) + 1];
403 P[((i + 1) * 4) + 2] = D_KEY[((rounds - i - 1) * 4) + 2];
404 P[((i + 1) * 4) + 3] = D_KEY[((rounds - i - 1) * 4) + 3];
405 } 129 }
406 130
407 P[0] = E_KEY[(rounds * 4) + 0]; 131 memcpy(ctx->E, gen_aes.key_enc, AES_MAX_KEYLENGTH);
408 P[1] = E_KEY[(rounds * 4) + 1]; 132 memcpy(ctx->D, gen_aes.key_dec, AES_MAX_KEYLENGTH);
409 P[2] = E_KEY[(rounds * 4) + 2];
410 P[3] = E_KEY[(rounds * 4) + 3];
411
412 memcpy(D_KEY, P, AES_EXTENDED_KEY_SIZE_B);
413
414 return 0; 133 return 0;
415} 134}
416 135
@@ -675,7 +394,6 @@ static int __init padlock_init(void)
675 return -ENODEV; 394 return -ENODEV;
676 } 395 }
677 396
678 gen_tabs();
679 if ((ret = crypto_register_alg(&aes_alg))) 397 if ((ret = crypto_register_alg(&aes_alg)))
680 goto aes_err; 398 goto aes_err;
681 399
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 2d01bc1b9752..d9c8daf7ae7d 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -26,7 +26,8 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <asm/semaphore.h> 29#include <linux/rwsem.h>
30#include <linux/semaphore.h>
30#include <asm/system.h> 31#include <asm/system.h>
31#include <linux/ctype.h> 32#include <linux/ctype.h>
32#include "fw-transaction.h" 33#include "fw-transaction.h"
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 3a59e9b783b0..ccf0e4cf108f 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -29,7 +29,6 @@
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32#include <asm/semaphore.h>
33 32
34#include "fw-transaction.h" 33#include "fw-transaction.h"
35#include "fw-topology.h" 34#include "fw-topology.h"
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 05f02a326f1c..40ffd767647d 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -93,4 +93,24 @@ config DMIID
93 information from userspace through /sys/class/dmi/id/ or if you want 93 information from userspace through /sys/class/dmi/id/ or if you want
94 DMI-based module auto-loading. 94 DMI-based module auto-loading.
95 95
96config ISCSI_IBFT_FIND
97 bool "iSCSI Boot Firmware Table Attributes"
98 depends on X86
99 default n
100 help
101 This option enables the kernel to find the region of memory
102 in which the ISCSI Boot Firmware Table (iBFT) resides. This
103 is necessary for iSCSI Boot Firmware Table Attributes module to work
104 properly.
105
106config ISCSI_IBFT
107 tristate "iSCSI Boot Firmware Table Attributes module"
108 depends on ISCSI_IBFT_FIND
109 default n
110 help
111 This option enables support for detection and exposing of iSCSI
112 Boot Firmware Table (iBFT) via sysfs to userspace. If you wish to
113 detect iSCSI boot parameters dynamically during system boot, say Y.
114 Otherwise, say N.
115
96endmenu 116endmenu
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 8d4ebc805a50..4c9147154df8 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -8,3 +8,5 @@ obj-$(CONFIG_EFI_PCDP) += pcdp.o
8obj-$(CONFIG_DELL_RBU) += dell_rbu.o 8obj-$(CONFIG_DELL_RBU) += dell_rbu.o
9obj-$(CONFIG_DCDBAS) += dcdbas.o 9obj-$(CONFIG_DCDBAS) += dcdbas.o
10obj-$(CONFIG_DMIID) += dmi-id.o 10obj-$(CONFIG_DMIID) += dmi-id.o
11obj-$(CONFIG_ISCSI_IBFT_FIND) += iscsi_ibft_find.o
12obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 1636806ec55e..f235940719e7 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -35,7 +35,6 @@
35#include <linux/types.h> 35#include <linux/types.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <asm/io.h> 37#include <asm/io.h>
38#include <asm/semaphore.h>
39 38
40#include "dcdbas.h" 39#include "dcdbas.h"
41 40
@@ -265,7 +264,7 @@ static int smi_request(struct smi_cmd *smi_cmd)
265 264
266 /* SMI requires CPU 0 */ 265 /* SMI requires CPU 0 */
267 old_mask = current->cpus_allowed; 266 old_mask = current->cpus_allowed;
268 set_cpus_allowed(current, cpumask_of_cpu(0)); 267 set_cpus_allowed_ptr(current, &cpumask_of_cpu(0));
269 if (smp_processor_id() != 0) { 268 if (smp_processor_id() != 0) {
270 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 269 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
271 __FUNCTION__); 270 __FUNCTION__);
@@ -285,7 +284,7 @@ static int smi_request(struct smi_cmd *smi_cmd)
285 ); 284 );
286 285
287out: 286out:
288 set_cpus_allowed(current, old_mask); 287 set_cpus_allowed_ptr(current, &old_mask);
289 return ret; 288 return ret;
290} 289}
291 290
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
new file mode 100644
index 000000000000..8024e3bfd877
--- /dev/null
+++ b/drivers/firmware/iscsi_ibft.c
@@ -0,0 +1,982 @@
1/*
2 * Copyright 2007 Red Hat, Inc.
3 * by Peter Jones <pjones@redhat.com>
4 * Copyright 2008 IBM, Inc.
5 * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
6 * Copyright 2008
7 * by Konrad Rzeszutek <ketuzsezr@darnok.org>
8 *
9 * This code exposes the iSCSI Boot Format Table to userland via sysfs.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License v2.0 as published by
13 * the Free Software Foundation
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * Changelog:
21 *
22 * 14 Mar 2008 - Konrad Rzeszutek <ketuzsezr@darnok.org>
23 * Updated comments and copyrights. (v0.4.9)
24 *
25 * 11 Feb 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
26 * Converted to using ibft_addr. (v0.4.8)
27 *
28 * 8 Feb 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
29 * Combined two functions in one: reserve_ibft_region. (v0.4.7)
30 *
31 * 30 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
32 * Added logic to handle IPv6 addresses. (v0.4.6)
33 *
34 * 25 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
35 * Added logic to handle badly not-to-spec iBFT. (v0.4.5)
36 *
37 * 4 Jan 2008 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
38 * Added __init to function declarations. (v0.4.4)
39 *
40 * 21 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
41 * Updated kobject registration, combined unregister functions in one
42 * and code and style cleanup. (v0.4.3)
43 *
44 * 5 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
45 * Added end-markers to enums and re-organized kobject registration. (v0.4.2)
46 *
47 * 4 Dec 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
48 * Created 'device' sysfs link to the NIC and style cleanup. (v0.4.1)
49 *
50 * 28 Nov 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
51 * Added sysfs-ibft documentation, moved 'find_ibft' function to
52 * in its own file and added text attributes for every struct field. (v0.4)
53 *
54 * 21 Nov 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
55 * Added text attributes emulating OpenFirmware /proc/device-tree naming.
56 * Removed binary /sysfs interface (v0.3)
57 *
58 * 29 Aug 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
59 * Added functionality in setup.c to reserve iBFT region. (v0.2)
60 *
61 * 27 Aug 2007 - Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
62 * First version exposing iBFT data via a binary /sysfs. (v0.1)
63 *
64 */
65
66
67#include <linux/blkdev.h>
68#include <linux/capability.h>
69#include <linux/ctype.h>
70#include <linux/device.h>
71#include <linux/err.h>
72#include <linux/init.h>
73#include <linux/iscsi_ibft.h>
74#include <linux/limits.h>
75#include <linux/module.h>
76#include <linux/pci.h>
77#include <linux/slab.h>
78#include <linux/stat.h>
79#include <linux/string.h>
80#include <linux/types.h>
81
82#define IBFT_ISCSI_VERSION "0.4.9"
83#define IBFT_ISCSI_DATE "2008-Mar-14"
84
85MODULE_AUTHOR("Peter Jones <pjones@redhat.com> and \
86Konrad Rzeszutek <ketuzsezr@darnok.org>");
87MODULE_DESCRIPTION("sysfs interface to BIOS iBFT information");
88MODULE_LICENSE("GPL");
89MODULE_VERSION(IBFT_ISCSI_VERSION);
90
91struct ibft_hdr {
92 u8 id;
93 u8 version;
94 u16 length;
95 u8 index;
96 u8 flags;
97} __attribute__((__packed__));
98
99struct ibft_control {
100 struct ibft_hdr hdr;
101 u16 extensions;
102 u16 initiator_off;
103 u16 nic0_off;
104 u16 tgt0_off;
105 u16 nic1_off;
106 u16 tgt1_off;
107} __attribute__((__packed__));
108
109struct ibft_initiator {
110 struct ibft_hdr hdr;
111 char isns_server[16];
112 char slp_server[16];
113 char pri_radius_server[16];
114 char sec_radius_server[16];
115 u16 initiator_name_len;
116 u16 initiator_name_off;
117} __attribute__((__packed__));
118
119struct ibft_nic {
120 struct ibft_hdr hdr;
121 char ip_addr[16];
122 u8 subnet_mask_prefix;
123 u8 origin;
124 char gateway[16];
125 char primary_dns[16];
126 char secondary_dns[16];
127 char dhcp[16];
128 u16 vlan;
129 char mac[6];
130 u16 pci_bdf;
131 u16 hostname_len;
132 u16 hostname_off;
133} __attribute__((__packed__));
134
135struct ibft_tgt {
136 struct ibft_hdr hdr;
137 char ip_addr[16];
138 u16 port;
139 char lun[8];
140 u8 chap_type;
141 u8 nic_assoc;
142 u16 tgt_name_len;
143 u16 tgt_name_off;
144 u16 chap_name_len;
145 u16 chap_name_off;
146 u16 chap_secret_len;
147 u16 chap_secret_off;
148 u16 rev_chap_name_len;
149 u16 rev_chap_name_off;
150 u16 rev_chap_secret_len;
151 u16 rev_chap_secret_off;
152} __attribute__((__packed__));
153
154/*
155 * The kobject different types and its names.
156 *
157*/
158enum ibft_id {
159 id_reserved = 0, /* We don't support. */
160 id_control = 1, /* Should show up only once and is not exported. */
161 id_initiator = 2,
162 id_nic = 3,
163 id_target = 4,
164 id_extensions = 5, /* We don't support. */
165 id_end_marker,
166};
167
168/*
169 * We do not support the other types, hence the usage of NULL.
170 * This maps to the enum ibft_id.
171 */
172static const char *ibft_id_names[] =
173 {NULL, NULL, "initiator", "ethernet%d", "target%d", NULL, NULL};
174
175/*
176 * The text attributes names for each of the kobjects.
177*/
178enum ibft_eth_properties_enum {
179 ibft_eth_index,
180 ibft_eth_flags,
181 ibft_eth_ip_addr,
182 ibft_eth_subnet_mask,
183 ibft_eth_origin,
184 ibft_eth_gateway,
185 ibft_eth_primary_dns,
186 ibft_eth_secondary_dns,
187 ibft_eth_dhcp,
188 ibft_eth_vlan,
189 ibft_eth_mac,
190 /* ibft_eth_pci_bdf - this is replaced by link to the device itself. */
191 ibft_eth_hostname,
192 ibft_eth_end_marker,
193};
194
195static const char *ibft_eth_properties[] =
196 {"index", "flags", "ip-addr", "subnet-mask", "origin", "gateway",
197 "primary-dns", "secondary-dns", "dhcp", "vlan", "mac", "hostname",
198 NULL};
199
200enum ibft_tgt_properties_enum {
201 ibft_tgt_index,
202 ibft_tgt_flags,
203 ibft_tgt_ip_addr,
204 ibft_tgt_port,
205 ibft_tgt_lun,
206 ibft_tgt_chap_type,
207 ibft_tgt_nic_assoc,
208 ibft_tgt_name,
209 ibft_tgt_chap_name,
210 ibft_tgt_chap_secret,
211 ibft_tgt_rev_chap_name,
212 ibft_tgt_rev_chap_secret,
213 ibft_tgt_end_marker,
214};
215
216static const char *ibft_tgt_properties[] =
217 {"index", "flags", "ip-addr", "port", "lun", "chap-type", "nic-assoc",
218 "target-name", "chap-name", "chap-secret", "rev-chap-name",
219 "rev-chap-name-secret", NULL};
220
221enum ibft_initiator_properties_enum {
222 ibft_init_index,
223 ibft_init_flags,
224 ibft_init_isns_server,
225 ibft_init_slp_server,
226 ibft_init_pri_radius_server,
227 ibft_init_sec_radius_server,
228 ibft_init_initiator_name,
229 ibft_init_end_marker,
230};
231
232static const char *ibft_initiator_properties[] =
233 {"index", "flags", "isns-server", "slp-server", "pri-radius-server",
234 "sec-radius-server", "initiator-name", NULL};
235
236/*
237 * The kobject and attribute structures.
238 */
239
240struct ibft_kobject {
241 struct ibft_table_header *header;
242 union {
243 struct ibft_initiator *initiator;
244 struct ibft_nic *nic;
245 struct ibft_tgt *tgt;
246 struct ibft_hdr *hdr;
247 };
248 struct kobject kobj;
249 struct list_head node;
250};
251
252struct ibft_attribute {
253 struct attribute attr;
254 ssize_t (*show) (struct ibft_kobject *entry,
255 struct ibft_attribute *attr, char *buf);
256 union {
257 struct ibft_initiator *initiator;
258 struct ibft_nic *nic;
259 struct ibft_tgt *tgt;
260 struct ibft_hdr *hdr;
261 };
262 struct kobject *kobj;
263 int type; /* The enum of the type. This can be any value of:
264 ibft_eth_properties_enum, ibft_tgt_properties_enum,
265 or ibft_initiator_properties_enum. */
266 struct list_head node;
267};
268
269static LIST_HEAD(ibft_attr_list);
270static LIST_HEAD(ibft_kobject_list);
271
272static const char nulls[16];
273
274/*
275 * Helper functions to parse data properly.
276 */
277static ssize_t sprintf_ipaddr(char *buf, u8 *ip)
278{
279 char *str = buf;
280
281 if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 &&
282 ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && ip[7] == 0 &&
283 ip[8] == 0 && ip[9] == 0 && ip[10] == 0xff && ip[11] == 0xff) {
284 /*
285 * IPV4
286 */
287 str += sprintf(buf, NIPQUAD_FMT, ip[12],
288 ip[13], ip[14], ip[15]);
289 } else {
290 /*
291 * IPv6
292 */
293 str += sprintf(str, NIP6_FMT, ntohs(ip[0]), ntohs(ip[1]),
294 ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]),
295 ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7]));
296 }
297 str += sprintf(str, "\n");
298 return str - buf;
299}
300
301static ssize_t sprintf_string(char *str, int len, char *buf)
302{
303 return sprintf(str, "%.*s\n", len, buf);
304}
305
306/*
307 * Helper function to verify the IBFT header.
308 */
309static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int length)
310{
311 if (hdr->id != id) {
312 printk(KERN_ERR "iBFT error: We expected the " \
313 "field header.id to have %d but " \
314 "found %d instead!\n", id, hdr->id);
315 return -ENODEV;
316 }
317 if (hdr->length != length) {
318 printk(KERN_ERR "iBFT error: We expected the " \
319 "field header.length to have %d but " \
320 "found %d instead!\n", length, hdr->length);
321 return -ENODEV;
322 }
323
324 return 0;
325}
326
327static void ibft_release(struct kobject *kobj)
328{
329 struct ibft_kobject *ibft =
330 container_of(kobj, struct ibft_kobject, kobj);
331 kfree(ibft);
332}
333
334/*
335 * Routines for parsing the iBFT data to be human readable.
336 */
337ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
338 struct ibft_attribute *attr,
339 char *buf)
340{
341 struct ibft_initiator *initiator = entry->initiator;
342 void *ibft_loc = entry->header;
343 char *str = buf;
344
345 if (!initiator)
346 return 0;
347
348 switch (attr->type) {
349 case ibft_init_index:
350 str += sprintf(str, "%d\n", initiator->hdr.index);
351 break;
352 case ibft_init_flags:
353 str += sprintf(str, "%d\n", initiator->hdr.flags);
354 break;
355 case ibft_init_isns_server:
356 str += sprintf_ipaddr(str, initiator->isns_server);
357 break;
358 case ibft_init_slp_server:
359 str += sprintf_ipaddr(str, initiator->slp_server);
360 break;
361 case ibft_init_pri_radius_server:
362 str += sprintf_ipaddr(str, initiator->pri_radius_server);
363 break;
364 case ibft_init_sec_radius_server:
365 str += sprintf_ipaddr(str, initiator->sec_radius_server);
366 break;
367 case ibft_init_initiator_name:
368 str += sprintf_string(str, initiator->initiator_name_len,
369 (char *)ibft_loc +
370 initiator->initiator_name_off);
371 break;
372 default:
373 break;
374 }
375
376 return str - buf;
377}
378
379ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
380 struct ibft_attribute *attr,
381 char *buf)
382{
383 struct ibft_nic *nic = entry->nic;
384 void *ibft_loc = entry->header;
385 char *str = buf;
386 char *mac;
387 int val;
388
389 if (!nic)
390 return 0;
391
392 switch (attr->type) {
393 case ibft_eth_index:
394 str += sprintf(str, "%d\n", nic->hdr.index);
395 break;
396 case ibft_eth_flags:
397 str += sprintf(str, "%d\n", nic->hdr.flags);
398 break;
399 case ibft_eth_ip_addr:
400 str += sprintf_ipaddr(str, nic->ip_addr);
401 break;
402 case ibft_eth_subnet_mask:
403 val = ~((1 << (32-nic->subnet_mask_prefix))-1);
404 str += sprintf(str, NIPQUAD_FMT,
405 (u8)(val >> 24), (u8)(val >> 16),
406 (u8)(val >> 8), (u8)(val));
407 break;
408 case ibft_eth_origin:
409 str += sprintf(str, "%d\n", nic->origin);
410 break;
411 case ibft_eth_gateway:
412 str += sprintf_ipaddr(str, nic->gateway);
413 break;
414 case ibft_eth_primary_dns:
415 str += sprintf_ipaddr(str, nic->primary_dns);
416 break;
417 case ibft_eth_secondary_dns:
418 str += sprintf_ipaddr(str, nic->secondary_dns);
419 break;
420 case ibft_eth_dhcp:
421 str += sprintf_ipaddr(str, nic->dhcp);
422 break;
423 case ibft_eth_vlan:
424 str += sprintf(str, "%d\n", nic->vlan);
425 break;
426 case ibft_eth_mac:
427 mac = nic->mac;
428 str += sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x\n",
429 (u8)mac[0], (u8)mac[1], (u8)mac[2],
430 (u8)mac[3], (u8)mac[4], (u8)mac[5]);
431 break;
432 case ibft_eth_hostname:
433 str += sprintf_string(str, nic->hostname_len,
434 (char *)ibft_loc + nic->hostname_off);
435 break;
436 default:
437 break;
438 }
439
440 return str - buf;
441};
442
443ssize_t ibft_attr_show_target(struct ibft_kobject *entry,
444 struct ibft_attribute *attr,
445 char *buf)
446{
447 struct ibft_tgt *tgt = entry->tgt;
448 void *ibft_loc = entry->header;
449 char *str = buf;
450 int i;
451
452 if (!tgt)
453 return 0;
454
455 switch (attr->type) {
456 case ibft_tgt_index:
457 str += sprintf(str, "%d\n", tgt->hdr.index);
458 break;
459 case ibft_tgt_flags:
460 str += sprintf(str, "%d\n", tgt->hdr.flags);
461 break;
462 case ibft_tgt_ip_addr:
463 str += sprintf_ipaddr(str, tgt->ip_addr);
464 break;
465 case ibft_tgt_port:
466 str += sprintf(str, "%d\n", tgt->port);
467 break;
468 case ibft_tgt_lun:
469 for (i = 0; i < 8; i++)
470 str += sprintf(str, "%x", (u8)tgt->lun[i]);
471 str += sprintf(str, "\n");
472 break;
473 case ibft_tgt_nic_assoc:
474 str += sprintf(str, "%d\n", tgt->nic_assoc);
475 break;
476 case ibft_tgt_chap_type:
477 str += sprintf(str, "%d\n", tgt->chap_type);
478 break;
479 case ibft_tgt_name:
480 str += sprintf_string(str, tgt->tgt_name_len,
481 (char *)ibft_loc + tgt->tgt_name_off);
482 break;
483 case ibft_tgt_chap_name:
484 str += sprintf_string(str, tgt->chap_name_len,
485 (char *)ibft_loc + tgt->chap_name_off);
486 break;
487 case ibft_tgt_chap_secret:
488 str += sprintf_string(str, tgt->chap_secret_len,
489 (char *)ibft_loc + tgt->chap_secret_off);
490 break;
491 case ibft_tgt_rev_chap_name:
492 str += sprintf_string(str, tgt->rev_chap_name_len,
493 (char *)ibft_loc +
494 tgt->rev_chap_name_off);
495 break;
496 case ibft_tgt_rev_chap_secret:
497 str += sprintf_string(str, tgt->rev_chap_secret_len,
498 (char *)ibft_loc +
499 tgt->rev_chap_secret_off);
500 break;
501 default:
502 break;
503 }
504
505 return str - buf;
506}
507
508/*
509 * The routine called for all sysfs attributes.
510 */
511static ssize_t ibft_show_attribute(struct kobject *kobj,
512 struct attribute *attr,
513 char *buf)
514{
515 struct ibft_kobject *dev =
516 container_of(kobj, struct ibft_kobject, kobj);
517 struct ibft_attribute *ibft_attr =
518 container_of(attr, struct ibft_attribute, attr);
519 ssize_t ret = -EIO;
520 char *str = buf;
521
522 if (!capable(CAP_SYS_ADMIN))
523 return -EACCES;
524
525 if (ibft_attr->show)
526 ret = ibft_attr->show(dev, ibft_attr, str);
527
528 return ret;
529}
530
531static struct sysfs_ops ibft_attr_ops = {
532 .show = ibft_show_attribute,
533};
534
535static struct kobj_type ibft_ktype = {
536 .release = ibft_release,
537 .sysfs_ops = &ibft_attr_ops,
538};
539
540static struct kset *ibft_kset;
541
542static int __init ibft_check_device(void)
543{
544 int len;
545 u8 *pos;
546 u8 csum = 0;
547
548 len = ibft_addr->length;
549
550 /* Sanity checking of iBFT. */
551 if (ibft_addr->revision != 1) {
552 printk(KERN_ERR "iBFT module supports only revision 1, " \
553 "while this is %d.\n", ibft_addr->revision);
554 return -ENOENT;
555 }
556 for (pos = (u8 *)ibft_addr; pos < (u8 *)ibft_addr + len; pos++)
557 csum += *pos;
558
559 if (csum) {
560 printk(KERN_ERR "iBFT has incorrect checksum (0x%x)!\n", csum);
561 return -ENOENT;
562 }
563
564 return 0;
565}
566
567/*
568 * Helper function for ibft_register_kobjects.
569 */
570static int __init ibft_create_kobject(struct ibft_table_header *header,
571 struct ibft_hdr *hdr,
572 struct list_head *list)
573{
574 struct ibft_kobject *ibft_kobj = NULL;
575 struct ibft_nic *nic = (struct ibft_nic *)hdr;
576 struct pci_dev *pci_dev;
577 int rc = 0;
578
579 ibft_kobj = kzalloc(sizeof(*ibft_kobj), GFP_KERNEL);
580 if (!ibft_kobj)
581 return -ENOMEM;
582
583 ibft_kobj->header = header;
584 ibft_kobj->hdr = hdr;
585
586 switch (hdr->id) {
587 case id_initiator:
588 rc = ibft_verify_hdr("initiator", hdr, id_initiator,
589 sizeof(*ibft_kobj->initiator));
590 break;
591 case id_nic:
592 rc = ibft_verify_hdr("ethernet", hdr, id_nic,
593 sizeof(*ibft_kobj->nic));
594 break;
595 case id_target:
596 rc = ibft_verify_hdr("target", hdr, id_target,
597 sizeof(*ibft_kobj->tgt));
598 break;
599 case id_reserved:
600 case id_control:
601 case id_extensions:
602 /* Fields which we don't support. Ignore them */
603 rc = 1;
604 break;
605 default:
606 printk(KERN_ERR "iBFT has unknown structure type (%d). " \
607 "Report this bug to %.6s!\n", hdr->id,
608 header->oem_id);
609 rc = 1;
610 break;
611 }
612
613 if (rc) {
614 /* Skip adding this kobject, but exit with non-fatal error. */
615 kfree(ibft_kobj);
616 goto out_invalid_struct;
617 }
618
619 ibft_kobj->kobj.kset = ibft_kset;
620
621 rc = kobject_init_and_add(&ibft_kobj->kobj, &ibft_ktype,
622 NULL, ibft_id_names[hdr->id], hdr->index);
623
624 if (rc) {
625 kfree(ibft_kobj);
626 goto out;
627 }
628
629 kobject_uevent(&ibft_kobj->kobj, KOBJ_ADD);
630
631 if (hdr->id == id_nic) {
632 /*
633 * We don't search for the device in other domains than
634 * zero. This is because on x86 platforms the BIOS
635 * executes only devices which are in domain 0. Furthermore, the
636 * iBFT spec doesn't have a domain id field :-(
637 */
638 pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >> 8,
639 (nic->pci_bdf & 0xff));
640 if (pci_dev) {
641 rc = sysfs_create_link(&ibft_kobj->kobj,
642 &pci_dev->dev.kobj, "device");
643 pci_dev_put(pci_dev);
644 }
645 }
646
647 /* Nothing broke so lets add it to the list. */
648 list_add_tail(&ibft_kobj->node, list);
649out:
650 return rc;
651out_invalid_struct:
652 /* Unsupported structs are skipped. */
653 return 0;
654}
655
656/*
657 * Scan the IBFT table structure for the NIC and Target fields. When
658 * found add them on the passed-in list. We do not support the other
659 * fields at this point, so they are skipped.
660 */
661static int __init ibft_register_kobjects(struct ibft_table_header *header,
662 struct list_head *list)
663{
664 struct ibft_control *control = NULL;
665 void *ptr, *end;
666 int rc = 0;
667 u16 offset;
668 u16 eot_offset;
669
670 control = (void *)header + sizeof(*header);
671 end = (void *)control + control->hdr.length;
672 eot_offset = (void *)header + header->length -
673 (void *)control - sizeof(*header);
674 rc = ibft_verify_hdr("control", (struct ibft_hdr *)control, id_control,
675 sizeof(*control));
676
677 /* iBFT table safety checking */
678 rc |= ((control->hdr.index) ? -ENODEV : 0);
679 if (rc) {
680 printk(KERN_ERR "iBFT error: Control header is invalid!\n");
681 return rc;
682 }
683 for (ptr = &control->initiator_off; ptr < end; ptr += sizeof(u16)) {
684 offset = *(u16 *)ptr;
685 if (offset && offset < header->length && offset < eot_offset) {
686 rc = ibft_create_kobject(header,
687 (void *)header + offset,
688 list);
689 if (rc)
690 break;
691 }
692 }
693
694 return rc;
695}
696
697static void ibft_unregister(struct list_head *attr_list,
698 struct list_head *kobj_list)
699{
700 struct ibft_kobject *data = NULL, *n;
701 struct ibft_attribute *attr = NULL, *m;
702
703 list_for_each_entry_safe(attr, m, attr_list, node) {
704 sysfs_remove_file(attr->kobj, &attr->attr);
705 list_del(&attr->node);
706 kfree(attr);
707 };
708 list_del_init(attr_list);
709
710 list_for_each_entry_safe(data, n, kobj_list, node) {
711 list_del(&data->node);
712 if (data->hdr->id == id_nic)
713 sysfs_remove_link(&data->kobj, "device");
714 kobject_put(&data->kobj);
715 };
716 list_del_init(kobj_list);
717}
718
719static int __init ibft_create_attribute(struct ibft_kobject *kobj_data,
720 int type,
721 const char *name,
722 ssize_t (*show)(struct ibft_kobject *,
723 struct ibft_attribute*,
724 char *buf),
725 struct list_head *list)
726{
727 struct ibft_attribute *attr = NULL;
728 struct ibft_hdr *hdr = kobj_data->hdr;
729
730 attr = kmalloc(sizeof(*attr), GFP_KERNEL);
731 if (!attr)
732 return -ENOMEM;
733
734 attr->attr.name = name;
735 attr->attr.mode = S_IRUSR;
736 attr->attr.owner = THIS_MODULE;
737
738 attr->hdr = hdr;
739 attr->show = show;
740 attr->kobj = &kobj_data->kobj;
741 attr->type = type;
742
743 list_add_tail(&attr->node, list);
744
745 return 0;
746}
747
748/*
749 * Helper routiners to check to determine if the entry is valid
750 * in the proper iBFT structure.
751 */
752static int __init ibft_check_nic_for(struct ibft_nic *nic, int entry)
753{
754 int rc = 0;
755
756 switch (entry) {
757 case ibft_eth_index:
758 case ibft_eth_flags:
759 rc = 1;
760 break;
761 case ibft_eth_ip_addr:
762 if (!memcmp(nic->dhcp, nulls, sizeof(nic->dhcp)))
763 rc = 1;
764 break;
765 case ibft_eth_subnet_mask:
766 if (!memcmp(nic->dhcp, nulls, sizeof(nic->dhcp)))
767 rc = 1;
768 break;
769 case ibft_eth_origin:
770 rc = 1;
771 break;
772 case ibft_eth_gateway:
773 if (memcmp(nic->gateway, nulls, sizeof(nic->gateway)))
774 rc = 1;
775 break;
776 case ibft_eth_primary_dns:
777 if (memcmp(nic->primary_dns, nulls,
778 sizeof(nic->primary_dns)))
779 rc = 1;
780 break;
781 case ibft_eth_secondary_dns:
782 if (memcmp(nic->secondary_dns, nulls,
783 sizeof(nic->secondary_dns)))
784 rc = 1;
785 break;
786 case ibft_eth_dhcp:
787 if (memcmp(nic->dhcp, nulls, sizeof(nic->dhcp)))
788 rc = 1;
789 break;
790 case ibft_eth_vlan:
791 case ibft_eth_mac:
792 rc = 1;
793 break;
794 case ibft_eth_hostname:
795 if (nic->hostname_off)
796 rc = 1;
797 break;
798 default:
799 break;
800 }
801
802 return rc;
803}
804
805static int __init ibft_check_tgt_for(struct ibft_tgt *tgt, int entry)
806{
807 int rc = 0;
808
809 switch (entry) {
810 case ibft_tgt_index:
811 case ibft_tgt_flags:
812 case ibft_tgt_ip_addr:
813 case ibft_tgt_port:
814 case ibft_tgt_lun:
815 case ibft_tgt_nic_assoc:
816 case ibft_tgt_chap_type:
817 rc = 1;
818 case ibft_tgt_name:
819 if (tgt->tgt_name_len)
820 rc = 1;
821 break;
822 case ibft_tgt_chap_name:
823 case ibft_tgt_chap_secret:
824 if (tgt->chap_name_len)
825 rc = 1;
826 break;
827 case ibft_tgt_rev_chap_name:
828 case ibft_tgt_rev_chap_secret:
829 if (tgt->rev_chap_name_len)
830 rc = 1;
831 break;
832 default:
833 break;
834 }
835
836 return rc;
837}
838
839static int __init ibft_check_initiator_for(struct ibft_initiator *init,
840 int entry)
841{
842 int rc = 0;
843
844 switch (entry) {
845 case ibft_init_index:
846 case ibft_init_flags:
847 rc = 1;
848 break;
849 case ibft_init_isns_server:
850 if (memcmp(init->isns_server, nulls,
851 sizeof(init->isns_server)))
852 rc = 1;
853 break;
854 case ibft_init_slp_server:
855 if (memcmp(init->slp_server, nulls,
856 sizeof(init->slp_server)))
857 rc = 1;
858 break;
859 case ibft_init_pri_radius_server:
860 if (memcmp(init->pri_radius_server, nulls,
861 sizeof(init->pri_radius_server)))
862 rc = 1;
863 break;
864 case ibft_init_sec_radius_server:
865 if (memcmp(init->sec_radius_server, nulls,
866 sizeof(init->sec_radius_server)))
867 rc = 1;
868 break;
869 case ibft_init_initiator_name:
870 if (init->initiator_name_len)
871 rc = 1;
872 break;
873 default:
874 break;
875 }
876
877 return rc;
878}
879
880/*
881 * Register the attributes for all of the kobjects.
882 */
883static int __init ibft_register_attributes(struct list_head *kobject_list,
884 struct list_head *attr_list)
885{
886 int rc = 0, i = 0;
887 struct ibft_kobject *data = NULL;
888 struct ibft_attribute *attr = NULL, *m;
889
890 list_for_each_entry(data, kobject_list, node) {
891 switch (data->hdr->id) {
892 case id_nic:
893 for (i = 0; i < ibft_eth_end_marker && !rc; i++)
894 if (ibft_check_nic_for(data->nic, i))
895 rc = ibft_create_attribute(data, i,
896 ibft_eth_properties[i],
897 ibft_attr_show_nic, attr_list);
898 break;
899 case id_target:
900 for (i = 0; i < ibft_tgt_end_marker && !rc; i++)
901 if (ibft_check_tgt_for(data->tgt, i))
902 rc = ibft_create_attribute(data, i,
903 ibft_tgt_properties[i],
904 ibft_attr_show_target,
905 attr_list);
906 break;
907 case id_initiator:
908 for (i = 0; i < ibft_init_end_marker && !rc; i++)
909 if (ibft_check_initiator_for(
910 data->initiator, i))
911 rc = ibft_create_attribute(data, i,
912 ibft_initiator_properties[i],
913 ibft_attr_show_initiator,
914 attr_list);
915 break;
916 default:
917 break;
918 }
919 if (rc)
920 break;
921 }
922 list_for_each_entry_safe(attr, m, attr_list, node) {
923 rc = sysfs_create_file(attr->kobj, &attr->attr);
924 if (rc) {
925 list_del(&attr->node);
926 kfree(attr);
927 break;
928 }
929 }
930
931 return rc;
932}
933
934/*
935 * ibft_init() - creates sysfs tree entries for the iBFT data.
936 */
937static int __init ibft_init(void)
938{
939 int rc = 0;
940
941 ibft_kset = kset_create_and_add("ibft", NULL, firmware_kobj);
942 if (!ibft_kset)
943 return -ENOMEM;
944
945 if (ibft_addr) {
946 printk(KERN_INFO "iBFT detected at 0x%lx.\n",
947 virt_to_phys((void *)ibft_addr));
948
949 rc = ibft_check_device();
950 if (rc)
951 goto out_firmware_unregister;
952
953 /* Scan the IBFT for data and register the kobjects. */
954 rc = ibft_register_kobjects(ibft_addr, &ibft_kobject_list);
955 if (rc)
956 goto out_free;
957
958 /* Register the attributes */
959 rc = ibft_register_attributes(&ibft_kobject_list,
960 &ibft_attr_list);
961 if (rc)
962 goto out_free;
963 } else
964 printk(KERN_INFO "No iBFT detected.\n");
965
966 return 0;
967
968out_free:
969 ibft_unregister(&ibft_attr_list, &ibft_kobject_list);
970out_firmware_unregister:
971 kset_unregister(ibft_kset);
972 return rc;
973}
974
975static void __exit ibft_exit(void)
976{
977 ibft_unregister(&ibft_attr_list, &ibft_kobject_list);
978 kset_unregister(ibft_kset);
979}
980
981module_init(ibft_init);
982module_exit(ibft_exit);
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c
new file mode 100644
index 000000000000..d0e5fa4ea51b
--- /dev/null
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -0,0 +1,84 @@
1/*
2 * Copyright 2007 Red Hat, Inc.
3 * by Peter Jones <pjones@redhat.com>
4 * Copyright 2007 IBM, Inc.
5 * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
6 * Copyright 2008
7 * by Konrad Rzeszutek <ketuzsezr@darnok.org>
8 *
9 * This code finds the iSCSI Boot Format Table.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License v2.0 as published by
13 * the Free Software Foundation
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 */
20
21#include <linux/bootmem.h>
22#include <linux/blkdev.h>
23#include <linux/ctype.h>
24#include <linux/device.h>
25#include <linux/err.h>
26#include <linux/init.h>
27#include <linux/limits.h>
28#include <linux/module.h>
29#include <linux/pci.h>
30#include <linux/slab.h>
31#include <linux/stat.h>
32#include <linux/string.h>
33#include <linux/types.h>
34
35#include <asm/mmzone.h>
36
37/*
38 * Physical location of iSCSI Boot Format Table.
39 */
40struct ibft_table_header *ibft_addr;
41EXPORT_SYMBOL_GPL(ibft_addr);
42
43#define IBFT_SIGN "iBFT"
44#define IBFT_SIGN_LEN 4
45#define IBFT_START 0x80000 /* 512kB */
46#define IBFT_END 0x100000 /* 1MB */
47#define VGA_MEM 0xA0000 /* VGA buffer */
48#define VGA_SIZE 0x20000 /* 128kB */
49
50
51/*
52 * Routine used to find the iSCSI Boot Format Table. The logical
53 * kernel address is set in the ibft_addr global variable.
54 */
55void __init reserve_ibft_region(void)
56{
57 unsigned long pos;
58 unsigned int len = 0;
59 void *virt;
60
61 ibft_addr = 0;
62
63 for (pos = IBFT_START; pos < IBFT_END; pos += 16) {
64 /* The table can't be inside the VGA BIOS reserved space,
65 * so skip that area */
66 if (pos == VGA_MEM)
67 pos += VGA_SIZE;
68 virt = phys_to_virt(pos);
69 if (memcmp(virt, IBFT_SIGN, IBFT_SIGN_LEN) == 0) {
70 unsigned long *addr =
71 (unsigned long *)phys_to_virt(pos + 4);
72 len = *addr;
73 /* if the length of the table extends past 1M,
74 * the table cannot be valid. */
75 if (pos + len <= (IBFT_END-1)) {
76 ibft_addr = (struct ibft_table_header *)virt;
77 break;
78 }
79 }
80 }
81 if (ibft_addr)
82 reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT);
83}
84EXPORT_SYMBOL_GPL(reserve_ibft_region);
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5fa9c3c67e0c..b04c99580d0d 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -645,7 +645,7 @@ config I2C_PCA_ISA
645 645
646config I2C_MV64XXX 646config I2C_MV64XXX
647 tristate "Marvell mv64xxx I2C Controller" 647 tristate "Marvell mv64xxx I2C Controller"
648 depends on (MV64X60 || ARCH_ORION) && EXPERIMENTAL 648 depends on (MV64X60 || PLAT_ORION) && EXPERIMENTAL
649 help 649 help
650 If you say yes to this option, support will be included for the 650 If you say yes to this option, support will be included for the
651 built-in I2C interface on the Marvell 64xxx line of host bridges. 651 built-in I2C interface on the Marvell 64xxx line of host bridges.
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 2d2087ad708f..6fd2d6a84eff 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -39,6 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40#include <asm/arch/i2c.h> 40#include <asm/arch/i2c.h>
41#include <asm/arch/pxa-regs.h> 41#include <asm/arch/pxa-regs.h>
42#include <asm/arch/pxa2xx-gpio.h>
42 43
43struct pxa_i2c { 44struct pxa_i2c {
44 spinlock_t lock; 45 spinlock_t lock;
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index b21593f93586..2da2edfa68ec 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -93,6 +93,7 @@ config ISP1301_OMAP
93 93
94config TPS65010 94config TPS65010
95 tristate "TPS6501x Power Management chips" 95 tristate "TPS6501x Power Management chips"
96 depends on HAVE_GPIO_LIB
96 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK 97 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK
97 help 98 help
98 If you say yes here you get support for the TPS6501x series of 99 If you say yes here you get support for the TPS6501x series of
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 4154a9108859..b67f69c2e7f3 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -30,9 +30,13 @@
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/platform_device.h>
33 34
34#include <linux/i2c/tps65010.h> 35#include <linux/i2c/tps65010.h>
35 36
37#include <asm/gpio.h>
38
39
36/*-------------------------------------------------------------------------*/ 40/*-------------------------------------------------------------------------*/
37 41
38#define DRIVER_VERSION "2 May 2005" 42#define DRIVER_VERSION "2 May 2005"
@@ -84,7 +88,9 @@ struct tps65010 {
84 u8 chgstatus, regstatus, chgconf; 88 u8 chgstatus, regstatus, chgconf;
85 u8 nmask1, nmask2; 89 u8 nmask1, nmask2;
86 90
87 /* not currently tracking GPIO state */ 91 u8 outmask;
92 struct gpio_chip chip;
93 struct platform_device *leds;
88}; 94};
89 95
90#define POWER_POLL_DELAY msecs_to_jiffies(5000) 96#define POWER_POLL_DELAY msecs_to_jiffies(5000)
@@ -449,12 +455,72 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)
449 455
450/*-------------------------------------------------------------------------*/ 456/*-------------------------------------------------------------------------*/
451 457
458/* offsets 0..3 == GPIO1..GPIO4
459 * offsets 4..5 == LED1/nPG, LED2 (we set one of the non-BLINK modes)
460 */
461static void
462tps65010_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
463{
464 if (offset < 4)
465 tps65010_set_gpio_out_value(offset + 1, value);
466 else
467 tps65010_set_led(offset - 3, value ? ON : OFF);
468}
469
470static int
471tps65010_output(struct gpio_chip *chip, unsigned offset, int value)
472{
473 /* GPIOs may be input-only */
474 if (offset < 4) {
475 struct tps65010 *tps;
476
477 tps = container_of(chip, struct tps65010, chip);
478 if (!(tps->outmask & (1 << offset)))
479 return -EINVAL;
480 tps65010_set_gpio_out_value(offset + 1, value);
481 } else
482 tps65010_set_led(offset - 3, value ? ON : OFF);
483
484 return 0;
485}
486
487static int tps65010_gpio_get(struct gpio_chip *chip, unsigned offset)
488{
489 int value;
490 struct tps65010 *tps;
491
492 tps = container_of(chip, struct tps65010, chip);
493
494 if (offset < 4) {
495 value = i2c_smbus_read_byte_data(tps->client, TPS_DEFGPIO);
496 if (value < 0)
497 return 0;
498 if (value & (1 << (offset + 4))) /* output */
499 return !(value & (1 << offset));
500 else /* input */
501 return (value & (1 << offset));
502 }
503
504 /* REVISIT we *could* report LED1/nPG and LED2 state ... */
505 return 0;
506}
507
508
509/*-------------------------------------------------------------------------*/
510
452static struct tps65010 *the_tps; 511static struct tps65010 *the_tps;
453 512
454static int __exit tps65010_remove(struct i2c_client *client) 513static int __exit tps65010_remove(struct i2c_client *client)
455{ 514{
456 struct tps65010 *tps = i2c_get_clientdata(client); 515 struct tps65010 *tps = i2c_get_clientdata(client);
516 struct tps65010_board *board = client->dev.platform_data;
457 517
518 if (board && board->teardown) {
519 int status = board->teardown(client, board->context);
520 if (status < 0)
521 dev_dbg(&client->dev, "board %s %s err %d\n",
522 "teardown", client->name, status);
523 }
458 if (client->irq > 0) 524 if (client->irq > 0)
459 free_irq(client->irq, tps); 525 free_irq(client->irq, tps);
460 cancel_delayed_work(&tps->work); 526 cancel_delayed_work(&tps->work);
@@ -469,6 +535,7 @@ static int tps65010_probe(struct i2c_client *client)
469{ 535{
470 struct tps65010 *tps; 536 struct tps65010 *tps;
471 int status; 537 int status;
538 struct tps65010_board *board = client->dev.platform_data;
472 539
473 if (the_tps) { 540 if (the_tps) {
474 dev_dbg(&client->dev, "only one tps6501x chip allowed\n"); 541 dev_dbg(&client->dev, "only one tps6501x chip allowed\n");
@@ -577,6 +644,38 @@ static int tps65010_probe(struct i2c_client *client)
577 644
578 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, 645 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
579 tps, DEBUG_FOPS); 646 tps, DEBUG_FOPS);
647
648 /* optionally register GPIOs */
649 if (board && board->base > 0) {
650 tps->outmask = board->outmask;
651
652 tps->chip.label = client->name;
653
654 tps->chip.set = tps65010_gpio_set;
655 tps->chip.direction_output = tps65010_output;
656
657 /* NOTE: only partial support for inputs; nyet IRQs */
658 tps->chip.get = tps65010_gpio_get;
659
660 tps->chip.base = board->base;
661 tps->chip.ngpio = 6;
662 tps->chip.can_sleep = 1;
663
664 status = gpiochip_add(&tps->chip);
665 if (status < 0)
666 dev_err(&client->dev, "can't add gpiochip, err %d\n",
667 status);
668 else if (board->setup) {
669 status = board->setup(client, board->context);
670 if (status < 0) {
671 dev_dbg(&client->dev,
672 "board %s %s err %d\n",
673 "setup", client->name, status);
674 status = 0;
675 }
676 }
677 }
678
580 return 0; 679 return 0;
581fail1: 680fail1:
582 kfree(tps); 681 kfree(tps);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 8b645c6b2cb5..e186df657119 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -35,8 +35,8 @@
35#include <linux/completion.h> 35#include <linux/completion.h>
36#include <linux/hardirq.h> 36#include <linux/hardirq.h>
37#include <linux/irqflags.h> 37#include <linux/irqflags.h>
38#include <linux/semaphore.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39#include <asm/semaphore.h>
40 40
41#include "i2c-core.h" 41#include "i2c-core.h"
42 42
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 70afa3786f3f..29d833e71cbf 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -18,8 +18,8 @@
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/freezer.h> 20#include <linux/freezer.h>
21#include <linux/semaphore.h>
21#include <asm/atomic.h> 22#include <asm/atomic.h>
22#include <asm/semaphore.h>
23 23
24#include "csr.h" 24#include "csr.h"
25#include "highlevel.h" 25#include "highlevel.h"
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 5a4b2e65534b..95756551cf7c 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -427,17 +427,17 @@ static struct kobj_type port_type = {
427 .default_attrs = port_default_attrs 427 .default_attrs = port_default_attrs
428}; 428};
429 429
430static void ib_device_release(struct class_device *cdev) 430static void ib_device_release(struct device *device)
431{ 431{
432 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 432 struct ib_device *dev = container_of(device, struct ib_device, dev);
433 433
434 kfree(dev); 434 kfree(dev);
435} 435}
436 436
437static int ib_device_uevent(struct class_device *cdev, 437static int ib_device_uevent(struct device *device,
438 struct kobj_uevent_env *env) 438 struct kobj_uevent_env *env)
439{ 439{
440 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 440 struct ib_device *dev = container_of(device, struct ib_device, dev);
441 441
442 if (add_uevent_var(env, "NAME=%s", dev->name)) 442 if (add_uevent_var(env, "NAME=%s", dev->name))
443 return -ENOMEM; 443 return -ENOMEM;
@@ -567,9 +567,10 @@ err_put:
567 return ret; 567 return ret;
568} 568}
569 569
570static ssize_t show_node_type(struct class_device *cdev, char *buf) 570static ssize_t show_node_type(struct device *device,
571 struct device_attribute *attr, char *buf)
571{ 572{
572 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 573 struct ib_device *dev = container_of(device, struct ib_device, dev);
573 574
574 if (!ibdev_is_alive(dev)) 575 if (!ibdev_is_alive(dev))
575 return -ENODEV; 576 return -ENODEV;
@@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf)
583 } 584 }
584} 585}
585 586
586static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) 587static ssize_t show_sys_image_guid(struct device *device,
588 struct device_attribute *dev_attr, char *buf)
587{ 589{
588 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 590 struct ib_device *dev = container_of(device, struct ib_device, dev);
589 struct ib_device_attr attr; 591 struct ib_device_attr attr;
590 ssize_t ret; 592 ssize_t ret;
591 593
@@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
603 be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); 605 be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3]));
604} 606}
605 607
606static ssize_t show_node_guid(struct class_device *cdev, char *buf) 608static ssize_t show_node_guid(struct device *device,
609 struct device_attribute *attr, char *buf)
607{ 610{
608 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 611 struct ib_device *dev = container_of(device, struct ib_device, dev);
609 612
610 if (!ibdev_is_alive(dev)) 613 if (!ibdev_is_alive(dev))
611 return -ENODEV; 614 return -ENODEV;
@@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
617 be16_to_cpu(((__be16 *) &dev->node_guid)[3])); 620 be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
618} 621}
619 622
620static ssize_t show_node_desc(struct class_device *cdev, char *buf) 623static ssize_t show_node_desc(struct device *device,
624 struct device_attribute *attr, char *buf)
621{ 625{
622 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 626 struct ib_device *dev = container_of(device, struct ib_device, dev);
623 627
624 return sprintf(buf, "%.64s\n", dev->node_desc); 628 return sprintf(buf, "%.64s\n", dev->node_desc);
625} 629}
626 630
627static ssize_t set_node_desc(struct class_device *cdev, const char *buf, 631static ssize_t set_node_desc(struct device *device,
628 size_t count) 632 struct device_attribute *attr,
633 const char *buf, size_t count)
629{ 634{
630 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 635 struct ib_device *dev = container_of(device, struct ib_device, dev);
631 struct ib_device_modify desc = {}; 636 struct ib_device_modify desc = {};
632 int ret; 637 int ret;
633 638
@@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
642 return count; 647 return count;
643} 648}
644 649
645static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); 650static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
646static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); 651static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
647static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); 652static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
648static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, 653static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc);
649 set_node_desc); 654
650 655static struct device_attribute *ib_class_attributes[] = {
651static struct class_device_attribute *ib_class_attributes[] = { 656 &dev_attr_node_type,
652 &class_device_attr_node_type, 657 &dev_attr_sys_image_guid,
653 &class_device_attr_sys_image_guid, 658 &dev_attr_node_guid,
654 &class_device_attr_node_guid, 659 &dev_attr_node_desc
655 &class_device_attr_node_desc
656}; 660};
657 661
658static struct class ib_class = { 662static struct class ib_class = {
659 .name = "infiniband", 663 .name = "infiniband",
660 .release = ib_device_release, 664 .dev_release = ib_device_release,
661 .uevent = ib_device_uevent, 665 .dev_uevent = ib_device_uevent,
662}; 666};
663 667
664int ib_device_register_sysfs(struct ib_device *device) 668int ib_device_register_sysfs(struct ib_device *device)
665{ 669{
666 struct class_device *class_dev = &device->class_dev; 670 struct device *class_dev = &device->dev;
667 int ret; 671 int ret;
668 int i; 672 int i;
669 673
670 class_dev->class = &ib_class; 674 class_dev->class = &ib_class;
671 class_dev->class_data = device; 675 class_dev->driver_data = device;
672 class_dev->dev = device->dma_device; 676 class_dev->parent = device->dma_device;
673 strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); 677 strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE);
674 678
675 INIT_LIST_HEAD(&device->port_list); 679 INIT_LIST_HEAD(&device->port_list);
676 680
677 ret = class_device_register(class_dev); 681 ret = device_register(class_dev);
678 if (ret) 682 if (ret)
679 goto err; 683 goto err;
680 684
681 for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { 685 for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
682 ret = class_device_create_file(class_dev, ib_class_attributes[i]); 686 ret = device_create_file(class_dev, ib_class_attributes[i]);
683 if (ret) 687 if (ret)
684 goto err_unregister; 688 goto err_unregister;
685 } 689 }
@@ -723,7 +727,7 @@ err_put:
723 kobject_put(&class_dev->kobj); 727 kobject_put(&class_dev->kobj);
724 728
725err_unregister: 729err_unregister:
726 class_device_unregister(class_dev); 730 device_unregister(class_dev);
727 731
728err: 732err:
729 return ret; 733 return ret;
@@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device)
744 } 748 }
745 749
746 kobject_put(device->ports_parent); 750 kobject_put(device->ports_parent);
747 class_device_unregister(&device->class_dev); 751 device_unregister(&device->dev);
748} 752}
749 753
750int ib_sysfs_setup(void) 754int ib_sysfs_setup(void)
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index 4291ab42a5b9..d7a6881b571d 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -58,8 +58,8 @@ MODULE_LICENSE("Dual BSD/GPL");
58 58
59struct ib_ucm_device { 59struct ib_ucm_device {
60 int devnum; 60 int devnum;
61 struct cdev dev; 61 struct cdev cdev;
62 struct class_device class_dev; 62 struct device dev;
63 struct ib_device *ib_dev; 63 struct ib_device *ib_dev;
64}; 64};
65 65
@@ -1171,7 +1171,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
1171 1171
1172 filp->private_data = file; 1172 filp->private_data = file;
1173 file->filp = filp; 1173 file->filp = filp;
1174 file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev); 1174 file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev);
1175 1175
1176 return 0; 1176 return 0;
1177} 1177}
@@ -1202,14 +1202,14 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
1202 return 0; 1202 return 0;
1203} 1203}
1204 1204
1205static void ucm_release_class_dev(struct class_device *class_dev) 1205static void ib_ucm_release_dev(struct device *dev)
1206{ 1206{
1207 struct ib_ucm_device *dev; 1207 struct ib_ucm_device *ucm_dev;
1208 1208
1209 dev = container_of(class_dev, struct ib_ucm_device, class_dev); 1209 ucm_dev = container_of(dev, struct ib_ucm_device, dev);
1210 cdev_del(&dev->dev); 1210 cdev_del(&ucm_dev->cdev);
1211 clear_bit(dev->devnum, dev_map); 1211 clear_bit(ucm_dev->devnum, dev_map);
1212 kfree(dev); 1212 kfree(ucm_dev);
1213} 1213}
1214 1214
1215static const struct file_operations ucm_fops = { 1215static const struct file_operations ucm_fops = {
@@ -1220,14 +1220,15 @@ static const struct file_operations ucm_fops = {
1220 .poll = ib_ucm_poll, 1220 .poll = ib_ucm_poll,
1221}; 1221};
1222 1222
1223static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 1223static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
1224 char *buf)
1224{ 1225{
1225 struct ib_ucm_device *dev; 1226 struct ib_ucm_device *ucm_dev;
1226 1227
1227 dev = container_of(class_dev, struct ib_ucm_device, class_dev); 1228 ucm_dev = container_of(dev, struct ib_ucm_device, dev);
1228 return sprintf(buf, "%s\n", dev->ib_dev->name); 1229 return sprintf(buf, "%s\n", ucm_dev->ib_dev->name);
1229} 1230}
1230static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1231static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
1231 1232
1232static void ib_ucm_add_one(struct ib_device *device) 1233static void ib_ucm_add_one(struct ib_device *device)
1233{ 1234{
@@ -1249,32 +1250,31 @@ static void ib_ucm_add_one(struct ib_device *device)
1249 1250
1250 set_bit(ucm_dev->devnum, dev_map); 1251 set_bit(ucm_dev->devnum, dev_map);
1251 1252
1252 cdev_init(&ucm_dev->dev, &ucm_fops); 1253 cdev_init(&ucm_dev->cdev, &ucm_fops);
1253 ucm_dev->dev.owner = THIS_MODULE; 1254 ucm_dev->cdev.owner = THIS_MODULE;
1254 kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum); 1255 kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum);
1255 if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) 1256 if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1))
1256 goto err; 1257 goto err;
1257 1258
1258 ucm_dev->class_dev.class = &cm_class; 1259 ucm_dev->dev.class = &cm_class;
1259 ucm_dev->class_dev.dev = device->dma_device; 1260 ucm_dev->dev.parent = device->dma_device;
1260 ucm_dev->class_dev.devt = ucm_dev->dev.dev; 1261 ucm_dev->dev.devt = ucm_dev->cdev.dev;
1261 ucm_dev->class_dev.release = ucm_release_class_dev; 1262 ucm_dev->dev.release = ib_ucm_release_dev;
1262 snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d", 1263 snprintf(ucm_dev->dev.bus_id, BUS_ID_SIZE, "ucm%d",
1263 ucm_dev->devnum); 1264 ucm_dev->devnum);
1264 if (class_device_register(&ucm_dev->class_dev)) 1265 if (device_register(&ucm_dev->dev))
1265 goto err_cdev; 1266 goto err_cdev;
1266 1267
1267 if (class_device_create_file(&ucm_dev->class_dev, 1268 if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev))
1268 &class_device_attr_ibdev)) 1269 goto err_dev;
1269 goto err_class;
1270 1270
1271 ib_set_client_data(device, &ucm_client, ucm_dev); 1271 ib_set_client_data(device, &ucm_client, ucm_dev);
1272 return; 1272 return;
1273 1273
1274err_class: 1274err_dev:
1275 class_device_unregister(&ucm_dev->class_dev); 1275 device_unregister(&ucm_dev->dev);
1276err_cdev: 1276err_cdev:
1277 cdev_del(&ucm_dev->dev); 1277 cdev_del(&ucm_dev->cdev);
1278 clear_bit(ucm_dev->devnum, dev_map); 1278 clear_bit(ucm_dev->devnum, dev_map);
1279err: 1279err:
1280 kfree(ucm_dev); 1280 kfree(ucm_dev);
@@ -1288,7 +1288,7 @@ static void ib_ucm_remove_one(struct ib_device *device)
1288 if (!ucm_dev) 1288 if (!ucm_dev)
1289 return; 1289 return;
1290 1290
1291 class_device_unregister(&ucm_dev->class_dev); 1291 device_unregister(&ucm_dev->dev);
1292} 1292}
1293 1293
1294static ssize_t show_abi_version(struct class *class, char *buf) 1294static ssize_t show_abi_version(struct class *class, char *buf)
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 4e915104ac4c..3aa2db54eae4 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -46,9 +46,9 @@
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/kref.h> 47#include <linux/kref.h>
48#include <linux/compat.h> 48#include <linux/compat.h>
49#include <linux/semaphore.h>
49 50
50#include <asm/uaccess.h> 51#include <asm/uaccess.h>
51#include <asm/semaphore.h>
52 52
53#include <rdma/ib_mad.h> 53#include <rdma/ib_mad.h>
54#include <rdma/ib_user_mad.h> 54#include <rdma/ib_user_mad.h>
@@ -88,11 +88,11 @@ enum {
88 */ 88 */
89 89
90struct ib_umad_port { 90struct ib_umad_port {
91 struct cdev *dev; 91 struct cdev *cdev;
92 struct class_device *class_dev; 92 struct device *dev;
93 93
94 struct cdev *sm_dev; 94 struct cdev *sm_cdev;
95 struct class_device *sm_class_dev; 95 struct device *sm_dev;
96 struct semaphore sm_sem; 96 struct semaphore sm_sem;
97 97
98 struct mutex file_mutex; 98 struct mutex file_mutex;
@@ -948,27 +948,29 @@ static struct ib_client umad_client = {
948 .remove = ib_umad_remove_one 948 .remove = ib_umad_remove_one
949}; 949};
950 950
951static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 951static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
952 char *buf)
952{ 953{
953 struct ib_umad_port *port = class_get_devdata(class_dev); 954 struct ib_umad_port *port = dev_get_drvdata(dev);
954 955
955 if (!port) 956 if (!port)
956 return -ENODEV; 957 return -ENODEV;
957 958
958 return sprintf(buf, "%s\n", port->ib_dev->name); 959 return sprintf(buf, "%s\n", port->ib_dev->name);
959} 960}
960static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 961static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
961 962
962static ssize_t show_port(struct class_device *class_dev, char *buf) 963static ssize_t show_port(struct device *dev, struct device_attribute *attr,
964 char *buf)
963{ 965{
964 struct ib_umad_port *port = class_get_devdata(class_dev); 966 struct ib_umad_port *port = dev_get_drvdata(dev);
965 967
966 if (!port) 968 if (!port)
967 return -ENODEV; 969 return -ENODEV;
968 970
969 return sprintf(buf, "%d\n", port->port_num); 971 return sprintf(buf, "%d\n", port->port_num);
970} 972}
971static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 973static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
972 974
973static ssize_t show_abi_version(struct class *class, char *buf) 975static ssize_t show_abi_version(struct class *class, char *buf)
974{ 976{
@@ -994,48 +996,47 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
994 mutex_init(&port->file_mutex); 996 mutex_init(&port->file_mutex);
995 INIT_LIST_HEAD(&port->file_list); 997 INIT_LIST_HEAD(&port->file_list);
996 998
997 port->dev = cdev_alloc(); 999 port->cdev = cdev_alloc();
998 if (!port->dev) 1000 if (!port->cdev)
999 return -1; 1001 return -1;
1000 port->dev->owner = THIS_MODULE; 1002 port->cdev->owner = THIS_MODULE;
1001 port->dev->ops = &umad_fops; 1003 port->cdev->ops = &umad_fops;
1002 kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num); 1004 kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num);
1003 if (cdev_add(port->dev, base_dev + port->dev_num, 1)) 1005 if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
1004 goto err_cdev; 1006 goto err_cdev;
1005 1007
1006 port->class_dev = class_device_create(umad_class, NULL, port->dev->dev, 1008 port->dev = device_create(umad_class, device->dma_device,
1007 device->dma_device, 1009 port->cdev->dev, "umad%d", port->dev_num);
1008 "umad%d", port->dev_num); 1010 if (IS_ERR(port->dev))
1009 if (IS_ERR(port->class_dev))
1010 goto err_cdev; 1011 goto err_cdev;
1011 1012
1012 if (class_device_create_file(port->class_dev, &class_device_attr_ibdev)) 1013 if (device_create_file(port->dev, &dev_attr_ibdev))
1013 goto err_class; 1014 goto err_dev;
1014 if (class_device_create_file(port->class_dev, &class_device_attr_port)) 1015 if (device_create_file(port->dev, &dev_attr_port))
1015 goto err_class; 1016 goto err_dev;
1016 1017
1017 port->sm_dev = cdev_alloc(); 1018 port->sm_cdev = cdev_alloc();
1018 if (!port->sm_dev) 1019 if (!port->sm_cdev)
1019 goto err_class; 1020 goto err_dev;
1020 port->sm_dev->owner = THIS_MODULE; 1021 port->sm_cdev->owner = THIS_MODULE;
1021 port->sm_dev->ops = &umad_sm_fops; 1022 port->sm_cdev->ops = &umad_sm_fops;
1022 kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num); 1023 kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num);
1023 if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1024 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
1024 goto err_sm_cdev; 1025 goto err_sm_cdev;
1025 1026
1026 port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev, 1027 port->sm_dev = device_create(umad_class, device->dma_device,
1027 device->dma_device, 1028 port->sm_cdev->dev,
1028 "issm%d", port->dev_num); 1029 "issm%d", port->dev_num);
1029 if (IS_ERR(port->sm_class_dev)) 1030 if (IS_ERR(port->sm_dev))
1030 goto err_sm_cdev; 1031 goto err_sm_cdev;
1031 1032
1032 class_set_devdata(port->class_dev, port); 1033 dev_set_drvdata(port->dev, port);
1033 class_set_devdata(port->sm_class_dev, port); 1034 dev_set_drvdata(port->sm_dev, port);
1034 1035
1035 if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev)) 1036 if (device_create_file(port->sm_dev, &dev_attr_ibdev))
1036 goto err_sm_class; 1037 goto err_sm_dev;
1037 if (class_device_create_file(port->sm_class_dev, &class_device_attr_port)) 1038 if (device_create_file(port->sm_dev, &dev_attr_port))
1038 goto err_sm_class; 1039 goto err_sm_dev;
1039 1040
1040 spin_lock(&port_lock); 1041 spin_lock(&port_lock);
1041 umad_port[port->dev_num] = port; 1042 umad_port[port->dev_num] = port;
@@ -1043,17 +1044,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
1043 1044
1044 return 0; 1045 return 0;
1045 1046
1046err_sm_class: 1047err_sm_dev:
1047 class_device_destroy(umad_class, port->sm_dev->dev); 1048 device_destroy(umad_class, port->sm_cdev->dev);
1048 1049
1049err_sm_cdev: 1050err_sm_cdev:
1050 cdev_del(port->sm_dev); 1051 cdev_del(port->sm_cdev);
1051 1052
1052err_class: 1053err_dev:
1053 class_device_destroy(umad_class, port->dev->dev); 1054 device_destroy(umad_class, port->cdev->dev);
1054 1055
1055err_cdev: 1056err_cdev:
1056 cdev_del(port->dev); 1057 cdev_del(port->cdev);
1057 clear_bit(port->dev_num, dev_map); 1058 clear_bit(port->dev_num, dev_map);
1058 1059
1059 return -1; 1060 return -1;
@@ -1065,14 +1066,14 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
1065 int already_dead; 1066 int already_dead;
1066 int id; 1067 int id;
1067 1068
1068 class_set_devdata(port->class_dev, NULL); 1069 dev_set_drvdata(port->dev, NULL);
1069 class_set_devdata(port->sm_class_dev, NULL); 1070 dev_set_drvdata(port->sm_dev, NULL);
1070 1071
1071 class_device_destroy(umad_class, port->dev->dev); 1072 device_destroy(umad_class, port->cdev->dev);
1072 class_device_destroy(umad_class, port->sm_dev->dev); 1073 device_destroy(umad_class, port->sm_cdev->dev);
1073 1074
1074 cdev_del(port->dev); 1075 cdev_del(port->cdev);
1075 cdev_del(port->sm_dev); 1076 cdev_del(port->sm_cdev);
1076 1077
1077 spin_lock(&port_lock); 1078 spin_lock(&port_lock);
1078 umad_port[port->dev_num] = NULL; 1079 umad_port[port->dev_num] = NULL;
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 2cad8b4b5292..376a57ce1b40 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -73,8 +73,8 @@ struct ib_uverbs_device {
73 struct kref ref; 73 struct kref ref;
74 struct completion comp; 74 struct completion comp;
75 int devnum; 75 int devnum;
76 struct cdev *dev; 76 struct cdev *cdev;
77 struct class_device *class_dev; 77 struct device *dev;
78 struct ib_device *ib_dev; 78 struct ib_device *ib_dev;
79 int num_comp_vectors; 79 int num_comp_vectors;
80}; 80};
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index f49f94653a96..cc1afa28c181 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -690,27 +690,29 @@ static struct ib_client uverbs_client = {
690 .remove = ib_uverbs_remove_one 690 .remove = ib_uverbs_remove_one
691}; 691};
692 692
693static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 693static ssize_t show_ibdev(struct device *device, struct device_attribute *attr,
694 char *buf)
694{ 695{
695 struct ib_uverbs_device *dev = class_get_devdata(class_dev); 696 struct ib_uverbs_device *dev = dev_get_drvdata(device);
696 697
697 if (!dev) 698 if (!dev)
698 return -ENODEV; 699 return -ENODEV;
699 700
700 return sprintf(buf, "%s\n", dev->ib_dev->name); 701 return sprintf(buf, "%s\n", dev->ib_dev->name);
701} 702}
702static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 703static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
703 704
704static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf) 705static ssize_t show_dev_abi_version(struct device *device,
706 struct device_attribute *attr, char *buf)
705{ 707{
706 struct ib_uverbs_device *dev = class_get_devdata(class_dev); 708 struct ib_uverbs_device *dev = dev_get_drvdata(device);
707 709
708 if (!dev) 710 if (!dev)
709 return -ENODEV; 711 return -ENODEV;
710 712
711 return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver); 713 return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver);
712} 714}
713static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); 715static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
714 716
715static ssize_t show_abi_version(struct class *class, char *buf) 717static ssize_t show_abi_version(struct class *class, char *buf)
716{ 718{
@@ -744,27 +746,26 @@ static void ib_uverbs_add_one(struct ib_device *device)
744 uverbs_dev->ib_dev = device; 746 uverbs_dev->ib_dev = device;
745 uverbs_dev->num_comp_vectors = device->num_comp_vectors; 747 uverbs_dev->num_comp_vectors = device->num_comp_vectors;
746 748
747 uverbs_dev->dev = cdev_alloc(); 749 uverbs_dev->cdev = cdev_alloc();
748 if (!uverbs_dev->dev) 750 if (!uverbs_dev->cdev)
749 goto err; 751 goto err;
750 uverbs_dev->dev->owner = THIS_MODULE; 752 uverbs_dev->cdev->owner = THIS_MODULE;
751 uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; 753 uverbs_dev->cdev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
752 kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum); 754 kobject_set_name(&uverbs_dev->cdev->kobj, "uverbs%d", uverbs_dev->devnum);
753 if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 755 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
754 goto err_cdev; 756 goto err_cdev;
755 757
756 uverbs_dev->class_dev = class_device_create(uverbs_class, NULL, 758 uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
757 uverbs_dev->dev->dev, 759 uverbs_dev->cdev->dev,
758 device->dma_device, 760 "uverbs%d", uverbs_dev->devnum);
759 "uverbs%d", uverbs_dev->devnum); 761 if (IS_ERR(uverbs_dev->dev))
760 if (IS_ERR(uverbs_dev->class_dev))
761 goto err_cdev; 762 goto err_cdev;
762 763
763 class_set_devdata(uverbs_dev->class_dev, uverbs_dev); 764 dev_set_drvdata(uverbs_dev->dev, uverbs_dev);
764 765
765 if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev)) 766 if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev))
766 goto err_class; 767 goto err_class;
767 if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version)) 768 if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
768 goto err_class; 769 goto err_class;
769 770
770 spin_lock(&map_lock); 771 spin_lock(&map_lock);
@@ -776,10 +777,10 @@ static void ib_uverbs_add_one(struct ib_device *device)
776 return; 777 return;
777 778
778err_class: 779err_class:
779 class_device_destroy(uverbs_class, uverbs_dev->dev->dev); 780 device_destroy(uverbs_class, uverbs_dev->cdev->dev);
780 781
781err_cdev: 782err_cdev:
782 cdev_del(uverbs_dev->dev); 783 cdev_del(uverbs_dev->cdev);
783 clear_bit(uverbs_dev->devnum, dev_map); 784 clear_bit(uverbs_dev->devnum, dev_map);
784 785
785err: 786err:
@@ -796,9 +797,9 @@ static void ib_uverbs_remove_one(struct ib_device *device)
796 if (!uverbs_dev) 797 if (!uverbs_dev)
797 return; 798 return;
798 799
799 class_set_devdata(uverbs_dev->class_dev, NULL); 800 dev_set_drvdata(uverbs_dev->dev, NULL);
800 class_device_destroy(uverbs_class, uverbs_dev->dev->dev); 801 device_destroy(uverbs_class, uverbs_dev->cdev->dev);
801 cdev_del(uverbs_dev->dev); 802 cdev_del(uverbs_dev->cdev);
802 803
803 spin_lock(&map_lock); 804 spin_lock(&map_lock);
804 dev_table[uverbs_dev->devnum] = NULL; 805 dev_table[uverbs_dev->devnum] = NULL;
diff --git a/drivers/infiniband/hw/amso1100/c2.h b/drivers/infiniband/hw/amso1100/c2.h
index ed38ab8d9c0c..d12a24a84fd9 100644
--- a/drivers/infiniband/hw/amso1100/c2.h
+++ b/drivers/infiniband/hw/amso1100/c2.h
@@ -40,7 +40,6 @@
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
42#include <linux/idr.h> 42#include <linux/idr.h>
43#include <asm/semaphore.h>
44 43
45#include "c2_provider.h" 44#include "c2_provider.h"
46#include "c2_mq.h" 45#include "c2_mq.h"
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index e10d27a6e145..6af2c0f79a67 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -523,45 +523,49 @@ static int c2_dereg_mr(struct ib_mr *ib_mr)
523 return err; 523 return err;
524} 524}
525 525
526static ssize_t show_rev(struct class_device *cdev, char *buf) 526static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
527 char *buf)
527{ 528{
528 struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); 529 struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
529 pr_debug("%s:%u\n", __func__, __LINE__); 530 pr_debug("%s:%u\n", __func__, __LINE__);
530 return sprintf(buf, "%x\n", dev->props.hw_ver); 531 return sprintf(buf, "%x\n", c2dev->props.hw_ver);
531} 532}
532 533
533static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 534static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
535 char *buf)
534{ 536{
535 struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); 537 struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
536 pr_debug("%s:%u\n", __func__, __LINE__); 538 pr_debug("%s:%u\n", __func__, __LINE__);
537 return sprintf(buf, "%x.%x.%x\n", 539 return sprintf(buf, "%x.%x.%x\n",
538 (int) (dev->props.fw_ver >> 32), 540 (int) (c2dev->props.fw_ver >> 32),
539 (int) (dev->props.fw_ver >> 16) & 0xffff, 541 (int) (c2dev->props.fw_ver >> 16) & 0xffff,
540 (int) (dev->props.fw_ver & 0xffff)); 542 (int) (c2dev->props.fw_ver & 0xffff));
541} 543}
542 544
543static ssize_t show_hca(struct class_device *cdev, char *buf) 545static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
546 char *buf)
544{ 547{
545 pr_debug("%s:%u\n", __func__, __LINE__); 548 pr_debug("%s:%u\n", __func__, __LINE__);
546 return sprintf(buf, "AMSO1100\n"); 549 return sprintf(buf, "AMSO1100\n");
547} 550}
548 551
549static ssize_t show_board(struct class_device *cdev, char *buf) 552static ssize_t show_board(struct device *dev, struct device_attribute *attr,
553 char *buf)
550{ 554{
551 pr_debug("%s:%u\n", __func__, __LINE__); 555 pr_debug("%s:%u\n", __func__, __LINE__);
552 return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID"); 556 return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID");
553} 557}
554 558
555static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 559static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
556static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 560static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
557static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 561static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
558static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 562static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
559 563
560static struct class_device_attribute *c2_class_attributes[] = { 564static struct device_attribute *c2_dev_attributes[] = {
561 &class_device_attr_hw_rev, 565 &dev_attr_hw_rev,
562 &class_device_attr_fw_ver, 566 &dev_attr_fw_ver,
563 &class_device_attr_hca_type, 567 &dev_attr_hca_type,
564 &class_device_attr_board_id 568 &dev_attr_board_id
565}; 569};
566 570
567static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 571static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
@@ -861,9 +865,9 @@ int c2_register_device(struct c2_dev *dev)
861 if (ret) 865 if (ret)
862 goto out1; 866 goto out1;
863 867
864 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { 868 for (i = 0; i < ARRAY_SIZE(c2_dev_attributes); ++i) {
865 ret = class_device_create_file(&dev->ibdev.class_dev, 869 ret = device_create_file(&dev->ibdev.dev,
866 c2_class_attributes[i]); 870 c2_dev_attributes[i]);
867 if (ret) 871 if (ret)
868 goto out0; 872 goto out0;
869 } 873 }
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index ca7265443c05..ab4695c1dd56 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -1041,61 +1041,60 @@ static int iwch_query_port(struct ib_device *ibdev,
1041 return 0; 1041 return 0;
1042} 1042}
1043 1043
1044static ssize_t show_rev(struct class_device *cdev, char *buf) 1044static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
1045 char *buf)
1045{ 1046{
1046 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1047 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1047 ibdev.class_dev); 1048 ibdev.dev);
1048 PDBG("%s class dev 0x%p\n", __func__, cdev); 1049 PDBG("%s dev 0x%p\n", __func__, dev);
1049 return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type); 1050 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
1050} 1051}
1051 1052
1052static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 1053static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf)
1053{ 1054{
1054 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1055 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1055 ibdev.class_dev); 1056 ibdev.dev);
1056 struct ethtool_drvinfo info; 1057 struct ethtool_drvinfo info;
1057 struct net_device *lldev = dev->rdev.t3cdev_p->lldev; 1058 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1058 1059
1059 PDBG("%s class dev 0x%p\n", __func__, cdev); 1060 PDBG("%s dev 0x%p\n", __func__, dev);
1060 rtnl_lock();
1061 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1061 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1062 rtnl_unlock();
1063 return sprintf(buf, "%s\n", info.fw_version); 1062 return sprintf(buf, "%s\n", info.fw_version);
1064} 1063}
1065 1064
1066static ssize_t show_hca(struct class_device *cdev, char *buf) 1065static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
1066 char *buf)
1067{ 1067{
1068 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1068 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1069 ibdev.class_dev); 1069 ibdev.dev);
1070 struct ethtool_drvinfo info; 1070 struct ethtool_drvinfo info;
1071 struct net_device *lldev = dev->rdev.t3cdev_p->lldev; 1071 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1072 1072
1073 PDBG("%s class dev 0x%p\n", __func__, cdev); 1073 PDBG("%s dev 0x%p\n", __func__, dev);
1074 rtnl_lock();
1075 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1074 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1076 rtnl_unlock();
1077 return sprintf(buf, "%s\n", info.driver); 1075 return sprintf(buf, "%s\n", info.driver);
1078} 1076}
1079 1077
1080static ssize_t show_board(struct class_device *cdev, char *buf) 1078static ssize_t show_board(struct device *dev, struct device_attribute *attr,
1079 char *buf)
1081{ 1080{
1082 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1081 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1083 ibdev.class_dev); 1082 ibdev.dev);
1084 PDBG("%s class dev 0x%p\n", __func__, dev); 1083 PDBG("%s dev 0x%p\n", __func__, dev);
1085 return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor, 1084 return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor,
1086 dev->rdev.rnic_info.pdev->device); 1085 iwch_dev->rdev.rnic_info.pdev->device);
1087} 1086}
1088 1087
1089static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1088static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
1090static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1089static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
1091static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1090static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
1092static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1091static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
1093 1092
1094static struct class_device_attribute *iwch_class_attributes[] = { 1093static struct device_attribute *iwch_class_attributes[] = {
1095 &class_device_attr_hw_rev, 1094 &dev_attr_hw_rev,
1096 &class_device_attr_fw_ver, 1095 &dev_attr_fw_ver,
1097 &class_device_attr_hca_type, 1096 &dev_attr_hca_type,
1098 &class_device_attr_board_id 1097 &dev_attr_board_id
1099}; 1098};
1100 1099
1101int iwch_register_device(struct iwch_dev *dev) 1100int iwch_register_device(struct iwch_dev *dev)
@@ -1189,8 +1188,8 @@ int iwch_register_device(struct iwch_dev *dev)
1189 goto bail1; 1188 goto bail1;
1190 1189
1191 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) { 1190 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) {
1192 ret = class_device_create_file(&dev->ibdev.class_dev, 1191 ret = device_create_file(&dev->ibdev.dev,
1193 iwch_class_attributes[i]); 1192 iwch_class_attributes[i]);
1194 if (ret) { 1193 if (ret) {
1195 goto bail2; 1194 goto bail2;
1196 } 1195 }
@@ -1208,8 +1207,8 @@ void iwch_unregister_device(struct iwch_dev *dev)
1208 1207
1209 PDBG("%s iwch_dev %p\n", __func__, dev); 1208 PDBG("%s iwch_dev %p\n", __func__, dev);
1210 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) 1209 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i)
1211 class_device_remove_file(&dev->ibdev.class_dev, 1210 device_remove_file(&dev->ibdev.dev,
1212 iwch_class_attributes[i]); 1211 iwch_class_attributes[i]);
1213 ib_unregister_device(&dev->ibdev); 1212 ib_unregister_device(&dev->ibdev);
1214 return; 1213 return;
1215} 1214}
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index 6d49d2f18a88..d4ce8b63e19e 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = {
79 79
80static atomic_t diagpkt_count = ATOMIC_INIT(0); 80static atomic_t diagpkt_count = ATOMIC_INIT(0);
81static struct cdev *diagpkt_cdev; 81static struct cdev *diagpkt_cdev;
82static struct class_device *diagpkt_class_dev; 82static struct device *diagpkt_dev;
83 83
84int ipath_diag_add(struct ipath_devdata *dd) 84int ipath_diag_add(struct ipath_devdata *dd)
85{ 85{
@@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
89 if (atomic_inc_return(&diagpkt_count) == 1) { 89 if (atomic_inc_return(&diagpkt_count) == 1) {
90 ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, 90 ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR,
91 "ipath_diagpkt", &diagpkt_file_ops, 91 "ipath_diagpkt", &diagpkt_file_ops,
92 &diagpkt_cdev, &diagpkt_class_dev); 92 &diagpkt_cdev, &diagpkt_dev);
93 93
94 if (ret) { 94 if (ret) {
95 ipath_dev_err(dd, "Couldn't create ipath_diagpkt " 95 ipath_dev_err(dd, "Couldn't create ipath_diagpkt "
@@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
102 102
103 ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, 103 ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name,
104 &diag_file_ops, &dd->diag_cdev, 104 &diag_file_ops, &dd->diag_cdev,
105 &dd->diag_class_dev); 105 &dd->diag_dev);
106 if (ret) 106 if (ret)
107 ipath_dev_err(dd, "Couldn't create %s device: %d", 107 ipath_dev_err(dd, "Couldn't create %s device: %d",
108 name, ret); 108 name, ret);
@@ -114,9 +114,9 @@ done:
114void ipath_diag_remove(struct ipath_devdata *dd) 114void ipath_diag_remove(struct ipath_devdata *dd)
115{ 115{
116 if (atomic_dec_and_test(&diagpkt_count)) 116 if (atomic_dec_and_test(&diagpkt_count))
117 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev); 117 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev);
118 118
119 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); 119 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev);
120} 120}
121 121
122/** 122/**
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 1e627aab18bf..8b1752202e78 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -2434,11 +2434,11 @@ static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov,
2434static struct class *ipath_class; 2434static struct class *ipath_class;
2435 2435
2436static int init_cdev(int minor, char *name, const struct file_operations *fops, 2436static int init_cdev(int minor, char *name, const struct file_operations *fops,
2437 struct cdev **cdevp, struct class_device **class_devp) 2437 struct cdev **cdevp, struct device **devp)
2438{ 2438{
2439 const dev_t dev = MKDEV(IPATH_MAJOR, minor); 2439 const dev_t dev = MKDEV(IPATH_MAJOR, minor);
2440 struct cdev *cdev = NULL; 2440 struct cdev *cdev = NULL;
2441 struct class_device *class_dev = NULL; 2441 struct device *device = NULL;
2442 int ret; 2442 int ret;
2443 2443
2444 cdev = cdev_alloc(); 2444 cdev = cdev_alloc();
@@ -2462,12 +2462,12 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
2462 goto err_cdev; 2462 goto err_cdev;
2463 } 2463 }
2464 2464
2465 class_dev = class_device_create(ipath_class, NULL, dev, NULL, name); 2465 device = device_create(ipath_class, NULL, dev, name);
2466 2466
2467 if (IS_ERR(class_dev)) { 2467 if (IS_ERR(device)) {
2468 ret = PTR_ERR(class_dev); 2468 ret = PTR_ERR(device);
2469 printk(KERN_ERR IPATH_DRV_NAME ": Could not create " 2469 printk(KERN_ERR IPATH_DRV_NAME ": Could not create "
2470 "class_dev for minor %d, %s (err %d)\n", 2470 "device for minor %d, %s (err %d)\n",
2471 minor, name, -ret); 2471 minor, name, -ret);
2472 goto err_cdev; 2472 goto err_cdev;
2473 } 2473 }
@@ -2481,29 +2481,29 @@ err_cdev:
2481done: 2481done:
2482 if (ret >= 0) { 2482 if (ret >= 0) {
2483 *cdevp = cdev; 2483 *cdevp = cdev;
2484 *class_devp = class_dev; 2484 *devp = device;
2485 } else { 2485 } else {
2486 *cdevp = NULL; 2486 *cdevp = NULL;
2487 *class_devp = NULL; 2487 *devp = NULL;
2488 } 2488 }
2489 2489
2490 return ret; 2490 return ret;
2491} 2491}
2492 2492
2493int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, 2493int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
2494 struct cdev **cdevp, struct class_device **class_devp) 2494 struct cdev **cdevp, struct device **devp)
2495{ 2495{
2496 return init_cdev(minor, name, fops, cdevp, class_devp); 2496 return init_cdev(minor, name, fops, cdevp, devp);
2497} 2497}
2498 2498
2499static void cleanup_cdev(struct cdev **cdevp, 2499static void cleanup_cdev(struct cdev **cdevp,
2500 struct class_device **class_devp) 2500 struct device **devp)
2501{ 2501{
2502 struct class_device *class_dev = *class_devp; 2502 struct device *dev = *devp;
2503 2503
2504 if (class_dev) { 2504 if (dev) {
2505 class_device_unregister(class_dev); 2505 device_unregister(dev);
2506 *class_devp = NULL; 2506 *devp = NULL;
2507 } 2507 }
2508 2508
2509 if (*cdevp) { 2509 if (*cdevp) {
@@ -2513,13 +2513,13 @@ static void cleanup_cdev(struct cdev **cdevp,
2513} 2513}
2514 2514
2515void ipath_cdev_cleanup(struct cdev **cdevp, 2515void ipath_cdev_cleanup(struct cdev **cdevp,
2516 struct class_device **class_devp) 2516 struct device **devp)
2517{ 2517{
2518 cleanup_cdev(cdevp, class_devp); 2518 cleanup_cdev(cdevp, devp);
2519} 2519}
2520 2520
2521static struct cdev *wildcard_cdev; 2521static struct cdev *wildcard_cdev;
2522static struct class_device *wildcard_class_dev; 2522static struct device *wildcard_dev;
2523 2523
2524static const dev_t dev = MKDEV(IPATH_MAJOR, 0); 2524static const dev_t dev = MKDEV(IPATH_MAJOR, 0);
2525 2525
@@ -2576,7 +2576,7 @@ int ipath_user_add(struct ipath_devdata *dd)
2576 goto bail; 2576 goto bail;
2577 } 2577 }
2578 ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, 2578 ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev,
2579 &wildcard_class_dev); 2579 &wildcard_dev);
2580 if (ret < 0) { 2580 if (ret < 0) {
2581 ipath_dev_err(dd, "Could not create wildcard " 2581 ipath_dev_err(dd, "Could not create wildcard "
2582 "minor: error %d\n", -ret); 2582 "minor: error %d\n", -ret);
@@ -2589,7 +2589,7 @@ int ipath_user_add(struct ipath_devdata *dd)
2589 snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); 2589 snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit);
2590 2590
2591 ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, 2591 ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops,
2592 &dd->user_cdev, &dd->user_class_dev); 2592 &dd->user_cdev, &dd->user_dev);
2593 if (ret < 0) 2593 if (ret < 0)
2594 ipath_dev_err(dd, "Could not create user minor %d, %s\n", 2594 ipath_dev_err(dd, "Could not create user minor %d, %s\n",
2595 dd->ipath_unit + 1, name); 2595 dd->ipath_unit + 1, name);
@@ -2604,13 +2604,13 @@ bail:
2604 2604
2605void ipath_user_remove(struct ipath_devdata *dd) 2605void ipath_user_remove(struct ipath_devdata *dd)
2606{ 2606{
2607 cleanup_cdev(&dd->user_cdev, &dd->user_class_dev); 2607 cleanup_cdev(&dd->user_cdev, &dd->user_dev);
2608 2608
2609 if (atomic_dec_return(&user_count) == 0) { 2609 if (atomic_dec_return(&user_count) == 0) {
2610 if (atomic_read(&user_setup) == 0) 2610 if (atomic_read(&user_setup) == 0)
2611 goto bail; 2611 goto bail;
2612 2612
2613 cleanup_cdev(&wildcard_cdev, &wildcard_class_dev); 2613 cleanup_cdev(&wildcard_cdev, &wildcard_dev);
2614 user_cleanup(); 2614 user_cleanup();
2615 2615
2616 atomic_set(&user_setup, 0); 2616 atomic_set(&user_setup, 0);
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 5863cbe99303..202337ae90dc 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -466,8 +466,8 @@ struct ipath_devdata {
466 struct pci_dev *pcidev; 466 struct pci_dev *pcidev;
467 struct cdev *user_cdev; 467 struct cdev *user_cdev;
468 struct cdev *diag_cdev; 468 struct cdev *diag_cdev;
469 struct class_device *user_class_dev; 469 struct device *user_dev;
470 struct class_device *diag_class_dev; 470 struct device *diag_dev;
471 /* timer used to prevent stats overflow, error throttling, etc. */ 471 /* timer used to prevent stats overflow, error throttling, etc. */
472 struct timer_list ipath_stats_timer; 472 struct timer_list ipath_stats_timer;
473 /* timer to verify interrupts work, and fallback if possible */ 473 /* timer to verify interrupts work, and fallback if possible */
@@ -854,9 +854,9 @@ void ipath_clear_freeze(struct ipath_devdata *);
854 854
855struct file_operations; 855struct file_operations;
856int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, 856int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
857 struct cdev **cdevp, struct class_device **class_devp); 857 struct cdev **cdevp, struct device **devp);
858void ipath_cdev_cleanup(struct cdev **cdevp, 858void ipath_cdev_cleanup(struct cdev **cdevp,
859 struct class_device **class_devp); 859 struct device **devp);
860 860
861int ipath_diag_add(struct ipath_devdata *); 861int ipath_diag_add(struct ipath_devdata *);
862void ipath_diag_remove(struct ipath_devdata *); 862void ipath_diag_remove(struct ipath_devdata *);
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 320a6d018de7..c38f9aa8be8d 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -2172,18 +2172,20 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev)
2172 ib_dealloc_device(ibdev); 2172 ib_dealloc_device(ibdev);
2173} 2173}
2174 2174
2175static ssize_t show_rev(struct class_device *cdev, char *buf) 2175static ssize_t show_rev(struct device *device, struct device_attribute *attr,
2176 char *buf)
2176{ 2177{
2177 struct ipath_ibdev *dev = 2178 struct ipath_ibdev *dev =
2178 container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2179 container_of(device, struct ipath_ibdev, ibdev.dev);
2179 2180
2180 return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); 2181 return sprintf(buf, "%x\n", dev->dd->ipath_pcirev);
2181} 2182}
2182 2183
2183static ssize_t show_hca(struct class_device *cdev, char *buf) 2184static ssize_t show_hca(struct device *device, struct device_attribute *attr,
2185 char *buf)
2184{ 2186{
2185 struct ipath_ibdev *dev = 2187 struct ipath_ibdev *dev =
2186 container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2188 container_of(device, struct ipath_ibdev, ibdev.dev);
2187 int ret; 2189 int ret;
2188 2190
2189 ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); 2191 ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128);
@@ -2196,10 +2198,11 @@ bail:
2196 return ret; 2198 return ret;
2197} 2199}
2198 2200
2199static ssize_t show_stats(struct class_device *cdev, char *buf) 2201static ssize_t show_stats(struct device *device, struct device_attribute *attr,
2202 char *buf)
2200{ 2203{
2201 struct ipath_ibdev *dev = 2204 struct ipath_ibdev *dev =
2202 container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2205 container_of(device, struct ipath_ibdev, ibdev.dev);
2203 int i; 2206 int i;
2204 int len; 2207 int len;
2205 2208
@@ -2237,16 +2240,16 @@ static ssize_t show_stats(struct class_device *cdev, char *buf)
2237 return len; 2240 return len;
2238} 2241}
2239 2242
2240static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2243static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
2241static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2244static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
2242static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); 2245static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL);
2243static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); 2246static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
2244 2247
2245static struct class_device_attribute *ipath_class_attributes[] = { 2248static struct device_attribute *ipath_class_attributes[] = {
2246 &class_device_attr_hw_rev, 2249 &dev_attr_hw_rev,
2247 &class_device_attr_hca_type, 2250 &dev_attr_hca_type,
2248 &class_device_attr_board_id, 2251 &dev_attr_board_id,
2249 &class_device_attr_stats 2252 &dev_attr_stats
2250}; 2253};
2251 2254
2252static int ipath_verbs_register_sysfs(struct ib_device *dev) 2255static int ipath_verbs_register_sysfs(struct ib_device *dev)
@@ -2255,8 +2258,8 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev)
2255 int ret; 2258 int ret;
2256 2259
2257 for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) 2260 for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i)
2258 if (class_device_create_file(&dev->class_dev, 2261 if (device_create_file(&dev->dev,
2259 ipath_class_attributes[i])) { 2262 ipath_class_attributes[i])) {
2260 ret = 1; 2263 ret = 1;
2261 goto bail; 2264 goto bail;
2262 } 2265 }
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 136c76c7b4e7..4d9b5ac42202 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -481,42 +481,51 @@ out:
481 return err; 481 return err;
482} 482}
483 483
484static ssize_t show_hca(struct class_device *cdev, char *buf) 484static ssize_t show_hca(struct device *device, struct device_attribute *attr,
485 char *buf)
485{ 486{
486 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 487 struct mlx4_ib_dev *dev =
488 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
487 return sprintf(buf, "MT%d\n", dev->dev->pdev->device); 489 return sprintf(buf, "MT%d\n", dev->dev->pdev->device);
488} 490}
489 491
490static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 492static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
493 char *buf)
491{ 494{
492 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 495 struct mlx4_ib_dev *dev =
496 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
493 return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32), 497 return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32),
494 (int) (dev->dev->caps.fw_ver >> 16) & 0xffff, 498 (int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
495 (int) dev->dev->caps.fw_ver & 0xffff); 499 (int) dev->dev->caps.fw_ver & 0xffff);
496} 500}
497 501
498static ssize_t show_rev(struct class_device *cdev, char *buf) 502static ssize_t show_rev(struct device *device, struct device_attribute *attr,
503 char *buf)
499{ 504{
500 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 505 struct mlx4_ib_dev *dev =
506 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
501 return sprintf(buf, "%x\n", dev->dev->rev_id); 507 return sprintf(buf, "%x\n", dev->dev->rev_id);
502} 508}
503 509
504static ssize_t show_board(struct class_device *cdev, char *buf) 510static ssize_t show_board(struct device *device, struct device_attribute *attr,
511 char *buf)
505{ 512{
506 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 513 struct mlx4_ib_dev *dev =
507 return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id); 514 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
515 return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN,
516 dev->dev->board_id);
508} 517}
509 518
510static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 519static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
511static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 520static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
512static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 521static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
513static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 522static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
514 523
515static struct class_device_attribute *mlx4_class_attributes[] = { 524static struct device_attribute *mlx4_class_attributes[] = {
516 &class_device_attr_hw_rev, 525 &dev_attr_hw_rev,
517 &class_device_attr_fw_ver, 526 &dev_attr_fw_ver,
518 &class_device_attr_hca_type, 527 &dev_attr_hca_type,
519 &class_device_attr_board_id 528 &dev_attr_board_id
520}; 529};
521 530
522static void *mlx4_ib_add(struct mlx4_dev *dev) 531static void *mlx4_ib_add(struct mlx4_dev *dev)
@@ -640,8 +649,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
640 goto err_reg; 649 goto err_reg;
641 650
642 for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) { 651 for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) {
643 if (class_device_create_file(&ibdev->ib_dev.class_dev, 652 if (device_create_file(&ibdev->ib_dev.dev,
644 mlx4_class_attributes[i])) 653 mlx4_class_attributes[i]))
645 goto err_reg; 654 goto err_reg;
646 } 655 }
647 656
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index 0e842e023400..7bc32f8e377e 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -46,8 +46,7 @@
46#include <linux/timer.h> 46#include <linux/timer.h>
47#include <linux/mutex.h> 47#include <linux/mutex.h>
48#include <linux/list.h> 48#include <linux/list.h>
49 49#include <linux/semaphore.h>
50#include <asm/semaphore.h>
51 50
52#include "mthca_provider.h" 51#include "mthca_provider.h"
53#include "mthca_doorbell.h" 52#include "mthca_doorbell.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 81b257e18bb6..696e1f302332 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -1170,23 +1170,29 @@ static int mthca_unmap_fmr(struct list_head *fmr_list)
1170 return 0; 1170 return 0;
1171} 1171}
1172 1172
1173static ssize_t show_rev(struct class_device *cdev, char *buf) 1173static ssize_t show_rev(struct device *device, struct device_attribute *attr,
1174 char *buf)
1174{ 1175{
1175 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1176 struct mthca_dev *dev =
1177 container_of(device, struct mthca_dev, ib_dev.dev);
1176 return sprintf(buf, "%x\n", dev->rev_id); 1178 return sprintf(buf, "%x\n", dev->rev_id);
1177} 1179}
1178 1180
1179static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 1181static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
1182 char *buf)
1180{ 1183{
1181 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1184 struct mthca_dev *dev =
1185 container_of(device, struct mthca_dev, ib_dev.dev);
1182 return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32), 1186 return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32),
1183 (int) (dev->fw_ver >> 16) & 0xffff, 1187 (int) (dev->fw_ver >> 16) & 0xffff,
1184 (int) dev->fw_ver & 0xffff); 1188 (int) dev->fw_ver & 0xffff);
1185} 1189}
1186 1190
1187static ssize_t show_hca(struct class_device *cdev, char *buf) 1191static ssize_t show_hca(struct device *device, struct device_attribute *attr,
1192 char *buf)
1188{ 1193{
1189 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1194 struct mthca_dev *dev =
1195 container_of(device, struct mthca_dev, ib_dev.dev);
1190 switch (dev->pdev->device) { 1196 switch (dev->pdev->device) {
1191 case PCI_DEVICE_ID_MELLANOX_TAVOR: 1197 case PCI_DEVICE_ID_MELLANOX_TAVOR:
1192 return sprintf(buf, "MT23108\n"); 1198 return sprintf(buf, "MT23108\n");
@@ -1202,22 +1208,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
1202 } 1208 }
1203} 1209}
1204 1210
1205static ssize_t show_board(struct class_device *cdev, char *buf) 1211static ssize_t show_board(struct device *device, struct device_attribute *attr,
1212 char *buf)
1206{ 1213{
1207 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1214 struct mthca_dev *dev =
1215 container_of(device, struct mthca_dev, ib_dev.dev);
1208 return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id); 1216 return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
1209} 1217}
1210 1218
1211static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1219static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
1212static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1220static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
1213static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1221static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
1214static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1222static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
1215 1223
1216static struct class_device_attribute *mthca_class_attributes[] = { 1224static struct device_attribute *mthca_dev_attributes[] = {
1217 &class_device_attr_hw_rev, 1225 &dev_attr_hw_rev,
1218 &class_device_attr_fw_ver, 1226 &dev_attr_fw_ver,
1219 &class_device_attr_hca_type, 1227 &dev_attr_hca_type,
1220 &class_device_attr_board_id 1228 &dev_attr_board_id
1221}; 1229};
1222 1230
1223static int mthca_init_node_data(struct mthca_dev *dev) 1231static int mthca_init_node_data(struct mthca_dev *dev)
@@ -1379,9 +1387,9 @@ int mthca_register_device(struct mthca_dev *dev)
1379 if (ret) 1387 if (ret)
1380 return ret; 1388 return ret;
1381 1389
1382 for (i = 0; i < ARRAY_SIZE(mthca_class_attributes); ++i) { 1390 for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) {
1383 ret = class_device_create_file(&dev->ib_dev.class_dev, 1391 ret = device_create_file(&dev->ib_dev.dev,
1384 mthca_class_attributes[i]); 1392 mthca_dev_attributes[i]);
1385 if (ret) { 1393 if (ret) {
1386 ib_unregister_device(&dev->ib_dev); 1394 ib_unregister_device(&dev->ib_dev);
1387 return ret; 1395 return ret;
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 1626124a156d..cdf2e9ad62f7 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -43,7 +43,6 @@
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/workqueue.h> 44#include <linux/workqueue.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <asm/semaphore.h>
47#include <linux/version.h> 46#include <linux/version.h>
48#include <asm/io.h> 47#include <asm/io.h>
49#include <linux/crc32c.h> 48#include <linux/crc32c.h>
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 7c27420c2240..f9a5d4390892 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -2800,10 +2800,11 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2800/** 2800/**
2801 * show_rev 2801 * show_rev
2802 */ 2802 */
2803static ssize_t show_rev(struct class_device *cdev, char *buf) 2803static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
2804 char *buf)
2804{ 2805{
2805 struct nes_ib_device *nesibdev = 2806 struct nes_ib_device *nesibdev =
2806 container_of(cdev, struct nes_ib_device, ibdev.class_dev); 2807 container_of(dev, struct nes_ib_device, ibdev.dev);
2807 struct nes_vnic *nesvnic = nesibdev->nesvnic; 2808 struct nes_vnic *nesvnic = nesibdev->nesvnic;
2808 2809
2809 nes_debug(NES_DBG_INIT, "\n"); 2810 nes_debug(NES_DBG_INIT, "\n");
@@ -2814,10 +2815,11 @@ static ssize_t show_rev(struct class_device *cdev, char *buf)
2814/** 2815/**
2815 * show_fw_ver 2816 * show_fw_ver
2816 */ 2817 */
2817static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 2818static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
2819 char *buf)
2818{ 2820{
2819 struct nes_ib_device *nesibdev = 2821 struct nes_ib_device *nesibdev =
2820 container_of(cdev, struct nes_ib_device, ibdev.class_dev); 2822 container_of(dev, struct nes_ib_device, ibdev.dev);
2821 struct nes_vnic *nesvnic = nesibdev->nesvnic; 2823 struct nes_vnic *nesvnic = nesibdev->nesvnic;
2822 2824
2823 nes_debug(NES_DBG_INIT, "\n"); 2825 nes_debug(NES_DBG_INIT, "\n");
@@ -2831,7 +2833,8 @@ static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
2831/** 2833/**
2832 * show_hca 2834 * show_hca
2833 */ 2835 */
2834static ssize_t show_hca(struct class_device *cdev, char *buf) 2836static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
2837 char *buf)
2835{ 2838{
2836 nes_debug(NES_DBG_INIT, "\n"); 2839 nes_debug(NES_DBG_INIT, "\n");
2837 return sprintf(buf, "NES020\n"); 2840 return sprintf(buf, "NES020\n");
@@ -2841,23 +2844,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
2841/** 2844/**
2842 * show_board 2845 * show_board
2843 */ 2846 */
2844static ssize_t show_board(struct class_device *cdev, char *buf) 2847static ssize_t show_board(struct device *dev, struct device_attribute *attr,
2848 char *buf)
2845{ 2849{
2846 nes_debug(NES_DBG_INIT, "\n"); 2850 nes_debug(NES_DBG_INIT, "\n");
2847 return sprintf(buf, "%.*s\n", 32, "NES020 Board ID"); 2851 return sprintf(buf, "%.*s\n", 32, "NES020 Board ID");
2848} 2852}
2849 2853
2850 2854
2851static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2855static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
2852static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 2856static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
2853static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2857static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
2854static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 2858static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
2855 2859
2856static struct class_device_attribute *nes_class_attributes[] = { 2860static struct device_attribute *nes_dev_attributes[] = {
2857 &class_device_attr_hw_rev, 2861 &dev_attr_hw_rev,
2858 &class_device_attr_fw_ver, 2862 &dev_attr_fw_ver,
2859 &class_device_attr_hca_type, 2863 &dev_attr_hca_type,
2860 &class_device_attr_board_id 2864 &dev_attr_board_id
2861}; 2865};
2862 2866
2863 2867
@@ -3782,7 +3786,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
3782 nesibdev->ibdev.phys_port_cnt = 1; 3786 nesibdev->ibdev.phys_port_cnt = 1;
3783 nesibdev->ibdev.num_comp_vectors = 1; 3787 nesibdev->ibdev.num_comp_vectors = 1;
3784 nesibdev->ibdev.dma_device = &nesdev->pcidev->dev; 3788 nesibdev->ibdev.dma_device = &nesdev->pcidev->dev;
3785 nesibdev->ibdev.class_dev.dev = &nesdev->pcidev->dev; 3789 nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev;
3786 nesibdev->ibdev.query_device = nes_query_device; 3790 nesibdev->ibdev.query_device = nes_query_device;
3787 nesibdev->ibdev.query_port = nes_query_port; 3791 nesibdev->ibdev.query_port = nes_query_port;
3788 nesibdev->ibdev.modify_port = nes_modify_port; 3792 nesibdev->ibdev.modify_port = nes_modify_port;
@@ -3877,13 +3881,13 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev)
3877 nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count; 3881 nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count;
3878 nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count; 3882 nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count;
3879 3883
3880 for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { 3884 for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
3881 ret = class_device_create_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); 3885 ret = device_create_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
3882 if (ret) { 3886 if (ret) {
3883 while (i > 0) { 3887 while (i > 0) {
3884 i--; 3888 i--;
3885 class_device_remove_file(&nesibdev->ibdev.class_dev, 3889 device_remove_file(&nesibdev->ibdev.dev,
3886 nes_class_attributes[i]); 3890 nes_dev_attributes[i]);
3887 } 3891 }
3888 ib_unregister_device(&nesibdev->ibdev); 3892 ib_unregister_device(&nesibdev->ibdev);
3889 return ret; 3893 return ret;
@@ -3904,8 +3908,8 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev)
3904 struct nes_vnic *nesvnic = nesibdev->nesvnic; 3908 struct nes_vnic *nesvnic = nesibdev->nesvnic;
3905 int i; 3909 int i;
3906 3910
3907 for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { 3911 for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
3908 class_device_remove_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); 3912 device_remove_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
3909 } 3913 }
3910 3914
3911 if (nesvnic->of_device_registered) { 3915 if (nesvnic->of_device_registered) {
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 125765aa9d59..435145709dd6 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -139,8 +139,9 @@ static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size,
139 if (!iu->buf) 139 if (!iu->buf)
140 goto out_free_iu; 140 goto out_free_iu;
141 141
142 iu->dma = ib_dma_map_single(host->dev->dev, iu->buf, size, direction); 142 iu->dma = ib_dma_map_single(host->srp_dev->dev, iu->buf, size,
143 if (ib_dma_mapping_error(host->dev->dev, iu->dma)) 143 direction);
144 if (ib_dma_mapping_error(host->srp_dev->dev, iu->dma))
144 goto out_free_buf; 145 goto out_free_buf;
145 146
146 iu->size = size; 147 iu->size = size;
@@ -161,7 +162,8 @@ static void srp_free_iu(struct srp_host *host, struct srp_iu *iu)
161 if (!iu) 162 if (!iu)
162 return; 163 return;
163 164
164 ib_dma_unmap_single(host->dev->dev, iu->dma, iu->size, iu->direction); 165 ib_dma_unmap_single(host->srp_dev->dev, iu->dma, iu->size,
166 iu->direction);
165 kfree(iu->buf); 167 kfree(iu->buf);
166 kfree(iu); 168 kfree(iu);
167} 169}
@@ -181,7 +183,7 @@ static int srp_init_qp(struct srp_target_port *target,
181 if (!attr) 183 if (!attr)
182 return -ENOMEM; 184 return -ENOMEM;
183 185
184 ret = ib_find_cached_pkey(target->srp_host->dev->dev, 186 ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev,
185 target->srp_host->port, 187 target->srp_host->port,
186 be16_to_cpu(target->path.pkey), 188 be16_to_cpu(target->path.pkey),
187 &attr->pkey_index); 189 &attr->pkey_index);
@@ -208,7 +210,7 @@ static int srp_new_cm_id(struct srp_target_port *target)
208{ 210{
209 struct ib_cm_id *new_cm_id; 211 struct ib_cm_id *new_cm_id;
210 212
211 new_cm_id = ib_create_cm_id(target->srp_host->dev->dev, 213 new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev,
212 srp_cm_handler, target); 214 srp_cm_handler, target);
213 if (IS_ERR(new_cm_id)) 215 if (IS_ERR(new_cm_id))
214 return PTR_ERR(new_cm_id); 216 return PTR_ERR(new_cm_id);
@@ -229,8 +231,8 @@ static int srp_create_target_ib(struct srp_target_port *target)
229 if (!init_attr) 231 if (!init_attr)
230 return -ENOMEM; 232 return -ENOMEM;
231 233
232 target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion, 234 target->cq = ib_create_cq(target->srp_host->srp_dev->dev,
233 NULL, target, SRP_CQ_SIZE, 0); 235 srp_completion, NULL, target, SRP_CQ_SIZE, 0);
234 if (IS_ERR(target->cq)) { 236 if (IS_ERR(target->cq)) {
235 ret = PTR_ERR(target->cq); 237 ret = PTR_ERR(target->cq);
236 goto out; 238 goto out;
@@ -248,7 +250,7 @@ static int srp_create_target_ib(struct srp_target_port *target)
248 init_attr->send_cq = target->cq; 250 init_attr->send_cq = target->cq;
249 init_attr->recv_cq = target->cq; 251 init_attr->recv_cq = target->cq;
250 252
251 target->qp = ib_create_qp(target->srp_host->dev->pd, init_attr); 253 target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr);
252 if (IS_ERR(target->qp)) { 254 if (IS_ERR(target->qp)) {
253 ret = PTR_ERR(target->qp); 255 ret = PTR_ERR(target->qp);
254 ib_destroy_cq(target->cq); 256 ib_destroy_cq(target->cq);
@@ -302,7 +304,7 @@ static int srp_lookup_path(struct srp_target_port *target)
302 init_completion(&target->done); 304 init_completion(&target->done);
303 305
304 target->path_query_id = ib_sa_path_rec_get(&srp_sa_client, 306 target->path_query_id = ib_sa_path_rec_get(&srp_sa_client,
305 target->srp_host->dev->dev, 307 target->srp_host->srp_dev->dev,
306 target->srp_host->port, 308 target->srp_host->port,
307 &target->path, 309 &target->path,
308 IB_SA_PATH_REC_SERVICE_ID | 310 IB_SA_PATH_REC_SERVICE_ID |
@@ -403,7 +405,7 @@ static int srp_send_req(struct srp_target_port *target)
403 (unsigned long long) be64_to_cpu(target->ioc_guid)); 405 (unsigned long long) be64_to_cpu(target->ioc_guid));
404 memset(req->priv.initiator_port_id, 0, 8); 406 memset(req->priv.initiator_port_id, 0, 8);
405 memcpy(req->priv.initiator_port_id + 8, 407 memcpy(req->priv.initiator_port_id + 8,
406 &target->srp_host->dev->dev->node_guid, 8); 408 &target->srp_host->srp_dev->dev->node_guid, 8);
407 } 409 }
408 410
409 status = ib_send_cm_req(target->cm_id, &req->param); 411 status = ib_send_cm_req(target->cm_id, &req->param);
@@ -520,7 +522,7 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
520 req->fmr = NULL; 522 req->fmr = NULL;
521 } 523 }
522 524
523 ib_dma_unmap_sg(target->srp_host->dev->dev, scsi_sglist(scmnd), 525 ib_dma_unmap_sg(target->srp_host->srp_dev->dev, scsi_sglist(scmnd),
524 scsi_sg_count(scmnd), scmnd->sc_data_direction); 526 scsi_sg_count(scmnd), scmnd->sc_data_direction);
525} 527}
526 528
@@ -628,7 +630,7 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
628 int page_cnt; 630 int page_cnt;
629 int i, j; 631 int i, j;
630 int ret; 632 int ret;
631 struct srp_device *dev = target->srp_host->dev; 633 struct srp_device *dev = target->srp_host->srp_dev;
632 struct ib_device *ibdev = dev->dev; 634 struct ib_device *ibdev = dev->dev;
633 struct scatterlist *sg; 635 struct scatterlist *sg;
634 636
@@ -723,7 +725,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
723 nents = scsi_sg_count(scmnd); 725 nents = scsi_sg_count(scmnd);
724 scat = scsi_sglist(scmnd); 726 scat = scsi_sglist(scmnd);
725 727
726 dev = target->srp_host->dev; 728 dev = target->srp_host->srp_dev;
727 ibdev = dev->dev; 729 ibdev = dev->dev;
728 730
729 count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction); 731 count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction);
@@ -779,7 +781,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
779 buf->table_desc.va = 781 buf->table_desc.va =
780 cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf); 782 cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf);
781 buf->table_desc.key = 783 buf->table_desc.key =
782 cpu_to_be32(target->srp_host->dev->mr->rkey); 784 cpu_to_be32(target->srp_host->srp_dev->mr->rkey);
783 buf->table_desc.len = 785 buf->table_desc.len =
784 cpu_to_be32(count * sizeof (struct srp_direct_buf)); 786 cpu_to_be32(count * sizeof (struct srp_direct_buf));
785 787
@@ -855,7 +857,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
855 857
856 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; 858 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV];
857 859
858 dev = target->srp_host->dev->dev; 860 dev = target->srp_host->srp_dev->dev;
859 ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len, 861 ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len,
860 DMA_FROM_DEVICE); 862 DMA_FROM_DEVICE);
861 863
@@ -937,7 +939,7 @@ static int __srp_post_recv(struct srp_target_port *target)
937 939
938 list.addr = iu->dma; 940 list.addr = iu->dma;
939 list.length = iu->size; 941 list.length = iu->size;
940 list.lkey = target->srp_host->dev->mr->lkey; 942 list.lkey = target->srp_host->srp_dev->mr->lkey;
941 943
942 wr.next = NULL; 944 wr.next = NULL;
943 wr.sg_list = &list; 945 wr.sg_list = &list;
@@ -996,7 +998,7 @@ static int __srp_post_send(struct srp_target_port *target,
996 998
997 list.addr = iu->dma; 999 list.addr = iu->dma;
998 list.length = len; 1000 list.length = len;
999 list.lkey = target->srp_host->dev->mr->lkey; 1001 list.lkey = target->srp_host->srp_dev->mr->lkey;
1000 1002
1001 wr.next = NULL; 1003 wr.next = NULL;
1002 wr.wr_id = target->tx_head & SRP_SQ_SIZE; 1004 wr.wr_id = target->tx_head & SRP_SQ_SIZE;
@@ -1039,7 +1041,7 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
1039 if (!iu) 1041 if (!iu)
1040 goto err; 1042 goto err;
1041 1043
1042 dev = target->srp_host->dev->dev; 1044 dev = target->srp_host->srp_dev->dev;
1043 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, 1045 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len,
1044 DMA_TO_DEVICE); 1046 DMA_TO_DEVICE);
1045 1047
@@ -1456,9 +1458,10 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
1456 return ret; 1458 return ret;
1457} 1459}
1458 1460
1459static ssize_t show_id_ext(struct class_device *cdev, char *buf) 1461static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr,
1462 char *buf)
1460{ 1463{
1461 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1464 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1462 1465
1463 if (target->state == SRP_TARGET_DEAD || 1466 if (target->state == SRP_TARGET_DEAD ||
1464 target->state == SRP_TARGET_REMOVED) 1467 target->state == SRP_TARGET_REMOVED)
@@ -1468,9 +1471,10 @@ static ssize_t show_id_ext(struct class_device *cdev, char *buf)
1468 (unsigned long long) be64_to_cpu(target->id_ext)); 1471 (unsigned long long) be64_to_cpu(target->id_ext));
1469} 1472}
1470 1473
1471static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) 1474static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr,
1475 char *buf)
1472{ 1476{
1473 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1477 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1474 1478
1475 if (target->state == SRP_TARGET_DEAD || 1479 if (target->state == SRP_TARGET_DEAD ||
1476 target->state == SRP_TARGET_REMOVED) 1480 target->state == SRP_TARGET_REMOVED)
@@ -1480,9 +1484,10 @@ static ssize_t show_ioc_guid(struct class_device *cdev, char *buf)
1480 (unsigned long long) be64_to_cpu(target->ioc_guid)); 1484 (unsigned long long) be64_to_cpu(target->ioc_guid));
1481} 1485}
1482 1486
1483static ssize_t show_service_id(struct class_device *cdev, char *buf) 1487static ssize_t show_service_id(struct device *dev,
1488 struct device_attribute *attr, char *buf)
1484{ 1489{
1485 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1490 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1486 1491
1487 if (target->state == SRP_TARGET_DEAD || 1492 if (target->state == SRP_TARGET_DEAD ||
1488 target->state == SRP_TARGET_REMOVED) 1493 target->state == SRP_TARGET_REMOVED)
@@ -1492,9 +1497,10 @@ static ssize_t show_service_id(struct class_device *cdev, char *buf)
1492 (unsigned long long) be64_to_cpu(target->service_id)); 1497 (unsigned long long) be64_to_cpu(target->service_id));
1493} 1498}
1494 1499
1495static ssize_t show_pkey(struct class_device *cdev, char *buf) 1500static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
1501 char *buf)
1496{ 1502{
1497 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1503 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1498 1504
1499 if (target->state == SRP_TARGET_DEAD || 1505 if (target->state == SRP_TARGET_DEAD ||
1500 target->state == SRP_TARGET_REMOVED) 1506 target->state == SRP_TARGET_REMOVED)
@@ -1503,9 +1509,10 @@ static ssize_t show_pkey(struct class_device *cdev, char *buf)
1503 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); 1509 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
1504} 1510}
1505 1511
1506static ssize_t show_dgid(struct class_device *cdev, char *buf) 1512static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
1513 char *buf)
1507{ 1514{
1508 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1515 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1509 1516
1510 if (target->state == SRP_TARGET_DEAD || 1517 if (target->state == SRP_TARGET_DEAD ||
1511 target->state == SRP_TARGET_REMOVED) 1518 target->state == SRP_TARGET_REMOVED)
@@ -1522,9 +1529,10 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf)
1522 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); 1529 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
1523} 1530}
1524 1531
1525static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) 1532static ssize_t show_orig_dgid(struct device *dev,
1533 struct device_attribute *attr, char *buf)
1526{ 1534{
1527 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1535 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1528 1536
1529 if (target->state == SRP_TARGET_DEAD || 1537 if (target->state == SRP_TARGET_DEAD ||
1530 target->state == SRP_TARGET_REMOVED) 1538 target->state == SRP_TARGET_REMOVED)
@@ -1541,9 +1549,10 @@ static ssize_t show_orig_dgid(struct class_device *cdev, char *buf)
1541 be16_to_cpu(target->orig_dgid[7])); 1549 be16_to_cpu(target->orig_dgid[7]));
1542} 1550}
1543 1551
1544static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) 1552static ssize_t show_zero_req_lim(struct device *dev,
1553 struct device_attribute *attr, char *buf)
1545{ 1554{
1546 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1555 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1547 1556
1548 if (target->state == SRP_TARGET_DEAD || 1557 if (target->state == SRP_TARGET_DEAD ||
1549 target->state == SRP_TARGET_REMOVED) 1558 target->state == SRP_TARGET_REMOVED)
@@ -1552,40 +1561,42 @@ static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf)
1552 return sprintf(buf, "%d\n", target->zero_req_lim); 1561 return sprintf(buf, "%d\n", target->zero_req_lim);
1553} 1562}
1554 1563
1555static ssize_t show_local_ib_port(struct class_device *cdev, char *buf) 1564static ssize_t show_local_ib_port(struct device *dev,
1565 struct device_attribute *attr, char *buf)
1556{ 1566{
1557 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1567 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1558 1568
1559 return sprintf(buf, "%d\n", target->srp_host->port); 1569 return sprintf(buf, "%d\n", target->srp_host->port);
1560} 1570}
1561 1571
1562static ssize_t show_local_ib_device(struct class_device *cdev, char *buf) 1572static ssize_t show_local_ib_device(struct device *dev,
1573 struct device_attribute *attr, char *buf)
1563{ 1574{
1564 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1575 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1565 1576
1566 return sprintf(buf, "%s\n", target->srp_host->dev->dev->name); 1577 return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name);
1567} 1578}
1568 1579
1569static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); 1580static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
1570static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); 1581static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
1571static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); 1582static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
1572static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); 1583static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
1573static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); 1584static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
1574static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); 1585static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL);
1575static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); 1586static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
1576static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); 1587static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL);
1577static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); 1588static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL);
1578 1589
1579static struct class_device_attribute *srp_host_attrs[] = { 1590static struct device_attribute *srp_host_attrs[] = {
1580 &class_device_attr_id_ext, 1591 &dev_attr_id_ext,
1581 &class_device_attr_ioc_guid, 1592 &dev_attr_ioc_guid,
1582 &class_device_attr_service_id, 1593 &dev_attr_service_id,
1583 &class_device_attr_pkey, 1594 &dev_attr_pkey,
1584 &class_device_attr_dgid, 1595 &dev_attr_dgid,
1585 &class_device_attr_orig_dgid, 1596 &dev_attr_orig_dgid,
1586 &class_device_attr_zero_req_lim, 1597 &dev_attr_zero_req_lim,
1587 &class_device_attr_local_ib_port, 1598 &dev_attr_local_ib_port,
1588 &class_device_attr_local_ib_device, 1599 &dev_attr_local_ib_device,
1589 NULL 1600 NULL
1590}; 1601};
1591 1602
@@ -1613,7 +1624,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1613 sprintf(target->target_name, "SRP.T10:%016llX", 1624 sprintf(target->target_name, "SRP.T10:%016llX",
1614 (unsigned long long) be64_to_cpu(target->id_ext)); 1625 (unsigned long long) be64_to_cpu(target->id_ext));
1615 1626
1616 if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) 1627 if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device))
1617 return -ENODEV; 1628 return -ENODEV;
1618 1629
1619 memcpy(ids.port_id, &target->id_ext, 8); 1630 memcpy(ids.port_id, &target->id_ext, 8);
@@ -1637,17 +1648,17 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1637 return 0; 1648 return 0;
1638} 1649}
1639 1650
1640static void srp_release_class_dev(struct class_device *class_dev) 1651static void srp_release_dev(struct device *dev)
1641{ 1652{
1642 struct srp_host *host = 1653 struct srp_host *host =
1643 container_of(class_dev, struct srp_host, class_dev); 1654 container_of(dev, struct srp_host, dev);
1644 1655
1645 complete(&host->released); 1656 complete(&host->released);
1646} 1657}
1647 1658
1648static struct class srp_class = { 1659static struct class srp_class = {
1649 .name = "infiniband_srp", 1660 .name = "infiniband_srp",
1650 .release = srp_release_class_dev 1661 .dev_release = srp_release_dev
1651}; 1662};
1652 1663
1653/* 1664/*
@@ -1835,11 +1846,12 @@ out:
1835 return ret; 1846 return ret;
1836} 1847}
1837 1848
1838static ssize_t srp_create_target(struct class_device *class_dev, 1849static ssize_t srp_create_target(struct device *dev,
1850 struct device_attribute *attr,
1839 const char *buf, size_t count) 1851 const char *buf, size_t count)
1840{ 1852{
1841 struct srp_host *host = 1853 struct srp_host *host =
1842 container_of(class_dev, struct srp_host, class_dev); 1854 container_of(dev, struct srp_host, dev);
1843 struct Scsi_Host *target_host; 1855 struct Scsi_Host *target_host;
1844 struct srp_target_port *target; 1856 struct srp_target_port *target;
1845 int ret; 1857 int ret;
@@ -1871,7 +1883,8 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1871 if (ret) 1883 if (ret)
1872 goto err; 1884 goto err;
1873 1885
1874 ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid); 1886 ib_get_cached_gid(host->srp_dev->dev, host->port, 0,
1887 &target->path.sgid);
1875 1888
1876 shost_printk(KERN_DEBUG, target->scsi_host, PFX 1889 shost_printk(KERN_DEBUG, target->scsi_host, PFX
1877 "new target: id_ext %016llx ioc_guid %016llx pkey %04x " 1890 "new target: id_ext %016llx ioc_guid %016llx pkey %04x "
@@ -1926,27 +1939,27 @@ err:
1926 return ret; 1939 return ret;
1927} 1940}
1928 1941
1929static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); 1942static DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target);
1930 1943
1931static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 1944static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
1945 char *buf)
1932{ 1946{
1933 struct srp_host *host = 1947 struct srp_host *host = container_of(dev, struct srp_host, dev);
1934 container_of(class_dev, struct srp_host, class_dev);
1935 1948
1936 return sprintf(buf, "%s\n", host->dev->dev->name); 1949 return sprintf(buf, "%s\n", host->srp_dev->dev->name);
1937} 1950}
1938 1951
1939static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1952static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
1940 1953
1941static ssize_t show_port(struct class_device *class_dev, char *buf) 1954static ssize_t show_port(struct device *dev, struct device_attribute *attr,
1955 char *buf)
1942{ 1956{
1943 struct srp_host *host = 1957 struct srp_host *host = container_of(dev, struct srp_host, dev);
1944 container_of(class_dev, struct srp_host, class_dev);
1945 1958
1946 return sprintf(buf, "%d\n", host->port); 1959 return sprintf(buf, "%d\n", host->port);
1947} 1960}
1948 1961
1949static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 1962static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
1950 1963
1951static struct srp_host *srp_add_port(struct srp_device *device, u8 port) 1964static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
1952{ 1965{
@@ -1959,27 +1972,27 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
1959 INIT_LIST_HEAD(&host->target_list); 1972 INIT_LIST_HEAD(&host->target_list);
1960 spin_lock_init(&host->target_lock); 1973 spin_lock_init(&host->target_lock);
1961 init_completion(&host->released); 1974 init_completion(&host->released);
1962 host->dev = device; 1975 host->srp_dev = device;
1963 host->port = port; 1976 host->port = port;
1964 1977
1965 host->class_dev.class = &srp_class; 1978 host->dev.class = &srp_class;
1966 host->class_dev.dev = device->dev->dma_device; 1979 host->dev.parent = device->dev->dma_device;
1967 snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d", 1980 snprintf(host->dev.bus_id, BUS_ID_SIZE, "srp-%s-%d",
1968 device->dev->name, port); 1981 device->dev->name, port);
1969 1982
1970 if (class_device_register(&host->class_dev)) 1983 if (device_register(&host->dev))
1971 goto free_host; 1984 goto free_host;
1972 if (class_device_create_file(&host->class_dev, &class_device_attr_add_target)) 1985 if (device_create_file(&host->dev, &dev_attr_add_target))
1973 goto err_class; 1986 goto err_class;
1974 if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev)) 1987 if (device_create_file(&host->dev, &dev_attr_ibdev))
1975 goto err_class; 1988 goto err_class;
1976 if (class_device_create_file(&host->class_dev, &class_device_attr_port)) 1989 if (device_create_file(&host->dev, &dev_attr_port))
1977 goto err_class; 1990 goto err_class;
1978 1991
1979 return host; 1992 return host;
1980 1993
1981err_class: 1994err_class:
1982 class_device_unregister(&host->class_dev); 1995 device_unregister(&host->dev);
1983 1996
1984free_host: 1997free_host:
1985 kfree(host); 1998 kfree(host);
@@ -2084,7 +2097,7 @@ static void srp_remove_one(struct ib_device *device)
2084 srp_dev = ib_get_client_data(device, &srp_client); 2097 srp_dev = ib_get_client_data(device, &srp_client);
2085 2098
2086 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { 2099 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) {
2087 class_device_unregister(&host->class_dev); 2100 device_unregister(&host->dev);
2088 /* 2101 /*
2089 * Wait for the sysfs entry to go away, so that no new 2102 * Wait for the sysfs entry to go away, so that no new
2090 * target ports can be created. 2103 * target ports can be created.
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index cb6eb816024a..63d2ae724061 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -97,9 +97,9 @@ struct srp_device {
97}; 97};
98 98
99struct srp_host { 99struct srp_host {
100 struct srp_device *dev; 100 struct srp_device *srp_dev;
101 u8 port; 101 u8 port;
102 struct class_device class_dev; 102 struct device dev;
103 struct list_head target_list; 103 struct list_head target_list;
104 spinlock_t target_lock; 104 spinlock_t target_lock;
105 struct completion released; 105 struct completion released;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 8ea709be3306..efd70a974591 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -314,4 +314,13 @@ config KEYBOARD_BFIN
314 To compile this driver as a module, choose M here: the 314 To compile this driver as a module, choose M here: the
315 module will be called bf54x-keys. 315 module will be called bf54x-keys.
316 316
317config KEYBOARD_SH_KEYSC
318 tristate "SuperH KEYSC keypad support"
319 depends on SUPERH
320 help
321 Say Y here if you want to use a keypad attached to the KEYSC block
322 on SuperH processors such as sh7722 and sh7343.
323
324 To compile this driver as a module, choose M here: the
325 module will be called sh_keysc.
317endif 326endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index e741f4031012..0edc8f285d1c 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -26,3 +26,4 @@ obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
26obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o 26obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
27obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o 27obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o
28obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o 28obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
29obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index 790fed368aae..5d6cc7f1dc94 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -23,6 +23,7 @@
23#include <asm/arch/corgi.h> 23#include <asm/arch/corgi.h>
24#include <asm/arch/hardware.h> 24#include <asm/arch/hardware.h>
25#include <asm/arch/pxa-regs.h> 25#include <asm/arch/pxa-regs.h>
26#include <asm/arch/pxa2xx-gpio.h>
26#include <asm/hardware/scoop.h> 27#include <asm/hardware/scoop.h>
27 28
28#define KB_ROWS 8 29#define KB_ROWS 8
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
new file mode 100644
index 000000000000..8486abc457ed
--- /dev/null
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -0,0 +1,280 @@
1/*
2 * SuperH KEYSC Keypad Driver
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
6 * Based on gpio_keys.c, Copyright 2005 Phil Blundell
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/interrupt.h>
17#include <linux/irq.h>
18#include <linux/delay.h>
19#include <linux/platform_device.h>
20#include <linux/input.h>
21#include <linux/io.h>
22#include <asm/sh_keysc.h>
23
24#define KYCR1_OFFS 0x00
25#define KYCR2_OFFS 0x04
26#define KYINDR_OFFS 0x08
27#define KYOUTDR_OFFS 0x0c
28
29#define KYCR2_IRQ_LEVEL 0x10
30#define KYCR2_IRQ_DISABLED 0x00
31
32static const struct {
33 unsigned char kymd, keyout, keyin;
34} sh_keysc_mode[] = {
35 [SH_KEYSC_MODE_1] = { 0, 6, 5 },
36 [SH_KEYSC_MODE_2] = { 1, 5, 6 },
37 [SH_KEYSC_MODE_3] = { 2, 4, 7 },
38};
39
40struct sh_keysc_priv {
41 void __iomem *iomem_base;
42 unsigned long last_keys;
43 struct input_dev *input;
44 struct sh_keysc_info pdata;
45};
46
47static irqreturn_t sh_keysc_isr(int irq, void *dev_id)
48{
49 struct platform_device *pdev = dev_id;
50 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
51 struct sh_keysc_info *pdata = &priv->pdata;
52 unsigned long keys, keys1, keys0, mask;
53 unsigned char keyin_set, tmp;
54 int i, k;
55
56 dev_dbg(&pdev->dev, "isr!\n");
57
58 keys1 = ~0;
59 keys0 = 0;
60
61 do {
62 keys = 0;
63 keyin_set = 0;
64
65 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS);
66
67 for (i = 0; i < sh_keysc_mode[pdata->mode].keyout; i++) {
68 iowrite16(0xfff ^ (3 << (i * 2)),
69 priv->iomem_base + KYOUTDR_OFFS);
70 udelay(pdata->delay);
71 tmp = ioread16(priv->iomem_base + KYINDR_OFFS);
72 keys |= tmp << (sh_keysc_mode[pdata->mode].keyin * i);
73 tmp ^= (1 << sh_keysc_mode[pdata->mode].keyin) - 1;
74 keyin_set |= tmp;
75 }
76
77 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS);
78 iowrite16(KYCR2_IRQ_LEVEL | (keyin_set << 8),
79 priv->iomem_base + KYCR2_OFFS);
80
81 keys ^= ~0;
82 keys &= (1 << (sh_keysc_mode[pdata->mode].keyin *
83 sh_keysc_mode[pdata->mode].keyout)) - 1;
84 keys1 &= keys;
85 keys0 |= keys;
86
87 dev_dbg(&pdev->dev, "keys 0x%08lx\n", keys);
88
89 } while (ioread16(priv->iomem_base + KYCR2_OFFS) & 0x01);
90
91 dev_dbg(&pdev->dev, "last_keys 0x%08lx keys0 0x%08lx keys1 0x%08lx\n",
92 priv->last_keys, keys0, keys1);
93
94 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) {
95 k = pdata->keycodes[i];
96 if (!k)
97 continue;
98
99 mask = 1 << i;
100
101 if (!((priv->last_keys ^ keys0) & mask))
102 continue;
103
104 if ((keys1 | keys0) & mask) {
105 input_event(priv->input, EV_KEY, k, 1);
106 priv->last_keys |= mask;
107 }
108
109 if (!(keys1 & mask)) {
110 input_event(priv->input, EV_KEY, k, 0);
111 priv->last_keys &= ~mask;
112 }
113
114 }
115 input_sync(priv->input);
116
117 return IRQ_HANDLED;
118}
119
120#define res_size(res) ((res)->end - (res)->start + 1)
121
122static int __devinit sh_keysc_probe(struct platform_device *pdev)
123{
124 struct sh_keysc_priv *priv;
125 struct sh_keysc_info *pdata;
126 struct resource *res;
127 struct input_dev *input;
128 int i, k;
129 int irq, error;
130
131 if (!pdev->dev.platform_data) {
132 dev_err(&pdev->dev, "no platform data defined\n");
133 error = -EINVAL;
134 goto err0;
135 }
136
137 error = -ENXIO;
138 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
139 if (res == NULL) {
140 dev_err(&pdev->dev, "failed to get I/O memory\n");
141 goto err0;
142 }
143
144 irq = platform_get_irq(pdev, 0);
145 if (irq < 0) {
146 dev_err(&pdev->dev, "failed to get irq\n");
147 goto err0;
148 }
149
150 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
151 if (priv == NULL) {
152 dev_err(&pdev->dev, "failed to allocate driver data\n");
153 error = -ENOMEM;
154 goto err0;
155 }
156
157 platform_set_drvdata(pdev, priv);
158 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata));
159 pdata = &priv->pdata;
160
161 res = request_mem_region(res->start, res_size(res), pdev->name);
162 if (res == NULL) {
163 dev_err(&pdev->dev, "failed to request I/O memory\n");
164 error = -EBUSY;
165 goto err1;
166 }
167
168 priv->iomem_base = ioremap_nocache(res->start, res_size(res));
169 if (priv->iomem_base == NULL) {
170 dev_err(&pdev->dev, "failed to remap I/O memory\n");
171 error = -ENXIO;
172 goto err2;
173 }
174
175 priv->input = input_allocate_device();
176 if (!priv->input) {
177 dev_err(&pdev->dev, "failed to allocate input device\n");
178 error = -ENOMEM;
179 goto err3;
180 }
181
182 input = priv->input;
183 input->evbit[0] = BIT_MASK(EV_KEY);
184
185 input->name = pdev->name;
186 input->phys = "sh-keysc-keys/input0";
187 input->dev.parent = &pdev->dev;
188
189 input->id.bustype = BUS_HOST;
190 input->id.vendor = 0x0001;
191 input->id.product = 0x0001;
192 input->id.version = 0x0100;
193
194 error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev);
195 if (error) {
196 dev_err(&pdev->dev, "failed to request IRQ\n");
197 goto err4;
198 }
199
200 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) {
201 k = pdata->keycodes[i];
202 if (k)
203 input_set_capability(input, EV_KEY, k);
204 }
205
206 error = input_register_device(input);
207 if (error) {
208 dev_err(&pdev->dev, "failed to register input device\n");
209 goto err5;
210 }
211
212 iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) |
213 pdata->scan_timing, priv->iomem_base + KYCR1_OFFS);
214 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS);
215 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS);
216 return 0;
217 err5:
218 free_irq(irq, pdev);
219 err4:
220 input_free_device(input);
221 err3:
222 iounmap(priv->iomem_base);
223 err2:
224 release_mem_region(res->start, res_size(res));
225 err1:
226 platform_set_drvdata(pdev, NULL);
227 kfree(priv);
228 err0:
229 return error;
230}
231
232static int __devexit sh_keysc_remove(struct platform_device *pdev)
233{
234 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
235 struct resource *res;
236
237 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS);
238
239 input_unregister_device(priv->input);
240 free_irq(platform_get_irq(pdev, 0), pdev);
241 iounmap(priv->iomem_base);
242
243 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
244 release_mem_region(res->start, res_size(res));
245
246 platform_set_drvdata(pdev, NULL);
247 kfree(priv);
248 return 0;
249}
250
251
252#define sh_keysc_suspend NULL
253#define sh_keysc_resume NULL
254
255struct platform_driver sh_keysc_device_driver = {
256 .probe = sh_keysc_probe,
257 .remove = __devexit_p(sh_keysc_remove),
258 .suspend = sh_keysc_suspend,
259 .resume = sh_keysc_resume,
260 .driver = {
261 .name = "sh_keysc",
262 }
263};
264
265static int __init sh_keysc_init(void)
266{
267 return platform_driver_register(&sh_keysc_device_driver);
268}
269
270static void __exit sh_keysc_exit(void)
271{
272 platform_driver_unregister(&sh_keysc_device_driver);
273}
274
275module_init(sh_keysc_init);
276module_exit(sh_keysc_exit);
277
278MODULE_AUTHOR("Magnus Damm");
279MODULE_DESCRIPTION("SuperH KEYSC Keypad Driver");
280MODULE_LICENSE("GPL");
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 1d59a2dc3c17..0be74bfc58fe 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -23,6 +23,7 @@
23#include <asm/arch/spitz.h> 23#include <asm/arch/spitz.h>
24#include <asm/arch/hardware.h> 24#include <asm/arch/hardware.h>
25#include <asm/arch/pxa-regs.h> 25#include <asm/arch/pxa-regs.h>
26#include <asm/arch/pxa2xx-gpio.h>
26 27
27#define KB_ROWS 7 28#define KB_ROWS 7
28#define KB_COLS 11 29#define KB_COLS 11
diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c
index c45ea74d53e4..f1fd3b638a37 100644
--- a/drivers/input/serio/hp_sdc_mlc.c
+++ b/drivers/input/serio/hp_sdc_mlc.c
@@ -40,7 +40,7 @@
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/string.h> 42#include <linux/string.h>
43#include <asm/semaphore.h> 43#include <linux/semaphore.h>
44 44
45#define PREFIX "HP SDC MLC: " 45#define PREFIX "HP SDC MLC: "
46 46
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 57a1c28bf122..39573b91c8de 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -28,13 +28,6 @@
28#include <linux/spi/ads7846.h> 28#include <linux/spi/ads7846.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#ifdef CONFIG_ARM
32#include <asm/mach-types.h>
33#ifdef CONFIG_ARCH_OMAP
34#include <asm/arch/gpio.h>
35#endif
36#endif
37
38 31
39/* 32/*
40 * This code has been heavily tested on a Nokia 770, and lightly 33 * This code has been heavily tested on a Nokia 770, and lightly
@@ -1174,31 +1167,6 @@ static struct spi_driver ads7846_driver = {
1174 1167
1175static int __init ads7846_init(void) 1168static int __init ads7846_init(void)
1176{ 1169{
1177 /* grr, board-specific init should stay out of drivers!! */
1178
1179#ifdef CONFIG_ARCH_OMAP
1180 if (machine_is_omap_osk()) {
1181 /* GPIO4 = PENIRQ; GPIO6 = BUSY */
1182 omap_request_gpio(4);
1183 omap_set_gpio_direction(4, 1);
1184 omap_request_gpio(6);
1185 omap_set_gpio_direction(6, 1);
1186 }
1187 // also TI 1510 Innovator, bitbanging through FPGA
1188 // also Nokia 770
1189 // also Palm Tungsten T2
1190#endif
1191
1192 // PXA:
1193 // also Dell Axim X50
1194 // also HP iPaq H191x/H192x/H415x/H435x
1195 // also Intel Lubbock (additional to UCB1400; as temperature sensor)
1196 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
1197
1198 // Atmel at91sam9261-EK uses ads7843
1199
1200 // also various AMD Au1x00 devel boards
1201
1202 return spi_register_driver(&ads7846_driver); 1170 return spi_register_driver(&ads7846_driver);
1203} 1171}
1204module_init(ads7846_init); 1172module_init(ads7846_init);
@@ -1206,14 +1174,6 @@ module_init(ads7846_init);
1206static void __exit ads7846_exit(void) 1174static void __exit ads7846_exit(void)
1207{ 1175{
1208 spi_unregister_driver(&ads7846_driver); 1176 spi_unregister_driver(&ads7846_driver);
1209
1210#ifdef CONFIG_ARCH_OMAP
1211 if (machine_is_omap_osk()) {
1212 omap_free_gpio(4);
1213 omap_free_gpio(6);
1214 }
1215#endif
1216
1217} 1177}
1218module_exit(ads7846_exit); 1178module_exit(ads7846_exit);
1219 1179
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 99d92f5c93d6..a22576779acd 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -22,6 +22,7 @@
22#include <asm/arch/sharpsl.h> 22#include <asm/arch/sharpsl.h>
23#include <asm/arch/hardware.h> 23#include <asm/arch/hardware.h>
24#include <asm/arch/pxa-regs.h> 24#include <asm/arch/pxa-regs.h>
25#include <asm/arch/pxa2xx-gpio.h>
25 26
26 27
27#define PWR_MODE_ACTIVE 0 28#define PWR_MODE_ACTIVE 0
diff --git a/drivers/isdn/hisax/asuscom.c b/drivers/isdn/hisax/asuscom.c
index 61e69e9c4aa9..b96f3184c2e5 100644
--- a/drivers/isdn/hisax/asuscom.c
+++ b/drivers/isdn/hisax/asuscom.c
@@ -20,8 +20,6 @@
20#include "hscx.h" 20#include "hscx.h"
21#include "isdnl1.h" 21#include "isdnl1.h"
22 22
23extern const char *CardType[];
24
25static const char *Asuscom_revision = "$Revision: 1.14.2.4 $"; 23static const char *Asuscom_revision = "$Revision: 1.14.2.4 $";
26 24
27#define byteout(addr,val) outb(val,addr) 25#define byteout(addr,val) outb(val,addr)
@@ -376,8 +374,7 @@ setup_asuscom(struct IsdnCard *card)
376 cs->irq = card->para[0]; 374 cs->irq = card->para[0];
377 if (!request_region(cs->hw.asus.cfg_reg, bytecnt, "asuscom isdn")) { 375 if (!request_region(cs->hw.asus.cfg_reg, bytecnt, "asuscom isdn")) {
378 printk(KERN_WARNING 376 printk(KERN_WARNING
379 "HiSax: %s config port %x-%x already in use\n", 377 "HiSax: ISDNLink config port %x-%x already in use\n",
380 CardType[card->typ],
381 cs->hw.asus.cfg_reg, 378 cs->hw.asus.cfg_reg,
382 cs->hw.asus.cfg_reg + bytecnt); 379 cs->hw.asus.cfg_reg + bytecnt);
383 return (0); 380 return (0);
diff --git a/drivers/isdn/hisax/avm_a1.c b/drivers/isdn/hisax/avm_a1.c
index d9028e9b9b8f..eb6b432e261f 100644
--- a/drivers/isdn/hisax/avm_a1.c
+++ b/drivers/isdn/hisax/avm_a1.c
@@ -16,7 +16,6 @@
16#include "hscx.h" 16#include "hscx.h"
17#include "isdnl1.h" 17#include "isdnl1.h"
18 18
19extern const char *CardType[];
20static const char *avm_revision = "$Revision: 2.15.2.4 $"; 19static const char *avm_revision = "$Revision: 2.15.2.4 $";
21 20
22#define AVM_A1_STAT_ISAC 0x01 21#define AVM_A1_STAT_ISAC 0x01
@@ -200,16 +199,14 @@ setup_avm_a1(struct IsdnCard *card)
200 cs->irq = card->para[0]; 199 cs->irq = card->para[0];
201 if (!request_region(cs->hw.avm.cfg_reg, 8, "avm cfg")) { 200 if (!request_region(cs->hw.avm.cfg_reg, 8, "avm cfg")) {
202 printk(KERN_WARNING 201 printk(KERN_WARNING
203 "HiSax: %s config port %x-%x already in use\n", 202 "HiSax: AVM A1 config port %x-%x already in use\n",
204 CardType[card->typ],
205 cs->hw.avm.cfg_reg, 203 cs->hw.avm.cfg_reg,
206 cs->hw.avm.cfg_reg + 8); 204 cs->hw.avm.cfg_reg + 8);
207 return (0); 205 return (0);
208 } 206 }
209 if (!request_region(cs->hw.avm.isac + 32, 32, "HiSax isac")) { 207 if (!request_region(cs->hw.avm.isac + 32, 32, "HiSax isac")) {
210 printk(KERN_WARNING 208 printk(KERN_WARNING
211 "HiSax: %s isac ports %x-%x already in use\n", 209 "HiSax: AVM A1 isac ports %x-%x already in use\n",
212 CardType[cs->typ],
213 cs->hw.avm.isac + 32, 210 cs->hw.avm.isac + 32,
214 cs->hw.avm.isac + 64); 211 cs->hw.avm.isac + 64);
215 release_ioregs(cs, 0); 212 release_ioregs(cs, 0);
@@ -217,16 +214,14 @@ setup_avm_a1(struct IsdnCard *card)
217 } 214 }
218 if (!request_region(cs->hw.avm.isacfifo, 1, "HiSax isac fifo")) { 215 if (!request_region(cs->hw.avm.isacfifo, 1, "HiSax isac fifo")) {
219 printk(KERN_WARNING 216 printk(KERN_WARNING
220 "HiSax: %s isac fifo port %x already in use\n", 217 "HiSax: AVM A1 isac fifo port %x already in use\n",
221 CardType[cs->typ],
222 cs->hw.avm.isacfifo); 218 cs->hw.avm.isacfifo);
223 release_ioregs(cs, 1); 219 release_ioregs(cs, 1);
224 return (0); 220 return (0);
225 } 221 }
226 if (!request_region(cs->hw.avm.hscx[0] + 32, 32, "HiSax hscx A")) { 222 if (!request_region(cs->hw.avm.hscx[0] + 32, 32, "HiSax hscx A")) {
227 printk(KERN_WARNING 223 printk(KERN_WARNING
228 "HiSax: %s hscx A ports %x-%x already in use\n", 224 "HiSax: AVM A1 hscx A ports %x-%x already in use\n",
229 CardType[cs->typ],
230 cs->hw.avm.hscx[0] + 32, 225 cs->hw.avm.hscx[0] + 32,
231 cs->hw.avm.hscx[0] + 64); 226 cs->hw.avm.hscx[0] + 64);
232 release_ioregs(cs, 3); 227 release_ioregs(cs, 3);
@@ -234,16 +229,14 @@ setup_avm_a1(struct IsdnCard *card)
234 } 229 }
235 if (!request_region(cs->hw.avm.hscxfifo[0], 1, "HiSax hscx A fifo")) { 230 if (!request_region(cs->hw.avm.hscxfifo[0], 1, "HiSax hscx A fifo")) {
236 printk(KERN_WARNING 231 printk(KERN_WARNING
237 "HiSax: %s hscx A fifo port %x already in use\n", 232 "HiSax: AVM A1 hscx A fifo port %x already in use\n",
238 CardType[cs->typ],
239 cs->hw.avm.hscxfifo[0]); 233 cs->hw.avm.hscxfifo[0]);
240 release_ioregs(cs, 7); 234 release_ioregs(cs, 7);
241 return (0); 235 return (0);
242 } 236 }
243 if (!request_region(cs->hw.avm.hscx[1] + 32, 32, "HiSax hscx B")) { 237 if (!request_region(cs->hw.avm.hscx[1] + 32, 32, "HiSax hscx B")) {
244 printk(KERN_WARNING 238 printk(KERN_WARNING
245 "HiSax: %s hscx B ports %x-%x already in use\n", 239 "HiSax: AVM A1 hscx B ports %x-%x already in use\n",
246 CardType[cs->typ],
247 cs->hw.avm.hscx[1] + 32, 240 cs->hw.avm.hscx[1] + 32,
248 cs->hw.avm.hscx[1] + 64); 241 cs->hw.avm.hscx[1] + 64);
249 release_ioregs(cs, 0xf); 242 release_ioregs(cs, 0xf);
@@ -251,8 +244,7 @@ setup_avm_a1(struct IsdnCard *card)
251 } 244 }
252 if (!request_region(cs->hw.avm.hscxfifo[1], 1, "HiSax hscx B fifo")) { 245 if (!request_region(cs->hw.avm.hscxfifo[1], 1, "HiSax hscx B fifo")) {
253 printk(KERN_WARNING 246 printk(KERN_WARNING
254 "HiSax: %s hscx B fifo port %x already in use\n", 247 "HiSax: AVM A1 hscx B fifo port %x already in use\n",
255 CardType[cs->typ],
256 cs->hw.avm.hscxfifo[1]); 248 cs->hw.avm.hscxfifo[1]);
257 release_ioregs(cs, 0x1f); 249 release_ioregs(cs, 0x1f);
258 return (0); 250 return (0);
@@ -284,9 +276,8 @@ setup_avm_a1(struct IsdnCard *card)
284 printk(KERN_INFO "AVM A1: Byte at %x is %x\n", 276 printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
285 cs->hw.avm.cfg_reg, val); 277 cs->hw.avm.cfg_reg, val);
286 278
287 printk(KERN_INFO 279 printk(KERN_INFO "HiSax: AVM A1 config irq:%d cfg:0x%X\n",
288 "HiSax: %s config irq:%d cfg:0x%X\n", 280 cs->irq,
289 CardType[cs->typ], cs->irq,
290 cs->hw.avm.cfg_reg); 281 cs->hw.avm.cfg_reg);
291 printk(KERN_INFO 282 printk(KERN_INFO
292 "HiSax: isac:0x%X/0x%X\n", 283 "HiSax: isac:0x%X/0x%X\n",
diff --git a/drivers/isdn/hisax/bkm_a4t.c b/drivers/isdn/hisax/bkm_a4t.c
index 3d1bdc8431ad..9ca2ee54cc94 100644
--- a/drivers/isdn/hisax/bkm_a4t.c
+++ b/drivers/isdn/hisax/bkm_a4t.c
@@ -20,8 +20,6 @@
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include "bkm_ax.h" 21#include "bkm_ax.h"
22 22
23extern const char *CardType[];
24
25static const char *bkm_a4t_revision = "$Revision: 1.22.2.4 $"; 23static const char *bkm_a4t_revision = "$Revision: 1.22.2.4 $";
26 24
27 25
@@ -284,15 +282,16 @@ static int __devinit a4t_cs_init(struct IsdnCard *card,
284 I20_REGISTER_FILE *pI20_Regs; 282 I20_REGISTER_FILE *pI20_Regs;
285 283
286 if (!cs->irq) { /* IRQ range check ?? */ 284 if (!cs->irq) { /* IRQ range check ?? */
287 printk(KERN_WARNING "HiSax: %s: No IRQ\n", CardType[card->typ]); 285 printk(KERN_WARNING "HiSax: Telekom A4T: No IRQ\n");
288 return (0); 286 return (0);
289 } 287 }
290 cs->hw.ax.base = (long) ioremap(pci_memaddr, 4096); 288 cs->hw.ax.base = (long) ioremap(pci_memaddr, 4096);
291 /* Check suspecious address */ 289 /* Check suspecious address */
292 pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base); 290 pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
293 if ((pI20_Regs->i20IntStatus & 0x8EFFFFFF) != 0) { 291 if ((pI20_Regs->i20IntStatus & 0x8EFFFFFF) != 0) {
294 printk(KERN_WARNING "HiSax: %s address %lx-%lx suspecious\n", 292 printk(KERN_WARNING "HiSax: Telekom A4T address "
295 CardType[card->typ], cs->hw.ax.base, cs->hw.ax.base + 4096); 293 "%lx-%lx suspicious\n",
294 cs->hw.ax.base, cs->hw.ax.base + 4096);
296 iounmap((void *) cs->hw.ax.base); 295 iounmap((void *) cs->hw.ax.base);
297 cs->hw.ax.base = 0; 296 cs->hw.ax.base = 0;
298 return (0); 297 return (0);
@@ -302,8 +301,9 @@ static int __devinit a4t_cs_init(struct IsdnCard *card,
302 cs->hw.ax.isac_ale = GCS_1; 301 cs->hw.ax.isac_ale = GCS_1;
303 cs->hw.ax.jade_ale = GCS_3; 302 cs->hw.ax.jade_ale = GCS_3;
304 303
305 printk(KERN_INFO "HiSax: %s: Card configured at 0x%lX IRQ %d\n", 304 printk(KERN_INFO "HiSax: Telekom A4T: Card configured at "
306 CardType[card->typ], cs->hw.ax.base, cs->irq); 305 "0x%lX IRQ %d\n",
306 cs->hw.ax.base, cs->irq);
307 307
308 setup_isac(cs); 308 setup_isac(cs);
309 cs->readisac = &ReadISAC; 309 cs->readisac = &ReadISAC;
@@ -349,11 +349,12 @@ setup_bkm_a4t(struct IsdnCard *card)
349 break; 349 break;
350 } 350 }
351 if (!found) { 351 if (!found) {
352 printk(KERN_WARNING "HiSax: %s: Card not found\n", CardType[card->typ]); 352 printk(KERN_WARNING "HiSax: Telekom A4T: Card not found\n");
353 return (0); 353 return (0);
354 } 354 }
355 if (!pci_memaddr) { 355 if (!pci_memaddr) {
356 printk(KERN_WARNING "HiSax: %s: No Memory base address\n", CardType[card->typ]); 356 printk(KERN_WARNING "HiSax: Telekom A4T: "
357 "No Memory base address\n");
357 return (0); 358 return (0);
358 } 359 }
359 360
diff --git a/drivers/isdn/hisax/bkm_a8.c b/drivers/isdn/hisax/bkm_a8.c
index 99ef3b43fcd7..e1ff4717a8a6 100644
--- a/drivers/isdn/hisax/bkm_a8.c
+++ b/drivers/isdn/hisax/bkm_a8.c
@@ -22,8 +22,6 @@
22 22
23#define ATTEMPT_PCI_REMAPPING /* Required for PLX rev 1 */ 23#define ATTEMPT_PCI_REMAPPING /* Required for PLX rev 1 */
24 24
25extern const char *CardType[];
26
27static const char sct_quadro_revision[] = "$Revision: 1.22.2.4 $"; 25static const char sct_quadro_revision[] = "$Revision: 1.22.2.4 $";
28 26
29static const char *sct_quadro_subtypes[] = 27static const char *sct_quadro_subtypes[] =
@@ -181,8 +179,7 @@ bkm_interrupt_ipac(int intno, void *dev_id)
181 goto Start_IPAC; 179 goto Start_IPAC;
182 } 180 }
183 if (!icnt) 181 if (!icnt)
184 printk(KERN_WARNING "HiSax: %s (%s) IRQ LOOP\n", 182 printk(KERN_WARNING "HiSax: Scitel Quadro (%s) IRQ LOOP\n",
185 CardType[cs->typ],
186 sct_quadro_subtypes[cs->subtyp]); 183 sct_quadro_subtypes[cs->subtyp]);
187 writereg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_MASK, 0xFF); 184 writereg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_MASK, 0xFF);
188 writereg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_MASK, 0xC0); 185 writereg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_MASK, 0xC0);
@@ -296,8 +293,8 @@ setup_sct_quadro(struct IsdnCard *card)
296 if (card->para[0] >= SCT_1 && card->para[0] <= SCT_4) 293 if (card->para[0] >= SCT_1 && card->para[0] <= SCT_4)
297 cs->subtyp = card->para[0]; 294 cs->subtyp = card->para[0];
298 else { 295 else {
299 printk(KERN_WARNING "HiSax: %s: Invalid subcontroller in configuration, default to 1\n", 296 printk(KERN_WARNING "HiSax: Scitel Quadro: Invalid "
300 CardType[card->typ]); 297 "subcontroller in configuration, default to 1\n");
301 return (0); 298 return (0);
302 } 299 }
303 if ((cs->subtyp != SCT_1) && ((sub_sys_id != PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) || 300 if ((cs->subtyp != SCT_1) && ((sub_sys_id != PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) ||
@@ -322,16 +319,16 @@ setup_sct_quadro(struct IsdnCard *card)
322 } 319 }
323 } 320 }
324 if (!found) { 321 if (!found) {
325 printk(KERN_WARNING "HiSax: %s (%s): Card not found\n", 322 printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
326 CardType[card->typ], 323 "Card not found\n",
327 sct_quadro_subtypes[cs->subtyp]); 324 sct_quadro_subtypes[cs->subtyp]);
328 return (0); 325 return (0);
329 } 326 }
330#ifdef ATTEMPT_PCI_REMAPPING 327#ifdef ATTEMPT_PCI_REMAPPING
331/* HACK: PLX revision 1 bug: PLX address bit 7 must not be set */ 328/* HACK: PLX revision 1 bug: PLX address bit 7 must not be set */
332 if ((pci_ioaddr1 & 0x80) && (dev_a8->revision == 1)) { 329 if ((pci_ioaddr1 & 0x80) && (dev_a8->revision == 1)) {
333 printk(KERN_WARNING "HiSax: %s (%s): PLX rev 1, remapping required!\n", 330 printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
334 CardType[card->typ], 331 "PLX rev 1, remapping required!\n",
335 sct_quadro_subtypes[cs->subtyp]); 332 sct_quadro_subtypes[cs->subtyp]);
336 /* Restart PCI negotiation */ 333 /* Restart PCI negotiation */
337 pci_write_config_dword(dev_a8, PCI_BASE_ADDRESS_1, (u_int) - 1); 334 pci_write_config_dword(dev_a8, PCI_BASE_ADDRESS_1, (u_int) - 1);
@@ -344,8 +341,7 @@ setup_sct_quadro(struct IsdnCard *card)
344#endif /* End HACK */ 341#endif /* End HACK */
345 } 342 }
346 if (!pci_irq) { /* IRQ range check ?? */ 343 if (!pci_irq) { /* IRQ range check ?? */
347 printk(KERN_WARNING "HiSax: %s (%s): No IRQ\n", 344 printk(KERN_WARNING "HiSax: Scitel Quadro (%s): No IRQ\n",
348 CardType[card->typ],
349 sct_quadro_subtypes[cs->subtyp]); 345 sct_quadro_subtypes[cs->subtyp]);
350 return (0); 346 return (0);
351 } 347 }
@@ -355,8 +351,8 @@ setup_sct_quadro(struct IsdnCard *card)
355 pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_4, &pci_ioaddr4); 351 pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_4, &pci_ioaddr4);
356 pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_5, &pci_ioaddr5); 352 pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_5, &pci_ioaddr5);
357 if (!pci_ioaddr1 || !pci_ioaddr2 || !pci_ioaddr3 || !pci_ioaddr4 || !pci_ioaddr5) { 353 if (!pci_ioaddr1 || !pci_ioaddr2 || !pci_ioaddr3 || !pci_ioaddr4 || !pci_ioaddr5) {
358 printk(KERN_WARNING "HiSax: %s (%s): No IO base address(es)\n", 354 printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
359 CardType[card->typ], 355 "No IO base address(es)\n",
360 sct_quadro_subtypes[cs->subtyp]); 356 sct_quadro_subtypes[cs->subtyp]);
361 return (0); 357 return (0);
362 } 358 }
@@ -411,8 +407,8 @@ setup_sct_quadro(struct IsdnCard *card)
411 /* For isac and hscx data path */ 407 /* For isac and hscx data path */
412 cs->hw.ax.data_adr = cs->hw.ax.base + 4; 408 cs->hw.ax.data_adr = cs->hw.ax.base + 4;
413 409
414 printk(KERN_INFO "HiSax: %s (%s) configured at 0x%.4lX, 0x%.4lX, 0x%.4lX and IRQ %d\n", 410 printk(KERN_INFO "HiSax: Scitel Quadro (%s) configured at "
415 CardType[card->typ], 411 "0x%.4lX, 0x%.4lX, 0x%.4lX and IRQ %d\n",
416 sct_quadro_subtypes[cs->subtyp], 412 sct_quadro_subtypes[cs->subtyp],
417 cs->hw.ax.plx_adr, 413 cs->hw.ax.plx_adr,
418 cs->hw.ax.base, 414 cs->hw.ax.base,
@@ -432,8 +428,7 @@ setup_sct_quadro(struct IsdnCard *card)
432 cs->cardmsg = &BKM_card_msg; 428 cs->cardmsg = &BKM_card_msg;
433 cs->irq_func = &bkm_interrupt_ipac; 429 cs->irq_func = &bkm_interrupt_ipac;
434 430
435 printk(KERN_INFO "HiSax: %s (%s): IPAC Version %d\n", 431 printk(KERN_INFO "HiSax: Scitel Quadro (%s): IPAC Version %d\n",
436 CardType[card->typ],
437 sct_quadro_subtypes[cs->subtyp], 432 sct_quadro_subtypes[cs->subtyp],
438 readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID)); 433 readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID));
439 return (1); 434 return (1);
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index a0ee43c04dd5..84d75a3f5d17 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1169,7 +1169,9 @@ outf_cs:
1169/* Used from an exported function but calls __devinit functions. 1169/* Used from an exported function but calls __devinit functions.
1170 * Tell modpost not to warn (__ref) 1170 * Tell modpost not to warn (__ref)
1171 */ 1171 */
1172static int __ref checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner) 1172static int __ref checkcard(int cardnr, char *id, int *busy_flag,
1173 struct module *lockowner,
1174 hisax_setup_func_t card_setup)
1173{ 1175{
1174 int ret; 1176 int ret;
1175 struct IsdnCard *card = cards + cardnr; 1177 struct IsdnCard *card = cards + cardnr;
@@ -1187,7 +1189,7 @@ static int __ref checkcard(int cardnr, char *id, int *busy_flag, struct module *
1187 (card->protocol == ISDN_PTYPE_NI1) ? "NI1" : 1189 (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
1188 "NONE", cs->iif.id, cs->myid); 1190 "NONE", cs->iif.id, cs->myid);
1189 1191
1190 ret = hisax_cs_setup_card(card); 1192 ret = card_setup(card);
1191 if (!ret) { 1193 if (!ret) {
1192 ll_unload(cs); 1194 ll_unload(cs);
1193 goto outf_cs; 1195 goto outf_cs;
@@ -1241,7 +1243,8 @@ static int HiSax_inithardware(int *busy_flag)
1241 else 1243 else
1242 sprintf(ids, "%s%d", id, i); 1244 sprintf(ids, "%s%d", id, i);
1243 } 1245 }
1244 if (checkcard(i, ids, busy_flag, THIS_MODULE)) { 1246 if (checkcard(i, ids, busy_flag, THIS_MODULE,
1247 hisax_cs_setup_card)) {
1245 foundcards++; 1248 foundcards++;
1246 i++; 1249 i++;
1247 } else { 1250 } else {
@@ -1549,7 +1552,8 @@ int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
1549 sprintf(ids, "HiSax%d", nrcards); 1552 sprintf(ids, "HiSax%d", nrcards);
1550 else 1553 else
1551 sprintf(ids, "HiSax"); 1554 sprintf(ids, "HiSax");
1552 if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE)) 1555 if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE,
1556 hisax_cs_setup_card))
1553 goto error; 1557 goto error;
1554 1558
1555 ret = nrcards; 1559 ret = nrcards;
@@ -1595,7 +1599,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1595 cards[i].protocol = protocol; 1599 cards[i].protocol = protocol;
1596 sprintf(id, "%s%d", name, i); 1600 sprintf(id, "%s%d", name, i);
1597 nrcards++; 1601 nrcards++;
1598 retval = checkcard(i, id, NULL, hisax_d_if->owner); 1602 retval = checkcard(i, id, NULL, hisax_d_if->owner, hisax_cs_setup_card);
1599 if (retval == 0) { // yuck 1603 if (retval == 0) { // yuck
1600 cards[i].typ = 0; 1604 cards[i].typ = 0;
1601 nrcards--; 1605 nrcards--;
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index d272d8ce6537..2c3691fda300 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -299,7 +299,7 @@ elsa_interrupt(int intno, void *dev_id)
299 val = serial_inp(cs, UART_IIR); 299 val = serial_inp(cs, UART_IIR);
300 if (!(val & UART_IIR_NO_INT)) { 300 if (!(val & UART_IIR_NO_INT)) {
301 debugl1(cs,"IIR %02x", val); 301 debugl1(cs,"IIR %02x", val);
302 rs_interrupt_elsa(intno, cs); 302 rs_interrupt_elsa(cs);
303 } 303 }
304 } 304 }
305#endif 305#endif
@@ -379,7 +379,7 @@ elsa_interrupt_ipac(int intno, void *dev_id)
379 val = serial_inp(cs, UART_IIR); 379 val = serial_inp(cs, UART_IIR);
380 if (!(val & UART_IIR_NO_INT)) { 380 if (!(val & UART_IIR_NO_INT)) {
381 debugl1(cs,"IIR %02x", val); 381 debugl1(cs,"IIR %02x", val);
382 rs_interrupt_elsa(intno, cs); 382 rs_interrupt_elsa(cs);
383 } 383 }
384 } 384 }
385#endif 385#endif
diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
index 1642dca988a1..f181db464392 100644
--- a/drivers/isdn/hisax/elsa_ser.c
+++ b/drivers/isdn/hisax/elsa_ser.c
@@ -384,13 +384,13 @@ static inline void transmit_chars(struct IsdnCardState *cs, int *intr_done)
384} 384}
385 385
386 386
387static void rs_interrupt_elsa(int irq, struct IsdnCardState *cs) 387static void rs_interrupt_elsa(struct IsdnCardState *cs)
388{ 388{
389 int status, iir, msr; 389 int status, iir, msr;
390 int pass_counter = 0; 390 int pass_counter = 0;
391 391
392#ifdef SERIAL_DEBUG_INTR 392#ifdef SERIAL_DEBUG_INTR
393 printk("rs_interrupt_single(%d)...", irq); 393 printk(KERN_DEBUG "rs_interrupt_single(%d)...", cs->irq);
394#endif 394#endif
395 395
396 do { 396 do {
diff --git a/drivers/isdn/hisax/gazel.c b/drivers/isdn/hisax/gazel.c
index f66620ad8e7c..0ea3b4607680 100644
--- a/drivers/isdn/hisax/gazel.c
+++ b/drivers/isdn/hisax/gazel.c
@@ -19,7 +19,6 @@
19#include "ipac.h" 19#include "ipac.h"
20#include <linux/pci.h> 20#include <linux/pci.h>
21 21
22extern const char *CardType[];
23static const char *gazel_revision = "$Revision: 2.19.2.4 $"; 22static const char *gazel_revision = "$Revision: 2.19.2.4 $";
24 23
25#define R647 1 24#define R647 1
@@ -479,8 +478,8 @@ reserve_regions(struct IsdnCard *card, struct IsdnCardState *cs)
479 return 0; 478 return 0;
480 479
481 error: 480 error:
482 printk(KERN_WARNING "Gazel: %s io ports 0x%x-0x%x already in use\n", 481 printk(KERN_WARNING "Gazel: io ports 0x%x-0x%x already in use\n",
483 CardType[cs->typ], adr, adr + len); 482 adr, adr + len);
484 return 1; 483 return 1;
485} 484}
486 485
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index fba8b624ffcf..f1265667b062 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -22,8 +22,6 @@
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24 24
25extern const char *CardType[];
26
27static const char *hfcpci_revision = "$Revision: 1.48.2.4 $"; 25static const char *hfcpci_revision = "$Revision: 1.48.2.4 $";
28 26
29/* table entry in the PCI devices list */ 27/* table entry in the PCI devices list */
diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
index 05482d2688e3..f4a213877e35 100644
--- a/drivers/isdn/hisax/hfc_sx.c
+++ b/drivers/isdn/hisax/hfc_sx.c
@@ -18,8 +18,6 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/isapnp.h> 19#include <linux/isapnp.h>
20 20
21extern const char *CardType[];
22
23static const char *hfcsx_revision = "$Revision: 1.12.2.5 $"; 21static const char *hfcsx_revision = "$Revision: 1.12.2.5 $";
24 22
25/***************************************/ 23/***************************************/
diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
index 34733c903df7..e8d429fda846 100644
--- a/drivers/isdn/hisax/hisax.h
+++ b/drivers/isdn/hisax/hisax.h
@@ -925,7 +925,7 @@ struct IsdnCardState {
925 int (*cardmsg) (struct IsdnCardState *, int, void *); 925 int (*cardmsg) (struct IsdnCardState *, int, void *);
926 void (*setstack_d) (struct PStack *, struct IsdnCardState *); 926 void (*setstack_d) (struct PStack *, struct IsdnCardState *);
927 void (*DC_Close) (struct IsdnCardState *); 927 void (*DC_Close) (struct IsdnCardState *);
928 int (*irq_func) (int, void *); 928 irq_handler_t irq_func;
929 int (*auxcmd) (struct IsdnCardState *, isdn_ctrl *); 929 int (*auxcmd) (struct IsdnCardState *, isdn_ctrl *);
930 struct Channel channel[2+MAX_WAITING_CALLS]; 930 struct Channel channel[2+MAX_WAITING_CALLS];
931 struct BCState bcs[2+MAX_WAITING_CALLS]; 931 struct BCState bcs[2+MAX_WAITING_CALLS];
diff --git a/drivers/isdn/hisax/hisax_cfg.h b/drivers/isdn/hisax/hisax_cfg.h
index ca3fe6259bca..17a2fea64efe 100644
--- a/drivers/isdn/hisax/hisax_cfg.h
+++ b/drivers/isdn/hisax/hisax_cfg.h
@@ -60,5 +60,7 @@ struct IsdnCard {
60 IsdnCardState_t *cs; 60 IsdnCardState_t *cs;
61}; 61};
62 62
63typedef int (*hisax_setup_func_t)(struct IsdnCard *card);
64
63extern void HiSax_closecard(int); 65extern void HiSax_closecard(int);
64extern int hisax_init_pcmcia(void *, int *, IsdnCard_t *); 66extern int hisax_init_pcmcia(void *, int *, IsdnCard_t *);
diff --git a/drivers/isdn/hisax/isurf.c b/drivers/isdn/hisax/isurf.c
index 55de06953540..ca4161798cdf 100644
--- a/drivers/isdn/hisax/isurf.c
+++ b/drivers/isdn/hisax/isurf.c
@@ -17,8 +17,6 @@
17#include "isdnl1.h" 17#include "isdnl1.h"
18#include <linux/isapnp.h> 18#include <linux/isapnp.h>
19 19
20extern const char *CardType[];
21
22static const char *ISurf_revision = "$Revision: 1.12.2.4 $"; 20static const char *ISurf_revision = "$Revision: 1.12.2.4 $";
23 21
24#define byteout(addr,val) outb(val,addr) 22#define byteout(addr,val) outb(val,addr)
@@ -251,22 +249,19 @@ setup_isurf(struct IsdnCard *card)
251 return(0); 249 return(0);
252 } 250 }
253#else 251#else
254 printk(KERN_WARNING "HiSax: %s port/mem not set\n", 252 printk(KERN_WARNING "HiSax: Siemens I-Surf port/mem not set\n");
255 CardType[card->typ]);
256 return (0); 253 return (0);
257#endif 254#endif
258 } 255 }
259 if (!request_region(cs->hw.isurf.reset, 1, "isurf isdn")) { 256 if (!request_region(cs->hw.isurf.reset, 1, "isurf isdn")) {
260 printk(KERN_WARNING 257 printk(KERN_WARNING
261 "HiSax: %s config port %x already in use\n", 258 "HiSax: Siemens I-Surf config port %x already in use\n",
262 CardType[card->typ],
263 cs->hw.isurf.reset); 259 cs->hw.isurf.reset);
264 return (0); 260 return (0);
265 } 261 }
266 if (!request_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE, "isurf iomem")) { 262 if (!request_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE, "isurf iomem")) {
267 printk(KERN_WARNING 263 printk(KERN_WARNING "HiSax: Siemens I-Surf memory region "
268 "HiSax: %s memory region %lx-%lx already in use\n", 264 "%lx-%lx already in use\n",
269 CardType[card->typ],
270 cs->hw.isurf.phymem, 265 cs->hw.isurf.phymem,
271 cs->hw.isurf.phymem + ISURF_IOMEM_SIZE); 266 cs->hw.isurf.phymem + ISURF_IOMEM_SIZE);
272 release_region(cs->hw.isurf.reset, 1); 267 release_region(cs->hw.isurf.reset, 1);
diff --git a/drivers/isdn/hisax/ix1_micro.c b/drivers/isdn/hisax/ix1_micro.c
index 252d79de5e5e..2d18d4f1e57e 100644
--- a/drivers/isdn/hisax/ix1_micro.c
+++ b/drivers/isdn/hisax/ix1_micro.c
@@ -24,7 +24,6 @@
24#include "hscx.h" 24#include "hscx.h"
25#include "isdnl1.h" 25#include "isdnl1.h"
26 26
27extern const char *CardType[];
28static const char *ix1_revision = "$Revision: 2.12.2.4 $"; 27static const char *ix1_revision = "$Revision: 2.12.2.4 $";
29 28
30#define byteout(addr,val) outb(val,addr) 29#define byteout(addr,val) outb(val,addr)
@@ -288,15 +287,15 @@ setup_ix1micro(struct IsdnCard *card)
288 if (cs->hw.ix1.cfg_reg) { 287 if (cs->hw.ix1.cfg_reg) {
289 if (!request_region(cs->hw.ix1.cfg_reg, 4, "ix1micro cfg")) { 288 if (!request_region(cs->hw.ix1.cfg_reg, 4, "ix1micro cfg")) {
290 printk(KERN_WARNING 289 printk(KERN_WARNING
291 "HiSax: %s config port %x-%x already in use\n", 290 "HiSax: ITK ix1-micro Rev.2 config port "
292 CardType[card->typ], 291 "%x-%x already in use\n",
293 cs->hw.ix1.cfg_reg, 292 cs->hw.ix1.cfg_reg,
294 cs->hw.ix1.cfg_reg + 4); 293 cs->hw.ix1.cfg_reg + 4);
295 return (0); 294 return (0);
296 } 295 }
297 } 296 }
298 printk(KERN_INFO "HiSax: %s config irq:%d io:0x%X\n", 297 printk(KERN_INFO "HiSax: ITK ix1-micro Rev.2 config irq:%d io:0x%X\n",
299 CardType[cs->typ], cs->irq, cs->hw.ix1.cfg_reg); 298 cs->irq, cs->hw.ix1.cfg_reg);
300 setup_isac(cs); 299 setup_isac(cs);
301 cs->readisac = &ReadISAC; 300 cs->readisac = &ReadISAC;
302 cs->writeisac = &WriteISAC; 301 cs->writeisac = &WriteISAC;
diff --git a/drivers/isdn/hisax/mic.c b/drivers/isdn/hisax/mic.c
index a81d175d9f64..253943029d25 100644
--- a/drivers/isdn/hisax/mic.c
+++ b/drivers/isdn/hisax/mic.c
@@ -16,8 +16,6 @@
16#include "hscx.h" 16#include "hscx.h"
17#include "isdnl1.h" 17#include "isdnl1.h"
18 18
19extern const char *CardType[];
20
21static const char *mic_revision = "$Revision: 1.12.2.4 $"; 19static const char *mic_revision = "$Revision: 1.12.2.4 $";
22 20
23#define byteout(addr,val) outb(val,addr) 21#define byteout(addr,val) outb(val,addr)
@@ -210,8 +208,7 @@ setup_mic(struct IsdnCard *card)
210 208
211 if (!request_region(cs->hw.mic.cfg_reg, bytecnt, "mic isdn")) { 209 if (!request_region(cs->hw.mic.cfg_reg, bytecnt, "mic isdn")) {
212 printk(KERN_WARNING 210 printk(KERN_WARNING
213 "HiSax: %s config port %x-%x already in use\n", 211 "HiSax: ith mic config port %x-%x already in use\n",
214 CardType[card->typ],
215 cs->hw.mic.cfg_reg, 212 cs->hw.mic.cfg_reg,
216 cs->hw.mic.cfg_reg + bytecnt); 213 cs->hw.mic.cfg_reg + bytecnt);
217 return (0); 214 return (0);
diff --git a/drivers/isdn/hisax/netjet.h b/drivers/isdn/hisax/netjet.h
index 4d89d3ea4173..68e504d4ebf9 100644
--- a/drivers/isdn/hisax/netjet.h
+++ b/drivers/isdn/hisax/netjet.h
@@ -12,8 +12,6 @@
12 * 12 *
13 */ 13 */
14 14
15extern const char *CardType[];
16
17#define byteout(addr,val) outb(val,addr) 15#define byteout(addr,val) outb(val,addr)
18#define bytein(addr) inb(addr) 16#define bytein(addr) inb(addr)
19 17
diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
index bd9921128aa8..421b8e6763d7 100644
--- a/drivers/isdn/hisax/niccy.c
+++ b/drivers/isdn/hisax/niccy.c
@@ -21,7 +21,6 @@
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/isapnp.h> 22#include <linux/isapnp.h>
23 23
24extern const char *CardType[];
25static const char *niccy_revision = "$Revision: 1.21.2.4 $"; 24static const char *niccy_revision = "$Revision: 1.21.2.4 $";
26 25
27#define byteout(addr,val) outb(val,addr) 26#define byteout(addr,val) outb(val,addr)
@@ -284,14 +283,14 @@ int __devinit setup_niccy(struct IsdnCard *card)
284 cs->subtyp = NICCY_PNP; 283 cs->subtyp = NICCY_PNP;
285 cs->irq = card->para[0]; 284 cs->irq = card->para[0];
286 if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) { 285 if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) {
287 printk(KERN_WARNING "HiSax: %s data port %x-%x " 286 printk(KERN_WARNING "HiSax: NICCY data port %x-%x "
288 "already in use\n", CardType[card->typ], 287 "already in use\n",
289 cs->hw.niccy.isac, cs->hw.niccy.isac + 1); 288 cs->hw.niccy.isac, cs->hw.niccy.isac + 1);
290 return 0; 289 return 0;
291 } 290 }
292 if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) { 291 if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) {
293 printk(KERN_WARNING "HiSax: %s address port %x-%x " 292 printk(KERN_WARNING "HiSax: NICCY address port %x-%x "
294 "already in use\n", CardType[card->typ], 293 "already in use\n",
295 cs->hw.niccy.isac_ale, 294 cs->hw.niccy.isac_ale,
296 cs->hw.niccy.isac_ale + 1); 295 cs->hw.niccy.isac_ale + 1);
297 release_region(cs->hw.niccy.isac, 2); 296 release_region(cs->hw.niccy.isac, 2);
@@ -339,15 +338,13 @@ int __devinit setup_niccy(struct IsdnCard *card)
339 cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR; 338 cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
340 if (!request_region(cs->hw.niccy.isac, 4, "niccy")) { 339 if (!request_region(cs->hw.niccy.isac, 4, "niccy")) {
341 printk(KERN_WARNING 340 printk(KERN_WARNING
342 "HiSax: %s data port %x-%x already in use\n", 341 "HiSax: NICCY data port %x-%x already in use\n",
343 CardType[card->typ],
344 cs->hw.niccy.isac, cs->hw.niccy.isac + 4); 342 cs->hw.niccy.isac, cs->hw.niccy.isac + 4);
345 return 0; 343 return 0;
346 } 344 }
347 if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) { 345 if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) {
348 printk(KERN_WARNING 346 printk(KERN_WARNING
349 "HiSax: %s pci port %x-%x already in use\n", 347 "HiSax: NICCY pci port %x-%x already in use\n",
350 CardType[card->typ],
351 cs->hw.niccy.cfg_reg, 348 cs->hw.niccy.cfg_reg,
352 cs->hw.niccy.cfg_reg + 0x40); 349 cs->hw.niccy.cfg_reg + 0x40);
353 release_region(cs->hw.niccy.isac, 4); 350 release_region(cs->hw.niccy.isac, 4);
@@ -359,8 +356,8 @@ int __devinit setup_niccy(struct IsdnCard *card)
359 return 0; 356 return 0;
360#endif /* CONFIG_PCI_LEGACY */ 357#endif /* CONFIG_PCI_LEGACY */
361 } 358 }
362 printk(KERN_INFO "HiSax: %s %s config irq:%d data:0x%X ale:0x%X\n", 359 printk(KERN_INFO "HiSax: NICCY %s config irq:%d data:0x%X ale:0x%X\n",
363 CardType[cs->typ], (cs->subtyp == 1) ? "PnP" : "PCI", 360 (cs->subtyp == 1) ? "PnP" : "PCI",
364 cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale); 361 cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale);
365 setup_isac(cs); 362 setup_isac(cs);
366 cs->readisac = &ReadISAC; 363 cs->readisac = &ReadISAC;
diff --git a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c
index a895dfed40e5..8d36ccc87d81 100644
--- a/drivers/isdn/hisax/nj_s.c
+++ b/drivers/isdn/hisax/nj_s.c
@@ -235,8 +235,7 @@ static int __devinit njs_cs_init_rest(struct IsdnCard *card,
235 cs->subtyp ? "TJ320" : "TJ300", cs->hw.njet.base, cs->irq); 235 cs->subtyp ? "TJ320" : "TJ300", cs->hw.njet.base, cs->irq);
236 if (!request_region(cs->hw.njet.base, bytecnt, "netjet-s isdn")) { 236 if (!request_region(cs->hw.njet.base, bytecnt, "netjet-s isdn")) {
237 printk(KERN_WARNING 237 printk(KERN_WARNING
238 "HiSax: %s config port %#lx-%#lx already in use\n", 238 "HiSax: NETjet-S config port %#lx-%#lx already in use\n",
239 CardType[card->typ],
240 cs->hw.njet.base, 239 cs->hw.njet.base,
241 cs->hw.njet.base + bytecnt); 240 cs->hw.njet.base + bytecnt);
242 return (0); 241 return (0);
diff --git a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c
index f017d3816b1d..d306c946ffba 100644
--- a/drivers/isdn/hisax/nj_u.c
+++ b/drivers/isdn/hisax/nj_u.c
@@ -197,8 +197,8 @@ static int __devinit nju_cs_init_rest(struct IsdnCard *card,
197 cs->hw.njet.base, cs->irq); 197 cs->hw.njet.base, cs->irq);
198 if (!request_region(cs->hw.njet.base, bytecnt, "netspider-u isdn")) { 198 if (!request_region(cs->hw.njet.base, bytecnt, "netspider-u isdn")) {
199 printk(KERN_WARNING 199 printk(KERN_WARNING
200 "HiSax: %s config port %#lx-%#lx already in use\n", 200 "HiSax: NETspider-U config port %#lx-%#lx "
201 CardType[card->typ], 201 "already in use\n",
202 cs->hw.njet.base, 202 cs->hw.njet.base,
203 cs->hw.njet.base + bytecnt); 203 cs->hw.njet.base + bytecnt);
204 return (0); 204 return (0);
diff --git a/drivers/isdn/hisax/s0box.c b/drivers/isdn/hisax/s0box.c
index 150ef68b4ae2..16d00b555c8c 100644
--- a/drivers/isdn/hisax/s0box.c
+++ b/drivers/isdn/hisax/s0box.c
@@ -16,7 +16,6 @@
16#include "hscx.h" 16#include "hscx.h"
17#include "isdnl1.h" 17#include "isdnl1.h"
18 18
19extern const char *CardType[];
20static const char *s0box_revision = "$Revision: 2.6.2.4 $"; 19static const char *s0box_revision = "$Revision: 2.6.2.4 $";
21 20
22static inline void 21static inline void
@@ -231,19 +230,15 @@ setup_s0box(struct IsdnCard *card)
231 cs->hw.teles3.hscxfifo[1] = cs->hw.teles3.hscx[1] + 0x3e; 230 cs->hw.teles3.hscxfifo[1] = cs->hw.teles3.hscx[1] + 0x3e;
232 cs->irq = card->para[0]; 231 cs->irq = card->para[0];
233 if (!request_region(cs->hw.teles3.cfg_reg,8, "S0Box parallel I/O")) { 232 if (!request_region(cs->hw.teles3.cfg_reg,8, "S0Box parallel I/O")) {
234 printk(KERN_WARNING 233 printk(KERN_WARNING "HiSax: S0Box ports %x-%x already in use\n",
235 "HiSax: %s ports %x-%x already in use\n",
236 CardType[cs->typ],
237 cs->hw.teles3.cfg_reg, 234 cs->hw.teles3.cfg_reg,
238 cs->hw.teles3.cfg_reg + 7); 235 cs->hw.teles3.cfg_reg + 7);
239 return 0; 236 return 0;
240 } 237 }
241 printk(KERN_INFO 238 printk(KERN_INFO "HiSax: S0Box config irq:%d isac:0x%x cfg:0x%x\n",
242 "HiSax: %s config irq:%d isac:0x%x cfg:0x%x\n", 239 cs->irq,
243 CardType[cs->typ], cs->irq,
244 cs->hw.teles3.isac, cs->hw.teles3.cfg_reg); 240 cs->hw.teles3.isac, cs->hw.teles3.cfg_reg);
245 printk(KERN_INFO 241 printk(KERN_INFO "HiSax: hscx A:0x%x hscx B:0x%x\n",
246 "HiSax: hscx A:0x%x hscx B:0x%x\n",
247 cs->hw.teles3.hscx[0], cs->hw.teles3.hscx[1]); 242 cs->hw.teles3.hscx[0], cs->hw.teles3.hscx[1]);
248 setup_isac(cs); 243 setup_isac(cs);
249 cs->readisac = &ReadISAC; 244 cs->readisac = &ReadISAC;
diff --git a/drivers/isdn/hisax/saphir.c b/drivers/isdn/hisax/saphir.c
index c99b16690fb3..b34a81d655b8 100644
--- a/drivers/isdn/hisax/saphir.c
+++ b/drivers/isdn/hisax/saphir.c
@@ -18,7 +18,6 @@
18#include "hscx.h" 18#include "hscx.h"
19#include "isdnl1.h" 19#include "isdnl1.h"
20 20
21extern const char *CardType[];
22static char *saphir_rev = "$Revision: 1.10.2.4 $"; 21static char *saphir_rev = "$Revision: 1.10.2.4 $";
23 22
24#define byteout(addr,val) outb(val,addr) 23#define byteout(addr,val) outb(val,addr)
@@ -260,15 +259,14 @@ setup_saphir(struct IsdnCard *card)
260 cs->irq = card->para[0]; 259 cs->irq = card->para[0];
261 if (!request_region(cs->hw.saphir.cfg_reg, 6, "saphir")) { 260 if (!request_region(cs->hw.saphir.cfg_reg, 6, "saphir")) {
262 printk(KERN_WARNING 261 printk(KERN_WARNING
263 "HiSax: %s config port %x-%x already in use\n", 262 "HiSax: HST Saphir config port %x-%x already in use\n",
264 CardType[card->typ],
265 cs->hw.saphir.cfg_reg, 263 cs->hw.saphir.cfg_reg,
266 cs->hw.saphir.cfg_reg + 5); 264 cs->hw.saphir.cfg_reg + 5);
267 return (0); 265 return (0);
268 } 266 }
269 267
270 printk(KERN_INFO "HiSax: %s config irq:%d io:0x%X\n", 268 printk(KERN_INFO "HiSax: HST Saphir config irq:%d io:0x%X\n",
271 CardType[cs->typ], cs->irq, cs->hw.saphir.cfg_reg); 269 cs->irq, cs->hw.saphir.cfg_reg);
272 270
273 setup_isac(cs); 271 setup_isac(cs);
274 cs->hw.saphir.timer.function = (void *) SaphirWatchDog; 272 cs->hw.saphir.timer.function = (void *) SaphirWatchDog;
diff --git a/drivers/isdn/hisax/sportster.c b/drivers/isdn/hisax/sportster.c
index 02209500b3b7..0a53759adfa4 100644
--- a/drivers/isdn/hisax/sportster.c
+++ b/drivers/isdn/hisax/sportster.c
@@ -18,7 +18,6 @@
18#include "hscx.h" 18#include "hscx.h"
19#include "isdnl1.h" 19#include "isdnl1.h"
20 20
21extern const char *CardType[];
22static const char *sportster_revision = "$Revision: 1.16.2.4 $"; 21static const char *sportster_revision = "$Revision: 1.16.2.4 $";
23 22
24#define byteout(addr,val) outb(val,addr) 23#define byteout(addr,val) outb(val,addr)
@@ -192,9 +191,9 @@ get_io_range(struct IsdnCardState *cs)
192 for (i=0;i<64;i++) { 191 for (i=0;i<64;i++) {
193 adr = cs->hw.spt.cfg_reg + i *1024; 192 adr = cs->hw.spt.cfg_reg + i *1024;
194 if (!request_region(adr, 8, "sportster")) { 193 if (!request_region(adr, 8, "sportster")) {
195 printk(KERN_WARNING 194 printk(KERN_WARNING "HiSax: USR Sportster config port "
196 "HiSax: %s config port %x-%x already in use\n", 195 "%x-%x already in use\n",
197 CardType[cs->typ], adr, adr + 8); 196 adr, adr + 8);
198 break; 197 break;
199 } 198 }
200 } 199 }
@@ -247,8 +246,8 @@ setup_sportster(struct IsdnCard *card)
247 printk(KERN_WARNING "Sportster: wrong IRQ\n"); 246 printk(KERN_WARNING "Sportster: wrong IRQ\n");
248 return(0); 247 return(0);
249 } 248 }
250 printk(KERN_INFO "HiSax: %s config irq:%d cfg:0x%X\n", 249 printk(KERN_INFO "HiSax: USR Sportster config irq:%d cfg:0x%X\n",
251 CardType[cs->typ], cs->irq, cs->hw.spt.cfg_reg); 250 cs->irq, cs->hw.spt.cfg_reg);
252 setup_isac(cs); 251 setup_isac(cs);
253 cs->readisac = &ReadISAC; 252 cs->readisac = &ReadISAC;
254 cs->writeisac = &WriteISAC; 253 cs->writeisac = &WriteISAC;
diff --git a/drivers/isdn/hisax/teleint.c b/drivers/isdn/hisax/teleint.c
index 0909662b7458..b0ce4ae45cbf 100644
--- a/drivers/isdn/hisax/teleint.c
+++ b/drivers/isdn/hisax/teleint.c
@@ -16,8 +16,6 @@
16#include "hfc_2bs0.h" 16#include "hfc_2bs0.h"
17#include "isdnl1.h" 17#include "isdnl1.h"
18 18
19extern const char *CardType[];
20
21static const char *TeleInt_revision = "$Revision: 1.16.2.5 $"; 19static const char *TeleInt_revision = "$Revision: 1.16.2.5 $";
22 20
23#define byteout(addr,val) outb(val,addr) 21#define byteout(addr,val) outb(val,addr)
@@ -286,8 +284,7 @@ setup_TeleInt(struct IsdnCard *card)
286 init_timer(&cs->hw.hfc.timer); 284 init_timer(&cs->hw.hfc.timer);
287 if (!request_region(cs->hw.hfc.addr, 2, "TeleInt isdn")) { 285 if (!request_region(cs->hw.hfc.addr, 2, "TeleInt isdn")) {
288 printk(KERN_WARNING 286 printk(KERN_WARNING
289 "HiSax: %s config port %x-%x already in use\n", 287 "HiSax: TeleInt config port %x-%x already in use\n",
290 CardType[card->typ],
291 cs->hw.hfc.addr, 288 cs->hw.hfc.addr,
292 cs->hw.hfc.addr + 2); 289 cs->hw.hfc.addr + 2);
293 return (0); 290 return (0);
diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
index 4393003ae162..28b08de4673d 100644
--- a/drivers/isdn/hisax/telespci.c
+++ b/drivers/isdn/hisax/telespci.c
@@ -19,7 +19,6 @@
19#include "isdnl1.h" 19#include "isdnl1.h"
20#include <linux/pci.h> 20#include <linux/pci.h>
21 21
22extern const char *CardType[];
23static const char *telespci_revision = "$Revision: 2.23.2.3 $"; 22static const char *telespci_revision = "$Revision: 2.23.2.3 $";
24 23
25#define ZORAN_PO_RQ_PEN 0x02000000 24#define ZORAN_PO_RQ_PEN 0x02000000
@@ -329,8 +328,8 @@ setup_telespci(struct IsdnCard *card)
329 /* writel(0x00800000, cs->hw.teles0.membase + 0x200); */ 328 /* writel(0x00800000, cs->hw.teles0.membase + 0x200); */
330 329
331 printk(KERN_INFO 330 printk(KERN_INFO
332 "HiSax: %s config irq:%d mem:%p\n", 331 "HiSax: Teles PCI config irq:%d mem:%p\n",
333 CardType[cs->typ], cs->irq, 332 cs->irq,
334 cs->hw.teles0.membase); 333 cs->hw.teles0.membase);
335 334
336 setup_isac(cs); 335 setup_isac(cs);
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 39129b94f8be..bb1c8dd1a230 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -38,8 +38,6 @@ static const PCI_ENTRY id_list[] =
38#define W6692_DYNALINK 1 38#define W6692_DYNALINK 1
39#define W6692_USR 2 39#define W6692_USR 2
40 40
41extern const char *CardType[];
42
43static const char *w6692_revision = "$Revision: 1.18.2.4 $"; 41static const char *w6692_revision = "$Revision: 1.18.2.4 $";
44 42
45#define DBUSY_TIMER_VALUE 80 43#define DBUSY_TIMER_VALUE 80
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 859814f62cb0..a3a6199639f9 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -46,13 +46,6 @@ config LEDS_SPITZ
46 This option enables support for the LEDs on Sharp Zaurus 46 This option enables support for the LEDs on Sharp Zaurus
47 SL-Cxx00 series (C1000, C3000, C3100). 47 SL-Cxx00 series (C1000, C3000, C3100).
48 48
49config LEDS_TOSA
50 tristate "LED Support for the Sharp SL-6000 series"
51 depends on LEDS_CLASS && PXA_SHARPSL
52 help
53 This option enables support for the LEDs on Sharp Zaurus
54 SL-6000 series.
55
56config LEDS_S3C24XX 49config LEDS_S3C24XX
57 tristate "LED Support for Samsung S3C24XX GPIO LEDs" 50 tristate "LED Support for Samsung S3C24XX GPIO LEDs"
58 depends on LEDS_CLASS && ARCH_S3C2410 51 depends on LEDS_CLASS && ARCH_S3C2410
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 84ced3b1a13d..e54f42da21a2 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o
9obj-$(CONFIG_LEDS_CORGI) += leds-corgi.o 9obj-$(CONFIG_LEDS_CORGI) += leds-corgi.o
10obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o 10obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
11obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o 11obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o
12obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o
13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o 12obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o 13obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o 14obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 4a938780dfc3..63aad90247c4 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -139,12 +139,10 @@ EXPORT_SYMBOL_GPL(led_classdev_register);
139/** 139/**
140 * __led_classdev_unregister - unregisters a object of led_properties class. 140 * __led_classdev_unregister - unregisters a object of led_properties class.
141 * @led_cdev: the led device to unregister 141 * @led_cdev: the led device to unregister
142 * @suspended: indicates whether system-wide suspend or resume is in progress
143 * 142 *
144 * Unregisters a previously registered via led_classdev_register object. 143 * Unregisters a previously registered via led_classdev_register object.
145 */ 144 */
146void __led_classdev_unregister(struct led_classdev *led_cdev, 145void led_classdev_unregister(struct led_classdev *led_cdev)
147 bool suspended)
148{ 146{
149 device_remove_file(led_cdev->dev, &dev_attr_brightness); 147 device_remove_file(led_cdev->dev, &dev_attr_brightness);
150#ifdef CONFIG_LEDS_TRIGGERS 148#ifdef CONFIG_LEDS_TRIGGERS
@@ -155,16 +153,13 @@ void __led_classdev_unregister(struct led_classdev *led_cdev,
155 up_write(&led_cdev->trigger_lock); 153 up_write(&led_cdev->trigger_lock);
156#endif 154#endif
157 155
158 if (suspended) 156 device_unregister(led_cdev->dev);
159 device_pm_schedule_removal(led_cdev->dev);
160 else
161 device_unregister(led_cdev->dev);
162 157
163 down_write(&leds_list_lock); 158 down_write(&leds_list_lock);
164 list_del(&led_cdev->node); 159 list_del(&led_cdev->node);
165 up_write(&leds_list_lock); 160 up_write(&leds_list_lock);
166} 161}
167EXPORT_SYMBOL_GPL(__led_classdev_unregister); 162EXPORT_SYMBOL_GPL(led_classdev_unregister);
168 163
169static int __init leds_init(void) 164static int __init leds_init(void)
170{ 165{
diff --git a/drivers/leds/leds-tosa.c b/drivers/leds/leds-tosa.c
deleted file mode 100644
index 7ebecc41a9be..000000000000
--- a/drivers/leds/leds-tosa.c
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * LED Triggers Core
3 *
4 * Copyright 2005 Dirk Opfer
5 *
6 * Author: Dirk Opfer <Dirk@Opfer-Online.de>
7 * based on spitz.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/leds.h>
19#include <asm/hardware/scoop.h>
20#include <asm/mach-types.h>
21#include <asm/arch/hardware.h>
22#include <asm/arch/pxa-regs.h>
23#include <asm/arch/tosa.h>
24
25static void tosaled_amber_set(struct led_classdev *led_cdev,
26 enum led_brightness value)
27{
28 if (value)
29 set_scoop_gpio(&tosascoop_jc_device.dev,
30 TOSA_SCOOP_JC_CHRG_ERR_LED);
31 else
32 reset_scoop_gpio(&tosascoop_jc_device.dev,
33 TOSA_SCOOP_JC_CHRG_ERR_LED);
34}
35
36static void tosaled_green_set(struct led_classdev *led_cdev,
37 enum led_brightness value)
38{
39 if (value)
40 set_scoop_gpio(&tosascoop_jc_device.dev,
41 TOSA_SCOOP_JC_NOTE_LED);
42 else
43 reset_scoop_gpio(&tosascoop_jc_device.dev,
44 TOSA_SCOOP_JC_NOTE_LED);
45}
46
47static struct led_classdev tosa_amber_led = {
48 .name = "tosa:amber:charge",
49 .default_trigger = "sharpsl-charge",
50 .brightness_set = tosaled_amber_set,
51};
52
53static struct led_classdev tosa_green_led = {
54 .name = "tosa:green:mail",
55 .default_trigger = "nand-disk",
56 .brightness_set = tosaled_green_set,
57};
58
59#ifdef CONFIG_PM
60static int tosaled_suspend(struct platform_device *dev, pm_message_t state)
61{
62#ifdef CONFIG_LEDS_TRIGGERS
63 if (tosa_amber_led.trigger && strcmp(tosa_amber_led.trigger->name,
64 "sharpsl-charge"))
65#endif
66 led_classdev_suspend(&tosa_amber_led);
67 led_classdev_suspend(&tosa_green_led);
68 return 0;
69}
70
71static int tosaled_resume(struct platform_device *dev)
72{
73 led_classdev_resume(&tosa_amber_led);
74 led_classdev_resume(&tosa_green_led);
75 return 0;
76}
77#else
78#define tosaled_suspend NULL
79#define tosaled_resume NULL
80#endif
81
82static int tosaled_probe(struct platform_device *pdev)
83{
84 int ret;
85
86 ret = led_classdev_register(&pdev->dev, &tosa_amber_led);
87 if (ret < 0)
88 return ret;
89
90 ret = led_classdev_register(&pdev->dev, &tosa_green_led);
91 if (ret < 0)
92 led_classdev_unregister(&tosa_amber_led);
93
94 return ret;
95}
96
97static int tosaled_remove(struct platform_device *pdev)
98{
99 led_classdev_unregister(&tosa_amber_led);
100 led_classdev_unregister(&tosa_green_led);
101
102 return 0;
103}
104
105static struct platform_driver tosaled_driver = {
106 .probe = tosaled_probe,
107 .remove = tosaled_remove,
108 .suspend = tosaled_suspend,
109 .resume = tosaled_resume,
110 .driver = {
111 .name = "tosa-led",
112 .owner = THIS_MODULE,
113 },
114};
115
116static int __init tosaled_init(void)
117{
118 return platform_driver_register(&tosaled_driver);
119}
120
121static void __exit tosaled_exit(void)
122{
123 platform_driver_unregister(&tosaled_driver);
124}
125
126module_init(tosaled_init);
127module_exit(tosaled_exit);
128
129MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
130MODULE_DESCRIPTION("Tosa LED driver");
131MODULE_LICENSE("GPL");
132MODULE_ALIAS("platform:tosa-led");
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index 2337e1a06f02..005bd045d2eb 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -10,7 +10,6 @@
10#include <linux/wait.h> 10#include <linux/wait.h>
11#include <linux/hrtimer.h> 11#include <linux/hrtimer.h>
12#include <linux/err.h> 12#include <linux/err.h>
13#include <asm/semaphore.h>
14 13
15#include <asm/lguest.h> 14#include <asm/lguest.h>
16 15
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 28958101061f..20978205cd02 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -37,9 +37,9 @@
37#include <linux/device.h> 37#include <linux/device.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/platform_device.h> 39#include <linux/platform_device.h>
40#include <linux/semaphore.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/semaphore.h>
43#ifdef CONFIG_PPC 43#ifdef CONFIG_PPC
44#include <asm/prom.h> 44#include <asm/prom.h>
45#include <asm/machdep.h> 45#include <asm/machdep.h>
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index f449d775cdf4..797918d0e59c 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/wait.h> 14#include <linux/wait.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <asm/semaphore.h> 16#include <linux/semaphore.h>
17#include <asm/prom.h> 17#include <asm/prom.h>
18#include <asm/smu.h> 18#include <asm/smu.h>
19#include <asm/pmac_low_i2c.h> 19#include <asm/pmac_low_i2c.h>
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index f0a67e93d7fd..c69bde39a233 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -36,7 +36,6 @@
36#include <asm/uaccess.h> /* copy to/from user */ 36#include <asm/uaccess.h> /* copy to/from user */
37#include <linux/videodev2.h> /* kernel radio structs */ 37#include <linux/videodev2.h> /* kernel radio structs */
38#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
39#include <asm/semaphore.h> /* Lock for the I/O */
40 39
41#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 40#include <linux/version.h> /* for KERNEL_VERSION MACRO */
42#define RADIO_VERSION KERNEL_VERSION(0,0,2) 41#define RADIO_VERSION KERNEL_VERSION(0,0,2)
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 9851987b95fb..dabafdf71e60 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -40,7 +40,6 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/i2c-id.h> 41#include <linux/i2c-id.h>
42#include <linux/workqueue.h> 42#include <linux/workqueue.h>
43#include <asm/semaphore.h>
44 43
45#include <media/ir-common.h> 44#include <media/ir-common.h>
46#include <media/ir-kbd-i2c.h> 45#include <media/ir-kbd-i2c.h>
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index d55d5800efb4..6590058e8ff0 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -41,7 +41,6 @@
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/ctype.h> 42#include <linux/ctype.h>
43#include <linux/pagemap.h> 43#include <linux/pagemap.h>
44#include <asm/semaphore.h>
45#include <asm/processor.h> 44#include <asm/processor.h>
46#include <linux/mm.h> 45#include <linux/mm.h>
47#include <linux/device.h> 46#include <linux/device.h>
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index 9d94aed2e12d..160437b21e6d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -26,7 +26,6 @@
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <asm/semaphore.h>
30 29
31 30
32static void pvr2_context_destroy(struct pvr2_context *mp) 31static void pvr2_context_destroy(struct pvr2_context *mp)
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index d6955fa39598..2404053a4d85 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -25,7 +25,6 @@
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <asm/semaphore.h>
29#include "pvrusb2.h" 28#include "pvrusb2.h"
30#include "pvrusb2-std.h" 29#include "pvrusb2-std.h"
31#include "pvrusb2-util.h" 30#include "pvrusb2-util.h"
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 7a1cd878e31a..07f4eae18433 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <asm/semaphore.h>
25#include "pvrusb2-sysfs.h" 24#include "pvrusb2-sysfs.h"
26#include "pvrusb2-hdw.h" 25#include "pvrusb2-hdw.h"
27#include "pvrusb2-debug.h" 26#include "pvrusb2-debug.h"
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index 946e3d3506ac..61b98c333cb0 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -177,16 +177,16 @@ static struct bus_type memstick_bus_type = {
177 .resume = memstick_device_resume 177 .resume = memstick_device_resume
178}; 178};
179 179
180static void memstick_free(struct class_device *cdev) 180static void memstick_free(struct device *dev)
181{ 181{
182 struct memstick_host *host = container_of(cdev, struct memstick_host, 182 struct memstick_host *host = container_of(dev, struct memstick_host,
183 cdev); 183 dev);
184 kfree(host); 184 kfree(host);
185} 185}
186 186
187static struct class memstick_host_class = { 187static struct class memstick_host_class = {
188 .name = "memstick_host", 188 .name = "memstick_host",
189 .release = memstick_free 189 .dev_release = memstick_free
190}; 190};
191 191
192static void memstick_free_card(struct device *dev) 192static void memstick_free_card(struct device *dev)
@@ -383,8 +383,8 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host)
383 if (card) { 383 if (card) {
384 card->host = host; 384 card->host = host;
385 snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), 385 snprintf(card->dev.bus_id, sizeof(card->dev.bus_id),
386 "%s", host->cdev.class_id); 386 "%s", host->dev.bus_id);
387 card->dev.parent = host->cdev.dev; 387 card->dev.parent = &host->dev;
388 card->dev.bus = &memstick_bus_type; 388 card->dev.bus = &memstick_bus_type;
389 card->dev.release = memstick_free_card; 389 card->dev.release = memstick_free_card;
390 card->check = memstick_dummy_check; 390 card->check = memstick_dummy_check;
@@ -427,7 +427,7 @@ static void memstick_check(struct work_struct *work)
427 media_checker); 427 media_checker);
428 struct memstick_dev *card; 428 struct memstick_dev *card;
429 429
430 dev_dbg(host->cdev.dev, "memstick_check started\n"); 430 dev_dbg(&host->dev, "memstick_check started\n");
431 mutex_lock(&host->lock); 431 mutex_lock(&host->lock);
432 if (!host->card) 432 if (!host->card)
433 memstick_power_on(host); 433 memstick_power_on(host);
@@ -440,7 +440,7 @@ static void memstick_check(struct work_struct *work)
440 host->card = NULL; 440 host->card = NULL;
441 } 441 }
442 } else { 442 } else {
443 dev_dbg(host->cdev.dev, "new card %02x, %02x, %02x\n", 443 dev_dbg(&host->dev, "new card %02x, %02x, %02x\n",
444 card->id.type, card->id.category, card->id.class); 444 card->id.type, card->id.category, card->id.class);
445 if (host->card) { 445 if (host->card) {
446 if (memstick_set_rw_addr(host->card) 446 if (memstick_set_rw_addr(host->card)
@@ -465,7 +465,7 @@ static void memstick_check(struct work_struct *work)
465 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); 465 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
466 466
467 mutex_unlock(&host->lock); 467 mutex_unlock(&host->lock);
468 dev_dbg(host->cdev.dev, "memstick_check finished\n"); 468 dev_dbg(&host->dev, "memstick_check finished\n");
469} 469}
470 470
471/** 471/**
@@ -482,9 +482,9 @@ struct memstick_host *memstick_alloc_host(unsigned int extra,
482 if (host) { 482 if (host) {
483 mutex_init(&host->lock); 483 mutex_init(&host->lock);
484 INIT_WORK(&host->media_checker, memstick_check); 484 INIT_WORK(&host->media_checker, memstick_check);
485 host->cdev.class = &memstick_host_class; 485 host->dev.class = &memstick_host_class;
486 host->cdev.dev = dev; 486 host->dev.parent = dev;
487 class_device_initialize(&host->cdev); 487 device_initialize(&host->dev);
488 } 488 }
489 return host; 489 return host;
490} 490}
@@ -507,10 +507,9 @@ int memstick_add_host(struct memstick_host *host)
507 if (rc) 507 if (rc)
508 return rc; 508 return rc;
509 509
510 snprintf(host->cdev.class_id, BUS_ID_SIZE, 510 snprintf(host->dev.bus_id, BUS_ID_SIZE, "memstick%u", host->id);
511 "memstick%u", host->id);
512 511
513 rc = class_device_add(&host->cdev); 512 rc = device_add(&host->dev);
514 if (rc) { 513 if (rc) {
515 spin_lock(&memstick_host_lock); 514 spin_lock(&memstick_host_lock);
516 idr_remove(&memstick_host_idr, host->id); 515 idr_remove(&memstick_host_idr, host->id);
@@ -541,7 +540,7 @@ void memstick_remove_host(struct memstick_host *host)
541 spin_lock(&memstick_host_lock); 540 spin_lock(&memstick_host_lock);
542 idr_remove(&memstick_host_idr, host->id); 541 idr_remove(&memstick_host_idr, host->id);
543 spin_unlock(&memstick_host_lock); 542 spin_unlock(&memstick_host_lock);
544 class_device_del(&host->cdev); 543 device_del(&host->dev);
545} 544}
546EXPORT_SYMBOL(memstick_remove_host); 545EXPORT_SYMBOL(memstick_remove_host);
547 546
@@ -552,7 +551,7 @@ EXPORT_SYMBOL(memstick_remove_host);
552void memstick_free_host(struct memstick_host *host) 551void memstick_free_host(struct memstick_host *host)
553{ 552{
554 mutex_destroy(&host->lock); 553 mutex_destroy(&host->lock);
555 class_device_put(&host->cdev); 554 put_device(&host->dev);
556} 555}
557EXPORT_SYMBOL(memstick_free_host); 556EXPORT_SYMBOL(memstick_free_host);
558 557
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 557dbbba5cb2..477d0fb6e588 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -1127,8 +1127,8 @@ static int mspro_block_init_disk(struct memstick_dev *card)
1127 u64 limit = BLK_BOUNCE_HIGH; 1127 u64 limit = BLK_BOUNCE_HIGH;
1128 unsigned long capacity; 1128 unsigned long capacity;
1129 1129
1130 if (host->cdev.dev->dma_mask && *(host->cdev.dev->dma_mask)) 1130 if (host->dev.dma_mask && *(host->dev.dma_mask))
1131 limit = *(host->cdev.dev->dma_mask); 1131 limit = *(host->dev.dma_mask);
1132 1132
1133 for (rc = 0; msb->attr_group.attrs[rc]; ++rc) { 1133 for (rc = 0; msb->attr_group.attrs[rc]; ++rc) {
1134 s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]); 1134 s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]);
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index 8770a5fac3b6..a054668eda16 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -361,15 +361,15 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
361 unsigned int data_len, cmd, t_val; 361 unsigned int data_len, cmd, t_val;
362 362
363 if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) { 363 if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) {
364 dev_dbg(msh->cdev.dev, "no media status\n"); 364 dev_dbg(&msh->dev, "no media status\n");
365 host->req->error = -ETIME; 365 host->req->error = -ETIME;
366 return host->req->error; 366 return host->req->error;
367 } 367 }
368 368
369 dev_dbg(msh->cdev.dev, "control %08x\n", 369 dev_dbg(&msh->dev, "control %08x\n",
370 readl(host->addr + HOST_CONTROL)); 370 readl(host->addr + HOST_CONTROL));
371 dev_dbg(msh->cdev.dev, "status %08x\n", readl(host->addr + INT_STATUS)); 371 dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS));
372 dev_dbg(msh->cdev.dev, "hstatus %08x\n", readl(host->addr + STATUS)); 372 dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS));
373 373
374 host->cmd_flags = 0; 374 host->cmd_flags = 0;
375 host->block_pos = 0; 375 host->block_pos = 0;
@@ -448,7 +448,7 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
448 host->req->error = 0; 448 host->req->error = 0;
449 449
450 writel(cmd, host->addr + TPC); 450 writel(cmd, host->addr + TPC);
451 dev_dbg(msh->cdev.dev, "executing TPC %08x, len %x\n", cmd, data_len); 451 dev_dbg(&msh->dev, "executing TPC %08x, len %x\n", cmd, data_len);
452 452
453 return 0; 453 return 0;
454} 454}
@@ -461,11 +461,11 @@ static void jmb38x_ms_complete_cmd(struct memstick_host *msh, int last)
461 461
462 del_timer(&host->timer); 462 del_timer(&host->timer);
463 463
464 dev_dbg(msh->cdev.dev, "c control %08x\n", 464 dev_dbg(&msh->dev, "c control %08x\n",
465 readl(host->addr + HOST_CONTROL)); 465 readl(host->addr + HOST_CONTROL));
466 dev_dbg(msh->cdev.dev, "c status %08x\n", 466 dev_dbg(&msh->dev, "c status %08x\n",
467 readl(host->addr + INT_STATUS)); 467 readl(host->addr + INT_STATUS));
468 dev_dbg(msh->cdev.dev, "c hstatus %08x\n", readl(host->addr + STATUS)); 468 dev_dbg(&msh->dev, "c hstatus %08x\n", readl(host->addr + STATUS));
469 469
470 host->req->int_reg = readl(host->addr + STATUS) & 0xff; 470 host->req->int_reg = readl(host->addr + STATUS) & 0xff;
471 471
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 89c63147a15d..b109bd8a4d19 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -3300,9 +3300,10 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
3300} 3300}
3301 3301
3302static ssize_t 3302static ssize_t
3303mptscsih_version_fw_show(struct class_device *cdev, char *buf) 3303mptscsih_version_fw_show(struct device *dev, struct device_attribute *attr,
3304 char *buf)
3304{ 3305{
3305 struct Scsi_Host *host = class_to_shost(cdev); 3306 struct Scsi_Host *host = class_to_shost(dev);
3306 MPT_SCSI_HOST *hd = shost_priv(host); 3307 MPT_SCSI_HOST *hd = shost_priv(host);
3307 MPT_ADAPTER *ioc = hd->ioc; 3308 MPT_ADAPTER *ioc = hd->ioc;
3308 3309
@@ -3312,12 +3313,13 @@ mptscsih_version_fw_show(struct class_device *cdev, char *buf)
3312 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, 3313 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
3313 ioc->facts.FWVersion.Word & 0x000000FF); 3314 ioc->facts.FWVersion.Word & 0x000000FF);
3314} 3315}
3315static CLASS_DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL); 3316static DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL);
3316 3317
3317static ssize_t 3318static ssize_t
3318mptscsih_version_bios_show(struct class_device *cdev, char *buf) 3319mptscsih_version_bios_show(struct device *dev, struct device_attribute *attr,
3320 char *buf)
3319{ 3321{
3320 struct Scsi_Host *host = class_to_shost(cdev); 3322 struct Scsi_Host *host = class_to_shost(dev);
3321 MPT_SCSI_HOST *hd = shost_priv(host); 3323 MPT_SCSI_HOST *hd = shost_priv(host);
3322 MPT_ADAPTER *ioc = hd->ioc; 3324 MPT_ADAPTER *ioc = hd->ioc;
3323 3325
@@ -3327,129 +3329,141 @@ mptscsih_version_bios_show(struct class_device *cdev, char *buf)
3327 (ioc->biosVersion & 0x0000FF00) >> 8, 3329 (ioc->biosVersion & 0x0000FF00) >> 8,
3328 ioc->biosVersion & 0x000000FF); 3330 ioc->biosVersion & 0x000000FF);
3329} 3331}
3330static CLASS_DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL); 3332static DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL);
3331 3333
3332static ssize_t 3334static ssize_t
3333mptscsih_version_mpi_show(struct class_device *cdev, char *buf) 3335mptscsih_version_mpi_show(struct device *dev, struct device_attribute *attr,
3336 char *buf)
3334{ 3337{
3335 struct Scsi_Host *host = class_to_shost(cdev); 3338 struct Scsi_Host *host = class_to_shost(dev);
3336 MPT_SCSI_HOST *hd = shost_priv(host); 3339 MPT_SCSI_HOST *hd = shost_priv(host);
3337 MPT_ADAPTER *ioc = hd->ioc; 3340 MPT_ADAPTER *ioc = hd->ioc;
3338 3341
3339 return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); 3342 return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion);
3340} 3343}
3341static CLASS_DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL); 3344static DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL);
3342 3345
3343static ssize_t 3346static ssize_t
3344mptscsih_version_product_show(struct class_device *cdev, char *buf) 3347mptscsih_version_product_show(struct device *dev,
3348 struct device_attribute *attr,
3349char *buf)
3345{ 3350{
3346 struct Scsi_Host *host = class_to_shost(cdev); 3351 struct Scsi_Host *host = class_to_shost(dev);
3347 MPT_SCSI_HOST *hd = shost_priv(host); 3352 MPT_SCSI_HOST *hd = shost_priv(host);
3348 MPT_ADAPTER *ioc = hd->ioc; 3353 MPT_ADAPTER *ioc = hd->ioc;
3349 3354
3350 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); 3355 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name);
3351} 3356}
3352static CLASS_DEVICE_ATTR(version_product, S_IRUGO, 3357static DEVICE_ATTR(version_product, S_IRUGO,
3353 mptscsih_version_product_show, NULL); 3358 mptscsih_version_product_show, NULL);
3354 3359
3355static ssize_t 3360static ssize_t
3356mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf) 3361mptscsih_version_nvdata_persistent_show(struct device *dev,
3362 struct device_attribute *attr,
3363 char *buf)
3357{ 3364{
3358 struct Scsi_Host *host = class_to_shost(cdev); 3365 struct Scsi_Host *host = class_to_shost(dev);
3359 MPT_SCSI_HOST *hd = shost_priv(host); 3366 MPT_SCSI_HOST *hd = shost_priv(host);
3360 MPT_ADAPTER *ioc = hd->ioc; 3367 MPT_ADAPTER *ioc = hd->ioc;
3361 3368
3362 return snprintf(buf, PAGE_SIZE, "%02xh\n", 3369 return snprintf(buf, PAGE_SIZE, "%02xh\n",
3363 ioc->nvdata_version_persistent); 3370 ioc->nvdata_version_persistent);
3364} 3371}
3365static CLASS_DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, 3372static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO,
3366 mptscsih_version_nvdata_persistent_show, NULL); 3373 mptscsih_version_nvdata_persistent_show, NULL);
3367 3374
3368static ssize_t 3375static ssize_t
3369mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf) 3376mptscsih_version_nvdata_default_show(struct device *dev,
3377 struct device_attribute *attr, char *buf)
3370{ 3378{
3371 struct Scsi_Host *host = class_to_shost(cdev); 3379 struct Scsi_Host *host = class_to_shost(dev);
3372 MPT_SCSI_HOST *hd = shost_priv(host); 3380 MPT_SCSI_HOST *hd = shost_priv(host);
3373 MPT_ADAPTER *ioc = hd->ioc; 3381 MPT_ADAPTER *ioc = hd->ioc;
3374 3382
3375 return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); 3383 return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default);
3376} 3384}
3377static CLASS_DEVICE_ATTR(version_nvdata_default, S_IRUGO, 3385static DEVICE_ATTR(version_nvdata_default, S_IRUGO,
3378 mptscsih_version_nvdata_default_show, NULL); 3386 mptscsih_version_nvdata_default_show, NULL);
3379 3387
3380static ssize_t 3388static ssize_t
3381mptscsih_board_name_show(struct class_device *cdev, char *buf) 3389mptscsih_board_name_show(struct device *dev, struct device_attribute *attr,
3390 char *buf)
3382{ 3391{
3383 struct Scsi_Host *host = class_to_shost(cdev); 3392 struct Scsi_Host *host = class_to_shost(dev);
3384 MPT_SCSI_HOST *hd = shost_priv(host); 3393 MPT_SCSI_HOST *hd = shost_priv(host);
3385 MPT_ADAPTER *ioc = hd->ioc; 3394 MPT_ADAPTER *ioc = hd->ioc;
3386 3395
3387 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); 3396 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name);
3388} 3397}
3389static CLASS_DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL); 3398static DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL);
3390 3399
3391static ssize_t 3400static ssize_t
3392mptscsih_board_assembly_show(struct class_device *cdev, char *buf) 3401mptscsih_board_assembly_show(struct device *dev,
3402 struct device_attribute *attr, char *buf)
3393{ 3403{
3394 struct Scsi_Host *host = class_to_shost(cdev); 3404 struct Scsi_Host *host = class_to_shost(dev);
3395 MPT_SCSI_HOST *hd = shost_priv(host); 3405 MPT_SCSI_HOST *hd = shost_priv(host);
3396 MPT_ADAPTER *ioc = hd->ioc; 3406 MPT_ADAPTER *ioc = hd->ioc;
3397 3407
3398 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); 3408 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly);
3399} 3409}
3400static CLASS_DEVICE_ATTR(board_assembly, S_IRUGO, 3410static DEVICE_ATTR(board_assembly, S_IRUGO,
3401 mptscsih_board_assembly_show, NULL); 3411 mptscsih_board_assembly_show, NULL);
3402 3412
3403static ssize_t 3413static ssize_t
3404mptscsih_board_tracer_show(struct class_device *cdev, char *buf) 3414mptscsih_board_tracer_show(struct device *dev, struct device_attribute *attr,
3415 char *buf)
3405{ 3416{
3406 struct Scsi_Host *host = class_to_shost(cdev); 3417 struct Scsi_Host *host = class_to_shost(dev);
3407 MPT_SCSI_HOST *hd = shost_priv(host); 3418 MPT_SCSI_HOST *hd = shost_priv(host);
3408 MPT_ADAPTER *ioc = hd->ioc; 3419 MPT_ADAPTER *ioc = hd->ioc;
3409 3420
3410 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); 3421 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer);
3411} 3422}
3412static CLASS_DEVICE_ATTR(board_tracer, S_IRUGO, 3423static DEVICE_ATTR(board_tracer, S_IRUGO,
3413 mptscsih_board_tracer_show, NULL); 3424 mptscsih_board_tracer_show, NULL);
3414 3425
3415static ssize_t 3426static ssize_t
3416mptscsih_io_delay_show(struct class_device *cdev, char *buf) 3427mptscsih_io_delay_show(struct device *dev, struct device_attribute *attr,
3428 char *buf)
3417{ 3429{
3418 struct Scsi_Host *host = class_to_shost(cdev); 3430 struct Scsi_Host *host = class_to_shost(dev);
3419 MPT_SCSI_HOST *hd = shost_priv(host); 3431 MPT_SCSI_HOST *hd = shost_priv(host);
3420 MPT_ADAPTER *ioc = hd->ioc; 3432 MPT_ADAPTER *ioc = hd->ioc;
3421 3433
3422 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); 3434 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
3423} 3435}
3424static CLASS_DEVICE_ATTR(io_delay, S_IRUGO, 3436static DEVICE_ATTR(io_delay, S_IRUGO,
3425 mptscsih_io_delay_show, NULL); 3437 mptscsih_io_delay_show, NULL);
3426 3438
3427static ssize_t 3439static ssize_t
3428mptscsih_device_delay_show(struct class_device *cdev, char *buf) 3440mptscsih_device_delay_show(struct device *dev, struct device_attribute *attr,
3441 char *buf)
3429{ 3442{
3430 struct Scsi_Host *host = class_to_shost(cdev); 3443 struct Scsi_Host *host = class_to_shost(dev);
3431 MPT_SCSI_HOST *hd = shost_priv(host); 3444 MPT_SCSI_HOST *hd = shost_priv(host);
3432 MPT_ADAPTER *ioc = hd->ioc; 3445 MPT_ADAPTER *ioc = hd->ioc;
3433 3446
3434 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); 3447 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
3435} 3448}
3436static CLASS_DEVICE_ATTR(device_delay, S_IRUGO, 3449static DEVICE_ATTR(device_delay, S_IRUGO,
3437 mptscsih_device_delay_show, NULL); 3450 mptscsih_device_delay_show, NULL);
3438 3451
3439static ssize_t 3452static ssize_t
3440mptscsih_debug_level_show(struct class_device *cdev, char *buf) 3453mptscsih_debug_level_show(struct device *dev, struct device_attribute *attr,
3454 char *buf)
3441{ 3455{
3442 struct Scsi_Host *host = class_to_shost(cdev); 3456 struct Scsi_Host *host = class_to_shost(dev);
3443 MPT_SCSI_HOST *hd = shost_priv(host); 3457 MPT_SCSI_HOST *hd = shost_priv(host);
3444 MPT_ADAPTER *ioc = hd->ioc; 3458 MPT_ADAPTER *ioc = hd->ioc;
3445 3459
3446 return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); 3460 return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level);
3447} 3461}
3448static ssize_t 3462static ssize_t
3449mptscsih_debug_level_store(struct class_device *cdev, const char *buf, 3463mptscsih_debug_level_store(struct device *dev, struct device_attribute *attr,
3450 size_t count) 3464 const char *buf, size_t count)
3451{ 3465{
3452 struct Scsi_Host *host = class_to_shost(cdev); 3466 struct Scsi_Host *host = class_to_shost(dev);
3453 MPT_SCSI_HOST *hd = shost_priv(host); 3467 MPT_SCSI_HOST *hd = shost_priv(host);
3454 MPT_ADAPTER *ioc = hd->ioc; 3468 MPT_ADAPTER *ioc = hd->ioc;
3455 int val = 0; 3469 int val = 0;
@@ -3462,22 +3476,22 @@ mptscsih_debug_level_store(struct class_device *cdev, const char *buf,
3462 ioc->name, ioc->debug_level); 3476 ioc->name, ioc->debug_level);
3463 return strlen(buf); 3477 return strlen(buf);
3464} 3478}
3465static CLASS_DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR, 3479static DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR,
3466 mptscsih_debug_level_show, mptscsih_debug_level_store); 3480 mptscsih_debug_level_show, mptscsih_debug_level_store);
3467 3481
3468struct class_device_attribute *mptscsih_host_attrs[] = { 3482struct device_attribute *mptscsih_host_attrs[] = {
3469 &class_device_attr_version_fw, 3483 &dev_attr_version_fw,
3470 &class_device_attr_version_bios, 3484 &dev_attr_version_bios,
3471 &class_device_attr_version_mpi, 3485 &dev_attr_version_mpi,
3472 &class_device_attr_version_product, 3486 &dev_attr_version_product,
3473 &class_device_attr_version_nvdata_persistent, 3487 &dev_attr_version_nvdata_persistent,
3474 &class_device_attr_version_nvdata_default, 3488 &dev_attr_version_nvdata_default,
3475 &class_device_attr_board_name, 3489 &dev_attr_board_name,
3476 &class_device_attr_board_assembly, 3490 &dev_attr_board_assembly,
3477 &class_device_attr_board_tracer, 3491 &dev_attr_board_tracer,
3478 &class_device_attr_io_delay, 3492 &dev_attr_io_delay,
3479 &class_device_attr_device_delay, 3493 &dev_attr_device_delay,
3480 &class_device_attr_debug_level, 3494 &dev_attr_debug_level,
3481 NULL, 3495 NULL,
3482}; 3496};
3483EXPORT_SYMBOL(mptscsih_host_attrs); 3497EXPORT_SYMBOL(mptscsih_host_attrs);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index d289e97cfe8b..7ea7da0e090c 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -129,4 +129,4 @@ extern void mptscsih_timer_expired(unsigned long data);
129extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); 129extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout);
130extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id); 130extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id);
131extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id); 131extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id);
132extern struct class_device_attribute *mptscsih_host_attrs[]; 132extern struct device_attribute *mptscsih_host_attrs[];
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 0c886c882385..2566479937c9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -22,6 +22,22 @@ config MFD_ASIC3
22 This driver supports the ASIC3 multifunction chip found on many 22 This driver supports the ASIC3 multifunction chip found on many
23 PDAs (mainly iPAQ and HTC based ones) 23 PDAs (mainly iPAQ and HTC based ones)
24 24
25config HTC_EGPIO
26 bool "HTC EGPIO support"
27 depends on GENERIC_HARDIRQS && HAVE_GPIO_LIB
28 help
29 This driver supports the CPLD egpio chip present on
30 several HTC phones. It provides basic support for input
31 pins, output pins, and irqs.
32
33config HTC_PASIC3
34 tristate "HTC PASIC3 LED/DS1WM chip support"
35 help
36 This core driver provides register access for the LED/DS1WM
37 chips labeled "AIC2" and "AIC3", found on HTC Blueangel and
38 HTC Magician devices, respectively. Actual functionality is
39 handled by the leds-pasic3 and ds1wm drivers.
40
25endmenu 41endmenu
26 42
27menu "Multimedia Capabilities Port drivers" 43menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 521cd5cb68af..eef4e26807df 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -5,6 +5,9 @@
5obj-$(CONFIG_MFD_SM501) += sm501.o 5obj-$(CONFIG_MFD_SM501) += sm501.o
6obj-$(CONFIG_MFD_ASIC3) += asic3.o 6obj-$(CONFIG_MFD_ASIC3) += asic3.o
7 7
8obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o
9obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o
10
8obj-$(CONFIG_MCP) += mcp-core.o 11obj-$(CONFIG_MCP) += mcp-core.o
9obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o 12obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o
10obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o 13obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c
new file mode 100644
index 000000000000..8872cc077519
--- /dev/null
+++ b/drivers/mfd/htc-egpio.c
@@ -0,0 +1,440 @@
1/*
2 * Support for the GPIO/IRQ expander chips present on several HTC phones.
3 * These are implemented in CPLD chips present on the board.
4 *
5 * Copyright (c) 2007 Kevin O'Connor <kevin@koconnor.net>
6 * Copyright (c) 2007 Philipp Zabel <philipp.zabel@gmail.com>
7 *
8 * This file may be distributed under the terms of the GNU GPL license.
9 */
10
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/interrupt.h>
14#include <linux/irq.h>
15#include <linux/io.h>
16#include <linux/spinlock.h>
17#include <linux/platform_device.h>
18#include <linux/module.h>
19#include <linux/mfd/htc-egpio.h>
20
21struct egpio_chip {
22 int reg_start;
23 int cached_values;
24 unsigned long is_out;
25 struct device *dev;
26 struct gpio_chip chip;
27};
28
29struct egpio_info {
30 spinlock_t lock;
31
32 /* iomem info */
33 void __iomem *base_addr;
34 int bus_shift; /* byte shift */
35 int reg_shift; /* bit shift */
36 int reg_mask;
37
38 /* irq info */
39 int ack_register;
40 int ack_write;
41 u16 irqs_enabled;
42 uint irq_start;
43 int nirqs;
44 uint chained_irq;
45
46 /* egpio info */
47 struct egpio_chip *chip;
48 int nchips;
49};
50
51static inline void egpio_writew(u16 value, struct egpio_info *ei, int reg)
52{
53 writew(value, ei->base_addr + (reg << ei->bus_shift));
54}
55
56static inline u16 egpio_readw(struct egpio_info *ei, int reg)
57{
58 return readw(ei->base_addr + (reg << ei->bus_shift));
59}
60
61/*
62 * IRQs
63 */
64
65static inline void ack_irqs(struct egpio_info *ei)
66{
67 egpio_writew(ei->ack_write, ei, ei->ack_register);
68 pr_debug("EGPIO ack - write %x to base+%x\n",
69 ei->ack_write, ei->ack_register << ei->bus_shift);
70}
71
72static void egpio_ack(unsigned int irq)
73{
74}
75
76/* There does not appear to be a way to proactively mask interrupts
77 * on the egpio chip itself. So, we simply ignore interrupts that
78 * aren't desired. */
79static void egpio_mask(unsigned int irq)
80{
81 struct egpio_info *ei = get_irq_chip_data(irq);
82 ei->irqs_enabled &= ~(1 << (irq - ei->irq_start));
83 pr_debug("EGPIO mask %d %04x\n", irq, ei->irqs_enabled);
84}
85static void egpio_unmask(unsigned int irq)
86{
87 struct egpio_info *ei = get_irq_chip_data(irq);
88 ei->irqs_enabled |= 1 << (irq - ei->irq_start);
89 pr_debug("EGPIO unmask %d %04x\n", irq, ei->irqs_enabled);
90}
91
92static struct irq_chip egpio_muxed_chip = {
93 .name = "htc-egpio",
94 .ack = egpio_ack,
95 .mask = egpio_mask,
96 .unmask = egpio_unmask,
97};
98
99static void egpio_handler(unsigned int irq, struct irq_desc *desc)
100{
101 struct egpio_info *ei = get_irq_data(irq);
102 int irqpin;
103
104 /* Read current pins. */
105 unsigned long readval = egpio_readw(ei, ei->ack_register);
106 pr_debug("IRQ reg: %x\n", (unsigned int)readval);
107 /* Ack/unmask interrupts. */
108 ack_irqs(ei);
109 /* Process all set pins. */
110 readval &= ei->irqs_enabled;
111 for_each_bit(irqpin, &readval, ei->nirqs) {
112 /* Run irq handler */
113 pr_debug("got IRQ %d\n", irqpin);
114 irq = ei->irq_start + irqpin;
115 desc = &irq_desc[irq];
116 desc->handle_irq(irq, desc);
117 }
118}
119
120int htc_egpio_get_wakeup_irq(struct device *dev)
121{
122 struct egpio_info *ei = dev_get_drvdata(dev);
123
124 /* Read current pins. */
125 u16 readval = egpio_readw(ei, ei->ack_register);
126 /* Ack/unmask interrupts. */
127 ack_irqs(ei);
128 /* Return first set pin. */
129 readval &= ei->irqs_enabled;
130 return ei->irq_start + ffs(readval) - 1;
131}
132EXPORT_SYMBOL(htc_egpio_get_wakeup_irq);
133
134static inline int egpio_pos(struct egpio_info *ei, int bit)
135{
136 return bit >> ei->reg_shift;
137}
138
139static inline int egpio_bit(struct egpio_info *ei, int bit)
140{
141 return 1 << (bit & ((1 << ei->reg_shift)-1));
142}
143
144/*
145 * Input pins
146 */
147
148static int egpio_get(struct gpio_chip *chip, unsigned offset)
149{
150 struct egpio_chip *egpio;
151 struct egpio_info *ei;
152 unsigned bit;
153 int reg;
154 int value;
155
156 pr_debug("egpio_get_value(%d)\n", chip->base + offset);
157
158 egpio = container_of(chip, struct egpio_chip, chip);
159 ei = dev_get_drvdata(egpio->dev);
160 bit = egpio_bit(ei, offset);
161 reg = egpio->reg_start + egpio_pos(ei, offset);
162
163 value = egpio_readw(ei, reg);
164 pr_debug("readw(%p + %x) = %x\n",
165 ei->base_addr, reg << ei->bus_shift, value);
166 return value & bit;
167}
168
169static int egpio_direction_input(struct gpio_chip *chip, unsigned offset)
170{
171 struct egpio_chip *egpio;
172
173 egpio = container_of(chip, struct egpio_chip, chip);
174 return test_bit(offset, &egpio->is_out) ? -EINVAL : 0;
175}
176
177
178/*
179 * Output pins
180 */
181
182static void egpio_set(struct gpio_chip *chip, unsigned offset, int value)
183{
184 unsigned long flag;
185 struct egpio_chip *egpio;
186 struct egpio_info *ei;
187 unsigned bit;
188 int pos;
189 int reg;
190 int shift;
191
192 pr_debug("egpio_set(%s, %d(%d), %d)\n",
193 chip->label, offset, offset+chip->base, value);
194
195 egpio = container_of(chip, struct egpio_chip, chip);
196 ei = dev_get_drvdata(egpio->dev);
197 bit = egpio_bit(ei, offset);
198 pos = egpio_pos(ei, offset);
199 reg = egpio->reg_start + pos;
200 shift = pos << ei->reg_shift;
201
202 pr_debug("egpio %s: reg %d = 0x%04x\n", value ? "set" : "clear",
203 reg, (egpio->cached_values >> shift) & ei->reg_mask);
204
205 spin_lock_irqsave(&ei->lock, flag);
206 if (value)
207 egpio->cached_values |= (1 << offset);
208 else
209 egpio->cached_values &= ~(1 << offset);
210 egpio_writew((egpio->cached_values >> shift) & ei->reg_mask, ei, reg);
211 spin_unlock_irqrestore(&ei->lock, flag);
212}
213
214static int egpio_direction_output(struct gpio_chip *chip,
215 unsigned offset, int value)
216{
217 struct egpio_chip *egpio;
218
219 egpio = container_of(chip, struct egpio_chip, chip);
220 if (test_bit(offset, &egpio->is_out)) {
221 egpio_set(chip, offset, value);
222 return 0;
223 } else {
224 return -EINVAL;
225 }
226}
227
228static void egpio_write_cache(struct egpio_info *ei)
229{
230 int i;
231 struct egpio_chip *egpio;
232 int shift;
233
234 for (i = 0; i < ei->nchips; i++) {
235 egpio = &(ei->chip[i]);
236 if (!egpio->is_out)
237 continue;
238
239 for (shift = 0; shift < egpio->chip.ngpio;
240 shift += (1<<ei->reg_shift)) {
241
242 int reg = egpio->reg_start + egpio_pos(ei, shift);
243
244 if (!((egpio->is_out >> shift) & ei->reg_mask))
245 continue;
246
247 pr_debug("EGPIO: setting %x to %x, was %x\n", reg,
248 (egpio->cached_values >> shift) & ei->reg_mask,
249 egpio_readw(ei, reg));
250
251 egpio_writew((egpio->cached_values >> shift)
252 & ei->reg_mask, ei, reg);
253 }
254 }
255}
256
257
258/*
259 * Setup
260 */
261
262static int __init egpio_probe(struct platform_device *pdev)
263{
264 struct htc_egpio_platform_data *pdata = pdev->dev.platform_data;
265 struct resource *res;
266 struct egpio_info *ei;
267 struct gpio_chip *chip;
268 unsigned int irq, irq_end;
269 int i;
270 int ret;
271
272 /* Initialize ei data structure. */
273 ei = kzalloc(sizeof(*ei), GFP_KERNEL);
274 if (!ei)
275 return -ENOMEM;
276
277 spin_lock_init(&ei->lock);
278
279 /* Find chained irq */
280 ret = -EINVAL;
281 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
282 if (res)
283 ei->chained_irq = res->start;
284
285 /* Map egpio chip into virtual address space. */
286 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
287 if (!res)
288 goto fail;
289 ei->base_addr = ioremap_nocache(res->start, res->end - res->start);
290 if (!ei->base_addr)
291 goto fail;
292 pr_debug("EGPIO phys=%08x virt=%p\n", res->start, ei->base_addr);
293
294 if ((pdata->bus_width != 16) && (pdata->bus_width != 32))
295 goto fail;
296 ei->bus_shift = fls(pdata->bus_width - 1) - 3;
297 pr_debug("bus_shift = %d\n", ei->bus_shift);
298
299 if ((pdata->reg_width != 8) && (pdata->reg_width != 16))
300 goto fail;
301 ei->reg_shift = fls(pdata->reg_width - 1);
302 pr_debug("reg_shift = %d\n", ei->reg_shift);
303
304 ei->reg_mask = (1 << pdata->reg_width) - 1;
305
306 platform_set_drvdata(pdev, ei);
307
308 ei->nchips = pdata->num_chips;
309 ei->chip = kzalloc(sizeof(struct egpio_chip) * ei->nchips, GFP_KERNEL);
310 if (!ei) {
311 ret = -ENOMEM;
312 goto fail;
313 }
314 for (i = 0; i < ei->nchips; i++) {
315 ei->chip[i].reg_start = pdata->chip[i].reg_start;
316 ei->chip[i].cached_values = pdata->chip[i].initial_values;
317 ei->chip[i].is_out = pdata->chip[i].direction;
318 ei->chip[i].dev = &(pdev->dev);
319 chip = &(ei->chip[i].chip);
320 chip->label = "htc-egpio";
321 chip->get = egpio_get;
322 chip->set = egpio_set;
323 chip->direction_input = egpio_direction_input;
324 chip->direction_output = egpio_direction_output;
325 chip->base = pdata->chip[i].gpio_base;
326 chip->ngpio = pdata->chip[i].num_gpios;
327
328 gpiochip_add(chip);
329 }
330
331 /* Set initial pin values */
332 egpio_write_cache(ei);
333
334 ei->irq_start = pdata->irq_base;
335 ei->nirqs = pdata->num_irqs;
336 ei->ack_register = pdata->ack_register;
337
338 if (ei->chained_irq) {
339 /* Setup irq handlers */
340 ei->ack_write = 0xFFFF;
341 if (pdata->invert_acks)
342 ei->ack_write = 0;
343 irq_end = ei->irq_start + ei->nirqs;
344 for (irq = ei->irq_start; irq < irq_end; irq++) {
345 set_irq_chip(irq, &egpio_muxed_chip);
346 set_irq_chip_data(irq, ei);
347 set_irq_handler(irq, handle_simple_irq);
348 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
349 }
350 set_irq_type(ei->chained_irq, IRQ_TYPE_EDGE_RISING);
351 set_irq_data(ei->chained_irq, ei);
352 set_irq_chained_handler(ei->chained_irq, egpio_handler);
353 ack_irqs(ei);
354
355 device_init_wakeup(&pdev->dev, 1);
356 }
357
358 return 0;
359
360fail:
361 printk(KERN_ERR "EGPIO failed to setup\n");
362 kfree(ei);
363 return ret;
364}
365
366static int __exit egpio_remove(struct platform_device *pdev)
367{
368 struct egpio_info *ei = platform_get_drvdata(pdev);
369 unsigned int irq, irq_end;
370
371 if (ei->chained_irq) {
372 irq_end = ei->irq_start + ei->nirqs;
373 for (irq = ei->irq_start; irq < irq_end; irq++) {
374 set_irq_chip(irq, NULL);
375 set_irq_handler(irq, NULL);
376 set_irq_flags(irq, 0);
377 }
378 set_irq_chained_handler(ei->chained_irq, NULL);
379 device_init_wakeup(&pdev->dev, 0);
380 }
381 iounmap(ei->base_addr);
382 kfree(ei->chip);
383 kfree(ei);
384
385 return 0;
386}
387
388#ifdef CONFIG_PM
389static int egpio_suspend(struct platform_device *pdev, pm_message_t state)
390{
391 struct egpio_info *ei = platform_get_drvdata(pdev);
392
393 if (ei->chained_irq && device_may_wakeup(&pdev->dev))
394 enable_irq_wake(ei->chained_irq);
395 return 0;
396}
397
398static int egpio_resume(struct platform_device *pdev)
399{
400 struct egpio_info *ei = platform_get_drvdata(pdev);
401
402 if (ei->chained_irq && device_may_wakeup(&pdev->dev))
403 disable_irq_wake(ei->chained_irq);
404
405 /* Update registers from the cache, in case
406 the CPLD was powered off during suspend */
407 egpio_write_cache(ei);
408 return 0;
409}
410#else
411#define egpio_suspend NULL
412#define egpio_resume NULL
413#endif
414
415
416static struct platform_driver egpio_driver = {
417 .driver = {
418 .name = "htc-egpio",
419 },
420 .remove = __exit_p(egpio_remove),
421 .suspend = egpio_suspend,
422 .resume = egpio_resume,
423};
424
425static int __init egpio_init(void)
426{
427 return platform_driver_probe(&egpio_driver, egpio_probe);
428}
429
430static void __exit egpio_exit(void)
431{
432 platform_driver_unregister(&egpio_driver);
433}
434
435/* start early for dependencies */
436subsys_initcall(egpio_init);
437module_exit(egpio_exit)
438
439MODULE_LICENSE("GPL");
440MODULE_AUTHOR("Kevin O'Connor <kevin@koconnor.net>");
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
new file mode 100644
index 000000000000..af66f4f28300
--- /dev/null
+++ b/drivers/mfd/htc-pasic3.c
@@ -0,0 +1,265 @@
1/*
2 * Core driver for HTC PASIC3 LED/DS1WM chip.
3 *
4 * Copyright (C) 2006 Philipp Zabel <philipp.zabel@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 */
10
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/platform_device.h>
14
15#include <linux/ds1wm.h>
16#include <linux/gpio.h>
17#include <linux/io.h>
18#include <linux/irq.h>
19#include <linux/interrupt.h>
20#include <linux/mfd/htc-pasic3.h>
21
22#include <asm/arch/pxa-regs.h>
23
24struct pasic3_data {
25 void __iomem *mapping;
26 unsigned int bus_shift;
27 struct platform_device *ds1wm_pdev;
28 struct platform_device *led_pdev;
29};
30
31#define REG_ADDR 5
32#define REG_DATA 6
33#define NUM_REGS 7
34
35#define READ_MODE 0x80
36
37/*
38 * write to a secondary register on the PASIC3
39 */
40void pasic3_write_register(struct device *dev, u32 reg, u8 val)
41{
42 struct pasic3_data *asic = dev->driver_data;
43 int bus_shift = asic->bus_shift;
44 void __iomem *addr = asic->mapping + (REG_ADDR << bus_shift);
45 void __iomem *data = asic->mapping + (REG_DATA << bus_shift);
46
47 __raw_writeb(~READ_MODE & reg, addr);
48 __raw_writeb(val, data);
49}
50EXPORT_SYMBOL(pasic3_write_register); /* for leds-pasic3 */
51
52/*
53 * read from a secondary register on the PASIC3
54 */
55u8 pasic3_read_register(struct device *dev, u32 reg)
56{
57 struct pasic3_data *asic = dev->driver_data;
58 int bus_shift = asic->bus_shift;
59 void __iomem *addr = asic->mapping + (REG_ADDR << bus_shift);
60 void __iomem *data = asic->mapping + (REG_DATA << bus_shift);
61
62 __raw_writeb(READ_MODE | reg, addr);
63 return __raw_readb(data);
64}
65EXPORT_SYMBOL(pasic3_read_register); /* for leds-pasic3 */
66
67/*
68 * LEDs
69 */
70
71static int led_device_add(struct device *pasic3_dev,
72 const struct pasic3_leds_machinfo *pdata)
73{
74 struct pasic3_data *asic = pasic3_dev->driver_data;
75 struct platform_device *pdev;
76 int ret;
77
78 pdev = platform_device_alloc("pasic3-led", -1);
79 if (!pdev) {
80 dev_dbg(pasic3_dev, "failed to allocate LED platform device\n");
81 return -ENOMEM;
82 }
83
84 ret = platform_device_add_data(pdev, pdata,
85 sizeof(struct pasic3_leds_machinfo));
86 if (ret < 0) {
87 dev_dbg(pasic3_dev, "failed to add LED platform data\n");
88 goto exit_pdev_put;
89 }
90
91 pdev->dev.parent = pasic3_dev;
92 ret = platform_device_add(pdev);
93 if (ret < 0) {
94 dev_dbg(pasic3_dev, "failed to add LED platform device\n");
95 goto exit_pdev_put;
96 }
97
98 asic->led_pdev = pdev;
99 return 0;
100
101exit_pdev_put:
102 platform_device_put(pdev);
103 return ret;
104}
105
106/*
107 * DS1WM
108 */
109
110static void ds1wm_enable(struct platform_device *pdev)
111{
112 struct device *dev = pdev->dev.parent;
113 int c;
114
115 c = pasic3_read_register(dev, 0x28);
116 pasic3_write_register(dev, 0x28, c & 0x7f);
117
118 dev_dbg(dev, "DS1WM OWM_EN low (active) %02x\n", c & 0x7f);
119}
120
121static void ds1wm_disable(struct platform_device *pdev)
122{
123 struct device *dev = pdev->dev.parent;
124 int c;
125
126 c = pasic3_read_register(dev, 0x28);
127 pasic3_write_register(dev, 0x28, c | 0x80);
128
129 dev_dbg(dev, "DS1WM OWM_EN high (inactive) %02x\n", c | 0x80);
130}
131
132static struct ds1wm_platform_data ds1wm_pdata = {
133 .bus_shift = 2,
134 .enable = ds1wm_enable,
135 .disable = ds1wm_disable,
136};
137
138static int ds1wm_device_add(struct device *pasic3_dev, int bus_shift)
139{
140 struct pasic3_data *asic = pasic3_dev->driver_data;
141 struct platform_device *pdev;
142 int ret;
143
144 pdev = platform_device_alloc("ds1wm", -1);
145 if (!pdev) {
146 dev_dbg(pasic3_dev, "failed to allocate DS1WM platform device\n");
147 return -ENOMEM;
148 }
149
150 ret = platform_device_add_resources(pdev, pdev->resource,
151 pdev->num_resources);
152 if (ret < 0) {
153 dev_dbg(pasic3_dev, "failed to add DS1WM resources\n");
154 goto exit_pdev_put;
155 }
156
157 ds1wm_pdata.bus_shift = asic->bus_shift;
158 ret = platform_device_add_data(pdev, &ds1wm_pdata,
159 sizeof(struct ds1wm_platform_data));
160 if (ret < 0) {
161 dev_dbg(pasic3_dev, "failed to add DS1WM platform data\n");
162 goto exit_pdev_put;
163 }
164
165 pdev->dev.parent = pasic3_dev;
166 ret = platform_device_add(pdev);
167 if (ret < 0) {
168 dev_dbg(pasic3_dev, "failed to add DS1WM platform device\n");
169 goto exit_pdev_put;
170 }
171
172 asic->ds1wm_pdev = pdev;
173 return 0;
174
175exit_pdev_put:
176 platform_device_put(pdev);
177 return ret;
178}
179
180static int __init pasic3_probe(struct platform_device *pdev)
181{
182 struct pasic3_platform_data *pdata = pdev->dev.platform_data;
183 struct device *dev = &pdev->dev;
184 struct pasic3_data *asic;
185 struct resource *r;
186 int ret;
187
188 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
189 if (!r)
190 return -ENXIO;
191
192 if (!request_mem_region(r->start, r->end - r->start + 1, "pasic3"))
193 return -EBUSY;
194
195 asic = kzalloc(sizeof(struct pasic3_data), GFP_KERNEL);
196 if (!asic)
197 return -ENOMEM;
198
199 platform_set_drvdata(pdev, asic);
200
201 if (pdata && pdata->bus_shift)
202 asic->bus_shift = pdata->bus_shift;
203 else
204 asic->bus_shift = 2;
205
206 asic->mapping = ioremap(r->start, r->end - r->start + 1);
207 if (!asic->mapping) {
208 dev_err(dev, "couldn't ioremap PASIC3\n");
209 kfree(asic);
210 return -ENOMEM;
211 }
212
213 ret = ds1wm_device_add(dev, asic->bus_shift);
214 if (ret < 0)
215 dev_warn(dev, "failed to register DS1WM\n");
216
217 if (pdata->led_pdata) {
218 ret = led_device_add(dev, pdata->led_pdata);
219 if (ret < 0)
220 dev_warn(dev, "failed to register LED device\n");
221 }
222
223 return 0;
224}
225
226static int pasic3_remove(struct platform_device *pdev)
227{
228 struct pasic3_data *asic = platform_get_drvdata(pdev);
229 struct resource *r;
230
231 if (asic->led_pdev)
232 platform_device_unregister(asic->led_pdev);
233 if (asic->ds1wm_pdev)
234 platform_device_unregister(asic->ds1wm_pdev);
235
236 iounmap(asic->mapping);
237 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
238 release_mem_region(r->start, r->end - r->start + 1);
239 kfree(asic);
240 return 0;
241}
242
243static struct platform_driver pasic3_driver = {
244 .driver = {
245 .name = "pasic3",
246 },
247 .remove = pasic3_remove,
248};
249
250static int __init pasic3_base_init(void)
251{
252 return platform_driver_probe(&pasic3_driver, pasic3_probe);
253}
254
255static void __exit pasic3_base_exit(void)
256{
257 platform_driver_unregister(&pasic3_driver);
258}
259
260module_init(pasic3_base_init);
261module_exit(pasic3_base_exit);
262
263MODULE_AUTHOR("Philipp Zabel <philipp.zabel@gmail.com>");
264MODULE_DESCRIPTION("Core driver for HTC PASIC3");
265MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index fdbaa776f249..5e859486eaf8 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -32,7 +32,6 @@
32#include <linux/kthread.h> 32#include <linux/kthread.h>
33 33
34#include <asm/dma.h> 34#include <asm/dma.h>
35#include <asm/semaphore.h>
36#include <asm/arch/collie.h> 35#include <asm/arch/collie.h>
37#include <asm/mach-types.h> 36#include <asm/mach-types.h>
38 37
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 962817e49fba..bb94ce78a6d0 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -22,6 +22,39 @@ config ATMEL_PWM
22 purposes including software controlled power-efficent backlights 22 purposes including software controlled power-efficent backlights
23 on LCD displays, motor control, and waveform generation. 23 on LCD displays, motor control, and waveform generation.
24 24
25config ATMEL_TCLIB
26 bool "Atmel AT32/AT91 Timer/Counter Library"
27 depends on (AVR32 || ARCH_AT91)
28 help
29 Select this if you want a library to allocate the Timer/Counter
30 blocks found on many Atmel processors. This facilitates using
31 these blocks by different drivers despite processor differences.
32
33config ATMEL_TCB_CLKSRC
34 bool "TC Block Clocksource"
35 depends on ATMEL_TCLIB && GENERIC_TIME
36 default y
37 help
38 Select this to get a high precision clocksource based on a
39 TC block with a 5+ MHz base clock rate. Two timer channels
40 are combined to make a single 32-bit timer.
41
42 When GENERIC_CLOCKEVENTS is defined, the third timer channel
43 may be used as a clock event device supporting oneshot mode
44 (delays of up to two seconds) based on the 32 KiHz clock.
45
46config ATMEL_TCB_CLKSRC_BLOCK
47 int
48 depends on ATMEL_TCB_CLKSRC
49 prompt "TC Block" if ARCH_AT91RM9200 || ARCH_AT91SAM9260 || CPU_AT32AP700X
50 default 0
51 range 0 1
52 help
53 Some chips provide more than one TC block, so you have the
54 choice of which one to use for the clock framework. The other
55 TC can be used for other purposes, such as PWM generation and
56 interval timing.
57
25config IBM_ASM 58config IBM_ASM
26 tristate "Device driver for IBM RSA service processor" 59 tristate "Device driver for IBM RSA service processor"
27 depends on X86 && PCI && INPUT && EXPERIMENTAL 60 depends on X86 && PCI && INPUT && EXPERIMENTAL
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index bbc69fdd1b9d..4581b2533111 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_ACER_WMI) += acer-wmi.o
10obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o 10obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
11obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o 11obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
12obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o 12obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
13obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
13obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o 14obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
14obj-$(CONFIG_LKDTM) += lkdtm.o 15obj-$(CONFIG_LKDTM) += lkdtm.o
15obj-$(CONFIG_TIFM_CORE) += tifm_core.o 16obj-$(CONFIG_TIFM_CORE) += tifm_core.o
diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
new file mode 100644
index 000000000000..05dc8a31f280
--- /dev/null
+++ b/drivers/misc/atmel_tclib.c
@@ -0,0 +1,161 @@
1#include <linux/atmel_tc.h>
2#include <linux/clk.h>
3#include <linux/err.h>
4#include <linux/init.h>
5#include <linux/io.h>
6#include <linux/ioport.h>
7#include <linux/kernel.h>
8#include <linux/platform_device.h>
9
10/* Number of bytes to reserve for the iomem resource */
11#define ATMEL_TC_IOMEM_SIZE 256
12
13
14/*
15 * This is a thin library to solve the problem of how to portably allocate
16 * one of the TC blocks. For simplicity, it doesn't currently expect to
17 * share individual timers between different drivers.
18 */
19
20#if defined(CONFIG_AVR32)
21/* AVR32 has these divide PBB */
22const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, };
23EXPORT_SYMBOL(atmel_tc_divisors);
24
25#elif defined(CONFIG_ARCH_AT91)
26/* AT91 has these divide MCK */
27const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
28EXPORT_SYMBOL(atmel_tc_divisors);
29
30#endif
31
32static DEFINE_SPINLOCK(tc_list_lock);
33static LIST_HEAD(tc_list);
34
35/**
36 * atmel_tc_alloc - allocate a specified TC block
37 * @block: which block to allocate
38 * @name: name to be associated with the iomem resource
39 *
40 * Caller allocates a block. If it is available, a pointer to a
41 * pre-initialized struct atmel_tc is returned. The caller can access
42 * the registers directly through the "regs" field.
43 */
44struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
45{
46 struct atmel_tc *tc;
47 struct platform_device *pdev = NULL;
48 struct resource *r;
49
50 spin_lock(&tc_list_lock);
51 list_for_each_entry(tc, &tc_list, node) {
52 if (tc->pdev->id == block) {
53 pdev = tc->pdev;
54 break;
55 }
56 }
57
58 if (!pdev || tc->iomem)
59 goto fail;
60
61 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
62 r = request_mem_region(r->start, ATMEL_TC_IOMEM_SIZE, name);
63 if (!r)
64 goto fail;
65
66 tc->regs = ioremap(r->start, ATMEL_TC_IOMEM_SIZE);
67 if (!tc->regs)
68 goto fail_ioremap;
69
70 tc->iomem = r;
71
72out:
73 spin_unlock(&tc_list_lock);
74 return tc;
75
76fail_ioremap:
77 release_resource(r);
78fail:
79 tc = NULL;
80 goto out;
81}
82EXPORT_SYMBOL_GPL(atmel_tc_alloc);
83
84/**
85 * atmel_tc_free - release a specified TC block
86 * @tc: Timer/counter block that was returned by atmel_tc_alloc()
87 *
88 * This reverses the effect of atmel_tc_alloc(), unmapping the I/O
89 * registers, invalidating the resource returned by that routine and
90 * making the TC available to other drivers.
91 */
92void atmel_tc_free(struct atmel_tc *tc)
93{
94 spin_lock(&tc_list_lock);
95 if (tc->regs) {
96 iounmap(tc->regs);
97 release_resource(tc->iomem);
98 tc->regs = NULL;
99 tc->iomem = NULL;
100 }
101 spin_unlock(&tc_list_lock);
102}
103EXPORT_SYMBOL_GPL(atmel_tc_free);
104
105static int __init tc_probe(struct platform_device *pdev)
106{
107 struct atmel_tc *tc;
108 struct clk *clk;
109 int irq;
110
111 if (!platform_get_resource(pdev, IORESOURCE_MEM, 0))
112 return -EINVAL;
113
114 irq = platform_get_irq(pdev, 0);
115 if (irq < 0)
116 return -EINVAL;
117
118 tc = kzalloc(sizeof(struct atmel_tc), GFP_KERNEL);
119 if (!tc)
120 return -ENOMEM;
121
122 tc->pdev = pdev;
123
124 clk = clk_get(&pdev->dev, "t0_clk");
125 if (IS_ERR(clk)) {
126 kfree(tc);
127 return -EINVAL;
128 }
129
130 tc->clk[0] = clk;
131 tc->clk[1] = clk_get(&pdev->dev, "t1_clk");
132 if (IS_ERR(tc->clk[1]))
133 tc->clk[1] = clk;
134 tc->clk[2] = clk_get(&pdev->dev, "t2_clk");
135 if (IS_ERR(tc->clk[2]))
136 tc->clk[2] = clk;
137
138 tc->irq[0] = irq;
139 tc->irq[1] = platform_get_irq(pdev, 1);
140 if (tc->irq[1] < 0)
141 tc->irq[1] = irq;
142 tc->irq[2] = platform_get_irq(pdev, 2);
143 if (tc->irq[2] < 0)
144 tc->irq[2] = irq;
145
146 spin_lock(&tc_list_lock);
147 list_add_tail(&tc->node, &tc_list);
148 spin_unlock(&tc_list_lock);
149
150 return 0;
151}
152
153static struct platform_driver tc_driver = {
154 .driver.name = "atmel_tcb",
155};
156
157static int __init tc_init(void)
158{
159 return platform_driver_probe(&tc_driver, tc_probe);
160}
161arch_initcall(tc_init);
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 6fcb0e96adf4..fafb57fed761 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -40,16 +40,16 @@ static struct class enclosure_component_class;
40 * Looks through the list of registered enclosures to see 40 * Looks through the list of registered enclosures to see
41 * if it can find a match for a device. Returns NULL if no 41 * if it can find a match for a device. Returns NULL if no
42 * enclosure is found. Obtains a reference to the enclosure class 42 * enclosure is found. Obtains a reference to the enclosure class
43 * device which must be released with class_device_put(). 43 * device which must be released with device_put().
44 */ 44 */
45struct enclosure_device *enclosure_find(struct device *dev) 45struct enclosure_device *enclosure_find(struct device *dev)
46{ 46{
47 struct enclosure_device *edev = NULL; 47 struct enclosure_device *edev;
48 48
49 mutex_lock(&container_list_lock); 49 mutex_lock(&container_list_lock);
50 list_for_each_entry(edev, &container_list, node) { 50 list_for_each_entry(edev, &container_list, node) {
51 if (edev->cdev.dev == dev) { 51 if (edev->edev.parent == dev) {
52 class_device_get(&edev->cdev); 52 get_device(&edev->edev);
53 mutex_unlock(&container_list_lock); 53 mutex_unlock(&container_list_lock);
54 return edev; 54 return edev;
55 } 55 }
@@ -117,11 +117,11 @@ enclosure_register(struct device *dev, const char *name, int components,
117 117
118 edev->components = components; 118 edev->components = components;
119 119
120 edev->cdev.class = &enclosure_class; 120 edev->edev.class = &enclosure_class;
121 edev->cdev.dev = get_device(dev); 121 edev->edev.parent = get_device(dev);
122 edev->cb = cb; 122 edev->cb = cb;
123 snprintf(edev->cdev.class_id, BUS_ID_SIZE, "%s", name); 123 snprintf(edev->edev.bus_id, BUS_ID_SIZE, "%s", name);
124 err = class_device_register(&edev->cdev); 124 err = device_register(&edev->edev);
125 if (err) 125 if (err)
126 goto err; 126 goto err;
127 127
@@ -135,7 +135,7 @@ enclosure_register(struct device *dev, const char *name, int components,
135 return edev; 135 return edev;
136 136
137 err: 137 err:
138 put_device(edev->cdev.dev); 138 put_device(edev->edev.parent);
139 kfree(edev); 139 kfree(edev);
140 return ERR_PTR(err); 140 return ERR_PTR(err);
141} 141}
@@ -158,27 +158,28 @@ void enclosure_unregister(struct enclosure_device *edev)
158 158
159 for (i = 0; i < edev->components; i++) 159 for (i = 0; i < edev->components; i++)
160 if (edev->component[i].number != -1) 160 if (edev->component[i].number != -1)
161 class_device_unregister(&edev->component[i].cdev); 161 device_unregister(&edev->component[i].cdev);
162 162
163 /* prevent any callbacks into service user */ 163 /* prevent any callbacks into service user */
164 edev->cb = &enclosure_null_callbacks; 164 edev->cb = &enclosure_null_callbacks;
165 class_device_unregister(&edev->cdev); 165 device_unregister(&edev->edev);
166} 166}
167EXPORT_SYMBOL_GPL(enclosure_unregister); 167EXPORT_SYMBOL_GPL(enclosure_unregister);
168 168
169static void enclosure_release(struct class_device *cdev) 169static void enclosure_release(struct device *cdev)
170{ 170{
171 struct enclosure_device *edev = to_enclosure_device(cdev); 171 struct enclosure_device *edev = to_enclosure_device(cdev);
172 172
173 put_device(cdev->dev); 173 put_device(cdev->parent);
174 kfree(edev); 174 kfree(edev);
175} 175}
176 176
177static void enclosure_component_release(struct class_device *cdev) 177static void enclosure_component_release(struct device *dev)
178{ 178{
179 if (cdev->dev) 179 struct enclosure_component *cdev = to_enclosure_component(dev);
180 put_device(cdev->dev); 180
181 class_device_put(cdev->parent); 181 put_device(cdev->dev);
182 put_device(dev->parent);
182} 183}
183 184
184/** 185/**
@@ -201,7 +202,7 @@ enclosure_component_register(struct enclosure_device *edev,
201 const char *name) 202 const char *name)
202{ 203{
203 struct enclosure_component *ecomp; 204 struct enclosure_component *ecomp;
204 struct class_device *cdev; 205 struct device *cdev;
205 int err; 206 int err;
206 207
207 if (number >= edev->components) 208 if (number >= edev->components)
@@ -215,14 +216,14 @@ enclosure_component_register(struct enclosure_device *edev,
215 ecomp->type = type; 216 ecomp->type = type;
216 ecomp->number = number; 217 ecomp->number = number;
217 cdev = &ecomp->cdev; 218 cdev = &ecomp->cdev;
218 cdev->parent = class_device_get(&edev->cdev); 219 cdev->parent = get_device(&edev->edev);
219 cdev->class = &enclosure_component_class; 220 cdev->class = &enclosure_component_class;
220 if (name) 221 if (name)
221 snprintf(cdev->class_id, BUS_ID_SIZE, "%s", name); 222 snprintf(cdev->bus_id, BUS_ID_SIZE, "%s", name);
222 else 223 else
223 snprintf(cdev->class_id, BUS_ID_SIZE, "%u", number); 224 snprintf(cdev->bus_id, BUS_ID_SIZE, "%u", number);
224 225
225 err = class_device_register(cdev); 226 err = device_register(cdev);
226 if (err) 227 if (err)
227 ERR_PTR(err); 228 ERR_PTR(err);
228 229
@@ -247,18 +248,17 @@ EXPORT_SYMBOL_GPL(enclosure_component_register);
247int enclosure_add_device(struct enclosure_device *edev, int component, 248int enclosure_add_device(struct enclosure_device *edev, int component,
248 struct device *dev) 249 struct device *dev)
249{ 250{
250 struct class_device *cdev; 251 struct enclosure_component *cdev;
251 252
252 if (!edev || component >= edev->components) 253 if (!edev || component >= edev->components)
253 return -EINVAL; 254 return -EINVAL;
254 255
255 cdev = &edev->component[component].cdev; 256 cdev = &edev->component[component];
256 257
257 class_device_del(cdev); 258 device_del(&cdev->cdev);
258 if (cdev->dev) 259 put_device(cdev->dev);
259 put_device(cdev->dev);
260 cdev->dev = get_device(dev); 260 cdev->dev = get_device(dev);
261 return class_device_add(cdev); 261 return device_add(&cdev->cdev);
262} 262}
263EXPORT_SYMBOL_GPL(enclosure_add_device); 263EXPORT_SYMBOL_GPL(enclosure_add_device);
264 264
@@ -272,18 +272,17 @@ EXPORT_SYMBOL_GPL(enclosure_add_device);
272 */ 272 */
273int enclosure_remove_device(struct enclosure_device *edev, int component) 273int enclosure_remove_device(struct enclosure_device *edev, int component)
274{ 274{
275 struct class_device *cdev; 275 struct enclosure_component *cdev;
276 276
277 if (!edev || component >= edev->components) 277 if (!edev || component >= edev->components)
278 return -EINVAL; 278 return -EINVAL;
279 279
280 cdev = &edev->component[component].cdev; 280 cdev = &edev->component[component];
281 281
282 class_device_del(cdev); 282 device_del(&cdev->cdev);
283 if (cdev->dev) 283 put_device(cdev->dev);
284 put_device(cdev->dev);
285 cdev->dev = NULL; 284 cdev->dev = NULL;
286 return class_device_add(cdev); 285 return device_add(&cdev->cdev);
287} 286}
288EXPORT_SYMBOL_GPL(enclosure_remove_device); 287EXPORT_SYMBOL_GPL(enclosure_remove_device);
289 288
@@ -291,14 +290,16 @@ EXPORT_SYMBOL_GPL(enclosure_remove_device);
291 * sysfs pieces below 290 * sysfs pieces below
292 */ 291 */
293 292
294static ssize_t enclosure_show_components(struct class_device *cdev, char *buf) 293static ssize_t enclosure_show_components(struct device *cdev,
294 struct device_attribute *attr,
295 char *buf)
295{ 296{
296 struct enclosure_device *edev = to_enclosure_device(cdev); 297 struct enclosure_device *edev = to_enclosure_device(cdev);
297 298
298 return snprintf(buf, 40, "%d\n", edev->components); 299 return snprintf(buf, 40, "%d\n", edev->components);
299} 300}
300 301
301static struct class_device_attribute enclosure_attrs[] = { 302static struct device_attribute enclosure_attrs[] = {
302 __ATTR(components, S_IRUGO, enclosure_show_components, NULL), 303 __ATTR(components, S_IRUGO, enclosure_show_components, NULL),
303 __ATTR_NULL 304 __ATTR_NULL
304}; 305};
@@ -306,8 +307,8 @@ static struct class_device_attribute enclosure_attrs[] = {
306static struct class enclosure_class = { 307static struct class enclosure_class = {
307 .name = "enclosure", 308 .name = "enclosure",
308 .owner = THIS_MODULE, 309 .owner = THIS_MODULE,
309 .release = enclosure_release, 310 .dev_release = enclosure_release,
310 .class_dev_attrs = enclosure_attrs, 311 .dev_attrs = enclosure_attrs,
311}; 312};
312 313
313static const char *const enclosure_status [] = { 314static const char *const enclosure_status [] = {
@@ -326,7 +327,8 @@ static const char *const enclosure_type [] = {
326 [ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device", 327 [ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device",
327}; 328};
328 329
329static ssize_t get_component_fault(struct class_device *cdev, char *buf) 330static ssize_t get_component_fault(struct device *cdev,
331 struct device_attribute *attr, char *buf)
330{ 332{
331 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 333 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
332 struct enclosure_component *ecomp = to_enclosure_component(cdev); 334 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -336,8 +338,9 @@ static ssize_t get_component_fault(struct class_device *cdev, char *buf)
336 return snprintf(buf, 40, "%d\n", ecomp->fault); 338 return snprintf(buf, 40, "%d\n", ecomp->fault);
337} 339}
338 340
339static ssize_t set_component_fault(struct class_device *cdev, const char *buf, 341static ssize_t set_component_fault(struct device *cdev,
340 size_t count) 342 struct device_attribute *attr,
343 const char *buf, size_t count)
341{ 344{
342 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 345 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
343 struct enclosure_component *ecomp = to_enclosure_component(cdev); 346 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -348,7 +351,8 @@ static ssize_t set_component_fault(struct class_device *cdev, const char *buf,
348 return count; 351 return count;
349} 352}
350 353
351static ssize_t get_component_status(struct class_device *cdev, char *buf) 354static ssize_t get_component_status(struct device *cdev,
355 struct device_attribute *attr,char *buf)
352{ 356{
353 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 357 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
354 struct enclosure_component *ecomp = to_enclosure_component(cdev); 358 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -358,8 +362,9 @@ static ssize_t get_component_status(struct class_device *cdev, char *buf)
358 return snprintf(buf, 40, "%s\n", enclosure_status[ecomp->status]); 362 return snprintf(buf, 40, "%s\n", enclosure_status[ecomp->status]);
359} 363}
360 364
361static ssize_t set_component_status(struct class_device *cdev, const char *buf, 365static ssize_t set_component_status(struct device *cdev,
362 size_t count) 366 struct device_attribute *attr,
367 const char *buf, size_t count)
363{ 368{
364 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 369 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
365 struct enclosure_component *ecomp = to_enclosure_component(cdev); 370 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -380,7 +385,8 @@ static ssize_t set_component_status(struct class_device *cdev, const char *buf,
380 return -EINVAL; 385 return -EINVAL;
381} 386}
382 387
383static ssize_t get_component_active(struct class_device *cdev, char *buf) 388static ssize_t get_component_active(struct device *cdev,
389 struct device_attribute *attr, char *buf)
384{ 390{
385 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 391 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
386 struct enclosure_component *ecomp = to_enclosure_component(cdev); 392 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -390,8 +396,9 @@ static ssize_t get_component_active(struct class_device *cdev, char *buf)
390 return snprintf(buf, 40, "%d\n", ecomp->active); 396 return snprintf(buf, 40, "%d\n", ecomp->active);
391} 397}
392 398
393static ssize_t set_component_active(struct class_device *cdev, const char *buf, 399static ssize_t set_component_active(struct device *cdev,
394 size_t count) 400 struct device_attribute *attr,
401 const char *buf, size_t count)
395{ 402{
396 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 403 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
397 struct enclosure_component *ecomp = to_enclosure_component(cdev); 404 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -402,7 +409,8 @@ static ssize_t set_component_active(struct class_device *cdev, const char *buf,
402 return count; 409 return count;
403} 410}
404 411
405static ssize_t get_component_locate(struct class_device *cdev, char *buf) 412static ssize_t get_component_locate(struct device *cdev,
413 struct device_attribute *attr, char *buf)
406{ 414{
407 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 415 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
408 struct enclosure_component *ecomp = to_enclosure_component(cdev); 416 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -412,8 +420,9 @@ static ssize_t get_component_locate(struct class_device *cdev, char *buf)
412 return snprintf(buf, 40, "%d\n", ecomp->locate); 420 return snprintf(buf, 40, "%d\n", ecomp->locate);
413} 421}
414 422
415static ssize_t set_component_locate(struct class_device *cdev, const char *buf, 423static ssize_t set_component_locate(struct device *cdev,
416 size_t count) 424 struct device_attribute *attr,
425 const char *buf, size_t count)
417{ 426{
418 struct enclosure_device *edev = to_enclosure_device(cdev->parent); 427 struct enclosure_device *edev = to_enclosure_device(cdev->parent);
419 struct enclosure_component *ecomp = to_enclosure_component(cdev); 428 struct enclosure_component *ecomp = to_enclosure_component(cdev);
@@ -424,7 +433,8 @@ static ssize_t set_component_locate(struct class_device *cdev, const char *buf,
424 return count; 433 return count;
425} 434}
426 435
427static ssize_t get_component_type(struct class_device *cdev, char *buf) 436static ssize_t get_component_type(struct device *cdev,
437 struct device_attribute *attr, char *buf)
428{ 438{
429 struct enclosure_component *ecomp = to_enclosure_component(cdev); 439 struct enclosure_component *ecomp = to_enclosure_component(cdev);
430 440
@@ -432,7 +442,7 @@ static ssize_t get_component_type(struct class_device *cdev, char *buf)
432} 442}
433 443
434 444
435static struct class_device_attribute enclosure_component_attrs[] = { 445static struct device_attribute enclosure_component_attrs[] = {
436 __ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault, 446 __ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault,
437 set_component_fault), 447 set_component_fault),
438 __ATTR(status, S_IRUGO | S_IWUSR, get_component_status, 448 __ATTR(status, S_IRUGO | S_IWUSR, get_component_status,
@@ -448,8 +458,8 @@ static struct class_device_attribute enclosure_component_attrs[] = {
448static struct class enclosure_component_class = { 458static struct class enclosure_component_class = {
449 .name = "enclosure_component", 459 .name = "enclosure_component",
450 .owner = THIS_MODULE, 460 .owner = THIS_MODULE,
451 .class_dev_attrs = enclosure_component_attrs, 461 .dev_attrs = enclosure_component_attrs,
452 .release = enclosure_component_release, 462 .dev_release = enclosure_component_release,
453}; 463};
454 464
455static int __init enclosure_init(void) 465static int __init enclosure_init(void)
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 4a3c6759492b..959fb86cda01 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -314,7 +314,7 @@ config MTD_ALAUDA
314 314
315config MTD_NAND_ORION 315config MTD_NAND_ORION
316 tristate "NAND Flash support for Marvell Orion SoC" 316 tristate "NAND Flash support for Marvell Orion SoC"
317 depends on ARCH_ORION && MTD_NAND 317 depends on PLAT_ORION && MTD_NAND
318 help 318 help
319 This enables the NAND flash controller on Orion machines. 319 This enables the NAND flash controller on Orion machines.
320 320
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index b025dfe0b274..378b7aa63812 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -36,207 +36,12 @@
36#include <linux/mtd/partitions.h> 36#include <linux/mtd/partitions.h>
37 37
38#include <asm/io.h> 38#include <asm/io.h>
39 39#include <asm/fsl_lbc.h>
40 40
41#define MAX_BANKS 8 41#define MAX_BANKS 8
42#define ERR_BYTE 0xFF /* Value returned for read bytes when read failed */ 42#define ERR_BYTE 0xFF /* Value returned for read bytes when read failed */
43#define FCM_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait for FCM */ 43#define FCM_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait for FCM */
44 44
45struct elbc_bank {
46 __be32 br; /**< Base Register */
47#define BR_BA 0xFFFF8000
48#define BR_BA_SHIFT 15
49#define BR_PS 0x00001800
50#define BR_PS_SHIFT 11
51#define BR_PS_8 0x00000800 /* Port Size 8 bit */
52#define BR_PS_16 0x00001000 /* Port Size 16 bit */
53#define BR_PS_32 0x00001800 /* Port Size 32 bit */
54#define BR_DECC 0x00000600
55#define BR_DECC_SHIFT 9
56#define BR_DECC_OFF 0x00000000 /* HW ECC checking and generation off */
57#define BR_DECC_CHK 0x00000200 /* HW ECC checking on, generation off */
58#define BR_DECC_CHK_GEN 0x00000400 /* HW ECC checking and generation on */
59#define BR_WP 0x00000100
60#define BR_WP_SHIFT 8
61#define BR_MSEL 0x000000E0
62#define BR_MSEL_SHIFT 5
63#define BR_MS_GPCM 0x00000000 /* GPCM */
64#define BR_MS_FCM 0x00000020 /* FCM */
65#define BR_MS_SDRAM 0x00000060 /* SDRAM */
66#define BR_MS_UPMA 0x00000080 /* UPMA */
67#define BR_MS_UPMB 0x000000A0 /* UPMB */
68#define BR_MS_UPMC 0x000000C0 /* UPMC */
69#define BR_V 0x00000001
70#define BR_V_SHIFT 0
71#define BR_RES ~(BR_BA|BR_PS|BR_DECC|BR_WP|BR_MSEL|BR_V)
72
73 __be32 or; /**< Base Register */
74#define OR0 0x5004
75#define OR1 0x500C
76#define OR2 0x5014
77#define OR3 0x501C
78#define OR4 0x5024
79#define OR5 0x502C
80#define OR6 0x5034
81#define OR7 0x503C
82
83#define OR_FCM_AM 0xFFFF8000
84#define OR_FCM_AM_SHIFT 15
85#define OR_FCM_BCTLD 0x00001000
86#define OR_FCM_BCTLD_SHIFT 12
87#define OR_FCM_PGS 0x00000400
88#define OR_FCM_PGS_SHIFT 10
89#define OR_FCM_CSCT 0x00000200
90#define OR_FCM_CSCT_SHIFT 9
91#define OR_FCM_CST 0x00000100
92#define OR_FCM_CST_SHIFT 8
93#define OR_FCM_CHT 0x00000080
94#define OR_FCM_CHT_SHIFT 7
95#define OR_FCM_SCY 0x00000070
96#define OR_FCM_SCY_SHIFT 4
97#define OR_FCM_SCY_1 0x00000010
98#define OR_FCM_SCY_2 0x00000020
99#define OR_FCM_SCY_3 0x00000030
100#define OR_FCM_SCY_4 0x00000040
101#define OR_FCM_SCY_5 0x00000050
102#define OR_FCM_SCY_6 0x00000060
103#define OR_FCM_SCY_7 0x00000070
104#define OR_FCM_RST 0x00000008
105#define OR_FCM_RST_SHIFT 3
106#define OR_FCM_TRLX 0x00000004
107#define OR_FCM_TRLX_SHIFT 2
108#define OR_FCM_EHTR 0x00000002
109#define OR_FCM_EHTR_SHIFT 1
110};
111
112struct elbc_regs {
113 struct elbc_bank bank[8];
114 u8 res0[0x28];
115 __be32 mar; /**< UPM Address Register */
116 u8 res1[0x4];
117 __be32 mamr; /**< UPMA Mode Register */
118 __be32 mbmr; /**< UPMB Mode Register */
119 __be32 mcmr; /**< UPMC Mode Register */
120 u8 res2[0x8];
121 __be32 mrtpr; /**< Memory Refresh Timer Prescaler Register */
122 __be32 mdr; /**< UPM Data Register */
123 u8 res3[0x4];
124 __be32 lsor; /**< Special Operation Initiation Register */
125 __be32 lsdmr; /**< SDRAM Mode Register */
126 u8 res4[0x8];
127 __be32 lurt; /**< UPM Refresh Timer */
128 __be32 lsrt; /**< SDRAM Refresh Timer */
129 u8 res5[0x8];
130 __be32 ltesr; /**< Transfer Error Status Register */
131#define LTESR_BM 0x80000000
132#define LTESR_FCT 0x40000000
133#define LTESR_PAR 0x20000000
134#define LTESR_WP 0x04000000
135#define LTESR_ATMW 0x00800000
136#define LTESR_ATMR 0x00400000
137#define LTESR_CS 0x00080000
138#define LTESR_CC 0x00000001
139#define LTESR_NAND_MASK (LTESR_FCT | LTESR_PAR | LTESR_CC)
140 __be32 ltedr; /**< Transfer Error Disable Register */
141 __be32 lteir; /**< Transfer Error Interrupt Register */
142 __be32 lteatr; /**< Transfer Error Attributes Register */
143 __be32 ltear; /**< Transfer Error Address Register */
144 u8 res6[0xC];
145 __be32 lbcr; /**< Configuration Register */
146#define LBCR_LDIS 0x80000000
147#define LBCR_LDIS_SHIFT 31
148#define LBCR_BCTLC 0x00C00000
149#define LBCR_BCTLC_SHIFT 22
150#define LBCR_AHD 0x00200000
151#define LBCR_LPBSE 0x00020000
152#define LBCR_LPBSE_SHIFT 17
153#define LBCR_EPAR 0x00010000
154#define LBCR_EPAR_SHIFT 16
155#define LBCR_BMT 0x0000FF00
156#define LBCR_BMT_SHIFT 8
157#define LBCR_INIT 0x00040000
158 __be32 lcrr; /**< Clock Ratio Register */
159#define LCRR_DBYP 0x80000000
160#define LCRR_DBYP_SHIFT 31
161#define LCRR_BUFCMDC 0x30000000
162#define LCRR_BUFCMDC_SHIFT 28
163#define LCRR_ECL 0x03000000
164#define LCRR_ECL_SHIFT 24
165#define LCRR_EADC 0x00030000
166#define LCRR_EADC_SHIFT 16
167#define LCRR_CLKDIV 0x0000000F
168#define LCRR_CLKDIV_SHIFT 0
169 u8 res7[0x8];
170 __be32 fmr; /**< Flash Mode Register */
171#define FMR_CWTO 0x0000F000
172#define FMR_CWTO_SHIFT 12
173#define FMR_BOOT 0x00000800
174#define FMR_ECCM 0x00000100
175#define FMR_AL 0x00000030
176#define FMR_AL_SHIFT 4
177#define FMR_OP 0x00000003
178#define FMR_OP_SHIFT 0
179 __be32 fir; /**< Flash Instruction Register */
180#define FIR_OP0 0xF0000000
181#define FIR_OP0_SHIFT 28
182#define FIR_OP1 0x0F000000
183#define FIR_OP1_SHIFT 24
184#define FIR_OP2 0x00F00000
185#define FIR_OP2_SHIFT 20
186#define FIR_OP3 0x000F0000
187#define FIR_OP3_SHIFT 16
188#define FIR_OP4 0x0000F000
189#define FIR_OP4_SHIFT 12
190#define FIR_OP5 0x00000F00
191#define FIR_OP5_SHIFT 8
192#define FIR_OP6 0x000000F0
193#define FIR_OP6_SHIFT 4
194#define FIR_OP7 0x0000000F
195#define FIR_OP7_SHIFT 0
196#define FIR_OP_NOP 0x0 /* No operation and end of sequence */
197#define FIR_OP_CA 0x1 /* Issue current column address */
198#define FIR_OP_PA 0x2 /* Issue current block+page address */
199#define FIR_OP_UA 0x3 /* Issue user defined address */
200#define FIR_OP_CM0 0x4 /* Issue command from FCR[CMD0] */
201#define FIR_OP_CM1 0x5 /* Issue command from FCR[CMD1] */
202#define FIR_OP_CM2 0x6 /* Issue command from FCR[CMD2] */
203#define FIR_OP_CM3 0x7 /* Issue command from FCR[CMD3] */
204#define FIR_OP_WB 0x8 /* Write FBCR bytes from FCM buffer */
205#define FIR_OP_WS 0x9 /* Write 1 or 2 bytes from MDR[AS] */
206#define FIR_OP_RB 0xA /* Read FBCR bytes to FCM buffer */
207#define FIR_OP_RS 0xB /* Read 1 or 2 bytes to MDR[AS] */
208#define FIR_OP_CW0 0xC /* Wait then issue FCR[CMD0] */
209#define FIR_OP_CW1 0xD /* Wait then issue FCR[CMD1] */
210#define FIR_OP_RBW 0xE /* Wait then read FBCR bytes */
211#define FIR_OP_RSW 0xE /* Wait then read 1 or 2 bytes */
212 __be32 fcr; /**< Flash Command Register */
213#define FCR_CMD0 0xFF000000
214#define FCR_CMD0_SHIFT 24
215#define FCR_CMD1 0x00FF0000
216#define FCR_CMD1_SHIFT 16
217#define FCR_CMD2 0x0000FF00
218#define FCR_CMD2_SHIFT 8
219#define FCR_CMD3 0x000000FF
220#define FCR_CMD3_SHIFT 0
221 __be32 fbar; /**< Flash Block Address Register */
222#define FBAR_BLK 0x00FFFFFF
223 __be32 fpar; /**< Flash Page Address Register */
224#define FPAR_SP_PI 0x00007C00
225#define FPAR_SP_PI_SHIFT 10
226#define FPAR_SP_MS 0x00000200
227#define FPAR_SP_CI 0x000001FF
228#define FPAR_SP_CI_SHIFT 0
229#define FPAR_LP_PI 0x0003F000
230#define FPAR_LP_PI_SHIFT 12
231#define FPAR_LP_MS 0x00000800
232#define FPAR_LP_CI 0x000007FF
233#define FPAR_LP_CI_SHIFT 0
234 __be32 fbcr; /**< Flash Byte Count Register */
235#define FBCR_BC 0x00000FFF
236 u8 res11[0x8];
237 u8 res8[0xF00];
238};
239
240struct fsl_elbc_ctrl; 45struct fsl_elbc_ctrl;
241 46
242/* mtd information per set */ 47/* mtd information per set */
@@ -261,7 +66,7 @@ struct fsl_elbc_ctrl {
261 66
262 /* device info */ 67 /* device info */
263 struct device *dev; 68 struct device *dev;
264 struct elbc_regs __iomem *regs; 69 struct fsl_lbc_regs __iomem *regs;
265 int irq; 70 int irq;
266 wait_queue_head_t irq_wait; 71 wait_queue_head_t irq_wait;
267 unsigned int irq_status; /* status read from LTESR by irq handler */ 72 unsigned int irq_status; /* status read from LTESR by irq handler */
@@ -322,7 +127,7 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)
322 struct nand_chip *chip = mtd->priv; 127 struct nand_chip *chip = mtd->priv;
323 struct fsl_elbc_mtd *priv = chip->priv; 128 struct fsl_elbc_mtd *priv = chip->priv;
324 struct fsl_elbc_ctrl *ctrl = priv->ctrl; 129 struct fsl_elbc_ctrl *ctrl = priv->ctrl;
325 struct elbc_regs __iomem *lbc = ctrl->regs; 130 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
326 int buf_num; 131 int buf_num;
327 132
328 ctrl->page = page_addr; 133 ctrl->page = page_addr;
@@ -363,7 +168,7 @@ static int fsl_elbc_run_command(struct mtd_info *mtd)
363 struct nand_chip *chip = mtd->priv; 168 struct nand_chip *chip = mtd->priv;
364 struct fsl_elbc_mtd *priv = chip->priv; 169 struct fsl_elbc_mtd *priv = chip->priv;
365 struct fsl_elbc_ctrl *ctrl = priv->ctrl; 170 struct fsl_elbc_ctrl *ctrl = priv->ctrl;
366 struct elbc_regs __iomem *lbc = ctrl->regs; 171 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
367 172
368 /* Setup the FMR[OP] to execute without write protection */ 173 /* Setup the FMR[OP] to execute without write protection */
369 out_be32(&lbc->fmr, priv->fmr | 3); 174 out_be32(&lbc->fmr, priv->fmr | 3);
@@ -406,7 +211,7 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob)
406{ 211{
407 struct fsl_elbc_mtd *priv = chip->priv; 212 struct fsl_elbc_mtd *priv = chip->priv;
408 struct fsl_elbc_ctrl *ctrl = priv->ctrl; 213 struct fsl_elbc_ctrl *ctrl = priv->ctrl;
409 struct elbc_regs __iomem *lbc = ctrl->regs; 214 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
410 215
411 if (priv->page_size) { 216 if (priv->page_size) {
412 out_be32(&lbc->fir, 217 out_be32(&lbc->fir,
@@ -439,7 +244,7 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
439 struct nand_chip *chip = mtd->priv; 244 struct nand_chip *chip = mtd->priv;
440 struct fsl_elbc_mtd *priv = chip->priv; 245 struct fsl_elbc_mtd *priv = chip->priv;
441 struct fsl_elbc_ctrl *ctrl = priv->ctrl; 246 struct fsl_elbc_ctrl *ctrl = priv->ctrl;
442 struct elbc_regs __iomem *lbc = ctrl->regs; 247 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
443 248
444 ctrl->use_mdr = 0; 249 ctrl->use_mdr = 0;
445 250
@@ -775,7 +580,7 @@ static int fsl_elbc_wait(struct mtd_info *mtd, struct nand_chip *chip)
775{ 580{
776 struct fsl_elbc_mtd *priv = chip->priv; 581 struct fsl_elbc_mtd *priv = chip->priv;
777 struct fsl_elbc_ctrl *ctrl = priv->ctrl; 582 struct fsl_elbc_ctrl *ctrl = priv->ctrl;
778 struct elbc_regs __iomem *lbc = ctrl->regs; 583 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
779 584
780 if (ctrl->status != LTESR_CC) 585 if (ctrl->status != LTESR_CC)
781 return NAND_STATUS_FAIL; 586 return NAND_STATUS_FAIL;
@@ -807,7 +612,7 @@ static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
807 struct nand_chip *chip = mtd->priv; 612 struct nand_chip *chip = mtd->priv;
808 struct fsl_elbc_mtd *priv = chip->priv; 613 struct fsl_elbc_mtd *priv = chip->priv;
809 struct fsl_elbc_ctrl *ctrl = priv->ctrl; 614 struct fsl_elbc_ctrl *ctrl = priv->ctrl;
810 struct elbc_regs __iomem *lbc = ctrl->regs; 615 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
811 unsigned int al; 616 unsigned int al;
812 617
813 /* calculate FMR Address Length field */ 618 /* calculate FMR Address Length field */
@@ -922,7 +727,7 @@ static void fsl_elbc_write_page(struct mtd_info *mtd,
922static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv) 727static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
923{ 728{
924 struct fsl_elbc_ctrl *ctrl = priv->ctrl; 729 struct fsl_elbc_ctrl *ctrl = priv->ctrl;
925 struct elbc_regs __iomem *lbc = ctrl->regs; 730 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
926 struct nand_chip *chip = &priv->chip; 731 struct nand_chip *chip = &priv->chip;
927 732
928 dev_dbg(priv->dev, "eLBC Set Information for bank %d\n", priv->bank); 733 dev_dbg(priv->dev, "eLBC Set Information for bank %d\n", priv->bank);
@@ -986,7 +791,7 @@ static int fsl_elbc_chip_remove(struct fsl_elbc_mtd *priv)
986static int fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl, 791static int fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
987 struct device_node *node) 792 struct device_node *node)
988{ 793{
989 struct elbc_regs __iomem *lbc = ctrl->regs; 794 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
990 struct fsl_elbc_mtd *priv; 795 struct fsl_elbc_mtd *priv;
991 struct resource res; 796 struct resource res;
992#ifdef CONFIG_MTD_PARTITIONS 797#ifdef CONFIG_MTD_PARTITIONS
@@ -1083,7 +888,7 @@ err:
1083 888
1084static int __devinit fsl_elbc_ctrl_init(struct fsl_elbc_ctrl *ctrl) 889static int __devinit fsl_elbc_ctrl_init(struct fsl_elbc_ctrl *ctrl)
1085{ 890{
1086 struct elbc_regs __iomem *lbc = ctrl->regs; 891 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
1087 892
1088 /* clear event registers */ 893 /* clear event registers */
1089 setbits32(&lbc->ltesr, LTESR_NAND_MASK); 894 setbits32(&lbc->ltesr, LTESR_NAND_MASK);
@@ -1128,7 +933,7 @@ static int __devexit fsl_elbc_ctrl_remove(struct of_device *ofdev)
1128static irqreturn_t fsl_elbc_ctrl_irq(int irqno, void *data) 933static irqreturn_t fsl_elbc_ctrl_irq(int irqno, void *data)
1129{ 934{
1130 struct fsl_elbc_ctrl *ctrl = data; 935 struct fsl_elbc_ctrl *ctrl = data;
1131 struct elbc_regs __iomem *lbc = ctrl->regs; 936 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
1132 __be32 status = in_be32(&lbc->ltesr) & LTESR_NAND_MASK; 937 __be32 status = in_be32(&lbc->ltesr) & LTESR_NAND_MASK;
1133 938
1134 if (status) { 939 if (status) {
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 9162cca0182b..ec5ad28b237e 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -18,8 +18,8 @@
18#include <linux/mtd/partitions.h> 18#include <linux/mtd/partitions.h>
19#include <asm/io.h> 19#include <asm/io.h>
20#include <asm/sizes.h> 20#include <asm/sizes.h>
21#include <asm/arch/platform.h>
22#include <asm/arch/hardware.h> 21#include <asm/arch/hardware.h>
22#include <asm/plat-orion/orion_nand.h>
23 23
24#ifdef CONFIG_MTD_CMDLINE_PARTS 24#ifdef CONFIG_MTD_CMDLINE_PARTS
25static const char *part_probes[] = { "cmdlinepart", NULL }; 25static const char *part_probes[] = { "cmdlinepart", NULL };
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index b72b89d53ec8..fae295b6809c 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -103,8 +103,8 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Procter <rnp@paradise.net.
103#include <linux/ethtool.h> 103#include <linux/ethtool.h>
104#include <linux/completion.h> 104#include <linux/completion.h>
105#include <linux/bitops.h> 105#include <linux/bitops.h>
106#include <linux/semaphore.h>
106 107
107#include <asm/semaphore.h>
108#include <asm/uaccess.h> 108#include <asm/uaccess.h>
109#include <asm/system.h> 109#include <asm/system.h>
110#include <asm/io.h> 110#include <asm/io.h>
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 45c3a208d93f..2399a3796f6e 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2335,7 +2335,7 @@ config UGETH_TX_ON_DEMAND
2335 2335
2336config MV643XX_ETH 2336config MV643XX_ETH
2337 tristate "Marvell Discovery (643XX) and Orion ethernet support" 2337 tristate "Marvell Discovery (643XX) and Orion ethernet support"
2338 depends on MV64360 || MV64X60 || (PPC_MULTIPLATFORM && PPC32) || ARCH_ORION 2338 depends on MV64360 || MV64X60 || (PPC_MULTIPLATFORM && PPC32) || PLAT_ORION
2339 select MII 2339 select MII
2340 help 2340 help
2341 This driver supports the gigabit ethernet MACs in the 2341 This driver supports the gigabit ethernet MACs in the
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 4d71729e85e5..2f1f3f2739fd 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -218,7 +218,8 @@ obj-$(CONFIG_SMC911X) += smc911x.o
218obj-$(CONFIG_BFIN_MAC) += bfin_mac.o 218obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
219obj-$(CONFIG_DM9000) += dm9000.o 219obj-$(CONFIG_DM9000) += dm9000.o
220obj-$(CONFIG_FEC_8XX) += fec_8xx/ 220obj-$(CONFIG_FEC_8XX) += fec_8xx/
221obj-$(CONFIG_PASEMI_MAC) += pasemi_mac.o 221obj-$(CONFIG_PASEMI_MAC) += pasemi_mac_driver.o
222pasemi_mac_driver-objs := pasemi_mac.o pasemi_mac_ethtool.o
222obj-$(CONFIG_MLX4_CORE) += mlx4/ 223obj-$(CONFIG_MLX4_CORE) += mlx4/
223obj-$(CONFIG_ENC28J60) += enc28j60.o 224obj-$(CONFIG_ENC28J60) += enc28j60.o
224 225
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 65b901ebfd62..82e9a5bd0dd2 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -69,6 +69,7 @@ static const char *version =
69#include <linux/atalk.h> 69#include <linux/atalk.h>
70#include <linux/spinlock.h> 70#include <linux/spinlock.h>
71#include <linux/bitops.h> 71#include <linux/bitops.h>
72#include <linux/jiffies.h>
72 73
73#include <asm/system.h> 74#include <asm/system.h>
74#include <asm/io.h> 75#include <asm/io.h>
@@ -503,7 +504,7 @@ static void cops_reset(struct net_device *dev, int sleep)
503 long snap=jiffies; 504 long snap=jiffies;
504 505
505 /* Let card finish initializing, about 1/3 second */ 506 /* Let card finish initializing, about 1/3 second */
506 while(jiffies-snap<HZ/3) 507 while (time_before(jiffies, snap + HZ/3))
507 schedule(); 508 schedule();
508 } 509 }
509 else 510 else
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 0ae0d83e5d22..978e20a1791b 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -1043,7 +1043,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1043 } else if (machine_is_csb337()) { 1043 } else if (machine_is_csb337()) {
1044 /* mix link activity status into LED2 link state */ 1044 /* mix link activity status into LED2 link state */
1045 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22); 1045 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
1046 } 1046 } else if (machine_is_ecbat91())
1047 write_phy(phy_address, MII_LEDCTRL_REG, 0x156A);
1048
1047 disable_mdi(); 1049 disable_mdi();
1048 spin_unlock_irq(&lp->lock); 1050 spin_unlock_irq(&lp->lock);
1049 1051
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index eb305a0895fc..4fdb13f8447b 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -43,7 +43,6 @@
43#include <linux/mutex.h> 43#include <linux/mutex.h>
44#include <linux/bitops.h> 44#include <linux/bitops.h>
45#include "t3cdev.h" 45#include "t3cdev.h"
46#include <asm/semaphore.h>
47#include <asm/io.h> 46#include <asm/io.h>
48 47
49struct vlan_group; 48struct vlan_group;
diff --git a/drivers/net/cxgb3/t3cdev.h b/drivers/net/cxgb3/t3cdev.h
index 77fcc1a4984e..a18c8a140424 100644
--- a/drivers/net/cxgb3/t3cdev.h
+++ b/drivers/net/cxgb3/t3cdev.h
@@ -34,7 +34,6 @@
34 34
35#include <linux/list.h> 35#include <linux/list.h>
36#include <asm/atomic.h> 36#include <asm/atomic.h>
37#include <asm/semaphore.h>
38#include <linux/netdevice.h> 37#include <linux/netdevice.h>
39#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
40#include <linux/skbuff.h> 39#include <linux/skbuff.h>
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 0a9b75139e0f..1da55dd2a5a0 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -33,7 +33,7 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/ip.h> 34#include <linux/ip.h>
35#include <linux/tcp.h> 35#include <linux/tcp.h>
36#include <asm/semaphore.h> 36#include <linux/semaphore.h>
37#include <asm/atomic.h> 37#include <asm/atomic.h>
38 38
39#define SIXPACK_VERSION "Revision: 0.3.0" 39#define SIXPACK_VERSION "Revision: 0.3.0"
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index bb31e09899fc..ce4fc2ec2fe4 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -49,7 +49,6 @@
49#include <linux/in.h> 49#include <linux/in.h>
50#include <linux/ip.h> 50#include <linux/ip.h>
51#include <net/net_namespace.h> 51#include <net/net_namespace.h>
52#include <asm/semaphore.h>
53#include <asm/hvcall.h> 52#include <asm/hvcall.h>
54#include <asm/atomic.h> 53#include <asm/atomic.h>
55#include <asm/vio.h> 54#include <asm/vio.h>
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 8c09344f58dc..8db71ab20456 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -36,6 +36,7 @@
36#include <asm/hardware.h> 36#include <asm/hardware.h>
37#include <asm/arch/irda.h> 37#include <asm/arch/irda.h>
38#include <asm/arch/pxa-regs.h> 38#include <asm/arch/pxa-regs.h>
39#include <asm/arch/pxa2xx-gpio.h>
39 40
40#ifdef CONFIG_MACH_MAINSTONE 41#ifdef CONFIG_MACH_MAINSTONE
41#include <asm/arch/mainstone.h> 42#include <asm/arch/mainstone.h>
@@ -831,6 +832,11 @@ static int pxa_irda_probe(struct platform_device *pdev)
831 if (err) 832 if (err)
832 goto err_mem_5; 833 goto err_mem_5;
833 834
835 if (si->pdata->startup)
836 err = si->pdata->startup(si->dev);
837 if (err)
838 goto err_startup;
839
834 dev->hard_start_xmit = pxa_irda_hard_xmit; 840 dev->hard_start_xmit = pxa_irda_hard_xmit;
835 dev->open = pxa_irda_start; 841 dev->open = pxa_irda_start;
836 dev->stop = pxa_irda_stop; 842 dev->stop = pxa_irda_stop;
@@ -856,6 +862,9 @@ static int pxa_irda_probe(struct platform_device *pdev)
856 dev_set_drvdata(&pdev->dev, dev); 862 dev_set_drvdata(&pdev->dev, dev);
857 863
858 if (err) { 864 if (err) {
865 if (si->pdata->shutdown)
866 si->pdata->shutdown(si->dev);
867err_startup:
859 kfree(si->tx_buff.head); 868 kfree(si->tx_buff.head);
860err_mem_5: 869err_mem_5:
861 kfree(si->rx_buff.head); 870 kfree(si->rx_buff.head);
@@ -881,6 +890,8 @@ static int pxa_irda_remove(struct platform_device *_dev)
881 if (dev) { 890 if (dev) {
882 struct pxa_irda *si = netdev_priv(dev); 891 struct pxa_irda *si = netdev_priv(dev);
883 unregister_netdev(dev); 892 unregister_netdev(dev);
893 if (si->pdata->shutdown)
894 si->pdata->shutdown(si->dev);
884 kfree(si->tx_buff.head); 895 kfree(si->tx_buff.head);
885 kfree(si->rx_buff.head); 896 kfree(si->rx_buff.head);
886 clk_put(si->fir_clk); 897 clk_put(si->fir_clk);
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index 58d3bb622da6..b8d0639c1cdf 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -308,7 +308,8 @@ static void veth_complete_allocation(void *parm, int number)
308 308
309static int veth_allocate_events(HvLpIndex rlp, int number) 309static int veth_allocate_events(HvLpIndex rlp, int number)
310{ 310{
311 struct veth_allocation vc = { COMPLETION_INITIALIZER(vc.c), 0 }; 311 struct veth_allocation vc =
312 { COMPLETION_INITIALIZER_ONSTACK(vc.c), 0 };
312 313
313 mf_allocate_lp_events(rlp, HvLpEvent_Type_VirtualLan, 314 mf_allocate_lp_events(rlp, HvLpEvent_Type_VirtualLan,
314 sizeof(struct veth_lpevent), number, 315 sizeof(struct veth_lpevent), number,
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 160f605e58db..24d027e29c45 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -34,7 +34,6 @@
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/version.h> 35#include <linux/version.h>
36 36
37#include <asm/semaphore.h>
38#include <linux/spinlock.h> 37#include <linux/spinlock.h>
39#include <asm/irq.h> 38#include <asm/irq.h>
40#include <linux/init.h> 39#include <linux/init.h>
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index bcd7f9814ed8..3b2a6c598088 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -55,15 +55,10 @@
55 * - Multiqueue RX/TX 55 * - Multiqueue RX/TX
56 */ 56 */
57 57
58
59/* Must be a power of two */
60#define RX_RING_SIZE 2048
61#define TX_RING_SIZE 4096
62
63#define LRO_MAX_AGGR 64 58#define LRO_MAX_AGGR 64
64 59
65#define PE_MIN_MTU 64 60#define PE_MIN_MTU 64
66#define PE_MAX_MTU 1500 61#define PE_MAX_MTU 9000
67#define PE_DEF_MTU ETH_DATA_LEN 62#define PE_DEF_MTU ETH_DATA_LEN
68 63
69#define DEFAULT_MSG_ENABLE \ 64#define DEFAULT_MSG_ENABLE \
@@ -76,16 +71,6 @@
76 NETIF_MSG_RX_ERR | \ 71 NETIF_MSG_RX_ERR | \
77 NETIF_MSG_TX_ERR) 72 NETIF_MSG_TX_ERR)
78 73
79#define TX_DESC(tx, num) ((tx)->chan.ring_virt[(num) & (TX_RING_SIZE-1)])
80#define TX_DESC_INFO(tx, num) ((tx)->ring_info[(num) & (TX_RING_SIZE-1)])
81#define RX_DESC(rx, num) ((rx)->chan.ring_virt[(num) & (RX_RING_SIZE-1)])
82#define RX_DESC_INFO(rx, num) ((rx)->ring_info[(num) & (RX_RING_SIZE-1)])
83#define RX_BUFF(rx, num) ((rx)->buffers[(num) & (RX_RING_SIZE-1)])
84
85#define RING_USED(ring) (((ring)->next_to_fill - (ring)->next_to_clean) \
86 & ((ring)->size - 1))
87#define RING_AVAIL(ring) ((ring->size) - RING_USED(ring))
88
89MODULE_LICENSE("GPL"); 74MODULE_LICENSE("GPL");
90MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>"); 75MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>");
91MODULE_DESCRIPTION("PA Semi PWRficient Ethernet driver"); 76MODULE_DESCRIPTION("PA Semi PWRficient Ethernet driver");
@@ -94,6 +79,8 @@ static int debug = -1; /* -1 == use DEFAULT_MSG_ENABLE as value */
94module_param(debug, int, 0); 79module_param(debug, int, 0);
95MODULE_PARM_DESC(debug, "PA Semi MAC bitmapped debugging message enable value"); 80MODULE_PARM_DESC(debug, "PA Semi MAC bitmapped debugging message enable value");
96 81
82extern const struct ethtool_ops pasemi_mac_ethtool_ops;
83
97static int translation_enabled(void) 84static int translation_enabled(void)
98{ 85{
99#if defined(CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE) 86#if defined(CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE)
@@ -322,6 +309,104 @@ static int pasemi_mac_unmap_tx_skb(struct pasemi_mac *mac,
322 return (nfrags + 3) & ~1; 309 return (nfrags + 3) & ~1;
323} 310}
324 311
312static struct pasemi_mac_csring *pasemi_mac_setup_csring(struct pasemi_mac *mac)
313{
314 struct pasemi_mac_csring *ring;
315 u32 val;
316 unsigned int cfg;
317 int chno;
318
319 ring = pasemi_dma_alloc_chan(TXCHAN, sizeof(struct pasemi_mac_csring),
320 offsetof(struct pasemi_mac_csring, chan));
321
322 if (!ring) {
323 dev_err(&mac->pdev->dev, "Can't allocate checksum channel\n");
324 goto out_chan;
325 }
326
327 chno = ring->chan.chno;
328
329 ring->size = CS_RING_SIZE;
330 ring->next_to_fill = 0;
331
332 /* Allocate descriptors */
333 if (pasemi_dma_alloc_ring(&ring->chan, CS_RING_SIZE))
334 goto out_ring_desc;
335
336 write_dma_reg(PAS_DMA_TXCHAN_BASEL(chno),
337 PAS_DMA_TXCHAN_BASEL_BRBL(ring->chan.ring_dma));
338 val = PAS_DMA_TXCHAN_BASEU_BRBH(ring->chan.ring_dma >> 32);
339 val |= PAS_DMA_TXCHAN_BASEU_SIZ(CS_RING_SIZE >> 3);
340
341 write_dma_reg(PAS_DMA_TXCHAN_BASEU(chno), val);
342
343 ring->events[0] = pasemi_dma_alloc_flag();
344 ring->events[1] = pasemi_dma_alloc_flag();
345 if (ring->events[0] < 0 || ring->events[1] < 0)
346 goto out_flags;
347
348 pasemi_dma_clear_flag(ring->events[0]);
349 pasemi_dma_clear_flag(ring->events[1]);
350
351 ring->fun = pasemi_dma_alloc_fun();
352 if (ring->fun < 0)
353 goto out_fun;
354
355 cfg = PAS_DMA_TXCHAN_CFG_TY_FUNC | PAS_DMA_TXCHAN_CFG_UP |
356 PAS_DMA_TXCHAN_CFG_TATTR(ring->fun) |
357 PAS_DMA_TXCHAN_CFG_LPSQ | PAS_DMA_TXCHAN_CFG_LPDQ;
358
359 if (translation_enabled())
360 cfg |= PAS_DMA_TXCHAN_CFG_TRD | PAS_DMA_TXCHAN_CFG_TRR;
361
362 write_dma_reg(PAS_DMA_TXCHAN_CFG(chno), cfg);
363
364 /* enable channel */
365 pasemi_dma_start_chan(&ring->chan, PAS_DMA_TXCHAN_TCMDSTA_SZ |
366 PAS_DMA_TXCHAN_TCMDSTA_DB |
367 PAS_DMA_TXCHAN_TCMDSTA_DE |
368 PAS_DMA_TXCHAN_TCMDSTA_DA);
369
370 return ring;
371
372out_fun:
373out_flags:
374 if (ring->events[0] >= 0)
375 pasemi_dma_free_flag(ring->events[0]);
376 if (ring->events[1] >= 0)
377 pasemi_dma_free_flag(ring->events[1]);
378 pasemi_dma_free_ring(&ring->chan);
379out_ring_desc:
380 pasemi_dma_free_chan(&ring->chan);
381out_chan:
382
383 return NULL;
384}
385
386static void pasemi_mac_setup_csrings(struct pasemi_mac *mac)
387{
388 int i;
389 mac->cs[0] = pasemi_mac_setup_csring(mac);
390 if (mac->type == MAC_TYPE_XAUI)
391 mac->cs[1] = pasemi_mac_setup_csring(mac);
392 else
393 mac->cs[1] = 0;
394
395 for (i = 0; i < MAX_CS; i++)
396 if (mac->cs[i])
397 mac->num_cs++;
398}
399
400static void pasemi_mac_free_csring(struct pasemi_mac_csring *csring)
401{
402 pasemi_dma_stop_chan(&csring->chan);
403 pasemi_dma_free_flag(csring->events[0]);
404 pasemi_dma_free_flag(csring->events[1]);
405 pasemi_dma_free_ring(&csring->chan);
406 pasemi_dma_free_chan(&csring->chan);
407 pasemi_dma_free_fun(csring->fun);
408}
409
325static int pasemi_mac_setup_rx_resources(const struct net_device *dev) 410static int pasemi_mac_setup_rx_resources(const struct net_device *dev)
326{ 411{
327 struct pasemi_mac_rxring *ring; 412 struct pasemi_mac_rxring *ring;
@@ -445,7 +530,7 @@ pasemi_mac_setup_tx_resources(const struct net_device *dev)
445 cfg = PAS_DMA_TXCHAN_CFG_TY_IFACE | 530 cfg = PAS_DMA_TXCHAN_CFG_TY_IFACE |
446 PAS_DMA_TXCHAN_CFG_TATTR(mac->dma_if) | 531 PAS_DMA_TXCHAN_CFG_TATTR(mac->dma_if) |
447 PAS_DMA_TXCHAN_CFG_UP | 532 PAS_DMA_TXCHAN_CFG_UP |
448 PAS_DMA_TXCHAN_CFG_WT(2); 533 PAS_DMA_TXCHAN_CFG_WT(4);
449 534
450 if (translation_enabled()) 535 if (translation_enabled())
451 cfg |= PAS_DMA_TXCHAN_CFG_TRD | PAS_DMA_TXCHAN_CFG_TRR; 536 cfg |= PAS_DMA_TXCHAN_CFG_TRD | PAS_DMA_TXCHAN_CFG_TRR;
@@ -810,13 +895,21 @@ restart:
810 u64 mactx = TX_DESC(txring, i); 895 u64 mactx = TX_DESC(txring, i);
811 struct sk_buff *skb; 896 struct sk_buff *skb;
812 897
813 skb = TX_DESC_INFO(txring, i+1).skb;
814 nr_frags = TX_DESC_INFO(txring, i).dma;
815
816 if ((mactx & XCT_MACTX_E) || 898 if ((mactx & XCT_MACTX_E) ||
817 (*chan->status & PAS_STATUS_ERROR)) 899 (*chan->status & PAS_STATUS_ERROR))
818 pasemi_mac_tx_error(mac, mactx); 900 pasemi_mac_tx_error(mac, mactx);
819 901
902 /* Skip over control descriptors */
903 if (!(mactx & XCT_MACTX_LLEN_M)) {
904 TX_DESC(txring, i) = 0;
905 TX_DESC(txring, i+1) = 0;
906 buf_count = 2;
907 continue;
908 }
909
910 skb = TX_DESC_INFO(txring, i+1).skb;
911 nr_frags = TX_DESC_INFO(txring, i).dma;
912
820 if (unlikely(mactx & XCT_MACTX_O)) 913 if (unlikely(mactx & XCT_MACTX_O))
821 /* Not yet transmitted */ 914 /* Not yet transmitted */
822 break; 915 break;
@@ -1041,13 +1134,7 @@ static int pasemi_mac_open(struct net_device *dev)
1041{ 1134{
1042 struct pasemi_mac *mac = netdev_priv(dev); 1135 struct pasemi_mac *mac = netdev_priv(dev);
1043 unsigned int flags; 1136 unsigned int flags;
1044 int ret; 1137 int i, ret;
1045
1046 /* enable rx section */
1047 write_dma_reg(PAS_DMA_COM_RXCMD, PAS_DMA_COM_RXCMD_EN);
1048
1049 /* enable tx section */
1050 write_dma_reg(PAS_DMA_COM_TXCMD, PAS_DMA_COM_TXCMD_EN);
1051 1138
1052 flags = PAS_MAC_CFG_TXP_FCE | PAS_MAC_CFG_TXP_FPC(3) | 1139 flags = PAS_MAC_CFG_TXP_FCE | PAS_MAC_CFG_TXP_FPC(3) |
1053 PAS_MAC_CFG_TXP_SL(3) | PAS_MAC_CFG_TXP_COB(0xf) | 1140 PAS_MAC_CFG_TXP_SL(3) | PAS_MAC_CFG_TXP_COB(0xf) |
@@ -1064,6 +1151,19 @@ static int pasemi_mac_open(struct net_device *dev)
1064 if (!mac->tx) 1151 if (!mac->tx)
1065 goto out_tx_ring; 1152 goto out_tx_ring;
1066 1153
1154 /* We might already have allocated rings in case mtu was changed
1155 * before interface was brought up.
1156 */
1157 if (dev->mtu > 1500 && !mac->num_cs) {
1158 pasemi_mac_setup_csrings(mac);
1159 if (!mac->num_cs)
1160 goto out_tx_ring;
1161 }
1162
1163 /* Zero out rmon counters */
1164 for (i = 0; i < 32; i++)
1165 write_mac_reg(mac, PAS_MAC_RMON(i), 0);
1166
1067 /* 0x3ff with 33MHz clock is about 31us */ 1167 /* 0x3ff with 33MHz clock is about 31us */
1068 write_iob_reg(PAS_IOB_DMA_COM_TIMEOUTCFG, 1168 write_iob_reg(PAS_IOB_DMA_COM_TIMEOUTCFG,
1069 PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(0x3ff)); 1169 PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(0x3ff));
@@ -1247,7 +1347,7 @@ static int pasemi_mac_close(struct net_device *dev)
1247{ 1347{
1248 struct pasemi_mac *mac = netdev_priv(dev); 1348 struct pasemi_mac *mac = netdev_priv(dev);
1249 unsigned int sta; 1349 unsigned int sta;
1250 int rxch, txch; 1350 int rxch, txch, i;
1251 1351
1252 rxch = rx_ring(mac)->chan.chno; 1352 rxch = rx_ring(mac)->chan.chno;
1253 txch = tx_ring(mac)->chan.chno; 1353 txch = tx_ring(mac)->chan.chno;
@@ -1292,6 +1392,13 @@ static int pasemi_mac_close(struct net_device *dev)
1292 free_irq(mac->tx->chan.irq, mac->tx); 1392 free_irq(mac->tx->chan.irq, mac->tx);
1293 free_irq(mac->rx->chan.irq, mac->rx); 1393 free_irq(mac->rx->chan.irq, mac->rx);
1294 1394
1395 for (i = 0; i < mac->num_cs; i++) {
1396 pasemi_mac_free_csring(mac->cs[i]);
1397 mac->cs[i] = NULL;
1398 }
1399
1400 mac->num_cs = 0;
1401
1295 /* Free resources */ 1402 /* Free resources */
1296 pasemi_mac_free_rx_resources(mac); 1403 pasemi_mac_free_rx_resources(mac);
1297 pasemi_mac_free_tx_resources(mac); 1404 pasemi_mac_free_tx_resources(mac);
@@ -1299,35 +1406,113 @@ static int pasemi_mac_close(struct net_device *dev)
1299 return 0; 1406 return 0;
1300} 1407}
1301 1408
1409static void pasemi_mac_queue_csdesc(const struct sk_buff *skb,
1410 const dma_addr_t *map,
1411 const unsigned int *map_size,
1412 struct pasemi_mac_txring *txring,
1413 struct pasemi_mac_csring *csring)
1414{
1415 u64 fund;
1416 dma_addr_t cs_dest;
1417 const int nh_off = skb_network_offset(skb);
1418 const int nh_len = skb_network_header_len(skb);
1419 const int nfrags = skb_shinfo(skb)->nr_frags;
1420 int cs_size, i, fill, hdr, cpyhdr, evt;
1421 dma_addr_t csdma;
1422
1423 fund = XCT_FUN_ST | XCT_FUN_RR_8BRES |
1424 XCT_FUN_O | XCT_FUN_FUN(csring->fun) |
1425 XCT_FUN_CRM_SIG | XCT_FUN_LLEN(skb->len - nh_off) |
1426 XCT_FUN_SHL(nh_len >> 2) | XCT_FUN_SE;
1427
1428 switch (ip_hdr(skb)->protocol) {
1429 case IPPROTO_TCP:
1430 fund |= XCT_FUN_SIG_TCP4;
1431 /* TCP checksum is 16 bytes into the header */
1432 cs_dest = map[0] + skb_transport_offset(skb) + 16;
1433 break;
1434 case IPPROTO_UDP:
1435 fund |= XCT_FUN_SIG_UDP4;
1436 /* UDP checksum is 6 bytes into the header */
1437 cs_dest = map[0] + skb_transport_offset(skb) + 6;
1438 break;
1439 default:
1440 BUG();
1441 }
1442
1443 /* Do the checksum offloaded */
1444 fill = csring->next_to_fill;
1445 hdr = fill;
1446
1447 CS_DESC(csring, fill++) = fund;
1448 /* Room for 8BRES. Checksum result is really 2 bytes into it */
1449 csdma = csring->chan.ring_dma + (fill & (CS_RING_SIZE-1)) * 8 + 2;
1450 CS_DESC(csring, fill++) = 0;
1451
1452 CS_DESC(csring, fill) = XCT_PTR_LEN(map_size[0]-nh_off) | XCT_PTR_ADDR(map[0]+nh_off);
1453 for (i = 1; i <= nfrags; i++)
1454 CS_DESC(csring, fill+i) = XCT_PTR_LEN(map_size[i]) | XCT_PTR_ADDR(map[i]);
1455
1456 fill += i;
1457 if (fill & 1)
1458 fill++;
1459
1460 /* Copy the result into the TCP packet */
1461 cpyhdr = fill;
1462 CS_DESC(csring, fill++) = XCT_FUN_O | XCT_FUN_FUN(csring->fun) |
1463 XCT_FUN_LLEN(2) | XCT_FUN_SE;
1464 CS_DESC(csring, fill++) = XCT_PTR_LEN(2) | XCT_PTR_ADDR(cs_dest) | XCT_PTR_T;
1465 CS_DESC(csring, fill++) = XCT_PTR_LEN(2) | XCT_PTR_ADDR(csdma);
1466 fill++;
1467
1468 evt = !csring->last_event;
1469 csring->last_event = evt;
1470
1471 /* Event handshaking with MAC TX */
1472 CS_DESC(csring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1473 CTRL_CMD_ETYPE_SET | CTRL_CMD_REG(csring->events[evt]);
1474 CS_DESC(csring, fill++) = 0;
1475 CS_DESC(csring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1476 CTRL_CMD_ETYPE_WCLR | CTRL_CMD_REG(csring->events[!evt]);
1477 CS_DESC(csring, fill++) = 0;
1478 csring->next_to_fill = fill & (CS_RING_SIZE-1);
1479
1480 cs_size = fill - hdr;
1481 write_dma_reg(PAS_DMA_TXCHAN_INCR(csring->chan.chno), (cs_size) >> 1);
1482
1483 /* TX-side event handshaking */
1484 fill = txring->next_to_fill;
1485 TX_DESC(txring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1486 CTRL_CMD_ETYPE_WSET | CTRL_CMD_REG(csring->events[evt]);
1487 TX_DESC(txring, fill++) = 0;
1488 TX_DESC(txring, fill++) = CTRL_CMD_T | CTRL_CMD_META_EVT | CTRL_CMD_O |
1489 CTRL_CMD_ETYPE_CLR | CTRL_CMD_REG(csring->events[!evt]);
1490 TX_DESC(txring, fill++) = 0;
1491 txring->next_to_fill = fill;
1492
1493 write_dma_reg(PAS_DMA_TXCHAN_INCR(txring->chan.chno), 2);
1494
1495 return;
1496}
1497
1302static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev) 1498static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
1303{ 1499{
1304 struct pasemi_mac *mac = netdev_priv(dev); 1500 struct pasemi_mac * const mac = netdev_priv(dev);
1305 struct pasemi_mac_txring *txring; 1501 struct pasemi_mac_txring * const txring = tx_ring(mac);
1306 u64 dflags, mactx; 1502 struct pasemi_mac_csring *csring;
1503 u64 dflags = 0;
1504 u64 mactx;
1307 dma_addr_t map[MAX_SKB_FRAGS+1]; 1505 dma_addr_t map[MAX_SKB_FRAGS+1];
1308 unsigned int map_size[MAX_SKB_FRAGS+1]; 1506 unsigned int map_size[MAX_SKB_FRAGS+1];
1309 unsigned long flags; 1507 unsigned long flags;
1310 int i, nfrags; 1508 int i, nfrags;
1311 int fill; 1509 int fill;
1510 const int nh_off = skb_network_offset(skb);
1511 const int nh_len = skb_network_header_len(skb);
1312 1512
1313 dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_CRC_PAD; 1513 prefetch(&txring->ring_info);
1314
1315 if (skb->ip_summed == CHECKSUM_PARTIAL) {
1316 const unsigned char *nh = skb_network_header(skb);
1317 1514
1318 switch (ip_hdr(skb)->protocol) { 1515 dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_CRC_PAD;
1319 case IPPROTO_TCP:
1320 dflags |= XCT_MACTX_CSUM_TCP;
1321 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
1322 dflags |= XCT_MACTX_IPO(nh - skb->data);
1323 break;
1324 case IPPROTO_UDP:
1325 dflags |= XCT_MACTX_CSUM_UDP;
1326 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
1327 dflags |= XCT_MACTX_IPO(nh - skb->data);
1328 break;
1329 }
1330 }
1331 1516
1332 nfrags = skb_shinfo(skb)->nr_frags; 1517 nfrags = skb_shinfo(skb)->nr_frags;
1333 1518
@@ -1350,24 +1535,46 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
1350 } 1535 }
1351 } 1536 }
1352 1537
1353 mactx = dflags | XCT_MACTX_LLEN(skb->len); 1538 if (skb->ip_summed == CHECKSUM_PARTIAL && skb->len <= 1540) {
1539 switch (ip_hdr(skb)->protocol) {
1540 case IPPROTO_TCP:
1541 dflags |= XCT_MACTX_CSUM_TCP;
1542 dflags |= XCT_MACTX_IPH(nh_len >> 2);
1543 dflags |= XCT_MACTX_IPO(nh_off);
1544 break;
1545 case IPPROTO_UDP:
1546 dflags |= XCT_MACTX_CSUM_UDP;
1547 dflags |= XCT_MACTX_IPH(nh_len >> 2);
1548 dflags |= XCT_MACTX_IPO(nh_off);
1549 break;
1550 default:
1551 WARN_ON(1);
1552 }
1553 }
1354 1554
1355 txring = tx_ring(mac); 1555 mactx = dflags | XCT_MACTX_LLEN(skb->len);
1356 1556
1357 spin_lock_irqsave(&txring->lock, flags); 1557 spin_lock_irqsave(&txring->lock, flags);
1358 1558
1359 fill = txring->next_to_fill;
1360
1361 /* Avoid stepping on the same cache line that the DMA controller 1559 /* Avoid stepping on the same cache line that the DMA controller
1362 * is currently about to send, so leave at least 8 words available. 1560 * is currently about to send, so leave at least 8 words available.
1363 * Total free space needed is mactx + fragments + 8 1561 * Total free space needed is mactx + fragments + 8
1364 */ 1562 */
1365 if (RING_AVAIL(txring) < nfrags + 10) { 1563 if (RING_AVAIL(txring) < nfrags + 14) {
1366 /* no room -- stop the queue and wait for tx intr */ 1564 /* no room -- stop the queue and wait for tx intr */
1367 netif_stop_queue(dev); 1565 netif_stop_queue(dev);
1368 goto out_err; 1566 goto out_err;
1369 } 1567 }
1370 1568
1569 /* Queue up checksum + event descriptors, if needed */
1570 if (mac->num_cs && skb->ip_summed == CHECKSUM_PARTIAL && skb->len > 1540) {
1571 csring = mac->cs[mac->last_cs];
1572 mac->last_cs = (mac->last_cs + 1) % mac->num_cs;
1573
1574 pasemi_mac_queue_csdesc(skb, map, map_size, txring, csring);
1575 }
1576
1577 fill = txring->next_to_fill;
1371 TX_DESC(txring, fill) = mactx; 1578 TX_DESC(txring, fill) = mactx;
1372 TX_DESC_INFO(txring, fill).dma = nfrags; 1579 TX_DESC_INFO(txring, fill).dma = nfrags;
1373 fill++; 1580 fill++;
@@ -1441,12 +1648,33 @@ static int pasemi_mac_poll(struct napi_struct *napi, int budget)
1441 return pkts; 1648 return pkts;
1442} 1649}
1443 1650
1651#ifdef CONFIG_NET_POLL_CONTROLLER
1652/*
1653 * Polling 'interrupt' - used by things like netconsole to send skbs
1654 * without having to re-enable interrupts. It's not called while
1655 * the interrupt routine is executing.
1656 */
1657static void pasemi_mac_netpoll(struct net_device *dev)
1658{
1659 const struct pasemi_mac *mac = netdev_priv(dev);
1660
1661 disable_irq(mac->tx->chan.irq);
1662 pasemi_mac_tx_intr(mac->tx->chan.irq, mac->tx);
1663 enable_irq(mac->tx->chan.irq);
1664
1665 disable_irq(mac->rx->chan.irq);
1666 pasemi_mac_rx_intr(mac->rx->chan.irq, mac->rx);
1667 enable_irq(mac->rx->chan.irq);
1668}
1669#endif
1670
1444static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu) 1671static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1445{ 1672{
1446 struct pasemi_mac *mac = netdev_priv(dev); 1673 struct pasemi_mac *mac = netdev_priv(dev);
1447 unsigned int reg; 1674 unsigned int reg;
1448 unsigned int rcmdsta; 1675 unsigned int rcmdsta = 0;
1449 int running; 1676 int running;
1677 int ret = 0;
1450 1678
1451 if (new_mtu < PE_MIN_MTU || new_mtu > PE_MAX_MTU) 1679 if (new_mtu < PE_MIN_MTU || new_mtu > PE_MAX_MTU)
1452 return -EINVAL; 1680 return -EINVAL;
@@ -1468,6 +1696,16 @@ static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1468 pasemi_mac_pause_rxint(mac); 1696 pasemi_mac_pause_rxint(mac);
1469 pasemi_mac_clean_rx(rx_ring(mac), RX_RING_SIZE); 1697 pasemi_mac_clean_rx(rx_ring(mac), RX_RING_SIZE);
1470 pasemi_mac_free_rx_buffers(mac); 1698 pasemi_mac_free_rx_buffers(mac);
1699
1700 }
1701
1702 /* Setup checksum channels if large MTU and none already allocated */
1703 if (new_mtu > 1500 && !mac->num_cs) {
1704 pasemi_mac_setup_csrings(mac);
1705 if (!mac->num_cs) {
1706 ret = -ENOMEM;
1707 goto out;
1708 }
1471 } 1709 }
1472 1710
1473 /* Change maxf, i.e. what size frames are accepted. 1711 /* Change maxf, i.e. what size frames are accepted.
@@ -1482,6 +1720,7 @@ static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1482 /* MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */ 1720 /* MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
1483 mac->bufsz = new_mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128; 1721 mac->bufsz = new_mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128;
1484 1722
1723out:
1485 if (running) { 1724 if (running) {
1486 write_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if), 1725 write_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if),
1487 rcmdsta | PAS_DMA_RXINT_RCMDSTA_EN); 1726 rcmdsta | PAS_DMA_RXINT_RCMDSTA_EN);
@@ -1494,7 +1733,7 @@ static int pasemi_mac_change_mtu(struct net_device *dev, int new_mtu)
1494 pasemi_mac_intf_enable(mac); 1733 pasemi_mac_intf_enable(mac);
1495 } 1734 }
1496 1735
1497 return 0; 1736 return ret;
1498} 1737}
1499 1738
1500static int __devinit 1739static int __devinit
@@ -1528,7 +1767,7 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1528 netif_napi_add(dev, &mac->napi, pasemi_mac_poll, 64); 1767 netif_napi_add(dev, &mac->napi, pasemi_mac_poll, 64);
1529 1768
1530 dev->features = NETIF_F_IP_CSUM | NETIF_F_LLTX | NETIF_F_SG | 1769 dev->features = NETIF_F_IP_CSUM | NETIF_F_LLTX | NETIF_F_SG |
1531 NETIF_F_HIGHDMA; 1770 NETIF_F_HIGHDMA | NETIF_F_GSO;
1532 1771
1533 mac->lro_mgr.max_aggr = LRO_MAX_AGGR; 1772 mac->lro_mgr.max_aggr = LRO_MAX_AGGR;
1534 mac->lro_mgr.max_desc = MAX_LRO_DESCRIPTORS; 1773 mac->lro_mgr.max_desc = MAX_LRO_DESCRIPTORS;
@@ -1588,8 +1827,12 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1588 dev->mtu = PE_DEF_MTU; 1827 dev->mtu = PE_DEF_MTU;
1589 /* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */ 1828 /* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
1590 mac->bufsz = dev->mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128; 1829 mac->bufsz = dev->mtu + ETH_HLEN + ETH_FCS_LEN + LOCAL_SKB_ALIGN + 128;
1830#ifdef CONFIG_NET_POLL_CONTROLLER
1831 dev->poll_controller = pasemi_mac_netpoll;
1832#endif
1591 1833
1592 dev->change_mtu = pasemi_mac_change_mtu; 1834 dev->change_mtu = pasemi_mac_change_mtu;
1835 dev->ethtool_ops = &pasemi_mac_ethtool_ops;
1593 1836
1594 if (err) 1837 if (err)
1595 goto out; 1838 goto out;
diff --git a/drivers/net/pasemi_mac.h b/drivers/net/pasemi_mac.h
index 99e7b9329a6f..1a115ec60b53 100644
--- a/drivers/net/pasemi_mac.h
+++ b/drivers/net/pasemi_mac.h
@@ -26,7 +26,14 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/phy.h> 27#include <linux/phy.h>
28 28
29/* Must be a power of two */
30#define RX_RING_SIZE 2048
31#define TX_RING_SIZE 4096
32#define CS_RING_SIZE (TX_RING_SIZE*2)
33
34
29#define MAX_LRO_DESCRIPTORS 8 35#define MAX_LRO_DESCRIPTORS 8
36#define MAX_CS 2
30 37
31struct pasemi_mac_txring { 38struct pasemi_mac_txring {
32 struct pasemi_dmachan chan; /* Must be first */ 39 struct pasemi_dmachan chan; /* Must be first */
@@ -51,6 +58,15 @@ struct pasemi_mac_rxring {
51 struct pasemi_mac *mac; /* Needed in intr handler */ 58 struct pasemi_mac *mac; /* Needed in intr handler */
52}; 59};
53 60
61struct pasemi_mac_csring {
62 struct pasemi_dmachan chan;
63 unsigned int size;
64 unsigned int next_to_fill;
65 int events[2];
66 int last_event;
67 int fun;
68};
69
54struct pasemi_mac { 70struct pasemi_mac {
55 struct net_device *netdev; 71 struct net_device *netdev;
56 struct pci_dev *pdev; 72 struct pci_dev *pdev;
@@ -60,10 +76,12 @@ struct pasemi_mac {
60 struct napi_struct napi; 76 struct napi_struct napi;
61 77
62 int bufsz; /* RX ring buffer size */ 78 int bufsz; /* RX ring buffer size */
79 int last_cs;
80 int num_cs;
81 u32 dma_if;
63 u8 type; 82 u8 type;
64#define MAC_TYPE_GMAC 1 83#define MAC_TYPE_GMAC 1
65#define MAC_TYPE_XAUI 2 84#define MAC_TYPE_XAUI 2
66 u32 dma_if;
67 85
68 u8 mac_addr[6]; 86 u8 mac_addr[6];
69 87
@@ -74,6 +92,7 @@ struct pasemi_mac {
74 92
75 struct pasemi_mac_txring *tx; 93 struct pasemi_mac_txring *tx;
76 struct pasemi_mac_rxring *rx; 94 struct pasemi_mac_rxring *rx;
95 struct pasemi_mac_csring *cs[MAX_CS];
77 char tx_irq_name[10]; /* "eth%d tx" */ 96 char tx_irq_name[10]; /* "eth%d tx" */
78 char rx_irq_name[10]; /* "eth%d rx" */ 97 char rx_irq_name[10]; /* "eth%d rx" */
79 int link; 98 int link;
@@ -90,6 +109,16 @@ struct pasemi_mac_buffer {
90 dma_addr_t dma; 109 dma_addr_t dma;
91}; 110};
92 111
112#define TX_DESC(tx, num) ((tx)->chan.ring_virt[(num) & (TX_RING_SIZE-1)])
113#define TX_DESC_INFO(tx, num) ((tx)->ring_info[(num) & (TX_RING_SIZE-1)])
114#define RX_DESC(rx, num) ((rx)->chan.ring_virt[(num) & (RX_RING_SIZE-1)])
115#define RX_DESC_INFO(rx, num) ((rx)->ring_info[(num) & (RX_RING_SIZE-1)])
116#define RX_BUFF(rx, num) ((rx)->buffers[(num) & (RX_RING_SIZE-1)])
117#define CS_DESC(cs, num) ((cs)->chan.ring_virt[(num) & (CS_RING_SIZE-1)])
118
119#define RING_USED(ring) (((ring)->next_to_fill - (ring)->next_to_clean) \
120 & ((ring)->size - 1))
121#define RING_AVAIL(ring) ((ring->size) - RING_USED(ring))
93 122
94/* PCI register offsets and formats */ 123/* PCI register offsets and formats */
95 124
@@ -101,6 +130,7 @@ enum {
101 PAS_MAC_CFG_ADR0 = 0x8c, 130 PAS_MAC_CFG_ADR0 = 0x8c,
102 PAS_MAC_CFG_ADR1 = 0x90, 131 PAS_MAC_CFG_ADR1 = 0x90,
103 PAS_MAC_CFG_TXP = 0x98, 132 PAS_MAC_CFG_TXP = 0x98,
133 PAS_MAC_CFG_RMON = 0x100,
104 PAS_MAC_IPC_CHNL = 0x208, 134 PAS_MAC_IPC_CHNL = 0x208,
105}; 135};
106 136
@@ -172,6 +202,8 @@ enum {
172#define PAS_MAC_CFG_TXP_TIFG(x) (((x) << PAS_MAC_CFG_TXP_TIFG_S) & \ 202#define PAS_MAC_CFG_TXP_TIFG(x) (((x) << PAS_MAC_CFG_TXP_TIFG_S) & \
173 PAS_MAC_CFG_TXP_TIFG_M) 203 PAS_MAC_CFG_TXP_TIFG_M)
174 204
205#define PAS_MAC_RMON(r) (0x100+(r)*4)
206
175#define PAS_MAC_IPC_CHNL_DCHNO_M 0x003f0000 207#define PAS_MAC_IPC_CHNL_DCHNO_M 0x003f0000
176#define PAS_MAC_IPC_CHNL_DCHNO_S 16 208#define PAS_MAC_IPC_CHNL_DCHNO_S 16
177#define PAS_MAC_IPC_CHNL_DCHNO(x) (((x) << PAS_MAC_IPC_CHNL_DCHNO_S) & \ 209#define PAS_MAC_IPC_CHNL_DCHNO(x) (((x) << PAS_MAC_IPC_CHNL_DCHNO_S) & \
@@ -181,4 +213,5 @@ enum {
181#define PAS_MAC_IPC_CHNL_BCH(x) (((x) << PAS_MAC_IPC_CHNL_BCH_S) & \ 213#define PAS_MAC_IPC_CHNL_BCH(x) (((x) << PAS_MAC_IPC_CHNL_BCH_S) & \
182 PAS_MAC_IPC_CHNL_BCH_M) 214 PAS_MAC_IPC_CHNL_BCH_M)
183 215
216
184#endif /* PASEMI_MAC_H */ 217#endif /* PASEMI_MAC_H */
diff --git a/drivers/net/pasemi_mac_ethtool.c b/drivers/net/pasemi_mac_ethtool.c
new file mode 100644
index 000000000000..5e8df3afea64
--- /dev/null
+++ b/drivers/net/pasemi_mac_ethtool.c
@@ -0,0 +1,159 @@
1/*
2 * Copyright (C) 2006-2008 PA Semi, Inc
3 *
4 * Ethtool hooks for the PA Semi PWRficient onchip 1G/10G Ethernet MACs
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20
21#include <linux/netdevice.h>
22#include <linux/ethtool.h>
23#include <linux/pci.h>
24#include <linux/inet_lro.h>
25
26#include <asm/pasemi_dma.h>
27#include "pasemi_mac.h"
28
29static struct {
30 const char str[ETH_GSTRING_LEN];
31} ethtool_stats_keys[] = {
32 { "rx-drops" },
33 { "rx-bytes" },
34 { "rx-packets" },
35 { "rx-broadcast-packets" },
36 { "rx-multicast-packets" },
37 { "rx-crc-errors" },
38 { "rx-undersize-errors" },
39 { "rx-oversize-errors" },
40 { "rx-short-fragment-errors" },
41 { "rx-jabber-errors" },
42 { "rx-64-byte-packets" },
43 { "rx-65-127-byte-packets" },
44 { "rx-128-255-byte-packets" },
45 { "rx-256-511-byte-packets" },
46 { "rx-512-1023-byte-packets" },
47 { "rx-1024-1518-byte-packets" },
48 { "rx-pause-frames" },
49 { "tx-bytes" },
50 { "tx-packets" },
51 { "tx-broadcast-packets" },
52 { "tx-multicast-packets" },
53 { "tx-collisions" },
54 { "tx-late-collisions" },
55 { "tx-excessive-collisions" },
56 { "tx-crc-errors" },
57 { "tx-undersize-errors" },
58 { "tx-oversize-errors" },
59 { "tx-64-byte-packets" },
60 { "tx-65-127-byte-packets" },
61 { "tx-128-255-byte-packets" },
62 { "tx-256-511-byte-packets" },
63 { "tx-512-1023-byte-packets" },
64 { "tx-1024-1518-byte-packets" },
65};
66
67static int
68pasemi_mac_ethtool_get_settings(struct net_device *netdev,
69 struct ethtool_cmd *cmd)
70{
71 struct pasemi_mac *mac = netdev_priv(netdev);
72 struct phy_device *phydev = mac->phydev;
73
74 return phy_ethtool_gset(phydev, cmd);
75}
76
77static void
78pasemi_mac_ethtool_get_drvinfo(struct net_device *netdev,
79 struct ethtool_drvinfo *drvinfo)
80{
81 struct pasemi_mac *mac;
82 mac = netdev_priv(netdev);
83
84 /* clear and fill out info */
85 memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
86 strncpy(drvinfo->driver, "pasemi_mac", 12);
87 strcpy(drvinfo->version, "N/A");
88 strcpy(drvinfo->fw_version, "N/A");
89 strncpy(drvinfo->bus_info, pci_name(mac->pdev), 32);
90}
91
92static u32
93pasemi_mac_ethtool_get_msglevel(struct net_device *netdev)
94{
95 struct pasemi_mac *mac = netdev_priv(netdev);
96 return mac->msg_enable;
97}
98
99static void
100pasemi_mac_ethtool_set_msglevel(struct net_device *netdev,
101 u32 level)
102{
103 struct pasemi_mac *mac = netdev_priv(netdev);
104 mac->msg_enable = level;
105}
106
107
108static void
109pasemi_mac_ethtool_get_ringparam(struct net_device *netdev,
110 struct ethtool_ringparam *ering)
111{
112 struct pasemi_mac *mac = netdev->priv;
113
114 ering->tx_max_pending = TX_RING_SIZE/2;
115 ering->tx_pending = RING_USED(mac->tx)/2;
116 ering->rx_max_pending = RX_RING_SIZE/4;
117 ering->rx_pending = RING_USED(mac->rx)/4;
118}
119
120static int pasemi_mac_get_sset_count(struct net_device *netdev, int sset)
121{
122 switch (sset) {
123 case ETH_SS_STATS:
124 return ARRAY_SIZE(ethtool_stats_keys);
125 default:
126 return -EOPNOTSUPP;
127 }
128}
129
130static void pasemi_mac_get_ethtool_stats(struct net_device *netdev,
131 struct ethtool_stats *stats, u64 *data)
132{
133 struct pasemi_mac *mac = netdev->priv;
134 int i;
135
136 data[0] = pasemi_read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if))
137 >> PAS_DMA_RXINT_RCMDSTA_DROPS_S;
138 for (i = 0; i < 32; i++)
139 data[1+i] = pasemi_read_mac_reg(mac->dma_if, PAS_MAC_RMON(i));
140}
141
142static void pasemi_mac_get_strings(struct net_device *netdev, u32 stringset,
143 u8 *data)
144{
145 memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
146}
147
148const struct ethtool_ops pasemi_mac_ethtool_ops = {
149 .get_settings = pasemi_mac_ethtool_get_settings,
150 .get_drvinfo = pasemi_mac_ethtool_get_drvinfo,
151 .get_msglevel = pasemi_mac_ethtool_get_msglevel,
152 .set_msglevel = pasemi_mac_ethtool_set_msglevel,
153 .get_link = ethtool_op_get_link,
154 .get_ringparam = pasemi_mac_ethtool_get_ringparam,
155 .get_strings = pasemi_mac_get_strings,
156 .get_sset_count = pasemi_mac_get_sset_count,
157 .get_ethtool_stats = pasemi_mac_get_ethtool_stats,
158};
159
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index 7eb6e7e848f4..e365efb3c627 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -1266,6 +1266,85 @@ int gelic_net_set_rx_csum(struct net_device *netdev, u32 data)
1266 return 0; 1266 return 0;
1267} 1267}
1268 1268
1269static void gelic_net_get_wol(struct net_device *netdev,
1270 struct ethtool_wolinfo *wol)
1271{
1272 if (0 <= ps3_compare_firmware_version(2, 2, 0))
1273 wol->supported = WAKE_MAGIC;
1274 else
1275 wol->supported = 0;
1276
1277 wol->wolopts = ps3_sys_manager_get_wol() ? wol->supported : 0;
1278 memset(&wol->sopass, 0, sizeof(wol->sopass));
1279}
1280static int gelic_net_set_wol(struct net_device *netdev,
1281 struct ethtool_wolinfo *wol)
1282{
1283 int status;
1284 struct gelic_card *card;
1285 u64 v1, v2;
1286
1287 if (ps3_compare_firmware_version(2, 2, 0) < 0 ||
1288 !capable(CAP_NET_ADMIN))
1289 return -EPERM;
1290
1291 if (wol->wolopts & ~WAKE_MAGIC)
1292 return -EINVAL;
1293
1294 card = netdev_card(netdev);
1295 if (wol->wolopts & WAKE_MAGIC) {
1296 status = lv1_net_control(bus_id(card), dev_id(card),
1297 GELIC_LV1_SET_WOL,
1298 GELIC_LV1_WOL_MAGIC_PACKET,
1299 0, GELIC_LV1_WOL_MP_ENABLE,
1300 &v1, &v2);
1301 if (status) {
1302 pr_info("%s: enabling WOL failed %d\n", __func__,
1303 status);
1304 status = -EIO;
1305 goto done;
1306 }
1307 status = lv1_net_control(bus_id(card), dev_id(card),
1308 GELIC_LV1_SET_WOL,
1309 GELIC_LV1_WOL_ADD_MATCH_ADDR,
1310 0, GELIC_LV1_WOL_MATCH_ALL,
1311 &v1, &v2);
1312 if (!status)
1313 ps3_sys_manager_set_wol(1);
1314 else {
1315 pr_info("%s: enabling WOL filter failed %d\n",
1316 __func__, status);
1317 status = -EIO;
1318 }
1319 } else {
1320 status = lv1_net_control(bus_id(card), dev_id(card),
1321 GELIC_LV1_SET_WOL,
1322 GELIC_LV1_WOL_MAGIC_PACKET,
1323 0, GELIC_LV1_WOL_MP_DISABLE,
1324 &v1, &v2);
1325 if (status) {
1326 pr_info("%s: disabling WOL failed %d\n", __func__,
1327 status);
1328 status = -EIO;
1329 goto done;
1330 }
1331 status = lv1_net_control(bus_id(card), dev_id(card),
1332 GELIC_LV1_SET_WOL,
1333 GELIC_LV1_WOL_DELETE_MATCH_ADDR,
1334 0, GELIC_LV1_WOL_MATCH_ALL,
1335 &v1, &v2);
1336 if (!status)
1337 ps3_sys_manager_set_wol(0);
1338 else {
1339 pr_info("%s: removing WOL filter failed %d\n",
1340 __func__, status);
1341 status = -EIO;
1342 }
1343 }
1344done:
1345 return status;
1346}
1347
1269static struct ethtool_ops gelic_ether_ethtool_ops = { 1348static struct ethtool_ops gelic_ether_ethtool_ops = {
1270 .get_drvinfo = gelic_net_get_drvinfo, 1349 .get_drvinfo = gelic_net_get_drvinfo,
1271 .get_settings = gelic_ether_get_settings, 1350 .get_settings = gelic_ether_get_settings,
@@ -1274,6 +1353,8 @@ static struct ethtool_ops gelic_ether_ethtool_ops = {
1274 .set_tx_csum = ethtool_op_set_tx_csum, 1353 .set_tx_csum = ethtool_op_set_tx_csum,
1275 .get_rx_csum = gelic_net_get_rx_csum, 1354 .get_rx_csum = gelic_net_get_rx_csum,
1276 .set_rx_csum = gelic_net_set_rx_csum, 1355 .set_rx_csum = gelic_net_set_rx_csum,
1356 .get_wol = gelic_net_get_wol,
1357 .set_wol = gelic_net_set_wol,
1277}; 1358};
1278 1359
1279/** 1360/**
diff --git a/drivers/net/ps3_gelic_net.h b/drivers/net/ps3_gelic_net.h
index 1d39d06797e4..520f143c2c09 100644
--- a/drivers/net/ps3_gelic_net.h
+++ b/drivers/net/ps3_gelic_net.h
@@ -182,12 +182,32 @@ enum gelic_lv1_net_control_code {
182 GELIC_LV1_GET_ETH_PORT_STATUS = 2, 182 GELIC_LV1_GET_ETH_PORT_STATUS = 2,
183 GELIC_LV1_SET_NEGOTIATION_MODE = 3, 183 GELIC_LV1_SET_NEGOTIATION_MODE = 3,
184 GELIC_LV1_GET_VLAN_ID = 4, 184 GELIC_LV1_GET_VLAN_ID = 4,
185 GELIC_LV1_SET_WOL = 5,
185 GELIC_LV1_GET_CHANNEL = 6, 186 GELIC_LV1_GET_CHANNEL = 6,
186 GELIC_LV1_POST_WLAN_CMD = 9, 187 GELIC_LV1_POST_WLAN_CMD = 9,
187 GELIC_LV1_GET_WLAN_CMD_RESULT = 10, 188 GELIC_LV1_GET_WLAN_CMD_RESULT = 10,
188 GELIC_LV1_GET_WLAN_EVENT = 11 189 GELIC_LV1_GET_WLAN_EVENT = 11
189}; 190};
190 191
192/* for GELIC_LV1_SET_WOL */
193enum gelic_lv1_wol_command {
194 GELIC_LV1_WOL_MAGIC_PACKET = 1,
195 GELIC_LV1_WOL_ADD_MATCH_ADDR = 6,
196 GELIC_LV1_WOL_DELETE_MATCH_ADDR = 7,
197};
198
199/* for GELIC_LV1_WOL_MAGIC_PACKET */
200enum gelic_lv1_wol_mp_arg {
201 GELIC_LV1_WOL_MP_DISABLE = 0,
202 GELIC_LV1_WOL_MP_ENABLE = 1,
203};
204
205/* for GELIC_LV1_WOL_{ADD,DELETE}_MATCH_ADDR */
206enum gelic_lv1_wol_match_arg {
207 GELIC_LV1_WOL_MATCH_INDIVIDUAL = 0,
208 GELIC_LV1_WOL_MATCH_ALL = 1,
209};
210
191/* status returened from GET_ETH_PORT_STATUS */ 211/* status returened from GET_ETH_PORT_STATUS */
192enum gelic_lv1_ether_port_status { 212enum gelic_lv1_ether_port_status {
193 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L, 213 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L,
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 96043c5746d0..bc4c62b8e81a 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -64,8 +64,8 @@
64 64
65#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
66#define PFX DRV_MODULE_NAME ": " 66#define PFX DRV_MODULE_NAME ": "
67#define DRV_MODULE_VERSION "3.90" 67#define DRV_MODULE_VERSION "3.91"
68#define DRV_MODULE_RELDATE "April 12, 2008" 68#define DRV_MODULE_RELDATE "April 18, 2008"
69 69
70#define TG3_DEF_MAC_MODE 0 70#define TG3_DEF_MAC_MODE 0
71#define TG3_DEF_RX_MODE 0 71#define TG3_DEF_RX_MODE 0
@@ -4135,11 +4135,21 @@ static int tigon3_dma_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
4135 u32 last_plus_one, u32 *start, 4135 u32 last_plus_one, u32 *start,
4136 u32 base_flags, u32 mss) 4136 u32 base_flags, u32 mss)
4137{ 4137{
4138 struct sk_buff *new_skb = skb_copy(skb, GFP_ATOMIC); 4138 struct sk_buff *new_skb;
4139 dma_addr_t new_addr = 0; 4139 dma_addr_t new_addr = 0;
4140 u32 entry = *start; 4140 u32 entry = *start;
4141 int i, ret = 0; 4141 int i, ret = 0;
4142 4142
4143 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)
4144 new_skb = skb_copy(skb, GFP_ATOMIC);
4145 else {
4146 int more_headroom = 4 - ((unsigned long)skb->data & 3);
4147
4148 new_skb = skb_copy_expand(skb,
4149 skb_headroom(skb) + more_headroom,
4150 skb_tailroom(skb), GFP_ATOMIC);
4151 }
4152
4143 if (!new_skb) { 4153 if (!new_skb) {
4144 ret = -1; 4154 ret = -1;
4145 } else { 4155 } else {
@@ -4462,7 +4472,9 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
4462 4472
4463 would_hit_hwbug = 0; 4473 would_hit_hwbug = 0;
4464 4474
4465 if (tg3_4g_overflow_test(mapping, len)) 4475 if (tp->tg3_flags3 & TG3_FLG3_5701_DMA_BUG)
4476 would_hit_hwbug = 1;
4477 else if (tg3_4g_overflow_test(mapping, len))
4466 would_hit_hwbug = 1; 4478 would_hit_hwbug = 1;
4467 4479
4468 tg3_set_txd(tp, entry, mapping, len, base_flags, 4480 tg3_set_txd(tp, entry, mapping, len, base_flags,
@@ -11339,6 +11351,38 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
11339 } 11351 }
11340 } 11352 }
11341 11353
11354 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) {
11355 static struct tg3_dev_id {
11356 u32 vendor;
11357 u32 device;
11358 } bridge_chipsets[] = {
11359 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_0 },
11360 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1 },
11361 { },
11362 };
11363 struct tg3_dev_id *pci_id = &bridge_chipsets[0];
11364 struct pci_dev *bridge = NULL;
11365
11366 while (pci_id->vendor != 0) {
11367 bridge = pci_get_device(pci_id->vendor,
11368 pci_id->device,
11369 bridge);
11370 if (!bridge) {
11371 pci_id++;
11372 continue;
11373 }
11374 if (bridge->subordinate &&
11375 (bridge->subordinate->number <=
11376 tp->pdev->bus->number) &&
11377 (bridge->subordinate->subordinate >=
11378 tp->pdev->bus->number)) {
11379 tp->tg3_flags3 |= TG3_FLG3_5701_DMA_BUG;
11380 pci_dev_put(bridge);
11381 break;
11382 }
11383 }
11384 }
11385
11342 /* The EPB bridge inside 5714, 5715, and 5780 cannot support 11386 /* The EPB bridge inside 5714, 5715, and 5780 cannot support
11343 * DMA addresses > 40-bit. This bridge may have other additional 11387 * DMA addresses > 40-bit. This bridge may have other additional
11344 * 57xx devices behind it in some 4-port NIC designs for example. 11388 * 57xx devices behind it in some 4-port NIC designs for example.
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index c1075a73d66c..c688c3ac5035 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2476,6 +2476,7 @@ struct tg3 {
2476#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001 2476#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001
2477#define TG3_FLG3_ENABLE_APE 0x00000002 2477#define TG3_FLG3_ENABLE_APE 0x00000002
2478#define TG3_FLG3_5761_5784_AX_FIXES 0x00000004 2478#define TG3_FLG3_5761_5784_AX_FIXES 0x00000004
2479#define TG3_FLG3_5701_DMA_BUG 0x00000008
2479 2480
2480 struct timer_list timer; 2481 struct timer_list timer;
2481 u16 timer_counter; 2482 u16 timer_counter;
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 29a4d650e8a8..2f11254bcc07 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -3853,7 +3853,13 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3853 3853
3854 ugeth_vdbg("%s: IN", __FUNCTION__); 3854 ugeth_vdbg("%s: IN", __FUNCTION__);
3855 3855
3856 prop = of_get_property(np, "device-id", NULL); 3856 prop = of_get_property(np, "cell-index", NULL);
3857 if (!prop) {
3858 prop = of_get_property(np, "device-id", NULL);
3859 if (!prop)
3860 return -ENODEV;
3861 }
3862
3857 ucc_num = *prop - 1; 3863 ucc_num = *prop - 1;
3858 if ((ucc_num < 0) || (ucc_num > 7)) 3864 if ((ucc_num < 0) || (ucc_num > 7))
3859 return -ENODEV; 3865 return -ENODEV;
diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index e4d3f330bac3..2af490781005 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -203,9 +203,14 @@ static int uec_mdio_probe(struct of_device *ofdev, const struct of_device_id *ma
203 if ((res.start >= tempres.start) && 203 if ((res.start >= tempres.start) &&
204 (res.end <= tempres.end)) { 204 (res.end <= tempres.end)) {
205 /* set this UCC to be the MII master */ 205 /* set this UCC to be the MII master */
206 const u32 *id = of_get_property(tempnp, "device-id", NULL); 206 const u32 *id;
207 if (id == NULL) 207
208 goto bus_register_fail; 208 id = of_get_property(tempnp, "cell-index", NULL);
209 if (!id) {
210 id = of_get_property(tempnp, "device-id", NULL);
211 if (!id)
212 goto bus_register_fail;
213 }
209 214
210 ucc_set_qe_mux_mii_mng(*id - 1); 215 ucc_set_qe_mux_mii_mng(*id - 1);
211 216
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 569ad8bfd383..0dcfc0310264 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -58,7 +58,6 @@
58#include <linux/dma-mapping.h> 58#include <linux/dma-mapping.h>
59#include <linux/wait.h> 59#include <linux/wait.h>
60#include <asm/uaccess.h> 60#include <asm/uaccess.h>
61#include <asm/semaphore.h>
62#include <asm/byteorder.h> 61#include <asm/byteorder.h>
63 62
64#undef DEBUG 63#undef DEBUG
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c
index 0aac1ff511df..36a9c42df835 100644
--- a/drivers/net/wireless/b43/leds.c
+++ b/drivers/net/wireless/b43/leds.c
@@ -116,10 +116,7 @@ static void b43_unregister_led(struct b43_led *led)
116{ 116{
117 if (!led->dev) 117 if (!led->dev)
118 return; 118 return;
119 if (led->dev->suspend_in_progress) 119 led_classdev_unregister(&led->led_dev);
120 led_classdev_unregister_suspended(&led->led_dev);
121 else
122 led_classdev_unregister(&led->led_dev);
123 b43_led_turn_off(led->dev, led->index, led->activelow); 120 b43_led_turn_off(led->dev, led->index, led->activelow);
124 led->dev = NULL; 121 led->dev = NULL;
125} 122}
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index cf5c046c9fa8..943cc851c504 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2804,10 +2804,10 @@ static int b43_rng_read(struct hwrng *rng, u32 * data)
2804 return (sizeof(u16)); 2804 return (sizeof(u16));
2805} 2805}
2806 2806
2807static void b43_rng_exit(struct b43_wl *wl, bool suspended) 2807static void b43_rng_exit(struct b43_wl *wl)
2808{ 2808{
2809 if (wl->rng_initialized) 2809 if (wl->rng_initialized)
2810 __hwrng_unregister(&wl->rng, suspended); 2810 hwrng_unregister(&wl->rng);
2811} 2811}
2812 2812
2813static int b43_rng_init(struct b43_wl *wl) 2813static int b43_rng_init(struct b43_wl *wl)
@@ -3824,7 +3824,7 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
3824 3824
3825 if (!dev->suspend_in_progress) { 3825 if (!dev->suspend_in_progress) {
3826 b43_leds_exit(dev); 3826 b43_leds_exit(dev);
3827 b43_rng_exit(dev->wl, false); 3827 b43_rng_exit(dev->wl);
3828 } 3828 }
3829 b43_dma_free(dev); 3829 b43_dma_free(dev);
3830 b43_pio_free(dev); 3830 b43_pio_free(dev);
@@ -4589,7 +4589,7 @@ static int b43_resume(struct ssb_device *dev)
4589 err = b43_wireless_core_start(wldev); 4589 err = b43_wireless_core_start(wldev);
4590 if (err) { 4590 if (err) {
4591 b43_leds_exit(wldev); 4591 b43_leds_exit(wldev);
4592 b43_rng_exit(wldev->wl, true); 4592 b43_rng_exit(wldev->wl);
4593 b43_wireless_core_exit(wldev); 4593 b43_wireless_core_exit(wldev);
4594 b43err(wl, "Resume failed at core start\n"); 4594 b43err(wl, "Resume failed at core start\n");
4595 goto out; 4595 goto out;
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 0f16f2606f29..9a30e1df311d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -239,28 +239,34 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
239 "ps_status: %u\n", station->ps_status); 239 "ps_status: %u\n", station->ps_status);
240 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); 240 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
241 pos += scnprintf(buf + pos, bufsz - pos, 241 pos += scnprintf(buf + pos, bufsz - pos,
242 "seq_num\t\ttxq_id\t"); 242 "seq_num\t\ttxq_id");
243#ifdef CONFIG_IWL4965_HT
243 pos += scnprintf(buf + pos, bufsz - pos, 244 pos += scnprintf(buf + pos, bufsz - pos,
244 "frame_count\twait_for_ba\t"); 245 "\tframe_count\twait_for_ba\t");
245 pos += scnprintf(buf + pos, bufsz - pos, 246 pos += scnprintf(buf + pos, bufsz - pos,
246 "start_idx\tbitmap0\t"); 247 "start_idx\tbitmap0\t");
247 pos += scnprintf(buf + pos, bufsz - pos, 248 pos += scnprintf(buf + pos, bufsz - pos,
248 "bitmap1\trate_n_flags\n"); 249 "bitmap1\trate_n_flags");
250#endif
251 pos += scnprintf(buf + pos, bufsz - pos, "\n");
249 252
250 for (j = 0; j < MAX_TID_COUNT; j++) { 253 for (j = 0; j < MAX_TID_COUNT; j++) {
251 pos += scnprintf(buf + pos, bufsz - pos, 254 pos += scnprintf(buf + pos, bufsz - pos,
252 "[%d]:\t\t%u\t", j, 255 "[%d]:\t\t%u", j,
253 station->tid[j].seq_number); 256 station->tid[j].seq_number);
257#ifdef CONFIG_IWL4965_HT
254 pos += scnprintf(buf + pos, bufsz - pos, 258 pos += scnprintf(buf + pos, bufsz - pos,
255 "%u\t\t%u\t\t%u\t\t", 259 "\t%u\t\t%u\t\t%u\t\t",
256 station->tid[j].agg.txq_id, 260 station->tid[j].agg.txq_id,
257 station->tid[j].agg.frame_count, 261 station->tid[j].agg.frame_count,
258 station->tid[j].agg.wait_for_ba); 262 station->tid[j].agg.wait_for_ba);
259 pos += scnprintf(buf + pos, bufsz - pos, 263 pos += scnprintf(buf + pos, bufsz - pos,
260 "%u\t%llu\t%u\n", 264 "%u\t%llu\t%u",
261 station->tid[j].agg.start_idx, 265 station->tid[j].agg.start_idx,
262 (unsigned long long)station->tid[j].agg.bitmap, 266 (unsigned long long)station->tid[j].agg.bitmap,
263 station->tid[j].agg.rate_n_flags); 267 station->tid[j].agg.rate_n_flags);
268#endif
269 pos += scnprintf(buf + pos, bufsz - pos, "\n");
264 } 270 }
265 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 271 pos += scnprintf(buf + pos, bufsz - pos, "\n");
266 } 272 }
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index c03072b12f42..3a7a11a75fb4 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -1,3 +1,15 @@
1config OF_DEVICE 1config OF_DEVICE
2 def_bool y 2 def_bool y
3 depends on OF && (SPARC || PPC_OF) 3 depends on OF && (SPARC || PPC_OF)
4
5config OF_GPIO
6 def_bool y
7 depends on OF && PPC_OF && HAVE_GPIO_LIB
8 help
9 OpenFirmware GPIO accessors
10
11config OF_I2C
12 def_tristate I2C
13 depends on PPC_OF && I2C
14 help
15 OpenFirmware I2C accessors
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index ab9be5d5255b..548772e871fd 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -1,2 +1,4 @@
1obj-y = base.o 1obj-y = base.o
2obj-$(CONFIG_OF_DEVICE) += device.o platform.o 2obj-$(CONFIG_OF_DEVICE) += device.o platform.o
3obj-$(CONFIG_OF_GPIO) += gpio.o
4obj-$(CONFIG_OF_I2C) += of_i2c.o
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 80c9deca5f35..9bd7c4a31253 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -117,6 +117,32 @@ int of_device_is_compatible(const struct device_node *device,
117EXPORT_SYMBOL(of_device_is_compatible); 117EXPORT_SYMBOL(of_device_is_compatible);
118 118
119/** 119/**
120 * of_device_is_available - check if a device is available for use
121 *
122 * @device: Node to check for availability
123 *
124 * Returns 1 if the status property is absent or set to "okay" or "ok",
125 * 0 otherwise
126 */
127int of_device_is_available(const struct device_node *device)
128{
129 const char *status;
130 int statlen;
131
132 status = of_get_property(device, "status", &statlen);
133 if (status == NULL)
134 return 1;
135
136 if (statlen > 0) {
137 if (!strcmp(status, "okay") || !strcmp(status, "ok"))
138 return 1;
139 }
140
141 return 0;
142}
143EXPORT_SYMBOL(of_device_is_available);
144
145/**
120 * of_get_parent - Get a node's parent if any 146 * of_get_parent - Get a node's parent if any
121 * @node: Node to get parent 147 * @node: Node to get parent
122 * 148 *
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
new file mode 100644
index 000000000000..000681e98f2c
--- /dev/null
+++ b/drivers/of/gpio.c
@@ -0,0 +1,242 @@
1/*
2 * OF helpers for the GPIO API
3 *
4 * Copyright (c) 2007-2008 MontaVista Software, Inc.
5 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/errno.h>
16#include <linux/io.h>
17#include <linux/of.h>
18#include <linux/of_gpio.h>
19#include <asm/prom.h>
20
21/**
22 * of_get_gpio - Get a GPIO number from the device tree to use with GPIO API
23 * @np: device node to get GPIO from
24 * @index: index of the GPIO
25 *
26 * Returns GPIO number to use with Linux generic GPIO API, or one of the errno
27 * value on the error condition.
28 */
29int of_get_gpio(struct device_node *np, int index)
30{
31 int ret = -EINVAL;
32 struct device_node *gc;
33 struct of_gpio_chip *of_gc = NULL;
34 int size;
35 const u32 *gpios;
36 u32 nr_cells;
37 int i;
38 const void *gpio_spec;
39 const u32 *gpio_cells;
40 int gpio_index = 0;
41
42 gpios = of_get_property(np, "gpios", &size);
43 if (!gpios) {
44 ret = -ENOENT;
45 goto err0;
46 }
47 nr_cells = size / sizeof(u32);
48
49 for (i = 0; i < nr_cells; gpio_index++) {
50 const phandle *gpio_phandle;
51
52 gpio_phandle = gpios + i;
53 gpio_spec = gpio_phandle + 1;
54
55 /* one cell hole in the gpios = <>; */
56 if (!*gpio_phandle) {
57 if (gpio_index == index)
58 return -ENOENT;
59 i++;
60 continue;
61 }
62
63 gc = of_find_node_by_phandle(*gpio_phandle);
64 if (!gc) {
65 pr_debug("%s: could not find phandle for gpios\n",
66 np->full_name);
67 goto err0;
68 }
69
70 of_gc = gc->data;
71 if (!of_gc) {
72 pr_debug("%s: gpio controller %s isn't registered\n",
73 np->full_name, gc->full_name);
74 goto err1;
75 }
76
77 gpio_cells = of_get_property(gc, "#gpio-cells", &size);
78 if (!gpio_cells || size != sizeof(*gpio_cells) ||
79 *gpio_cells != of_gc->gpio_cells) {
80 pr_debug("%s: wrong #gpio-cells for %s\n",
81 np->full_name, gc->full_name);
82 goto err1;
83 }
84
85 /* Next phandle is at phandle cells + #gpio-cells */
86 i += sizeof(*gpio_phandle) / sizeof(u32) + *gpio_cells;
87 if (i >= nr_cells + 1) {
88 pr_debug("%s: insufficient gpio-spec length\n",
89 np->full_name);
90 goto err1;
91 }
92
93 if (gpio_index == index)
94 break;
95
96 of_gc = NULL;
97 of_node_put(gc);
98 }
99
100 if (!of_gc) {
101 ret = -ENOENT;
102 goto err0;
103 }
104
105 ret = of_gc->xlate(of_gc, np, gpio_spec);
106 if (ret < 0)
107 goto err1;
108
109 ret += of_gc->gc.base;
110err1:
111 of_node_put(gc);
112err0:
113 pr_debug("%s exited with status %d\n", __func__, ret);
114 return ret;
115}
116EXPORT_SYMBOL(of_get_gpio);
117
118/**
119 * of_gpio_simple_xlate - translate gpio_spec to the GPIO number
120 * @of_gc: pointer to the of_gpio_chip structure
121 * @np: device node of the GPIO chip
122 * @gpio_spec: gpio specifier as found in the device tree
123 *
124 * This is simple translation function, suitable for the most 1:1 mapped
125 * gpio chips. This function performs only one sanity check: whether gpio
126 * is less than ngpios (that is specified in the gpio_chip).
127 */
128int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
129 const void *gpio_spec)
130{
131 const u32 *gpio = gpio_spec;
132
133 if (*gpio > of_gc->gc.ngpio)
134 return -EINVAL;
135
136 return *gpio;
137}
138EXPORT_SYMBOL(of_gpio_simple_xlate);
139
140/* Should be sufficient for now, later we'll use dynamic bases. */
141#if defined(CONFIG_PPC32) || defined(CONFIG_SPARC32)
142#define GPIOS_PER_CHIP 32
143#else
144#define GPIOS_PER_CHIP 64
145#endif
146
147static int of_get_gpiochip_base(struct device_node *np)
148{
149 struct device_node *gc = NULL;
150 int gpiochip_base = 0;
151
152 while ((gc = of_find_all_nodes(gc))) {
153 if (!of_get_property(gc, "gpio-controller", NULL))
154 continue;
155
156 if (gc != np) {
157 gpiochip_base += GPIOS_PER_CHIP;
158 continue;
159 }
160
161 of_node_put(gc);
162
163 if (gpiochip_base >= ARCH_NR_GPIOS)
164 return -ENOSPC;
165
166 return gpiochip_base;
167 }
168
169 return -ENOENT;
170}
171
172/**
173 * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank)
174 * @np: device node of the GPIO chip
175 * @mm_gc: pointer to the of_mm_gpio_chip allocated structure
176 *
177 * To use this function you should allocate and fill mm_gc with:
178 *
179 * 1) In the gpio_chip structure:
180 * - all the callbacks
181 *
182 * 2) In the of_gpio_chip structure:
183 * - gpio_cells
184 * - xlate callback (optional)
185 *
186 * 3) In the of_mm_gpio_chip structure:
187 * - save_regs callback (optional)
188 *
189 * If succeeded, this function will map bank's memory and will
190 * do all necessary work for you. Then you'll able to use .regs
191 * to manage GPIOs from the callbacks.
192 */
193int of_mm_gpiochip_add(struct device_node *np,
194 struct of_mm_gpio_chip *mm_gc)
195{
196 int ret = -ENOMEM;
197 struct of_gpio_chip *of_gc = &mm_gc->of_gc;
198 struct gpio_chip *gc = &of_gc->gc;
199
200 gc->label = kstrdup(np->full_name, GFP_KERNEL);
201 if (!gc->label)
202 goto err0;
203
204 mm_gc->regs = of_iomap(np, 0);
205 if (!mm_gc->regs)
206 goto err1;
207
208 gc->base = of_get_gpiochip_base(np);
209 if (gc->base < 0) {
210 ret = gc->base;
211 goto err1;
212 }
213
214 if (!of_gc->xlate)
215 of_gc->xlate = of_gpio_simple_xlate;
216
217 if (mm_gc->save_regs)
218 mm_gc->save_regs(mm_gc);
219
220 np->data = of_gc;
221
222 ret = gpiochip_add(gc);
223 if (ret)
224 goto err2;
225
226 /* We don't want to lose the node and its ->data */
227 of_node_get(np);
228
229 pr_debug("%s: registered as generic GPIO chip, base is %d\n",
230 np->full_name, gc->base);
231 return 0;
232err2:
233 np->data = NULL;
234 iounmap(mm_gc->regs);
235err1:
236 kfree(gc->label);
237err0:
238 pr_err("%s: GPIO chip registration failed with status %d\n",
239 np->full_name, ret);
240 return ret;
241}
242EXPORT_SYMBOL(of_mm_gpiochip_add);
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
new file mode 100644
index 000000000000..631689171159
--- /dev/null
+++ b/drivers/of/of_i2c.c
@@ -0,0 +1,115 @@
1/*
2 * OF helpers for the I2C API
3 *
4 * Copyright (c) 2008 Jochen Friedrich <jochen@scram.de>
5 *
6 * Based on a previous patch from Jon Smirl <jonsmirl@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/i2c.h>
15#include <linux/of.h>
16
17struct i2c_driver_device {
18 char *of_device;
19 char *i2c_type;
20};
21
22static struct i2c_driver_device i2c_devices[] = {
23 { "dallas,ds1374", "rtc-ds1374" },
24};
25
26static int of_find_i2c_driver(struct device_node *node,
27 struct i2c_board_info *info)
28{
29 int i, cplen;
30 const char *compatible;
31 const char *p;
32
33 /* 1. search for exception list entry */
34 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
35 if (!of_device_is_compatible(node, i2c_devices[i].of_device))
36 continue;
37 if (strlcpy(info->type, i2c_devices[i].i2c_type,
38 I2C_NAME_SIZE) >= I2C_NAME_SIZE)
39 return -ENOMEM;
40
41 return 0;
42 }
43
44 compatible = of_get_property(node, "compatible", &cplen);
45 if (!compatible)
46 return -ENODEV;
47
48 /* 2. search for linux,<i2c-type> entry */
49 p = compatible;
50 while (cplen > 0) {
51 if (!strncmp(p, "linux,", 6)) {
52 p += 6;
53 if (strlcpy(info->type, p,
54 I2C_NAME_SIZE) >= I2C_NAME_SIZE)
55 return -ENOMEM;
56 return 0;
57 }
58
59 i = strlen(p) + 1;
60 p += i;
61 cplen -= i;
62 }
63
64 /* 3. take fist compatible entry and strip manufacturer */
65 p = strchr(compatible, ',');
66 if (!p)
67 return -ENODEV;
68 p++;
69 if (strlcpy(info->type, p, I2C_NAME_SIZE) >= I2C_NAME_SIZE)
70 return -ENOMEM;
71 return 0;
72}
73
74void of_register_i2c_devices(struct i2c_adapter *adap,
75 struct device_node *adap_node)
76{
77 void *result;
78 struct device_node *node;
79
80 for_each_child_of_node(adap_node, node) {
81 struct i2c_board_info info = {};
82 const u32 *addr;
83 int len;
84
85 addr = of_get_property(node, "reg", &len);
86 if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
87 printk(KERN_ERR
88 "of-i2c: invalid i2c device entry\n");
89 continue;
90 }
91
92 info.irq = irq_of_parse_and_map(node, 0);
93 if (info.irq == NO_IRQ)
94 info.irq = -1;
95
96 if (of_find_i2c_driver(node, &info) < 0) {
97 irq_dispose_mapping(info.irq);
98 continue;
99 }
100
101 info.addr = *addr;
102
103 request_module(info.type);
104
105 result = i2c_new_device(adap, &info);
106 if (result == NULL) {
107 printk(KERN_ERR
108 "of-i2c: Failed to load driver for %s\n",
109 info.type);
110 irq_dispose_mapping(info.irq);
111 continue;
112 }
113 }
114}
115EXPORT_SYMBOL(of_register_i2c_devices);
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index b7bcdcc5c724..209b4a464bcf 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -36,7 +36,7 @@ if PARPORT
36config PARPORT_PC 36config PARPORT_PC
37 tristate "PC-style hardware" 37 tristate "PC-style hardware"
38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \ 38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \
39 (!M68K || ISA) && !MN10300 39 (!M68K || ISA) && !MN10300 && !AVR32
40 ---help--- 40 ---help---
41 You should say Y here if you have a PC-style parallel port. All 41 You should say Y here if you have a PC-style parallel port. All
42 IBM PC compatible computers and some Alphas have PC-style 42 IBM PC compatible computers and some Alphas have PC-style
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index e571c72e6753..e8d94fafc280 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -182,15 +182,18 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
182 struct mempolicy *oldpol; 182 struct mempolicy *oldpol;
183 cpumask_t oldmask = current->cpus_allowed; 183 cpumask_t oldmask = current->cpus_allowed;
184 int node = pcibus_to_node(dev->bus); 184 int node = pcibus_to_node(dev->bus);
185 if (node >= 0 && node_online(node)) 185
186 set_cpus_allowed(current, node_to_cpumask(node)); 186 if (node >= 0) {
187 node_to_cpumask_ptr(nodecpumask, node);
188 set_cpus_allowed_ptr(current, nodecpumask);
189 }
187 /* And set default memory allocation policy */ 190 /* And set default memory allocation policy */
188 oldpol = current->mempolicy; 191 oldpol = current->mempolicy;
189 current->mempolicy = NULL; /* fall back to system default policy */ 192 current->mempolicy = NULL; /* fall back to system default policy */
190#endif 193#endif
191 error = drv->probe(dev, id); 194 error = drv->probe(dev, id);
192#ifdef CONFIG_NUMA 195#ifdef CONFIG_NUMA
193 set_cpus_allowed(current, oldmask); 196 set_cpus_allowed_ptr(current, &oldmask);
194 current->mempolicy = oldpol; 197 current->mempolicy = oldpol;
195#endif 198#endif
196 return error; 199 return error;
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index ae9a7695be97..271d41cc05ab 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -74,8 +74,23 @@ static ssize_t local_cpus_show(struct device *dev,
74 74
75 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 75 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
76 len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); 76 len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
77 strcat(buf,"\n"); 77 buf[len++] = '\n';
78 return 1+len; 78 buf[len] = '\0';
79 return len;
80}
81
82
83static ssize_t local_cpulist_show(struct device *dev,
84 struct device_attribute *attr, char *buf)
85{
86 cpumask_t mask;
87 int len;
88
89 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
90 len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask);
91 buf[len++] = '\n';
92 buf[len] = '\0';
93 return len;
79} 94}
80 95
81/* show resources */ 96/* show resources */
@@ -202,6 +217,7 @@ struct device_attribute pci_dev_attrs[] = {
202 __ATTR_RO(class), 217 __ATTR_RO(class),
203 __ATTR_RO(irq), 218 __ATTR_RO(irq),
204 __ATTR_RO(local_cpus), 219 __ATTR_RO(local_cpus),
220 __ATTR_RO(local_cpulist),
205 __ATTR_RO(modalias), 221 __ATTR_RO(modalias),
206#ifdef CONFIG_NUMA 222#ifdef CONFIG_NUMA
207 __ATTR_RO(numa_node), 223 __ATTR_RO(numa_node),
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 46a475384362..f991359f0c36 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -92,6 +92,7 @@ void pci_remove_legacy_files(struct pci_bus *bus) { return; }
92 * PCI Bus Class Devices 92 * PCI Bus Class Devices
93 */ 93 */
94static ssize_t pci_bus_show_cpuaffinity(struct device *dev, 94static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
95 int type,
95 struct device_attribute *attr, 96 struct device_attribute *attr,
96 char *buf) 97 char *buf)
97{ 98{
@@ -99,12 +100,30 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
99 cpumask_t cpumask; 100 cpumask_t cpumask;
100 101
101 cpumask = pcibus_to_cpumask(to_pci_bus(dev)); 102 cpumask = pcibus_to_cpumask(to_pci_bus(dev));
102 ret = cpumask_scnprintf(buf, PAGE_SIZE, cpumask); 103 ret = type?
103 if (ret < PAGE_SIZE) 104 cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask):
104 buf[ret++] = '\n'; 105 cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
106 buf[ret++] = '\n';
107 buf[ret] = '\0';
105 return ret; 108 return ret;
106} 109}
107DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL); 110
111static ssize_t inline pci_bus_show_cpumaskaffinity(struct device *dev,
112 struct device_attribute *attr,
113 char *buf)
114{
115 return pci_bus_show_cpuaffinity(dev, 0, attr, buf);
116}
117
118static ssize_t inline pci_bus_show_cpulistaffinity(struct device *dev,
119 struct device_attribute *attr,
120 char *buf)
121{
122 return pci_bus_show_cpuaffinity(dev, 1, attr, buf);
123}
124
125DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL);
126DEVICE_ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL);
108 127
109/* 128/*
110 * PCI Bus Class 129 * PCI Bus Class
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 8b22281b087f..ed8c06904807 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -200,6 +200,7 @@ config PCMCIA_AU1X00
200config PCMCIA_SA1100 200config PCMCIA_SA1100
201 tristate "SA1100 support" 201 tristate "SA1100 support"
202 depends on ARM && ARCH_SA1100 && PCMCIA 202 depends on ARM && ARCH_SA1100 && PCMCIA
203 depends on ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL || MACH_ARMCORE
203 help 204 help
204 Say Y here to include support for SA11x0-based PCMCIA or CF 205 Say Y here to include support for SA11x0-based PCMCIA or CF
205 sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/ 206 sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c
index fbf2f3a6984c..e7ab060ff118 100644
--- a/drivers/pcmcia/pxa2xx_cm_x270.c
+++ b/drivers/pcmcia/pxa2xx_cm_x270.c
@@ -20,6 +20,7 @@
20#include <asm/hardware.h> 20#include <asm/hardware.h>
21 21
22#include <asm/arch/pxa-regs.h> 22#include <asm/arch/pxa-regs.h>
23#include <asm/arch/pxa2xx-gpio.h>
23#include <asm/arch/cm-x270.h> 24#include <asm/arch/cm-x270.h>
24 25
25#include "soc_common.h" 26#include "soc_common.h"
diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c
index d4f6f960dd18..7605453b74fd 100644
--- a/drivers/ps3/ps3-sys-manager.c
+++ b/drivers/ps3/ps3-sys-manager.c
@@ -24,6 +24,7 @@
24#include <linux/reboot.h> 24#include <linux/reboot.h>
25 25
26#include <asm/firmware.h> 26#include <asm/firmware.h>
27#include <asm/lv1call.h>
27#include <asm/ps3.h> 28#include <asm/ps3.h>
28 29
29#include "vuart.h" 30#include "vuart.h"
@@ -187,6 +188,7 @@ enum ps3_sys_manager_next_op {
187 * controller, and bluetooth controller. 188 * controller, and bluetooth controller.
188 * @PS3_SM_WAKE_RTC: 189 * @PS3_SM_WAKE_RTC:
189 * @PS3_SM_WAKE_RTC_ERROR: 190 * @PS3_SM_WAKE_RTC_ERROR:
191 * @PS3_SM_WAKE_W_O_L: Ether or wireless LAN.
190 * @PS3_SM_WAKE_P_O_R: Power on reset. 192 * @PS3_SM_WAKE_P_O_R: Power on reset.
191 * 193 *
192 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. 194 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN.
@@ -200,10 +202,19 @@ enum ps3_sys_manager_wake_source {
200 PS3_SM_WAKE_DEFAULT = 0, 202 PS3_SM_WAKE_DEFAULT = 0,
201 PS3_SM_WAKE_RTC = 0x00000040, 203 PS3_SM_WAKE_RTC = 0x00000040,
202 PS3_SM_WAKE_RTC_ERROR = 0x00000080, 204 PS3_SM_WAKE_RTC_ERROR = 0x00000080,
205 PS3_SM_WAKE_W_O_L = 0x00000400,
203 PS3_SM_WAKE_P_O_R = 0x80000000, 206 PS3_SM_WAKE_P_O_R = 0x80000000,
204}; 207};
205 208
206/** 209/**
210 * user_wake_sources - User specified wakeup sources.
211 *
212 * Logical OR of enum ps3_sys_manager_wake_source types.
213 */
214
215static u32 user_wake_sources = PS3_SM_WAKE_DEFAULT;
216
217/**
207 * enum ps3_sys_manager_cmd - Command from system manager to guest. 218 * enum ps3_sys_manager_cmd - Command from system manager to guest.
208 * 219 *
209 * The guest completes the actions needed, then acks or naks the command via 220 * The guest completes the actions needed, then acks or naks the command via
@@ -581,6 +592,23 @@ fail_id:
581 return -EIO; 592 return -EIO;
582} 593}
583 594
595static void ps3_sys_manager_fin(struct ps3_system_bus_device *dev)
596{
597 ps3_sys_manager_send_request_shutdown(dev);
598
599 pr_emerg("System Halted, OK to turn off power\n");
600
601 while (ps3_sys_manager_handle_msg(dev)) {
602 /* pause until next DEC interrupt */
603 lv1_pause(0);
604 }
605
606 while (1) {
607 /* pause, ignoring DEC interrupt */
608 lv1_pause(1);
609 }
610}
611
584/** 612/**
585 * ps3_sys_manager_final_power_off - The final platform machine_power_off routine. 613 * ps3_sys_manager_final_power_off - The final platform machine_power_off routine.
586 * 614 *
@@ -601,13 +629,9 @@ static void ps3_sys_manager_final_power_off(struct ps3_system_bus_device *dev)
601 ps3_vuart_cancel_async(dev); 629 ps3_vuart_cancel_async(dev);
602 630
603 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN, 631 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN,
604 PS3_SM_WAKE_DEFAULT); 632 user_wake_sources);
605 ps3_sys_manager_send_request_shutdown(dev);
606
607 pr_emerg("System Halted, OK to turn off power\n");
608 633
609 while (1) 634 ps3_sys_manager_fin(dev);
610 ps3_sys_manager_handle_msg(dev);
611} 635}
612 636
613/** 637/**
@@ -638,14 +662,42 @@ static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev)
638 662
639 ps3_sys_manager_send_attr(dev, 0); 663 ps3_sys_manager_send_attr(dev, 0);
640 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT, 664 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT,
641 PS3_SM_WAKE_DEFAULT); 665 user_wake_sources);
642 ps3_sys_manager_send_request_shutdown(dev);
643 666
644 pr_emerg("System Halted, OK to turn off power\n"); 667 ps3_sys_manager_fin(dev);
668}
669
670/**
671 * ps3_sys_manager_get_wol - Get wake-on-lan setting.
672 */
673
674int ps3_sys_manager_get_wol(void)
675{
676 pr_debug("%s:%d\n", __func__, __LINE__);
677
678 return (user_wake_sources & PS3_SM_WAKE_W_O_L) != 0;
679}
680EXPORT_SYMBOL_GPL(ps3_sys_manager_get_wol);
681
682/**
683 * ps3_sys_manager_set_wol - Set wake-on-lan setting.
684 */
685
686void ps3_sys_manager_set_wol(int state)
687{
688 static DEFINE_MUTEX(mutex);
689
690 mutex_lock(&mutex);
691
692 pr_debug("%s:%d: %d\n", __func__, __LINE__, state);
645 693
646 while (1) 694 if (state)
647 ps3_sys_manager_handle_msg(dev); 695 user_wake_sources |= PS3_SM_WAKE_W_O_L;
696 else
697 user_wake_sources &= ~PS3_SM_WAKE_W_O_L;
698 mutex_unlock(&mutex);
648} 699}
700EXPORT_SYMBOL_GPL(ps3_sys_manager_set_wol);
649 701
650/** 702/**
651 * ps3_sys_manager_work - Asynchronous read handler. 703 * ps3_sys_manager_work - Asynchronous read handler.
diff --git a/drivers/ps3/sys-manager-core.c b/drivers/ps3/sys-manager-core.c
index 31648f7d9ae1..474225852b63 100644
--- a/drivers/ps3/sys-manager-core.c
+++ b/drivers/ps3/sys-manager-core.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <asm/lv1call.h>
22#include <asm/ps3.h> 23#include <asm/ps3.h>
23 24
24/** 25/**
@@ -50,10 +51,7 @@ void ps3_sys_manager_power_off(void)
50 if (ps3_sys_manager_ops.power_off) 51 if (ps3_sys_manager_ops.power_off)
51 ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev); 52 ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
52 53
53 printk(KERN_EMERG "System Halted, OK to turn off power\n"); 54 ps3_sys_manager_halt();
54 local_irq_disable();
55 while (1)
56 (void)0;
57} 55}
58 56
59void ps3_sys_manager_restart(void) 57void ps3_sys_manager_restart(void)
@@ -61,8 +59,14 @@ void ps3_sys_manager_restart(void)
61 if (ps3_sys_manager_ops.restart) 59 if (ps3_sys_manager_ops.restart)
62 ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev); 60 ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
63 61
64 printk(KERN_EMERG "System Halted, OK to turn off power\n"); 62 ps3_sys_manager_halt();
63}
64
65void ps3_sys_manager_halt(void)
66{
67 pr_emerg("System Halted, OK to turn off power\n");
65 local_irq_disable(); 68 local_irq_disable();
66 while (1) 69 while (1)
67 (void)0; 70 lv1_pause(1);
68} 71}
72
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 9e9caa5d7f5f..c594b34c6767 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * SuperH On-Chip RTC Support 2 * SuperH On-Chip RTC Support
3 * 3 *
4 * Copyright (C) 2006, 2007 Paul Mundt 4 * Copyright (C) 2006, 2007, 2008 Paul Mundt
5 * Copyright (C) 2006 Jamie Lenehan 5 * Copyright (C) 2006 Jamie Lenehan
6 * Copyright (C) 2008 Angelo Castello
6 * 7 *
7 * Based on the old arch/sh/kernel/cpu/rtc.c by: 8 * Based on the old arch/sh/kernel/cpu/rtc.c by:
8 * 9 *
@@ -26,7 +27,7 @@
26#include <asm/rtc.h> 27#include <asm/rtc.h>
27 28
28#define DRV_NAME "sh-rtc" 29#define DRV_NAME "sh-rtc"
29#define DRV_VERSION "0.1.6" 30#define DRV_VERSION "0.2.0"
30 31
31#define RTC_REG(r) ((r) * rtc_reg_size) 32#define RTC_REG(r) ((r) * rtc_reg_size)
32 33
@@ -63,6 +64,13 @@
63/* ALARM Bits - or with BCD encoded value */ 64/* ALARM Bits - or with BCD encoded value */
64#define AR_ENB 0x80 /* Enable for alarm cmp */ 65#define AR_ENB 0x80 /* Enable for alarm cmp */
65 66
67/* Period Bits */
68#define PF_HP 0x100 /* Enable Half Period to support 8,32,128Hz */
69#define PF_COUNT 0x200 /* Half periodic counter */
70#define PF_OXS 0x400 /* Periodic One x Second */
71#define PF_KOU 0x800 /* Kernel or User periodic request 1=kernel */
72#define PF_MASK 0xf00
73
66/* RCR1 Bits */ 74/* RCR1 Bits */
67#define RCR1_CF 0x80 /* Carry Flag */ 75#define RCR1_CF 0x80 /* Carry Flag */
68#define RCR1_CIE 0x10 /* Carry Interrupt Enable */ 76#define RCR1_CIE 0x10 /* Carry Interrupt Enable */
@@ -84,33 +92,24 @@ struct sh_rtc {
84 unsigned int alarm_irq, periodic_irq, carry_irq; 92 unsigned int alarm_irq, periodic_irq, carry_irq;
85 struct rtc_device *rtc_dev; 93 struct rtc_device *rtc_dev;
86 spinlock_t lock; 94 spinlock_t lock;
87 int rearm_aie;
88 unsigned long capabilities; /* See asm-sh/rtc.h for cap bits */ 95 unsigned long capabilities; /* See asm-sh/rtc.h for cap bits */
96 unsigned short periodic_freq;
89}; 97};
90 98
91static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id) 99static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id)
92{ 100{
93 struct platform_device *pdev = to_platform_device(dev_id); 101 struct sh_rtc *rtc = dev_id;
94 struct sh_rtc *rtc = platform_get_drvdata(pdev); 102 unsigned int tmp;
95 unsigned int tmp, events = 0;
96 103
97 spin_lock(&rtc->lock); 104 spin_lock(&rtc->lock);
98 105
99 tmp = readb(rtc->regbase + RCR1); 106 tmp = readb(rtc->regbase + RCR1);
100 tmp &= ~RCR1_CF; 107 tmp &= ~RCR1_CF;
101
102 if (rtc->rearm_aie) {
103 if (tmp & RCR1_AF)
104 tmp &= ~RCR1_AF; /* try to clear AF again */
105 else {
106 tmp |= RCR1_AIE; /* AF has cleared, rearm IRQ */
107 rtc->rearm_aie = 0;
108 }
109 }
110
111 writeb(tmp, rtc->regbase + RCR1); 108 writeb(tmp, rtc->regbase + RCR1);
112 109
113 rtc_update_irq(rtc->rtc_dev, 1, events); 110 /* Users have requested One x Second IRQ */
111 if (rtc->periodic_freq & PF_OXS)
112 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
114 113
115 spin_unlock(&rtc->lock); 114 spin_unlock(&rtc->lock);
116 115
@@ -119,47 +118,48 @@ static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id)
119 118
120static irqreturn_t sh_rtc_alarm(int irq, void *dev_id) 119static irqreturn_t sh_rtc_alarm(int irq, void *dev_id)
121{ 120{
122 struct platform_device *pdev = to_platform_device(dev_id); 121 struct sh_rtc *rtc = dev_id;
123 struct sh_rtc *rtc = platform_get_drvdata(pdev); 122 unsigned int tmp;
124 unsigned int tmp, events = 0;
125 123
126 spin_lock(&rtc->lock); 124 spin_lock(&rtc->lock);
127 125
128 tmp = readb(rtc->regbase + RCR1); 126 tmp = readb(rtc->regbase + RCR1);
129 127 tmp &= ~(RCR1_AF | RCR1_AIE);
130 /*
131 * If AF is set then the alarm has triggered. If we clear AF while
132 * the alarm time still matches the RTC time then AF will
133 * immediately be set again, and if AIE is enabled then the alarm
134 * interrupt will immediately be retrigger. So we clear AIE here
135 * and use rtc->rearm_aie so that the carry interrupt will keep
136 * trying to clear AF and once it stays cleared it'll re-enable
137 * AIE.
138 */
139 if (tmp & RCR1_AF) {
140 events |= RTC_AF | RTC_IRQF;
141
142 tmp &= ~(RCR1_AF|RCR1_AIE);
143
144 writeb(tmp, rtc->regbase + RCR1); 128 writeb(tmp, rtc->regbase + RCR1);
145 129
146 rtc->rearm_aie = 1; 130 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
147
148 rtc_update_irq(rtc->rtc_dev, 1, events);
149 }
150 131
151 spin_unlock(&rtc->lock); 132 spin_unlock(&rtc->lock);
133
152 return IRQ_HANDLED; 134 return IRQ_HANDLED;
153} 135}
154 136
155static irqreturn_t sh_rtc_periodic(int irq, void *dev_id) 137static irqreturn_t sh_rtc_periodic(int irq, void *dev_id)
156{ 138{
157 struct platform_device *pdev = to_platform_device(dev_id); 139 struct sh_rtc *rtc = dev_id;
158 struct sh_rtc *rtc = platform_get_drvdata(pdev); 140 struct rtc_device *rtc_dev = rtc->rtc_dev;
141 unsigned int tmp;
159 142
160 spin_lock(&rtc->lock); 143 spin_lock(&rtc->lock);
161 144
162 rtc_update_irq(rtc->rtc_dev, 1, RTC_PF | RTC_IRQF); 145 tmp = readb(rtc->regbase + RCR2);
146 tmp &= ~RCR2_PEF;
147 writeb(tmp, rtc->regbase + RCR2);
148
149 /* Half period enabled than one skipped and the next notified */
150 if ((rtc->periodic_freq & PF_HP) && (rtc->periodic_freq & PF_COUNT))
151 rtc->periodic_freq &= ~PF_COUNT;
152 else {
153 if (rtc->periodic_freq & PF_HP)
154 rtc->periodic_freq |= PF_COUNT;
155 if (rtc->periodic_freq & PF_KOU) {
156 spin_lock(&rtc_dev->irq_task_lock);
157 if (rtc_dev->irq_task)
158 rtc_dev->irq_task->func(rtc_dev->irq_task->private_data);
159 spin_unlock(&rtc_dev->irq_task_lock);
160 } else
161 rtc_update_irq(rtc->rtc_dev, 1, RTC_PF | RTC_IRQF);
162 }
163 163
164 spin_unlock(&rtc->lock); 164 spin_unlock(&rtc->lock);
165 165
@@ -176,8 +176,8 @@ static inline void sh_rtc_setpie(struct device *dev, unsigned int enable)
176 tmp = readb(rtc->regbase + RCR2); 176 tmp = readb(rtc->regbase + RCR2);
177 177
178 if (enable) { 178 if (enable) {
179 tmp &= ~RCR2_PESMASK; 179 tmp &= ~RCR2_PEF; /* Clear PES bit */
180 tmp |= RCR2_PEF | (2 << 4); 180 tmp |= (rtc->periodic_freq & ~PF_HP); /* Set PES2-0 */
181 } else 181 } else
182 tmp &= ~(RCR2_PESMASK | RCR2_PEF); 182 tmp &= ~(RCR2_PESMASK | RCR2_PEF);
183 183
@@ -186,82 +186,81 @@ static inline void sh_rtc_setpie(struct device *dev, unsigned int enable)
186 spin_unlock_irq(&rtc->lock); 186 spin_unlock_irq(&rtc->lock);
187} 187}
188 188
189static inline void sh_rtc_setaie(struct device *dev, unsigned int enable) 189static inline int sh_rtc_setfreq(struct device *dev, unsigned int freq)
190{ 190{
191 struct sh_rtc *rtc = dev_get_drvdata(dev); 191 struct sh_rtc *rtc = dev_get_drvdata(dev);
192 unsigned int tmp; 192 int tmp, ret = 0;
193 193
194 spin_lock_irq(&rtc->lock); 194 spin_lock_irq(&rtc->lock);
195 tmp = rtc->periodic_freq & PF_MASK;
195 196
196 tmp = readb(rtc->regbase + RCR1); 197 switch (freq) {
197 198 case 0:
198 if (!enable) { 199 rtc->periodic_freq = 0x00;
199 tmp &= ~RCR1_AIE; 200 break;
200 rtc->rearm_aie = 0; 201 case 1:
201 } else if (rtc->rearm_aie == 0) 202 rtc->periodic_freq = 0x60;
202 tmp |= RCR1_AIE; 203 break;
204 case 2:
205 rtc->periodic_freq = 0x50;
206 break;
207 case 4:
208 rtc->periodic_freq = 0x40;
209 break;
210 case 8:
211 rtc->periodic_freq = 0x30 | PF_HP;
212 break;
213 case 16:
214 rtc->periodic_freq = 0x30;
215 break;
216 case 32:
217 rtc->periodic_freq = 0x20 | PF_HP;
218 break;
219 case 64:
220 rtc->periodic_freq = 0x20;
221 break;
222 case 128:
223 rtc->periodic_freq = 0x10 | PF_HP;
224 break;
225 case 256:
226 rtc->periodic_freq = 0x10;
227 break;
228 default:
229 ret = -ENOTSUPP;
230 }
203 231
204 writeb(tmp, rtc->regbase + RCR1); 232 if (ret == 0) {
233 rtc->periodic_freq |= tmp;
234 rtc->rtc_dev->irq_freq = freq;
235 }
205 236
206 spin_unlock_irq(&rtc->lock); 237 spin_unlock_irq(&rtc->lock);
238 return ret;
207} 239}
208 240
209static int sh_rtc_open(struct device *dev) 241static inline void sh_rtc_setaie(struct device *dev, unsigned int enable)
210{ 242{
211 struct sh_rtc *rtc = dev_get_drvdata(dev); 243 struct sh_rtc *rtc = dev_get_drvdata(dev);
212 unsigned int tmp; 244 unsigned int tmp;
213 int ret;
214
215 tmp = readb(rtc->regbase + RCR1);
216 tmp &= ~RCR1_CF;
217 tmp |= RCR1_CIE;
218 writeb(tmp, rtc->regbase + RCR1);
219 245
220 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, IRQF_DISABLED, 246 spin_lock_irq(&rtc->lock);
221 "sh-rtc period", dev);
222 if (unlikely(ret)) {
223 dev_err(dev, "request period IRQ failed with %d, IRQ %d\n",
224 ret, rtc->periodic_irq);
225 return ret;
226 }
227
228 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED,
229 "sh-rtc carry", dev);
230 if (unlikely(ret)) {
231 dev_err(dev, "request carry IRQ failed with %d, IRQ %d\n",
232 ret, rtc->carry_irq);
233 free_irq(rtc->periodic_irq, dev);
234 goto err_bad_carry;
235 }
236 247
237 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, IRQF_DISABLED, 248 tmp = readb(rtc->regbase + RCR1);
238 "sh-rtc alarm", dev);
239 if (unlikely(ret)) {
240 dev_err(dev, "request alarm IRQ failed with %d, IRQ %d\n",
241 ret, rtc->alarm_irq);
242 goto err_bad_alarm;
243 }
244 249
245 return 0; 250 if (!enable)
251 tmp &= ~RCR1_AIE;
252 else
253 tmp |= RCR1_AIE;
246 254
247err_bad_alarm: 255 writeb(tmp, rtc->regbase + RCR1);
248 free_irq(rtc->carry_irq, dev);
249err_bad_carry:
250 free_irq(rtc->periodic_irq, dev);
251 256
252 return ret; 257 spin_unlock_irq(&rtc->lock);
253} 258}
254 259
255static void sh_rtc_release(struct device *dev) 260static void sh_rtc_release(struct device *dev)
256{ 261{
257 struct sh_rtc *rtc = dev_get_drvdata(dev);
258
259 sh_rtc_setpie(dev, 0); 262 sh_rtc_setpie(dev, 0);
260 sh_rtc_setaie(dev, 0); 263 sh_rtc_setaie(dev, 0);
261
262 free_irq(rtc->periodic_irq, dev);
263 free_irq(rtc->carry_irq, dev);
264 free_irq(rtc->alarm_irq, dev);
265} 264}
266 265
267static int sh_rtc_proc(struct device *dev, struct seq_file *seq) 266static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
@@ -270,31 +269,44 @@ static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
270 unsigned int tmp; 269 unsigned int tmp;
271 270
272 tmp = readb(rtc->regbase + RCR1); 271 tmp = readb(rtc->regbase + RCR1);
273 seq_printf(seq, "carry_IRQ\t: %s\n", 272 seq_printf(seq, "carry_IRQ\t: %s\n", (tmp & RCR1_CIE) ? "yes" : "no");
274 (tmp & RCR1_CIE) ? "yes" : "no");
275 273
276 tmp = readb(rtc->regbase + RCR2); 274 tmp = readb(rtc->regbase + RCR2);
277 seq_printf(seq, "periodic_IRQ\t: %s\n", 275 seq_printf(seq, "periodic_IRQ\t: %s\n",
278 (tmp & RCR2_PEF) ? "yes" : "no"); 276 (tmp & RCR2_PESMASK) ? "yes" : "no");
279 277
280 return 0; 278 return 0;
281} 279}
282 280
283static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 281static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
284{ 282{
285 unsigned int ret = -ENOIOCTLCMD; 283 struct sh_rtc *rtc = dev_get_drvdata(dev);
284 unsigned int ret = 0;
286 285
287 switch (cmd) { 286 switch (cmd) {
288 case RTC_PIE_OFF: 287 case RTC_PIE_OFF:
289 case RTC_PIE_ON: 288 case RTC_PIE_ON:
290 sh_rtc_setpie(dev, cmd == RTC_PIE_ON); 289 sh_rtc_setpie(dev, cmd == RTC_PIE_ON);
291 ret = 0;
292 break; 290 break;
293 case RTC_AIE_OFF: 291 case RTC_AIE_OFF:
294 case RTC_AIE_ON: 292 case RTC_AIE_ON:
295 sh_rtc_setaie(dev, cmd == RTC_AIE_ON); 293 sh_rtc_setaie(dev, cmd == RTC_AIE_ON);
296 ret = 0;
297 break; 294 break;
295 case RTC_UIE_OFF:
296 rtc->periodic_freq &= ~PF_OXS;
297 break;
298 case RTC_UIE_ON:
299 rtc->periodic_freq |= PF_OXS;
300 break;
301 case RTC_IRQP_READ:
302 ret = put_user(rtc->rtc_dev->irq_freq,
303 (unsigned long __user *)arg);
304 break;
305 case RTC_IRQP_SET:
306 ret = sh_rtc_setfreq(dev, arg);
307 break;
308 default:
309 ret = -ENOIOCTLCMD;
298 } 310 }
299 311
300 return ret; 312 return ret;
@@ -421,7 +433,7 @@ static int sh_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
421{ 433{
422 struct platform_device *pdev = to_platform_device(dev); 434 struct platform_device *pdev = to_platform_device(dev);
423 struct sh_rtc *rtc = platform_get_drvdata(pdev); 435 struct sh_rtc *rtc = platform_get_drvdata(pdev);
424 struct rtc_time* tm = &wkalrm->time; 436 struct rtc_time *tm = &wkalrm->time;
425 437
426 spin_lock_irq(&rtc->lock); 438 spin_lock_irq(&rtc->lock);
427 439
@@ -452,7 +464,7 @@ static inline void sh_rtc_write_alarm_value(struct sh_rtc *rtc,
452 writeb(BIN2BCD(value) | AR_ENB, rtc->regbase + reg_off); 464 writeb(BIN2BCD(value) | AR_ENB, rtc->regbase + reg_off);
453} 465}
454 466
455static int sh_rtc_check_alarm(struct rtc_time* tm) 467static int sh_rtc_check_alarm(struct rtc_time *tm)
456{ 468{
457 /* 469 /*
458 * The original rtc says anything > 0xc0 is "don't care" or "match 470 * The original rtc says anything > 0xc0 is "don't care" or "match
@@ -503,11 +515,9 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
503 515
504 /* disable alarm interrupt and clear the alarm flag */ 516 /* disable alarm interrupt and clear the alarm flag */
505 rcr1 = readb(rtc->regbase + RCR1); 517 rcr1 = readb(rtc->regbase + RCR1);
506 rcr1 &= ~(RCR1_AF|RCR1_AIE); 518 rcr1 &= ~(RCR1_AF | RCR1_AIE);
507 writeb(rcr1, rtc->regbase + RCR1); 519 writeb(rcr1, rtc->regbase + RCR1);
508 520
509 rtc->rearm_aie = 0;
510
511 /* set alarm time */ 521 /* set alarm time */
512 sh_rtc_write_alarm_value(rtc, tm->tm_sec, RSECAR); 522 sh_rtc_write_alarm_value(rtc, tm->tm_sec, RSECAR);
513 sh_rtc_write_alarm_value(rtc, tm->tm_min, RMINAR); 523 sh_rtc_write_alarm_value(rtc, tm->tm_min, RMINAR);
@@ -529,14 +539,34 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
529 return 0; 539 return 0;
530} 540}
531 541
542static int sh_rtc_irq_set_state(struct device *dev, int enabled)
543{
544 struct platform_device *pdev = to_platform_device(dev);
545 struct sh_rtc *rtc = platform_get_drvdata(pdev);
546
547 if (enabled) {
548 rtc->periodic_freq |= PF_KOU;
549 return sh_rtc_ioctl(dev, RTC_PIE_ON, 0);
550 } else {
551 rtc->periodic_freq &= ~PF_KOU;
552 return sh_rtc_ioctl(dev, RTC_PIE_OFF, 0);
553 }
554}
555
556static int sh_rtc_irq_set_freq(struct device *dev, int freq)
557{
558 return sh_rtc_ioctl(dev, RTC_IRQP_SET, freq);
559}
560
532static struct rtc_class_ops sh_rtc_ops = { 561static struct rtc_class_ops sh_rtc_ops = {
533 .open = sh_rtc_open,
534 .release = sh_rtc_release, 562 .release = sh_rtc_release,
535 .ioctl = sh_rtc_ioctl, 563 .ioctl = sh_rtc_ioctl,
536 .read_time = sh_rtc_read_time, 564 .read_time = sh_rtc_read_time,
537 .set_time = sh_rtc_set_time, 565 .set_time = sh_rtc_set_time,
538 .read_alarm = sh_rtc_read_alarm, 566 .read_alarm = sh_rtc_read_alarm,
539 .set_alarm = sh_rtc_set_alarm, 567 .set_alarm = sh_rtc_set_alarm,
568 .irq_set_state = sh_rtc_irq_set_state,
569 .irq_set_freq = sh_rtc_irq_set_freq,
540 .proc = sh_rtc_proc, 570 .proc = sh_rtc_proc,
541}; 571};
542 572
@@ -544,6 +574,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
544{ 574{
545 struct sh_rtc *rtc; 575 struct sh_rtc *rtc;
546 struct resource *res; 576 struct resource *res;
577 unsigned int tmp;
547 int ret = -ENOENT; 578 int ret = -ENOENT;
548 579
549 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); 580 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL);
@@ -552,6 +583,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
552 583
553 spin_lock_init(&rtc->lock); 584 spin_lock_init(&rtc->lock);
554 585
586 /* get periodic/carry/alarm irqs */
555 rtc->periodic_irq = platform_get_irq(pdev, 0); 587 rtc->periodic_irq = platform_get_irq(pdev, 0);
556 if (unlikely(rtc->periodic_irq < 0)) { 588 if (unlikely(rtc->periodic_irq < 0)) {
557 dev_err(&pdev->dev, "No IRQ for period\n"); 589 dev_err(&pdev->dev, "No IRQ for period\n");
@@ -608,8 +640,48 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
608 rtc->capabilities |= pinfo->capabilities; 640 rtc->capabilities |= pinfo->capabilities;
609 } 641 }
610 642
643 rtc->rtc_dev->max_user_freq = 256;
644 rtc->rtc_dev->irq_freq = 1;
645 rtc->periodic_freq = 0x60;
646
611 platform_set_drvdata(pdev, rtc); 647 platform_set_drvdata(pdev, rtc);
612 648
649 /* register periodic/carry/alarm irqs */
650 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, IRQF_DISABLED,
651 "sh-rtc period", rtc);
652 if (unlikely(ret)) {
653 dev_err(&pdev->dev,
654 "request period IRQ failed with %d, IRQ %d\n", ret,
655 rtc->periodic_irq);
656 goto err_badmap;
657 }
658
659 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED,
660 "sh-rtc carry", rtc);
661 if (unlikely(ret)) {
662 dev_err(&pdev->dev,
663 "request carry IRQ failed with %d, IRQ %d\n", ret,
664 rtc->carry_irq);
665 free_irq(rtc->periodic_irq, rtc);
666 goto err_badmap;
667 }
668
669 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, IRQF_DISABLED,
670 "sh-rtc alarm", rtc);
671 if (unlikely(ret)) {
672 dev_err(&pdev->dev,
673 "request alarm IRQ failed with %d, IRQ %d\n", ret,
674 rtc->alarm_irq);
675 free_irq(rtc->carry_irq, rtc);
676 free_irq(rtc->periodic_irq, rtc);
677 goto err_badmap;
678 }
679
680 tmp = readb(rtc->regbase + RCR1);
681 tmp &= ~RCR1_CF;
682 tmp |= RCR1_CIE;
683 writeb(tmp, rtc->regbase + RCR1);
684
613 return 0; 685 return 0;
614 686
615err_badmap: 687err_badmap:
@@ -630,6 +702,10 @@ static int __devexit sh_rtc_remove(struct platform_device *pdev)
630 sh_rtc_setpie(&pdev->dev, 0); 702 sh_rtc_setpie(&pdev->dev, 0);
631 sh_rtc_setaie(&pdev->dev, 0); 703 sh_rtc_setaie(&pdev->dev, 0);
632 704
705 free_irq(rtc->carry_irq, rtc);
706 free_irq(rtc->periodic_irq, rtc);
707 free_irq(rtc->alarm_irq, rtc);
708
633 release_resource(rtc->res); 709 release_resource(rtc->res);
634 710
635 platform_set_drvdata(pdev, NULL); 711 platform_set_drvdata(pdev, NULL);
@@ -662,6 +738,8 @@ module_exit(sh_rtc_exit);
662 738
663MODULE_DESCRIPTION("SuperH on-chip RTC driver"); 739MODULE_DESCRIPTION("SuperH on-chip RTC driver");
664MODULE_VERSION(DRV_VERSION); 740MODULE_VERSION(DRV_VERSION);
665MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, Jamie Lenehan <lenehan@twibble.org>"); 741MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, "
742 "Jamie Lenehan <lenehan@twibble.org>, "
743 "Angelo Castello <angelo.castello@st.com>");
666MODULE_LICENSE("GPL"); 744MODULE_LICENSE("GPL");
667MODULE_ALIAS("platform:" DRV_NAME); 745MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 03914fa81174..fe1ad1722158 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -16,7 +16,6 @@
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/dcache.h> 17#include <linux/dcache.h>
18 18
19#include <asm/semaphore.h>
20#include <asm/ccwdev.h> 19#include <asm/ccwdev.h>
21#include <asm/ccwgroup.h> 20#include <asm/ccwgroup.h>
22 21
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index c359386708e9..10aa1e780801 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -38,11 +38,11 @@
38#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
39#include <linux/timer.h> 39#include <linux/timer.h>
40#include <linux/mempool.h> 40#include <linux/mempool.h>
41#include <linux/semaphore.h>
41 42
42#include <asm/ccwdev.h> 43#include <asm/ccwdev.h>
43#include <asm/io.h> 44#include <asm/io.h>
44#include <asm/atomic.h> 45#include <asm/atomic.h>
45#include <asm/semaphore.h>
46#include <asm/timex.h> 46#include <asm/timex.h>
47 47
48#include <asm/debug.h> 48#include <asm/debug.h>
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 51c3ebf1c7d1..b31faeccb9cd 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -140,9 +140,10 @@ static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id);
140/* Functions */ 140/* Functions */
141 141
142/* Show some statistics about the card */ 142/* Show some statistics about the card */
143static ssize_t twa_show_stats(struct class_device *class_dev, char *buf) 143static ssize_t twa_show_stats(struct device *dev,
144 struct device_attribute *attr, char *buf)
144{ 145{
145 struct Scsi_Host *host = class_to_shost(class_dev); 146 struct Scsi_Host *host = class_to_shost(dev);
146 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; 147 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
147 unsigned long flags = 0; 148 unsigned long flags = 0;
148 ssize_t len; 149 ssize_t len;
@@ -184,7 +185,7 @@ static int twa_change_queue_depth(struct scsi_device *sdev, int queue_depth)
184} /* End twa_change_queue_depth() */ 185} /* End twa_change_queue_depth() */
185 186
186/* Create sysfs 'stats' entry */ 187/* Create sysfs 'stats' entry */
187static struct class_device_attribute twa_host_stats_attr = { 188static struct device_attribute twa_host_stats_attr = {
188 .attr = { 189 .attr = {
189 .name = "stats", 190 .name = "stats",
190 .mode = S_IRUGO, 191 .mode = S_IRUGO,
@@ -193,7 +194,7 @@ static struct class_device_attribute twa_host_stats_attr = {
193}; 194};
194 195
195/* Host attributes initializer */ 196/* Host attributes initializer */
196static struct class_device_attribute *twa_host_attrs[] = { 197static struct device_attribute *twa_host_attrs[] = {
197 &twa_host_stats_attr, 198 &twa_host_stats_attr,
198 NULL, 199 NULL,
199}; 200};
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index adb98a297210..8c22329aa85e 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -484,9 +484,10 @@ static void tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id)
484} /* End tw_state_request_start() */ 484} /* End tw_state_request_start() */
485 485
486/* Show some statistics about the card */ 486/* Show some statistics about the card */
487static ssize_t tw_show_stats(struct class_device *class_dev, char *buf) 487static ssize_t tw_show_stats(struct device *dev, struct device_attribute *attr,
488 char *buf)
488{ 489{
489 struct Scsi_Host *host = class_to_shost(class_dev); 490 struct Scsi_Host *host = class_to_shost(dev);
490 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; 491 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
491 unsigned long flags = 0; 492 unsigned long flags = 0;
492 ssize_t len; 493 ssize_t len;
@@ -528,7 +529,7 @@ static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth)
528} /* End tw_change_queue_depth() */ 529} /* End tw_change_queue_depth() */
529 530
530/* Create sysfs 'stats' entry */ 531/* Create sysfs 'stats' entry */
531static struct class_device_attribute tw_host_stats_attr = { 532static struct device_attribute tw_host_stats_attr = {
532 .attr = { 533 .attr = {
533 .name = "stats", 534 .name = "stats",
534 .mode = S_IRUGO, 535 .mode = S_IRUGO,
@@ -537,7 +538,7 @@ static struct class_device_attribute tw_host_stats_attr = {
537}; 538};
538 539
539/* Host attributes initializer */ 540/* Host attributes initializer */
540static struct class_device_attribute *tw_host_attrs[] = { 541static struct device_attribute *tw_host_attrs[] = {
541 &tw_host_stats_attr, 542 &tw_host_stats_attr,
542 NULL, 543 NULL,
543}; 544};
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 369fcf78f396..460d4024c46c 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -31,7 +31,6 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/completion.h> 32#include <linux/completion.h>
33#include <linux/blkdev.h> 33#include <linux/blkdev.h>
34#include <asm/semaphore.h>
35#include <asm/uaccess.h> 34#include <asm/uaccess.h>
36#include <linux/highmem.h> /* For flush_kernel_dcache_page */ 35#include <linux/highmem.h> /* For flush_kernel_dcache_page */
37 36
@@ -1316,7 +1315,7 @@ int aac_get_adapter_info(struct aac_dev* dev)
1316 tmp>>24,(tmp>>16)&0xff,tmp&0xff, 1315 tmp>>24,(tmp>>16)&0xff,tmp&0xff,
1317 le32_to_cpu(dev->adapter_info.biosbuild)); 1316 le32_to_cpu(dev->adapter_info.biosbuild));
1318 buffer[0] = '\0'; 1317 buffer[0] = '\0';
1319 if (aac_show_serial_number( 1318 if (aac_get_serial_number(
1320 shost_to_class(dev->scsi_host_ptr), buffer)) 1319 shost_to_class(dev->scsi_host_ptr), buffer))
1321 printk(KERN_INFO "%s%d: serial %s", 1320 printk(KERN_INFO "%s%d: serial %s",
1322 dev->name, dev->id, buffer); 1321 dev->name, dev->id, buffer);
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index ace0b751c131..113ca9c8934c 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -1850,9 +1850,9 @@ int aac_get_containers(struct aac_dev *dev);
1850int aac_scsi_cmd(struct scsi_cmnd *cmd); 1850int aac_scsi_cmd(struct scsi_cmnd *cmd);
1851int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg); 1851int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg);
1852#ifndef shost_to_class 1852#ifndef shost_to_class
1853#define shost_to_class(shost) &shost->shost_classdev 1853#define shost_to_class(shost) &shost->shost_dev
1854#endif 1854#endif
1855ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf); 1855ssize_t aac_get_serial_number(struct device *dev, char *buf);
1856int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg); 1856int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg);
1857int aac_rx_init(struct aac_dev *dev); 1857int aac_rx_init(struct aac_dev *dev);
1858int aac_rkt_init(struct aac_dev *dev); 1858int aac_rkt_init(struct aac_dev *dev);
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index abef05146d75..5fd83deab36c 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -39,7 +39,7 @@
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/delay.h> /* ssleep prototype */ 40#include <linux/delay.h> /* ssleep prototype */
41#include <linux/kthread.h> 41#include <linux/kthread.h>
42#include <asm/semaphore.h> 42#include <linux/semaphore.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44 44
45#include "aacraid.h" 45#include "aacraid.h"
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 89cc8b7b42a2..294a802450be 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -39,7 +39,6 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/mm.h> 40#include <linux/mm.h>
41#include <scsi/scsi_host.h> 41#include <scsi/scsi_host.h>
42#include <asm/semaphore.h>
43 42
44#include "aacraid.h" 43#include "aacraid.h"
45 44
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 23a8e9f8dcb4..ef67816a6fe5 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -41,11 +41,11 @@
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/kthread.h> 42#include <linux/kthread.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/semaphore.h>
44#include <scsi/scsi.h> 45#include <scsi/scsi.h>
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <scsi/scsi_device.h> 47#include <scsi/scsi_device.h>
47#include <scsi/scsi_cmnd.h> 48#include <scsi/scsi_cmnd.h>
48#include <asm/semaphore.h>
49 49
50#include "aacraid.h" 50#include "aacraid.h"
51 51
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c
index d1163ded132b..933f208eedba 100644
--- a/drivers/scsi/aacraid/dpcsup.c
+++ b/drivers/scsi/aacraid/dpcsup.c
@@ -36,7 +36,7 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/completion.h> 37#include <linux/completion.h>
38#include <linux/blkdev.h> 38#include <linux/blkdev.h>
39#include <asm/semaphore.h> 39#include <linux/semaphore.h>
40 40
41#include "aacraid.h" 41#include "aacraid.h"
42 42
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index ae5f74fb62d5..c109f63f8279 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -42,7 +42,6 @@
42#include <linux/syscalls.h> 42#include <linux/syscalls.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/kthread.h> 44#include <linux/kthread.h>
45#include <asm/semaphore.h>
46 45
47#include <scsi/scsi.h> 46#include <scsi/scsi.h>
48#include <scsi/scsi_cmnd.h> 47#include <scsi/scsi_cmnd.h>
@@ -755,10 +754,10 @@ static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long
755} 754}
756#endif 755#endif
757 756
758static ssize_t aac_show_model(struct class_device *class_dev, 757static ssize_t aac_show_model(struct device *device,
759 char *buf) 758 struct device_attribute *attr, char *buf)
760{ 759{
761 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 760 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
762 int len; 761 int len;
763 762
764 if (dev->supplement_adapter_info.AdapterTypeText[0]) { 763 if (dev->supplement_adapter_info.AdapterTypeText[0]) {
@@ -774,10 +773,10 @@ static ssize_t aac_show_model(struct class_device *class_dev,
774 return len; 773 return len;
775} 774}
776 775
777static ssize_t aac_show_vendor(struct class_device *class_dev, 776static ssize_t aac_show_vendor(struct device *device,
778 char *buf) 777 struct device_attribute *attr, char *buf)
779{ 778{
780 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 779 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
781 int len; 780 int len;
782 781
783 if (dev->supplement_adapter_info.AdapterTypeText[0]) { 782 if (dev->supplement_adapter_info.AdapterTypeText[0]) {
@@ -793,10 +792,11 @@ static ssize_t aac_show_vendor(struct class_device *class_dev,
793 return len; 792 return len;
794} 793}
795 794
796static ssize_t aac_show_flags(struct class_device *class_dev, char *buf) 795static ssize_t aac_show_flags(struct device *cdev,
796 struct device_attribute *attr, char *buf)
797{ 797{
798 int len = 0; 798 int len = 0;
799 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 799 struct aac_dev *dev = (struct aac_dev*)class_to_shost(cdev)->hostdata;
800 800
801 if (nblank(dprintk(x))) 801 if (nblank(dprintk(x)))
802 len = snprintf(buf, PAGE_SIZE, "dprintk\n"); 802 len = snprintf(buf, PAGE_SIZE, "dprintk\n");
@@ -812,10 +812,11 @@ static ssize_t aac_show_flags(struct class_device *class_dev, char *buf)
812 return len; 812 return len;
813} 813}
814 814
815static ssize_t aac_show_kernel_version(struct class_device *class_dev, 815static ssize_t aac_show_kernel_version(struct device *device,
816 char *buf) 816 struct device_attribute *attr,
817 char *buf)
817{ 818{
818 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 819 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
819 int len, tmp; 820 int len, tmp;
820 821
821 tmp = le32_to_cpu(dev->adapter_info.kernelrev); 822 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
@@ -825,10 +826,11 @@ static ssize_t aac_show_kernel_version(struct class_device *class_dev,
825 return len; 826 return len;
826} 827}
827 828
828static ssize_t aac_show_monitor_version(struct class_device *class_dev, 829static ssize_t aac_show_monitor_version(struct device *device,
829 char *buf) 830 struct device_attribute *attr,
831 char *buf)
830{ 832{
831 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 833 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
832 int len, tmp; 834 int len, tmp;
833 835
834 tmp = le32_to_cpu(dev->adapter_info.monitorrev); 836 tmp = le32_to_cpu(dev->adapter_info.monitorrev);
@@ -838,10 +840,11 @@ static ssize_t aac_show_monitor_version(struct class_device *class_dev,
838 return len; 840 return len;
839} 841}
840 842
841static ssize_t aac_show_bios_version(struct class_device *class_dev, 843static ssize_t aac_show_bios_version(struct device *device,
842 char *buf) 844 struct device_attribute *attr,
845 char *buf)
843{ 846{
844 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 847 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
845 int len, tmp; 848 int len, tmp;
846 849
847 tmp = le32_to_cpu(dev->adapter_info.biosrev); 850 tmp = le32_to_cpu(dev->adapter_info.biosrev);
@@ -851,9 +854,10 @@ static ssize_t aac_show_bios_version(struct class_device *class_dev,
851 return len; 854 return len;
852} 855}
853 856
854ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf) 857ssize_t aac_show_serial_number(struct device *device,
858 struct device_attribute *attr, char *buf)
855{ 859{
856 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 860 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
857 int len = 0; 861 int len = 0;
858 862
859 if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0) 863 if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0)
@@ -869,35 +873,39 @@ ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf)
869 return len; 873 return len;
870} 874}
871 875
872static ssize_t aac_show_max_channel(struct class_device *class_dev, char *buf) 876static ssize_t aac_show_max_channel(struct device *device,
877 struct device_attribute *attr, char *buf)
873{ 878{
874 return snprintf(buf, PAGE_SIZE, "%d\n", 879 return snprintf(buf, PAGE_SIZE, "%d\n",
875 class_to_shost(class_dev)->max_channel); 880 class_to_shost(device)->max_channel);
876} 881}
877 882
878static ssize_t aac_show_max_id(struct class_device *class_dev, char *buf) 883static ssize_t aac_show_max_id(struct device *device,
884 struct device_attribute *attr, char *buf)
879{ 885{
880 return snprintf(buf, PAGE_SIZE, "%d\n", 886 return snprintf(buf, PAGE_SIZE, "%d\n",
881 class_to_shost(class_dev)->max_id); 887 class_to_shost(device)->max_id);
882} 888}
883 889
884static ssize_t aac_store_reset_adapter(struct class_device *class_dev, 890static ssize_t aac_store_reset_adapter(struct device *device,
885 const char *buf, size_t count) 891 struct device_attribute *attr,
892 const char *buf, size_t count)
886{ 893{
887 int retval = -EACCES; 894 int retval = -EACCES;
888 895
889 if (!capable(CAP_SYS_ADMIN)) 896 if (!capable(CAP_SYS_ADMIN))
890 return retval; 897 return retval;
891 retval = aac_reset_adapter((struct aac_dev*)class_to_shost(class_dev)->hostdata, buf[0] == '!'); 898 retval = aac_reset_adapter((struct aac_dev*)class_to_shost(device)->hostdata, buf[0] == '!');
892 if (retval >= 0) 899 if (retval >= 0)
893 retval = count; 900 retval = count;
894 return retval; 901 return retval;
895} 902}
896 903
897static ssize_t aac_show_reset_adapter(struct class_device *class_dev, 904static ssize_t aac_show_reset_adapter(struct device *device,
898 char *buf) 905 struct device_attribute *attr,
906 char *buf)
899{ 907{
900 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata; 908 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
901 int len, tmp; 909 int len, tmp;
902 910
903 tmp = aac_adapter_check_health(dev); 911 tmp = aac_adapter_check_health(dev);
@@ -907,70 +915,70 @@ static ssize_t aac_show_reset_adapter(struct class_device *class_dev,
907 return len; 915 return len;
908} 916}
909 917
910static struct class_device_attribute aac_model = { 918static struct device_attribute aac_model = {
911 .attr = { 919 .attr = {
912 .name = "model", 920 .name = "model",
913 .mode = S_IRUGO, 921 .mode = S_IRUGO,
914 }, 922 },
915 .show = aac_show_model, 923 .show = aac_show_model,
916}; 924};
917static struct class_device_attribute aac_vendor = { 925static struct device_attribute aac_vendor = {
918 .attr = { 926 .attr = {
919 .name = "vendor", 927 .name = "vendor",
920 .mode = S_IRUGO, 928 .mode = S_IRUGO,
921 }, 929 },
922 .show = aac_show_vendor, 930 .show = aac_show_vendor,
923}; 931};
924static struct class_device_attribute aac_flags = { 932static struct device_attribute aac_flags = {
925 .attr = { 933 .attr = {
926 .name = "flags", 934 .name = "flags",
927 .mode = S_IRUGO, 935 .mode = S_IRUGO,
928 }, 936 },
929 .show = aac_show_flags, 937 .show = aac_show_flags,
930}; 938};
931static struct class_device_attribute aac_kernel_version = { 939static struct device_attribute aac_kernel_version = {
932 .attr = { 940 .attr = {
933 .name = "hba_kernel_version", 941 .name = "hba_kernel_version",
934 .mode = S_IRUGO, 942 .mode = S_IRUGO,
935 }, 943 },
936 .show = aac_show_kernel_version, 944 .show = aac_show_kernel_version,
937}; 945};
938static struct class_device_attribute aac_monitor_version = { 946static struct device_attribute aac_monitor_version = {
939 .attr = { 947 .attr = {
940 .name = "hba_monitor_version", 948 .name = "hba_monitor_version",
941 .mode = S_IRUGO, 949 .mode = S_IRUGO,
942 }, 950 },
943 .show = aac_show_monitor_version, 951 .show = aac_show_monitor_version,
944}; 952};
945static struct class_device_attribute aac_bios_version = { 953static struct device_attribute aac_bios_version = {
946 .attr = { 954 .attr = {
947 .name = "hba_bios_version", 955 .name = "hba_bios_version",
948 .mode = S_IRUGO, 956 .mode = S_IRUGO,
949 }, 957 },
950 .show = aac_show_bios_version, 958 .show = aac_show_bios_version,
951}; 959};
952static struct class_device_attribute aac_serial_number = { 960static struct device_attribute aac_serial_number = {
953 .attr = { 961 .attr = {
954 .name = "serial_number", 962 .name = "serial_number",
955 .mode = S_IRUGO, 963 .mode = S_IRUGO,
956 }, 964 },
957 .show = aac_show_serial_number, 965 .show = aac_show_serial_number,
958}; 966};
959static struct class_device_attribute aac_max_channel = { 967static struct device_attribute aac_max_channel = {
960 .attr = { 968 .attr = {
961 .name = "max_channel", 969 .name = "max_channel",
962 .mode = S_IRUGO, 970 .mode = S_IRUGO,
963 }, 971 },
964 .show = aac_show_max_channel, 972 .show = aac_show_max_channel,
965}; 973};
966static struct class_device_attribute aac_max_id = { 974static struct device_attribute aac_max_id = {
967 .attr = { 975 .attr = {
968 .name = "max_id", 976 .name = "max_id",
969 .mode = S_IRUGO, 977 .mode = S_IRUGO,
970 }, 978 },
971 .show = aac_show_max_id, 979 .show = aac_show_max_id,
972}; 980};
973static struct class_device_attribute aac_reset = { 981static struct device_attribute aac_reset = {
974 .attr = { 982 .attr = {
975 .name = "reset_host", 983 .name = "reset_host",
976 .mode = S_IWUSR|S_IRUGO, 984 .mode = S_IWUSR|S_IRUGO,
@@ -979,7 +987,7 @@ static struct class_device_attribute aac_reset = {
979 .show = aac_show_reset_adapter, 987 .show = aac_show_reset_adapter,
980}; 988};
981 989
982static struct class_device_attribute *aac_attrs[] = { 990static struct device_attribute *aac_attrs[] = {
983 &aac_model, 991 &aac_model,
984 &aac_vendor, 992 &aac_vendor,
985 &aac_flags, 993 &aac_flags,
@@ -993,6 +1001,10 @@ static struct class_device_attribute *aac_attrs[] = {
993 NULL 1001 NULL
994}; 1002};
995 1003
1004ssize_t aac_get_serial_number(struct device *device, char *buf)
1005{
1006 return aac_show_serial_number(device, &aac_serial_number, buf);
1007}
996 1008
997static const struct file_operations aac_cfg_fops = { 1009static const struct file_operations aac_cfg_fops = {
998 .owner = THIS_MODULE, 1010 .owner = THIS_MODULE,
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index 1f18b83e1e02..073208b0f622 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -39,7 +39,6 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/time.h> 40#include <linux/time.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <asm/semaphore.h>
43 42
44#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
45 44
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index cfc3410ec073..fc1a55796a89 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -39,7 +39,6 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/time.h> 40#include <linux/time.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <asm/semaphore.h>
43 42
44#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
45 44
diff --git a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
index 3288be2e49f8..ab646e580d64 100644
--- a/drivers/scsi/arcmsr/arcmsr.h
+++ b/drivers/scsi/arcmsr/arcmsr.h
@@ -44,7 +44,7 @@
44*/ 44*/
45#include <linux/interrupt.h> 45#include <linux/interrupt.h>
46 46
47struct class_device_attribute; 47struct device_attribute;
48/*The limit of outstanding scsi command that firmware can handle*/ 48/*The limit of outstanding scsi command that firmware can handle*/
49#define ARCMSR_MAX_OUTSTANDING_CMD 256 49#define ARCMSR_MAX_OUTSTANDING_CMD 256
50#define ARCMSR_MAX_FREECCB_NUM 320 50#define ARCMSR_MAX_FREECCB_NUM 320
@@ -556,6 +556,6 @@ struct SENSE_DATA
556extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *); 556extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *);
557extern void arcmsr_iop_message_read(struct AdapterControlBlock *); 557extern void arcmsr_iop_message_read(struct AdapterControlBlock *);
558extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); 558extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
559extern struct class_device_attribute *arcmsr_host_attrs[]; 559extern struct device_attribute *arcmsr_host_attrs[];
560extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); 560extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
561void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb); 561void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index 7d7b0a554276..69f8346aa288 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -57,15 +57,15 @@
57#include <scsi/scsi_transport.h> 57#include <scsi/scsi_transport.h>
58#include "arcmsr.h" 58#include "arcmsr.h"
59 59
60struct class_device_attribute *arcmsr_host_attrs[]; 60struct device_attribute *arcmsr_host_attrs[];
61 61
62static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, 62static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj,
63 struct bin_attribute *bin, 63 struct bin_attribute *bin,
64 char *buf, loff_t off, 64 char *buf, loff_t off,
65 size_t count) 65 size_t count)
66{ 66{
67 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 67 struct device *dev = container_of(kobj,struct device,kobj);
68 struct Scsi_Host *host = class_to_shost(cdev); 68 struct Scsi_Host *host = class_to_shost(dev);
69 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 69 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
70 uint8_t *pQbuffer,*ptmpQbuffer; 70 uint8_t *pQbuffer,*ptmpQbuffer;
71 int32_t allxfer_len = 0; 71 int32_t allxfer_len = 0;
@@ -110,8 +110,8 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct kobject *kobj,
110 char *buf, loff_t off, 110 char *buf, loff_t off,
111 size_t count) 111 size_t count)
112{ 112{
113 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 113 struct device *dev = container_of(kobj,struct device,kobj);
114 struct Scsi_Host *host = class_to_shost(cdev); 114 struct Scsi_Host *host = class_to_shost(dev);
115 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 115 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
116 int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex; 116 int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;
117 uint8_t *pQbuffer, *ptmpuserbuffer; 117 uint8_t *pQbuffer, *ptmpuserbuffer;
@@ -158,8 +158,8 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct kobject *kobj,
158 char *buf, loff_t off, 158 char *buf, loff_t off,
159 size_t count) 159 size_t count)
160{ 160{
161 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 161 struct device *dev = container_of(kobj,struct device,kobj);
162 struct Scsi_Host *host = class_to_shost(cdev); 162 struct Scsi_Host *host = class_to_shost(dev);
163 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 163 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
164 uint8_t *pQbuffer; 164 uint8_t *pQbuffer;
165 165
@@ -220,87 +220,104 @@ int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb)
220 struct Scsi_Host *host = acb->host; 220 struct Scsi_Host *host = acb->host;
221 int error; 221 int error;
222 222
223 error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); 223 error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
224 if (error) { 224 if (error) {
225 printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n"); 225 printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n");
226 goto error_bin_file_message_read; 226 goto error_bin_file_message_read;
227 } 227 }
228 error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); 228 error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
229 if (error) { 229 if (error) {
230 printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n"); 230 printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n");
231 goto error_bin_file_message_write; 231 goto error_bin_file_message_write;
232 } 232 }
233 error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr); 233 error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr);
234 if (error) { 234 if (error) {
235 printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n"); 235 printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n");
236 goto error_bin_file_message_clear; 236 goto error_bin_file_message_clear;
237 } 237 }
238 return 0; 238 return 0;
239error_bin_file_message_clear: 239error_bin_file_message_clear:
240 sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); 240 sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
241error_bin_file_message_write: 241error_bin_file_message_write:
242 sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); 242 sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
243error_bin_file_message_read: 243error_bin_file_message_read:
244 return error; 244 return error;
245} 245}
246 246
247void 247void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb)
248arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) { 248{
249 struct Scsi_Host *host = acb->host; 249 struct Scsi_Host *host = acb->host;
250 250
251 sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr); 251 sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr);
252 sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); 252 sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
253 sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); 253 sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
254} 254}
255 255
256 256
257static ssize_t 257static ssize_t
258arcmsr_attr_host_driver_version(struct class_device *cdev, char *buf) { 258arcmsr_attr_host_driver_version(struct device *dev,
259 struct device_attribute *attr, char *buf)
260{
259 return snprintf(buf, PAGE_SIZE, 261 return snprintf(buf, PAGE_SIZE,
260 "%s\n", 262 "%s\n",
261 ARCMSR_DRIVER_VERSION); 263 ARCMSR_DRIVER_VERSION);
262} 264}
263 265
264static ssize_t 266static ssize_t
265arcmsr_attr_host_driver_posted_cmd(struct class_device *cdev, char *buf) { 267arcmsr_attr_host_driver_posted_cmd(struct device *dev,
266 struct Scsi_Host *host = class_to_shost(cdev); 268 struct device_attribute *attr, char *buf)
267 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 269{
270 struct Scsi_Host *host = class_to_shost(dev);
271 struct AdapterControlBlock *acb =
272 (struct AdapterControlBlock *) host->hostdata;
268 return snprintf(buf, PAGE_SIZE, 273 return snprintf(buf, PAGE_SIZE,
269 "%4d\n", 274 "%4d\n",
270 atomic_read(&acb->ccboutstandingcount)); 275 atomic_read(&acb->ccboutstandingcount));
271} 276}
272 277
273static ssize_t 278static ssize_t
274arcmsr_attr_host_driver_reset(struct class_device *cdev, char *buf) { 279arcmsr_attr_host_driver_reset(struct device *dev,
275 struct Scsi_Host *host = class_to_shost(cdev); 280 struct device_attribute *attr, char *buf)
276 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 281{
282 struct Scsi_Host *host = class_to_shost(dev);
283 struct AdapterControlBlock *acb =
284 (struct AdapterControlBlock *) host->hostdata;
277 return snprintf(buf, PAGE_SIZE, 285 return snprintf(buf, PAGE_SIZE,
278 "%4d\n", 286 "%4d\n",
279 acb->num_resets); 287 acb->num_resets);
280} 288}
281 289
282static ssize_t 290static ssize_t
283arcmsr_attr_host_driver_abort(struct class_device *cdev, char *buf) { 291arcmsr_attr_host_driver_abort(struct device *dev,
284 struct Scsi_Host *host = class_to_shost(cdev); 292 struct device_attribute *attr, char *buf)
285 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 293{
294 struct Scsi_Host *host = class_to_shost(dev);
295 struct AdapterControlBlock *acb =
296 (struct AdapterControlBlock *) host->hostdata;
286 return snprintf(buf, PAGE_SIZE, 297 return snprintf(buf, PAGE_SIZE,
287 "%4d\n", 298 "%4d\n",
288 acb->num_aborts); 299 acb->num_aborts);
289} 300}
290 301
291static ssize_t 302static ssize_t
292arcmsr_attr_host_fw_model(struct class_device *cdev, char *buf) { 303arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr,
293 struct Scsi_Host *host = class_to_shost(cdev); 304 char *buf)
294 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 305{
306 struct Scsi_Host *host = class_to_shost(dev);
307 struct AdapterControlBlock *acb =
308 (struct AdapterControlBlock *) host->hostdata;
295 return snprintf(buf, PAGE_SIZE, 309 return snprintf(buf, PAGE_SIZE,
296 "%s\n", 310 "%s\n",
297 acb->firm_model); 311 acb->firm_model);
298} 312}
299 313
300static ssize_t 314static ssize_t
301arcmsr_attr_host_fw_version(struct class_device *cdev, char *buf) { 315arcmsr_attr_host_fw_version(struct device *dev,
302 struct Scsi_Host *host = class_to_shost(cdev); 316 struct device_attribute *attr, char *buf)
303 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 317{
318 struct Scsi_Host *host = class_to_shost(dev);
319 struct AdapterControlBlock *acb =
320 (struct AdapterControlBlock *) host->hostdata;
304 321
305 return snprintf(buf, PAGE_SIZE, 322 return snprintf(buf, PAGE_SIZE,
306 "%s\n", 323 "%s\n",
@@ -308,9 +325,12 @@ arcmsr_attr_host_fw_version(struct class_device *cdev, char *buf) {
308} 325}
309 326
310static ssize_t 327static ssize_t
311arcmsr_attr_host_fw_request_len(struct class_device *cdev, char *buf) { 328arcmsr_attr_host_fw_request_len(struct device *dev,
312 struct Scsi_Host *host = class_to_shost(cdev); 329 struct device_attribute *attr, char *buf)
313 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 330{
331 struct Scsi_Host *host = class_to_shost(dev);
332 struct AdapterControlBlock *acb =
333 (struct AdapterControlBlock *) host->hostdata;
314 334
315 return snprintf(buf, PAGE_SIZE, 335 return snprintf(buf, PAGE_SIZE,
316 "%4d\n", 336 "%4d\n",
@@ -318,9 +338,12 @@ arcmsr_attr_host_fw_request_len(struct class_device *cdev, char *buf) {
318} 338}
319 339
320static ssize_t 340static ssize_t
321arcmsr_attr_host_fw_numbers_queue(struct class_device *cdev, char *buf) { 341arcmsr_attr_host_fw_numbers_queue(struct device *dev,
322 struct Scsi_Host *host = class_to_shost(cdev); 342 struct device_attribute *attr, char *buf)
323 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 343{
344 struct Scsi_Host *host = class_to_shost(dev);
345 struct AdapterControlBlock *acb =
346 (struct AdapterControlBlock *) host->hostdata;
324 347
325 return snprintf(buf, PAGE_SIZE, 348 return snprintf(buf, PAGE_SIZE,
326 "%4d\n", 349 "%4d\n",
@@ -328,9 +351,12 @@ arcmsr_attr_host_fw_numbers_queue(struct class_device *cdev, char *buf) {
328} 351}
329 352
330static ssize_t 353static ssize_t
331arcmsr_attr_host_fw_sdram_size(struct class_device *cdev, char *buf) { 354arcmsr_attr_host_fw_sdram_size(struct device *dev,
332 struct Scsi_Host *host = class_to_shost(cdev); 355 struct device_attribute *attr, char *buf)
333 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 356{
357 struct Scsi_Host *host = class_to_shost(dev);
358 struct AdapterControlBlock *acb =
359 (struct AdapterControlBlock *) host->hostdata;
334 360
335 return snprintf(buf, PAGE_SIZE, 361 return snprintf(buf, PAGE_SIZE,
336 "%4d\n", 362 "%4d\n",
@@ -338,36 +364,39 @@ arcmsr_attr_host_fw_sdram_size(struct class_device *cdev, char *buf) {
338} 364}
339 365
340static ssize_t 366static ssize_t
341arcmsr_attr_host_fw_hd_channels(struct class_device *cdev, char *buf) { 367arcmsr_attr_host_fw_hd_channels(struct device *dev,
342 struct Scsi_Host *host = class_to_shost(cdev); 368 struct device_attribute *attr, char *buf)
343 struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 369{
370 struct Scsi_Host *host = class_to_shost(dev);
371 struct AdapterControlBlock *acb =
372 (struct AdapterControlBlock *) host->hostdata;
344 373
345 return snprintf(buf, PAGE_SIZE, 374 return snprintf(buf, PAGE_SIZE,
346 "%4d\n", 375 "%4d\n",
347 acb->firm_hd_channels); 376 acb->firm_hd_channels);
348} 377}
349 378
350static CLASS_DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); 379static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL);
351static CLASS_DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); 380static DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL);
352static CLASS_DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); 381static DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL);
353static CLASS_DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); 382static DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL);
354static CLASS_DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); 383static DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL);
355static CLASS_DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); 384static DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL);
356static CLASS_DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); 385static DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL);
357static CLASS_DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); 386static DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL);
358static CLASS_DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); 387static DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL);
359static CLASS_DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); 388static DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL);
360 389
361struct class_device_attribute *arcmsr_host_attrs[] = { 390struct device_attribute *arcmsr_host_attrs[] = {
362 &class_device_attr_host_driver_version, 391 &dev_attr_host_driver_version,
363 &class_device_attr_host_driver_posted_cmd, 392 &dev_attr_host_driver_posted_cmd,
364 &class_device_attr_host_driver_reset, 393 &dev_attr_host_driver_reset,
365 &class_device_attr_host_driver_abort, 394 &dev_attr_host_driver_abort,
366 &class_device_attr_host_fw_model, 395 &dev_attr_host_fw_model,
367 &class_device_attr_host_fw_version, 396 &dev_attr_host_fw_version,
368 &class_device_attr_host_fw_request_len, 397 &dev_attr_host_fw_request_len,
369 &class_device_attr_host_fw_numbers_queue, 398 &dev_attr_host_fw_numbers_queue,
370 &class_device_attr_host_fw_sdram_size, 399 &dev_attr_host_fw_sdram_size,
371 &class_device_attr_host_fw_hd_channels, 400 &dev_attr_host_fw_hd_channels,
372 NULL, 401 NULL,
373}; 402};
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 92d1cb1b21cb..75c84d7b9ce8 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -881,7 +881,7 @@ static long ch_ioctl_compat(struct file * file,
881static int ch_probe(struct device *dev) 881static int ch_probe(struct device *dev)
882{ 882{
883 struct scsi_device *sd = to_scsi_device(dev); 883 struct scsi_device *sd = to_scsi_device(dev);
884 struct class_device *class_dev; 884 struct device *class_dev;
885 int minor, ret = -ENOMEM; 885 int minor, ret = -ENOMEM;
886 scsi_changer *ch; 886 scsi_changer *ch;
887 887
@@ -910,11 +910,11 @@ static int ch_probe(struct device *dev)
910 ch->minor = minor; 910 ch->minor = minor;
911 sprintf(ch->name,"ch%d",ch->minor); 911 sprintf(ch->name,"ch%d",ch->minor);
912 912
913 class_dev = class_device_create(ch_sysfs_class, NULL, 913 class_dev = device_create(ch_sysfs_class, dev,
914 MKDEV(SCSI_CHANGER_MAJOR, ch->minor), 914 MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
915 dev, "s%s", ch->name); 915 "s%s", ch->name);
916 if (IS_ERR(class_dev)) { 916 if (IS_ERR(class_dev)) {
917 printk(KERN_WARNING "ch%d: class_device_create failed\n", 917 printk(KERN_WARNING "ch%d: device_create failed\n",
918 ch->minor); 918 ch->minor);
919 ret = PTR_ERR(class_dev); 919 ret = PTR_ERR(class_dev);
920 goto remove_idr; 920 goto remove_idr;
@@ -945,8 +945,7 @@ static int ch_remove(struct device *dev)
945 idr_remove(&ch_index_idr, ch->minor); 945 idr_remove(&ch_index_idr, ch->minor);
946 spin_unlock(&ch_index_lock); 946 spin_unlock(&ch_index_lock);
947 947
948 class_device_destroy(ch_sysfs_class, 948 device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
949 MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
950 kfree(ch->dt); 949 kfree(ch->dt);
951 kfree(ch); 950 kfree(ch);
952 return 0; 951 return 0;
diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h
index 100b49baca7f..19406cea6d6a 100644
--- a/drivers/scsi/dpt/dpti_i2o.h
+++ b/drivers/scsi/dpt/dpti_i2o.h
@@ -21,7 +21,6 @@
21 21
22#include <linux/i2o-dev.h> 22#include <linux/i2o-dev.h>
23 23
24#include <asm/semaphore.h> /* Needed for MUTEX init macros */
25#include <linux/version.h> 24#include <linux/version.h>
26#include <linux/notifier.h> 25#include <linux/notifier.h>
27#include <asm/atomic.h> 26#include <asm/atomic.h>
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 1592640a87b5..c264a8c5f01e 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -43,14 +43,14 @@
43static int scsi_host_next_hn; /* host_no for next new host */ 43static int scsi_host_next_hn; /* host_no for next new host */
44 44
45 45
46static void scsi_host_cls_release(struct class_device *class_dev) 46static void scsi_host_cls_release(struct device *dev)
47{ 47{
48 put_device(&class_to_shost(class_dev)->shost_gendev); 48 put_device(&class_to_shost(dev)->shost_gendev);
49} 49}
50 50
51static struct class shost_class = { 51static struct class shost_class = {
52 .name = "scsi_host", 52 .name = "scsi_host",
53 .release = scsi_host_cls_release, 53 .dev_release = scsi_host_cls_release,
54}; 54};
55 55
56/** 56/**
@@ -174,7 +174,7 @@ void scsi_remove_host(struct Scsi_Host *shost)
174 spin_unlock_irqrestore(shost->host_lock, flags); 174 spin_unlock_irqrestore(shost->host_lock, flags);
175 175
176 transport_unregister_device(&shost->shost_gendev); 176 transport_unregister_device(&shost->shost_gendev);
177 class_device_unregister(&shost->shost_classdev); 177 device_unregister(&shost->shost_dev);
178 device_del(&shost->shost_gendev); 178 device_del(&shost->shost_gendev);
179 scsi_proc_hostdir_rm(shost->hostt); 179 scsi_proc_hostdir_rm(shost->hostt);
180} 180}
@@ -212,7 +212,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
212 scsi_host_set_state(shost, SHOST_RUNNING); 212 scsi_host_set_state(shost, SHOST_RUNNING);
213 get_device(shost->shost_gendev.parent); 213 get_device(shost->shost_gendev.parent);
214 214
215 error = class_device_add(&shost->shost_classdev); 215 error = device_add(&shost->shost_dev);
216 if (error) 216 if (error)
217 goto out_del_gendev; 217 goto out_del_gendev;
218 218
@@ -223,7 +223,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
223 GFP_KERNEL); 223 GFP_KERNEL);
224 if (shost->shost_data == NULL) { 224 if (shost->shost_data == NULL) {
225 error = -ENOMEM; 225 error = -ENOMEM;
226 goto out_del_classdev; 226 goto out_del_dev;
227 } 227 }
228 } 228 }
229 229
@@ -250,8 +250,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
250 destroy_workqueue(shost->work_q); 250 destroy_workqueue(shost->work_q);
251 out_free_shost_data: 251 out_free_shost_data:
252 kfree(shost->shost_data); 252 kfree(shost->shost_data);
253 out_del_classdev: 253 out_del_dev:
254 class_device_del(&shost->shost_classdev); 254 device_del(&shost->shost_dev);
255 out_del_gendev: 255 out_del_gendev:
256 device_del(&shost->shost_gendev); 256 device_del(&shost->shost_gendev);
257 out: 257 out:
@@ -385,11 +385,11 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
385 shost->host_no); 385 shost->host_no);
386 shost->shost_gendev.release = scsi_host_dev_release; 386 shost->shost_gendev.release = scsi_host_dev_release;
387 387
388 class_device_initialize(&shost->shost_classdev); 388 device_initialize(&shost->shost_dev);
389 shost->shost_classdev.dev = &shost->shost_gendev; 389 shost->shost_dev.parent = &shost->shost_gendev;
390 shost->shost_classdev.class = &shost_class; 390 shost->shost_dev.class = &shost_class;
391 snprintf(shost->shost_classdev.class_id, BUS_ID_SIZE, "host%d", 391 snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d",
392 shost->host_no); 392 shost->host_no);
393 393
394 shost->ehandler = kthread_run(scsi_error_handler, shost, 394 shost->ehandler = kthread_run(scsi_error_handler, shost,
395 "scsi_eh_%d", shost->host_no); 395 "scsi_eh_%d", shost->host_no);
@@ -432,12 +432,12 @@ void scsi_unregister(struct Scsi_Host *shost)
432} 432}
433EXPORT_SYMBOL(scsi_unregister); 433EXPORT_SYMBOL(scsi_unregister);
434 434
435static int __scsi_host_match(struct class_device *cdev, void *data) 435static int __scsi_host_match(struct device *dev, void *data)
436{ 436{
437 struct Scsi_Host *p; 437 struct Scsi_Host *p;
438 unsigned short *hostnum = (unsigned short *)data; 438 unsigned short *hostnum = (unsigned short *)data;
439 439
440 p = class_to_shost(cdev); 440 p = class_to_shost(dev);
441 return p->host_no == *hostnum; 441 return p->host_no == *hostnum;
442} 442}
443 443
@@ -450,10 +450,10 @@ static int __scsi_host_match(struct class_device *cdev, void *data)
450 **/ 450 **/
451struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) 451struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
452{ 452{
453 struct class_device *cdev; 453 struct device *cdev;
454 struct Scsi_Host *shost = ERR_PTR(-ENXIO); 454 struct Scsi_Host *shost = ERR_PTR(-ENXIO);
455 455
456 cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match); 456 cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
457 if (cdev) 457 if (cdev)
458 shost = scsi_host_get(class_to_shost(cdev)); 458 shost = scsi_host_get(class_to_shost(cdev));
459 459
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index beecda991682..5b7be1e9841c 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -859,14 +859,16 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,
859 return queue_depth; 859 return queue_depth;
860} 860}
861 861
862static ssize_t hptiop_show_version(struct class_device *class_dev, char *buf) 862static ssize_t hptiop_show_version(struct device *dev,
863 struct device_attribute *attr, char *buf)
863{ 864{
864 return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver); 865 return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver);
865} 866}
866 867
867static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf) 868static ssize_t hptiop_show_fw_version(struct device *dev,
869 struct device_attribute *attr, char *buf)
868{ 870{
869 struct Scsi_Host *host = class_to_shost(class_dev); 871 struct Scsi_Host *host = class_to_shost(dev);
870 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; 872 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;
871 873
872 return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", 874 return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n",
@@ -876,7 +878,7 @@ static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf)
876 hba->firmware_version & 0xff); 878 hba->firmware_version & 0xff);
877} 879}
878 880
879static struct class_device_attribute hptiop_attr_version = { 881static struct device_attribute hptiop_attr_version = {
880 .attr = { 882 .attr = {
881 .name = "driver-version", 883 .name = "driver-version",
882 .mode = S_IRUGO, 884 .mode = S_IRUGO,
@@ -884,7 +886,7 @@ static struct class_device_attribute hptiop_attr_version = {
884 .show = hptiop_show_version, 886 .show = hptiop_show_version,
885}; 887};
886 888
887static struct class_device_attribute hptiop_attr_fw_version = { 889static struct device_attribute hptiop_attr_fw_version = {
888 .attr = { 890 .attr = {
889 .name = "firmware-version", 891 .name = "firmware-version",
890 .mode = S_IRUGO, 892 .mode = S_IRUGO,
@@ -892,7 +894,7 @@ static struct class_device_attribute hptiop_attr_fw_version = {
892 .show = hptiop_show_fw_version, 894 .show = hptiop_show_fw_version,
893}; 895};
894 896
895static struct class_device_attribute *hptiop_attrs[] = { 897static struct device_attribute *hptiop_attrs[] = {
896 &hptiop_attr_version, 898 &hptiop_attr_version,
897 &hptiop_attr_fw_version, 899 &hptiop_attr_fw_version,
898 NULL 900 NULL
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 78d46a900bb5..4a922c57125e 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1456,9 +1456,10 @@ static int ibmvscsi_change_queue_depth(struct scsi_device *sdev, int qdepth)
1456/* ------------------------------------------------------------ 1456/* ------------------------------------------------------------
1457 * sysfs attributes 1457 * sysfs attributes
1458 */ 1458 */
1459static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf) 1459static ssize_t show_host_srp_version(struct device *dev,
1460 struct device_attribute *attr, char *buf)
1460{ 1461{
1461 struct Scsi_Host *shost = class_to_shost(class_dev); 1462 struct Scsi_Host *shost = class_to_shost(dev);
1462 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1463 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1463 int len; 1464 int len;
1464 1465
@@ -1467,7 +1468,7 @@ static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf)
1467 return len; 1468 return len;
1468} 1469}
1469 1470
1470static struct class_device_attribute ibmvscsi_host_srp_version = { 1471static struct device_attribute ibmvscsi_host_srp_version = {
1471 .attr = { 1472 .attr = {
1472 .name = "srp_version", 1473 .name = "srp_version",
1473 .mode = S_IRUGO, 1474 .mode = S_IRUGO,
@@ -1475,10 +1476,11 @@ static struct class_device_attribute ibmvscsi_host_srp_version = {
1475 .show = show_host_srp_version, 1476 .show = show_host_srp_version,
1476}; 1477};
1477 1478
1478static ssize_t show_host_partition_name(struct class_device *class_dev, 1479static ssize_t show_host_partition_name(struct device *dev,
1480 struct device_attribute *attr,
1479 char *buf) 1481 char *buf)
1480{ 1482{
1481 struct Scsi_Host *shost = class_to_shost(class_dev); 1483 struct Scsi_Host *shost = class_to_shost(dev);
1482 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1484 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1483 int len; 1485 int len;
1484 1486
@@ -1487,7 +1489,7 @@ static ssize_t show_host_partition_name(struct class_device *class_dev,
1487 return len; 1489 return len;
1488} 1490}
1489 1491
1490static struct class_device_attribute ibmvscsi_host_partition_name = { 1492static struct device_attribute ibmvscsi_host_partition_name = {
1491 .attr = { 1493 .attr = {
1492 .name = "partition_name", 1494 .name = "partition_name",
1493 .mode = S_IRUGO, 1495 .mode = S_IRUGO,
@@ -1495,10 +1497,11 @@ static struct class_device_attribute ibmvscsi_host_partition_name = {
1495 .show = show_host_partition_name, 1497 .show = show_host_partition_name,
1496}; 1498};
1497 1499
1498static ssize_t show_host_partition_number(struct class_device *class_dev, 1500static ssize_t show_host_partition_number(struct device *dev,
1501 struct device_attribute *attr,
1499 char *buf) 1502 char *buf)
1500{ 1503{
1501 struct Scsi_Host *shost = class_to_shost(class_dev); 1504 struct Scsi_Host *shost = class_to_shost(dev);
1502 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1505 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1503 int len; 1506 int len;
1504 1507
@@ -1507,7 +1510,7 @@ static ssize_t show_host_partition_number(struct class_device *class_dev,
1507 return len; 1510 return len;
1508} 1511}
1509 1512
1510static struct class_device_attribute ibmvscsi_host_partition_number = { 1513static struct device_attribute ibmvscsi_host_partition_number = {
1511 .attr = { 1514 .attr = {
1512 .name = "partition_number", 1515 .name = "partition_number",
1513 .mode = S_IRUGO, 1516 .mode = S_IRUGO,
@@ -1515,9 +1518,10 @@ static struct class_device_attribute ibmvscsi_host_partition_number = {
1515 .show = show_host_partition_number, 1518 .show = show_host_partition_number,
1516}; 1519};
1517 1520
1518static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf) 1521static ssize_t show_host_mad_version(struct device *dev,
1522 struct device_attribute *attr, char *buf)
1519{ 1523{
1520 struct Scsi_Host *shost = class_to_shost(class_dev); 1524 struct Scsi_Host *shost = class_to_shost(dev);
1521 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1525 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1522 int len; 1526 int len;
1523 1527
@@ -1526,7 +1530,7 @@ static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf)
1526 return len; 1530 return len;
1527} 1531}
1528 1532
1529static struct class_device_attribute ibmvscsi_host_mad_version = { 1533static struct device_attribute ibmvscsi_host_mad_version = {
1530 .attr = { 1534 .attr = {
1531 .name = "mad_version", 1535 .name = "mad_version",
1532 .mode = S_IRUGO, 1536 .mode = S_IRUGO,
@@ -1534,9 +1538,10 @@ static struct class_device_attribute ibmvscsi_host_mad_version = {
1534 .show = show_host_mad_version, 1538 .show = show_host_mad_version,
1535}; 1539};
1536 1540
1537static ssize_t show_host_os_type(struct class_device *class_dev, char *buf) 1541static ssize_t show_host_os_type(struct device *dev,
1542 struct device_attribute *attr, char *buf)
1538{ 1543{
1539 struct Scsi_Host *shost = class_to_shost(class_dev); 1544 struct Scsi_Host *shost = class_to_shost(dev);
1540 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1545 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1541 int len; 1546 int len;
1542 1547
@@ -1544,7 +1549,7 @@ static ssize_t show_host_os_type(struct class_device *class_dev, char *buf)
1544 return len; 1549 return len;
1545} 1550}
1546 1551
1547static struct class_device_attribute ibmvscsi_host_os_type = { 1552static struct device_attribute ibmvscsi_host_os_type = {
1548 .attr = { 1553 .attr = {
1549 .name = "os_type", 1554 .name = "os_type",
1550 .mode = S_IRUGO, 1555 .mode = S_IRUGO,
@@ -1552,9 +1557,10 @@ static struct class_device_attribute ibmvscsi_host_os_type = {
1552 .show = show_host_os_type, 1557 .show = show_host_os_type,
1553}; 1558};
1554 1559
1555static ssize_t show_host_config(struct class_device *class_dev, char *buf) 1560static ssize_t show_host_config(struct device *dev,
1561 struct device_attribute *attr, char *buf)
1556{ 1562{
1557 struct Scsi_Host *shost = class_to_shost(class_dev); 1563 struct Scsi_Host *shost = class_to_shost(dev);
1558 struct ibmvscsi_host_data *hostdata = shost_priv(shost); 1564 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1559 1565
1560 /* returns null-terminated host config data */ 1566 /* returns null-terminated host config data */
@@ -1564,7 +1570,7 @@ static ssize_t show_host_config(struct class_device *class_dev, char *buf)
1564 return 0; 1570 return 0;
1565} 1571}
1566 1572
1567static struct class_device_attribute ibmvscsi_host_config = { 1573static struct device_attribute ibmvscsi_host_config = {
1568 .attr = { 1574 .attr = {
1569 .name = "config", 1575 .name = "config",
1570 .mode = S_IRUGO, 1576 .mode = S_IRUGO,
@@ -1572,7 +1578,7 @@ static struct class_device_attribute ibmvscsi_host_config = {
1572 .show = show_host_config, 1578 .show = show_host_config,
1573}; 1579};
1574 1580
1575static struct class_device_attribute *ibmvscsi_attrs[] = { 1581static struct device_attribute *ibmvscsi_attrs[] = {
1576 &ibmvscsi_host_srp_version, 1582 &ibmvscsi_host_srp_version,
1577 &ibmvscsi_host_partition_name, 1583 &ibmvscsi_host_partition_name,
1578 &ibmvscsi_host_partition_number, 1584 &ibmvscsi_host_partition_number,
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index e5881e92d0fb..3b9514c8f1f1 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -780,32 +780,35 @@ static int ibmvstgt_it_nexus_response(struct Scsi_Host *shost, u64 itn_id,
780 return 0; 780 return 0;
781} 781}
782 782
783static ssize_t system_id_show(struct class_device *cdev, char *buf) 783static ssize_t system_id_show(struct device *dev,
784 struct device_attribute *attr, char *buf)
784{ 785{
785 return snprintf(buf, PAGE_SIZE, "%s\n", system_id); 786 return snprintf(buf, PAGE_SIZE, "%s\n", system_id);
786} 787}
787 788
788static ssize_t partition_number_show(struct class_device *cdev, char *buf) 789static ssize_t partition_number_show(struct device *dev,
790 struct device_attribute *attr, char *buf)
789{ 791{
790 return snprintf(buf, PAGE_SIZE, "%x\n", partition_number); 792 return snprintf(buf, PAGE_SIZE, "%x\n", partition_number);
791} 793}
792 794
793static ssize_t unit_address_show(struct class_device *cdev, char *buf) 795static ssize_t unit_address_show(struct device *dev,
796 struct device_attribute *attr, char *buf)
794{ 797{
795 struct Scsi_Host *shost = class_to_shost(cdev); 798 struct Scsi_Host *shost = class_to_shost(dev);
796 struct srp_target *target = host_to_srp_target(shost); 799 struct srp_target *target = host_to_srp_target(shost);
797 struct vio_port *vport = target_to_port(target); 800 struct vio_port *vport = target_to_port(target);
798 return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address); 801 return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address);
799} 802}
800 803
801static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL); 804static DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL);
802static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL); 805static DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
803static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL); 806static DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
804 807
805static struct class_device_attribute *ibmvstgt_attrs[] = { 808static struct device_attribute *ibmvstgt_attrs[] = {
806 &class_device_attr_system_id, 809 &dev_attr_system_id,
807 &class_device_attr_partition_number, 810 &dev_attr_partition_number,
808 &class_device_attr_unit_address, 811 &dev_attr_unit_address,
809 NULL, 812 NULL,
810}; 813};
811 814
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 65dc18dea845..de5ae6a65029 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2431,7 +2431,7 @@ restart:
2431 } 2431 }
2432 2432
2433 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 2433 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2434 kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE); 2434 kobject_uevent(&ioa_cfg->host->shost_dev.kobj, KOBJ_CHANGE);
2435 LEAVE; 2435 LEAVE;
2436} 2436}
2437 2437
@@ -2451,8 +2451,8 @@ static ssize_t ipr_read_trace(struct kobject *kobj,
2451 struct bin_attribute *bin_attr, 2451 struct bin_attribute *bin_attr,
2452 char *buf, loff_t off, size_t count) 2452 char *buf, loff_t off, size_t count)
2453{ 2453{
2454 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 2454 struct device *dev = container_of(kobj, struct device, kobj);
2455 struct Scsi_Host *shost = class_to_shost(cdev); 2455 struct Scsi_Host *shost = class_to_shost(dev);
2456 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2456 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2457 unsigned long lock_flags = 0; 2457 unsigned long lock_flags = 0;
2458 int size = IPR_TRACE_SIZE; 2458 int size = IPR_TRACE_SIZE;
@@ -2492,15 +2492,16 @@ static const struct {
2492 2492
2493/** 2493/**
2494 * ipr_show_write_caching - Show the write caching attribute 2494 * ipr_show_write_caching - Show the write caching attribute
2495 * @class_dev: class device struct 2495 * @dev: device struct
2496 * @buf: buffer 2496 * @buf: buffer
2497 * 2497 *
2498 * Return value: 2498 * Return value:
2499 * number of bytes printed to buffer 2499 * number of bytes printed to buffer
2500 **/ 2500 **/
2501static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf) 2501static ssize_t ipr_show_write_caching(struct device *dev,
2502 struct device_attribute *attr, char *buf)
2502{ 2503{
2503 struct Scsi_Host *shost = class_to_shost(class_dev); 2504 struct Scsi_Host *shost = class_to_shost(dev);
2504 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2505 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2505 unsigned long lock_flags = 0; 2506 unsigned long lock_flags = 0;
2506 int i, len = 0; 2507 int i, len = 0;
@@ -2519,19 +2520,20 @@ static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf)
2519 2520
2520/** 2521/**
2521 * ipr_store_write_caching - Enable/disable adapter write cache 2522 * ipr_store_write_caching - Enable/disable adapter write cache
2522 * @class_dev: class_device struct 2523 * @dev: device struct
2523 * @buf: buffer 2524 * @buf: buffer
2524 * @count: buffer size 2525 * @count: buffer size
2525 * 2526 *
2526 * This function will enable/disable adapter write cache. 2527 * This function will enable/disable adapter write cache.
2527 * 2528 *
2528 * Return value: 2529 * Return value:
2529 * count on success / other on failure 2530 * count on success / other on failure
2530 **/ 2531 **/
2531static ssize_t ipr_store_write_caching(struct class_device *class_dev, 2532static ssize_t ipr_store_write_caching(struct device *dev,
2532 const char *buf, size_t count) 2533 struct device_attribute *attr,
2534 const char *buf, size_t count)
2533{ 2535{
2534 struct Scsi_Host *shost = class_to_shost(class_dev); 2536 struct Scsi_Host *shost = class_to_shost(dev);
2535 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2537 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2536 unsigned long lock_flags = 0; 2538 unsigned long lock_flags = 0;
2537 enum ipr_cache_state new_state = CACHE_INVALID; 2539 enum ipr_cache_state new_state = CACHE_INVALID;
@@ -2569,7 +2571,7 @@ static ssize_t ipr_store_write_caching(struct class_device *class_dev,
2569 return count; 2571 return count;
2570} 2572}
2571 2573
2572static struct class_device_attribute ipr_ioa_cache_attr = { 2574static struct device_attribute ipr_ioa_cache_attr = {
2573 .attr = { 2575 .attr = {
2574 .name = "write_cache", 2576 .name = "write_cache",
2575 .mode = S_IRUGO | S_IWUSR, 2577 .mode = S_IRUGO | S_IWUSR,
@@ -2580,15 +2582,16 @@ static struct class_device_attribute ipr_ioa_cache_attr = {
2580 2582
2581/** 2583/**
2582 * ipr_show_fw_version - Show the firmware version 2584 * ipr_show_fw_version - Show the firmware version
2583 * @class_dev: class device struct 2585 * @dev: class device struct
2584 * @buf: buffer 2586 * @buf: buffer
2585 * 2587 *
2586 * Return value: 2588 * Return value:
2587 * number of bytes printed to buffer 2589 * number of bytes printed to buffer
2588 **/ 2590 **/
2589static ssize_t ipr_show_fw_version(struct class_device *class_dev, char *buf) 2591static ssize_t ipr_show_fw_version(struct device *dev,
2592 struct device_attribute *attr, char *buf)
2590{ 2593{
2591 struct Scsi_Host *shost = class_to_shost(class_dev); 2594 struct Scsi_Host *shost = class_to_shost(dev);
2592 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2595 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2593 struct ipr_inquiry_page3 *ucode_vpd = &ioa_cfg->vpd_cbs->page3_data; 2596 struct ipr_inquiry_page3 *ucode_vpd = &ioa_cfg->vpd_cbs->page3_data;
2594 unsigned long lock_flags = 0; 2597 unsigned long lock_flags = 0;
@@ -2603,7 +2606,7 @@ static ssize_t ipr_show_fw_version(struct class_device *class_dev, char *buf)
2603 return len; 2606 return len;
2604} 2607}
2605 2608
2606static struct class_device_attribute ipr_fw_version_attr = { 2609static struct device_attribute ipr_fw_version_attr = {
2607 .attr = { 2610 .attr = {
2608 .name = "fw_version", 2611 .name = "fw_version",
2609 .mode = S_IRUGO, 2612 .mode = S_IRUGO,
@@ -2613,15 +2616,16 @@ static struct class_device_attribute ipr_fw_version_attr = {
2613 2616
2614/** 2617/**
2615 * ipr_show_log_level - Show the adapter's error logging level 2618 * ipr_show_log_level - Show the adapter's error logging level
2616 * @class_dev: class device struct 2619 * @dev: class device struct
2617 * @buf: buffer 2620 * @buf: buffer
2618 * 2621 *
2619 * Return value: 2622 * Return value:
2620 * number of bytes printed to buffer 2623 * number of bytes printed to buffer
2621 **/ 2624 **/
2622static ssize_t ipr_show_log_level(struct class_device *class_dev, char *buf) 2625static ssize_t ipr_show_log_level(struct device *dev,
2626 struct device_attribute *attr, char *buf)
2623{ 2627{
2624 struct Scsi_Host *shost = class_to_shost(class_dev); 2628 struct Scsi_Host *shost = class_to_shost(dev);
2625 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2629 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2626 unsigned long lock_flags = 0; 2630 unsigned long lock_flags = 0;
2627 int len; 2631 int len;
@@ -2634,16 +2638,17 @@ static ssize_t ipr_show_log_level(struct class_device *class_dev, char *buf)
2634 2638
2635/** 2639/**
2636 * ipr_store_log_level - Change the adapter's error logging level 2640 * ipr_store_log_level - Change the adapter's error logging level
2637 * @class_dev: class device struct 2641 * @dev: class device struct
2638 * @buf: buffer 2642 * @buf: buffer
2639 * 2643 *
2640 * Return value: 2644 * Return value:
2641 * number of bytes printed to buffer 2645 * number of bytes printed to buffer
2642 **/ 2646 **/
2643static ssize_t ipr_store_log_level(struct class_device *class_dev, 2647static ssize_t ipr_store_log_level(struct device *dev,
2648 struct device_attribute *attr,
2644 const char *buf, size_t count) 2649 const char *buf, size_t count)
2645{ 2650{
2646 struct Scsi_Host *shost = class_to_shost(class_dev); 2651 struct Scsi_Host *shost = class_to_shost(dev);
2647 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2652 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2648 unsigned long lock_flags = 0; 2653 unsigned long lock_flags = 0;
2649 2654
@@ -2653,7 +2658,7 @@ static ssize_t ipr_store_log_level(struct class_device *class_dev,
2653 return strlen(buf); 2658 return strlen(buf);
2654} 2659}
2655 2660
2656static struct class_device_attribute ipr_log_level_attr = { 2661static struct device_attribute ipr_log_level_attr = {
2657 .attr = { 2662 .attr = {
2658 .name = "log_level", 2663 .name = "log_level",
2659 .mode = S_IRUGO | S_IWUSR, 2664 .mode = S_IRUGO | S_IWUSR,
@@ -2664,9 +2669,9 @@ static struct class_device_attribute ipr_log_level_attr = {
2664 2669
2665/** 2670/**
2666 * ipr_store_diagnostics - IOA Diagnostics interface 2671 * ipr_store_diagnostics - IOA Diagnostics interface
2667 * @class_dev: class_device struct 2672 * @dev: device struct
2668 * @buf: buffer 2673 * @buf: buffer
2669 * @count: buffer size 2674 * @count: buffer size
2670 * 2675 *
2671 * This function will reset the adapter and wait a reasonable 2676 * This function will reset the adapter and wait a reasonable
2672 * amount of time for any errors that the adapter might log. 2677 * amount of time for any errors that the adapter might log.
@@ -2674,10 +2679,11 @@ static struct class_device_attribute ipr_log_level_attr = {
2674 * Return value: 2679 * Return value:
2675 * count on success / other on failure 2680 * count on success / other on failure
2676 **/ 2681 **/
2677static ssize_t ipr_store_diagnostics(struct class_device *class_dev, 2682static ssize_t ipr_store_diagnostics(struct device *dev,
2683 struct device_attribute *attr,
2678 const char *buf, size_t count) 2684 const char *buf, size_t count)
2679{ 2685{
2680 struct Scsi_Host *shost = class_to_shost(class_dev); 2686 struct Scsi_Host *shost = class_to_shost(dev);
2681 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2687 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2682 unsigned long lock_flags = 0; 2688 unsigned long lock_flags = 0;
2683 int rc = count; 2689 int rc = count;
@@ -2714,7 +2720,7 @@ static ssize_t ipr_store_diagnostics(struct class_device *class_dev,
2714 return rc; 2720 return rc;
2715} 2721}
2716 2722
2717static struct class_device_attribute ipr_diagnostics_attr = { 2723static struct device_attribute ipr_diagnostics_attr = {
2718 .attr = { 2724 .attr = {
2719 .name = "run_diagnostics", 2725 .name = "run_diagnostics",
2720 .mode = S_IWUSR, 2726 .mode = S_IWUSR,
@@ -2724,15 +2730,16 @@ static struct class_device_attribute ipr_diagnostics_attr = {
2724 2730
2725/** 2731/**
2726 * ipr_show_adapter_state - Show the adapter's state 2732 * ipr_show_adapter_state - Show the adapter's state
2727 * @class_dev: class device struct 2733 * @class_dev: device struct
2728 * @buf: buffer 2734 * @buf: buffer
2729 * 2735 *
2730 * Return value: 2736 * Return value:
2731 * number of bytes printed to buffer 2737 * number of bytes printed to buffer
2732 **/ 2738 **/
2733static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf) 2739static ssize_t ipr_show_adapter_state(struct device *dev,
2740 struct device_attribute *attr, char *buf)
2734{ 2741{
2735 struct Scsi_Host *shost = class_to_shost(class_dev); 2742 struct Scsi_Host *shost = class_to_shost(dev);
2736 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2743 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2737 unsigned long lock_flags = 0; 2744 unsigned long lock_flags = 0;
2738 int len; 2745 int len;
@@ -2748,19 +2755,20 @@ static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf)
2748 2755
2749/** 2756/**
2750 * ipr_store_adapter_state - Change adapter state 2757 * ipr_store_adapter_state - Change adapter state
2751 * @class_dev: class_device struct 2758 * @dev: device struct
2752 * @buf: buffer 2759 * @buf: buffer
2753 * @count: buffer size 2760 * @count: buffer size
2754 * 2761 *
2755 * This function will change the adapter's state. 2762 * This function will change the adapter's state.
2756 * 2763 *
2757 * Return value: 2764 * Return value:
2758 * count on success / other on failure 2765 * count on success / other on failure
2759 **/ 2766 **/
2760static ssize_t ipr_store_adapter_state(struct class_device *class_dev, 2767static ssize_t ipr_store_adapter_state(struct device *dev,
2768 struct device_attribute *attr,
2761 const char *buf, size_t count) 2769 const char *buf, size_t count)
2762{ 2770{
2763 struct Scsi_Host *shost = class_to_shost(class_dev); 2771 struct Scsi_Host *shost = class_to_shost(dev);
2764 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2772 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2765 unsigned long lock_flags; 2773 unsigned long lock_flags;
2766 int result = count; 2774 int result = count;
@@ -2781,7 +2789,7 @@ static ssize_t ipr_store_adapter_state(struct class_device *class_dev,
2781 return result; 2789 return result;
2782} 2790}
2783 2791
2784static struct class_device_attribute ipr_ioa_state_attr = { 2792static struct device_attribute ipr_ioa_state_attr = {
2785 .attr = { 2793 .attr = {
2786 .name = "state", 2794 .name = "state",
2787 .mode = S_IRUGO | S_IWUSR, 2795 .mode = S_IRUGO | S_IWUSR,
@@ -2792,19 +2800,20 @@ static struct class_device_attribute ipr_ioa_state_attr = {
2792 2800
2793/** 2801/**
2794 * ipr_store_reset_adapter - Reset the adapter 2802 * ipr_store_reset_adapter - Reset the adapter
2795 * @class_dev: class_device struct 2803 * @dev: device struct
2796 * @buf: buffer 2804 * @buf: buffer
2797 * @count: buffer size 2805 * @count: buffer size
2798 * 2806 *
2799 * This function will reset the adapter. 2807 * This function will reset the adapter.
2800 * 2808 *
2801 * Return value: 2809 * Return value:
2802 * count on success / other on failure 2810 * count on success / other on failure
2803 **/ 2811 **/
2804static ssize_t ipr_store_reset_adapter(struct class_device *class_dev, 2812static ssize_t ipr_store_reset_adapter(struct device *dev,
2813 struct device_attribute *attr,
2805 const char *buf, size_t count) 2814 const char *buf, size_t count)
2806{ 2815{
2807 struct Scsi_Host *shost = class_to_shost(class_dev); 2816 struct Scsi_Host *shost = class_to_shost(dev);
2808 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 2817 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2809 unsigned long lock_flags; 2818 unsigned long lock_flags;
2810 int result = count; 2819 int result = count;
@@ -2821,7 +2830,7 @@ static ssize_t ipr_store_reset_adapter(struct class_device *class_dev,
2821 return result; 2830 return result;
2822} 2831}
2823 2832
2824static struct class_device_attribute ipr_ioa_reset_attr = { 2833static struct device_attribute ipr_ioa_reset_attr = {
2825 .attr = { 2834 .attr = {
2826 .name = "reset_host", 2835 .name = "reset_host",
2827 .mode = S_IWUSR, 2836 .mode = S_IWUSR,
@@ -3054,19 +3063,20 @@ static int ipr_update_ioa_ucode(struct ipr_ioa_cfg *ioa_cfg,
3054 3063
3055/** 3064/**
3056 * ipr_store_update_fw - Update the firmware on the adapter 3065 * ipr_store_update_fw - Update the firmware on the adapter
3057 * @class_dev: class_device struct 3066 * @class_dev: device struct
3058 * @buf: buffer 3067 * @buf: buffer
3059 * @count: buffer size 3068 * @count: buffer size
3060 * 3069 *
3061 * This function will update the firmware on the adapter. 3070 * This function will update the firmware on the adapter.
3062 * 3071 *
3063 * Return value: 3072 * Return value:
3064 * count on success / other on failure 3073 * count on success / other on failure
3065 **/ 3074 **/
3066static ssize_t ipr_store_update_fw(struct class_device *class_dev, 3075static ssize_t ipr_store_update_fw(struct device *dev,
3067 const char *buf, size_t count) 3076 struct device_attribute *attr,
3077 const char *buf, size_t count)
3068{ 3078{
3069 struct Scsi_Host *shost = class_to_shost(class_dev); 3079 struct Scsi_Host *shost = class_to_shost(dev);
3070 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 3080 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
3071 struct ipr_ucode_image_header *image_hdr; 3081 struct ipr_ucode_image_header *image_hdr;
3072 const struct firmware *fw_entry; 3082 const struct firmware *fw_entry;
@@ -3124,7 +3134,7 @@ out:
3124 return result; 3134 return result;
3125} 3135}
3126 3136
3127static struct class_device_attribute ipr_update_fw_attr = { 3137static struct device_attribute ipr_update_fw_attr = {
3128 .attr = { 3138 .attr = {
3129 .name = "update_fw", 3139 .name = "update_fw",
3130 .mode = S_IWUSR, 3140 .mode = S_IWUSR,
@@ -3132,7 +3142,7 @@ static struct class_device_attribute ipr_update_fw_attr = {
3132 .store = ipr_store_update_fw 3142 .store = ipr_store_update_fw
3133}; 3143};
3134 3144
3135static struct class_device_attribute *ipr_ioa_attrs[] = { 3145static struct device_attribute *ipr_ioa_attrs[] = {
3136 &ipr_fw_version_attr, 3146 &ipr_fw_version_attr,
3137 &ipr_log_level_attr, 3147 &ipr_log_level_attr,
3138 &ipr_diagnostics_attr, 3148 &ipr_diagnostics_attr,
@@ -3159,7 +3169,7 @@ static ssize_t ipr_read_dump(struct kobject *kobj,
3159 struct bin_attribute *bin_attr, 3169 struct bin_attribute *bin_attr,
3160 char *buf, loff_t off, size_t count) 3170 char *buf, loff_t off, size_t count)
3161{ 3171{
3162 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 3172 struct device *cdev = container_of(kobj, struct device, kobj);
3163 struct Scsi_Host *shost = class_to_shost(cdev); 3173 struct Scsi_Host *shost = class_to_shost(cdev);
3164 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 3174 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
3165 struct ipr_dump *dump; 3175 struct ipr_dump *dump;
@@ -3322,7 +3332,7 @@ static ssize_t ipr_write_dump(struct kobject *kobj,
3322 struct bin_attribute *bin_attr, 3332 struct bin_attribute *bin_attr,
3323 char *buf, loff_t off, size_t count) 3333 char *buf, loff_t off, size_t count)
3324{ 3334{
3325 struct class_device *cdev = container_of(kobj,struct class_device,kobj); 3335 struct device *cdev = container_of(kobj, struct device, kobj);
3326 struct Scsi_Host *shost = class_to_shost(cdev); 3336 struct Scsi_Host *shost = class_to_shost(cdev);
3327 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; 3337 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
3328 int rc; 3338 int rc;
@@ -7671,9 +7681,9 @@ static void ipr_remove(struct pci_dev *pdev)
7671 7681
7672 ENTER; 7682 ENTER;
7673 7683
7674 ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj, 7684 ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj,
7675 &ipr_trace_attr); 7685 &ipr_trace_attr);
7676 ipr_remove_dump_file(&ioa_cfg->host->shost_classdev.kobj, 7686 ipr_remove_dump_file(&ioa_cfg->host->shost_dev.kobj,
7677 &ipr_dump_attr); 7687 &ipr_dump_attr);
7678 scsi_remove_host(ioa_cfg->host); 7688 scsi_remove_host(ioa_cfg->host);
7679 7689
@@ -7714,7 +7724,7 @@ static int __devinit ipr_probe(struct pci_dev *pdev,
7714 return rc; 7724 return rc;
7715 } 7725 }
7716 7726
7717 rc = ipr_create_trace_file(&ioa_cfg->host->shost_classdev.kobj, 7727 rc = ipr_create_trace_file(&ioa_cfg->host->shost_dev.kobj,
7718 &ipr_trace_attr); 7728 &ipr_trace_attr);
7719 7729
7720 if (rc) { 7730 if (rc) {
@@ -7723,11 +7733,11 @@ static int __devinit ipr_probe(struct pci_dev *pdev,
7723 return rc; 7733 return rc;
7724 } 7734 }
7725 7735
7726 rc = ipr_create_dump_file(&ioa_cfg->host->shost_classdev.kobj, 7736 rc = ipr_create_dump_file(&ioa_cfg->host->shost_dev.kobj,
7727 &ipr_dump_attr); 7737 &ipr_dump_attr);
7728 7738
7729 if (rc) { 7739 if (rc) {
7730 ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj, 7740 ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj,
7731 &ipr_trace_attr); 7741 &ipr_trace_attr);
7732 scsi_remove_host(ioa_cfg->host); 7742 scsi_remove_host(ioa_cfg->host);
7733 __ipr_remove(pdev); 7743 __ipr_remove(pdev);
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 74c9fc204211..a9fbb3f88659 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -66,23 +66,26 @@ lpfc_jedec_to_ascii(int incr, char hdw[])
66} 66}
67 67
68static ssize_t 68static ssize_t
69lpfc_drvr_version_show(struct class_device *cdev, char *buf) 69lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
70 char *buf)
70{ 71{
71 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); 72 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
72} 73}
73 74
74static ssize_t 75static ssize_t
75lpfc_info_show(struct class_device *cdev, char *buf) 76lpfc_info_show(struct device *dev, struct device_attribute *attr,
77 char *buf)
76{ 78{
77 struct Scsi_Host *host = class_to_shost(cdev); 79 struct Scsi_Host *host = class_to_shost(dev);
78 80
79 return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); 81 return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
80} 82}
81 83
82static ssize_t 84static ssize_t
83lpfc_serialnum_show(struct class_device *cdev, char *buf) 85lpfc_serialnum_show(struct device *dev, struct device_attribute *attr,
86 char *buf)
84{ 87{
85 struct Scsi_Host *shost = class_to_shost(cdev); 88 struct Scsi_Host *shost = class_to_shost(dev);
86 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 89 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
87 struct lpfc_hba *phba = vport->phba; 90 struct lpfc_hba *phba = vport->phba;
88 91
@@ -90,18 +93,20 @@ lpfc_serialnum_show(struct class_device *cdev, char *buf)
90} 93}
91 94
92static ssize_t 95static ssize_t
93lpfc_temp_sensor_show(struct class_device *cdev, char *buf) 96lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr,
97 char *buf)
94{ 98{
95 struct Scsi_Host *shost = class_to_shost(cdev); 99 struct Scsi_Host *shost = class_to_shost(dev);
96 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 100 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
97 struct lpfc_hba *phba = vport->phba; 101 struct lpfc_hba *phba = vport->phba;
98 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); 102 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
99} 103}
100 104
101static ssize_t 105static ssize_t
102lpfc_modeldesc_show(struct class_device *cdev, char *buf) 106lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr,
107 char *buf)
103{ 108{
104 struct Scsi_Host *shost = class_to_shost(cdev); 109 struct Scsi_Host *shost = class_to_shost(dev);
105 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 110 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
106 struct lpfc_hba *phba = vport->phba; 111 struct lpfc_hba *phba = vport->phba;
107 112
@@ -109,9 +114,10 @@ lpfc_modeldesc_show(struct class_device *cdev, char *buf)
109} 114}
110 115
111static ssize_t 116static ssize_t
112lpfc_modelname_show(struct class_device *cdev, char *buf) 117lpfc_modelname_show(struct device *dev, struct device_attribute *attr,
118 char *buf)
113{ 119{
114 struct Scsi_Host *shost = class_to_shost(cdev); 120 struct Scsi_Host *shost = class_to_shost(dev);
115 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 121 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
116 struct lpfc_hba *phba = vport->phba; 122 struct lpfc_hba *phba = vport->phba;
117 123
@@ -119,9 +125,10 @@ lpfc_modelname_show(struct class_device *cdev, char *buf)
119} 125}
120 126
121static ssize_t 127static ssize_t
122lpfc_programtype_show(struct class_device *cdev, char *buf) 128lpfc_programtype_show(struct device *dev, struct device_attribute *attr,
129 char *buf)
123{ 130{
124 struct Scsi_Host *shost = class_to_shost(cdev); 131 struct Scsi_Host *shost = class_to_shost(dev);
125 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 132 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
126 struct lpfc_hba *phba = vport->phba; 133 struct lpfc_hba *phba = vport->phba;
127 134
@@ -129,9 +136,10 @@ lpfc_programtype_show(struct class_device *cdev, char *buf)
129} 136}
130 137
131static ssize_t 138static ssize_t
132lpfc_vportnum_show(struct class_device *cdev, char *buf) 139lpfc_vportnum_show(struct device *dev, struct device_attribute *attr,
140 char *buf)
133{ 141{
134 struct Scsi_Host *shost = class_to_shost(cdev); 142 struct Scsi_Host *shost = class_to_shost(dev);
135 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 143 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
136 struct lpfc_hba *phba = vport->phba; 144 struct lpfc_hba *phba = vport->phba;
137 145
@@ -139,9 +147,10 @@ lpfc_vportnum_show(struct class_device *cdev, char *buf)
139} 147}
140 148
141static ssize_t 149static ssize_t
142lpfc_fwrev_show(struct class_device *cdev, char *buf) 150lpfc_fwrev_show(struct device *dev, struct device_attribute *attr,
151 char *buf)
143{ 152{
144 struct Scsi_Host *shost = class_to_shost(cdev); 153 struct Scsi_Host *shost = class_to_shost(dev);
145 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 154 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
146 struct lpfc_hba *phba = vport->phba; 155 struct lpfc_hba *phba = vport->phba;
147 char fwrev[32]; 156 char fwrev[32];
@@ -151,10 +160,10 @@ lpfc_fwrev_show(struct class_device *cdev, char *buf)
151} 160}
152 161
153static ssize_t 162static ssize_t
154lpfc_hdw_show(struct class_device *cdev, char *buf) 163lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf)
155{ 164{
156 char hdw[9]; 165 char hdw[9];
157 struct Scsi_Host *shost = class_to_shost(cdev); 166 struct Scsi_Host *shost = class_to_shost(dev);
158 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 167 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
159 struct lpfc_hba *phba = vport->phba; 168 struct lpfc_hba *phba = vport->phba;
160 lpfc_vpd_t *vp = &phba->vpd; 169 lpfc_vpd_t *vp = &phba->vpd;
@@ -163,18 +172,20 @@ lpfc_hdw_show(struct class_device *cdev, char *buf)
163 return snprintf(buf, PAGE_SIZE, "%s\n", hdw); 172 return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
164} 173}
165static ssize_t 174static ssize_t
166lpfc_option_rom_version_show(struct class_device *cdev, char *buf) 175lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr,
176 char *buf)
167{ 177{
168 struct Scsi_Host *shost = class_to_shost(cdev); 178 struct Scsi_Host *shost = class_to_shost(dev);
169 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 179 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
170 struct lpfc_hba *phba = vport->phba; 180 struct lpfc_hba *phba = vport->phba;
171 181
172 return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); 182 return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
173} 183}
174static ssize_t 184static ssize_t
175lpfc_state_show(struct class_device *cdev, char *buf) 185lpfc_state_show(struct device *dev, struct device_attribute *attr,
186 char *buf)
176{ 187{
177 struct Scsi_Host *shost = class_to_shost(cdev); 188 struct Scsi_Host *shost = class_to_shost(dev);
178 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 189 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
179 struct lpfc_hba *phba = vport->phba; 190 struct lpfc_hba *phba = vport->phba;
180 int len = 0; 191 int len = 0;
@@ -243,9 +254,10 @@ lpfc_state_show(struct class_device *cdev, char *buf)
243} 254}
244 255
245static ssize_t 256static ssize_t
246lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf) 257lpfc_num_discovered_ports_show(struct device *dev,
258 struct device_attribute *attr, char *buf)
247{ 259{
248 struct Scsi_Host *shost = class_to_shost(cdev); 260 struct Scsi_Host *shost = class_to_shost(dev);
249 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 261 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
250 262
251 return snprintf(buf, PAGE_SIZE, "%d\n", 263 return snprintf(buf, PAGE_SIZE, "%d\n",
@@ -367,9 +379,10 @@ lpfc_selective_reset(struct lpfc_hba *phba)
367} 379}
368 380
369static ssize_t 381static ssize_t
370lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count) 382lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
383 const char *buf, size_t count)
371{ 384{
372 struct Scsi_Host *shost = class_to_shost(cdev); 385 struct Scsi_Host *shost = class_to_shost(dev);
373 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 386 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
374 struct lpfc_hba *phba = vport->phba; 387 struct lpfc_hba *phba = vport->phba;
375 388
@@ -385,9 +398,10 @@ lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count)
385} 398}
386 399
387static ssize_t 400static ssize_t
388lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf) 401lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr,
402 char *buf)
389{ 403{
390 struct Scsi_Host *shost = class_to_shost(cdev); 404 struct Scsi_Host *shost = class_to_shost(dev);
391 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 405 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
392 struct lpfc_hba *phba = vport->phba; 406 struct lpfc_hba *phba = vport->phba;
393 407
@@ -395,9 +409,10 @@ lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf)
395} 409}
396 410
397static ssize_t 411static ssize_t
398lpfc_board_mode_show(struct class_device *cdev, char *buf) 412lpfc_board_mode_show(struct device *dev, struct device_attribute *attr,
413 char *buf)
399{ 414{
400 struct Scsi_Host *shost = class_to_shost(cdev); 415 struct Scsi_Host *shost = class_to_shost(dev);
401 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 416 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
402 struct lpfc_hba *phba = vport->phba; 417 struct lpfc_hba *phba = vport->phba;
403 char * state; 418 char * state;
@@ -415,9 +430,10 @@ lpfc_board_mode_show(struct class_device *cdev, char *buf)
415} 430}
416 431
417static ssize_t 432static ssize_t
418lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count) 433lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
434 const char *buf, size_t count)
419{ 435{
420 struct Scsi_Host *shost = class_to_shost(cdev); 436 struct Scsi_Host *shost = class_to_shost(dev);
421 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 437 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
422 struct lpfc_hba *phba = vport->phba; 438 struct lpfc_hba *phba = vport->phba;
423 struct completion online_compl; 439 struct completion online_compl;
@@ -509,9 +525,10 @@ lpfc_get_hba_info(struct lpfc_hba *phba,
509} 525}
510 526
511static ssize_t 527static ssize_t
512lpfc_max_rpi_show(struct class_device *cdev, char *buf) 528lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr,
529 char *buf)
513{ 530{
514 struct Scsi_Host *shost = class_to_shost(cdev); 531 struct Scsi_Host *shost = class_to_shost(dev);
515 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 532 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
516 struct lpfc_hba *phba = vport->phba; 533 struct lpfc_hba *phba = vport->phba;
517 uint32_t cnt; 534 uint32_t cnt;
@@ -522,9 +539,10 @@ lpfc_max_rpi_show(struct class_device *cdev, char *buf)
522} 539}
523 540
524static ssize_t 541static ssize_t
525lpfc_used_rpi_show(struct class_device *cdev, char *buf) 542lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr,
543 char *buf)
526{ 544{
527 struct Scsi_Host *shost = class_to_shost(cdev); 545 struct Scsi_Host *shost = class_to_shost(dev);
528 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 546 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
529 struct lpfc_hba *phba = vport->phba; 547 struct lpfc_hba *phba = vport->phba;
530 uint32_t cnt, acnt; 548 uint32_t cnt, acnt;
@@ -535,9 +553,10 @@ lpfc_used_rpi_show(struct class_device *cdev, char *buf)
535} 553}
536 554
537static ssize_t 555static ssize_t
538lpfc_max_xri_show(struct class_device *cdev, char *buf) 556lpfc_max_xri_show(struct device *dev, struct device_attribute *attr,
557 char *buf)
539{ 558{
540 struct Scsi_Host *shost = class_to_shost(cdev); 559 struct Scsi_Host *shost = class_to_shost(dev);
541 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 560 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
542 struct lpfc_hba *phba = vport->phba; 561 struct lpfc_hba *phba = vport->phba;
543 uint32_t cnt; 562 uint32_t cnt;
@@ -548,9 +567,10 @@ lpfc_max_xri_show(struct class_device *cdev, char *buf)
548} 567}
549 568
550static ssize_t 569static ssize_t
551lpfc_used_xri_show(struct class_device *cdev, char *buf) 570lpfc_used_xri_show(struct device *dev, struct device_attribute *attr,
571 char *buf)
552{ 572{
553 struct Scsi_Host *shost = class_to_shost(cdev); 573 struct Scsi_Host *shost = class_to_shost(dev);
554 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 574 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
555 struct lpfc_hba *phba = vport->phba; 575 struct lpfc_hba *phba = vport->phba;
556 uint32_t cnt, acnt; 576 uint32_t cnt, acnt;
@@ -561,9 +581,10 @@ lpfc_used_xri_show(struct class_device *cdev, char *buf)
561} 581}
562 582
563static ssize_t 583static ssize_t
564lpfc_max_vpi_show(struct class_device *cdev, char *buf) 584lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr,
585 char *buf)
565{ 586{
566 struct Scsi_Host *shost = class_to_shost(cdev); 587 struct Scsi_Host *shost = class_to_shost(dev);
567 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 588 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
568 struct lpfc_hba *phba = vport->phba; 589 struct lpfc_hba *phba = vport->phba;
569 uint32_t cnt; 590 uint32_t cnt;
@@ -574,9 +595,10 @@ lpfc_max_vpi_show(struct class_device *cdev, char *buf)
574} 595}
575 596
576static ssize_t 597static ssize_t
577lpfc_used_vpi_show(struct class_device *cdev, char *buf) 598lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr,
599 char *buf)
578{ 600{
579 struct Scsi_Host *shost = class_to_shost(cdev); 601 struct Scsi_Host *shost = class_to_shost(dev);
580 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 602 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
581 struct lpfc_hba *phba = vport->phba; 603 struct lpfc_hba *phba = vport->phba;
582 uint32_t cnt, acnt; 604 uint32_t cnt, acnt;
@@ -587,9 +609,10 @@ lpfc_used_vpi_show(struct class_device *cdev, char *buf)
587} 609}
588 610
589static ssize_t 611static ssize_t
590lpfc_npiv_info_show(struct class_device *cdev, char *buf) 612lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr,
613 char *buf)
591{ 614{
592 struct Scsi_Host *shost = class_to_shost(cdev); 615 struct Scsi_Host *shost = class_to_shost(dev);
593 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 616 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
594 struct lpfc_hba *phba = vport->phba; 617 struct lpfc_hba *phba = vport->phba;
595 618
@@ -601,9 +624,10 @@ lpfc_npiv_info_show(struct class_device *cdev, char *buf)
601} 624}
602 625
603static ssize_t 626static ssize_t
604lpfc_poll_show(struct class_device *cdev, char *buf) 627lpfc_poll_show(struct device *dev, struct device_attribute *attr,
628 char *buf)
605{ 629{
606 struct Scsi_Host *shost = class_to_shost(cdev); 630 struct Scsi_Host *shost = class_to_shost(dev);
607 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 631 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
608 struct lpfc_hba *phba = vport->phba; 632 struct lpfc_hba *phba = vport->phba;
609 633
@@ -611,10 +635,10 @@ lpfc_poll_show(struct class_device *cdev, char *buf)
611} 635}
612 636
613static ssize_t 637static ssize_t
614lpfc_poll_store(struct class_device *cdev, const char *buf, 638lpfc_poll_store(struct device *dev, struct device_attribute *attr,
615 size_t count) 639 const char *buf, size_t count)
616{ 640{
617 struct Scsi_Host *shost = class_to_shost(cdev); 641 struct Scsi_Host *shost = class_to_shost(dev);
618 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 642 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
619 struct lpfc_hba *phba = vport->phba; 643 struct lpfc_hba *phba = vport->phba;
620 uint32_t creg_val; 644 uint32_t creg_val;
@@ -670,9 +694,10 @@ lpfc_poll_store(struct class_device *cdev, const char *buf,
670 694
671#define lpfc_param_show(attr) \ 695#define lpfc_param_show(attr) \
672static ssize_t \ 696static ssize_t \
673lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 697lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
698 char *buf) \
674{ \ 699{ \
675 struct Scsi_Host *shost = class_to_shost(cdev);\ 700 struct Scsi_Host *shost = class_to_shost(dev);\
676 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 701 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
677 struct lpfc_hba *phba = vport->phba;\ 702 struct lpfc_hba *phba = vport->phba;\
678 int val = 0;\ 703 int val = 0;\
@@ -683,9 +708,10 @@ lpfc_##attr##_show(struct class_device *cdev, char *buf) \
683 708
684#define lpfc_param_hex_show(attr) \ 709#define lpfc_param_hex_show(attr) \
685static ssize_t \ 710static ssize_t \
686lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 711lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
712 char *buf) \
687{ \ 713{ \
688 struct Scsi_Host *shost = class_to_shost(cdev);\ 714 struct Scsi_Host *shost = class_to_shost(dev);\
689 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 715 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
690 struct lpfc_hba *phba = vport->phba;\ 716 struct lpfc_hba *phba = vport->phba;\
691 int val = 0;\ 717 int val = 0;\
@@ -725,9 +751,10 @@ lpfc_##attr##_set(struct lpfc_hba *phba, int val) \
725 751
726#define lpfc_param_store(attr) \ 752#define lpfc_param_store(attr) \
727static ssize_t \ 753static ssize_t \
728lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ 754lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
755 const char *buf, size_t count) \
729{ \ 756{ \
730 struct Scsi_Host *shost = class_to_shost(cdev);\ 757 struct Scsi_Host *shost = class_to_shost(dev);\
731 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 758 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
732 struct lpfc_hba *phba = vport->phba;\ 759 struct lpfc_hba *phba = vport->phba;\
733 int val=0;\ 760 int val=0;\
@@ -743,9 +770,10 @@ lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
743 770
744#define lpfc_vport_param_show(attr) \ 771#define lpfc_vport_param_show(attr) \
745static ssize_t \ 772static ssize_t \
746lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 773lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
774 char *buf) \
747{ \ 775{ \
748 struct Scsi_Host *shost = class_to_shost(cdev);\ 776 struct Scsi_Host *shost = class_to_shost(dev);\
749 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 777 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
750 int val = 0;\ 778 int val = 0;\
751 val = vport->cfg_##attr;\ 779 val = vport->cfg_##attr;\
@@ -754,9 +782,10 @@ lpfc_##attr##_show(struct class_device *cdev, char *buf) \
754 782
755#define lpfc_vport_param_hex_show(attr) \ 783#define lpfc_vport_param_hex_show(attr) \
756static ssize_t \ 784static ssize_t \
757lpfc_##attr##_show(struct class_device *cdev, char *buf) \ 785lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
786 char *buf) \
758{ \ 787{ \
759 struct Scsi_Host *shost = class_to_shost(cdev);\ 788 struct Scsi_Host *shost = class_to_shost(dev);\
760 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 789 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
761 int val = 0;\ 790 int val = 0;\
762 val = vport->cfg_##attr;\ 791 val = vport->cfg_##attr;\
@@ -794,9 +823,10 @@ lpfc_##attr##_set(struct lpfc_vport *vport, int val) \
794 823
795#define lpfc_vport_param_store(attr) \ 824#define lpfc_vport_param_store(attr) \
796static ssize_t \ 825static ssize_t \
797lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \ 826lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
827 const char *buf, size_t count) \
798{ \ 828{ \
799 struct Scsi_Host *shost = class_to_shost(cdev);\ 829 struct Scsi_Host *shost = class_to_shost(dev);\
800 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 830 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
801 int val=0;\ 831 int val=0;\
802 if (!isdigit(buf[0]))\ 832 if (!isdigit(buf[0]))\
@@ -822,7 +852,7 @@ module_param(lpfc_##name, int, 0);\
822MODULE_PARM_DESC(lpfc_##name, desc);\ 852MODULE_PARM_DESC(lpfc_##name, desc);\
823lpfc_param_show(name)\ 853lpfc_param_show(name)\
824lpfc_param_init(name, defval, minval, maxval)\ 854lpfc_param_init(name, defval, minval, maxval)\
825static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 855static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
826 856
827#define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ 857#define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \
828static int lpfc_##name = defval;\ 858static int lpfc_##name = defval;\
@@ -832,8 +862,8 @@ lpfc_param_show(name)\
832lpfc_param_init(name, defval, minval, maxval)\ 862lpfc_param_init(name, defval, minval, maxval)\
833lpfc_param_set(name, defval, minval, maxval)\ 863lpfc_param_set(name, defval, minval, maxval)\
834lpfc_param_store(name)\ 864lpfc_param_store(name)\
835static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 865static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
836 lpfc_##name##_show, lpfc_##name##_store) 866 lpfc_##name##_show, lpfc_##name##_store)
837 867
838#define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ 868#define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
839static int lpfc_##name = defval;\ 869static int lpfc_##name = defval;\
@@ -841,7 +871,7 @@ module_param(lpfc_##name, int, 0);\
841MODULE_PARM_DESC(lpfc_##name, desc);\ 871MODULE_PARM_DESC(lpfc_##name, desc);\
842lpfc_param_hex_show(name)\ 872lpfc_param_hex_show(name)\
843lpfc_param_init(name, defval, minval, maxval)\ 873lpfc_param_init(name, defval, minval, maxval)\
844static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 874static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
845 875
846#define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ 876#define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
847static int lpfc_##name = defval;\ 877static int lpfc_##name = defval;\
@@ -851,8 +881,8 @@ lpfc_param_hex_show(name)\
851lpfc_param_init(name, defval, minval, maxval)\ 881lpfc_param_init(name, defval, minval, maxval)\
852lpfc_param_set(name, defval, minval, maxval)\ 882lpfc_param_set(name, defval, minval, maxval)\
853lpfc_param_store(name)\ 883lpfc_param_store(name)\
854static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 884static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
855 lpfc_##name##_show, lpfc_##name##_store) 885 lpfc_##name##_show, lpfc_##name##_store)
856 886
857#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ 887#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
858static int lpfc_##name = defval;\ 888static int lpfc_##name = defval;\
@@ -866,7 +896,7 @@ module_param(lpfc_##name, int, 0);\
866MODULE_PARM_DESC(lpfc_##name, desc);\ 896MODULE_PARM_DESC(lpfc_##name, desc);\
867lpfc_vport_param_show(name)\ 897lpfc_vport_param_show(name)\
868lpfc_vport_param_init(name, defval, minval, maxval)\ 898lpfc_vport_param_init(name, defval, minval, maxval)\
869static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 899static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
870 900
871#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ 901#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
872static int lpfc_##name = defval;\ 902static int lpfc_##name = defval;\
@@ -876,8 +906,8 @@ lpfc_vport_param_show(name)\
876lpfc_vport_param_init(name, defval, minval, maxval)\ 906lpfc_vport_param_init(name, defval, minval, maxval)\
877lpfc_vport_param_set(name, defval, minval, maxval)\ 907lpfc_vport_param_set(name, defval, minval, maxval)\
878lpfc_vport_param_store(name)\ 908lpfc_vport_param_store(name)\
879static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 909static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
880 lpfc_##name##_show, lpfc_##name##_store) 910 lpfc_##name##_show, lpfc_##name##_store)
881 911
882#define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ 912#define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
883static int lpfc_##name = defval;\ 913static int lpfc_##name = defval;\
@@ -885,7 +915,7 @@ module_param(lpfc_##name, int, 0);\
885MODULE_PARM_DESC(lpfc_##name, desc);\ 915MODULE_PARM_DESC(lpfc_##name, desc);\
886lpfc_vport_param_hex_show(name)\ 916lpfc_vport_param_hex_show(name)\
887lpfc_vport_param_init(name, defval, minval, maxval)\ 917lpfc_vport_param_init(name, defval, minval, maxval)\
888static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 918static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
889 919
890#define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ 920#define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
891static int lpfc_##name = defval;\ 921static int lpfc_##name = defval;\
@@ -895,46 +925,44 @@ lpfc_vport_param_hex_show(name)\
895lpfc_vport_param_init(name, defval, minval, maxval)\ 925lpfc_vport_param_init(name, defval, minval, maxval)\
896lpfc_vport_param_set(name, defval, minval, maxval)\ 926lpfc_vport_param_set(name, defval, minval, maxval)\
897lpfc_vport_param_store(name)\ 927lpfc_vport_param_store(name)\
898static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 928static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
899 lpfc_##name##_show, lpfc_##name##_store) 929 lpfc_##name##_show, lpfc_##name##_store)
900 930
901static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); 931static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
902static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); 932static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
903static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); 933static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
904static CLASS_DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL); 934static DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL);
905static CLASS_DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL); 935static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL);
906static CLASS_DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); 936static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL);
907static CLASS_DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); 937static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL);
908static CLASS_DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); 938static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL);
909static CLASS_DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL); 939static DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL);
910static CLASS_DEVICE_ATTR(option_rom_version, S_IRUGO, 940static DEVICE_ATTR(option_rom_version, S_IRUGO,
911 lpfc_option_rom_version_show, NULL); 941 lpfc_option_rom_version_show, NULL);
912static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO, 942static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
913 lpfc_num_discovered_ports_show, NULL); 943 lpfc_num_discovered_ports_show, NULL);
914static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 944static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
915static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, 945static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL);
916 NULL); 946static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
917static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 947 lpfc_board_mode_show, lpfc_board_mode_store);
918 lpfc_board_mode_show, lpfc_board_mode_store); 948static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
919static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 949static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL);
920static CLASS_DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL); 950static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL);
921static CLASS_DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL); 951static DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL);
922static CLASS_DEVICE_ATTR(max_rpi, S_IRUGO, lpfc_max_rpi_show, NULL); 952static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL);
923static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); 953static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
924static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); 954static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
925static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); 955static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
926static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); 956static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL);
927static CLASS_DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show,
928 NULL);
929 957
930 958
931static char *lpfc_soft_wwn_key = "C99G71SL8032A"; 959static char *lpfc_soft_wwn_key = "C99G71SL8032A";
932 960
933static ssize_t 961static ssize_t
934lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf, 962lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr,
935 size_t count) 963 const char *buf, size_t count)
936{ 964{
937 struct Scsi_Host *shost = class_to_shost(cdev); 965 struct Scsi_Host *shost = class_to_shost(dev);
938 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 966 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
939 struct lpfc_hba *phba = vport->phba; 967 struct lpfc_hba *phba = vport->phba;
940 unsigned int cnt = count; 968 unsigned int cnt = count;
@@ -963,13 +991,14 @@ lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf,
963 phba->soft_wwn_enable = 1; 991 phba->soft_wwn_enable = 1;
964 return count; 992 return count;
965} 993}
966static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, 994static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
967 lpfc_soft_wwn_enable_store); 995 lpfc_soft_wwn_enable_store);
968 996
969static ssize_t 997static ssize_t
970lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) 998lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr,
999 char *buf)
971{ 1000{
972 struct Scsi_Host *shost = class_to_shost(cdev); 1001 struct Scsi_Host *shost = class_to_shost(dev);
973 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1002 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
974 struct lpfc_hba *phba = vport->phba; 1003 struct lpfc_hba *phba = vport->phba;
975 1004
@@ -979,9 +1008,10 @@ lpfc_soft_wwpn_show(struct class_device *cdev, char *buf)
979 1008
980 1009
981static ssize_t 1010static ssize_t
982lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count) 1011lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr,
1012 const char *buf, size_t count)
983{ 1013{
984 struct Scsi_Host *shost = class_to_shost(cdev); 1014 struct Scsi_Host *shost = class_to_shost(dev);
985 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1015 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
986 struct lpfc_hba *phba = vport->phba; 1016 struct lpfc_hba *phba = vport->phba;
987 struct completion online_compl; 1017 struct completion online_compl;
@@ -1047,13 +1077,14 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
1047 "reinit adapter - %d\n", stat2); 1077 "reinit adapter - %d\n", stat2);
1048 return (stat1 || stat2) ? -EIO : count; 1078 return (stat1 || stat2) ? -EIO : count;
1049} 1079}
1050static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 1080static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
1051 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); 1081 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store);
1052 1082
1053static ssize_t 1083static ssize_t
1054lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) 1084lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr,
1085 char *buf)
1055{ 1086{
1056 struct Scsi_Host *shost = class_to_shost(cdev); 1087 struct Scsi_Host *shost = class_to_shost(dev);
1057 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; 1088 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
1058 return snprintf(buf, PAGE_SIZE, "0x%llx\n", 1089 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
1059 (unsigned long long)phba->cfg_soft_wwnn); 1090 (unsigned long long)phba->cfg_soft_wwnn);
@@ -1061,9 +1092,10 @@ lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
1061 1092
1062 1093
1063static ssize_t 1094static ssize_t
1064lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) 1095lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr,
1096 const char *buf, size_t count)
1065{ 1097{
1066 struct Scsi_Host *shost = class_to_shost(cdev); 1098 struct Scsi_Host *shost = class_to_shost(dev);
1067 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; 1099 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
1068 unsigned int i, j, cnt=count; 1100 unsigned int i, j, cnt=count;
1069 u8 wwnn[8]; 1101 u8 wwnn[8];
@@ -1107,8 +1139,8 @@ lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count)
1107 1139
1108 return count; 1140 return count;
1109} 1141}
1110static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\ 1142static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\
1111 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store); 1143 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store);
1112 1144
1113 1145
1114static int lpfc_poll = 0; 1146static int lpfc_poll = 0;
@@ -1118,8 +1150,8 @@ MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
1118 " 1 - poll with interrupts enabled" 1150 " 1 - poll with interrupts enabled"
1119 " 3 - poll and disable FCP ring interrupts"); 1151 " 3 - poll and disable FCP ring interrupts");
1120 1152
1121static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, 1153static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
1122 lpfc_poll_show, lpfc_poll_store); 1154 lpfc_poll_show, lpfc_poll_store);
1123 1155
1124int lpfc_sli_mode = 0; 1156int lpfc_sli_mode = 0;
1125module_param(lpfc_sli_mode, int, 0); 1157module_param(lpfc_sli_mode, int, 0);
@@ -1133,7 +1165,7 @@ module_param(lpfc_enable_npiv, int, 0);
1133MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality"); 1165MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality");
1134lpfc_param_show(enable_npiv); 1166lpfc_param_show(enable_npiv);
1135lpfc_param_init(enable_npiv, 0, 0, 1); 1167lpfc_param_init(enable_npiv, 0, 0, 1);
1136static CLASS_DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, 1168static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO,
1137 lpfc_enable_npiv_show, NULL); 1169 lpfc_enable_npiv_show, NULL);
1138 1170
1139/* 1171/*
@@ -1147,9 +1179,10 @@ MODULE_PARM_DESC(lpfc_nodev_tmo,
1147 "Seconds driver will hold I/O waiting " 1179 "Seconds driver will hold I/O waiting "
1148 "for a device to come back"); 1180 "for a device to come back");
1149static ssize_t 1181static ssize_t
1150lpfc_nodev_tmo_show(struct class_device *cdev, char *buf) 1182lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr,
1183 char *buf)
1151{ 1184{
1152 struct Scsi_Host *shost = class_to_shost(cdev); 1185 struct Scsi_Host *shost = class_to_shost(dev);
1153 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1186 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1154 int val = 0; 1187 int val = 0;
1155 val = vport->cfg_devloss_tmo; 1188 val = vport->cfg_devloss_tmo;
@@ -1221,8 +1254,8 @@ lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
1221 1254
1222lpfc_vport_param_store(nodev_tmo) 1255lpfc_vport_param_store(nodev_tmo)
1223 1256
1224static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, 1257static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR,
1225 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); 1258 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
1226 1259
1227/* 1260/*
1228# lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that 1261# lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
@@ -1255,8 +1288,8 @@ lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
1255} 1288}
1256 1289
1257lpfc_vport_param_store(devloss_tmo) 1290lpfc_vport_param_store(devloss_tmo)
1258static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, 1291static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
1259 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); 1292 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
1260 1293
1261/* 1294/*
1262# lpfc_log_verbose: Only turn this flag on if you are willing to risk being 1295# lpfc_log_verbose: Only turn this flag on if you are willing to risk being
@@ -1374,8 +1407,8 @@ lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
1374 return 0; 1407 return 0;
1375} 1408}
1376lpfc_vport_param_store(restrict_login); 1409lpfc_vport_param_store(restrict_login);
1377static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, 1410static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR,
1378 lpfc_restrict_login_show, lpfc_restrict_login_store); 1411 lpfc_restrict_login_show, lpfc_restrict_login_store);
1379 1412
1380/* 1413/*
1381# Some disk devices have a "select ID" or "select Target" capability. 1414# Some disk devices have a "select ID" or "select Target" capability.
@@ -1433,7 +1466,7 @@ MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology");
1433lpfc_param_show(topology) 1466lpfc_param_show(topology)
1434lpfc_param_init(topology, 0, 0, 6) 1467lpfc_param_init(topology, 0, 0, 6)
1435lpfc_param_store(topology) 1468lpfc_param_store(topology)
1436static CLASS_DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, 1469static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR,
1437 lpfc_topology_show, lpfc_topology_store); 1470 lpfc_topology_show, lpfc_topology_store);
1438 1471
1439/* 1472/*
@@ -1497,7 +1530,7 @@ lpfc_link_speed_init(struct lpfc_hba *phba, int val)
1497} 1530}
1498 1531
1499lpfc_param_store(link_speed) 1532lpfc_param_store(link_speed)
1500static CLASS_DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, 1533static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
1501 lpfc_link_speed_show, lpfc_link_speed_store); 1534 lpfc_link_speed_show, lpfc_link_speed_store);
1502 1535
1503/* 1536/*
@@ -1623,82 +1656,81 @@ LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
1623LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, 1656LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
1624 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); 1657 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
1625 1658
1626struct class_device_attribute *lpfc_hba_attrs[] = { 1659struct device_attribute *lpfc_hba_attrs[] = {
1627 &class_device_attr_info, 1660 &dev_attr_info,
1628 &class_device_attr_serialnum, 1661 &dev_attr_serialnum,
1629 &class_device_attr_modeldesc, 1662 &dev_attr_modeldesc,
1630 &class_device_attr_modelname, 1663 &dev_attr_modelname,
1631 &class_device_attr_programtype, 1664 &dev_attr_programtype,
1632 &class_device_attr_portnum, 1665 &dev_attr_portnum,
1633 &class_device_attr_fwrev, 1666 &dev_attr_fwrev,
1634 &class_device_attr_hdw, 1667 &dev_attr_hdw,
1635 &class_device_attr_option_rom_version, 1668 &dev_attr_option_rom_version,
1636 &class_device_attr_state, 1669 &dev_attr_state,
1637 &class_device_attr_num_discovered_ports, 1670 &dev_attr_num_discovered_ports,
1638 &class_device_attr_lpfc_drvr_version, 1671 &dev_attr_lpfc_drvr_version,
1639 &class_device_attr_lpfc_temp_sensor, 1672 &dev_attr_lpfc_temp_sensor,
1640 &class_device_attr_lpfc_log_verbose, 1673 &dev_attr_lpfc_log_verbose,
1641 &class_device_attr_lpfc_lun_queue_depth, 1674 &dev_attr_lpfc_lun_queue_depth,
1642 &class_device_attr_lpfc_hba_queue_depth, 1675 &dev_attr_lpfc_hba_queue_depth,
1643 &class_device_attr_lpfc_peer_port_login, 1676 &dev_attr_lpfc_peer_port_login,
1644 &class_device_attr_lpfc_nodev_tmo, 1677 &dev_attr_lpfc_nodev_tmo,
1645 &class_device_attr_lpfc_devloss_tmo, 1678 &dev_attr_lpfc_devloss_tmo,
1646 &class_device_attr_lpfc_fcp_class, 1679 &dev_attr_lpfc_fcp_class,
1647 &class_device_attr_lpfc_use_adisc, 1680 &dev_attr_lpfc_use_adisc,
1648 &class_device_attr_lpfc_ack0, 1681 &dev_attr_lpfc_ack0,
1649 &class_device_attr_lpfc_topology, 1682 &dev_attr_lpfc_topology,
1650 &class_device_attr_lpfc_scan_down, 1683 &dev_attr_lpfc_scan_down,
1651 &class_device_attr_lpfc_link_speed, 1684 &dev_attr_lpfc_link_speed,
1652 &class_device_attr_lpfc_cr_delay, 1685 &dev_attr_lpfc_cr_delay,
1653 &class_device_attr_lpfc_cr_count, 1686 &dev_attr_lpfc_cr_count,
1654 &class_device_attr_lpfc_multi_ring_support, 1687 &dev_attr_lpfc_multi_ring_support,
1655 &class_device_attr_lpfc_multi_ring_rctl, 1688 &dev_attr_lpfc_multi_ring_rctl,
1656 &class_device_attr_lpfc_multi_ring_type, 1689 &dev_attr_lpfc_multi_ring_type,
1657 &class_device_attr_lpfc_fdmi_on, 1690 &dev_attr_lpfc_fdmi_on,
1658 &class_device_attr_lpfc_max_luns, 1691 &dev_attr_lpfc_max_luns,
1659 &class_device_attr_lpfc_enable_npiv, 1692 &dev_attr_lpfc_enable_npiv,
1660 &class_device_attr_nport_evt_cnt, 1693 &dev_attr_nport_evt_cnt,
1661 &class_device_attr_board_mode, 1694 &dev_attr_board_mode,
1662 &class_device_attr_max_vpi, 1695 &dev_attr_max_vpi,
1663 &class_device_attr_used_vpi, 1696 &dev_attr_used_vpi,
1664 &class_device_attr_max_rpi, 1697 &dev_attr_max_rpi,
1665 &class_device_attr_used_rpi, 1698 &dev_attr_used_rpi,
1666 &class_device_attr_max_xri, 1699 &dev_attr_max_xri,
1667 &class_device_attr_used_xri, 1700 &dev_attr_used_xri,
1668 &class_device_attr_npiv_info, 1701 &dev_attr_npiv_info,
1669 &class_device_attr_issue_reset, 1702 &dev_attr_issue_reset,
1670 &class_device_attr_lpfc_poll, 1703 &dev_attr_lpfc_poll,
1671 &class_device_attr_lpfc_poll_tmo, 1704 &dev_attr_lpfc_poll_tmo,
1672 &class_device_attr_lpfc_use_msi, 1705 &dev_attr_lpfc_use_msi,
1673 &class_device_attr_lpfc_soft_wwnn, 1706 &dev_attr_lpfc_soft_wwnn,
1674 &class_device_attr_lpfc_soft_wwpn, 1707 &dev_attr_lpfc_soft_wwpn,
1675 &class_device_attr_lpfc_soft_wwn_enable, 1708 &dev_attr_lpfc_soft_wwn_enable,
1676 &class_device_attr_lpfc_enable_hba_reset, 1709 &dev_attr_lpfc_enable_hba_reset,
1677 &class_device_attr_lpfc_enable_hba_heartbeat, 1710 &dev_attr_lpfc_enable_hba_heartbeat,
1678 &class_device_attr_lpfc_sg_seg_cnt, 1711 &dev_attr_lpfc_sg_seg_cnt,
1679 NULL, 1712 NULL,
1680}; 1713};
1681 1714
1682struct class_device_attribute *lpfc_vport_attrs[] = { 1715struct device_attribute *lpfc_vport_attrs[] = {
1683 &class_device_attr_info, 1716 &dev_attr_info,
1684 &class_device_attr_state, 1717 &dev_attr_state,
1685 &class_device_attr_num_discovered_ports, 1718 &dev_attr_num_discovered_ports,
1686 &class_device_attr_lpfc_drvr_version, 1719 &dev_attr_lpfc_drvr_version,
1687 1720 &dev_attr_lpfc_log_verbose,
1688 &class_device_attr_lpfc_log_verbose, 1721 &dev_attr_lpfc_lun_queue_depth,
1689 &class_device_attr_lpfc_lun_queue_depth, 1722 &dev_attr_lpfc_nodev_tmo,
1690 &class_device_attr_lpfc_nodev_tmo, 1723 &dev_attr_lpfc_devloss_tmo,
1691 &class_device_attr_lpfc_devloss_tmo, 1724 &dev_attr_lpfc_hba_queue_depth,
1692 &class_device_attr_lpfc_hba_queue_depth, 1725 &dev_attr_lpfc_peer_port_login,
1693 &class_device_attr_lpfc_peer_port_login, 1726 &dev_attr_lpfc_restrict_login,
1694 &class_device_attr_lpfc_restrict_login, 1727 &dev_attr_lpfc_fcp_class,
1695 &class_device_attr_lpfc_fcp_class, 1728 &dev_attr_lpfc_use_adisc,
1696 &class_device_attr_lpfc_use_adisc, 1729 &dev_attr_lpfc_fdmi_on,
1697 &class_device_attr_lpfc_fdmi_on, 1730 &dev_attr_lpfc_max_luns,
1698 &class_device_attr_lpfc_max_luns, 1731 &dev_attr_nport_evt_cnt,
1699 &class_device_attr_nport_evt_cnt, 1732 &dev_attr_npiv_info,
1700 &class_device_attr_npiv_info, 1733 &dev_attr_lpfc_enable_da_id,
1701 &class_device_attr_lpfc_enable_da_id,
1702 NULL, 1734 NULL,
1703}; 1735};
1704 1736
@@ -1707,9 +1739,8 @@ sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1707 char *buf, loff_t off, size_t count) 1739 char *buf, loff_t off, size_t count)
1708{ 1740{
1709 size_t buf_off; 1741 size_t buf_off;
1710 struct class_device *cdev = container_of(kobj, struct class_device, 1742 struct device *dev = container_of(kobj, struct device, kobj);
1711 kobj); 1743 struct Scsi_Host *shost = class_to_shost(dev);
1712 struct Scsi_Host *shost = class_to_shost(cdev);
1713 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1744 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1714 struct lpfc_hba *phba = vport->phba; 1745 struct lpfc_hba *phba = vport->phba;
1715 1746
@@ -1741,9 +1772,8 @@ sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr,
1741{ 1772{
1742 size_t buf_off; 1773 size_t buf_off;
1743 uint32_t * tmp_ptr; 1774 uint32_t * tmp_ptr;
1744 struct class_device *cdev = container_of(kobj, struct class_device, 1775 struct device *dev = container_of(kobj, struct device, kobj);
1745 kobj); 1776 struct Scsi_Host *shost = class_to_shost(dev);
1746 struct Scsi_Host *shost = class_to_shost(cdev);
1747 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1777 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1748 struct lpfc_hba *phba = vport->phba; 1778 struct lpfc_hba *phba = vport->phba;
1749 1779
@@ -1798,9 +1828,8 @@ static ssize_t
1798sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, 1828sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1799 char *buf, loff_t off, size_t count) 1829 char *buf, loff_t off, size_t count)
1800{ 1830{
1801 struct class_device *cdev = container_of(kobj, struct class_device, 1831 struct device *dev = container_of(kobj, struct device, kobj);
1802 kobj); 1832 struct Scsi_Host *shost = class_to_shost(dev);
1803 struct Scsi_Host *shost = class_to_shost(cdev);
1804 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1833 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1805 struct lpfc_hba *phba = vport->phba; 1834 struct lpfc_hba *phba = vport->phba;
1806 struct lpfcMboxq *mbox = NULL; 1835 struct lpfcMboxq *mbox = NULL;
@@ -1853,9 +1882,8 @@ static ssize_t
1853sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, 1882sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
1854 char *buf, loff_t off, size_t count) 1883 char *buf, loff_t off, size_t count)
1855{ 1884{
1856 struct class_device *cdev = container_of(kobj, struct class_device, 1885 struct device *dev = container_of(kobj, struct device, kobj);
1857 kobj); 1886 struct Scsi_Host *shost = class_to_shost(dev);
1858 struct Scsi_Host *shost = class_to_shost(cdev);
1859 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1887 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1860 struct lpfc_hba *phba = vport->phba; 1888 struct lpfc_hba *phba = vport->phba;
1861 int rc; 1889 int rc;
@@ -2038,19 +2066,19 @@ lpfc_alloc_sysfs_attr(struct lpfc_vport *vport)
2038 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2066 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2039 int error; 2067 int error;
2040 2068
2041 error = sysfs_create_bin_file(&shost->shost_classdev.kobj, 2069 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
2042 &sysfs_ctlreg_attr); 2070 &sysfs_ctlreg_attr);
2043 if (error) 2071 if (error)
2044 goto out; 2072 goto out;
2045 2073
2046 error = sysfs_create_bin_file(&shost->shost_classdev.kobj, 2074 error = sysfs_create_bin_file(&shost->shost_dev.kobj,
2047 &sysfs_mbox_attr); 2075 &sysfs_mbox_attr);
2048 if (error) 2076 if (error)
2049 goto out_remove_ctlreg_attr; 2077 goto out_remove_ctlreg_attr;
2050 2078
2051 return 0; 2079 return 0;
2052out_remove_ctlreg_attr: 2080out_remove_ctlreg_attr:
2053 sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); 2081 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
2054out: 2082out:
2055 return error; 2083 return error;
2056} 2084}
@@ -2060,8 +2088,8 @@ lpfc_free_sysfs_attr(struct lpfc_vport *vport)
2060{ 2088{
2061 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2089 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2062 2090
2063 sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_mbox_attr); 2091 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_mbox_attr);
2064 sysfs_remove_bin_file(&shost->shost_classdev.kobj, &sysfs_ctlreg_attr); 2092 sysfs_remove_bin_file(&shost->shost_dev.kobj, &sysfs_ctlreg_attr);
2065} 2093}
2066 2094
2067 2095
@@ -2443,9 +2471,11 @@ lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
2443 2471
2444#define lpfc_rport_show_function(field, format_string, sz, cast) \ 2472#define lpfc_rport_show_function(field, format_string, sz, cast) \
2445static ssize_t \ 2473static ssize_t \
2446lpfc_show_rport_##field (struct class_device *cdev, char *buf) \ 2474lpfc_show_rport_##field (struct device *dev, \
2475 struct device_attribute *attr, \
2476 char *buf) \
2447{ \ 2477{ \
2448 struct fc_rport *rport = transport_class_to_rport(cdev); \ 2478 struct fc_rport *rport = transport_class_to_rport(dev); \
2449 struct lpfc_rport_data *rdata = rport->hostdata; \ 2479 struct lpfc_rport_data *rdata = rport->hostdata; \
2450 return snprintf(buf, sz, format_string, \ 2480 return snprintf(buf, sz, format_string, \
2451 (rdata->target) ? cast rdata->target->field : 0); \ 2481 (rdata->target) ? cast rdata->target->field : 0); \
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 0819f5f39de5..7c9f8317d972 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -253,8 +253,8 @@ void lpfc_get_cfgparam(struct lpfc_hba *);
253void lpfc_get_vport_cfgparam(struct lpfc_vport *); 253void lpfc_get_vport_cfgparam(struct lpfc_vport *);
254int lpfc_alloc_sysfs_attr(struct lpfc_vport *); 254int lpfc_alloc_sysfs_attr(struct lpfc_vport *);
255void lpfc_free_sysfs_attr(struct lpfc_vport *); 255void lpfc_free_sysfs_attr(struct lpfc_vport *);
256extern struct class_device_attribute *lpfc_hba_attrs[]; 256extern struct device_attribute *lpfc_hba_attrs[];
257extern struct class_device_attribute *lpfc_vport_attrs[]; 257extern struct device_attribute *lpfc_vport_attrs[];
258extern struct scsi_host_template lpfc_template; 258extern struct scsi_host_template lpfc_template;
259extern struct scsi_host_template lpfc_vport_template; 259extern struct scsi_host_template lpfc_vport_template;
260extern struct fc_function_template lpfc_transport_functions; 260extern struct fc_function_template lpfc_transport_functions;
diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
index fef9ac958754..f62ed468ada0 100644
--- a/drivers/scsi/megaraid/mega_common.h
+++ b/drivers/scsi/megaraid/mega_common.h
@@ -28,7 +28,6 @@
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/dma-mapping.h> 30#include <linux/dma-mapping.h>
31#include <asm/semaphore.h>
32#include <scsi/scsi.h> 31#include <scsi/scsi.h>
33#include <scsi/scsi_cmnd.h> 32#include <scsi/scsi_cmnd.h>
34#include <scsi/scsi_device.h> 33#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/megaraid/megaraid_ioctl.h b/drivers/scsi/megaraid/megaraid_ioctl.h
index 706fa05a187a..05f6e4ec3453 100644
--- a/drivers/scsi/megaraid/megaraid_ioctl.h
+++ b/drivers/scsi/megaraid/megaraid_ioctl.h
@@ -18,7 +18,7 @@
18#define _MEGARAID_IOCTL_H_ 18#define _MEGARAID_IOCTL_H_
19 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <asm/semaphore.h> 21#include <linux/semaphore.h>
22 22
23#include "mbox_defs.h" 23#include "mbox_defs.h"
24 24
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 9f041929aca5..820f91fb63ba 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -125,7 +125,7 @@ static irqreturn_t megaraid_isr(int, void *);
125 125
126static void megaraid_mbox_dpc(unsigned long); 126static void megaraid_mbox_dpc(unsigned long);
127 127
128static ssize_t megaraid_sysfs_show_app_hndl(struct class_device *, char *); 128static ssize_t megaraid_sysfs_show_app_hndl(struct device *, struct device_attribute *attr, char *);
129static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *); 129static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *);
130 130
131static int megaraid_cmm_register(adapter_t *); 131static int megaraid_cmm_register(adapter_t *);
@@ -313,12 +313,12 @@ static struct pci_driver megaraid_pci_driver = {
313// definitions for the device attributes for exporting logical drive number 313// definitions for the device attributes for exporting logical drive number
314// for a scsi address (Host, Channel, Id, Lun) 314// for a scsi address (Host, Channel, Id, Lun)
315 315
316CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl, 316DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl,
317 NULL); 317 NULL);
318 318
319// Host template initializer for megaraid mbox sysfs device attributes 319// Host template initializer for megaraid mbox sysfs device attributes
320static struct class_device_attribute *megaraid_shost_attrs[] = { 320static struct device_attribute *megaraid_shost_attrs[] = {
321 &class_device_attr_megaraid_mbox_app_hndl, 321 &dev_attr_megaraid_mbox_app_hndl,
322 NULL, 322 NULL,
323}; 323};
324 324
@@ -4063,9 +4063,10 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
4063 * handle, since we do not interface with applications directly. 4063 * handle, since we do not interface with applications directly.
4064 */ 4064 */
4065static ssize_t 4065static ssize_t
4066megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf) 4066megaraid_sysfs_show_app_hndl(struct device *dev, struct device_attribute *attr,
4067 char *buf)
4067{ 4068{
4068 struct Scsi_Host *shost = class_to_shost(cdev); 4069 struct Scsi_Host *shost = class_to_shost(dev);
4069 adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(shost); 4070 adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(shost);
4070 uint32_t app_hndl; 4071 uint32_t app_hndl;
4071 4072
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index c5ebf018b378..d89289400425 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -8243,7 +8243,8 @@ static void process_waiting_list(struct ncb *np, int sts)
8243 8243
8244#undef next_wcmd 8244#undef next_wcmd
8245 8245
8246static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf) 8246static ssize_t show_ncr53c8xx_revision(struct device *dev,
8247 struct device_attribute *attr, char *buf)
8247{ 8248{
8248 struct Scsi_Host *host = class_to_shost(dev); 8249 struct Scsi_Host *host = class_to_shost(dev);
8249 struct host_data *host_data = (struct host_data *)host->hostdata; 8250 struct host_data *host_data = (struct host_data *)host->hostdata;
@@ -8251,12 +8252,12 @@ static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf)
8251 return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id); 8252 return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id);
8252} 8253}
8253 8254
8254static struct class_device_attribute ncr53c8xx_revision_attr = { 8255static struct device_attribute ncr53c8xx_revision_attr = {
8255 .attr = { .name = "revision", .mode = S_IRUGO, }, 8256 .attr = { .name = "revision", .mode = S_IRUGO, },
8256 .show = show_ncr53c8xx_revision, 8257 .show = show_ncr53c8xx_revision,
8257}; 8258};
8258 8259
8259static struct class_device_attribute *ncr53c8xx_host_attrs[] = { 8260static struct device_attribute *ncr53c8xx_host_attrs[] = {
8260 &ncr53c8xx_revision_attr, 8261 &ncr53c8xx_revision_attr,
8261 NULL 8262 NULL
8262}; 8263};
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index abef7048f25b..31f7aec44d90 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5591,9 +5591,10 @@ static void osst_remove_sysfs_files(struct device_driver *sysfs)
5591 * sysfs support for accessing ADR header information 5591 * sysfs support for accessing ADR header information
5592 */ 5592 */
5593 5593
5594static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf) 5594static ssize_t osst_adr_rev_show(struct device *dev,
5595 struct device_attribute *attr, char *buf)
5595{ 5596{
5596 struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5597 struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
5597 ssize_t l = 0; 5598 ssize_t l = 0;
5598 5599
5599 if (STp && STp->header_ok && STp->linux_media) 5600 if (STp && STp->header_ok && STp->linux_media)
@@ -5601,11 +5602,13 @@ static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf)
5601 return l; 5602 return l;
5602} 5603}
5603 5604
5604CLASS_DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL); 5605DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL);
5605 5606
5606static ssize_t osst_linux_media_version_show(struct class_device *class_dev, char *buf) 5607static ssize_t osst_linux_media_version_show(struct device *dev,
5608 struct device_attribute *attr,
5609 char *buf)
5607{ 5610{
5608 struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5611 struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
5609 ssize_t l = 0; 5612 ssize_t l = 0;
5610 5613
5611 if (STp && STp->header_ok && STp->linux_media) 5614 if (STp && STp->header_ok && STp->linux_media)
@@ -5613,11 +5616,12 @@ static ssize_t osst_linux_media_version_show(struct class_device *class_dev, cha
5613 return l; 5616 return l;
5614} 5617}
5615 5618
5616CLASS_DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL); 5619DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL);
5617 5620
5618static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf) 5621static ssize_t osst_capacity_show(struct device *dev,
5622 struct device_attribute *attr, char *buf)
5619{ 5623{
5620 struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5624 struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
5621 ssize_t l = 0; 5625 ssize_t l = 0;
5622 5626
5623 if (STp && STp->header_ok && STp->linux_media) 5627 if (STp && STp->header_ok && STp->linux_media)
@@ -5625,11 +5629,13 @@ static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf)
5625 return l; 5629 return l;
5626} 5630}
5627 5631
5628CLASS_DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL); 5632DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL);
5629 5633
5630static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *buf) 5634static ssize_t osst_first_data_ppos_show(struct device *dev,
5635 struct device_attribute *attr,
5636 char *buf)
5631{ 5637{
5632 struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5638 struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
5633 ssize_t l = 0; 5639 ssize_t l = 0;
5634 5640
5635 if (STp && STp->header_ok && STp->linux_media) 5641 if (STp && STp->header_ok && STp->linux_media)
@@ -5637,11 +5643,13 @@ static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *b
5637 return l; 5643 return l;
5638} 5644}
5639 5645
5640CLASS_DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL); 5646DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL);
5641 5647
5642static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *buf) 5648static ssize_t osst_eod_frame_ppos_show(struct device *dev,
5649 struct device_attribute *attr,
5650 char *buf)
5643{ 5651{
5644 struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5652 struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
5645 ssize_t l = 0; 5653 ssize_t l = 0;
5646 5654
5647 if (STp && STp->header_ok && STp->linux_media) 5655 if (STp && STp->header_ok && STp->linux_media)
@@ -5649,11 +5657,12 @@ static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *bu
5649 return l; 5657 return l;
5650} 5658}
5651 5659
5652CLASS_DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL); 5660DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL);
5653 5661
5654static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf) 5662static ssize_t osst_filemark_cnt_show(struct device *dev,
5663 struct device_attribute *attr, char *buf)
5655{ 5664{
5656 struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev); 5665 struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
5657 ssize_t l = 0; 5666 ssize_t l = 0;
5658 5667
5659 if (STp && STp->header_ok && STp->linux_media) 5668 if (STp && STp->header_ok && STp->linux_media)
@@ -5661,7 +5670,7 @@ static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf)
5661 return l; 5670 return l;
5662} 5671}
5663 5672
5664CLASS_DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL); 5673DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL);
5665 5674
5666static struct class *osst_sysfs_class; 5675static struct class *osst_sysfs_class;
5667 5676
@@ -5678,44 +5687,37 @@ static int osst_sysfs_init(void)
5678 5687
5679static void osst_sysfs_destroy(dev_t dev) 5688static void osst_sysfs_destroy(dev_t dev)
5680{ 5689{
5681 class_device_destroy(osst_sysfs_class, dev); 5690 device_destroy(osst_sysfs_class, dev);
5682} 5691}
5683 5692
5684static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name) 5693static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name)
5685{ 5694{
5686 struct class_device *osst_class_member; 5695 struct device *osst_member;
5687 int err; 5696 int err;
5688 5697
5689 osst_class_member = class_device_create(osst_sysfs_class, NULL, dev, 5698 osst_member = device_create(osst_sysfs_class, device, dev, "%s", name);
5690 device, "%s", name); 5699 if (IS_ERR(osst_member)) {
5691 if (IS_ERR(osst_class_member)) {
5692 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5700 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
5693 return PTR_ERR(osst_class_member); 5701 return PTR_ERR(osst_member);
5694 } 5702 }
5695 5703
5696 class_set_devdata(osst_class_member, STp); 5704 dev_set_drvdata(osst_member, STp);
5697 err = class_device_create_file(osst_class_member, 5705 err = device_create_file(osst_member, &dev_attr_ADR_rev);
5698 &class_device_attr_ADR_rev);
5699 if (err) 5706 if (err)
5700 goto err_out; 5707 goto err_out;
5701 err = class_device_create_file(osst_class_member, 5708 err = device_create_file(osst_member, &dev_attr_media_version);
5702 &class_device_attr_media_version);
5703 if (err) 5709 if (err)
5704 goto err_out; 5710 goto err_out;
5705 err = class_device_create_file(osst_class_member, 5711 err = device_create_file(osst_member, &dev_attr_capacity);
5706 &class_device_attr_capacity);
5707 if (err) 5712 if (err)
5708 goto err_out; 5713 goto err_out;
5709 err = class_device_create_file(osst_class_member, 5714 err = device_create_file(osst_member, &dev_attr_BOT_frame);
5710 &class_device_attr_BOT_frame);
5711 if (err) 5715 if (err)
5712 goto err_out; 5716 goto err_out;
5713 err = class_device_create_file(osst_class_member, 5717 err = device_create_file(osst_member, &dev_attr_EOD_frame);
5714 &class_device_attr_EOD_frame);
5715 if (err) 5718 if (err)
5716 goto err_out; 5719 goto err_out;
5717 err = class_device_create_file(osst_class_member, 5720 err = device_create_file(osst_member, &dev_attr_file_count);
5718 &class_device_attr_file_count);
5719 if (err) 5721 if (err)
5720 goto err_out; 5722 goto err_out;
5721 5723
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 3454a5714749..0be232b58ffb 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -632,9 +632,10 @@ SYM53C500_biosparm(struct scsi_device *disk,
632} 632}
633 633
634static ssize_t 634static ssize_t
635SYM53C500_show_pio(struct class_device *cdev, char *buf) 635SYM53C500_show_pio(struct device *dev, struct device_attribute *attr,
636 char *buf)
636{ 637{
637 struct Scsi_Host *SHp = class_to_shost(cdev); 638 struct Scsi_Host *SHp = class_to_shost(dev);
638 struct sym53c500_data *data = 639 struct sym53c500_data *data =
639 (struct sym53c500_data *)SHp->hostdata; 640 (struct sym53c500_data *)SHp->hostdata;
640 641
@@ -642,10 +643,11 @@ SYM53C500_show_pio(struct class_device *cdev, char *buf)
642} 643}
643 644
644static ssize_t 645static ssize_t
645SYM53C500_store_pio(struct class_device *cdev, const char *buf, size_t count) 646SYM53C500_store_pio(struct device *dev, struct device_attribute *attr,
647 const char *buf, size_t count)
646{ 648{
647 int pio; 649 int pio;
648 struct Scsi_Host *SHp = class_to_shost(cdev); 650 struct Scsi_Host *SHp = class_to_shost(dev);
649 struct sym53c500_data *data = 651 struct sym53c500_data *data =
650 (struct sym53c500_data *)SHp->hostdata; 652 (struct sym53c500_data *)SHp->hostdata;
651 653
@@ -662,7 +664,7 @@ SYM53C500_store_pio(struct class_device *cdev, const char *buf, size_t count)
662* SCSI HBA device attributes we want to 664* SCSI HBA device attributes we want to
663* make available via sysfs. 665* make available via sysfs.
664*/ 666*/
665static struct class_device_attribute SYM53C500_pio_attr = { 667static struct device_attribute SYM53C500_pio_attr = {
666 .attr = { 668 .attr = {
667 .name = "fast_pio", 669 .name = "fast_pio",
668 .mode = (S_IRUGO | S_IWUSR), 670 .mode = (S_IRUGO | S_IWUSR),
@@ -671,7 +673,7 @@ static struct class_device_attribute SYM53C500_pio_attr = {
671 .store = SYM53C500_store_pio, 673 .store = SYM53C500_store_pio,
672}; 674};
673 675
674static struct class_device_attribute *SYM53C500_shost_attrs[] = { 676static struct device_attribute *SYM53C500_shost_attrs[] = {
675 &SYM53C500_pio_attr, 677 &SYM53C500_pio_attr,
676 NULL, 678 NULL,
677}; 679};
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 413d8cd6a324..d61df036910c 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -530,15 +530,17 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
530/* Scsi_Host attributes. */ 530/* Scsi_Host attributes. */
531 531
532static ssize_t 532static ssize_t
533qla2x00_drvr_version_show(struct class_device *cdev, char *buf) 533qla2x00_drvr_version_show(struct device *dev,
534 struct device_attribute *attr, char *buf)
534{ 535{
535 return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); 536 return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
536} 537}
537 538
538static ssize_t 539static ssize_t
539qla2x00_fw_version_show(struct class_device *cdev, char *buf) 540qla2x00_fw_version_show(struct device *dev,
541 struct device_attribute *attr, char *buf)
540{ 542{
541 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 543 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
542 char fw_str[30]; 544 char fw_str[30];
543 545
544 return snprintf(buf, PAGE_SIZE, "%s\n", 546 return snprintf(buf, PAGE_SIZE, "%s\n",
@@ -546,9 +548,10 @@ qla2x00_fw_version_show(struct class_device *cdev, char *buf)
546} 548}
547 549
548static ssize_t 550static ssize_t
549qla2x00_serial_num_show(struct class_device *cdev, char *buf) 551qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
552 char *buf)
550{ 553{
551 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 554 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
552 uint32_t sn; 555 uint32_t sn;
553 556
554 if (IS_FWI2_CAPABLE(ha)) 557 if (IS_FWI2_CAPABLE(ha))
@@ -560,40 +563,45 @@ qla2x00_serial_num_show(struct class_device *cdev, char *buf)
560} 563}
561 564
562static ssize_t 565static ssize_t
563qla2x00_isp_name_show(struct class_device *cdev, char *buf) 566qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr,
567 char *buf)
564{ 568{
565 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 569 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
566 return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); 570 return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device);
567} 571}
568 572
569static ssize_t 573static ssize_t
570qla2x00_isp_id_show(struct class_device *cdev, char *buf) 574qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr,
575 char *buf)
571{ 576{
572 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 577 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
573 return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", 578 return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
574 ha->product_id[0], ha->product_id[1], ha->product_id[2], 579 ha->product_id[0], ha->product_id[1], ha->product_id[2],
575 ha->product_id[3]); 580 ha->product_id[3]);
576} 581}
577 582
578static ssize_t 583static ssize_t
579qla2x00_model_name_show(struct class_device *cdev, char *buf) 584qla2x00_model_name_show(struct device *dev, struct device_attribute *attr,
585 char *buf)
580{ 586{
581 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 587 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
582 return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); 588 return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number);
583} 589}
584 590
585static ssize_t 591static ssize_t
586qla2x00_model_desc_show(struct class_device *cdev, char *buf) 592qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr,
593 char *buf)
587{ 594{
588 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 595 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
589 return snprintf(buf, PAGE_SIZE, "%s\n", 596 return snprintf(buf, PAGE_SIZE, "%s\n",
590 ha->model_desc ? ha->model_desc: ""); 597 ha->model_desc ? ha->model_desc: "");
591} 598}
592 599
593static ssize_t 600static ssize_t
594qla2x00_pci_info_show(struct class_device *cdev, char *buf) 601qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr,
602 char *buf)
595{ 603{
596 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 604 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
597 char pci_info[30]; 605 char pci_info[30];
598 606
599 return snprintf(buf, PAGE_SIZE, "%s\n", 607 return snprintf(buf, PAGE_SIZE, "%s\n",
@@ -601,9 +609,10 @@ qla2x00_pci_info_show(struct class_device *cdev, char *buf)
601} 609}
602 610
603static ssize_t 611static ssize_t
604qla2x00_state_show(struct class_device *cdev, char *buf) 612qla2x00_state_show(struct device *dev, struct device_attribute *attr,
613 char *buf)
605{ 614{
606 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 615 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
607 int len = 0; 616 int len = 0;
608 617
609 if (atomic_read(&ha->loop_state) == LOOP_DOWN || 618 if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
@@ -639,9 +648,10 @@ qla2x00_state_show(struct class_device *cdev, char *buf)
639} 648}
640 649
641static ssize_t 650static ssize_t
642qla2x00_zio_show(struct class_device *cdev, char *buf) 651qla2x00_zio_show(struct device *dev, struct device_attribute *attr,
652 char *buf)
643{ 653{
644 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 654 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
645 int len = 0; 655 int len = 0;
646 656
647 switch (ha->zio_mode) { 657 switch (ha->zio_mode) {
@@ -656,9 +666,10 @@ qla2x00_zio_show(struct class_device *cdev, char *buf)
656} 666}
657 667
658static ssize_t 668static ssize_t
659qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count) 669qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
670 const char *buf, size_t count)
660{ 671{
661 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 672 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
662 int val = 0; 673 int val = 0;
663 uint16_t zio_mode; 674 uint16_t zio_mode;
664 675
@@ -682,18 +693,19 @@ qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count)
682} 693}
683 694
684static ssize_t 695static ssize_t
685qla2x00_zio_timer_show(struct class_device *cdev, char *buf) 696qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr,
697 char *buf)
686{ 698{
687 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 699 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
688 700
689 return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); 701 return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100);
690} 702}
691 703
692static ssize_t 704static ssize_t
693qla2x00_zio_timer_store(struct class_device *cdev, const char *buf, 705qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
694 size_t count) 706 const char *buf, size_t count)
695{ 707{
696 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 708 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
697 int val = 0; 709 int val = 0;
698 uint16_t zio_timer; 710 uint16_t zio_timer;
699 711
@@ -709,9 +721,10 @@ qla2x00_zio_timer_store(struct class_device *cdev, const char *buf,
709} 721}
710 722
711static ssize_t 723static ssize_t
712qla2x00_beacon_show(struct class_device *cdev, char *buf) 724qla2x00_beacon_show(struct device *dev, struct device_attribute *attr,
725 char *buf)
713{ 726{
714 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 727 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
715 int len = 0; 728 int len = 0;
716 729
717 if (ha->beacon_blink_led) 730 if (ha->beacon_blink_led)
@@ -722,10 +735,10 @@ qla2x00_beacon_show(struct class_device *cdev, char *buf)
722} 735}
723 736
724static ssize_t 737static ssize_t
725qla2x00_beacon_store(struct class_device *cdev, const char *buf, 738qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
726 size_t count) 739 const char *buf, size_t count)
727{ 740{
728 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 741 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
729 int val = 0; 742 int val = 0;
730 int rval; 743 int rval;
731 744
@@ -753,84 +766,86 @@ qla2x00_beacon_store(struct class_device *cdev, const char *buf,
753} 766}
754 767
755static ssize_t 768static ssize_t
756qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf) 769qla2x00_optrom_bios_version_show(struct device *dev,
770 struct device_attribute *attr, char *buf)
757{ 771{
758 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 772 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
759 773
760 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], 774 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
761 ha->bios_revision[0]); 775 ha->bios_revision[0]);
762} 776}
763 777
764static ssize_t 778static ssize_t
765qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf) 779qla2x00_optrom_efi_version_show(struct device *dev,
780 struct device_attribute *attr, char *buf)
766{ 781{
767 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 782 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
768 783
769 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], 784 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
770 ha->efi_revision[0]); 785 ha->efi_revision[0]);
771} 786}
772 787
773static ssize_t 788static ssize_t
774qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf) 789qla2x00_optrom_fcode_version_show(struct device *dev,
790 struct device_attribute *attr, char *buf)
775{ 791{
776 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 792 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
777 793
778 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], 794 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
779 ha->fcode_revision[0]); 795 ha->fcode_revision[0]);
780} 796}
781 797
782static ssize_t 798static ssize_t
783qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf) 799qla2x00_optrom_fw_version_show(struct device *dev,
800 struct device_attribute *attr, char *buf)
784{ 801{
785 scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); 802 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
786 803
787 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", 804 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
788 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], 805 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
789 ha->fw_revision[3]); 806 ha->fw_revision[3]);
790} 807}
791 808
792static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, 809static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
793 NULL); 810static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
794static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); 811static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
795static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); 812static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
796static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); 813static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
797static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); 814static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
798static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); 815static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
799static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); 816static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
800static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); 817static DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL);
801static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL); 818static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store);
802static CLASS_DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, 819static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
803 qla2x00_zio_store); 820 qla2x00_zio_timer_store);
804static CLASS_DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show, 821static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
805 qla2x00_zio_timer_store); 822 qla2x00_beacon_store);
806static CLASS_DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show, 823static DEVICE_ATTR(optrom_bios_version, S_IRUGO,
807 qla2x00_beacon_store); 824 qla2x00_optrom_bios_version_show, NULL);
808static CLASS_DEVICE_ATTR(optrom_bios_version, S_IRUGO, 825static DEVICE_ATTR(optrom_efi_version, S_IRUGO,
809 qla2x00_optrom_bios_version_show, NULL); 826 qla2x00_optrom_efi_version_show, NULL);
810static CLASS_DEVICE_ATTR(optrom_efi_version, S_IRUGO, 827static DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
811 qla2x00_optrom_efi_version_show, NULL); 828 qla2x00_optrom_fcode_version_show, NULL);
812static CLASS_DEVICE_ATTR(optrom_fcode_version, S_IRUGO, 829static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
813 qla2x00_optrom_fcode_version_show, NULL); 830 NULL);
814static CLASS_DEVICE_ATTR(optrom_fw_version, S_IRUGO, 831
815 qla2x00_optrom_fw_version_show, NULL); 832struct device_attribute *qla2x00_host_attrs[] = {
816 833 &dev_attr_driver_version,
817struct class_device_attribute *qla2x00_host_attrs[] = { 834 &dev_attr_fw_version,
818 &class_device_attr_driver_version, 835 &dev_attr_serial_num,
819 &class_device_attr_fw_version, 836 &dev_attr_isp_name,
820 &class_device_attr_serial_num, 837 &dev_attr_isp_id,
821 &class_device_attr_isp_name, 838 &dev_attr_model_name,
822 &class_device_attr_isp_id, 839 &dev_attr_model_desc,
823 &class_device_attr_model_name, 840 &dev_attr_pci_info,
824 &class_device_attr_model_desc, 841 &dev_attr_state,
825 &class_device_attr_pci_info, 842 &dev_attr_zio,
826 &class_device_attr_state, 843 &dev_attr_zio_timer,
827 &class_device_attr_zio, 844 &dev_attr_beacon,
828 &class_device_attr_zio_timer, 845 &dev_attr_optrom_bios_version,
829 &class_device_attr_beacon, 846 &dev_attr_optrom_efi_version,
830 &class_device_attr_optrom_bios_version, 847 &dev_attr_optrom_fcode_version,
831 &class_device_attr_optrom_efi_version, 848 &dev_attr_optrom_fw_version,
832 &class_device_attr_optrom_fcode_version,
833 &class_device_attr_optrom_fw_version,
834 NULL, 849 NULL,
835}; 850};
836 851
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 094d95f0764c..299eccf6cabd 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -25,7 +25,7 @@
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/aer.h> 26#include <linux/aer.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <asm/semaphore.h> 28#include <linux/semaphore.h>
29 29
30#include <scsi/scsi.h> 30#include <scsi/scsi.h>
31#include <scsi/scsi_host.h> 31#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index a9571c214a9e..76eb4fecce65 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -347,8 +347,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
347/* 347/*
348 * Global Function Prototypes in qla_attr.c source file. 348 * Global Function Prototypes in qla_attr.c source file.
349 */ 349 */
350struct class_device_attribute; 350struct device_attribute;
351extern struct class_device_attribute *qla2x00_host_attrs[]; 351extern struct device_attribute *qla2x00_host_attrs[];
352struct fc_function_template; 352struct fc_function_template;
353extern struct fc_function_template qla2xxx_transport_functions; 353extern struct fc_function_template qla2xxx_transport_functions;
354extern struct fc_function_template qla2xxx_transport_vport_functions; 354extern struct fc_function_template qla2xxx_transport_vport_functions;
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c
index 52182a744ba6..913a931176ef 100644
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -24,15 +24,15 @@ struct raid_internal {
24 struct raid_template r; 24 struct raid_template r;
25 struct raid_function_template *f; 25 struct raid_function_template *f;
26 /* The actual attributes */ 26 /* The actual attributes */
27 struct class_device_attribute private_attrs[RAID_NUM_ATTRS]; 27 struct device_attribute private_attrs[RAID_NUM_ATTRS];
28 /* The array of null terminated pointers to attributes 28 /* The array of null terminated pointers to attributes
29 * needed by scsi_sysfs.c */ 29 * needed by scsi_sysfs.c */
30 struct class_device_attribute *attrs[RAID_NUM_ATTRS + 1]; 30 struct device_attribute *attrs[RAID_NUM_ATTRS + 1];
31}; 31};
32 32
33struct raid_component { 33struct raid_component {
34 struct list_head node; 34 struct list_head node;
35 struct class_device cdev; 35 struct device dev;
36 int num; 36 int num;
37}; 37};
38 38
@@ -50,9 +50,9 @@ struct raid_component {
50 tc_to_raid_internal(tc); \ 50 tc_to_raid_internal(tc); \
51}) 51})
52 52
53#define class_device_to_raid_internal(cdev) ({ \ 53#define device_to_raid_internal(dev) ({ \
54 struct attribute_container *ac = \ 54 struct attribute_container *ac = \
55 attribute_container_classdev_to_container(cdev); \ 55 attribute_container_classdev_to_container(dev); \
56 ac_to_raid_internal(ac); \ 56 ac_to_raid_internal(ac); \
57}) 57})
58 58
@@ -76,33 +76,33 @@ static int raid_match(struct attribute_container *cont, struct device *dev)
76} 76}
77 77
78static int raid_setup(struct transport_container *tc, struct device *dev, 78static int raid_setup(struct transport_container *tc, struct device *dev,
79 struct class_device *cdev) 79 struct device *cdev)
80{ 80{
81 struct raid_data *rd; 81 struct raid_data *rd;
82 82
83 BUG_ON(class_get_devdata(cdev)); 83 BUG_ON(dev_get_drvdata(cdev));
84 84
85 rd = kzalloc(sizeof(*rd), GFP_KERNEL); 85 rd = kzalloc(sizeof(*rd), GFP_KERNEL);
86 if (!rd) 86 if (!rd)
87 return -ENOMEM; 87 return -ENOMEM;
88 88
89 INIT_LIST_HEAD(&rd->component_list); 89 INIT_LIST_HEAD(&rd->component_list);
90 class_set_devdata(cdev, rd); 90 dev_set_drvdata(cdev, rd);
91 91
92 return 0; 92 return 0;
93} 93}
94 94
95static int raid_remove(struct transport_container *tc, struct device *dev, 95static int raid_remove(struct transport_container *tc, struct device *dev,
96 struct class_device *cdev) 96 struct device *cdev)
97{ 97{
98 struct raid_data *rd = class_get_devdata(cdev); 98 struct raid_data *rd = dev_get_drvdata(cdev);
99 struct raid_component *rc, *next; 99 struct raid_component *rc, *next;
100 dev_printk(KERN_ERR, dev, "RAID REMOVE\n"); 100 dev_printk(KERN_ERR, dev, "RAID REMOVE\n");
101 class_set_devdata(cdev, NULL); 101 dev_set_drvdata(cdev, NULL);
102 list_for_each_entry_safe(rc, next, &rd->component_list, node) { 102 list_for_each_entry_safe(rc, next, &rd->component_list, node) {
103 list_del(&rc->node); 103 list_del(&rc->node);
104 dev_printk(KERN_ERR, rc->cdev.dev, "RAID COMPONENT REMOVE\n"); 104 dev_printk(KERN_ERR, rc->dev.parent, "RAID COMPONENT REMOVE\n");
105 class_device_unregister(&rc->cdev); 105 device_unregister(&rc->dev);
106 } 106 }
107 dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n"); 107 dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n");
108 kfree(rd); 108 kfree(rd);
@@ -171,9 +171,11 @@ static const char *raid_level_name(enum raid_level level)
171} 171}
172 172
173#define raid_attr_show_internal(attr, fmt, var, code) \ 173#define raid_attr_show_internal(attr, fmt, var, code) \
174static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \ 174static ssize_t raid_show_##attr(struct device *dev, \
175 struct device_attribute *attr, \
176 char *buf) \
175{ \ 177{ \
176 struct raid_data *rd = class_get_devdata(cdev); \ 178 struct raid_data *rd = dev_get_drvdata(dev); \
177 code \ 179 code \
178 return snprintf(buf, 20, #fmt "\n", var); \ 180 return snprintf(buf, 20, #fmt "\n", var); \
179} 181}
@@ -184,17 +186,17 @@ raid_attr_show_internal(attr, %s, name, \
184 code \ 186 code \
185 name = raid_##states##_name(rd->attr); \ 187 name = raid_##states##_name(rd->attr); \
186) \ 188) \
187static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) 189static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
188 190
189 191
190#define raid_attr_ro_internal(attr, code) \ 192#define raid_attr_ro_internal(attr, code) \
191raid_attr_show_internal(attr, %d, rd->attr, code) \ 193raid_attr_show_internal(attr, %d, rd->attr, code) \
192static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) 194static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
193 195
194#define ATTR_CODE(attr) \ 196#define ATTR_CODE(attr) \
195 struct raid_internal *i = class_device_to_raid_internal(cdev); \ 197 struct raid_internal *i = device_to_raid_internal(dev); \
196 if (i->f->get_##attr) \ 198 if (i->f->get_##attr) \
197 i->f->get_##attr(cdev->dev); 199 i->f->get_##attr(dev->parent);
198 200
199#define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) 201#define raid_attr_ro(attr) raid_attr_ro_internal(attr, )
200#define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) 202#define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr))
@@ -206,23 +208,23 @@ raid_attr_ro_state(level);
206raid_attr_ro_fn(resync); 208raid_attr_ro_fn(resync);
207raid_attr_ro_state_fn(state); 209raid_attr_ro_state_fn(state);
208 210
209static void raid_component_release(struct class_device *cdev) 211static void raid_component_release(struct device *dev)
210{ 212{
211 struct raid_component *rc = container_of(cdev, struct raid_component, 213 struct raid_component *rc =
212 cdev); 214 container_of(dev, struct raid_component, dev);
213 dev_printk(KERN_ERR, rc->cdev.dev, "COMPONENT RELEASE\n"); 215 dev_printk(KERN_ERR, rc->dev.parent, "COMPONENT RELEASE\n");
214 put_device(rc->cdev.dev); 216 put_device(rc->dev.parent);
215 kfree(rc); 217 kfree(rc);
216} 218}
217 219
218int raid_component_add(struct raid_template *r,struct device *raid_dev, 220int raid_component_add(struct raid_template *r,struct device *raid_dev,
219 struct device *component_dev) 221 struct device *component_dev)
220{ 222{
221 struct class_device *cdev = 223 struct device *cdev =
222 attribute_container_find_class_device(&r->raid_attrs.ac, 224 attribute_container_find_class_device(&r->raid_attrs.ac,
223 raid_dev); 225 raid_dev);
224 struct raid_component *rc; 226 struct raid_component *rc;
225 struct raid_data *rd = class_get_devdata(cdev); 227 struct raid_data *rd = dev_get_drvdata(cdev);
226 int err; 228 int err;
227 229
228 rc = kzalloc(sizeof(*rc), GFP_KERNEL); 230 rc = kzalloc(sizeof(*rc), GFP_KERNEL);
@@ -230,17 +232,16 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev,
230 return -ENOMEM; 232 return -ENOMEM;
231 233
232 INIT_LIST_HEAD(&rc->node); 234 INIT_LIST_HEAD(&rc->node);
233 class_device_initialize(&rc->cdev); 235 device_initialize(&rc->dev);
234 rc->cdev.release = raid_component_release; 236 rc->dev.release = raid_component_release;
235 rc->cdev.dev = get_device(component_dev); 237 rc->dev.parent = get_device(component_dev);
236 rc->num = rd->component_count++; 238 rc->num = rd->component_count++;
237 239
238 snprintf(rc->cdev.class_id, sizeof(rc->cdev.class_id), 240 snprintf(rc->dev.bus_id, sizeof(rc->dev.bus_id),
239 "component-%d", rc->num); 241 "component-%d", rc->num);
240 list_add_tail(&rc->node, &rd->component_list); 242 list_add_tail(&rc->node, &rd->component_list);
241 rc->cdev.parent = cdev; 243 rc->dev.class = &raid_class.class;
242 rc->cdev.class = &raid_class.class; 244 err = device_add(&rc->dev);
243 err = class_device_add(&rc->cdev);
244 if (err) 245 if (err)
245 goto err_out; 246 goto err_out;
246 247
@@ -273,9 +274,9 @@ raid_class_attach(struct raid_function_template *ft)
273 274
274 attribute_container_register(&i->r.raid_attrs.ac); 275 attribute_container_register(&i->r.raid_attrs.ac);
275 276
276 i->attrs[count++] = &class_device_attr_level; 277 i->attrs[count++] = &dev_attr_level;
277 i->attrs[count++] = &class_device_attr_resync; 278 i->attrs[count++] = &dev_attr_resync;
278 i->attrs[count++] = &class_device_attr_state; 279 i->attrs[count++] = &dev_attr_state;
279 280
280 i->attrs[count] = NULL; 281 i->attrs[count] = NULL;
281 BUG_ON(count > RAID_NUM_ATTRS); 282 BUG_ON(count > RAID_NUM_ATTRS);
diff --git a/drivers/scsi/scsi_sas_internal.h b/drivers/scsi/scsi_sas_internal.h
index e1edab45a37b..998cb5be6833 100644
--- a/drivers/scsi/scsi_sas_internal.h
+++ b/drivers/scsi/scsi_sas_internal.h
@@ -13,12 +13,12 @@ struct sas_internal {
13 struct sas_function_template *f; 13 struct sas_function_template *f;
14 struct sas_domain_function_template *dft; 14 struct sas_domain_function_template *dft;
15 15
16 struct class_device_attribute private_host_attrs[SAS_HOST_ATTRS]; 16 struct device_attribute private_host_attrs[SAS_HOST_ATTRS];
17 struct class_device_attribute private_phy_attrs[SAS_PHY_ATTRS]; 17 struct device_attribute private_phy_attrs[SAS_PHY_ATTRS];
18 struct class_device_attribute private_port_attrs[SAS_PORT_ATTRS]; 18 struct device_attribute private_port_attrs[SAS_PORT_ATTRS];
19 struct class_device_attribute private_rphy_attrs[SAS_RPORT_ATTRS]; 19 struct device_attribute private_rphy_attrs[SAS_RPORT_ATTRS];
20 struct class_device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS]; 20 struct device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS];
21 struct class_device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS]; 21 struct device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS];
22 22
23 struct transport_container phy_attr_cont; 23 struct transport_container phy_attr_cont;
24 struct transport_container port_attr_cont; 24 struct transport_container port_attr_cont;
@@ -30,12 +30,12 @@ struct sas_internal {
30 * The array of null terminated pointers to attributes 30 * The array of null terminated pointers to attributes
31 * needed by scsi_sysfs.c 31 * needed by scsi_sysfs.c
32 */ 32 */
33 struct class_device_attribute *host_attrs[SAS_HOST_ATTRS + 1]; 33 struct device_attribute *host_attrs[SAS_HOST_ATTRS + 1];
34 struct class_device_attribute *phy_attrs[SAS_PHY_ATTRS + 1]; 34 struct device_attribute *phy_attrs[SAS_PHY_ATTRS + 1];
35 struct class_device_attribute *port_attrs[SAS_PORT_ATTRS + 1]; 35 struct device_attribute *port_attrs[SAS_PORT_ATTRS + 1];
36 struct class_device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1]; 36 struct device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1];
37 struct class_device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1]; 37 struct device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1];
38 struct class_device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1]; 38 struct device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1];
39}; 39};
40#define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t) 40#define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t)
41 41
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index ed83cdb6e67d..67bb20ed45d2 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -119,9 +119,10 @@ static int scsi_scan(struct Scsi_Host *shost, const char *str)
119 */ 119 */
120#define shost_show_function(name, field, format_string) \ 120#define shost_show_function(name, field, format_string) \
121static ssize_t \ 121static ssize_t \
122show_##name (struct class_device *class_dev, char *buf) \ 122show_##name (struct device *dev, struct device_attribute *attr, \
123 char *buf) \
123{ \ 124{ \
124 struct Scsi_Host *shost = class_to_shost(class_dev); \ 125 struct Scsi_Host *shost = class_to_shost(dev); \
125 return snprintf (buf, 20, format_string, shost->field); \ 126 return snprintf (buf, 20, format_string, shost->field); \
126} 127}
127 128
@@ -131,7 +132,7 @@ show_##name (struct class_device *class_dev, char *buf) \
131 */ 132 */
132#define shost_rd_attr2(name, field, format_string) \ 133#define shost_rd_attr2(name, field, format_string) \
133 shost_show_function(name, field, format_string) \ 134 shost_show_function(name, field, format_string) \
134static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); 135static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
135 136
136#define shost_rd_attr(field, format_string) \ 137#define shost_rd_attr(field, format_string) \
137shost_rd_attr2(field, field, format_string) 138shost_rd_attr2(field, field, format_string)
@@ -140,10 +141,11 @@ shost_rd_attr2(field, field, format_string)
140 * Create the actual show/store functions and data structures. 141 * Create the actual show/store functions and data structures.
141 */ 142 */
142 143
143static ssize_t store_scan(struct class_device *class_dev, const char *buf, 144static ssize_t
144 size_t count) 145store_scan(struct device *dev, struct device_attribute *attr,
146 const char *buf, size_t count)
145{ 147{
146 struct Scsi_Host *shost = class_to_shost(class_dev); 148 struct Scsi_Host *shost = class_to_shost(dev);
147 int res; 149 int res;
148 150
149 res = scsi_scan(shost, buf); 151 res = scsi_scan(shost, buf);
@@ -151,13 +153,14 @@ static ssize_t store_scan(struct class_device *class_dev, const char *buf,
151 res = count; 153 res = count;
152 return res; 154 return res;
153}; 155};
154static CLASS_DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); 156static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
155 157
156static ssize_t 158static ssize_t
157store_shost_state(struct class_device *class_dev, const char *buf, size_t count) 159store_shost_state(struct device *dev, struct device_attribute *attr,
160 const char *buf, size_t count)
158{ 161{
159 int i; 162 int i;
160 struct Scsi_Host *shost = class_to_shost(class_dev); 163 struct Scsi_Host *shost = class_to_shost(dev);
161 enum scsi_host_state state = 0; 164 enum scsi_host_state state = 0;
162 165
163 for (i = 0; i < ARRAY_SIZE(shost_states); i++) { 166 for (i = 0; i < ARRAY_SIZE(shost_states); i++) {
@@ -177,9 +180,9 @@ store_shost_state(struct class_device *class_dev, const char *buf, size_t count)
177} 180}
178 181
179static ssize_t 182static ssize_t
180show_shost_state(struct class_device *class_dev, char *buf) 183show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
181{ 184{
182 struct Scsi_Host *shost = class_to_shost(class_dev); 185 struct Scsi_Host *shost = class_to_shost(dev);
183 const char *name = scsi_host_state_name(shost->shost_state); 186 const char *name = scsi_host_state_name(shost->shost_state);
184 187
185 if (!name) 188 if (!name)
@@ -188,7 +191,9 @@ show_shost_state(struct class_device *class_dev, char *buf)
188 return snprintf(buf, 20, "%s\n", name); 191 return snprintf(buf, 20, "%s\n", name);
189} 192}
190 193
191static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); 194/* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */
195struct device_attribute dev_attr_hstate =
196 __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
192 197
193static ssize_t 198static ssize_t
194show_shost_mode(unsigned int mode, char *buf) 199show_shost_mode(unsigned int mode, char *buf)
@@ -206,9 +211,11 @@ show_shost_mode(unsigned int mode, char *buf)
206 return len; 211 return len;
207} 212}
208 213
209static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf) 214static ssize_t
215show_shost_supported_mode(struct device *dev, struct device_attribute *attr,
216 char *buf)
210{ 217{
211 struct Scsi_Host *shost = class_to_shost(class_dev); 218 struct Scsi_Host *shost = class_to_shost(dev);
212 unsigned int supported_mode = shost->hostt->supported_mode; 219 unsigned int supported_mode = shost->hostt->supported_mode;
213 220
214 if (supported_mode == MODE_UNKNOWN) 221 if (supported_mode == MODE_UNKNOWN)
@@ -218,11 +225,13 @@ static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *b
218 return show_shost_mode(supported_mode, buf); 225 return show_shost_mode(supported_mode, buf);
219} 226}
220 227
221static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); 228static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL);
222 229
223static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf) 230static ssize_t
231show_shost_active_mode(struct device *dev,
232 struct device_attribute *attr, char *buf)
224{ 233{
225 struct Scsi_Host *shost = class_to_shost(class_dev); 234 struct Scsi_Host *shost = class_to_shost(dev);
226 235
227 if (shost->active_mode == MODE_UNKNOWN) 236 if (shost->active_mode == MODE_UNKNOWN)
228 return snprintf(buf, 20, "unknown\n"); 237 return snprintf(buf, 20, "unknown\n");
@@ -230,7 +239,7 @@ static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf)
230 return show_shost_mode(shost->active_mode, buf); 239 return show_shost_mode(shost->active_mode, buf);
231} 240}
232 241
233static CLASS_DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); 242static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
234 243
235shost_rd_attr(unique_id, "%u\n"); 244shost_rd_attr(unique_id, "%u\n");
236shost_rd_attr(host_busy, "%hu\n"); 245shost_rd_attr(host_busy, "%hu\n");
@@ -240,22 +249,22 @@ shost_rd_attr(sg_tablesize, "%hu\n");
240shost_rd_attr(unchecked_isa_dma, "%d\n"); 249shost_rd_attr(unchecked_isa_dma, "%d\n");
241shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); 250shost_rd_attr2(proc_name, hostt->proc_name, "%s\n");
242 251
243static struct class_device_attribute *scsi_sysfs_shost_attrs[] = { 252static struct device_attribute *scsi_sysfs_shost_attrs[] = {
244 &class_device_attr_unique_id, 253 &dev_attr_unique_id,
245 &class_device_attr_host_busy, 254 &dev_attr_host_busy,
246 &class_device_attr_cmd_per_lun, 255 &dev_attr_cmd_per_lun,
247 &class_device_attr_can_queue, 256 &dev_attr_can_queue,
248 &class_device_attr_sg_tablesize, 257 &dev_attr_sg_tablesize,
249 &class_device_attr_unchecked_isa_dma, 258 &dev_attr_unchecked_isa_dma,
250 &class_device_attr_proc_name, 259 &dev_attr_proc_name,
251 &class_device_attr_scan, 260 &dev_attr_scan,
252 &class_device_attr_state, 261 &dev_attr_hstate,
253 &class_device_attr_supported_mode, 262 &dev_attr_supported_mode,
254 &class_device_attr_active_mode, 263 &dev_attr_active_mode,
255 NULL 264 NULL
256}; 265};
257 266
258static void scsi_device_cls_release(struct class_device *class_dev) 267static void scsi_device_cls_release(struct device *class_dev)
259{ 268{
260 struct scsi_device *sdev; 269 struct scsi_device *sdev;
261 270
@@ -320,7 +329,7 @@ static void scsi_device_dev_release(struct device *dev)
320 329
321static struct class sdev_class = { 330static struct class sdev_class = {
322 .name = "scsi_device", 331 .name = "scsi_device",
323 .release = scsi_device_cls_release, 332 .dev_release = scsi_device_cls_release,
324}; 333};
325 334
326/* all probing is done in the individual ->probe routines */ 335/* all probing is done in the individual ->probe routines */
@@ -424,7 +433,8 @@ void scsi_sysfs_unregister(void)
424 */ 433 */
425#define sdev_show_function(field, format_string) \ 434#define sdev_show_function(field, format_string) \
426static ssize_t \ 435static ssize_t \
427sdev_show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ 436sdev_show_##field (struct device *dev, struct device_attribute *attr, \
437 char *buf) \
428{ \ 438{ \
429 struct scsi_device *sdev; \ 439 struct scsi_device *sdev; \
430 sdev = to_scsi_device(dev); \ 440 sdev = to_scsi_device(dev); \
@@ -448,7 +458,8 @@ static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL);
448 sdev_show_function(field, format_string) \ 458 sdev_show_function(field, format_string) \
449 \ 459 \
450static ssize_t \ 460static ssize_t \
451sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 461sdev_store_##field (struct device *dev, struct device_attribute *attr, \
462 const char *buf, size_t count) \
452{ \ 463{ \
453 struct scsi_device *sdev; \ 464 struct scsi_device *sdev; \
454 sdev = to_scsi_device(dev); \ 465 sdev = to_scsi_device(dev); \
@@ -468,7 +479,8 @@ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##fie
468 sdev_show_function(field, "%d\n") \ 479 sdev_show_function(field, "%d\n") \
469 \ 480 \
470static ssize_t \ 481static ssize_t \
471sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 482sdev_store_##field (struct device *dev, struct device_attribute *attr, \
483 const char *buf, size_t count) \
472{ \ 484{ \
473 int ret; \ 485 int ret; \
474 struct scsi_device *sdev; \ 486 struct scsi_device *sdev; \
@@ -519,7 +531,8 @@ sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf)
519} 531}
520 532
521static ssize_t 533static ssize_t
522sdev_store_timeout (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 534sdev_store_timeout (struct device *dev, struct device_attribute *attr,
535 const char *buf, size_t count)
523{ 536{
524 struct scsi_device *sdev; 537 struct scsi_device *sdev;
525 int timeout; 538 int timeout;
@@ -531,7 +544,8 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr, const cha
531static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); 544static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
532 545
533static ssize_t 546static ssize_t
534store_rescan_field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 547store_rescan_field (struct device *dev, struct device_attribute *attr,
548 const char *buf, size_t count)
535{ 549{
536 scsi_rescan_device(dev); 550 scsi_rescan_device(dev);
537 return count; 551 return count;
@@ -543,8 +557,9 @@ static void sdev_store_delete_callback(struct device *dev)
543 scsi_remove_device(to_scsi_device(dev)); 557 scsi_remove_device(to_scsi_device(dev));
544} 558}
545 559
546static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *attr, const char *buf, 560static ssize_t
547 size_t count) 561sdev_store_delete(struct device *dev, struct device_attribute *attr,
562 const char *buf, size_t count)
548{ 563{
549 int rc; 564 int rc;
550 565
@@ -559,7 +574,8 @@ static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *at
559static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete); 574static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete);
560 575
561static ssize_t 576static ssize_t
562store_state_field(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 577store_state_field(struct device *dev, struct device_attribute *attr,
578 const char *buf, size_t count)
563{ 579{
564 int i; 580 int i;
565 struct scsi_device *sdev = to_scsi_device(dev); 581 struct scsi_device *sdev = to_scsi_device(dev);
@@ -596,7 +612,8 @@ show_state_field(struct device *dev, struct device_attribute *attr, char *buf)
596static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field); 612static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field);
597 613
598static ssize_t 614static ssize_t
599show_queue_type_field(struct device *dev, struct device_attribute *attr, char *buf) 615show_queue_type_field(struct device *dev, struct device_attribute *attr,
616 char *buf)
600{ 617{
601 struct scsi_device *sdev = to_scsi_device(dev); 618 struct scsi_device *sdev = to_scsi_device(dev);
602 const char *name = "none"; 619 const char *name = "none";
@@ -612,7 +629,7 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr, char *b
612static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL); 629static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL);
613 630
614static ssize_t 631static ssize_t
615show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf) 632show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf)
616{ 633{
617 return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8); 634 return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8);
618} 635}
@@ -621,7 +638,8 @@ static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL);
621 638
622#define show_sdev_iostat(field) \ 639#define show_sdev_iostat(field) \
623static ssize_t \ 640static ssize_t \
624show_iostat_##field(struct device *dev, struct device_attribute *attr, char *buf) \ 641show_iostat_##field(struct device *dev, struct device_attribute *attr, \
642 char *buf) \
625{ \ 643{ \
626 struct scsi_device *sdev = to_scsi_device(dev); \ 644 struct scsi_device *sdev = to_scsi_device(dev); \
627 unsigned long long count = atomic_read(&sdev->field); \ 645 unsigned long long count = atomic_read(&sdev->field); \
@@ -645,7 +663,7 @@ static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL);
645#define DECLARE_EVT_SHOW(name, Cap_name) \ 663#define DECLARE_EVT_SHOW(name, Cap_name) \
646static ssize_t \ 664static ssize_t \
647sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \ 665sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \
648 char *buf) \ 666 char *buf) \
649{ \ 667{ \
650 struct scsi_device *sdev = to_scsi_device(dev); \ 668 struct scsi_device *sdev = to_scsi_device(dev); \
651 int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\ 669 int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
@@ -654,7 +672,7 @@ sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \
654 672
655#define DECLARE_EVT_STORE(name, Cap_name) \ 673#define DECLARE_EVT_STORE(name, Cap_name) \
656static ssize_t \ 674static ssize_t \
657sdev_store_evt_##name(struct device *dev, struct device_attribute *attr, \ 675sdev_store_evt_##name(struct device *dev, struct device_attribute *attr,\
658 const char *buf, size_t count) \ 676 const char *buf, size_t count) \
659{ \ 677{ \
660 struct scsi_device *sdev = to_scsi_device(dev); \ 678 struct scsi_device *sdev = to_scsi_device(dev); \
@@ -707,8 +725,9 @@ static struct attribute_group *scsi_sdev_attr_groups[] = {
707 NULL 725 NULL
708}; 726};
709 727
710static ssize_t sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr, const char *buf, 728static ssize_t
711 size_t count) 729sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr,
730 const char *buf, size_t count)
712{ 731{
713 int depth, retval; 732 int depth, retval;
714 struct scsi_device *sdev = to_scsi_device(dev); 733 struct scsi_device *sdev = to_scsi_device(dev);
@@ -733,8 +752,9 @@ static struct device_attribute sdev_attr_queue_depth_rw =
733 __ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth, 752 __ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth,
734 sdev_store_queue_depth_rw); 753 sdev_store_queue_depth_rw);
735 754
736static ssize_t sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr, const char *buf, 755static ssize_t
737 size_t count) 756sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr,
757 const char *buf, size_t count)
738{ 758{
739 struct scsi_device *sdev = to_scsi_device(dev); 759 struct scsi_device *sdev = to_scsi_device(dev);
740 struct scsi_host_template *sht = sdev->host->hostt; 760 struct scsi_host_template *sht = sdev->host->hostt;
@@ -786,13 +806,13 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
786 printk(KERN_INFO "error 1\n"); 806 printk(KERN_INFO "error 1\n");
787 return error; 807 return error;
788 } 808 }
789 error = class_device_add(&sdev->sdev_classdev); 809 error = device_add(&sdev->sdev_dev);
790 if (error) { 810 if (error) {
791 printk(KERN_INFO "error 2\n"); 811 printk(KERN_INFO "error 2\n");
792 goto clean_device; 812 goto clean_device;
793 } 813 }
794 814
795 /* take a reference for the sdev_classdev; this is 815 /* take a reference for the sdev_dev; this is
796 * released by the sdev_class .release */ 816 * released by the sdev_class .release */
797 get_device(&sdev->sdev_gendev); 817 get_device(&sdev->sdev_gendev);
798 818
@@ -858,7 +878,7 @@ void __scsi_remove_device(struct scsi_device *sdev)
858 return; 878 return;
859 879
860 bsg_unregister_queue(sdev->request_queue); 880 bsg_unregister_queue(sdev->request_queue);
861 class_device_unregister(&sdev->sdev_classdev); 881 device_unregister(&sdev->sdev_dev);
862 transport_remove_device(dev); 882 transport_remove_device(dev);
863 device_del(dev); 883 device_del(dev);
864 scsi_device_set_state(sdev, SDEV_DEL); 884 scsi_device_set_state(sdev, SDEV_DEL);
@@ -952,9 +972,9 @@ int scsi_register_interface(struct class_interface *intf)
952EXPORT_SYMBOL(scsi_register_interface); 972EXPORT_SYMBOL(scsi_register_interface);
953 973
954 974
955static struct class_device_attribute *class_attr_overridden( 975static struct device_attribute *class_attr_overridden(
956 struct class_device_attribute **attrs, 976 struct device_attribute **attrs,
957 struct class_device_attribute *attr) 977 struct device_attribute *attr)
958{ 978{
959 int i; 979 int i;
960 980
@@ -966,10 +986,10 @@ static struct class_device_attribute *class_attr_overridden(
966 return NULL; 986 return NULL;
967} 987}
968 988
969static int class_attr_add(struct class_device *classdev, 989static int class_attr_add(struct device *classdev,
970 struct class_device_attribute *attr) 990 struct device_attribute *attr)
971{ 991{
972 struct class_device_attribute *base_attr; 992 struct device_attribute *base_attr;
973 993
974 /* 994 /*
975 * Spare the caller from having to copy things it's not interested in. 995 * Spare the caller from having to copy things it's not interested in.
@@ -986,7 +1006,7 @@ static int class_attr_add(struct class_device *classdev,
986 attr->store = base_attr->store; 1006 attr->store = base_attr->store;
987 } 1007 }
988 1008
989 return class_device_create_file(classdev, attr); 1009 return device_create_file(classdev, attr);
990} 1010}
991 1011
992/** 1012/**
@@ -1000,7 +1020,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost)
1000 1020
1001 if (shost->hostt->shost_attrs) { 1021 if (shost->hostt->shost_attrs) {
1002 for (i = 0; shost->hostt->shost_attrs[i]; i++) { 1022 for (i = 0; shost->hostt->shost_attrs[i]; i++) {
1003 error = class_attr_add(&shost->shost_classdev, 1023 error = class_attr_add(&shost->shost_dev,
1004 shost->hostt->shost_attrs[i]); 1024 shost->hostt->shost_attrs[i]);
1005 if (error) 1025 if (error)
1006 return error; 1026 return error;
@@ -1010,7 +1030,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost)
1010 for (i = 0; scsi_sysfs_shost_attrs[i]; i++) { 1030 for (i = 0; scsi_sysfs_shost_attrs[i]; i++) {
1011 if (!class_attr_overridden(shost->hostt->shost_attrs, 1031 if (!class_attr_overridden(shost->hostt->shost_attrs,
1012 scsi_sysfs_shost_attrs[i])) { 1032 scsi_sysfs_shost_attrs[i])) {
1013 error = class_device_create_file(&shost->shost_classdev, 1033 error = device_create_file(&shost->shost_dev,
1014 scsi_sysfs_shost_attrs[i]); 1034 scsi_sysfs_shost_attrs[i]);
1015 if (error) 1035 if (error)
1016 return error; 1036 return error;
@@ -1041,10 +1061,10 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
1041 sdev->host->host_no, sdev->channel, sdev->id, 1061 sdev->host->host_no, sdev->channel, sdev->id,
1042 sdev->lun); 1062 sdev->lun);
1043 1063
1044 class_device_initialize(&sdev->sdev_classdev); 1064 device_initialize(&sdev->sdev_dev);
1045 sdev->sdev_classdev.dev = &sdev->sdev_gendev; 1065 sdev->sdev_dev.parent = &sdev->sdev_gendev;
1046 sdev->sdev_classdev.class = &sdev_class; 1066 sdev->sdev_dev.class = &sdev_class;
1047 snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE, 1067 snprintf(sdev->sdev_dev.bus_id, BUS_ID_SIZE,
1048 "%d:%d:%d:%d", sdev->host->host_no, 1068 "%d:%d:%d:%d", sdev->host->host_no,
1049 sdev->channel, sdev->id, sdev->lun); 1069 sdev->channel, sdev->id, sdev->lun);
1050 sdev->scsi_level = starget->scsi_level; 1070 sdev->scsi_level = starget->scsi_level;
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index b1119da6e88c..6b092a6c295d 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -72,8 +72,8 @@ static int fc_vport_create(struct Scsi_Host *shost, int channel,
72 * Redefine so that we can have same named attributes in the 72 * Redefine so that we can have same named attributes in the
73 * sdev/starget/host objects. 73 * sdev/starget/host objects.
74 */ 74 */
75#define FC_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ 75#define FC_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
76struct class_device_attribute class_device_attr_##_prefix##_##_name = \ 76struct device_attribute device_attr_##_prefix##_##_name = \
77 __ATTR(_name,_mode,_show,_store) 77 __ATTR(_name,_mode,_show,_store)
78 78
79#define fc_enum_name_search(title, table_type, table) \ 79#define fc_enum_name_search(title, table_type, table) \
@@ -326,26 +326,26 @@ struct fc_internal {
326 * part of the midlayer. As the remote port is specific to the 326 * part of the midlayer. As the remote port is specific to the
327 * fc transport, we must provide the attribute container. 327 * fc transport, we must provide the attribute container.
328 */ 328 */
329 struct class_device_attribute private_starget_attrs[ 329 struct device_attribute private_starget_attrs[
330 FC_STARGET_NUM_ATTRS]; 330 FC_STARGET_NUM_ATTRS];
331 struct class_device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1]; 331 struct device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1];
332 332
333 struct class_device_attribute private_host_attrs[FC_HOST_NUM_ATTRS]; 333 struct device_attribute private_host_attrs[FC_HOST_NUM_ATTRS];
334 struct class_device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1]; 334 struct device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1];
335 335
336 struct transport_container rport_attr_cont; 336 struct transport_container rport_attr_cont;
337 struct class_device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS]; 337 struct device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS];
338 struct class_device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1]; 338 struct device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1];
339 339
340 struct transport_container vport_attr_cont; 340 struct transport_container vport_attr_cont;
341 struct class_device_attribute private_vport_attrs[FC_VPORT_NUM_ATTRS]; 341 struct device_attribute private_vport_attrs[FC_VPORT_NUM_ATTRS];
342 struct class_device_attribute *vport_attrs[FC_VPORT_NUM_ATTRS + 1]; 342 struct device_attribute *vport_attrs[FC_VPORT_NUM_ATTRS + 1];
343}; 343};
344 344
345#define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t) 345#define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t)
346 346
347static int fc_target_setup(struct transport_container *tc, struct device *dev, 347static int fc_target_setup(struct transport_container *tc, struct device *dev,
348 struct class_device *cdev) 348 struct device *cdev)
349{ 349{
350 struct scsi_target *starget = to_scsi_target(dev); 350 struct scsi_target *starget = to_scsi_target(dev);
351 struct fc_rport *rport = starget_to_rport(starget); 351 struct fc_rport *rport = starget_to_rport(starget);
@@ -375,7 +375,7 @@ static DECLARE_TRANSPORT_CLASS(fc_transport_class,
375 NULL); 375 NULL);
376 376
377static int fc_host_setup(struct transport_container *tc, struct device *dev, 377static int fc_host_setup(struct transport_container *tc, struct device *dev,
378 struct class_device *cdev) 378 struct device *cdev)
379{ 379{
380 struct Scsi_Host *shost = dev_to_shost(dev); 380 struct Scsi_Host *shost = dev_to_shost(dev);
381 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 381 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
@@ -682,9 +682,10 @@ static void __exit fc_transport_exit(void)
682 682
683#define fc_rport_show_function(field, format_string, sz, cast) \ 683#define fc_rport_show_function(field, format_string, sz, cast) \
684static ssize_t \ 684static ssize_t \
685show_fc_rport_##field (struct class_device *cdev, char *buf) \ 685show_fc_rport_##field (struct device *dev, \
686 struct device_attribute *attr, char *buf) \
686{ \ 687{ \
687 struct fc_rport *rport = transport_class_to_rport(cdev); \ 688 struct fc_rport *rport = transport_class_to_rport(dev); \
688 struct Scsi_Host *shost = rport_to_shost(rport); \ 689 struct Scsi_Host *shost = rport_to_shost(rport); \
689 struct fc_internal *i = to_fc_internal(shost->transportt); \ 690 struct fc_internal *i = to_fc_internal(shost->transportt); \
690 if ((i->f->get_rport_##field) && \ 691 if ((i->f->get_rport_##field) && \
@@ -697,11 +698,12 @@ show_fc_rport_##field (struct class_device *cdev, char *buf) \
697 698
698#define fc_rport_store_function(field) \ 699#define fc_rport_store_function(field) \
699static ssize_t \ 700static ssize_t \
700store_fc_rport_##field(struct class_device *cdev, const char *buf, \ 701store_fc_rport_##field(struct device *dev, \
701 size_t count) \ 702 struct device_attribute *attr, \
703 const char *buf, size_t count) \
702{ \ 704{ \
703 int val; \ 705 int val; \
704 struct fc_rport *rport = transport_class_to_rport(cdev); \ 706 struct fc_rport *rport = transport_class_to_rport(dev); \
705 struct Scsi_Host *shost = rport_to_shost(rport); \ 707 struct Scsi_Host *shost = rport_to_shost(rport); \
706 struct fc_internal *i = to_fc_internal(shost->transportt); \ 708 struct fc_internal *i = to_fc_internal(shost->transportt); \
707 char *cp; \ 709 char *cp; \
@@ -718,58 +720,60 @@ store_fc_rport_##field(struct class_device *cdev, const char *buf, \
718 720
719#define fc_rport_rd_attr(field, format_string, sz) \ 721#define fc_rport_rd_attr(field, format_string, sz) \
720 fc_rport_show_function(field, format_string, sz, ) \ 722 fc_rport_show_function(field, format_string, sz, ) \
721static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 723static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
722 show_fc_rport_##field, NULL) 724 show_fc_rport_##field, NULL)
723 725
724#define fc_rport_rd_attr_cast(field, format_string, sz, cast) \ 726#define fc_rport_rd_attr_cast(field, format_string, sz, cast) \
725 fc_rport_show_function(field, format_string, sz, (cast)) \ 727 fc_rport_show_function(field, format_string, sz, (cast)) \
726static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 728static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
727 show_fc_rport_##field, NULL) 729 show_fc_rport_##field, NULL)
728 730
729#define fc_rport_rw_attr(field, format_string, sz) \ 731#define fc_rport_rw_attr(field, format_string, sz) \
730 fc_rport_show_function(field, format_string, sz, ) \ 732 fc_rport_show_function(field, format_string, sz, ) \
731 fc_rport_store_function(field) \ 733 fc_rport_store_function(field) \
732static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \ 734static FC_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \
733 show_fc_rport_##field, \ 735 show_fc_rport_##field, \
734 store_fc_rport_##field) 736 store_fc_rport_##field)
735 737
736 738
737#define fc_private_rport_show_function(field, format_string, sz, cast) \ 739#define fc_private_rport_show_function(field, format_string, sz, cast) \
738static ssize_t \ 740static ssize_t \
739show_fc_rport_##field (struct class_device *cdev, char *buf) \ 741show_fc_rport_##field (struct device *dev, \
742 struct device_attribute *attr, char *buf) \
740{ \ 743{ \
741 struct fc_rport *rport = transport_class_to_rport(cdev); \ 744 struct fc_rport *rport = transport_class_to_rport(dev); \
742 return snprintf(buf, sz, format_string, cast rport->field); \ 745 return snprintf(buf, sz, format_string, cast rport->field); \
743} 746}
744 747
745#define fc_private_rport_rd_attr(field, format_string, sz) \ 748#define fc_private_rport_rd_attr(field, format_string, sz) \
746 fc_private_rport_show_function(field, format_string, sz, ) \ 749 fc_private_rport_show_function(field, format_string, sz, ) \
747static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 750static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
748 show_fc_rport_##field, NULL) 751 show_fc_rport_##field, NULL)
749 752
750#define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \ 753#define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \
751 fc_private_rport_show_function(field, format_string, sz, (cast)) \ 754 fc_private_rport_show_function(field, format_string, sz, (cast)) \
752static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \ 755static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
753 show_fc_rport_##field, NULL) 756 show_fc_rport_##field, NULL)
754 757
755 758
756#define fc_private_rport_rd_enum_attr(title, maxlen) \ 759#define fc_private_rport_rd_enum_attr(title, maxlen) \
757static ssize_t \ 760static ssize_t \
758show_fc_rport_##title (struct class_device *cdev, char *buf) \ 761show_fc_rport_##title (struct device *dev, \
762 struct device_attribute *attr, char *buf) \
759{ \ 763{ \
760 struct fc_rport *rport = transport_class_to_rport(cdev); \ 764 struct fc_rport *rport = transport_class_to_rport(dev); \
761 const char *name; \ 765 const char *name; \
762 name = get_fc_##title##_name(rport->title); \ 766 name = get_fc_##title##_name(rport->title); \
763 if (!name) \ 767 if (!name) \
764 return -EINVAL; \ 768 return -EINVAL; \
765 return snprintf(buf, maxlen, "%s\n", name); \ 769 return snprintf(buf, maxlen, "%s\n", name); \
766} \ 770} \
767static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \ 771static FC_DEVICE_ATTR(rport, title, S_IRUGO, \
768 show_fc_rport_##title, NULL) 772 show_fc_rport_##title, NULL)
769 773
770 774
771#define SETUP_RPORT_ATTRIBUTE_RD(field) \ 775#define SETUP_RPORT_ATTRIBUTE_RD(field) \
772 i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 776 i->private_rport_attrs[count] = device_attr_rport_##field; \
773 i->private_rport_attrs[count].attr.mode = S_IRUGO; \ 777 i->private_rport_attrs[count].attr.mode = S_IRUGO; \
774 i->private_rport_attrs[count].store = NULL; \ 778 i->private_rport_attrs[count].store = NULL; \
775 i->rport_attrs[count] = &i->private_rport_attrs[count]; \ 779 i->rport_attrs[count] = &i->private_rport_attrs[count]; \
@@ -777,14 +781,14 @@ static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \
777 count++ 781 count++
778 782
779#define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \ 783#define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \
780 i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 784 i->private_rport_attrs[count] = device_attr_rport_##field; \
781 i->private_rport_attrs[count].attr.mode = S_IRUGO; \ 785 i->private_rport_attrs[count].attr.mode = S_IRUGO; \
782 i->private_rport_attrs[count].store = NULL; \ 786 i->private_rport_attrs[count].store = NULL; \
783 i->rport_attrs[count] = &i->private_rport_attrs[count]; \ 787 i->rport_attrs[count] = &i->private_rport_attrs[count]; \
784 count++ 788 count++
785 789
786#define SETUP_RPORT_ATTRIBUTE_RW(field) \ 790#define SETUP_RPORT_ATTRIBUTE_RW(field) \
787 i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 791 i->private_rport_attrs[count] = device_attr_rport_##field; \
788 if (!i->f->set_rport_##field) { \ 792 if (!i->f->set_rport_##field) { \
789 i->private_rport_attrs[count].attr.mode = S_IRUGO; \ 793 i->private_rport_attrs[count].attr.mode = S_IRUGO; \
790 i->private_rport_attrs[count].store = NULL; \ 794 i->private_rport_attrs[count].store = NULL; \
@@ -795,7 +799,7 @@ static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \
795 799
796#define SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(field) \ 800#define SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(field) \
797{ \ 801{ \
798 i->private_rport_attrs[count] = class_device_attr_rport_##field; \ 802 i->private_rport_attrs[count] = device_attr_rport_##field; \
799 i->rport_attrs[count] = &i->private_rport_attrs[count]; \ 803 i->rport_attrs[count] = &i->private_rport_attrs[count]; \
800 count++; \ 804 count++; \
801} 805}
@@ -808,14 +812,15 @@ static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \
808fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20); 812fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20);
809 813
810static ssize_t 814static ssize_t
811show_fc_rport_supported_classes (struct class_device *cdev, char *buf) 815show_fc_rport_supported_classes (struct device *dev,
816 struct device_attribute *attr, char *buf)
812{ 817{
813 struct fc_rport *rport = transport_class_to_rport(cdev); 818 struct fc_rport *rport = transport_class_to_rport(dev);
814 if (rport->supported_classes == FC_COS_UNSPECIFIED) 819 if (rport->supported_classes == FC_COS_UNSPECIFIED)
815 return snprintf(buf, 20, "unspecified\n"); 820 return snprintf(buf, 20, "unspecified\n");
816 return get_fc_cos_names(rport->supported_classes, buf); 821 return get_fc_cos_names(rport->supported_classes, buf);
817} 822}
818static FC_CLASS_DEVICE_ATTR(rport, supported_classes, S_IRUGO, 823static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
819 show_fc_rport_supported_classes, NULL); 824 show_fc_rport_supported_classes, NULL);
820 825
821/* Dynamic Remote Port Attributes */ 826/* Dynamic Remote Port Attributes */
@@ -825,11 +830,11 @@ static FC_CLASS_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
825 */ 830 */
826fc_rport_show_function(dev_loss_tmo, "%d\n", 20, ) 831fc_rport_show_function(dev_loss_tmo, "%d\n", 20, )
827static ssize_t 832static ssize_t
828store_fc_rport_dev_loss_tmo(struct class_device *cdev, const char *buf, 833store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
829 size_t count) 834 const char *buf, size_t count)
830{ 835{
831 int val; 836 int val;
832 struct fc_rport *rport = transport_class_to_rport(cdev); 837 struct fc_rport *rport = transport_class_to_rport(dev);
833 struct Scsi_Host *shost = rport_to_shost(rport); 838 struct Scsi_Host *shost = rport_to_shost(rport);
834 struct fc_internal *i = to_fc_internal(shost->transportt); 839 struct fc_internal *i = to_fc_internal(shost->transportt);
835 char *cp; 840 char *cp;
@@ -844,7 +849,7 @@ store_fc_rport_dev_loss_tmo(struct class_device *cdev, const char *buf,
844 i->f->set_rport_dev_loss_tmo(rport, val); 849 i->f->set_rport_dev_loss_tmo(rport, val);
845 return count; 850 return count;
846} 851}
847static FC_CLASS_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR, 852static FC_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR,
848 show_fc_rport_dev_loss_tmo, store_fc_rport_dev_loss_tmo); 853 show_fc_rport_dev_loss_tmo, store_fc_rport_dev_loss_tmo);
849 854
850 855
@@ -855,9 +860,10 @@ fc_private_rport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
855fc_private_rport_rd_attr(port_id, "0x%06x\n", 20); 860fc_private_rport_rd_attr(port_id, "0x%06x\n", 20);
856 861
857static ssize_t 862static ssize_t
858show_fc_rport_roles (struct class_device *cdev, char *buf) 863show_fc_rport_roles (struct device *dev, struct device_attribute *attr,
864 char *buf)
859{ 865{
860 struct fc_rport *rport = transport_class_to_rport(cdev); 866 struct fc_rport *rport = transport_class_to_rport(dev);
861 867
862 /* identify any roles that are port_id specific */ 868 /* identify any roles that are port_id specific */
863 if ((rport->port_id != -1) && 869 if ((rport->port_id != -1) &&
@@ -883,7 +889,7 @@ show_fc_rport_roles (struct class_device *cdev, char *buf)
883 return get_fc_port_roles_names(rport->roles, buf); 889 return get_fc_port_roles_names(rport->roles, buf);
884 } 890 }
885} 891}
886static FC_CLASS_DEVICE_ATTR(rport, roles, S_IRUGO, 892static FC_DEVICE_ATTR(rport, roles, S_IRUGO,
887 show_fc_rport_roles, NULL); 893 show_fc_rport_roles, NULL);
888 894
889fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN); 895fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
@@ -893,9 +899,10 @@ fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20);
893 * fast_io_fail_tmo attribute 899 * fast_io_fail_tmo attribute
894 */ 900 */
895static ssize_t 901static ssize_t
896show_fc_rport_fast_io_fail_tmo (struct class_device *cdev, char *buf) 902show_fc_rport_fast_io_fail_tmo (struct device *dev,
903 struct device_attribute *attr, char *buf)
897{ 904{
898 struct fc_rport *rport = transport_class_to_rport(cdev); 905 struct fc_rport *rport = transport_class_to_rport(dev);
899 906
900 if (rport->fast_io_fail_tmo == -1) 907 if (rport->fast_io_fail_tmo == -1)
901 return snprintf(buf, 5, "off\n"); 908 return snprintf(buf, 5, "off\n");
@@ -903,12 +910,13 @@ show_fc_rport_fast_io_fail_tmo (struct class_device *cdev, char *buf)
903} 910}
904 911
905static ssize_t 912static ssize_t
906store_fc_rport_fast_io_fail_tmo(struct class_device *cdev, const char *buf, 913store_fc_rport_fast_io_fail_tmo(struct device *dev,
907 size_t count) 914 struct device_attribute *attr, const char *buf,
915 size_t count)
908{ 916{
909 int val; 917 int val;
910 char *cp; 918 char *cp;
911 struct fc_rport *rport = transport_class_to_rport(cdev); 919 struct fc_rport *rport = transport_class_to_rport(dev);
912 920
913 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || 921 if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
914 (rport->port_state == FC_PORTSTATE_DELETED) || 922 (rport->port_state == FC_PORTSTATE_DELETED) ||
@@ -925,7 +933,7 @@ store_fc_rport_fast_io_fail_tmo(struct class_device *cdev, const char *buf,
925 } 933 }
926 return count; 934 return count;
927} 935}
928static FC_CLASS_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, 936static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR,
929 show_fc_rport_fast_io_fail_tmo, store_fc_rport_fast_io_fail_tmo); 937 show_fc_rport_fast_io_fail_tmo, store_fc_rport_fast_io_fail_tmo);
930 938
931 939
@@ -941,9 +949,10 @@ static FC_CLASS_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR,
941 */ 949 */
942#define fc_starget_show_function(field, format_string, sz, cast) \ 950#define fc_starget_show_function(field, format_string, sz, cast) \
943static ssize_t \ 951static ssize_t \
944show_fc_starget_##field (struct class_device *cdev, char *buf) \ 952show_fc_starget_##field (struct device *dev, \
953 struct device_attribute *attr, char *buf) \
945{ \ 954{ \
946 struct scsi_target *starget = transport_class_to_starget(cdev); \ 955 struct scsi_target *starget = transport_class_to_starget(dev); \
947 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 956 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
948 struct fc_internal *i = to_fc_internal(shost->transportt); \ 957 struct fc_internal *i = to_fc_internal(shost->transportt); \
949 struct fc_rport *rport = starget_to_rport(starget); \ 958 struct fc_rport *rport = starget_to_rport(starget); \
@@ -957,16 +966,16 @@ show_fc_starget_##field (struct class_device *cdev, char *buf) \
957 966
958#define fc_starget_rd_attr(field, format_string, sz) \ 967#define fc_starget_rd_attr(field, format_string, sz) \
959 fc_starget_show_function(field, format_string, sz, ) \ 968 fc_starget_show_function(field, format_string, sz, ) \
960static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \ 969static FC_DEVICE_ATTR(starget, field, S_IRUGO, \
961 show_fc_starget_##field, NULL) 970 show_fc_starget_##field, NULL)
962 971
963#define fc_starget_rd_attr_cast(field, format_string, sz, cast) \ 972#define fc_starget_rd_attr_cast(field, format_string, sz, cast) \
964 fc_starget_show_function(field, format_string, sz, (cast)) \ 973 fc_starget_show_function(field, format_string, sz, (cast)) \
965static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \ 974static FC_DEVICE_ATTR(starget, field, S_IRUGO, \
966 show_fc_starget_##field, NULL) 975 show_fc_starget_##field, NULL)
967 976
968#define SETUP_STARGET_ATTRIBUTE_RD(field) \ 977#define SETUP_STARGET_ATTRIBUTE_RD(field) \
969 i->private_starget_attrs[count] = class_device_attr_starget_##field; \ 978 i->private_starget_attrs[count] = device_attr_starget_##field; \
970 i->private_starget_attrs[count].attr.mode = S_IRUGO; \ 979 i->private_starget_attrs[count].attr.mode = S_IRUGO; \
971 i->private_starget_attrs[count].store = NULL; \ 980 i->private_starget_attrs[count].store = NULL; \
972 i->starget_attrs[count] = &i->private_starget_attrs[count]; \ 981 i->starget_attrs[count] = &i->private_starget_attrs[count]; \
@@ -974,7 +983,7 @@ static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \
974 count++ 983 count++
975 984
976#define SETUP_STARGET_ATTRIBUTE_RW(field) \ 985#define SETUP_STARGET_ATTRIBUTE_RW(field) \
977 i->private_starget_attrs[count] = class_device_attr_starget_##field; \ 986 i->private_starget_attrs[count] = device_attr_starget_##field; \
978 if (!i->f->set_starget_##field) { \ 987 if (!i->f->set_starget_##field) { \
979 i->private_starget_attrs[count].attr.mode = S_IRUGO; \ 988 i->private_starget_attrs[count].attr.mode = S_IRUGO; \
980 i->private_starget_attrs[count].store = NULL; \ 989 i->private_starget_attrs[count].store = NULL; \
@@ -995,9 +1004,10 @@ fc_starget_rd_attr(port_id, "0x%06x\n", 20);
995 1004
996#define fc_vport_show_function(field, format_string, sz, cast) \ 1005#define fc_vport_show_function(field, format_string, sz, cast) \
997static ssize_t \ 1006static ssize_t \
998show_fc_vport_##field (struct class_device *cdev, char *buf) \ 1007show_fc_vport_##field (struct device *dev, \
1008 struct device_attribute *attr, char *buf) \
999{ \ 1009{ \
1000 struct fc_vport *vport = transport_class_to_vport(cdev); \ 1010 struct fc_vport *vport = transport_class_to_vport(dev); \
1001 struct Scsi_Host *shost = vport_to_shost(vport); \ 1011 struct Scsi_Host *shost = vport_to_shost(vport); \
1002 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1012 struct fc_internal *i = to_fc_internal(shost->transportt); \
1003 if ((i->f->get_vport_##field) && \ 1013 if ((i->f->get_vport_##field) && \
@@ -1008,11 +1018,12 @@ show_fc_vport_##field (struct class_device *cdev, char *buf) \
1008 1018
1009#define fc_vport_store_function(field) \ 1019#define fc_vport_store_function(field) \
1010static ssize_t \ 1020static ssize_t \
1011store_fc_vport_##field(struct class_device *cdev, const char *buf, \ 1021store_fc_vport_##field(struct device *dev, \
1012 size_t count) \ 1022 struct device_attribute *attr, \
1023 const char *buf, size_t count) \
1013{ \ 1024{ \
1014 int val; \ 1025 int val; \
1015 struct fc_vport *vport = transport_class_to_vport(cdev); \ 1026 struct fc_vport *vport = transport_class_to_vport(dev); \
1016 struct Scsi_Host *shost = vport_to_shost(vport); \ 1027 struct Scsi_Host *shost = vport_to_shost(vport); \
1017 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1028 struct fc_internal *i = to_fc_internal(shost->transportt); \
1018 char *cp; \ 1029 char *cp; \
@@ -1027,10 +1038,11 @@ store_fc_vport_##field(struct class_device *cdev, const char *buf, \
1027 1038
1028#define fc_vport_store_str_function(field, slen) \ 1039#define fc_vport_store_str_function(field, slen) \
1029static ssize_t \ 1040static ssize_t \
1030store_fc_vport_##field(struct class_device *cdev, const char *buf, \ 1041store_fc_vport_##field(struct device *dev, \
1031 size_t count) \ 1042 struct device_attribute *attr, \
1043 const char *buf, size_t count) \
1032{ \ 1044{ \
1033 struct fc_vport *vport = transport_class_to_vport(cdev); \ 1045 struct fc_vport *vport = transport_class_to_vport(dev); \
1034 struct Scsi_Host *shost = vport_to_shost(vport); \ 1046 struct Scsi_Host *shost = vport_to_shost(vport); \
1035 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1047 struct fc_internal *i = to_fc_internal(shost->transportt); \
1036 unsigned int cnt=count; \ 1048 unsigned int cnt=count; \
@@ -1047,36 +1059,38 @@ store_fc_vport_##field(struct class_device *cdev, const char *buf, \
1047 1059
1048#define fc_vport_rd_attr(field, format_string, sz) \ 1060#define fc_vport_rd_attr(field, format_string, sz) \
1049 fc_vport_show_function(field, format_string, sz, ) \ 1061 fc_vport_show_function(field, format_string, sz, ) \
1050static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1062static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
1051 show_fc_vport_##field, NULL) 1063 show_fc_vport_##field, NULL)
1052 1064
1053#define fc_vport_rd_attr_cast(field, format_string, sz, cast) \ 1065#define fc_vport_rd_attr_cast(field, format_string, sz, cast) \
1054 fc_vport_show_function(field, format_string, sz, (cast)) \ 1066 fc_vport_show_function(field, format_string, sz, (cast)) \
1055static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1067static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
1056 show_fc_vport_##field, NULL) 1068 show_fc_vport_##field, NULL)
1057 1069
1058#define fc_vport_rw_attr(field, format_string, sz) \ 1070#define fc_vport_rw_attr(field, format_string, sz) \
1059 fc_vport_show_function(field, format_string, sz, ) \ 1071 fc_vport_show_function(field, format_string, sz, ) \
1060 fc_vport_store_function(field) \ 1072 fc_vport_store_function(field) \
1061static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ 1073static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \
1062 show_fc_vport_##field, \ 1074 show_fc_vport_##field, \
1063 store_fc_vport_##field) 1075 store_fc_vport_##field)
1064 1076
1065#define fc_private_vport_show_function(field, format_string, sz, cast) \ 1077#define fc_private_vport_show_function(field, format_string, sz, cast) \
1066static ssize_t \ 1078static ssize_t \
1067show_fc_vport_##field (struct class_device *cdev, char *buf) \ 1079show_fc_vport_##field (struct device *dev, \
1080 struct device_attribute *attr, char *buf) \
1068{ \ 1081{ \
1069 struct fc_vport *vport = transport_class_to_vport(cdev); \ 1082 struct fc_vport *vport = transport_class_to_vport(dev); \
1070 return snprintf(buf, sz, format_string, cast vport->field); \ 1083 return snprintf(buf, sz, format_string, cast vport->field); \
1071} 1084}
1072 1085
1073#define fc_private_vport_store_u32_function(field) \ 1086#define fc_private_vport_store_u32_function(field) \
1074static ssize_t \ 1087static ssize_t \
1075store_fc_vport_##field(struct class_device *cdev, const char *buf, \ 1088store_fc_vport_##field(struct device *dev, \
1076 size_t count) \ 1089 struct device_attribute *attr, \
1090 const char *buf, size_t count) \
1077{ \ 1091{ \
1078 u32 val; \ 1092 u32 val; \
1079 struct fc_vport *vport = transport_class_to_vport(cdev); \ 1093 struct fc_vport *vport = transport_class_to_vport(dev); \
1080 char *cp; \ 1094 char *cp; \
1081 if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) \ 1095 if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) \
1082 return -EBUSY; \ 1096 return -EBUSY; \
@@ -1090,39 +1104,41 @@ store_fc_vport_##field(struct class_device *cdev, const char *buf, \
1090 1104
1091#define fc_private_vport_rd_attr(field, format_string, sz) \ 1105#define fc_private_vport_rd_attr(field, format_string, sz) \
1092 fc_private_vport_show_function(field, format_string, sz, ) \ 1106 fc_private_vport_show_function(field, format_string, sz, ) \
1093static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1107static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
1094 show_fc_vport_##field, NULL) 1108 show_fc_vport_##field, NULL)
1095 1109
1096#define fc_private_vport_rd_attr_cast(field, format_string, sz, cast) \ 1110#define fc_private_vport_rd_attr_cast(field, format_string, sz, cast) \
1097 fc_private_vport_show_function(field, format_string, sz, (cast)) \ 1111 fc_private_vport_show_function(field, format_string, sz, (cast)) \
1098static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO, \ 1112static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
1099 show_fc_vport_##field, NULL) 1113 show_fc_vport_##field, NULL)
1100 1114
1101#define fc_private_vport_rw_u32_attr(field, format_string, sz) \ 1115#define fc_private_vport_rw_u32_attr(field, format_string, sz) \
1102 fc_private_vport_show_function(field, format_string, sz, ) \ 1116 fc_private_vport_show_function(field, format_string, sz, ) \
1103 fc_private_vport_store_u32_function(field) \ 1117 fc_private_vport_store_u32_function(field) \
1104static FC_CLASS_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \ 1118static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \
1105 show_fc_vport_##field, \ 1119 show_fc_vport_##field, \
1106 store_fc_vport_##field) 1120 store_fc_vport_##field)
1107 1121
1108 1122
1109#define fc_private_vport_rd_enum_attr(title, maxlen) \ 1123#define fc_private_vport_rd_enum_attr(title, maxlen) \
1110static ssize_t \ 1124static ssize_t \
1111show_fc_vport_##title (struct class_device *cdev, char *buf) \ 1125show_fc_vport_##title (struct device *dev, \
1126 struct device_attribute *attr, \
1127 char *buf) \
1112{ \ 1128{ \
1113 struct fc_vport *vport = transport_class_to_vport(cdev); \ 1129 struct fc_vport *vport = transport_class_to_vport(dev); \
1114 const char *name; \ 1130 const char *name; \
1115 name = get_fc_##title##_name(vport->title); \ 1131 name = get_fc_##title##_name(vport->title); \
1116 if (!name) \ 1132 if (!name) \
1117 return -EINVAL; \ 1133 return -EINVAL; \
1118 return snprintf(buf, maxlen, "%s\n", name); \ 1134 return snprintf(buf, maxlen, "%s\n", name); \
1119} \ 1135} \
1120static FC_CLASS_DEVICE_ATTR(vport, title, S_IRUGO, \ 1136static FC_DEVICE_ATTR(vport, title, S_IRUGO, \
1121 show_fc_vport_##title, NULL) 1137 show_fc_vport_##title, NULL)
1122 1138
1123 1139
1124#define SETUP_VPORT_ATTRIBUTE_RD(field) \ 1140#define SETUP_VPORT_ATTRIBUTE_RD(field) \
1125 i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1141 i->private_vport_attrs[count] = device_attr_vport_##field; \
1126 i->private_vport_attrs[count].attr.mode = S_IRUGO; \ 1142 i->private_vport_attrs[count].attr.mode = S_IRUGO; \
1127 i->private_vport_attrs[count].store = NULL; \ 1143 i->private_vport_attrs[count].store = NULL; \
1128 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ 1144 i->vport_attrs[count] = &i->private_vport_attrs[count]; \
@@ -1131,21 +1147,21 @@ static FC_CLASS_DEVICE_ATTR(vport, title, S_IRUGO, \
1131 /* NOTE: Above MACRO differs: checks function not show bit */ 1147 /* NOTE: Above MACRO differs: checks function not show bit */
1132 1148
1133#define SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(field) \ 1149#define SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(field) \
1134 i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1150 i->private_vport_attrs[count] = device_attr_vport_##field; \
1135 i->private_vport_attrs[count].attr.mode = S_IRUGO; \ 1151 i->private_vport_attrs[count].attr.mode = S_IRUGO; \
1136 i->private_vport_attrs[count].store = NULL; \ 1152 i->private_vport_attrs[count].store = NULL; \
1137 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ 1153 i->vport_attrs[count] = &i->private_vport_attrs[count]; \
1138 count++ 1154 count++
1139 1155
1140#define SETUP_VPORT_ATTRIBUTE_WR(field) \ 1156#define SETUP_VPORT_ATTRIBUTE_WR(field) \
1141 i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1157 i->private_vport_attrs[count] = device_attr_vport_##field; \
1142 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ 1158 i->vport_attrs[count] = &i->private_vport_attrs[count]; \
1143 if (i->f->field) \ 1159 if (i->f->field) \
1144 count++ 1160 count++
1145 /* NOTE: Above MACRO differs: checks function */ 1161 /* NOTE: Above MACRO differs: checks function */
1146 1162
1147#define SETUP_VPORT_ATTRIBUTE_RW(field) \ 1163#define SETUP_VPORT_ATTRIBUTE_RW(field) \
1148 i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1164 i->private_vport_attrs[count] = device_attr_vport_##field; \
1149 if (!i->f->set_vport_##field) { \ 1165 if (!i->f->set_vport_##field) { \
1150 i->private_vport_attrs[count].attr.mode = S_IRUGO; \ 1166 i->private_vport_attrs[count].attr.mode = S_IRUGO; \
1151 i->private_vport_attrs[count].store = NULL; \ 1167 i->private_vport_attrs[count].store = NULL; \
@@ -1156,7 +1172,7 @@ static FC_CLASS_DEVICE_ATTR(vport, title, S_IRUGO, \
1156 1172
1157#define SETUP_PRIVATE_VPORT_ATTRIBUTE_RW(field) \ 1173#define SETUP_PRIVATE_VPORT_ATTRIBUTE_RW(field) \
1158{ \ 1174{ \
1159 i->private_vport_attrs[count] = class_device_attr_vport_##field; \ 1175 i->private_vport_attrs[count] = device_attr_vport_##field; \
1160 i->vport_attrs[count] = &i->private_vport_attrs[count]; \ 1176 i->vport_attrs[count] = &i->private_vport_attrs[count]; \
1161 count++; \ 1177 count++; \
1162} 1178}
@@ -1176,35 +1192,36 @@ fc_private_vport_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
1176fc_private_vport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long); 1192fc_private_vport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
1177 1193
1178static ssize_t 1194static ssize_t
1179show_fc_vport_roles (struct class_device *cdev, char *buf) 1195show_fc_vport_roles (struct device *dev, struct device_attribute *attr,
1196 char *buf)
1180{ 1197{
1181 struct fc_vport *vport = transport_class_to_vport(cdev); 1198 struct fc_vport *vport = transport_class_to_vport(dev);
1182 1199
1183 if (vport->roles == FC_PORT_ROLE_UNKNOWN) 1200 if (vport->roles == FC_PORT_ROLE_UNKNOWN)
1184 return snprintf(buf, 20, "unknown\n"); 1201 return snprintf(buf, 20, "unknown\n");
1185 return get_fc_port_roles_names(vport->roles, buf); 1202 return get_fc_port_roles_names(vport->roles, buf);
1186} 1203}
1187static FC_CLASS_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL); 1204static FC_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL);
1188 1205
1189fc_private_vport_rd_enum_attr(vport_type, FC_PORTTYPE_MAX_NAMELEN); 1206fc_private_vport_rd_enum_attr(vport_type, FC_PORTTYPE_MAX_NAMELEN);
1190 1207
1191fc_private_vport_show_function(symbolic_name, "%s\n", 1208fc_private_vport_show_function(symbolic_name, "%s\n",
1192 FC_VPORT_SYMBOLIC_NAMELEN + 1, ) 1209 FC_VPORT_SYMBOLIC_NAMELEN + 1, )
1193fc_vport_store_str_function(symbolic_name, FC_VPORT_SYMBOLIC_NAMELEN) 1210fc_vport_store_str_function(symbolic_name, FC_VPORT_SYMBOLIC_NAMELEN)
1194static FC_CLASS_DEVICE_ATTR(vport, symbolic_name, S_IRUGO | S_IWUSR, 1211static FC_DEVICE_ATTR(vport, symbolic_name, S_IRUGO | S_IWUSR,
1195 show_fc_vport_symbolic_name, store_fc_vport_symbolic_name); 1212 show_fc_vport_symbolic_name, store_fc_vport_symbolic_name);
1196 1213
1197static ssize_t 1214static ssize_t
1198store_fc_vport_delete(struct class_device *cdev, const char *buf, 1215store_fc_vport_delete(struct device *dev, struct device_attribute *attr,
1199 size_t count) 1216 const char *buf, size_t count)
1200{ 1217{
1201 struct fc_vport *vport = transport_class_to_vport(cdev); 1218 struct fc_vport *vport = transport_class_to_vport(dev);
1202 struct Scsi_Host *shost = vport_to_shost(vport); 1219 struct Scsi_Host *shost = vport_to_shost(vport);
1203 1220
1204 fc_queue_work(shost, &vport->vport_delete_work); 1221 fc_queue_work(shost, &vport->vport_delete_work);
1205 return count; 1222 return count;
1206} 1223}
1207static FC_CLASS_DEVICE_ATTR(vport, vport_delete, S_IWUSR, 1224static FC_DEVICE_ATTR(vport, vport_delete, S_IWUSR,
1208 NULL, store_fc_vport_delete); 1225 NULL, store_fc_vport_delete);
1209 1226
1210 1227
@@ -1213,10 +1230,11 @@ static FC_CLASS_DEVICE_ATTR(vport, vport_delete, S_IWUSR,
1213 * Write "1" to disable, write "0" to enable 1230 * Write "1" to disable, write "0" to enable
1214 */ 1231 */
1215static ssize_t 1232static ssize_t
1216store_fc_vport_disable(struct class_device *cdev, const char *buf, 1233store_fc_vport_disable(struct device *dev, struct device_attribute *attr,
1234 const char *buf,
1217 size_t count) 1235 size_t count)
1218{ 1236{
1219 struct fc_vport *vport = transport_class_to_vport(cdev); 1237 struct fc_vport *vport = transport_class_to_vport(dev);
1220 struct Scsi_Host *shost = vport_to_shost(vport); 1238 struct Scsi_Host *shost = vport_to_shost(vport);
1221 struct fc_internal *i = to_fc_internal(shost->transportt); 1239 struct fc_internal *i = to_fc_internal(shost->transportt);
1222 int stat; 1240 int stat;
@@ -1236,7 +1254,7 @@ store_fc_vport_disable(struct class_device *cdev, const char *buf,
1236 stat = i->f->vport_disable(vport, ((*buf == '0') ? false : true)); 1254 stat = i->f->vport_disable(vport, ((*buf == '0') ? false : true));
1237 return stat ? stat : count; 1255 return stat ? stat : count;
1238} 1256}
1239static FC_CLASS_DEVICE_ATTR(vport, vport_disable, S_IWUSR, 1257static FC_DEVICE_ATTR(vport, vport_disable, S_IWUSR,
1240 NULL, store_fc_vport_disable); 1258 NULL, store_fc_vport_disable);
1241 1259
1242 1260
@@ -1246,9 +1264,10 @@ static FC_CLASS_DEVICE_ATTR(vport, vport_disable, S_IWUSR,
1246 1264
1247#define fc_host_show_function(field, format_string, sz, cast) \ 1265#define fc_host_show_function(field, format_string, sz, cast) \
1248static ssize_t \ 1266static ssize_t \
1249show_fc_host_##field (struct class_device *cdev, char *buf) \ 1267show_fc_host_##field (struct device *dev, \
1268 struct device_attribute *attr, char *buf) \
1250{ \ 1269{ \
1251 struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1270 struct Scsi_Host *shost = transport_class_to_shost(dev); \
1252 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1271 struct fc_internal *i = to_fc_internal(shost->transportt); \
1253 if (i->f->get_host_##field) \ 1272 if (i->f->get_host_##field) \
1254 i->f->get_host_##field(shost); \ 1273 i->f->get_host_##field(shost); \
@@ -1257,11 +1276,12 @@ show_fc_host_##field (struct class_device *cdev, char *buf) \
1257 1276
1258#define fc_host_store_function(field) \ 1277#define fc_host_store_function(field) \
1259static ssize_t \ 1278static ssize_t \
1260store_fc_host_##field(struct class_device *cdev, const char *buf, \ 1279store_fc_host_##field(struct device *dev, \
1261 size_t count) \ 1280 struct device_attribute *attr, \
1281 const char *buf, size_t count) \
1262{ \ 1282{ \
1263 int val; \ 1283 int val; \
1264 struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1284 struct Scsi_Host *shost = transport_class_to_shost(dev); \
1265 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1285 struct fc_internal *i = to_fc_internal(shost->transportt); \
1266 char *cp; \ 1286 char *cp; \
1267 \ 1287 \
@@ -1274,10 +1294,11 @@ store_fc_host_##field(struct class_device *cdev, const char *buf, \
1274 1294
1275#define fc_host_store_str_function(field, slen) \ 1295#define fc_host_store_str_function(field, slen) \
1276static ssize_t \ 1296static ssize_t \
1277store_fc_host_##field(struct class_device *cdev, const char *buf, \ 1297store_fc_host_##field(struct device *dev, \
1278 size_t count) \ 1298 struct device_attribute *attr, \
1299 const char *buf, size_t count) \
1279{ \ 1300{ \
1280 struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1301 struct Scsi_Host *shost = transport_class_to_shost(dev); \
1281 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1302 struct fc_internal *i = to_fc_internal(shost->transportt); \
1282 unsigned int cnt=count; \ 1303 unsigned int cnt=count; \
1283 \ 1304 \
@@ -1293,26 +1314,27 @@ store_fc_host_##field(struct class_device *cdev, const char *buf, \
1293 1314
1294#define fc_host_rd_attr(field, format_string, sz) \ 1315#define fc_host_rd_attr(field, format_string, sz) \
1295 fc_host_show_function(field, format_string, sz, ) \ 1316 fc_host_show_function(field, format_string, sz, ) \
1296static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1317static FC_DEVICE_ATTR(host, field, S_IRUGO, \
1297 show_fc_host_##field, NULL) 1318 show_fc_host_##field, NULL)
1298 1319
1299#define fc_host_rd_attr_cast(field, format_string, sz, cast) \ 1320#define fc_host_rd_attr_cast(field, format_string, sz, cast) \
1300 fc_host_show_function(field, format_string, sz, (cast)) \ 1321 fc_host_show_function(field, format_string, sz, (cast)) \
1301static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1322static FC_DEVICE_ATTR(host, field, S_IRUGO, \
1302 show_fc_host_##field, NULL) 1323 show_fc_host_##field, NULL)
1303 1324
1304#define fc_host_rw_attr(field, format_string, sz) \ 1325#define fc_host_rw_attr(field, format_string, sz) \
1305 fc_host_show_function(field, format_string, sz, ) \ 1326 fc_host_show_function(field, format_string, sz, ) \
1306 fc_host_store_function(field) \ 1327 fc_host_store_function(field) \
1307static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \ 1328static FC_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \
1308 show_fc_host_##field, \ 1329 show_fc_host_##field, \
1309 store_fc_host_##field) 1330 store_fc_host_##field)
1310 1331
1311#define fc_host_rd_enum_attr(title, maxlen) \ 1332#define fc_host_rd_enum_attr(title, maxlen) \
1312static ssize_t \ 1333static ssize_t \
1313show_fc_host_##title (struct class_device *cdev, char *buf) \ 1334show_fc_host_##title (struct device *dev, \
1335 struct device_attribute *attr, char *buf) \
1314{ \ 1336{ \
1315 struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1337 struct Scsi_Host *shost = transport_class_to_shost(dev); \
1316 struct fc_internal *i = to_fc_internal(shost->transportt); \ 1338 struct fc_internal *i = to_fc_internal(shost->transportt); \
1317 const char *name; \ 1339 const char *name; \
1318 if (i->f->get_host_##title) \ 1340 if (i->f->get_host_##title) \
@@ -1322,10 +1344,10 @@ show_fc_host_##title (struct class_device *cdev, char *buf) \
1322 return -EINVAL; \ 1344 return -EINVAL; \
1323 return snprintf(buf, maxlen, "%s\n", name); \ 1345 return snprintf(buf, maxlen, "%s\n", name); \
1324} \ 1346} \
1325static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL) 1347static FC_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL)
1326 1348
1327#define SETUP_HOST_ATTRIBUTE_RD(field) \ 1349#define SETUP_HOST_ATTRIBUTE_RD(field) \
1328 i->private_host_attrs[count] = class_device_attr_host_##field; \ 1350 i->private_host_attrs[count] = device_attr_host_##field; \
1329 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1351 i->private_host_attrs[count].attr.mode = S_IRUGO; \
1330 i->private_host_attrs[count].store = NULL; \ 1352 i->private_host_attrs[count].store = NULL; \
1331 i->host_attrs[count] = &i->private_host_attrs[count]; \ 1353 i->host_attrs[count] = &i->private_host_attrs[count]; \
@@ -1333,14 +1355,14 @@ static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL)
1333 count++ 1355 count++
1334 1356
1335#define SETUP_HOST_ATTRIBUTE_RD_NS(field) \ 1357#define SETUP_HOST_ATTRIBUTE_RD_NS(field) \
1336 i->private_host_attrs[count] = class_device_attr_host_##field; \ 1358 i->private_host_attrs[count] = device_attr_host_##field; \
1337 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1359 i->private_host_attrs[count].attr.mode = S_IRUGO; \
1338 i->private_host_attrs[count].store = NULL; \ 1360 i->private_host_attrs[count].store = NULL; \
1339 i->host_attrs[count] = &i->private_host_attrs[count]; \ 1361 i->host_attrs[count] = &i->private_host_attrs[count]; \
1340 count++ 1362 count++
1341 1363
1342#define SETUP_HOST_ATTRIBUTE_RW(field) \ 1364#define SETUP_HOST_ATTRIBUTE_RW(field) \
1343 i->private_host_attrs[count] = class_device_attr_host_##field; \ 1365 i->private_host_attrs[count] = device_attr_host_##field; \
1344 if (!i->f->set_host_##field) { \ 1366 if (!i->f->set_host_##field) { \
1345 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1367 i->private_host_attrs[count].attr.mode = S_IRUGO; \
1346 i->private_host_attrs[count].store = NULL; \ 1368 i->private_host_attrs[count].store = NULL; \
@@ -1352,24 +1374,25 @@ static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL)
1352 1374
1353#define fc_private_host_show_function(field, format_string, sz, cast) \ 1375#define fc_private_host_show_function(field, format_string, sz, cast) \
1354static ssize_t \ 1376static ssize_t \
1355show_fc_host_##field (struct class_device *cdev, char *buf) \ 1377show_fc_host_##field (struct device *dev, \
1378 struct device_attribute *attr, char *buf) \
1356{ \ 1379{ \
1357 struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1380 struct Scsi_Host *shost = transport_class_to_shost(dev); \
1358 return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \ 1381 return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \
1359} 1382}
1360 1383
1361#define fc_private_host_rd_attr(field, format_string, sz) \ 1384#define fc_private_host_rd_attr(field, format_string, sz) \
1362 fc_private_host_show_function(field, format_string, sz, ) \ 1385 fc_private_host_show_function(field, format_string, sz, ) \
1363static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1386static FC_DEVICE_ATTR(host, field, S_IRUGO, \
1364 show_fc_host_##field, NULL) 1387 show_fc_host_##field, NULL)
1365 1388
1366#define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \ 1389#define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \
1367 fc_private_host_show_function(field, format_string, sz, (cast)) \ 1390 fc_private_host_show_function(field, format_string, sz, (cast)) \
1368static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \ 1391static FC_DEVICE_ATTR(host, field, S_IRUGO, \
1369 show_fc_host_##field, NULL) 1392 show_fc_host_##field, NULL)
1370 1393
1371#define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \ 1394#define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \
1372 i->private_host_attrs[count] = class_device_attr_host_##field; \ 1395 i->private_host_attrs[count] = device_attr_host_##field; \
1373 i->private_host_attrs[count].attr.mode = S_IRUGO; \ 1396 i->private_host_attrs[count].attr.mode = S_IRUGO; \
1374 i->private_host_attrs[count].store = NULL; \ 1397 i->private_host_attrs[count].store = NULL; \
1375 i->host_attrs[count] = &i->private_host_attrs[count]; \ 1398 i->host_attrs[count] = &i->private_host_attrs[count]; \
@@ -1377,7 +1400,7 @@ static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
1377 1400
1378#define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \ 1401#define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \
1379{ \ 1402{ \
1380 i->private_host_attrs[count] = class_device_attr_host_##field; \ 1403 i->private_host_attrs[count] = device_attr_host_##field; \
1381 i->host_attrs[count] = &i->private_host_attrs[count]; \ 1404 i->host_attrs[count] = &i->private_host_attrs[count]; \
1382 count++; \ 1405 count++; \
1383} 1406}
@@ -1386,38 +1409,41 @@ static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
1386/* Fixed Host Attributes */ 1409/* Fixed Host Attributes */
1387 1410
1388static ssize_t 1411static ssize_t
1389show_fc_host_supported_classes (struct class_device *cdev, char *buf) 1412show_fc_host_supported_classes (struct device *dev,
1413 struct device_attribute *attr, char *buf)
1390{ 1414{
1391 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1415 struct Scsi_Host *shost = transport_class_to_shost(dev);
1392 1416
1393 if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED) 1417 if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED)
1394 return snprintf(buf, 20, "unspecified\n"); 1418 return snprintf(buf, 20, "unspecified\n");
1395 1419
1396 return get_fc_cos_names(fc_host_supported_classes(shost), buf); 1420 return get_fc_cos_names(fc_host_supported_classes(shost), buf);
1397} 1421}
1398static FC_CLASS_DEVICE_ATTR(host, supported_classes, S_IRUGO, 1422static FC_DEVICE_ATTR(host, supported_classes, S_IRUGO,
1399 show_fc_host_supported_classes, NULL); 1423 show_fc_host_supported_classes, NULL);
1400 1424
1401static ssize_t 1425static ssize_t
1402show_fc_host_supported_fc4s (struct class_device *cdev, char *buf) 1426show_fc_host_supported_fc4s (struct device *dev,
1427 struct device_attribute *attr, char *buf)
1403{ 1428{
1404 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1429 struct Scsi_Host *shost = transport_class_to_shost(dev);
1405 return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost)); 1430 return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost));
1406} 1431}
1407static FC_CLASS_DEVICE_ATTR(host, supported_fc4s, S_IRUGO, 1432static FC_DEVICE_ATTR(host, supported_fc4s, S_IRUGO,
1408 show_fc_host_supported_fc4s, NULL); 1433 show_fc_host_supported_fc4s, NULL);
1409 1434
1410static ssize_t 1435static ssize_t
1411show_fc_host_supported_speeds (struct class_device *cdev, char *buf) 1436show_fc_host_supported_speeds (struct device *dev,
1437 struct device_attribute *attr, char *buf)
1412{ 1438{
1413 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1439 struct Scsi_Host *shost = transport_class_to_shost(dev);
1414 1440
1415 if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN) 1441 if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN)
1416 return snprintf(buf, 20, "unknown\n"); 1442 return snprintf(buf, 20, "unknown\n");
1417 1443
1418 return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf); 1444 return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf);
1419} 1445}
1420static FC_CLASS_DEVICE_ATTR(host, supported_speeds, S_IRUGO, 1446static FC_DEVICE_ATTR(host, supported_speeds, S_IRUGO,
1421 show_fc_host_supported_speeds, NULL); 1447 show_fc_host_supported_speeds, NULL);
1422 1448
1423 1449
@@ -1433,9 +1459,10 @@ fc_private_host_rd_attr(serial_number, "%s\n", (FC_SERIAL_NUMBER_SIZE +1));
1433/* Dynamic Host Attributes */ 1459/* Dynamic Host Attributes */
1434 1460
1435static ssize_t 1461static ssize_t
1436show_fc_host_active_fc4s (struct class_device *cdev, char *buf) 1462show_fc_host_active_fc4s (struct device *dev,
1463 struct device_attribute *attr, char *buf)
1437{ 1464{
1438 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1465 struct Scsi_Host *shost = transport_class_to_shost(dev);
1439 struct fc_internal *i = to_fc_internal(shost->transportt); 1466 struct fc_internal *i = to_fc_internal(shost->transportt);
1440 1467
1441 if (i->f->get_host_active_fc4s) 1468 if (i->f->get_host_active_fc4s)
@@ -1443,13 +1470,14 @@ show_fc_host_active_fc4s (struct class_device *cdev, char *buf)
1443 1470
1444 return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost)); 1471 return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost));
1445} 1472}
1446static FC_CLASS_DEVICE_ATTR(host, active_fc4s, S_IRUGO, 1473static FC_DEVICE_ATTR(host, active_fc4s, S_IRUGO,
1447 show_fc_host_active_fc4s, NULL); 1474 show_fc_host_active_fc4s, NULL);
1448 1475
1449static ssize_t 1476static ssize_t
1450show_fc_host_speed (struct class_device *cdev, char *buf) 1477show_fc_host_speed (struct device *dev,
1478 struct device_attribute *attr, char *buf)
1451{ 1479{
1452 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1480 struct Scsi_Host *shost = transport_class_to_shost(dev);
1453 struct fc_internal *i = to_fc_internal(shost->transportt); 1481 struct fc_internal *i = to_fc_internal(shost->transportt);
1454 1482
1455 if (i->f->get_host_speed) 1483 if (i->f->get_host_speed)
@@ -1460,7 +1488,7 @@ show_fc_host_speed (struct class_device *cdev, char *buf)
1460 1488
1461 return get_fc_port_speed_names(fc_host_speed(shost), buf); 1489 return get_fc_port_speed_names(fc_host_speed(shost), buf);
1462} 1490}
1463static FC_CLASS_DEVICE_ATTR(host, speed, S_IRUGO, 1491static FC_DEVICE_ATTR(host, speed, S_IRUGO,
1464 show_fc_host_speed, NULL); 1492 show_fc_host_speed, NULL);
1465 1493
1466 1494
@@ -1473,16 +1501,17 @@ fc_host_rd_attr(symbolic_name, "%s\n", FC_SYMBOLIC_NAME_SIZE + 1);
1473fc_private_host_show_function(system_hostname, "%s\n", 1501fc_private_host_show_function(system_hostname, "%s\n",
1474 FC_SYMBOLIC_NAME_SIZE + 1, ) 1502 FC_SYMBOLIC_NAME_SIZE + 1, )
1475fc_host_store_str_function(system_hostname, FC_SYMBOLIC_NAME_SIZE) 1503fc_host_store_str_function(system_hostname, FC_SYMBOLIC_NAME_SIZE)
1476static FC_CLASS_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR, 1504static FC_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR,
1477 show_fc_host_system_hostname, store_fc_host_system_hostname); 1505 show_fc_host_system_hostname, store_fc_host_system_hostname);
1478 1506
1479 1507
1480/* Private Host Attributes */ 1508/* Private Host Attributes */
1481 1509
1482static ssize_t 1510static ssize_t
1483show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf) 1511show_fc_private_host_tgtid_bind_type(struct device *dev,
1512 struct device_attribute *attr, char *buf)
1484{ 1513{
1485 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1514 struct Scsi_Host *shost = transport_class_to_shost(dev);
1486 const char *name; 1515 const char *name;
1487 1516
1488 name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost)); 1517 name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost));
@@ -1495,10 +1524,10 @@ show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf)
1495 pos = list_entry((head)->next, typeof(*pos), member) 1524 pos = list_entry((head)->next, typeof(*pos), member)
1496 1525
1497static ssize_t 1526static ssize_t
1498store_fc_private_host_tgtid_bind_type(struct class_device *cdev, 1527store_fc_private_host_tgtid_bind_type(struct device *dev,
1499 const char *buf, size_t count) 1528 struct device_attribute *attr, const char *buf, size_t count)
1500{ 1529{
1501 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1530 struct Scsi_Host *shost = transport_class_to_shost(dev);
1502 struct fc_rport *rport; 1531 struct fc_rport *rport;
1503 enum fc_tgtid_binding_type val; 1532 enum fc_tgtid_binding_type val;
1504 unsigned long flags; 1533 unsigned long flags;
@@ -1523,15 +1552,15 @@ store_fc_private_host_tgtid_bind_type(struct class_device *cdev,
1523 return count; 1552 return count;
1524} 1553}
1525 1554
1526static FC_CLASS_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR, 1555static FC_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR,
1527 show_fc_private_host_tgtid_bind_type, 1556 show_fc_private_host_tgtid_bind_type,
1528 store_fc_private_host_tgtid_bind_type); 1557 store_fc_private_host_tgtid_bind_type);
1529 1558
1530static ssize_t 1559static ssize_t
1531store_fc_private_host_issue_lip(struct class_device *cdev, 1560store_fc_private_host_issue_lip(struct device *dev,
1532 const char *buf, size_t count) 1561 struct device_attribute *attr, const char *buf, size_t count)
1533{ 1562{
1534 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1563 struct Scsi_Host *shost = transport_class_to_shost(dev);
1535 struct fc_internal *i = to_fc_internal(shost->transportt); 1564 struct fc_internal *i = to_fc_internal(shost->transportt);
1536 int ret; 1565 int ret;
1537 1566
@@ -1544,7 +1573,7 @@ store_fc_private_host_issue_lip(struct class_device *cdev,
1544 return -ENOENT; 1573 return -ENOENT;
1545} 1574}
1546 1575
1547static FC_CLASS_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL, 1576static FC_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL,
1548 store_fc_private_host_issue_lip); 1577 store_fc_private_host_issue_lip);
1549 1578
1550fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20); 1579fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20);
@@ -1556,9 +1585,9 @@ fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20);
1556 1585
1557/* Show a given an attribute in the statistics group */ 1586/* Show a given an attribute in the statistics group */
1558static ssize_t 1587static ssize_t
1559fc_stat_show(const struct class_device *cdev, char *buf, unsigned long offset) 1588fc_stat_show(const struct device *dev, char *buf, unsigned long offset)
1560{ 1589{
1561 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1590 struct Scsi_Host *shost = transport_class_to_shost(dev);
1562 struct fc_internal *i = to_fc_internal(shost->transportt); 1591 struct fc_internal *i = to_fc_internal(shost->transportt);
1563 struct fc_host_statistics *stats; 1592 struct fc_host_statistics *stats;
1564 ssize_t ret = -ENOENT; 1593 ssize_t ret = -ENOENT;
@@ -1579,12 +1608,14 @@ fc_stat_show(const struct class_device *cdev, char *buf, unsigned long offset)
1579 1608
1580/* generate a read-only statistics attribute */ 1609/* generate a read-only statistics attribute */
1581#define fc_host_statistic(name) \ 1610#define fc_host_statistic(name) \
1582static ssize_t show_fcstat_##name(struct class_device *cd, char *buf) \ 1611static ssize_t show_fcstat_##name(struct device *cd, \
1612 struct device_attribute *attr, \
1613 char *buf) \
1583{ \ 1614{ \
1584 return fc_stat_show(cd, buf, \ 1615 return fc_stat_show(cd, buf, \
1585 offsetof(struct fc_host_statistics, name)); \ 1616 offsetof(struct fc_host_statistics, name)); \
1586} \ 1617} \
1587static FC_CLASS_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL) 1618static FC_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL)
1588 1619
1589fc_host_statistic(seconds_since_last_reset); 1620fc_host_statistic(seconds_since_last_reset);
1590fc_host_statistic(tx_frames); 1621fc_host_statistic(tx_frames);
@@ -1608,10 +1639,10 @@ fc_host_statistic(fcp_input_megabytes);
1608fc_host_statistic(fcp_output_megabytes); 1639fc_host_statistic(fcp_output_megabytes);
1609 1640
1610static ssize_t 1641static ssize_t
1611fc_reset_statistics(struct class_device *cdev, const char *buf, 1642fc_reset_statistics(struct device *dev, struct device_attribute *attr,
1612 size_t count) 1643 const char *buf, size_t count)
1613{ 1644{
1614 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1645 struct Scsi_Host *shost = transport_class_to_shost(dev);
1615 struct fc_internal *i = to_fc_internal(shost->transportt); 1646 struct fc_internal *i = to_fc_internal(shost->transportt);
1616 1647
1617 /* ignore any data value written to the attribute */ 1648 /* ignore any data value written to the attribute */
@@ -1622,31 +1653,31 @@ fc_reset_statistics(struct class_device *cdev, const char *buf,
1622 1653
1623 return -ENOENT; 1654 return -ENOENT;
1624} 1655}
1625static FC_CLASS_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL, 1656static FC_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL,
1626 fc_reset_statistics); 1657 fc_reset_statistics);
1627 1658
1628static struct attribute *fc_statistics_attrs[] = { 1659static struct attribute *fc_statistics_attrs[] = {
1629 &class_device_attr_host_seconds_since_last_reset.attr, 1660 &device_attr_host_seconds_since_last_reset.attr,
1630 &class_device_attr_host_tx_frames.attr, 1661 &device_attr_host_tx_frames.attr,
1631 &class_device_attr_host_tx_words.attr, 1662 &device_attr_host_tx_words.attr,
1632 &class_device_attr_host_rx_frames.attr, 1663 &device_attr_host_rx_frames.attr,
1633 &class_device_attr_host_rx_words.attr, 1664 &device_attr_host_rx_words.attr,
1634 &class_device_attr_host_lip_count.attr, 1665 &device_attr_host_lip_count.attr,
1635 &class_device_attr_host_nos_count.attr, 1666 &device_attr_host_nos_count.attr,
1636 &class_device_attr_host_error_frames.attr, 1667 &device_attr_host_error_frames.attr,
1637 &class_device_attr_host_dumped_frames.attr, 1668 &device_attr_host_dumped_frames.attr,
1638 &class_device_attr_host_link_failure_count.attr, 1669 &device_attr_host_link_failure_count.attr,
1639 &class_device_attr_host_loss_of_sync_count.attr, 1670 &device_attr_host_loss_of_sync_count.attr,
1640 &class_device_attr_host_loss_of_signal_count.attr, 1671 &device_attr_host_loss_of_signal_count.attr,
1641 &class_device_attr_host_prim_seq_protocol_err_count.attr, 1672 &device_attr_host_prim_seq_protocol_err_count.attr,
1642 &class_device_attr_host_invalid_tx_word_count.attr, 1673 &device_attr_host_invalid_tx_word_count.attr,
1643 &class_device_attr_host_invalid_crc_count.attr, 1674 &device_attr_host_invalid_crc_count.attr,
1644 &class_device_attr_host_fcp_input_requests.attr, 1675 &device_attr_host_fcp_input_requests.attr,
1645 &class_device_attr_host_fcp_output_requests.attr, 1676 &device_attr_host_fcp_output_requests.attr,
1646 &class_device_attr_host_fcp_control_requests.attr, 1677 &device_attr_host_fcp_control_requests.attr,
1647 &class_device_attr_host_fcp_input_megabytes.attr, 1678 &device_attr_host_fcp_input_megabytes.attr,
1648 &class_device_attr_host_fcp_output_megabytes.attr, 1679 &device_attr_host_fcp_output_megabytes.attr,
1649 &class_device_attr_host_reset_statistics.attr, 1680 &device_attr_host_reset_statistics.attr,
1650 NULL 1681 NULL
1651}; 1682};
1652 1683
@@ -1695,10 +1726,10 @@ fc_parse_wwn(const char *ns, u64 *nm)
1695 * as hex characters, and may *not* contain any prefixes (e.g. 0x, x, etc) 1726 * as hex characters, and may *not* contain any prefixes (e.g. 0x, x, etc)
1696 */ 1727 */
1697static ssize_t 1728static ssize_t
1698store_fc_host_vport_create(struct class_device *cdev, const char *buf, 1729store_fc_host_vport_create(struct device *dev, struct device_attribute *attr,
1699 size_t count) 1730 const char *buf, size_t count)
1700{ 1731{
1701 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1732 struct Scsi_Host *shost = transport_class_to_shost(dev);
1702 struct fc_vport_identifiers vid; 1733 struct fc_vport_identifiers vid;
1703 struct fc_vport *vport; 1734 struct fc_vport *vport;
1704 unsigned int cnt=count; 1735 unsigned int cnt=count;
@@ -1731,7 +1762,7 @@ store_fc_host_vport_create(struct class_device *cdev, const char *buf,
1731 stat = fc_vport_create(shost, 0, &shost->shost_gendev, &vid, &vport); 1762 stat = fc_vport_create(shost, 0, &shost->shost_gendev, &vid, &vport);
1732 return stat ? stat : count; 1763 return stat ? stat : count;
1733} 1764}
1734static FC_CLASS_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL, 1765static FC_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL,
1735 store_fc_host_vport_create); 1766 store_fc_host_vport_create);
1736 1767
1737 1768
@@ -1742,10 +1773,10 @@ static FC_CLASS_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL,
1742 * any prefixes (e.g. 0x, x, etc) 1773 * any prefixes (e.g. 0x, x, etc)
1743 */ 1774 */
1744static ssize_t 1775static ssize_t
1745store_fc_host_vport_delete(struct class_device *cdev, const char *buf, 1776store_fc_host_vport_delete(struct device *dev, struct device_attribute *attr,
1746 size_t count) 1777 const char *buf, size_t count)
1747{ 1778{
1748 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1779 struct Scsi_Host *shost = transport_class_to_shost(dev);
1749 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 1780 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
1750 struct fc_vport *vport; 1781 struct fc_vport *vport;
1751 u64 wwpn, wwnn; 1782 u64 wwpn, wwnn;
@@ -1787,7 +1818,7 @@ store_fc_host_vport_delete(struct class_device *cdev, const char *buf,
1787 stat = fc_vport_terminate(vport); 1818 stat = fc_vport_terminate(vport);
1788 return stat ? stat : count; 1819 return stat ? stat : count;
1789} 1820}
1790static FC_CLASS_DEVICE_ATTR(host, vport_delete, S_IWUSR, NULL, 1821static FC_DEVICE_ATTR(host, vport_delete, S_IWUSR, NULL,
1791 store_fc_host_vport_delete); 1822 store_fc_host_vport_delete);
1792 1823
1793 1824
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index ca7bb6f63bde..65d1737eb664 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -40,13 +40,13 @@ struct iscsi_internal {
40 struct scsi_transport_template t; 40 struct scsi_transport_template t;
41 struct iscsi_transport *iscsi_transport; 41 struct iscsi_transport *iscsi_transport;
42 struct list_head list; 42 struct list_head list;
43 struct class_device cdev; 43 struct device dev;
44 44
45 struct class_device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; 45 struct device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1];
46 struct transport_container conn_cont; 46 struct transport_container conn_cont;
47 struct class_device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; 47 struct device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1];
48 struct transport_container session_cont; 48 struct transport_container session_cont;
49 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; 49 struct device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
50}; 50};
51 51
52static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ 52static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
@@ -63,12 +63,12 @@ static DEFINE_SPINLOCK(iscsi_transport_lock);
63#define to_iscsi_internal(tmpl) \ 63#define to_iscsi_internal(tmpl) \
64 container_of(tmpl, struct iscsi_internal, t) 64 container_of(tmpl, struct iscsi_internal, t)
65 65
66#define cdev_to_iscsi_internal(_cdev) \ 66#define dev_to_iscsi_internal(_dev) \
67 container_of(_cdev, struct iscsi_internal, cdev) 67 container_of(_dev, struct iscsi_internal, dev)
68 68
69static void iscsi_transport_release(struct class_device *cdev) 69static void iscsi_transport_release(struct device *dev)
70{ 70{
71 struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); 71 struct iscsi_internal *priv = dev_to_iscsi_internal(dev);
72 kfree(priv); 72 kfree(priv);
73} 73}
74 74
@@ -78,25 +78,27 @@ static void iscsi_transport_release(struct class_device *cdev)
78 */ 78 */
79static struct class iscsi_transport_class = { 79static struct class iscsi_transport_class = {
80 .name = "iscsi_transport", 80 .name = "iscsi_transport",
81 .release = iscsi_transport_release, 81 .dev_release = iscsi_transport_release,
82}; 82};
83 83
84static ssize_t 84static ssize_t
85show_transport_handle(struct class_device *cdev, char *buf) 85show_transport_handle(struct device *dev, struct device_attribute *attr,
86 char *buf)
86{ 87{
87 struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); 88 struct iscsi_internal *priv = dev_to_iscsi_internal(dev);
88 return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); 89 return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport));
89} 90}
90static CLASS_DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); 91static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL);
91 92
92#define show_transport_attr(name, format) \ 93#define show_transport_attr(name, format) \
93static ssize_t \ 94static ssize_t \
94show_transport_##name(struct class_device *cdev, char *buf) \ 95show_transport_##name(struct device *dev, \
96 struct device_attribute *attr,char *buf) \
95{ \ 97{ \
96 struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); \ 98 struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \
97 return sprintf(buf, format"\n", priv->iscsi_transport->name); \ 99 return sprintf(buf, format"\n", priv->iscsi_transport->name); \
98} \ 100} \
99static CLASS_DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); 101static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL);
100 102
101show_transport_attr(caps, "0x%x"); 103show_transport_attr(caps, "0x%x");
102show_transport_attr(max_lun, "%d"); 104show_transport_attr(max_lun, "%d");
@@ -104,11 +106,11 @@ show_transport_attr(max_conn, "%d");
104show_transport_attr(max_cmd_len, "%d"); 106show_transport_attr(max_cmd_len, "%d");
105 107
106static struct attribute *iscsi_transport_attrs[] = { 108static struct attribute *iscsi_transport_attrs[] = {
107 &class_device_attr_handle.attr, 109 &dev_attr_handle.attr,
108 &class_device_attr_caps.attr, 110 &dev_attr_caps.attr,
109 &class_device_attr_max_lun.attr, 111 &dev_attr_max_lun.attr,
110 &class_device_attr_max_conn.attr, 112 &dev_attr_max_conn.attr,
111 &class_device_attr_max_cmd_len.attr, 113 &dev_attr_max_cmd_len.attr,
112 NULL, 114 NULL,
113}; 115};
114 116
@@ -119,7 +121,7 @@ static struct attribute_group iscsi_transport_group = {
119 121
120 122
121static int iscsi_setup_host(struct transport_container *tc, struct device *dev, 123static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
122 struct class_device *cdev) 124 struct device *cdev)
123{ 125{
124 struct Scsi_Host *shost = dev_to_shost(dev); 126 struct Scsi_Host *shost = dev_to_shost(dev);
125 struct iscsi_host *ihost = shost->shost_data; 127 struct iscsi_host *ihost = shost->shost_data;
@@ -139,7 +141,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
139} 141}
140 142
141static int iscsi_remove_host(struct transport_container *tc, struct device *dev, 143static int iscsi_remove_host(struct transport_container *tc, struct device *dev,
142 struct class_device *cdev) 144 struct device *cdev)
143{ 145{
144 struct Scsi_Host *shost = dev_to_shost(dev); 146 struct Scsi_Host *shost = dev_to_shost(dev);
145 struct iscsi_host *ihost = shost->shost_data; 147 struct iscsi_host *ihost = shost->shost_data;
@@ -1337,11 +1339,8 @@ iscsi_if_rx(struct sk_buff *skb)
1337 mutex_unlock(&rx_queue_mutex); 1339 mutex_unlock(&rx_queue_mutex);
1338} 1340}
1339 1341
1340#define iscsi_cdev_to_conn(_cdev) \
1341 iscsi_dev_to_conn(_cdev->dev)
1342
1343#define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \ 1342#define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \
1344struct class_device_attribute class_device_attr_##_prefix##_##_name = \ 1343struct device_attribute dev_attr_##_prefix##_##_name = \
1345 __ATTR(_name,_mode,_show,_store) 1344 __ATTR(_name,_mode,_show,_store)
1346 1345
1347/* 1346/*
@@ -1349,9 +1348,10 @@ struct class_device_attribute class_device_attr_##_prefix##_##_name = \
1349 */ 1348 */
1350#define iscsi_conn_attr_show(param) \ 1349#define iscsi_conn_attr_show(param) \
1351static ssize_t \ 1350static ssize_t \
1352show_conn_param_##param(struct class_device *cdev, char *buf) \ 1351show_conn_param_##param(struct device *dev, \
1352 struct device_attribute *attr, char *buf) \
1353{ \ 1353{ \
1354 struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ 1354 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \
1355 struct iscsi_transport *t = conn->transport; \ 1355 struct iscsi_transport *t = conn->transport; \
1356 return t->get_conn_param(conn, param, buf); \ 1356 return t->get_conn_param(conn, param, buf); \
1357} 1357}
@@ -1375,17 +1375,16 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);
1375iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); 1375iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO);
1376iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); 1376iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO);
1377 1377
1378#define iscsi_cdev_to_session(_cdev) \
1379 iscsi_dev_to_session(_cdev->dev)
1380
1381/* 1378/*
1382 * iSCSI session attrs 1379 * iSCSI session attrs
1383 */ 1380 */
1384#define iscsi_session_attr_show(param, perm) \ 1381#define iscsi_session_attr_show(param, perm) \
1385static ssize_t \ 1382static ssize_t \
1386show_session_param_##param(struct class_device *cdev, char *buf) \ 1383show_session_param_##param(struct device *dev, \
1384 struct device_attribute *attr, char *buf) \
1387{ \ 1385{ \
1388 struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ 1386 struct iscsi_cls_session *session = \
1387 iscsi_dev_to_session(dev->parent); \
1389 struct iscsi_transport *t = session->transport; \ 1388 struct iscsi_transport *t = session->transport; \
1390 \ 1389 \
1391 if (perm && !capable(CAP_SYS_ADMIN)) \ 1390 if (perm && !capable(CAP_SYS_ADMIN)) \
@@ -1417,9 +1416,10 @@ iscsi_session_attr(abort_tmo, ISCSI_PARAM_ABORT_TMO, 0);
1417iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); 1416iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0);
1418 1417
1419static ssize_t 1418static ssize_t
1420show_priv_session_state(struct class_device *cdev, char *buf) 1419show_priv_session_state(struct device *dev, struct device_attribute *attr,
1420 char *buf)
1421{ 1421{
1422 struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); 1422 struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent);
1423 return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); 1423 return sprintf(buf, "%s\n", iscsi_session_state_name(session->state));
1424} 1424}
1425static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, 1425static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state,
@@ -1427,9 +1427,11 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state,
1427 1427
1428#define iscsi_priv_session_attr_show(field, format) \ 1428#define iscsi_priv_session_attr_show(field, format) \
1429static ssize_t \ 1429static ssize_t \
1430show_priv_session_##field(struct class_device *cdev, char *buf) \ 1430show_priv_session_##field(struct device *dev, \
1431 struct device_attribute *attr, char *buf) \
1431{ \ 1432{ \
1432 struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\ 1433 struct iscsi_cls_session *session = \
1434 iscsi_dev_to_session(dev->parent); \
1433 return sprintf(buf, format"\n", session->field); \ 1435 return sprintf(buf, format"\n", session->field); \
1434} 1436}
1435 1437
@@ -1444,9 +1446,10 @@ iscsi_priv_session_attr(recovery_tmo, "%d");
1444 */ 1446 */
1445#define iscsi_host_attr_show(param) \ 1447#define iscsi_host_attr_show(param) \
1446static ssize_t \ 1448static ssize_t \
1447show_host_param_##param(struct class_device *cdev, char *buf) \ 1449show_host_param_##param(struct device *dev, \
1450 struct device_attribute *attr, char *buf) \
1448{ \ 1451{ \
1449 struct Scsi_Host *shost = transport_class_to_shost(cdev); \ 1452 struct Scsi_Host *shost = transport_class_to_shost(dev); \
1450 struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ 1453 struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \
1451 return priv->iscsi_transport->get_host_param(shost, param, buf); \ 1454 return priv->iscsi_transport->get_host_param(shost, param, buf); \
1452} 1455}
@@ -1463,7 +1466,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME);
1463 1466
1464#define SETUP_PRIV_SESSION_RD_ATTR(field) \ 1467#define SETUP_PRIV_SESSION_RD_ATTR(field) \
1465do { \ 1468do { \
1466 priv->session_attrs[count] = &class_device_attr_priv_sess_##field; \ 1469 priv->session_attrs[count] = &dev_attr_priv_sess_##field; \
1467 count++; \ 1470 count++; \
1468} while (0) 1471} while (0)
1469 1472
@@ -1471,7 +1474,7 @@ do { \
1471#define SETUP_SESSION_RD_ATTR(field, param_flag) \ 1474#define SETUP_SESSION_RD_ATTR(field, param_flag) \
1472do { \ 1475do { \
1473 if (tt->param_mask & param_flag) { \ 1476 if (tt->param_mask & param_flag) { \
1474 priv->session_attrs[count] = &class_device_attr_sess_##field; \ 1477 priv->session_attrs[count] = &dev_attr_sess_##field; \
1475 count++; \ 1478 count++; \
1476 } \ 1479 } \
1477} while (0) 1480} while (0)
@@ -1479,7 +1482,7 @@ do { \
1479#define SETUP_CONN_RD_ATTR(field, param_flag) \ 1482#define SETUP_CONN_RD_ATTR(field, param_flag) \
1480do { \ 1483do { \
1481 if (tt->param_mask & param_flag) { \ 1484 if (tt->param_mask & param_flag) { \
1482 priv->conn_attrs[count] = &class_device_attr_conn_##field; \ 1485 priv->conn_attrs[count] = &dev_attr_conn_##field; \
1483 count++; \ 1486 count++; \
1484 } \ 1487 } \
1485} while (0) 1488} while (0)
@@ -1487,7 +1490,7 @@ do { \
1487#define SETUP_HOST_RD_ATTR(field, param_flag) \ 1490#define SETUP_HOST_RD_ATTR(field, param_flag) \
1488do { \ 1491do { \
1489 if (tt->host_param_mask & param_flag) { \ 1492 if (tt->host_param_mask & param_flag) { \
1490 priv->host_attrs[count] = &class_device_attr_host_##field; \ 1493 priv->host_attrs[count] = &dev_attr_host_##field; \
1491 count++; \ 1494 count++; \
1492 } \ 1495 } \
1493} while (0) 1496} while (0)
@@ -1578,15 +1581,15 @@ iscsi_register_transport(struct iscsi_transport *tt)
1578 priv->iscsi_transport = tt; 1581 priv->iscsi_transport = tt;
1579 priv->t.user_scan = iscsi_user_scan; 1582 priv->t.user_scan = iscsi_user_scan;
1580 1583
1581 priv->cdev.class = &iscsi_transport_class; 1584 priv->dev.class = &iscsi_transport_class;
1582 snprintf(priv->cdev.class_id, BUS_ID_SIZE, "%s", tt->name); 1585 snprintf(priv->dev.bus_id, BUS_ID_SIZE, "%s", tt->name);
1583 err = class_device_register(&priv->cdev); 1586 err = device_register(&priv->dev);
1584 if (err) 1587 if (err)
1585 goto free_priv; 1588 goto free_priv;
1586 1589
1587 err = sysfs_create_group(&priv->cdev.kobj, &iscsi_transport_group); 1590 err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group);
1588 if (err) 1591 if (err)
1589 goto unregister_cdev; 1592 goto unregister_dev;
1590 1593
1591 /* host parameters */ 1594 /* host parameters */
1592 priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; 1595 priv->t.host_attrs.ac.attrs = &priv->host_attrs[0];
@@ -1663,8 +1666,8 @@ iscsi_register_transport(struct iscsi_transport *tt)
1663 printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); 1666 printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name);
1664 return &priv->t; 1667 return &priv->t;
1665 1668
1666unregister_cdev: 1669unregister_dev:
1667 class_device_unregister(&priv->cdev); 1670 device_unregister(&priv->dev);
1668free_priv: 1671free_priv:
1669 kfree(priv); 1672 kfree(priv);
1670 return NULL; 1673 return NULL;
@@ -1691,8 +1694,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
1691 transport_container_unregister(&priv->session_cont); 1694 transport_container_unregister(&priv->session_cont);
1692 transport_container_unregister(&priv->t.host_attrs); 1695 transport_container_unregister(&priv->t.host_attrs);
1693 1696
1694 sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); 1697 sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group);
1695 class_device_unregister(&priv->cdev); 1698 device_unregister(&priv->dev);
1696 mutex_unlock(&rx_queue_mutex); 1699 mutex_unlock(&rx_queue_mutex);
1697 1700
1698 return 0; 1701 return 0;
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 43a964d635b4..27ec625ab771 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -53,8 +53,8 @@ struct sas_host_attrs {
53/* 53/*
54 * Hack to allow attributes of the same name in different objects. 54 * Hack to allow attributes of the same name in different objects.
55 */ 55 */
56#define SAS_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ 56#define SAS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
57 struct class_device_attribute class_device_attr_##_prefix##_##_name = \ 57 struct device_attribute dev_attr_##_prefix##_##_name = \
58 __ATTR(_name,_mode,_show,_store) 58 __ATTR(_name,_mode,_show,_store)
59 59
60 60
@@ -261,7 +261,7 @@ static void sas_bsg_remove(struct Scsi_Host *shost, struct sas_rphy *rphy)
261 */ 261 */
262 262
263static int sas_host_setup(struct transport_container *tc, struct device *dev, 263static int sas_host_setup(struct transport_container *tc, struct device *dev,
264 struct class_device *cdev) 264 struct device *cdev)
265{ 265{
266 struct Scsi_Host *shost = dev_to_shost(dev); 266 struct Scsi_Host *shost = dev_to_shost(dev);
267 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 267 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
@@ -280,7 +280,7 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev,
280} 280}
281 281
282static int sas_host_remove(struct transport_container *tc, struct device *dev, 282static int sas_host_remove(struct transport_container *tc, struct device *dev,
283 struct class_device *cdev) 283 struct device *cdev)
284{ 284{
285 struct Scsi_Host *shost = dev_to_shost(dev); 285 struct Scsi_Host *shost = dev_to_shost(dev);
286 286
@@ -356,22 +356,24 @@ EXPORT_SYMBOL(sas_remove_host);
356 356
357#define sas_phy_show_simple(field, name, format_string, cast) \ 357#define sas_phy_show_simple(field, name, format_string, cast) \
358static ssize_t \ 358static ssize_t \
359show_sas_phy_##name(struct class_device *cdev, char *buf) \ 359show_sas_phy_##name(struct device *dev, \
360 struct device_attribute *attr, char *buf) \
360{ \ 361{ \
361 struct sas_phy *phy = transport_class_to_phy(cdev); \ 362 struct sas_phy *phy = transport_class_to_phy(dev); \
362 \ 363 \
363 return snprintf(buf, 20, format_string, cast phy->field); \ 364 return snprintf(buf, 20, format_string, cast phy->field); \
364} 365}
365 366
366#define sas_phy_simple_attr(field, name, format_string, type) \ 367#define sas_phy_simple_attr(field, name, format_string, type) \
367 sas_phy_show_simple(field, name, format_string, (type)) \ 368 sas_phy_show_simple(field, name, format_string, (type)) \
368static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) 369static DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
369 370
370#define sas_phy_show_protocol(field, name) \ 371#define sas_phy_show_protocol(field, name) \
371static ssize_t \ 372static ssize_t \
372show_sas_phy_##name(struct class_device *cdev, char *buf) \ 373show_sas_phy_##name(struct device *dev, \
374 struct device_attribute *attr, char *buf) \
373{ \ 375{ \
374 struct sas_phy *phy = transport_class_to_phy(cdev); \ 376 struct sas_phy *phy = transport_class_to_phy(dev); \
375 \ 377 \
376 if (!phy->field) \ 378 if (!phy->field) \
377 return snprintf(buf, 20, "none\n"); \ 379 return snprintf(buf, 20, "none\n"); \
@@ -380,13 +382,14 @@ show_sas_phy_##name(struct class_device *cdev, char *buf) \
380 382
381#define sas_phy_protocol_attr(field, name) \ 383#define sas_phy_protocol_attr(field, name) \
382 sas_phy_show_protocol(field, name) \ 384 sas_phy_show_protocol(field, name) \
383static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL) 385static DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
384 386
385#define sas_phy_show_linkspeed(field) \ 387#define sas_phy_show_linkspeed(field) \
386static ssize_t \ 388static ssize_t \
387show_sas_phy_##field(struct class_device *cdev, char *buf) \ 389show_sas_phy_##field(struct device *dev, \
390 struct device_attribute *attr, char *buf) \
388{ \ 391{ \
389 struct sas_phy *phy = transport_class_to_phy(cdev); \ 392 struct sas_phy *phy = transport_class_to_phy(dev); \
390 \ 393 \
391 return get_sas_linkspeed_names(phy->field, buf); \ 394 return get_sas_linkspeed_names(phy->field, buf); \
392} 395}
@@ -394,10 +397,11 @@ show_sas_phy_##field(struct class_device *cdev, char *buf) \
394/* Fudge to tell if we're minimum or maximum */ 397/* Fudge to tell if we're minimum or maximum */
395#define sas_phy_store_linkspeed(field) \ 398#define sas_phy_store_linkspeed(field) \
396static ssize_t \ 399static ssize_t \
397store_sas_phy_##field(struct class_device *cdev, const char *buf, \ 400store_sas_phy_##field(struct device *dev, \
398 size_t count) \ 401 struct device_attribute *attr, \
402 const char *buf, size_t count) \
399{ \ 403{ \
400 struct sas_phy *phy = transport_class_to_phy(cdev); \ 404 struct sas_phy *phy = transport_class_to_phy(dev); \
401 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ 405 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \
402 struct sas_internal *i = to_sas_internal(shost->transportt); \ 406 struct sas_internal *i = to_sas_internal(shost->transportt); \
403 u32 value; \ 407 u32 value; \
@@ -416,19 +420,20 @@ store_sas_phy_##field(struct class_device *cdev, const char *buf, \
416#define sas_phy_linkspeed_rw_attr(field) \ 420#define sas_phy_linkspeed_rw_attr(field) \
417 sas_phy_show_linkspeed(field) \ 421 sas_phy_show_linkspeed(field) \
418 sas_phy_store_linkspeed(field) \ 422 sas_phy_store_linkspeed(field) \
419static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, \ 423static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, \
420 store_sas_phy_##field) 424 store_sas_phy_##field)
421 425
422#define sas_phy_linkspeed_attr(field) \ 426#define sas_phy_linkspeed_attr(field) \
423 sas_phy_show_linkspeed(field) \ 427 sas_phy_show_linkspeed(field) \
424static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) 428static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
425 429
426 430
427#define sas_phy_show_linkerror(field) \ 431#define sas_phy_show_linkerror(field) \
428static ssize_t \ 432static ssize_t \
429show_sas_phy_##field(struct class_device *cdev, char *buf) \ 433show_sas_phy_##field(struct device *dev, \
434 struct device_attribute *attr, char *buf) \
430{ \ 435{ \
431 struct sas_phy *phy = transport_class_to_phy(cdev); \ 436 struct sas_phy *phy = transport_class_to_phy(dev); \
432 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \ 437 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \
433 struct sas_internal *i = to_sas_internal(shost->transportt); \ 438 struct sas_internal *i = to_sas_internal(shost->transportt); \
434 int error; \ 439 int error; \
@@ -441,24 +446,25 @@ show_sas_phy_##field(struct class_device *cdev, char *buf) \
441 446
442#define sas_phy_linkerror_attr(field) \ 447#define sas_phy_linkerror_attr(field) \
443 sas_phy_show_linkerror(field) \ 448 sas_phy_show_linkerror(field) \
444static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL) 449static DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
445 450
446 451
447static ssize_t 452static ssize_t
448show_sas_device_type(struct class_device *cdev, char *buf) 453show_sas_device_type(struct device *dev,
454 struct device_attribute *attr, char *buf)
449{ 455{
450 struct sas_phy *phy = transport_class_to_phy(cdev); 456 struct sas_phy *phy = transport_class_to_phy(dev);
451 457
452 if (!phy->identify.device_type) 458 if (!phy->identify.device_type)
453 return snprintf(buf, 20, "none\n"); 459 return snprintf(buf, 20, "none\n");
454 return get_sas_device_type_names(phy->identify.device_type, buf); 460 return get_sas_device_type_names(phy->identify.device_type, buf);
455} 461}
456static CLASS_DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL); 462static DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL);
457 463
458static ssize_t do_sas_phy_enable(struct class_device *cdev, 464static ssize_t do_sas_phy_enable(struct device *dev,
459 size_t count, int enable) 465 size_t count, int enable)
460{ 466{
461 struct sas_phy *phy = transport_class_to_phy(cdev); 467 struct sas_phy *phy = transport_class_to_phy(dev);
462 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 468 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
463 struct sas_internal *i = to_sas_internal(shost->transportt); 469 struct sas_internal *i = to_sas_internal(shost->transportt);
464 int error; 470 int error;
@@ -470,18 +476,19 @@ static ssize_t do_sas_phy_enable(struct class_device *cdev,
470 return count; 476 return count;
471}; 477};
472 478
473static ssize_t store_sas_phy_enable(struct class_device *cdev, 479static ssize_t
474 const char *buf, size_t count) 480store_sas_phy_enable(struct device *dev, struct device_attribute *attr,
481 const char *buf, size_t count)
475{ 482{
476 if (count < 1) 483 if (count < 1)
477 return -EINVAL; 484 return -EINVAL;
478 485
479 switch (buf[0]) { 486 switch (buf[0]) {
480 case '0': 487 case '0':
481 do_sas_phy_enable(cdev, count, 0); 488 do_sas_phy_enable(dev, count, 0);
482 break; 489 break;
483 case '1': 490 case '1':
484 do_sas_phy_enable(cdev, count, 1); 491 do_sas_phy_enable(dev, count, 1);
485 break; 492 break;
486 default: 493 default:
487 return -EINVAL; 494 return -EINVAL;
@@ -490,20 +497,22 @@ static ssize_t store_sas_phy_enable(struct class_device *cdev,
490 return count; 497 return count;
491} 498}
492 499
493static ssize_t show_sas_phy_enable(struct class_device *cdev, char *buf) 500static ssize_t
501show_sas_phy_enable(struct device *dev, struct device_attribute *attr,
502 char *buf)
494{ 503{
495 struct sas_phy *phy = transport_class_to_phy(cdev); 504 struct sas_phy *phy = transport_class_to_phy(dev);
496 505
497 return snprintf(buf, 20, "%d", phy->enabled); 506 return snprintf(buf, 20, "%d", phy->enabled);
498} 507}
499 508
500static CLASS_DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable, 509static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable,
501 store_sas_phy_enable); 510 store_sas_phy_enable);
502 511
503static ssize_t do_sas_phy_reset(struct class_device *cdev, 512static ssize_t
504 size_t count, int hard_reset) 513do_sas_phy_reset(struct device *dev, size_t count, int hard_reset)
505{ 514{
506 struct sas_phy *phy = transport_class_to_phy(cdev); 515 struct sas_phy *phy = transport_class_to_phy(dev);
507 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 516 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
508 struct sas_internal *i = to_sas_internal(shost->transportt); 517 struct sas_internal *i = to_sas_internal(shost->transportt);
509 int error; 518 int error;
@@ -514,19 +523,21 @@ static ssize_t do_sas_phy_reset(struct class_device *cdev,
514 return count; 523 return count;
515}; 524};
516 525
517static ssize_t store_sas_link_reset(struct class_device *cdev, 526static ssize_t
518 const char *buf, size_t count) 527store_sas_link_reset(struct device *dev, struct device_attribute *attr,
528 const char *buf, size_t count)
519{ 529{
520 return do_sas_phy_reset(cdev, count, 0); 530 return do_sas_phy_reset(dev, count, 0);
521} 531}
522static CLASS_DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset); 532static DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset);
523 533
524static ssize_t store_sas_hard_reset(struct class_device *cdev, 534static ssize_t
525 const char *buf, size_t count) 535store_sas_hard_reset(struct device *dev, struct device_attribute *attr,
536 const char *buf, size_t count)
526{ 537{
527 return do_sas_phy_reset(cdev, count, 1); 538 return do_sas_phy_reset(dev, count, 1);
528} 539}
529static CLASS_DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset); 540static DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset);
530 541
531sas_phy_protocol_attr(identify.initiator_port_protocols, 542sas_phy_protocol_attr(identify.initiator_port_protocols,
532 initiator_port_protocols); 543 initiator_port_protocols);
@@ -695,16 +706,17 @@ EXPORT_SYMBOL(scsi_is_sas_phy);
695 */ 706 */
696#define sas_port_show_simple(field, name, format_string, cast) \ 707#define sas_port_show_simple(field, name, format_string, cast) \
697static ssize_t \ 708static ssize_t \
698show_sas_port_##name(struct class_device *cdev, char *buf) \ 709show_sas_port_##name(struct device *dev, \
710 struct device_attribute *attr, char *buf) \
699{ \ 711{ \
700 struct sas_port *port = transport_class_to_sas_port(cdev); \ 712 struct sas_port *port = transport_class_to_sas_port(dev); \
701 \ 713 \
702 return snprintf(buf, 20, format_string, cast port->field); \ 714 return snprintf(buf, 20, format_string, cast port->field); \
703} 715}
704 716
705#define sas_port_simple_attr(field, name, format_string, type) \ 717#define sas_port_simple_attr(field, name, format_string, type) \
706 sas_port_show_simple(field, name, format_string, (type)) \ 718 sas_port_show_simple(field, name, format_string, (type)) \
707static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL) 719static DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL)
708 720
709sas_port_simple_attr(num_phys, num_phys, "%d\n", int); 721sas_port_simple_attr(num_phys, num_phys, "%d\n", int);
710 722
@@ -1017,23 +1029,25 @@ EXPORT_SYMBOL(sas_port_mark_backlink);
1017 1029
1018#define sas_rphy_show_simple(field, name, format_string, cast) \ 1030#define sas_rphy_show_simple(field, name, format_string, cast) \
1019static ssize_t \ 1031static ssize_t \
1020show_sas_rphy_##name(struct class_device *cdev, char *buf) \ 1032show_sas_rphy_##name(struct device *dev, \
1033 struct device_attribute *attr, char *buf) \
1021{ \ 1034{ \
1022 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1035 struct sas_rphy *rphy = transport_class_to_rphy(dev); \
1023 \ 1036 \
1024 return snprintf(buf, 20, format_string, cast rphy->field); \ 1037 return snprintf(buf, 20, format_string, cast rphy->field); \
1025} 1038}
1026 1039
1027#define sas_rphy_simple_attr(field, name, format_string, type) \ 1040#define sas_rphy_simple_attr(field, name, format_string, type) \
1028 sas_rphy_show_simple(field, name, format_string, (type)) \ 1041 sas_rphy_show_simple(field, name, format_string, (type)) \
1029static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \ 1042static SAS_DEVICE_ATTR(rphy, name, S_IRUGO, \
1030 show_sas_rphy_##name, NULL) 1043 show_sas_rphy_##name, NULL)
1031 1044
1032#define sas_rphy_show_protocol(field, name) \ 1045#define sas_rphy_show_protocol(field, name) \
1033static ssize_t \ 1046static ssize_t \
1034show_sas_rphy_##name(struct class_device *cdev, char *buf) \ 1047show_sas_rphy_##name(struct device *dev, \
1048 struct device_attribute *attr, char *buf) \
1035{ \ 1049{ \
1036 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1050 struct sas_rphy *rphy = transport_class_to_rphy(dev); \
1037 \ 1051 \
1038 if (!rphy->field) \ 1052 if (!rphy->field) \
1039 return snprintf(buf, 20, "none\n"); \ 1053 return snprintf(buf, 20, "none\n"); \
@@ -1042,13 +1056,14 @@ show_sas_rphy_##name(struct class_device *cdev, char *buf) \
1042 1056
1043#define sas_rphy_protocol_attr(field, name) \ 1057#define sas_rphy_protocol_attr(field, name) \
1044 sas_rphy_show_protocol(field, name) \ 1058 sas_rphy_show_protocol(field, name) \
1045static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \ 1059static SAS_DEVICE_ATTR(rphy, name, S_IRUGO, \
1046 show_sas_rphy_##name, NULL) 1060 show_sas_rphy_##name, NULL)
1047 1061
1048static ssize_t 1062static ssize_t
1049show_sas_rphy_device_type(struct class_device *cdev, char *buf) 1063show_sas_rphy_device_type(struct device *dev,
1064 struct device_attribute *attr, char *buf)
1050{ 1065{
1051 struct sas_rphy *rphy = transport_class_to_rphy(cdev); 1066 struct sas_rphy *rphy = transport_class_to_rphy(dev);
1052 1067
1053 if (!rphy->identify.device_type) 1068 if (!rphy->identify.device_type)
1054 return snprintf(buf, 20, "none\n"); 1069 return snprintf(buf, 20, "none\n");
@@ -1056,13 +1071,14 @@ show_sas_rphy_device_type(struct class_device *cdev, char *buf)
1056 rphy->identify.device_type, buf); 1071 rphy->identify.device_type, buf);
1057} 1072}
1058 1073
1059static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO, 1074static SAS_DEVICE_ATTR(rphy, device_type, S_IRUGO,
1060 show_sas_rphy_device_type, NULL); 1075 show_sas_rphy_device_type, NULL);
1061 1076
1062static ssize_t 1077static ssize_t
1063show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf) 1078show_sas_rphy_enclosure_identifier(struct device *dev,
1079 struct device_attribute *attr, char *buf)
1064{ 1080{
1065 struct sas_rphy *rphy = transport_class_to_rphy(cdev); 1081 struct sas_rphy *rphy = transport_class_to_rphy(dev);
1066 struct sas_phy *phy = dev_to_phy(rphy->dev.parent); 1082 struct sas_phy *phy = dev_to_phy(rphy->dev.parent);
1067 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 1083 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
1068 struct sas_internal *i = to_sas_internal(shost->transportt); 1084 struct sas_internal *i = to_sas_internal(shost->transportt);
@@ -1082,13 +1098,14 @@ show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf)
1082 return sprintf(buf, "0x%llx\n", (unsigned long long)identifier); 1098 return sprintf(buf, "0x%llx\n", (unsigned long long)identifier);
1083} 1099}
1084 1100
1085static SAS_CLASS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO, 1101static SAS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO,
1086 show_sas_rphy_enclosure_identifier, NULL); 1102 show_sas_rphy_enclosure_identifier, NULL);
1087 1103
1088static ssize_t 1104static ssize_t
1089show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf) 1105show_sas_rphy_bay_identifier(struct device *dev,
1106 struct device_attribute *attr, char *buf)
1090{ 1107{
1091 struct sas_rphy *rphy = transport_class_to_rphy(cdev); 1108 struct sas_rphy *rphy = transport_class_to_rphy(dev);
1092 struct sas_phy *phy = dev_to_phy(rphy->dev.parent); 1109 struct sas_phy *phy = dev_to_phy(rphy->dev.parent);
1093 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); 1110 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
1094 struct sas_internal *i = to_sas_internal(shost->transportt); 1111 struct sas_internal *i = to_sas_internal(shost->transportt);
@@ -1103,7 +1120,7 @@ show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf)
1103 return sprintf(buf, "%d\n", val); 1120 return sprintf(buf, "%d\n", val);
1104} 1121}
1105 1122
1106static SAS_CLASS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO, 1123static SAS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO,
1107 show_sas_rphy_bay_identifier, NULL); 1124 show_sas_rphy_bay_identifier, NULL);
1108 1125
1109sas_rphy_protocol_attr(identify.initiator_port_protocols, 1126sas_rphy_protocol_attr(identify.initiator_port_protocols,
@@ -1161,9 +1178,10 @@ static DECLARE_TRANSPORT_CLASS(sas_end_dev_class,
1161 1178
1162#define sas_end_dev_show_simple(field, name, format_string, cast) \ 1179#define sas_end_dev_show_simple(field, name, format_string, cast) \
1163static ssize_t \ 1180static ssize_t \
1164show_sas_end_dev_##name(struct class_device *cdev, char *buf) \ 1181show_sas_end_dev_##name(struct device *dev, \
1182 struct device_attribute *attr, char *buf) \
1165{ \ 1183{ \
1166 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1184 struct sas_rphy *rphy = transport_class_to_rphy(dev); \
1167 struct sas_end_device *rdev = rphy_to_end_device(rphy); \ 1185 struct sas_end_device *rdev = rphy_to_end_device(rphy); \
1168 \ 1186 \
1169 return snprintf(buf, 20, format_string, cast rdev->field); \ 1187 return snprintf(buf, 20, format_string, cast rdev->field); \
@@ -1171,7 +1189,7 @@ show_sas_end_dev_##name(struct class_device *cdev, char *buf) \
1171 1189
1172#define sas_end_dev_simple_attr(field, name, format_string, type) \ 1190#define sas_end_dev_simple_attr(field, name, format_string, type) \
1173 sas_end_dev_show_simple(field, name, format_string, (type)) \ 1191 sas_end_dev_show_simple(field, name, format_string, (type)) \
1174static SAS_CLASS_DEVICE_ATTR(end_dev, name, S_IRUGO, \ 1192static SAS_DEVICE_ATTR(end_dev, name, S_IRUGO, \
1175 show_sas_end_dev_##name, NULL) 1193 show_sas_end_dev_##name, NULL)
1176 1194
1177sas_end_dev_simple_attr(ready_led_meaning, ready_led_meaning, "%d\n", int); 1195sas_end_dev_simple_attr(ready_led_meaning, ready_led_meaning, "%d\n", int);
@@ -1185,9 +1203,10 @@ static DECLARE_TRANSPORT_CLASS(sas_expander_class,
1185 1203
1186#define sas_expander_show_simple(field, name, format_string, cast) \ 1204#define sas_expander_show_simple(field, name, format_string, cast) \
1187static ssize_t \ 1205static ssize_t \
1188show_sas_expander_##name(struct class_device *cdev, char *buf) \ 1206show_sas_expander_##name(struct device *dev, \
1207 struct device_attribute *attr, char *buf) \
1189{ \ 1208{ \
1190 struct sas_rphy *rphy = transport_class_to_rphy(cdev); \ 1209 struct sas_rphy *rphy = transport_class_to_rphy(dev); \
1191 struct sas_expander_device *edev = rphy_to_expander_device(rphy); \ 1210 struct sas_expander_device *edev = rphy_to_expander_device(rphy); \
1192 \ 1211 \
1193 return snprintf(buf, 20, format_string, cast edev->field); \ 1212 return snprintf(buf, 20, format_string, cast edev->field); \
@@ -1195,7 +1214,7 @@ show_sas_expander_##name(struct class_device *cdev, char *buf) \
1195 1214
1196#define sas_expander_simple_attr(field, name, format_string, type) \ 1215#define sas_expander_simple_attr(field, name, format_string, type) \
1197 sas_expander_show_simple(field, name, format_string, (type)) \ 1216 sas_expander_show_simple(field, name, format_string, (type)) \
1198static SAS_CLASS_DEVICE_ATTR(expander, name, S_IRUGO, \ 1217static SAS_DEVICE_ATTR(expander, name, S_IRUGO, \
1199 show_sas_expander_##name, NULL) 1218 show_sas_expander_##name, NULL)
1200 1219
1201sas_expander_simple_attr(vendor_id, vendor_id, "%s\n", char *); 1220sas_expander_simple_attr(vendor_id, vendor_id, "%s\n", char *);
@@ -1554,14 +1573,14 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel,
1554 */ 1573 */
1555 1574
1556#define SETUP_TEMPLATE(attrb, field, perm, test) \ 1575#define SETUP_TEMPLATE(attrb, field, perm, test) \
1557 i->private_##attrb[count] = class_device_attr_##field; \ 1576 i->private_##attrb[count] = dev_attr_##field; \
1558 i->private_##attrb[count].attr.mode = perm; \ 1577 i->private_##attrb[count].attr.mode = perm; \
1559 i->attrb[count] = &i->private_##attrb[count]; \ 1578 i->attrb[count] = &i->private_##attrb[count]; \
1560 if (test) \ 1579 if (test) \
1561 count++ 1580 count++
1562 1581
1563#define SETUP_TEMPLATE_RW(attrb, field, perm, test, ro_test, ro_perm) \ 1582#define SETUP_TEMPLATE_RW(attrb, field, perm, test, ro_test, ro_perm) \
1564 i->private_##attrb[count] = class_device_attr_##field; \ 1583 i->private_##attrb[count] = dev_attr_##field; \
1565 i->private_##attrb[count].attr.mode = perm; \ 1584 i->private_##attrb[count].attr.mode = perm; \
1566 if (ro_test) { \ 1585 if (ro_test) { \
1567 i->private_##attrb[count].attr.mode = ro_perm; \ 1586 i->private_##attrb[count].attr.mode = ro_perm; \
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 1fb60313a516..bc12b5d5d676 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -158,7 +158,7 @@ static inline enum spi_signal_type spi_signal_to_value(const char *name)
158} 158}
159 159
160static int spi_host_setup(struct transport_container *tc, struct device *dev, 160static int spi_host_setup(struct transport_container *tc, struct device *dev,
161 struct class_device *cdev) 161 struct device *cdev)
162{ 162{
163 struct Scsi_Host *shost = dev_to_shost(dev); 163 struct Scsi_Host *shost = dev_to_shost(dev);
164 164
@@ -169,7 +169,7 @@ static int spi_host_setup(struct transport_container *tc, struct device *dev,
169 169
170static int spi_host_configure(struct transport_container *tc, 170static int spi_host_configure(struct transport_container *tc,
171 struct device *dev, 171 struct device *dev,
172 struct class_device *cdev); 172 struct device *cdev);
173 173
174static DECLARE_TRANSPORT_CLASS(spi_host_class, 174static DECLARE_TRANSPORT_CLASS(spi_host_class,
175 "spi_host", 175 "spi_host",
@@ -195,11 +195,11 @@ static int spi_host_match(struct attribute_container *cont,
195 195
196static int spi_target_configure(struct transport_container *tc, 196static int spi_target_configure(struct transport_container *tc,
197 struct device *dev, 197 struct device *dev,
198 struct class_device *cdev); 198 struct device *cdev);
199 199
200static int spi_device_configure(struct transport_container *tc, 200static int spi_device_configure(struct transport_container *tc,
201 struct device *dev, 201 struct device *dev,
202 struct class_device *cdev) 202 struct device *cdev)
203{ 203{
204 struct scsi_device *sdev = to_scsi_device(dev); 204 struct scsi_device *sdev = to_scsi_device(dev);
205 struct scsi_target *starget = sdev->sdev_target; 205 struct scsi_target *starget = sdev->sdev_target;
@@ -219,7 +219,7 @@ static int spi_device_configure(struct transport_container *tc,
219 219
220static int spi_setup_transport_attrs(struct transport_container *tc, 220static int spi_setup_transport_attrs(struct transport_container *tc,
221 struct device *dev, 221 struct device *dev,
222 struct class_device *cdev) 222 struct device *cdev)
223{ 223{
224 struct scsi_target *starget = to_scsi_target(dev); 224 struct scsi_target *starget = to_scsi_target(dev);
225 225
@@ -248,9 +248,10 @@ static int spi_setup_transport_attrs(struct transport_container *tc,
248#define spi_transport_show_simple(field, format_string) \ 248#define spi_transport_show_simple(field, format_string) \
249 \ 249 \
250static ssize_t \ 250static ssize_t \
251show_spi_transport_##field(struct class_device *cdev, char *buf) \ 251show_spi_transport_##field(struct device *dev, \
252 struct device_attribute *attr, char *buf) \
252{ \ 253{ \
253 struct scsi_target *starget = transport_class_to_starget(cdev); \ 254 struct scsi_target *starget = transport_class_to_starget(dev); \
254 struct spi_transport_attrs *tp; \ 255 struct spi_transport_attrs *tp; \
255 \ 256 \
256 tp = (struct spi_transport_attrs *)&starget->starget_data; \ 257 tp = (struct spi_transport_attrs *)&starget->starget_data; \
@@ -260,11 +261,12 @@ show_spi_transport_##field(struct class_device *cdev, char *buf) \
260#define spi_transport_store_simple(field, format_string) \ 261#define spi_transport_store_simple(field, format_string) \
261 \ 262 \
262static ssize_t \ 263static ssize_t \
263store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 264store_spi_transport_##field(struct device *dev, \
264 size_t count) \ 265 struct device_attribute *attr, \
266 const char *buf, size_t count) \
265{ \ 267{ \
266 int val; \ 268 int val; \
267 struct scsi_target *starget = transport_class_to_starget(cdev); \ 269 struct scsi_target *starget = transport_class_to_starget(dev); \
268 struct spi_transport_attrs *tp; \ 270 struct spi_transport_attrs *tp; \
269 \ 271 \
270 tp = (struct spi_transport_attrs *)&starget->starget_data; \ 272 tp = (struct spi_transport_attrs *)&starget->starget_data; \
@@ -276,9 +278,10 @@ store_spi_transport_##field(struct class_device *cdev, const char *buf, \
276#define spi_transport_show_function(field, format_string) \ 278#define spi_transport_show_function(field, format_string) \
277 \ 279 \
278static ssize_t \ 280static ssize_t \
279show_spi_transport_##field(struct class_device *cdev, char *buf) \ 281show_spi_transport_##field(struct device *dev, \
282 struct device_attribute *attr, char *buf) \
280{ \ 283{ \
281 struct scsi_target *starget = transport_class_to_starget(cdev); \ 284 struct scsi_target *starget = transport_class_to_starget(dev); \
282 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 285 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
283 struct spi_transport_attrs *tp; \ 286 struct spi_transport_attrs *tp; \
284 struct spi_internal *i = to_spi_internal(shost->transportt); \ 287 struct spi_internal *i = to_spi_internal(shost->transportt); \
@@ -290,11 +293,12 @@ show_spi_transport_##field(struct class_device *cdev, char *buf) \
290 293
291#define spi_transport_store_function(field, format_string) \ 294#define spi_transport_store_function(field, format_string) \
292static ssize_t \ 295static ssize_t \
293store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 296store_spi_transport_##field(struct device *dev, \
294 size_t count) \ 297 struct device_attribute *attr, \
298 const char *buf, size_t count) \
295{ \ 299{ \
296 int val; \ 300 int val; \
297 struct scsi_target *starget = transport_class_to_starget(cdev); \ 301 struct scsi_target *starget = transport_class_to_starget(dev); \
298 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 302 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
299 struct spi_internal *i = to_spi_internal(shost->transportt); \ 303 struct spi_internal *i = to_spi_internal(shost->transportt); \
300 \ 304 \
@@ -307,11 +311,12 @@ store_spi_transport_##field(struct class_device *cdev, const char *buf, \
307 311
308#define spi_transport_store_max(field, format_string) \ 312#define spi_transport_store_max(field, format_string) \
309static ssize_t \ 313static ssize_t \
310store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 314store_spi_transport_##field(struct device *dev, \
311 size_t count) \ 315 struct device_attribute *attr, \
316 const char *buf, size_t count) \
312{ \ 317{ \
313 int val; \ 318 int val; \
314 struct scsi_target *starget = transport_class_to_starget(cdev); \ 319 struct scsi_target *starget = transport_class_to_starget(dev); \
315 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 320 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
316 struct spi_internal *i = to_spi_internal(shost->transportt); \ 321 struct spi_internal *i = to_spi_internal(shost->transportt); \
317 struct spi_transport_attrs *tp \ 322 struct spi_transport_attrs *tp \
@@ -329,24 +334,24 @@ store_spi_transport_##field(struct class_device *cdev, const char *buf, \
329#define spi_transport_rd_attr(field, format_string) \ 334#define spi_transport_rd_attr(field, format_string) \
330 spi_transport_show_function(field, format_string) \ 335 spi_transport_show_function(field, format_string) \
331 spi_transport_store_function(field, format_string) \ 336 spi_transport_store_function(field, format_string) \
332static CLASS_DEVICE_ATTR(field, S_IRUGO, \ 337static DEVICE_ATTR(field, S_IRUGO, \
333 show_spi_transport_##field, \ 338 show_spi_transport_##field, \
334 store_spi_transport_##field); 339 store_spi_transport_##field);
335 340
336#define spi_transport_simple_attr(field, format_string) \ 341#define spi_transport_simple_attr(field, format_string) \
337 spi_transport_show_simple(field, format_string) \ 342 spi_transport_show_simple(field, format_string) \
338 spi_transport_store_simple(field, format_string) \ 343 spi_transport_store_simple(field, format_string) \
339static CLASS_DEVICE_ATTR(field, S_IRUGO, \ 344static DEVICE_ATTR(field, S_IRUGO, \
340 show_spi_transport_##field, \ 345 show_spi_transport_##field, \
341 store_spi_transport_##field); 346 store_spi_transport_##field);
342 347
343#define spi_transport_max_attr(field, format_string) \ 348#define spi_transport_max_attr(field, format_string) \
344 spi_transport_show_function(field, format_string) \ 349 spi_transport_show_function(field, format_string) \
345 spi_transport_store_max(field, format_string) \ 350 spi_transport_store_max(field, format_string) \
346 spi_transport_simple_attr(max_##field, format_string) \ 351 spi_transport_simple_attr(max_##field, format_string) \
347static CLASS_DEVICE_ATTR(field, S_IRUGO, \ 352static DEVICE_ATTR(field, S_IRUGO, \
348 show_spi_transport_##field, \ 353 show_spi_transport_##field, \
349 store_spi_transport_##field); 354 store_spi_transport_##field);
350 355
351/* The Parallel SCSI Tranport Attributes: */ 356/* The Parallel SCSI Tranport Attributes: */
352spi_transport_max_attr(offset, "%d\n"); 357spi_transport_max_attr(offset, "%d\n");
@@ -370,14 +375,15 @@ static int child_iter(struct device *dev, void *data)
370} 375}
371 376
372static ssize_t 377static ssize_t
373store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count) 378store_spi_revalidate(struct device *dev, struct device_attribute *attr,
379 const char *buf, size_t count)
374{ 380{
375 struct scsi_target *starget = transport_class_to_starget(cdev); 381 struct scsi_target *starget = transport_class_to_starget(dev);
376 382
377 device_for_each_child(&starget->dev, NULL, child_iter); 383 device_for_each_child(&starget->dev, NULL, child_iter);
378 return count; 384 return count;
379} 385}
380static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); 386static DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
381 387
382/* Translate the period into ns according to the current spec 388/* Translate the period into ns according to the current spec
383 * for SDTR/PPR messages */ 389 * for SDTR/PPR messages */
@@ -412,7 +418,7 @@ show_spi_transport_period_helper(char *buf, int period)
412} 418}
413 419
414static ssize_t 420static ssize_t
415store_spi_transport_period_helper(struct class_device *cdev, const char *buf, 421store_spi_transport_period_helper(struct device *dev, const char *buf,
416 size_t count, int *periodp) 422 size_t count, int *periodp)
417{ 423{
418 int j, picosec, period = -1; 424 int j, picosec, period = -1;
@@ -449,9 +455,10 @@ store_spi_transport_period_helper(struct class_device *cdev, const char *buf,
449} 455}
450 456
451static ssize_t 457static ssize_t
452show_spi_transport_period(struct class_device *cdev, char *buf) 458show_spi_transport_period(struct device *dev,
459 struct device_attribute *attr, char *buf)
453{ 460{
454 struct scsi_target *starget = transport_class_to_starget(cdev); 461 struct scsi_target *starget = transport_class_to_starget(dev);
455 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 462 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
456 struct spi_internal *i = to_spi_internal(shost->transportt); 463 struct spi_internal *i = to_spi_internal(shost->transportt);
457 struct spi_transport_attrs *tp = 464 struct spi_transport_attrs *tp =
@@ -464,8 +471,8 @@ show_spi_transport_period(struct class_device *cdev, char *buf)
464} 471}
465 472
466static ssize_t 473static ssize_t
467store_spi_transport_period(struct class_device *cdev, const char *buf, 474store_spi_transport_period(struct device *cdev, struct device_attribute *attr,
468 size_t count) 475 const char *buf, size_t count)
469{ 476{
470 struct scsi_target *starget = transport_class_to_starget(cdev); 477 struct scsi_target *starget = transport_class_to_starget(cdev);
471 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 478 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -487,12 +494,13 @@ store_spi_transport_period(struct class_device *cdev, const char *buf,
487 return retval; 494 return retval;
488} 495}
489 496
490static CLASS_DEVICE_ATTR(period, S_IRUGO, 497static DEVICE_ATTR(period, S_IRUGO,
491 show_spi_transport_period, 498 show_spi_transport_period,
492 store_spi_transport_period); 499 store_spi_transport_period);
493 500
494static ssize_t 501static ssize_t
495show_spi_transport_min_period(struct class_device *cdev, char *buf) 502show_spi_transport_min_period(struct device *cdev,
503 struct device_attribute *attr, char *buf)
496{ 504{
497 struct scsi_target *starget = transport_class_to_starget(cdev); 505 struct scsi_target *starget = transport_class_to_starget(cdev);
498 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 506 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -507,8 +515,9 @@ show_spi_transport_min_period(struct class_device *cdev, char *buf)
507} 515}
508 516
509static ssize_t 517static ssize_t
510store_spi_transport_min_period(struct class_device *cdev, const char *buf, 518store_spi_transport_min_period(struct device *cdev,
511 size_t count) 519 struct device_attribute *attr,
520 const char *buf, size_t count)
512{ 521{
513 struct scsi_target *starget = transport_class_to_starget(cdev); 522 struct scsi_target *starget = transport_class_to_starget(cdev);
514 struct spi_transport_attrs *tp = 523 struct spi_transport_attrs *tp =
@@ -519,12 +528,14 @@ store_spi_transport_min_period(struct class_device *cdev, const char *buf,
519} 528}
520 529
521 530
522static CLASS_DEVICE_ATTR(min_period, S_IRUGO, 531static DEVICE_ATTR(min_period, S_IRUGO,
523 show_spi_transport_min_period, 532 show_spi_transport_min_period,
524 store_spi_transport_min_period); 533 store_spi_transport_min_period);
525 534
526 535
527static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) 536static ssize_t show_spi_host_signalling(struct device *cdev,
537 struct device_attribute *attr,
538 char *buf)
528{ 539{
529 struct Scsi_Host *shost = transport_class_to_shost(cdev); 540 struct Scsi_Host *shost = transport_class_to_shost(cdev);
530 struct spi_internal *i = to_spi_internal(shost->transportt); 541 struct spi_internal *i = to_spi_internal(shost->transportt);
@@ -534,10 +545,11 @@ static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf)
534 545
535 return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost))); 546 return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost)));
536} 547}
537static ssize_t store_spi_host_signalling(struct class_device *cdev, 548static ssize_t store_spi_host_signalling(struct device *dev,
549 struct device_attribute *attr,
538 const char *buf, size_t count) 550 const char *buf, size_t count)
539{ 551{
540 struct Scsi_Host *shost = transport_class_to_shost(cdev); 552 struct Scsi_Host *shost = transport_class_to_shost(dev);
541 struct spi_internal *i = to_spi_internal(shost->transportt); 553 struct spi_internal *i = to_spi_internal(shost->transportt);
542 enum spi_signal_type type = spi_signal_to_value(buf); 554 enum spi_signal_type type = spi_signal_to_value(buf);
543 555
@@ -549,9 +561,9 @@ static ssize_t store_spi_host_signalling(struct class_device *cdev,
549 561
550 return count; 562 return count;
551} 563}
552static CLASS_DEVICE_ATTR(signalling, S_IRUGO, 564static DEVICE_ATTR(signalling, S_IRUGO,
553 show_spi_host_signalling, 565 show_spi_host_signalling,
554 store_spi_host_signalling); 566 store_spi_host_signalling);
555 567
556#define DV_SET(x, y) \ 568#define DV_SET(x, y) \
557 if(i->f->set_##x) \ 569 if(i->f->set_##x) \
@@ -1334,7 +1346,7 @@ static DECLARE_ANON_TRANSPORT_CLASS(spi_device_class,
1334 spi_device_configure); 1346 spi_device_configure);
1335 1347
1336static struct attribute *host_attributes[] = { 1348static struct attribute *host_attributes[] = {
1337 &class_device_attr_signalling.attr, 1349 &dev_attr_signalling.attr,
1338 NULL 1350 NULL
1339}; 1351};
1340 1352
@@ -1344,12 +1356,12 @@ static struct attribute_group host_attribute_group = {
1344 1356
1345static int spi_host_configure(struct transport_container *tc, 1357static int spi_host_configure(struct transport_container *tc,
1346 struct device *dev, 1358 struct device *dev,
1347 struct class_device *cdev) 1359 struct device *cdev)
1348{ 1360{
1349 struct kobject *kobj = &cdev->kobj; 1361 struct kobject *kobj = &cdev->kobj;
1350 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1362 struct Scsi_Host *shost = transport_class_to_shost(cdev);
1351 struct spi_internal *si = to_spi_internal(shost->transportt); 1363 struct spi_internal *si = to_spi_internal(shost->transportt);
1352 struct attribute *attr = &class_device_attr_signalling.attr; 1364 struct attribute *attr = &dev_attr_signalling.attr;
1353 int rc = 0; 1365 int rc = 0;
1354 1366
1355 if (si->f->set_signalling) 1367 if (si->f->set_signalling)
@@ -1368,76 +1380,75 @@ static int spi_host_configure(struct transport_container *tc,
1368static int target_attribute_is_visible(struct kobject *kobj, 1380static int target_attribute_is_visible(struct kobject *kobj,
1369 struct attribute *attr, int i) 1381 struct attribute *attr, int i)
1370{ 1382{
1371 struct class_device *cdev = 1383 struct device *cdev = container_of(kobj, struct device, kobj);
1372 container_of(kobj, struct class_device, kobj);
1373 struct scsi_target *starget = transport_class_to_starget(cdev); 1384 struct scsi_target *starget = transport_class_to_starget(cdev);
1374 struct Scsi_Host *shost = transport_class_to_shost(cdev); 1385 struct Scsi_Host *shost = transport_class_to_shost(cdev);
1375 struct spi_internal *si = to_spi_internal(shost->transportt); 1386 struct spi_internal *si = to_spi_internal(shost->transportt);
1376 1387
1377 if (attr == &class_device_attr_period.attr && 1388 if (attr == &dev_attr_period.attr &&
1378 spi_support_sync(starget)) 1389 spi_support_sync(starget))
1379 return TARGET_ATTRIBUTE_HELPER(period); 1390 return TARGET_ATTRIBUTE_HELPER(period);
1380 else if (attr == &class_device_attr_min_period.attr && 1391 else if (attr == &dev_attr_min_period.attr &&
1381 spi_support_sync(starget)) 1392 spi_support_sync(starget))
1382 return TARGET_ATTRIBUTE_HELPER(period); 1393 return TARGET_ATTRIBUTE_HELPER(period);
1383 else if (attr == &class_device_attr_offset.attr && 1394 else if (attr == &dev_attr_offset.attr &&
1384 spi_support_sync(starget)) 1395 spi_support_sync(starget))
1385 return TARGET_ATTRIBUTE_HELPER(offset); 1396 return TARGET_ATTRIBUTE_HELPER(offset);
1386 else if (attr == &class_device_attr_max_offset.attr && 1397 else if (attr == &dev_attr_max_offset.attr &&
1387 spi_support_sync(starget)) 1398 spi_support_sync(starget))
1388 return TARGET_ATTRIBUTE_HELPER(offset); 1399 return TARGET_ATTRIBUTE_HELPER(offset);
1389 else if (attr == &class_device_attr_width.attr && 1400 else if (attr == &dev_attr_width.attr &&
1390 spi_support_wide(starget)) 1401 spi_support_wide(starget))
1391 return TARGET_ATTRIBUTE_HELPER(width); 1402 return TARGET_ATTRIBUTE_HELPER(width);
1392 else if (attr == &class_device_attr_max_width.attr && 1403 else if (attr == &dev_attr_max_width.attr &&
1393 spi_support_wide(starget)) 1404 spi_support_wide(starget))
1394 return TARGET_ATTRIBUTE_HELPER(width); 1405 return TARGET_ATTRIBUTE_HELPER(width);
1395 else if (attr == &class_device_attr_iu.attr && 1406 else if (attr == &dev_attr_iu.attr &&
1396 spi_support_ius(starget)) 1407 spi_support_ius(starget))
1397 return TARGET_ATTRIBUTE_HELPER(iu); 1408 return TARGET_ATTRIBUTE_HELPER(iu);
1398 else if (attr == &class_device_attr_dt.attr && 1409 else if (attr == &dev_attr_dt.attr &&
1399 spi_support_dt(starget)) 1410 spi_support_dt(starget))
1400 return TARGET_ATTRIBUTE_HELPER(dt); 1411 return TARGET_ATTRIBUTE_HELPER(dt);
1401 else if (attr == &class_device_attr_qas.attr && 1412 else if (attr == &dev_attr_qas.attr &&
1402 spi_support_qas(starget)) 1413 spi_support_qas(starget))
1403 return TARGET_ATTRIBUTE_HELPER(qas); 1414 return TARGET_ATTRIBUTE_HELPER(qas);
1404 else if (attr == &class_device_attr_wr_flow.attr && 1415 else if (attr == &dev_attr_wr_flow.attr &&
1405 spi_support_ius(starget)) 1416 spi_support_ius(starget))
1406 return TARGET_ATTRIBUTE_HELPER(wr_flow); 1417 return TARGET_ATTRIBUTE_HELPER(wr_flow);
1407 else if (attr == &class_device_attr_rd_strm.attr && 1418 else if (attr == &dev_attr_rd_strm.attr &&
1408 spi_support_ius(starget)) 1419 spi_support_ius(starget))
1409 return TARGET_ATTRIBUTE_HELPER(rd_strm); 1420 return TARGET_ATTRIBUTE_HELPER(rd_strm);
1410 else if (attr == &class_device_attr_rti.attr && 1421 else if (attr == &dev_attr_rti.attr &&
1411 spi_support_ius(starget)) 1422 spi_support_ius(starget))
1412 return TARGET_ATTRIBUTE_HELPER(rti); 1423 return TARGET_ATTRIBUTE_HELPER(rti);
1413 else if (attr == &class_device_attr_pcomp_en.attr && 1424 else if (attr == &dev_attr_pcomp_en.attr &&
1414 spi_support_ius(starget)) 1425 spi_support_ius(starget))
1415 return TARGET_ATTRIBUTE_HELPER(pcomp_en); 1426 return TARGET_ATTRIBUTE_HELPER(pcomp_en);
1416 else if (attr == &class_device_attr_hold_mcs.attr && 1427 else if (attr == &dev_attr_hold_mcs.attr &&
1417 spi_support_ius(starget)) 1428 spi_support_ius(starget))
1418 return TARGET_ATTRIBUTE_HELPER(hold_mcs); 1429 return TARGET_ATTRIBUTE_HELPER(hold_mcs);
1419 else if (attr == &class_device_attr_revalidate.attr) 1430 else if (attr == &dev_attr_revalidate.attr)
1420 return 1; 1431 return 1;
1421 1432
1422 return 0; 1433 return 0;
1423} 1434}
1424 1435
1425static struct attribute *target_attributes[] = { 1436static struct attribute *target_attributes[] = {
1426 &class_device_attr_period.attr, 1437 &dev_attr_period.attr,
1427 &class_device_attr_min_period.attr, 1438 &dev_attr_min_period.attr,
1428 &class_device_attr_offset.attr, 1439 &dev_attr_offset.attr,
1429 &class_device_attr_max_offset.attr, 1440 &dev_attr_max_offset.attr,
1430 &class_device_attr_width.attr, 1441 &dev_attr_width.attr,
1431 &class_device_attr_max_width.attr, 1442 &dev_attr_max_width.attr,
1432 &class_device_attr_iu.attr, 1443 &dev_attr_iu.attr,
1433 &class_device_attr_dt.attr, 1444 &dev_attr_dt.attr,
1434 &class_device_attr_qas.attr, 1445 &dev_attr_qas.attr,
1435 &class_device_attr_wr_flow.attr, 1446 &dev_attr_wr_flow.attr,
1436 &class_device_attr_rd_strm.attr, 1447 &dev_attr_rd_strm.attr,
1437 &class_device_attr_rti.attr, 1448 &dev_attr_rti.attr,
1438 &class_device_attr_pcomp_en.attr, 1449 &dev_attr_pcomp_en.attr,
1439 &class_device_attr_hold_mcs.attr, 1450 &dev_attr_hold_mcs.attr,
1440 &class_device_attr_revalidate.attr, 1451 &dev_attr_revalidate.attr,
1441 NULL 1452 NULL
1442}; 1453};
1443 1454
@@ -1448,7 +1459,7 @@ static struct attribute_group target_attribute_group = {
1448 1459
1449static int spi_target_configure(struct transport_container *tc, 1460static int spi_target_configure(struct transport_container *tc,
1450 struct device *dev, 1461 struct device *dev,
1451 struct class_device *cdev) 1462 struct device *cdev)
1452{ 1463{
1453 struct kobject *kobj = &cdev->kobj; 1464 struct kobject *kobj = &cdev->kobj;
1454 int i; 1465 int i;
@@ -1462,7 +1473,7 @@ static int spi_target_configure(struct transport_container *tc,
1462 * to ignore, sysfs also does a WARN_ON and dumps a trace, 1473 * to ignore, sysfs also does a WARN_ON and dumps a trace,
1463 * which is bad, so temporarily, skip attributes that are 1474 * which is bad, so temporarily, skip attributes that are
1464 * already visible (the revalidate one) */ 1475 * already visible (the revalidate one) */
1465 if (j && attr != &class_device_attr_revalidate.attr) 1476 if (j && attr != &dev_attr_revalidate.attr)
1466 rc = sysfs_add_file_to_group(kobj, attr, 1477 rc = sysfs_add_file_to_group(kobj, attr,
1467 target_attribute_group.name); 1478 target_attribute_group.name);
1468 /* and make the attribute writeable if we have a set 1479 /* and make the attribute writeable if we have a set
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 2445c98ae95e..8a7af951d98a 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -44,20 +44,20 @@ struct srp_internal {
44 struct scsi_transport_template t; 44 struct scsi_transport_template t;
45 struct srp_function_template *f; 45 struct srp_function_template *f;
46 46
47 struct class_device_attribute *host_attrs[SRP_HOST_ATTRS + 1]; 47 struct device_attribute *host_attrs[SRP_HOST_ATTRS + 1];
48 48
49 struct class_device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1]; 49 struct device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1];
50 struct class_device_attribute private_rport_attrs[SRP_RPORT_ATTRS]; 50 struct device_attribute private_rport_attrs[SRP_RPORT_ATTRS];
51 struct transport_container rport_attr_cont; 51 struct transport_container rport_attr_cont;
52}; 52};
53 53
54#define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t) 54#define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t)
55 55
56#define dev_to_rport(d) container_of(d, struct srp_rport, dev) 56#define dev_to_rport(d) container_of(d, struct srp_rport, dev)
57#define transport_class_to_srp_rport(cdev) dev_to_rport((cdev)->dev) 57#define transport_class_to_srp_rport(dev) dev_to_rport((dev)->parent)
58 58
59static int srp_host_setup(struct transport_container *tc, struct device *dev, 59static int srp_host_setup(struct transport_container *tc, struct device *dev,
60 struct class_device *cdev) 60 struct device *cdev)
61{ 61{
62 struct Scsi_Host *shost = dev_to_shost(dev); 62 struct Scsi_Host *shost = dev_to_shost(dev);
63 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost); 63 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
@@ -73,7 +73,7 @@ static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
73 NULL, NULL, NULL); 73 NULL, NULL, NULL);
74 74
75#define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \ 75#define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \
76 i->private_##attrb[count] = class_device_attr_##field; \ 76 i->private_##attrb[count] = dev_attr_##field; \
77 i->private_##attrb[count].attr.mode = perm; \ 77 i->private_##attrb[count].attr.mode = perm; \
78 if (ro_test) { \ 78 if (ro_test) { \
79 i->private_##attrb[count].attr.mode = ro_perm; \ 79 i->private_##attrb[count].attr.mode = ro_perm; \
@@ -100,13 +100,14 @@ static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
100 "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" 100 "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
101 101
102static ssize_t 102static ssize_t
103show_srp_rport_id(struct class_device *cdev, char *buf) 103show_srp_rport_id(struct device *dev, struct device_attribute *attr,
104 char *buf)
104{ 105{
105 struct srp_rport *rport = transport_class_to_srp_rport(cdev); 106 struct srp_rport *rport = transport_class_to_srp_rport(dev);
106 return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport)); 107 return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport));
107} 108}
108 109
109static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); 110static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
110 111
111static const struct { 112static const struct {
112 u32 value; 113 u32 value;
@@ -117,9 +118,10 @@ static const struct {
117}; 118};
118 119
119static ssize_t 120static ssize_t
120show_srp_rport_roles(struct class_device *cdev, char *buf) 121show_srp_rport_roles(struct device *dev, struct device_attribute *attr,
122 char *buf)
121{ 123{
122 struct srp_rport *rport = transport_class_to_srp_rport(cdev); 124 struct srp_rport *rport = transport_class_to_srp_rport(dev);
123 int i; 125 int i;
124 char *name = NULL; 126 char *name = NULL;
125 127
@@ -131,7 +133,7 @@ show_srp_rport_roles(struct class_device *cdev, char *buf)
131 return sprintf(buf, "%s\n", name ? : "unknown"); 133 return sprintf(buf, "%s\n", name ? : "unknown");
132} 134}
133 135
134static CLASS_DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL); 136static DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL);
135 137
136static void srp_rport_release(struct device *dev) 138static void srp_rport_release(struct device *dev)
137{ 139{
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 5fe7aaed904c..3cea17dd5dba 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -95,7 +95,7 @@ static int sd_resume(struct device *);
95static void sd_rescan(struct device *); 95static void sd_rescan(struct device *);
96static int sd_done(struct scsi_cmnd *); 96static int sd_done(struct scsi_cmnd *);
97static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 97static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
98static void scsi_disk_release(struct class_device *cdev); 98static void scsi_disk_release(struct device *cdev);
99static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); 99static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
100static void sd_print_result(struct scsi_disk *, int); 100static void sd_print_result(struct scsi_disk *, int);
101 101
@@ -112,11 +112,12 @@ static const char *sd_cache_types[] = {
112 "write back, no read (daft)" 112 "write back, no read (daft)"
113}; 113};
114 114
115static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf, 115static ssize_t
116 size_t count) 116sd_store_cache_type(struct device *dev, struct device_attribute *attr,
117 const char *buf, size_t count)
117{ 118{
118 int i, ct = -1, rcd, wce, sp; 119 int i, ct = -1, rcd, wce, sp;
119 struct scsi_disk *sdkp = to_scsi_disk(cdev); 120 struct scsi_disk *sdkp = to_scsi_disk(dev);
120 struct scsi_device *sdp = sdkp->device; 121 struct scsi_device *sdp = sdkp->device;
121 char buffer[64]; 122 char buffer[64];
122 char *buffer_data; 123 char *buffer_data;
@@ -163,10 +164,11 @@ static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf,
163 return count; 164 return count;
164} 165}
165 166
166static ssize_t sd_store_manage_start_stop(struct class_device *cdev, 167static ssize_t
167 const char *buf, size_t count) 168sd_store_manage_start_stop(struct device *dev, struct device_attribute *attr,
169 const char *buf, size_t count)
168{ 170{
169 struct scsi_disk *sdkp = to_scsi_disk(cdev); 171 struct scsi_disk *sdkp = to_scsi_disk(dev);
170 struct scsi_device *sdp = sdkp->device; 172 struct scsi_device *sdp = sdkp->device;
171 173
172 if (!capable(CAP_SYS_ADMIN)) 174 if (!capable(CAP_SYS_ADMIN))
@@ -177,10 +179,11 @@ static ssize_t sd_store_manage_start_stop(struct class_device *cdev,
177 return count; 179 return count;
178} 180}
179 181
180static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf, 182static ssize_t
181 size_t count) 183sd_store_allow_restart(struct device *dev, struct device_attribute *attr,
184 const char *buf, size_t count)
182{ 185{
183 struct scsi_disk *sdkp = to_scsi_disk(cdev); 186 struct scsi_disk *sdkp = to_scsi_disk(dev);
184 struct scsi_device *sdp = sdkp->device; 187 struct scsi_device *sdp = sdkp->device;
185 188
186 if (!capable(CAP_SYS_ADMIN)) 189 if (!capable(CAP_SYS_ADMIN))
@@ -194,37 +197,44 @@ static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf
194 return count; 197 return count;
195} 198}
196 199
197static ssize_t sd_show_cache_type(struct class_device *cdev, char *buf) 200static ssize_t
201sd_show_cache_type(struct device *dev, struct device_attribute *attr,
202 char *buf)
198{ 203{
199 struct scsi_disk *sdkp = to_scsi_disk(cdev); 204 struct scsi_disk *sdkp = to_scsi_disk(dev);
200 int ct = sdkp->RCD + 2*sdkp->WCE; 205 int ct = sdkp->RCD + 2*sdkp->WCE;
201 206
202 return snprintf(buf, 40, "%s\n", sd_cache_types[ct]); 207 return snprintf(buf, 40, "%s\n", sd_cache_types[ct]);
203} 208}
204 209
205static ssize_t sd_show_fua(struct class_device *cdev, char *buf) 210static ssize_t
211sd_show_fua(struct device *dev, struct device_attribute *attr, char *buf)
206{ 212{
207 struct scsi_disk *sdkp = to_scsi_disk(cdev); 213 struct scsi_disk *sdkp = to_scsi_disk(dev);
208 214
209 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); 215 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA);
210} 216}
211 217
212static ssize_t sd_show_manage_start_stop(struct class_device *cdev, char *buf) 218static ssize_t
219sd_show_manage_start_stop(struct device *dev, struct device_attribute *attr,
220 char *buf)
213{ 221{
214 struct scsi_disk *sdkp = to_scsi_disk(cdev); 222 struct scsi_disk *sdkp = to_scsi_disk(dev);
215 struct scsi_device *sdp = sdkp->device; 223 struct scsi_device *sdp = sdkp->device;
216 224
217 return snprintf(buf, 20, "%u\n", sdp->manage_start_stop); 225 return snprintf(buf, 20, "%u\n", sdp->manage_start_stop);
218} 226}
219 227
220static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf) 228static ssize_t
229sd_show_allow_restart(struct device *dev, struct device_attribute *attr,
230 char *buf)
221{ 231{
222 struct scsi_disk *sdkp = to_scsi_disk(cdev); 232 struct scsi_disk *sdkp = to_scsi_disk(dev);
223 233
224 return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); 234 return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart);
225} 235}
226 236
227static struct class_device_attribute sd_disk_attrs[] = { 237static struct device_attribute sd_disk_attrs[] = {
228 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, 238 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type,
229 sd_store_cache_type), 239 sd_store_cache_type),
230 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), 240 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL),
@@ -238,8 +248,8 @@ static struct class_device_attribute sd_disk_attrs[] = {
238static struct class sd_disk_class = { 248static struct class sd_disk_class = {
239 .name = "scsi_disk", 249 .name = "scsi_disk",
240 .owner = THIS_MODULE, 250 .owner = THIS_MODULE,
241 .release = scsi_disk_release, 251 .dev_release = scsi_disk_release,
242 .class_dev_attrs = sd_disk_attrs, 252 .dev_attrs = sd_disk_attrs,
243}; 253};
244 254
245static struct scsi_driver sd_template = { 255static struct scsi_driver sd_template = {
@@ -297,7 +307,7 @@ static struct scsi_disk *__scsi_disk_get(struct gendisk *disk)
297 if (disk->private_data) { 307 if (disk->private_data) {
298 sdkp = scsi_disk(disk); 308 sdkp = scsi_disk(disk);
299 if (scsi_device_get(sdkp->device) == 0) 309 if (scsi_device_get(sdkp->device) == 0)
300 class_device_get(&sdkp->cdev); 310 get_device(&sdkp->dev);
301 else 311 else
302 sdkp = NULL; 312 sdkp = NULL;
303 } 313 }
@@ -331,7 +341,7 @@ static void scsi_disk_put(struct scsi_disk *sdkp)
331 struct scsi_device *sdev = sdkp->device; 341 struct scsi_device *sdev = sdkp->device;
332 342
333 mutex_lock(&sd_ref_mutex); 343 mutex_lock(&sd_ref_mutex);
334 class_device_put(&sdkp->cdev); 344 put_device(&sdkp->dev);
335 scsi_device_put(sdev); 345 scsi_device_put(sdev);
336 mutex_unlock(&sd_ref_mutex); 346 mutex_unlock(&sd_ref_mutex);
337} 347}
@@ -1663,12 +1673,12 @@ static int sd_probe(struct device *dev)
1663 sdp->timeout = SD_MOD_TIMEOUT; 1673 sdp->timeout = SD_MOD_TIMEOUT;
1664 } 1674 }
1665 1675
1666 class_device_initialize(&sdkp->cdev); 1676 device_initialize(&sdkp->dev);
1667 sdkp->cdev.dev = &sdp->sdev_gendev; 1677 sdkp->dev.parent = &sdp->sdev_gendev;
1668 sdkp->cdev.class = &sd_disk_class; 1678 sdkp->dev.class = &sd_disk_class;
1669 strncpy(sdkp->cdev.class_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE); 1679 strncpy(sdkp->dev.bus_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE);
1670 1680
1671 if (class_device_add(&sdkp->cdev)) 1681 if (device_add(&sdkp->dev))
1672 goto out_put; 1682 goto out_put;
1673 1683
1674 get_device(&sdp->sdev_gendev); 1684 get_device(&sdp->sdev_gendev);
@@ -1734,13 +1744,13 @@ static int sd_remove(struct device *dev)
1734{ 1744{
1735 struct scsi_disk *sdkp = dev_get_drvdata(dev); 1745 struct scsi_disk *sdkp = dev_get_drvdata(dev);
1736 1746
1737 class_device_del(&sdkp->cdev); 1747 device_del(&sdkp->dev);
1738 del_gendisk(sdkp->disk); 1748 del_gendisk(sdkp->disk);
1739 sd_shutdown(dev); 1749 sd_shutdown(dev);
1740 1750
1741 mutex_lock(&sd_ref_mutex); 1751 mutex_lock(&sd_ref_mutex);
1742 dev_set_drvdata(dev, NULL); 1752 dev_set_drvdata(dev, NULL);
1743 class_device_put(&sdkp->cdev); 1753 put_device(&sdkp->dev);
1744 mutex_unlock(&sd_ref_mutex); 1754 mutex_unlock(&sd_ref_mutex);
1745 1755
1746 return 0; 1756 return 0;
@@ -1748,16 +1758,16 @@ static int sd_remove(struct device *dev)
1748 1758
1749/** 1759/**
1750 * scsi_disk_release - Called to free the scsi_disk structure 1760 * scsi_disk_release - Called to free the scsi_disk structure
1751 * @cdev: pointer to embedded class device 1761 * @dev: pointer to embedded class device
1752 * 1762 *
1753 * sd_ref_mutex must be held entering this routine. Because it is 1763 * sd_ref_mutex must be held entering this routine. Because it is
1754 * called on last put, you should always use the scsi_disk_get() 1764 * called on last put, you should always use the scsi_disk_get()
1755 * scsi_disk_put() helpers which manipulate the semaphore directly 1765 * scsi_disk_put() helpers which manipulate the semaphore directly
1756 * and never do a direct class_device_put(). 1766 * and never do a direct put_device.
1757 **/ 1767 **/
1758static void scsi_disk_release(struct class_device *cdev) 1768static void scsi_disk_release(struct device *dev)
1759{ 1769{
1760 struct scsi_disk *sdkp = to_scsi_disk(cdev); 1770 struct scsi_disk *sdkp = to_scsi_disk(dev);
1761 struct gendisk *disk = sdkp->disk; 1771 struct gendisk *disk = sdkp->disk;
1762 1772
1763 spin_lock(&sd_index_lock); 1773 spin_lock(&sd_index_lock);
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index a6d96694d0a5..45df83b9d847 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -107,7 +107,7 @@ static int ses_set_page2_descriptor(struct enclosure_device *edev,
107 unsigned char *desc) 107 unsigned char *desc)
108{ 108{
109 int i, j, count = 0, descriptor = ecomp->number; 109 int i, j, count = 0, descriptor = ecomp->number;
110 struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); 110 struct scsi_device *sdev = to_scsi_device(edev->edev.parent);
111 struct ses_device *ses_dev = edev->scratch; 111 struct ses_device *ses_dev = edev->scratch;
112 unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; 112 unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11];
113 unsigned char *desc_ptr = ses_dev->page2 + 8; 113 unsigned char *desc_ptr = ses_dev->page2 + 8;
@@ -137,7 +137,7 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev,
137 struct enclosure_component *ecomp) 137 struct enclosure_component *ecomp)
138{ 138{
139 int i, j, count = 0, descriptor = ecomp->number; 139 int i, j, count = 0, descriptor = ecomp->number;
140 struct scsi_device *sdev = to_scsi_device(edev->cdev.dev); 140 struct scsi_device *sdev = to_scsi_device(edev->edev.parent);
141 struct ses_device *ses_dev = edev->scratch; 141 struct ses_device *ses_dev = edev->scratch;
142 unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11]; 142 unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11];
143 unsigned char *desc_ptr = ses_dev->page2 + 8; 143 unsigned char *desc_ptr = ses_dev->page2 + 8;
@@ -269,10 +269,10 @@ int ses_match_host(struct enclosure_device *edev, void *data)
269 struct ses_host_edev *sed = data; 269 struct ses_host_edev *sed = data;
270 struct scsi_device *sdev; 270 struct scsi_device *sdev;
271 271
272 if (!scsi_is_sdev_device(edev->cdev.dev)) 272 if (!scsi_is_sdev_device(edev->edev.parent))
273 return 0; 273 return 0;
274 274
275 sdev = to_scsi_device(edev->cdev.dev); 275 sdev = to_scsi_device(edev->edev.parent);
276 276
277 if (sdev->host != sed->shost) 277 if (sdev->host != sed->shost)
278 return 0; 278 return 0;
@@ -407,10 +407,10 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
407 407
408#define INIT_ALLOC_SIZE 32 408#define INIT_ALLOC_SIZE 32
409 409
410static int ses_intf_add(struct class_device *cdev, 410static int ses_intf_add(struct device *cdev,
411 struct class_interface *intf) 411 struct class_interface *intf)
412{ 412{
413 struct scsi_device *sdev = to_scsi_device(cdev->dev); 413 struct scsi_device *sdev = to_scsi_device(cdev->parent);
414 struct scsi_device *tmp_sdev; 414 struct scsi_device *tmp_sdev;
415 unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr = NULL, 415 unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr = NULL,
416 *addl_desc_ptr = NULL; 416 *addl_desc_ptr = NULL;
@@ -426,7 +426,7 @@ static int ses_intf_add(struct class_device *cdev,
426 edev = enclosure_find(&sdev->host->shost_gendev); 426 edev = enclosure_find(&sdev->host->shost_gendev);
427 if (edev) { 427 if (edev) {
428 ses_match_to_enclosure(edev, sdev); 428 ses_match_to_enclosure(edev, sdev);
429 class_device_put(&edev->cdev); 429 put_device(&edev->edev);
430 } 430 }
431 return -ENODEV; 431 return -ENODEV;
432 } 432 }
@@ -515,7 +515,7 @@ static int ses_intf_add(struct class_device *cdev,
515 if (!scomp) 515 if (!scomp)
516 goto err_free; 516 goto err_free;
517 517
518 edev = enclosure_register(cdev->dev, sdev->sdev_gendev.bus_id, 518 edev = enclosure_register(cdev->parent, sdev->sdev_gendev.bus_id,
519 components, &ses_enclosure_callbacks); 519 components, &ses_enclosure_callbacks);
520 if (IS_ERR(edev)) { 520 if (IS_ERR(edev)) {
521 err = PTR_ERR(edev); 521 err = PTR_ERR(edev);
@@ -625,17 +625,17 @@ static int ses_remove(struct device *dev)
625 return 0; 625 return 0;
626} 626}
627 627
628static void ses_intf_remove(struct class_device *cdev, 628static void ses_intf_remove(struct device *cdev,
629 struct class_interface *intf) 629 struct class_interface *intf)
630{ 630{
631 struct scsi_device *sdev = to_scsi_device(cdev->dev); 631 struct scsi_device *sdev = to_scsi_device(cdev->parent);
632 struct enclosure_device *edev; 632 struct enclosure_device *edev;
633 struct ses_device *ses_dev; 633 struct ses_device *ses_dev;
634 634
635 if (!scsi_device_enclosure(sdev)) 635 if (!scsi_device_enclosure(sdev))
636 return; 636 return;
637 637
638 edev = enclosure_find(cdev->dev); 638 edev = enclosure_find(cdev->parent);
639 if (!edev) 639 if (!edev)
640 return; 640 return;
641 641
@@ -649,13 +649,13 @@ static void ses_intf_remove(struct class_device *cdev,
649 649
650 kfree(edev->component[0].scratch); 650 kfree(edev->component[0].scratch);
651 651
652 class_device_put(&edev->cdev); 652 put_device(&edev->edev);
653 enclosure_unregister(edev); 653 enclosure_unregister(edev);
654} 654}
655 655
656static struct class_interface ses_interface = { 656static struct class_interface ses_interface = {
657 .add = ses_intf_add, 657 .add_dev = ses_intf_add,
658 .remove = ses_intf_remove, 658 .remove_dev = ses_intf_remove,
659}; 659};
660 660
661static struct scsi_driver ses_template = { 661static struct scsi_driver ses_template = {
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index e5156aa6dd20..2029422bc04d 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -101,16 +101,16 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ;
101#define SG_SECTOR_SZ 512 101#define SG_SECTOR_SZ 512
102#define SG_SECTOR_MSK (SG_SECTOR_SZ - 1) 102#define SG_SECTOR_MSK (SG_SECTOR_SZ - 1)
103 103
104static int sg_add(struct class_device *, struct class_interface *); 104static int sg_add(struct device *, struct class_interface *);
105static void sg_remove(struct class_device *, struct class_interface *); 105static void sg_remove(struct device *, struct class_interface *);
106 106
107static DEFINE_IDR(sg_index_idr); 107static DEFINE_IDR(sg_index_idr);
108static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock 108static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock
109 file descriptor list for device */ 109 file descriptor list for device */
110 110
111static struct class_interface sg_interface = { 111static struct class_interface sg_interface = {
112 .add = sg_add, 112 .add_dev = sg_add,
113 .remove = sg_remove, 113 .remove_dev = sg_remove,
114}; 114};
115 115
116typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */ 116typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */
@@ -1401,9 +1401,9 @@ static Sg_device *sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1401} 1401}
1402 1402
1403static int 1403static int
1404sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) 1404sg_add(struct device *cl_dev, struct class_interface *cl_intf)
1405{ 1405{
1406 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1406 struct scsi_device *scsidp = to_scsi_device(cl_dev->parent);
1407 struct gendisk *disk; 1407 struct gendisk *disk;
1408 Sg_device *sdp = NULL; 1408 Sg_device *sdp = NULL;
1409 struct cdev * cdev = NULL; 1409 struct cdev * cdev = NULL;
@@ -1439,19 +1439,19 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1439 1439
1440 sdp->cdev = cdev; 1440 sdp->cdev = cdev;
1441 if (sg_sysfs_valid) { 1441 if (sg_sysfs_valid) {
1442 struct class_device * sg_class_member; 1442 struct device *sg_class_member;
1443 1443
1444 sg_class_member = class_device_create(sg_sysfs_class, NULL, 1444 sg_class_member = device_create(sg_sysfs_class, cl_dev->parent,
1445 MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1445 MKDEV(SCSI_GENERIC_MAJOR,
1446 cl_dev->dev, "%s", 1446 sdp->index),
1447 disk->disk_name); 1447 "%s", disk->disk_name);
1448 if (IS_ERR(sg_class_member)) { 1448 if (IS_ERR(sg_class_member)) {
1449 printk(KERN_ERR "sg_add: " 1449 printk(KERN_ERR "sg_add: "
1450 "class_device_create failed\n"); 1450 "device_create failed\n");
1451 error = PTR_ERR(sg_class_member); 1451 error = PTR_ERR(sg_class_member);
1452 goto cdev_add_err; 1452 goto cdev_add_err;
1453 } 1453 }
1454 class_set_devdata(sg_class_member, sdp); 1454 dev_set_drvdata(sg_class_member, sdp);
1455 error = sysfs_create_link(&scsidp->sdev_gendev.kobj, 1455 error = sysfs_create_link(&scsidp->sdev_gendev.kobj,
1456 &sg_class_member->kobj, "generic"); 1456 &sg_class_member->kobj, "generic");
1457 if (error) 1457 if (error)
@@ -1464,7 +1464,7 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1464 "Attached scsi generic sg%d type %d\n", sdp->index, 1464 "Attached scsi generic sg%d type %d\n", sdp->index,
1465 scsidp->type); 1465 scsidp->type);
1466 1466
1467 class_set_devdata(cl_dev, sdp); 1467 dev_set_drvdata(cl_dev, sdp);
1468 1468
1469 return 0; 1469 return 0;
1470 1470
@@ -1482,10 +1482,10 @@ out:
1482} 1482}
1483 1483
1484static void 1484static void
1485sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) 1485sg_remove(struct device *cl_dev, struct class_interface *cl_intf)
1486{ 1486{
1487 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1487 struct scsi_device *scsidp = to_scsi_device(cl_dev->parent);
1488 Sg_device *sdp = class_get_devdata(cl_dev); 1488 Sg_device *sdp = dev_get_drvdata(cl_dev);
1489 unsigned long iflags; 1489 unsigned long iflags;
1490 Sg_fd *sfp; 1490 Sg_fd *sfp;
1491 Sg_fd *tsfp; 1491 Sg_fd *tsfp;
@@ -1528,7 +1528,7 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
1528 write_unlock_irqrestore(&sg_index_lock, iflags); 1528 write_unlock_irqrestore(&sg_index_lock, iflags);
1529 1529
1530 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic"); 1530 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic");
1531 class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index)); 1531 device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index));
1532 cdev_del(sdp->cdev); 1532 cdev_del(sdp->cdev);
1533 sdp->cdev = NULL; 1533 sdp->cdev = NULL;
1534 put_disk(sdp->disk); 1534 put_disk(sdp->disk);
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index df83bea2c620..a860c3a9ae99 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4108,9 +4108,9 @@ out_free_tape:
4108 if (STm->cdevs[j]) { 4108 if (STm->cdevs[j]) {
4109 if (cdev == STm->cdevs[j]) 4109 if (cdev == STm->cdevs[j])
4110 cdev = NULL; 4110 cdev = NULL;
4111 class_device_destroy(st_sysfs_class, 4111 device_destroy(st_sysfs_class,
4112 MKDEV(SCSI_TAPE_MAJOR, 4112 MKDEV(SCSI_TAPE_MAJOR,
4113 TAPE_MINOR(i, mode, j))); 4113 TAPE_MINOR(i, mode, j)));
4114 cdev_del(STm->cdevs[j]); 4114 cdev_del(STm->cdevs[j]);
4115 } 4115 }
4116 } 4116 }
@@ -4148,9 +4148,9 @@ static int st_remove(struct device *dev)
4148 "tape"); 4148 "tape");
4149 for (mode = 0; mode < ST_NBR_MODES; ++mode) { 4149 for (mode = 0; mode < ST_NBR_MODES; ++mode) {
4150 for (j=0; j < 2; j++) { 4150 for (j=0; j < 2; j++) {
4151 class_device_destroy(st_sysfs_class, 4151 device_destroy(st_sysfs_class,
4152 MKDEV(SCSI_TAPE_MAJOR, 4152 MKDEV(SCSI_TAPE_MAJOR,
4153 TAPE_MINOR(i, mode, j))); 4153 TAPE_MINOR(i, mode, j)));
4154 cdev_del(tpnt->modes[mode].cdevs[j]); 4154 cdev_del(tpnt->modes[mode].cdevs[j]);
4155 tpnt->modes[mode].cdevs[j] = NULL; 4155 tpnt->modes[mode].cdevs[j] = NULL;
4156 } 4156 }
@@ -4319,31 +4319,34 @@ static void do_remove_sysfs_files(void)
4319 4319
4320 4320
4321/* The sysfs simple class interface */ 4321/* The sysfs simple class interface */
4322static ssize_t st_defined_show(struct class_device *class_dev, char *buf) 4322static ssize_t
4323st_defined_show(struct device *dev, struct device_attribute *attr, char *buf)
4323{ 4324{
4324 struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4325 struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev);
4325 ssize_t l = 0; 4326 ssize_t l = 0;
4326 4327
4327 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined); 4328 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined);
4328 return l; 4329 return l;
4329} 4330}
4330 4331
4331CLASS_DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL); 4332DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL);
4332 4333
4333static ssize_t st_defblk_show(struct class_device *class_dev, char *buf) 4334static ssize_t
4335st_defblk_show(struct device *dev, struct device_attribute *attr, char *buf)
4334{ 4336{
4335 struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4337 struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev);
4336 ssize_t l = 0; 4338 ssize_t l = 0;
4337 4339
4338 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize); 4340 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize);
4339 return l; 4341 return l;
4340} 4342}
4341 4343
4342CLASS_DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL); 4344DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL);
4343 4345
4344static ssize_t st_defdensity_show(struct class_device *class_dev, char *buf) 4346static ssize_t
4347st_defdensity_show(struct device *dev, struct device_attribute *attr, char *buf)
4345{ 4348{
4346 struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4349 struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev);
4347 ssize_t l = 0; 4350 ssize_t l = 0;
4348 char *fmt; 4351 char *fmt;
4349 4352
@@ -4352,22 +4355,25 @@ static ssize_t st_defdensity_show(struct class_device *class_dev, char *buf)
4352 return l; 4355 return l;
4353} 4356}
4354 4357
4355CLASS_DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL); 4358DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL);
4356 4359
4357static ssize_t st_defcompression_show(struct class_device *class_dev, char *buf) 4360static ssize_t
4361st_defcompression_show(struct device *dev, struct device_attribute *attr,
4362 char *buf)
4358{ 4363{
4359 struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4364 struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev);
4360 ssize_t l = 0; 4365 ssize_t l = 0;
4361 4366
4362 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1); 4367 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1);
4363 return l; 4368 return l;
4364} 4369}
4365 4370
4366CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL); 4371DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL);
4367 4372
4368static ssize_t st_options_show(struct class_device *class_dev, char *buf) 4373static ssize_t
4374st_options_show(struct device *dev, struct device_attribute *attr, char *buf)
4369{ 4375{
4370 struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); 4376 struct st_modedef *STm = (struct st_modedef *)dev_get_drvdata(dev);
4371 struct scsi_tape *STp; 4377 struct scsi_tape *STp;
4372 int i, j, options; 4378 int i, j, options;
4373 ssize_t l = 0; 4379 ssize_t l = 0;
@@ -4403,13 +4409,13 @@ static ssize_t st_options_show(struct class_device *class_dev, char *buf)
4403 return l; 4409 return l;
4404} 4410}
4405 4411
4406CLASS_DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL); 4412DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL);
4407 4413
4408static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) 4414static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4409{ 4415{
4410 int i, rew, error; 4416 int i, rew, error;
4411 char name[10]; 4417 char name[10];
4412 struct class_device *st_class_member; 4418 struct device *st_class_member;
4413 4419
4414 for (rew=0; rew < 2; rew++) { 4420 for (rew=0; rew < 2; rew++) {
4415 /* Make sure that the minor numbers corresponding to the four 4421 /* Make sure that the minor numbers corresponding to the four
@@ -4418,32 +4424,32 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4418 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4424 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
4419 STp->disk->disk_name, st_formats[i]); 4425 STp->disk->disk_name, st_formats[i]);
4420 st_class_member = 4426 st_class_member =
4421 class_device_create(st_sysfs_class, NULL, 4427 device_create(st_sysfs_class, &STp->device->sdev_gendev,
4422 MKDEV(SCSI_TAPE_MAJOR, 4428 MKDEV(SCSI_TAPE_MAJOR,
4423 TAPE_MINOR(dev_num, mode, rew)), 4429 TAPE_MINOR(dev_num, mode, rew)),
4424 &STp->device->sdev_gendev, "%s", name); 4430 "%s", name);
4425 if (IS_ERR(st_class_member)) { 4431 if (IS_ERR(st_class_member)) {
4426 printk(KERN_WARNING "st%d: class_device_create failed\n", 4432 printk(KERN_WARNING "st%d: device_create failed\n",
4427 dev_num); 4433 dev_num);
4428 error = PTR_ERR(st_class_member); 4434 error = PTR_ERR(st_class_member);
4429 goto out; 4435 goto out;
4430 } 4436 }
4431 class_set_devdata(st_class_member, &STp->modes[mode]); 4437 dev_set_drvdata(st_class_member, &STp->modes[mode]);
4432 4438
4433 error = class_device_create_file(st_class_member, 4439 error = device_create_file(st_class_member,
4434 &class_device_attr_defined); 4440 &dev_attr_defined);
4435 if (error) goto out; 4441 if (error) goto out;
4436 error = class_device_create_file(st_class_member, 4442 error = device_create_file(st_class_member,
4437 &class_device_attr_default_blksize); 4443 &dev_attr_default_blksize);
4438 if (error) goto out; 4444 if (error) goto out;
4439 error = class_device_create_file(st_class_member, 4445 error = device_create_file(st_class_member,
4440 &class_device_attr_default_density); 4446 &dev_attr_default_density);
4441 if (error) goto out; 4447 if (error) goto out;
4442 error = class_device_create_file(st_class_member, 4448 error = device_create_file(st_class_member,
4443 &class_device_attr_default_compression); 4449 &dev_attr_default_compression);
4444 if (error) goto out; 4450 if (error) goto out;
4445 error = class_device_create_file(st_class_member, 4451 error = device_create_file(st_class_member,
4446 &class_device_attr_options); 4452 &dev_attr_options);
4447 if (error) goto out; 4453 if (error) goto out;
4448 4454
4449 if (mode == 0 && rew == 0) { 4455 if (mode == 0 && rew == 0) {
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index 32b9737759c4..0cc39f82d7c5 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -92,6 +92,9 @@ extern struct uart_cpm_port cpm_uart_ports[UART_NR];
92 92
93/* these are located in their respective files */ 93/* these are located in their respective files */
94void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd); 94void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
95void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
96 struct device_node *np);
97void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
95int cpm_uart_init_portdesc(void); 98int cpm_uart_init_portdesc(void);
96int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); 99int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
97void cpm_uart_freebuf(struct uart_cpm_port *pinfo); 100void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 236af9d33851..a638ba0679ac 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -966,24 +966,23 @@ static int cpm_uart_init_port(struct device_node *np,
966 if (!mem) 966 if (!mem)
967 return -ENOMEM; 967 return -ENOMEM;
968 968
969 pram = of_iomap(np, 1);
970 if (!pram) {
971 ret = -ENOMEM;
972 goto out_mem;
973 }
974
975 if (of_device_is_compatible(np, "fsl,cpm1-scc-uart") || 969 if (of_device_is_compatible(np, "fsl,cpm1-scc-uart") ||
976 of_device_is_compatible(np, "fsl,cpm2-scc-uart")) { 970 of_device_is_compatible(np, "fsl,cpm2-scc-uart")) {
977 pinfo->sccp = mem; 971 pinfo->sccp = mem;
978 pinfo->sccup = pram; 972 pinfo->sccup = pram = cpm_uart_map_pram(pinfo, np);
979 } else if (of_device_is_compatible(np, "fsl,cpm1-smc-uart") || 973 } else if (of_device_is_compatible(np, "fsl,cpm1-smc-uart") ||
980 of_device_is_compatible(np, "fsl,cpm2-smc-uart")) { 974 of_device_is_compatible(np, "fsl,cpm2-smc-uart")) {
981 pinfo->flags |= FLAG_SMC; 975 pinfo->flags |= FLAG_SMC;
982 pinfo->smcp = mem; 976 pinfo->smcp = mem;
983 pinfo->smcup = pram; 977 pinfo->smcup = pram = cpm_uart_map_pram(pinfo, np);
984 } else { 978 } else {
985 ret = -ENODEV; 979 ret = -ENODEV;
986 goto out_pram; 980 goto out_mem;
981 }
982
983 if (!pram) {
984 ret = -ENOMEM;
985 goto out_mem;
987 } 986 }
988 987
989 pinfo->tx_nrfifos = TX_NUM_FIFO; 988 pinfo->tx_nrfifos = TX_NUM_FIFO;
@@ -1007,7 +1006,7 @@ static int cpm_uart_init_port(struct device_node *np,
1007 return cpm_uart_request_port(&pinfo->port); 1006 return cpm_uart_request_port(&pinfo->port);
1008 1007
1009out_pram: 1008out_pram:
1010 iounmap(pram); 1009 cpm_uart_unmap_pram(pinfo, pram);
1011out_mem: 1010out_mem:
1012 iounmap(mem); 1011 iounmap(mem);
1013 return ret; 1012 return ret;
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index 6ea0366e26ae..74f1432bb248 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -45,6 +45,8 @@
45#include <linux/serial_core.h> 45#include <linux/serial_core.h>
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47 47
48#include <linux/of.h>
49
48#include "cpm_uart.h" 50#include "cpm_uart.h"
49 51
50/**************************************************************/ 52/**************************************************************/
@@ -54,6 +56,18 @@ void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
54{ 56{
55 cpm_command(port->command, cmd); 57 cpm_command(port->command, cmd);
56} 58}
59
60void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
61 struct device_node *np)
62{
63 return of_iomap(np, 1);
64}
65
66void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
67{
68 iounmap(pram);
69}
70
57#else 71#else
58void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) 72void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
59{ 73{
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index d9af06a791ba..bb862e2f54cf 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -41,6 +41,9 @@
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/irq.h> 42#include <asm/irq.h>
43#include <asm/fs_pd.h> 43#include <asm/fs_pd.h>
44#ifdef CONFIG_PPC_CPM_NEW_BINDING
45#include <asm/prom.h>
46#endif
44 47
45#include <linux/serial_core.h> 48#include <linux/serial_core.h>
46#include <linux/kernel.h> 49#include <linux/kernel.h>
@@ -54,6 +57,55 @@ void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
54{ 57{
55 cpm_command(port->command, cmd); 58 cpm_command(port->command, cmd);
56} 59}
60
61void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
62 struct device_node *np)
63{
64 void __iomem *pram;
65 unsigned long offset;
66 struct resource res;
67 unsigned long len;
68
69 /* Don't remap parameter RAM if it has already been initialized
70 * during console setup.
71 */
72 if (IS_SMC(port) && port->smcup)
73 return port->smcup;
74 else if (!IS_SMC(port) && port->sccup)
75 return port->sccup;
76
77 if (of_address_to_resource(np, 1, &res))
78 return NULL;
79
80 len = 1 + res.end - res.start;
81 pram = ioremap(res.start, len);
82 if (!pram)
83 return NULL;
84
85 if (!IS_SMC(port))
86 return pram;
87
88 if (len != 2) {
89 printk(KERN_WARNING "cpm_uart[%d]: device tree references "
90 "SMC pram, using boot loader/wrapper pram mapping. "
91 "Please fix your device tree to reference the pram "
92 "base register instead.\n",
93 port->port.line);
94 return pram;
95 }
96
97 offset = cpm_dpalloc(PROFF_SMC_SIZE, 64);
98 out_be16(pram, offset);
99 iounmap(pram);
100 return cpm_muram_addr(offset);
101}
102
103void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
104{
105 if (!IS_SMC(port))
106 iounmap(pram);
107}
108
57#else 109#else
58void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) 110void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
59{ 111{
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 16ba9ac7a566..5a375bf0ebf4 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -166,15 +166,6 @@
166#define SERIAL_IMX_MAJOR 204 166#define SERIAL_IMX_MAJOR 204
167#define MINOR_START 41 167#define MINOR_START 41
168 168
169#define NR_PORTS 2
170
171#define IMX_ISR_PASS_LIMIT 256
172
173/*
174 * This is the size of our serial port register set.
175 */
176#define UART_PORT_SIZE 0x100
177
178/* 169/*
179 * This determines how often we check the modem status signals 170 * This determines how often we check the modem status signals
180 * for any change. They generally aren't connected to an IRQ 171 * for any change. They generally aren't connected to an IRQ
@@ -358,66 +349,60 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
358 struct tty_struct *tty = sport->port.info->tty; 349 struct tty_struct *tty = sport->port.info->tty;
359 unsigned long flags, temp; 350 unsigned long flags, temp;
360 351
361 rx = readl(sport->port.membase + URXD0);
362 spin_lock_irqsave(&sport->port.lock,flags); 352 spin_lock_irqsave(&sport->port.lock,flags);
363 353
364 do { 354 while (readl(sport->port.membase + USR2) & USR2_RDR) {
365 flg = TTY_NORMAL; 355 flg = TTY_NORMAL;
366 sport->port.icount.rx++; 356 sport->port.icount.rx++;
367 357
358 rx = readl(sport->port.membase + URXD0);
359
368 temp = readl(sport->port.membase + USR2); 360 temp = readl(sport->port.membase + USR2);
369 if( temp & USR2_BRCD ) { 361 if (temp & USR2_BRCD) {
370 writel(temp | USR2_BRCD, sport->port.membase + USR2); 362 writel(temp | USR2_BRCD, sport->port.membase + USR2);
371 if(uart_handle_break(&sport->port)) 363 if (uart_handle_break(&sport->port))
372 goto ignore_char; 364 continue;
373 } 365 }
374 366
375 if (uart_handle_sysrq_char 367 if (uart_handle_sysrq_char
376 (&sport->port, (unsigned char)rx)) 368 (&sport->port, (unsigned char)rx))
377 goto ignore_char; 369 continue;
370
371 if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) {
372 if (rx & URXD_PRERR)
373 sport->port.icount.parity++;
374 else if (rx & URXD_FRMERR)
375 sport->port.icount.frame++;
376 if (rx & URXD_OVRRUN)
377 sport->port.icount.overrun++;
378
379 if (rx & sport->port.ignore_status_mask) {
380 if (++ignored > 100)
381 goto out;
382 continue;
383 }
384
385 rx &= sport->port.read_status_mask;
386
387 if (rx & URXD_PRERR)
388 flg = TTY_PARITY;
389 else if (rx & URXD_FRMERR)
390 flg = TTY_FRAME;
391 if (rx & URXD_OVRRUN)
392 flg = TTY_OVERRUN;
378 393
379 if( rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) 394#ifdef SUPPORT_SYSRQ
380 goto handle_error; 395 sport->port.sysrq = 0;
396#endif
397 }
381 398
382 error_return:
383 tty_insert_flip_char(tty, rx, flg); 399 tty_insert_flip_char(tty, rx, flg);
384 400 }
385 ignore_char:
386 rx = readl(sport->port.membase + URXD0);
387 } while(rx & URXD_CHARRDY);
388 401
389out: 402out:
390 spin_unlock_irqrestore(&sport->port.lock,flags); 403 spin_unlock_irqrestore(&sport->port.lock,flags);
391 tty_flip_buffer_push(tty); 404 tty_flip_buffer_push(tty);
392 return IRQ_HANDLED; 405 return IRQ_HANDLED;
393
394handle_error:
395 if (rx & URXD_PRERR)
396 sport->port.icount.parity++;
397 else if (rx & URXD_FRMERR)
398 sport->port.icount.frame++;
399 if (rx & URXD_OVRRUN)
400 sport->port.icount.overrun++;
401
402 if (rx & sport->port.ignore_status_mask) {
403 if (++ignored > 100)
404 goto out;
405 goto ignore_char;
406 }
407
408 rx &= sport->port.read_status_mask;
409
410 if (rx & URXD_PRERR)
411 flg = TTY_PARITY;
412 else if (rx & URXD_FRMERR)
413 flg = TTY_FRAME;
414 if (rx & URXD_OVRRUN)
415 flg = TTY_OVERRUN;
416
417#ifdef SUPPORT_SYSRQ
418 sport->port.sysrq = 0;
419#endif
420 goto error_return;
421} 406}
422 407
423/* 408/*
@@ -546,7 +531,7 @@ static int imx_startup(struct uart_port *port)
546 writel(USR1_RTSD, sport->port.membase + USR1); 531 writel(USR1_RTSD, sport->port.membase + USR1);
547 532
548 temp = readl(sport->port.membase + UCR1); 533 temp = readl(sport->port.membase + UCR1);
549 temp |= (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); 534 temp |= UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN;
550 writel(temp, sport->port.membase + UCR1); 535 writel(temp, sport->port.membase + UCR1);
551 536
552 temp = readl(sport->port.membase + UCR2); 537 temp = readl(sport->port.membase + UCR2);
@@ -731,9 +716,11 @@ static const char *imx_type(struct uart_port *port)
731 */ 716 */
732static void imx_release_port(struct uart_port *port) 717static void imx_release_port(struct uart_port *port)
733{ 718{
734 struct imx_port *sport = (struct imx_port *)port; 719 struct platform_device *pdev = to_platform_device(port->dev);
720 struct resource *mmres;
735 721
736 release_mem_region(sport->port.mapbase, UART_PORT_SIZE); 722 mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
723 release_mem_region(mmres->start, mmres->end - mmres->start + 1);
737} 724}
738 725
739/* 726/*
@@ -741,10 +728,18 @@ static void imx_release_port(struct uart_port *port)
741 */ 728 */
742static int imx_request_port(struct uart_port *port) 729static int imx_request_port(struct uart_port *port)
743{ 730{
744 struct imx_port *sport = (struct imx_port *)port; 731 struct platform_device *pdev = to_platform_device(port->dev);
732 struct resource *mmres;
733 void *ret;
734
735 mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
736 if (!mmres)
737 return -ENODEV;
738
739 ret = request_mem_region(mmres->start, mmres->end - mmres->start + 1,
740 "imx-uart");
745 741
746 return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, 742 return ret ? 0 : -EBUSY;
747 "imx-uart") != NULL ? 0 : -EBUSY;
748} 743}
749 744
750/* 745/*
@@ -815,7 +810,7 @@ static struct imx_port imx_ports[] = {
815 .type = PORT_IMX, 810 .type = PORT_IMX,
816 .iotype = UPIO_MEM, 811 .iotype = UPIO_MEM,
817 .membase = (void *)IMX_UART1_BASE, 812 .membase = (void *)IMX_UART1_BASE,
818 .mapbase = IMX_UART1_BASE, /* FIXME */ 813 .mapbase = 0x00206000,
819 .irq = UART1_MINT_RX, 814 .irq = UART1_MINT_RX,
820 .uartclk = 16000000, 815 .uartclk = 16000000,
821 .fifosize = 32, 816 .fifosize = 32,
@@ -831,7 +826,7 @@ static struct imx_port imx_ports[] = {
831 .type = PORT_IMX, 826 .type = PORT_IMX,
832 .iotype = UPIO_MEM, 827 .iotype = UPIO_MEM,
833 .membase = (void *)IMX_UART2_BASE, 828 .membase = (void *)IMX_UART2_BASE,
834 .mapbase = IMX_UART2_BASE, /* FIXME */ 829 .mapbase = 0x00207000,
835 .irq = UART2_MINT_RX, 830 .irq = UART2_MINT_RX,
836 .uartclk = 16000000, 831 .uartclk = 16000000,
837 .fifosize = 32, 832 .fifosize = 32,
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index 99af084c7cec..ddd3aa50d4ad 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -40,7 +40,6 @@
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/irq.h> 41#include <asm/irq.h>
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/semaphore.h>
44#include <asm/delay.h> 43#include <asm/delay.h>
45#include <asm/coldfire.h> 44#include <asm/coldfire.h>
46#include <asm/mcfsim.h> 45#include <asm/mcfsim.h>
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index c0e50a461055..8aacfb78deab 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -56,7 +56,9 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev,
56 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP 56 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
57 | UPF_FIXED_PORT; 57 | UPF_FIXED_PORT;
58 port->dev = &ofdev->dev; 58 port->dev = &ofdev->dev;
59 port->custom_divisor = *clk / (16 * (*spd)); 59 /* If current-speed was set, then try not to change it. */
60 if (spd)
61 port->custom_divisor = *clk / (16 * (*spd));
60 62
61 return 0; 63 return 0;
62} 64}
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index c32c1ca75f63..a9ca03ead3e5 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2422,7 +2422,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
2422 */ 2422 */
2423 tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev); 2423 tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev);
2424 if (likely(!IS_ERR(tty_dev))) { 2424 if (likely(!IS_ERR(tty_dev))) {
2425 device_can_wakeup(tty_dev) = 1; 2425 device_init_wakeup(tty_dev, 1);
2426 device_set_wakeup_enable(tty_dev, 0); 2426 device_set_wakeup_enable(tty_dev, 0);
2427 } else 2427 } else
2428 printk(KERN_ERR "Cannot register tty device on line %d\n", 2428 printk(KERN_ERR "Cannot register tty device on line %d\n",
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index eff593080d4f..c2ea5d4df44a 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -333,7 +333,6 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
333 } 333 }
334 sci_out(port, SCFCR, fcr_val); 334 sci_out(port, SCFCR, fcr_val);
335} 335}
336
337#elif defined(CONFIG_CPU_SH3) 336#elif defined(CONFIG_CPU_SH3)
338/* For SH7705, SH7706, SH7707, SH7709, SH7709A, SH7729 */ 337/* For SH7705, SH7706, SH7707, SH7709, SH7709A, SH7729 */
339static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 338static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
@@ -384,6 +383,12 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
384 383
385 sci_out(port, SCFCR, fcr_val); 384 sci_out(port, SCFCR, fcr_val);
386} 385}
386#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
387static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
388{
389 /* Nothing to do here.. */
390 sci_out(port, SCFCR, 0);
391}
387#else 392#else
388/* For SH7750 */ 393/* For SH7750 */
389static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 394static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 01a9dd715f5d..fa8700a968fc 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -1,20 +1,5 @@
1/* $Id: sh-sci.h,v 1.4 2004/02/19 16:43:56 lethal Exp $
2 *
3 * linux/drivers/serial/sh-sci.h
4 *
5 * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO)
6 * Copyright (C) 1999, 2000 Niibe Yutaka
7 * Copyright (C) 2000 Greg Banks
8 * Copyright (C) 2002, 2003 Paul Mundt
9 * Modified to support multiple serial ports. Stuart Menefy (May 2000).
10 * Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003).
11 * Modified to support H8/300 Series Yoshinori Sato (Feb 2004).
12 * Removed SH7300 support (Jul 2007).
13 * Modified to support SH7720 SCIF. Markus Brunner, Mark Jonas (Aug 2007).
14 */
15#include <linux/serial_core.h> 1#include <linux/serial_core.h>
16#include <asm/io.h> 2#include <asm/io.h>
17
18#include <asm/gpio.h> 3#include <asm/gpio.h>
19 4
20#if defined(CONFIG_H83007) || defined(CONFIG_H83068) 5#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
@@ -102,6 +87,15 @@
102# define SCSPTR0 SCPDR0 87# define SCSPTR0 SCPDR0
103# define SCIF_ORER 0x0001 /* overrun error bit */ 88# define SCIF_ORER 0x0001 /* overrun error bit */
104# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 89# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
90#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
91# define SCSPTR0 0xa4050160
92# define SCSPTR1 0xa405013e
93# define SCSPTR2 0xa4050160
94# define SCSPTR3 0xa405013e
95# define SCSPTR4 0xa4050128
96# define SCSPTR5 0xa4050128
97# define SCIF_ORER 0x0001 /* overrun error bit */
98# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
105# define SCIF_ONLY 99# define SCIF_ONLY
106#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 100#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
107# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 101# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
@@ -395,6 +389,11 @@
395 h8_sci_offset, h8_sci_size) \ 389 h8_sci_offset, h8_sci_size) \
396 CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size) 390 CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
397#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) 391#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size)
392#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
393 #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \
394 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size)
395 #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
396 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
398#else 397#else
399#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ 398#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
400 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ 399 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
@@ -419,6 +418,18 @@ SCIF_FNS(SCFDR, 0x1c, 16)
419SCIF_FNS(SCxTDR, 0x20, 8) 418SCIF_FNS(SCxTDR, 0x20, 8)
420SCIF_FNS(SCxRDR, 0x24, 8) 419SCIF_FNS(SCxRDR, 0x24, 8)
421SCIF_FNS(SCLSR, 0x24, 16) 420SCIF_FNS(SCLSR, 0x24, 16)
421#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
422SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
423SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
424SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
425SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8)
426SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16)
427SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8)
428SCIF_FNS(SCTDSR, 0x0c, 8)
429SCIF_FNS(SCFER, 0x10, 16)
430SCIF_FNS(SCFCR, 0x18, 16)
431SCIF_FNS(SCFDR, 0x1c, 16)
432SCIF_FNS(SCLSR, 0x24, 16)
422#else 433#else
423/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/ 434/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/
424/* name off sz off sz off sz off sz off sz*/ 435/* name off sz off sz off sz off sz off sz*/
@@ -589,6 +600,23 @@ static inline int sci_rxd_in(struct uart_port *port)
589 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */ 600 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
590 return 1; 601 return 1;
591} 602}
603#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
604static inline int sci_rxd_in(struct uart_port *port)
605{
606 if (port->mapbase == 0xffe00000)
607 return ctrl_inb(SCSPTR0) & 0x0008 ? 1 : 0; /* SCIF0 */
608 if (port->mapbase == 0xffe10000)
609 return ctrl_inb(SCSPTR1) & 0x0020 ? 1 : 0; /* SCIF1 */
610 if (port->mapbase == 0xffe20000)
611 return ctrl_inb(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF2 */
612 if (port->mapbase == 0xa4e30000)
613 return ctrl_inb(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF3 */
614 if (port->mapbase == 0xa4e40000)
615 return ctrl_inb(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF4 */
616 if (port->mapbase == 0xa4e50000)
617 return ctrl_inb(SCSPTR5) & 0x0008 ? 1 : 0; /* SCIF5 */
618 return 1;
619}
592#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 620#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
593static inline int sci_rxd_in(struct uart_port *port) 621static inline int sci_rxd_in(struct uart_port *port)
594{ 622{
@@ -727,6 +755,8 @@ static inline int sci_rxd_in(struct uart_port *port)
727 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 755 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
728 defined(CONFIG_CPU_SUBTYPE_SH7721) 756 defined(CONFIG_CPU_SUBTYPE_SH7721)
729#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) 757#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
758#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
759#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(16*bps)-1)
730#elif defined(__H8300H__) || defined(__H8300S__) 760#elif defined(__H8300H__) || defined(__H8300S__)
731#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) 761#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
732#elif defined(CONFIG_SUPERH64) 762#elif defined(CONFIG_SUPERH64)
diff --git a/drivers/serial/ucc_uart.c b/drivers/serial/ucc_uart.c
index e0994f061001..5e4310ccd591 100644
--- a/drivers/serial/ucc_uart.c
+++ b/drivers/serial/ucc_uart.c
@@ -1270,10 +1270,18 @@ static int ucc_uart_probe(struct of_device *ofdev,
1270 1270
1271 /* Get the UCC number (device ID) */ 1271 /* Get the UCC number (device ID) */
1272 /* UCCs are numbered 1-7 */ 1272 /* UCCs are numbered 1-7 */
1273 iprop = of_get_property(np, "device-id", NULL); 1273 iprop = of_get_property(np, "cell-index", NULL);
1274 if (!iprop || (*iprop < 1) || (*iprop > UCC_MAX_NUM)) { 1274 if (!iprop) {
1275 dev_err(&ofdev->dev, 1275 iprop = of_get_property(np, "device-id", NULL);
1276 "missing or invalid UCC specified in device tree\n"); 1276 if (!iprop) {
1277 dev_err(&ofdev->dev, "UCC is unspecified in "
1278 "device tree\n");
1279 return -EINVAL;
1280 }
1281 }
1282
1283 if ((*iprop < 1) || (*iprop > UCC_MAX_NUM)) {
1284 dev_err(&ofdev->dev, "no support for UCC%u\n", *iprop);
1277 kfree(qe_port); 1285 kfree(qe_port);
1278 return -ENODEV; 1286 return -ENODEV;
1279 } 1287 }
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index b778ed71f636..a4aaab9c7ddc 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -1,8 +1,6 @@
1menu "Userspace I/O" 1menuconfig UIO
2 depends on !S390
3
4config UIO
5 tristate "Userspace I/O drivers" 2 tristate "Userspace I/O drivers"
3 depends on !S390
6 default n 4 default n
7 help 5 help
8 Enable this to allow the userspace driver core code to be 6 Enable this to allow the userspace driver core code to be
@@ -13,6 +11,8 @@ config UIO
13 11
14 If you don't know what to do here, say N. 12 If you don't know what to do here, say N.
15 13
14if UIO
15
16config UIO_CIF 16config UIO_CIF
17 tristate "generic Hilscher CIF Card driver" 17 tristate "generic Hilscher CIF Card driver"
18 depends on UIO && PCI 18 depends on UIO && PCI
@@ -26,4 +26,17 @@ config UIO_CIF
26 To compile this driver as a module, choose M here: the module 26 To compile this driver as a module, choose M here: the module
27 will be called uio_cif. 27 will be called uio_cif.
28 28
29endmenu 29config UIO_SMX
30 tristate "SMX cryptengine UIO interface"
31 depends on UIO
32 default n
33 help
34 Userspace IO interface to the Cryptography engine found on the
35 Nias Digital SMX boards. These will be available from Q4 2008
36 from http://www.niasdigital.com. The userspace part of this
37 driver will be released under the GPL at the same time as the
38 hardware and will be able to be downloaded from the same site.
39
40 If you compile this as a module, it will be called uio_smx.
41
42endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 7fecfb459da5..18c45662431e 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -1,2 +1,3 @@
1obj-$(CONFIG_UIO) += uio.o 1obj-$(CONFIG_UIO) += uio.o
2obj-$(CONFIG_UIO_CIF) += uio_cif.o 2obj-$(CONFIG_UIO_CIF) += uio_cif.o
3obj-$(CONFIG_UIO_SMX) += uio_smx.o
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 11759080ca54..55cc7b80422a 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -301,23 +301,33 @@ static int uio_open(struct inode *inode, struct file *filep)
301 if (!idev) 301 if (!idev)
302 return -ENODEV; 302 return -ENODEV;
303 303
304 if (!try_module_get(idev->owner))
305 return -ENODEV;
306
304 listener = kmalloc(sizeof(*listener), GFP_KERNEL); 307 listener = kmalloc(sizeof(*listener), GFP_KERNEL);
305 if (!listener) 308 if (!listener) {
306 return -ENOMEM; 309 ret = -ENOMEM;
310 goto err_alloc_listener;
311 }
307 312
308 listener->dev = idev; 313 listener->dev = idev;
309 listener->event_count = atomic_read(&idev->event); 314 listener->event_count = atomic_read(&idev->event);
310 filep->private_data = listener; 315 filep->private_data = listener;
311 316
312 if (idev->info->open) { 317 if (idev->info->open) {
313 if (!try_module_get(idev->owner))
314 return -ENODEV;
315 ret = idev->info->open(idev->info, inode); 318 ret = idev->info->open(idev->info, inode);
316 module_put(idev->owner); 319 if (ret)
320 goto err_infoopen;
317 } 321 }
318 322
319 if (ret) 323 return 0;
320 kfree(listener); 324
325err_infoopen:
326
327 kfree(listener);
328err_alloc_listener:
329
330 module_put(idev->owner);
321 331
322 return ret; 332 return ret;
323} 333}
@@ -336,12 +346,11 @@ static int uio_release(struct inode *inode, struct file *filep)
336 struct uio_listener *listener = filep->private_data; 346 struct uio_listener *listener = filep->private_data;
337 struct uio_device *idev = listener->dev; 347 struct uio_device *idev = listener->dev;
338 348
339 if (idev->info->release) { 349 if (idev->info->release)
340 if (!try_module_get(idev->owner))
341 return -ENODEV;
342 ret = idev->info->release(idev->info, inode); 350 ret = idev->info->release(idev->info, inode);
343 module_put(idev->owner); 351
344 } 352 module_put(idev->owner);
353
345 if (filep->f_flags & FASYNC) 354 if (filep->f_flags & FASYNC)
346 ret = uio_fasync(-1, filep, 0); 355 ret = uio_fasync(-1, filep, 0);
347 kfree(listener); 356 kfree(listener);
@@ -510,10 +519,7 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
510 return -EINVAL; 519 return -EINVAL;
511 520
512 if (idev->info->mmap) { 521 if (idev->info->mmap) {
513 if (!try_module_get(idev->owner))
514 return -ENODEV;
515 ret = idev->info->mmap(idev->info, vma); 522 ret = idev->info->mmap(idev->info, vma);
516 module_put(idev->owner);
517 return ret; 523 return ret;
518 } 524 }
519 525
diff --git a/drivers/uio/uio_cif.c b/drivers/uio/uio_cif.c
index 838bae460831..57376060b978 100644
--- a/drivers/uio/uio_cif.c
+++ b/drivers/uio/uio_cif.c
@@ -15,10 +15,6 @@
15 15
16#include <asm/io.h> 16#include <asm/io.h>
17 17
18#ifndef PCI_DEVICE_ID_PLX_9030
19#define PCI_DEVICE_ID_PLX_9030 0x9030
20#endif
21
22#define PLX9030_INTCSR 0x4C 18#define PLX9030_INTCSR 0x4C
23#define INTSCR_INT1_ENABLE 0x01 19#define INTSCR_INT1_ENABLE 0x01
24#define INTSCR_INT1_STATUS 0x04 20#define INTSCR_INT1_STATUS 0x04
@@ -116,7 +112,7 @@ static void hilscher_pci_remove(struct pci_dev *dev)
116 kfree (info); 112 kfree (info);
117} 113}
118 114
119static struct pci_device_id hilscher_pci_ids[] = { 115static struct pci_device_id hilscher_pci_ids[] __devinitdata = {
120 { 116 {
121 .vendor = PCI_VENDOR_ID_PLX, 117 .vendor = PCI_VENDOR_ID_PLX,
122 .device = PCI_DEVICE_ID_PLX_9030, 118 .device = PCI_DEVICE_ID_PLX_9030,
diff --git a/drivers/uio/uio_smx.c b/drivers/uio/uio_smx.c
new file mode 100644
index 000000000000..44054a650a8a
--- /dev/null
+++ b/drivers/uio/uio_smx.c
@@ -0,0 +1,140 @@
1/*
2 * UIO SMX Cryptengine driver.
3 *
4 * (C) 2008 Nias Digital P/L <bn@niasdigital.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/device.h>
13#include <linux/module.h>
14#include <linux/platform_device.h>
15#include <linux/uio_driver.h>
16#include <linux/io.h>
17
18#define DRV_NAME "smx-ce"
19#define DRV_VERSION "0.03"
20
21#define SMX_CSR 0x00000000
22#define SMX_EnD 0x00000001
23#define SMX_RUN 0x00000002
24#define SMX_DRDY 0x00000004
25#define SMX_ERR 0x00000008
26
27static irqreturn_t smx_handler(int irq, struct uio_info *dev_info)
28{
29 void __iomem *csr = dev_info->mem[0].internal_addr + SMX_CSR;
30
31 u32 status = ioread32(csr);
32
33 if (!(status & SMX_DRDY))
34 return IRQ_NONE;
35
36 /* Disable interrupt */
37 iowrite32(status & ~SMX_DRDY, csr);
38 return IRQ_HANDLED;
39}
40
41static int __devinit smx_ce_probe(struct platform_device *dev)
42{
43
44 int ret = -ENODEV;
45 struct uio_info *info;
46 struct resource *regs;
47
48 info = kzalloc(sizeof(struct uio_info), GFP_KERNEL);
49 if (!info)
50 return -ENOMEM;
51
52 regs = platform_get_resource(dev, IORESOURCE_MEM, 0);
53 if (!regs) {
54 dev_err(&dev->dev, "No memory resource specified\n");
55 goto out_free;
56 }
57
58 info->mem[0].addr = regs->start;
59 if (!info->mem[0].addr) {
60 dev_err(&dev->dev, "Invalid memory resource\n");
61 goto out_free;
62 }
63
64 info->mem[0].size = regs->end - regs->start + 1;
65 info->mem[0].internal_addr = ioremap(regs->start, info->mem[0].size);
66
67 if (!info->mem[0].internal_addr) {
68 dev_err(&dev->dev, "Can't remap memory address range\n");
69 goto out_free;
70 }
71
72 info->mem[0].memtype = UIO_MEM_PHYS;
73
74 info->name = "smx-ce";
75 info->version = "0.03";
76
77 info->irq = platform_get_irq(dev, 0);
78 if (info->irq < 0) {
79 ret = info->irq;
80 dev_err(&dev->dev, "No (or invalid) IRQ resource specified\n");
81 goto out_unmap;
82 }
83
84 info->irq_flags = IRQF_SHARED;
85 info->handler = smx_handler;
86
87 platform_set_drvdata(dev, info);
88
89 ret = uio_register_device(&dev->dev, info);
90
91 if (ret)
92 goto out_unmap;
93
94 return 0;
95
96out_unmap:
97 iounmap(info->mem[0].internal_addr);
98out_free:
99 kfree(info);
100
101 return ret;
102}
103
104static int __devexit smx_ce_remove(struct platform_device *dev)
105{
106 struct uio_info *info = platform_get_drvdata(dev);
107
108 uio_unregister_device(info);
109 platform_set_drvdata(dev, NULL);
110 iounmap(info->mem[0].internal_addr);
111
112 kfree(info);
113
114 return 0;
115}
116
117static struct platform_driver smx_ce_driver = {
118 .probe = smx_ce_probe,
119 .remove = __devexit_p(smx_ce_remove),
120 .driver = {
121 .name = DRV_NAME,
122 .owner = THIS_MODULE,
123 },
124};
125
126static int __init smx_ce_init_module(void)
127{
128 return platform_driver_register(&smx_ce_driver);
129}
130module_init(smx_ce_init_module);
131
132static void __exit smx_ce_exit_module(void)
133{
134 platform_driver_unregister(&smx_ce_driver);
135}
136module_exit(smx_ce_exit_module);
137
138MODULE_LICENSE("GPL v2");
139MODULE_VERSION(DRV_VERSION);
140MODULE_AUTHOR("Ben Nizette <bn@niasdigital.com>");
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index ff8551e93372..fc6c2be5999c 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -24,7 +24,6 @@
24#ifndef _USBATM_H_ 24#ifndef _USBATM_H_
25#define _USBATM_H_ 25#define _USBATM_H_
26 26
27#include <asm/semaphore.h>
28#include <linux/atm.h> 27#include <linux/atm.h>
29#include <linux/atmdev.h> 28#include <linux/atmdev.h>
30#include <linux/completion.h> 29#include <linux/completion.h>
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 68fc5219ca15..57aeca160f38 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -23,7 +23,6 @@
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/freezer.h> 24#include <linux/freezer.h>
25 25
26#include <asm/semaphore.h>
27#include <asm/uaccess.h> 26#include <asm/uaccess.h>
28#include <asm/byteorder.h> 27#include <asm/byteorder.h>
29 28
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 6f45dd669b33..d681bb27fa58 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -118,10 +118,10 @@ config USB_AMD5536UDC
118config USB_GADGET_ATMEL_USBA 118config USB_GADGET_ATMEL_USBA
119 boolean "Atmel USBA" 119 boolean "Atmel USBA"
120 select USB_GADGET_DUALSPEED 120 select USB_GADGET_DUALSPEED
121 depends on AVR32 121 depends on AVR32 || ARCH_AT91CAP9
122 help 122 help
123 USBA is the integrated high-speed USB Device controller on 123 USBA is the integrated high-speed USB Device controller on
124 the AT32AP700x processors from Atmel. 124 the AT32AP700x and AT91CAP9 processors from Atmel.
125 125
126config USB_ATMEL_USBA 126config USB_ATMEL_USBA
127 tristate 127 tristate
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index b0db4c31d018..e756023362c2 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/usb/ch9.h> 19#include <linux/usb/ch9.h>
20#include <linux/usb/gadget.h> 20#include <linux/usb/gadget.h>
21#include <linux/usb/atmel_usba_udc.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22 23
23#include <asm/gpio.h> 24#include <asm/gpio.h>
@@ -27,6 +28,7 @@
27 28
28 29
29static struct usba_udc the_udc; 30static struct usba_udc the_udc;
31static struct usba_ep *usba_ep;
30 32
31#ifdef CONFIG_USB_GADGET_DEBUG_FS 33#ifdef CONFIG_USB_GADGET_DEBUG_FS
32#include <linux/debugfs.h> 34#include <linux/debugfs.h>
@@ -324,53 +326,28 @@ static int vbus_is_present(struct usba_udc *udc)
324 return 1; 326 return 1;
325} 327}
326 328
327static void copy_to_fifo(void __iomem *fifo, const void *buf, int len) 329#if defined(CONFIG_AVR32)
330
331static void toggle_bias(int is_on)
328{ 332{
329 unsigned long tmp;
330
331 DBG(DBG_FIFO, "copy to FIFO (len %d):\n", len);
332 for (; len > 0; len -= 4, buf += 4, fifo += 4) {
333 tmp = *(unsigned long *)buf;
334 if (len >= 4) {
335 DBG(DBG_FIFO, " -> %08lx\n", tmp);
336 __raw_writel(tmp, fifo);
337 } else {
338 do {
339 DBG(DBG_FIFO, " -> %02lx\n", tmp >> 24);
340 __raw_writeb(tmp >> 24, fifo);
341 fifo++;
342 tmp <<= 8;
343 } while (--len);
344 break;
345 }
346 }
347} 333}
348 334
349static void copy_from_fifo(void *buf, void __iomem *fifo, int len) 335#elif defined(CONFIG_ARCH_AT91)
336
337#include <asm/arch/at91_pmc.h>
338
339static void toggle_bias(int is_on)
350{ 340{
351 union { 341 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
352 unsigned long *w; 342
353 unsigned char *b; 343 if (is_on)
354 } p; 344 at91_sys_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
355 unsigned long tmp; 345 else
356 346 at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
357 DBG(DBG_FIFO, "copy from FIFO (len %d):\n", len);
358 for (p.w = buf; len > 0; len -= 4, p.w++, fifo += 4) {
359 if (len >= 4) {
360 tmp = __raw_readl(fifo);
361 *p.w = tmp;
362 DBG(DBG_FIFO, " -> %08lx\n", tmp);
363 } else {
364 do {
365 tmp = __raw_readb(fifo);
366 *p.b = tmp;
367 DBG(DBG_FIFO, " -> %02lx\n", tmp);
368 fifo++, p.b++;
369 } while (--len);
370 }
371 }
372} 347}
373 348
349#endif /* CONFIG_ARCH_AT91 */
350
374static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req) 351static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
375{ 352{
376 unsigned int transaction_len; 353 unsigned int transaction_len;
@@ -387,7 +364,7 @@ static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
387 ep->ep.name, req, transaction_len, 364 ep->ep.name, req, transaction_len,
388 req->last_transaction ? ", done" : ""); 365 req->last_transaction ? ", done" : "");
389 366
390 copy_to_fifo(ep->fifo, req->req.buf + req->req.actual, transaction_len); 367 memcpy_toio(ep->fifo, req->req.buf + req->req.actual, transaction_len);
391 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); 368 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
392 req->req.actual += transaction_len; 369 req->req.actual += transaction_len;
393} 370}
@@ -476,7 +453,7 @@ static void receive_data(struct usba_ep *ep)
476 bytecount = req->req.length - req->req.actual; 453 bytecount = req->req.length - req->req.actual;
477 } 454 }
478 455
479 copy_from_fifo(req->req.buf + req->req.actual, 456 memcpy_fromio(req->req.buf + req->req.actual,
480 ep->fifo, bytecount); 457 ep->fifo, bytecount);
481 req->req.actual += bytecount; 458 req->req.actual += bytecount;
482 459
@@ -1029,33 +1006,6 @@ static const struct usb_gadget_ops usba_udc_ops = {
1029 .set_selfpowered = usba_udc_set_selfpowered, 1006 .set_selfpowered = usba_udc_set_selfpowered,
1030}; 1007};
1031 1008
1032#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
1033{ \
1034 .ep = { \
1035 .ops = &usba_ep_ops, \
1036 .name = nam, \
1037 .maxpacket = maxpkt, \
1038 }, \
1039 .udc = &the_udc, \
1040 .queue = LIST_HEAD_INIT(usba_ep[idx].queue), \
1041 .fifo_size = maxpkt, \
1042 .nr_banks = maxbk, \
1043 .index = idx, \
1044 .can_dma = dma, \
1045 .can_isoc = isoc, \
1046}
1047
1048static struct usba_ep usba_ep[] = {
1049 EP("ep0", 0, 64, 1, 0, 0),
1050 EP("ep1in-bulk", 1, 512, 2, 1, 1),
1051 EP("ep2out-bulk", 2, 512, 2, 1, 1),
1052 EP("ep3in-int", 3, 64, 3, 1, 0),
1053 EP("ep4out-int", 4, 64, 3, 1, 0),
1054 EP("ep5in-iso", 5, 1024, 3, 1, 1),
1055 EP("ep6out-iso", 6, 1024, 3, 1, 1),
1056};
1057#undef EP
1058
1059static struct usb_endpoint_descriptor usba_ep0_desc = { 1009static struct usb_endpoint_descriptor usba_ep0_desc = {
1060 .bLength = USB_DT_ENDPOINT_SIZE, 1010 .bLength = USB_DT_ENDPOINT_SIZE,
1061 .bDescriptorType = USB_DT_ENDPOINT, 1011 .bDescriptorType = USB_DT_ENDPOINT,
@@ -1074,7 +1024,6 @@ static void nop_release(struct device *dev)
1074static struct usba_udc the_udc = { 1024static struct usba_udc the_udc = {
1075 .gadget = { 1025 .gadget = {
1076 .ops = &usba_udc_ops, 1026 .ops = &usba_udc_ops,
1077 .ep0 = &usba_ep[0].ep,
1078 .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list), 1027 .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list),
1079 .is_dualspeed = 1, 1028 .is_dualspeed = 1,
1080 .name = "atmel_usba_udc", 1029 .name = "atmel_usba_udc",
@@ -1231,7 +1180,7 @@ static int do_test_mode(struct usba_udc *udc)
1231 } else { 1180 } else {
1232 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); 1181 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE);
1233 usba_writel(udc, TST, USBA_TST_PKT_MODE); 1182 usba_writel(udc, TST, USBA_TST_PKT_MODE);
1234 copy_to_fifo(ep->fifo, test_packet_buffer, 1183 memcpy_toio(ep->fifo, test_packet_buffer,
1235 sizeof(test_packet_buffer)); 1184 sizeof(test_packet_buffer));
1236 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); 1185 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
1237 dev_info(dev, "Entering Test_Packet mode...\n"); 1186 dev_info(dev, "Entering Test_Packet mode...\n");
@@ -1530,13 +1479,13 @@ restart:
1530 DBG(DBG_HW, "Packet length: %u\n", pkt_len); 1479 DBG(DBG_HW, "Packet length: %u\n", pkt_len);
1531 if (pkt_len != sizeof(crq)) { 1480 if (pkt_len != sizeof(crq)) {
1532 pr_warning("udc: Invalid packet length %u " 1481 pr_warning("udc: Invalid packet length %u "
1533 "(expected %lu)\n", pkt_len, sizeof(crq)); 1482 "(expected %zu)\n", pkt_len, sizeof(crq));
1534 set_protocol_stall(udc, ep); 1483 set_protocol_stall(udc, ep);
1535 return; 1484 return;
1536 } 1485 }
1537 1486
1538 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo); 1487 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo);
1539 copy_from_fifo(crq.data, ep->fifo, sizeof(crq)); 1488 memcpy_fromio(crq.data, ep->fifo, sizeof(crq));
1540 1489
1541 /* Free up one bank in the FIFO so that we can 1490 /* Free up one bank in the FIFO so that we can
1542 * generate or receive a reply right away. */ 1491 * generate or receive a reply right away. */
@@ -1688,6 +1637,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1688 DBG(DBG_INT, "irq, status=%#08x\n", status); 1637 DBG(DBG_INT, "irq, status=%#08x\n", status);
1689 1638
1690 if (status & USBA_DET_SUSPEND) { 1639 if (status & USBA_DET_SUSPEND) {
1640 toggle_bias(0);
1691 usba_writel(udc, INT_CLR, USBA_DET_SUSPEND); 1641 usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
1692 DBG(DBG_BUS, "Suspend detected\n"); 1642 DBG(DBG_BUS, "Suspend detected\n");
1693 if (udc->gadget.speed != USB_SPEED_UNKNOWN 1643 if (udc->gadget.speed != USB_SPEED_UNKNOWN
@@ -1699,6 +1649,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1699 } 1649 }
1700 1650
1701 if (status & USBA_WAKE_UP) { 1651 if (status & USBA_WAKE_UP) {
1652 toggle_bias(1);
1702 usba_writel(udc, INT_CLR, USBA_WAKE_UP); 1653 usba_writel(udc, INT_CLR, USBA_WAKE_UP);
1703 DBG(DBG_BUS, "Wake Up CPU detected\n"); 1654 DBG(DBG_BUS, "Wake Up CPU detected\n");
1704 } 1655 }
@@ -1792,12 +1743,14 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
1792 vbus = gpio_get_value(udc->vbus_pin); 1743 vbus = gpio_get_value(udc->vbus_pin);
1793 if (vbus != udc->vbus_prev) { 1744 if (vbus != udc->vbus_prev) {
1794 if (vbus) { 1745 if (vbus) {
1795 usba_writel(udc, CTRL, USBA_EN_USBA); 1746 toggle_bias(1);
1747 usba_writel(udc, CTRL, USBA_ENABLE_MASK);
1796 usba_writel(udc, INT_ENB, USBA_END_OF_RESET); 1748 usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
1797 } else { 1749 } else {
1798 udc->gadget.speed = USB_SPEED_UNKNOWN; 1750 udc->gadget.speed = USB_SPEED_UNKNOWN;
1799 reset_all_endpoints(udc); 1751 reset_all_endpoints(udc);
1800 usba_writel(udc, CTRL, 0); 1752 toggle_bias(0);
1753 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1801 spin_unlock(&udc->lock); 1754 spin_unlock(&udc->lock);
1802 udc->driver->disconnect(&udc->gadget); 1755 udc->driver->disconnect(&udc->gadget);
1803 spin_lock(&udc->lock); 1756 spin_lock(&udc->lock);
@@ -1850,7 +1803,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1850 /* If Vbus is present, enable the controller and wait for reset */ 1803 /* If Vbus is present, enable the controller and wait for reset */
1851 spin_lock_irqsave(&udc->lock, flags); 1804 spin_lock_irqsave(&udc->lock, flags);
1852 if (vbus_is_present(udc) && udc->vbus_prev == 0) { 1805 if (vbus_is_present(udc) && udc->vbus_prev == 0) {
1853 usba_writel(udc, CTRL, USBA_EN_USBA); 1806 toggle_bias(1);
1807 usba_writel(udc, CTRL, USBA_ENABLE_MASK);
1854 usba_writel(udc, INT_ENB, USBA_END_OF_RESET); 1808 usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
1855 } 1809 }
1856 spin_unlock_irqrestore(&udc->lock, flags); 1810 spin_unlock_irqrestore(&udc->lock, flags);
@@ -1883,7 +1837,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1883 spin_unlock_irqrestore(&udc->lock, flags); 1837 spin_unlock_irqrestore(&udc->lock, flags);
1884 1838
1885 /* This will also disable the DP pullup */ 1839 /* This will also disable the DP pullup */
1886 usba_writel(udc, CTRL, 0); 1840 toggle_bias(0);
1841 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1887 1842
1888 driver->unbind(&udc->gadget); 1843 driver->unbind(&udc->gadget);
1889 udc->gadget.dev.driver = NULL; 1844 udc->gadget.dev.driver = NULL;
@@ -1908,7 +1863,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1908 1863
1909 regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); 1864 regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
1910 fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); 1865 fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
1911 if (!regs || !fifo) 1866 if (!regs || !fifo || !pdata)
1912 return -ENXIO; 1867 return -ENXIO;
1913 1868
1914 irq = platform_get_irq(pdev, 0); 1869 irq = platform_get_irq(pdev, 0);
@@ -1953,19 +1908,48 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1953 1908
1954 /* Make sure we start from a clean slate */ 1909 /* Make sure we start from a clean slate */
1955 clk_enable(pclk); 1910 clk_enable(pclk);
1956 usba_writel(udc, CTRL, 0); 1911 toggle_bias(0);
1912 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1957 clk_disable(pclk); 1913 clk_disable(pclk);
1958 1914
1915 usba_ep = kmalloc(sizeof(struct usba_ep) * pdata->num_ep,
1916 GFP_KERNEL);
1917 if (!usba_ep)
1918 goto err_alloc_ep;
1919
1920 the_udc.gadget.ep0 = &usba_ep[0].ep;
1921
1959 INIT_LIST_HEAD(&usba_ep[0].ep.ep_list); 1922 INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
1960 usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0); 1923 usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
1961 usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0); 1924 usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0);
1962 usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0); 1925 usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0);
1963 for (i = 1; i < ARRAY_SIZE(usba_ep); i++) { 1926 usba_ep[0].ep.ops = &usba_ep_ops;
1927 usba_ep[0].ep.name = pdata->ep[0].name;
1928 usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
1929 usba_ep[0].udc = &the_udc;
1930 INIT_LIST_HEAD(&usba_ep[0].queue);
1931 usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
1932 usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
1933 usba_ep[0].index = pdata->ep[0].index;
1934 usba_ep[0].can_dma = pdata->ep[0].can_dma;
1935 usba_ep[0].can_isoc = pdata->ep[0].can_isoc;
1936
1937 for (i = 1; i < pdata->num_ep; i++) {
1964 struct usba_ep *ep = &usba_ep[i]; 1938 struct usba_ep *ep = &usba_ep[i];
1965 1939
1966 ep->ep_regs = udc->regs + USBA_EPT_BASE(i); 1940 ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
1967 ep->dma_regs = udc->regs + USBA_DMA_BASE(i); 1941 ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
1968 ep->fifo = udc->fifo + USBA_FIFO_BASE(i); 1942 ep->fifo = udc->fifo + USBA_FIFO_BASE(i);
1943 ep->ep.ops = &usba_ep_ops;
1944 ep->ep.name = pdata->ep[i].name;
1945 ep->ep.maxpacket = pdata->ep[i].fifo_size;
1946 ep->udc = &the_udc;
1947 INIT_LIST_HEAD(&ep->queue);
1948 ep->fifo_size = pdata->ep[i].fifo_size;
1949 ep->nr_banks = pdata->ep[i].nr_banks;
1950 ep->index = pdata->ep[i].index;
1951 ep->can_dma = pdata->ep[i].can_dma;
1952 ep->can_isoc = pdata->ep[i].can_isoc;
1969 1953
1970 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); 1954 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
1971 } 1955 }
@@ -1984,7 +1968,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1984 goto err_device_add; 1968 goto err_device_add;
1985 } 1969 }
1986 1970
1987 if (pdata && pdata->vbus_pin != GPIO_PIN_NONE) { 1971 if (pdata->vbus_pin >= 0) {
1988 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { 1972 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
1989 udc->vbus_pin = pdata->vbus_pin; 1973 udc->vbus_pin = pdata->vbus_pin;
1990 1974
@@ -2004,7 +1988,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
2004 } 1988 }
2005 1989
2006 usba_init_debugfs(udc); 1990 usba_init_debugfs(udc);
2007 for (i = 1; i < ARRAY_SIZE(usba_ep); i++) 1991 for (i = 1; i < pdata->num_ep; i++)
2008 usba_ep_init_debugfs(udc, &usba_ep[i]); 1992 usba_ep_init_debugfs(udc, &usba_ep[i]);
2009 1993
2010 return 0; 1994 return 0;
@@ -2012,6 +1996,8 @@ static int __init usba_udc_probe(struct platform_device *pdev)
2012err_device_add: 1996err_device_add:
2013 free_irq(irq, udc); 1997 free_irq(irq, udc);
2014err_request_irq: 1998err_request_irq:
1999 kfree(usba_ep);
2000err_alloc_ep:
2015 iounmap(udc->fifo); 2001 iounmap(udc->fifo);
2016err_map_fifo: 2002err_map_fifo:
2017 iounmap(udc->regs); 2003 iounmap(udc->regs);
@@ -2029,10 +2015,11 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
2029{ 2015{
2030 struct usba_udc *udc; 2016 struct usba_udc *udc;
2031 int i; 2017 int i;
2018 struct usba_platform_data *pdata = pdev->dev.platform_data;
2032 2019
2033 udc = platform_get_drvdata(pdev); 2020 udc = platform_get_drvdata(pdev);
2034 2021
2035 for (i = 1; i < ARRAY_SIZE(usba_ep); i++) 2022 for (i = 1; i < pdata->num_ep; i++)
2036 usba_ep_cleanup_debugfs(&usba_ep[i]); 2023 usba_ep_cleanup_debugfs(&usba_ep[i]);
2037 usba_cleanup_debugfs(udc); 2024 usba_cleanup_debugfs(udc);
2038 2025
@@ -2040,6 +2027,7 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
2040 gpio_free(udc->vbus_pin); 2027 gpio_free(udc->vbus_pin);
2041 2028
2042 free_irq(udc->irq, udc); 2029 free_irq(udc->irq, udc);
2030 kfree(usba_ep);
2043 iounmap(udc->fifo); 2031 iounmap(udc->fifo);
2044 iounmap(udc->regs); 2032 iounmap(udc->regs);
2045 clk_put(udc->hclk); 2033 clk_put(udc->hclk);
diff --git a/drivers/usb/gadget/atmel_usba_udc.h b/drivers/usb/gadget/atmel_usba_udc.h
index 08bf6f9aaf7e..f7baea307f0d 100644
--- a/drivers/usb/gadget/atmel_usba_udc.h
+++ b/drivers/usb/gadget/atmel_usba_udc.h
@@ -41,6 +41,15 @@
41#define USBA_EN_USBA (1 << 8) 41#define USBA_EN_USBA (1 << 8)
42#define USBA_DETACH (1 << 9) 42#define USBA_DETACH (1 << 9)
43#define USBA_REMOTE_WAKE_UP (1 << 10) 43#define USBA_REMOTE_WAKE_UP (1 << 10)
44#define USBA_PULLD_DIS (1 << 11)
45
46#if defined(CONFIG_AVR32)
47#define USBA_ENABLE_MASK USBA_EN_USBA
48#define USBA_DISABLE_MASK 0
49#elif defined(CONFIG_ARCH_AT91)
50#define USBA_ENABLE_MASK (USBA_EN_USBA | USBA_PULLD_DIS)
51#define USBA_DISABLE_MASK USBA_DETACH
52#endif /* CONFIG_ARCH_AT91 */
44 53
45/* Bitfields in FNUM */ 54/* Bitfields in FNUM */
46#define USBA_MICRO_FRAME_NUM_OFFSET 0 55#define USBA_MICRO_FRAME_NUM_OFFSET 0
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 46ee7f4c0912..85074cb36f38 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1033,7 +1033,7 @@ MODULE_LICENSE ("GPL");
1033#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver 1033#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver
1034#endif 1034#endif
1035 1035
1036#ifdef CONFIG_ARCH_ORION 1036#ifdef CONFIG_PLAT_ORION
1037#include "ehci-orion.c" 1037#include "ehci-orion.c"
1038#define PLATFORM_DRIVER ehci_orion_driver 1038#define PLATFORM_DRIVER ehci_orion_driver
1039#endif 1039#endif
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index e129981f139f..d187d0313742 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -11,15 +11,18 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <asm/arch/orion.h> 14#include <linux/mbus.h>
15#include <asm/plat-orion/ehci-orion.h>
15 16
16#define rdl(off) __raw_readl(hcd->regs + (off)) 17#define rdl(off) __raw_readl(hcd->regs + (off))
17#define wrl(off, val) __raw_writel((val), hcd->regs + (off)) 18#define wrl(off, val) __raw_writel((val), hcd->regs + (off))
18 19
19#define USB_CAUSE 0x310
20#define USB_MASK 0x314
21#define USB_CMD 0x140 20#define USB_CMD 0x140
22#define USB_MODE 0x1a8 21#define USB_MODE 0x1a8
22#define USB_CAUSE 0x310
23#define USB_MASK 0x314
24#define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
25#define USB_WINDOW_BASE(i) (0x324 + ((i) << 4))
23#define USB_IPG 0x360 26#define USB_IPG 0x360
24#define USB_PHY_PWR_CTRL 0x400 27#define USB_PHY_PWR_CTRL 0x400
25#define USB_PHY_TX_CTRL 0x420 28#define USB_PHY_TX_CTRL 0x420
@@ -162,8 +165,30 @@ static const struct hc_driver ehci_orion_hc_driver = {
162 .bus_resume = ehci_bus_resume, 165 .bus_resume = ehci_bus_resume,
163}; 166};
164 167
168static void __init
169ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
170 struct mbus_dram_target_info *dram)
171{
172 int i;
173
174 for (i = 0; i < 4; i++) {
175 wrl(USB_WINDOW_CTRL(i), 0);
176 wrl(USB_WINDOW_BASE(i), 0);
177 }
178
179 for (i = 0; i < dram->num_cs; i++) {
180 struct mbus_dram_window *cs = dram->cs + i;
181
182 wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) |
183 (cs->mbus_attr << 8) |
184 (dram->mbus_dram_target_id << 4) | 1);
185 wrl(USB_WINDOW_BASE(i), cs->base);
186 }
187}
188
165static int __init ehci_orion_drv_probe(struct platform_device *pdev) 189static int __init ehci_orion_drv_probe(struct platform_device *pdev)
166{ 190{
191 struct orion_ehci_data *pd = pdev->dev.platform_data;
167 struct resource *res; 192 struct resource *res;
168 struct usb_hcd *hcd; 193 struct usb_hcd *hcd;
169 struct ehci_hcd *ehci; 194 struct ehci_hcd *ehci;
@@ -227,6 +252,12 @@ static int __init ehci_orion_drv_probe(struct platform_device *pdev)
227 ehci->sbrn = 0x20; 252 ehci->sbrn = 0x20;
228 253
229 /* 254 /*
255 * (Re-)program MBUS remapping windows if we are asked to.
256 */
257 if (pd != NULL && pd->dram != NULL)
258 ehci_orion_conf_mbus_windows(hcd, pd->dram);
259
260 /*
230 * setup Orion USB controller 261 * setup Orion USB controller
231 */ 262 */
232 orion_usb_setup(hcd); 263 orion_usb_setup(hcd);
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 1cb56f2d5c84..a5e4c3545c72 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -29,7 +29,6 @@
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/workqueue.h> 30#include <linux/workqueue.h>
31#include <asm/atomic.h> 31#include <asm/atomic.h>
32#include <asm/semaphore.h>
33 32
34#define APPLE_VENDOR_ID 0x05AC 33#define APPLE_VENDOR_ID 0x05AC
35 34
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index cd3405953f74..e5ea5ef6335d 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -38,7 +38,6 @@
38#include <linux/serial.h> 38#include <linux/serial.h>
39#include <linux/ioctl.h> 39#include <linux/ioctl.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <asm/semaphore.h>
42#include <linux/usb.h> 41#include <linux/usb.h>
43#include <linux/usb/serial.h> 42#include <linux/usb/serial.h>
44 43
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index e3d241f67afc..3a3776677339 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -82,7 +82,6 @@
82#include <linux/circ_buf.h> 82#include <linux/circ_buf.h>
83#include <linux/mutex.h> 83#include <linux/mutex.h>
84#include <asm/uaccess.h> 84#include <asm/uaccess.h>
85#include <asm/semaphore.h>
86#include <linux/usb.h> 85#include <linux/usb.h>
87#include <linux/usb/serial.h> 86#include <linux/usb/serial.h>
88 87
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 97facb121c73..757651954e6c 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -45,6 +45,7 @@
45#include <asm/irq.h> 45#include <asm/irq.h>
46#include <asm/div64.h> 46#include <asm/div64.h>
47#include <asm/arch/pxa-regs.h> 47#include <asm/arch/pxa-regs.h>
48#include <asm/arch/pxa2xx-gpio.h>
48#include <asm/arch/bitfield.h> 49#include <asm/arch/bitfield.h>
49#include <asm/arch/pxafb.h> 50#include <asm/arch/pxafb.h>
50 51
diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
index 32ccd7c89c7d..35cddff7020f 100644
--- a/drivers/watchdog/sc1200wdt.c
+++ b/drivers/watchdog/sc1200wdt.c
@@ -38,8 +38,8 @@
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/pnp.h> 39#include <linux/pnp.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/semaphore.h>
41 42
42#include <asm/semaphore.h>
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
45 45