aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/asus_acpi.c4
-rw-r--r--drivers/ata/ata_piix.c1
-rw-r--r--drivers/ata/libata-core.c57
-rw-r--r--drivers/ata/libata-scsi.c34
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_ali.c3
-rw-r--r--drivers/ata/pata_it821x.c270
-rw-r--r--drivers/ata/pata_via.c64
-rw-r--r--drivers/atm/iphase.c40
-rw-r--r--drivers/base/class.c1
-rw-r--r--drivers/block/aoe/aoenet.c2
-rw-r--r--drivers/bluetooth/hci_usb.c7
-rw-r--r--drivers/cdrom/gdrom.c4
-rw-r--r--drivers/char/efirtc.c1
-rw-r--r--drivers/char/tty_ldisc.c2
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c2
-rw-r--r--drivers/hwmon/Kconfig25
-rw-r--r--drivers/hwmon/adt7473.c16
-rw-r--r--drivers/hwmon/dme1737.c297
-rw-r--r--drivers/hwmon/lm75.c282
-rw-r--r--drivers/hwmon/lm85.c672
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba7220.c2
-rw-r--r--drivers/input/keyboard/maple_keyb.c1
-rw-r--r--drivers/isdn/Makefile2
-rw-r--r--drivers/isdn/gigaset/isocdata.c5
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c37
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c2
-rw-r--r--drivers/isdn/hysdn/hysdn_pof.h2
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c6
-rw-r--r--drivers/isdn/mISDN/socket.c4
-rw-r--r--drivers/md/bitmap.c2
-rw-r--r--drivers/md/dm-table.c29
-rw-r--r--drivers/md/md.c8
-rw-r--r--drivers/md/raid10.c3
-rw-r--r--drivers/md/raid5.c29
-rw-r--r--drivers/media/video/cs5345.c2
-rw-r--r--drivers/media/video/cs53l32a.c2
-rw-r--r--drivers/media/video/mt9v022.c2
-rw-r--r--drivers/media/video/planb.c0
-rw-r--r--drivers/media/video/planb.h0
-rw-r--r--drivers/media/video/saa7196.h0
-rw-r--r--drivers/media/video/videodev.c0
-rw-r--r--drivers/misc/Kconfig2
-rw-r--r--drivers/mmc/card/block.c17
-rw-r--r--drivers/mmc/card/mmc_test.c85
-rw-r--r--drivers/mmc/core/core.c5
-rw-r--r--drivers/mmc/host/au1xmmc.c8
-rw-r--r--drivers/mmc/host/sdhci-pci.c3
-rw-r--r--drivers/mmc/host/sdhci.c15
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mtd/chips/jedec_probe.c2
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c130
-rw-r--r--drivers/mtd/maps/ipaq-flash.c2
-rw-r--r--drivers/mtd/mtdsuper.c42
-rw-r--r--drivers/mtd/nand/Kconfig13
-rw-r--r--drivers/mtd/nand/bf5xx_nand.c93
-rw-r--r--drivers/mtd/nand/diskonchip.c30
-rw-r--r--drivers/mtd/nand/fsl_elbc_nand.c2
-rw-r--r--drivers/mtd/nand/nandsim.c66
-rw-r--r--drivers/net/Kconfig4
-rw-r--r--drivers/net/bfin_mac.c111
-rw-r--r--drivers/net/cxgb3/t3_hw.c2
-rw-r--r--drivers/net/ehea/ehea_main.c4
-rw-r--r--drivers/net/enc28j60.c6
-rw-r--r--drivers/net/forcedeth.c64
-rw-r--r--drivers/net/ifb.c12
-rw-r--r--drivers/net/irda/act200l-sir.c10
-rw-r--r--drivers/net/irda/actisys-sir.c2
-rw-r--r--drivers/net/irda/ali-ircc.c246
-rw-r--r--drivers/net/irda/donauboe.c68
-rw-r--r--drivers/net/irda/girbil-sir.c12
-rw-r--r--drivers/net/irda/irda-usb.c92
-rw-r--r--drivers/net/irda/irtty-sir.c10
-rw-r--r--drivers/net/irda/kingsun-sir.c2
-rw-r--r--drivers/net/irda/litelink-sir.c8
-rw-r--r--drivers/net/irda/ma600-sir.c16
-rw-r--r--drivers/net/irda/mcp2120-sir.c12
-rw-r--r--drivers/net/irda/nsc-ircc.c119
-rw-r--r--drivers/net/irda/nsc-ircc.h3
-rw-r--r--drivers/net/irda/old_belkin-sir.c8
-rw-r--r--drivers/net/irda/sir_dev.c63
-rw-r--r--drivers/net/irda/sir_dongle.c2
-rw-r--r--drivers/net/irda/smsc-ircc2.c120
-rw-r--r--drivers/net/irda/tekram-sir.c10
-rw-r--r--drivers/net/irda/toim3232-sir.c10
-rw-r--r--drivers/net/irda/via-ircc.c80
-rw-r--r--drivers/net/irda/vlsi_ir.c92
-rw-r--r--drivers/net/irda/vlsi_ir.h2
-rw-r--r--drivers/net/irda/w83977af_ir.c62
-rw-r--r--drivers/net/mv643xx_eth.c358
-rw-r--r--drivers/net/ne.c6
-rw-r--r--drivers/net/netconsole.c2
-rw-r--r--drivers/net/s2io.c29
-rw-r--r--drivers/net/sh_eth.c202
-rw-r--r--drivers/net/sh_eth.h426
-rw-r--r--drivers/net/skfp/smt.c13
-rw-r--r--drivers/net/tg3.c67
-rw-r--r--drivers/net/tokenring/3c359.c8
-rw-r--r--drivers/net/usb/dm9601.c52
-rw-r--r--drivers/net/wd.c2
-rw-r--r--drivers/net/wireless/ipw2200.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c2
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c2
-rw-r--r--drivers/pnp/support.c96
-rw-r--r--drivers/power/Kconfig7
-rw-r--r--drivers/power/Makefile1
-rw-r--r--drivers/power/olpc_battery.c273
-rw-r--r--drivers/power/power_supply_sysfs.c1
-rw-r--r--drivers/power/tosa_battery.c486
-rw-r--r--drivers/regulator/Kconfig59
-rw-r--r--drivers/regulator/Makefile12
-rw-r--r--drivers/regulator/bq24022.c167
-rw-r--r--drivers/regulator/core.c1903
-rw-r--r--drivers/regulator/fixed.c129
-rw-r--r--drivers/regulator/virtual.c345
-rw-r--r--drivers/scsi/sd.c21
-rw-r--r--drivers/scsi/sd.h6
-rw-r--r--drivers/serial/bfin_5xx.c2
-rw-r--r--drivers/serial/crisv10.c79
-rw-r--r--drivers/serial/crisv10.h3
-rw-r--r--drivers/serial/sh-sci.h12
-rw-r--r--drivers/sh/maple/maple.c265
-rw-r--r--drivers/spi/atmel_spi.c17
-rw-r--r--drivers/spi/spi_s3c24xx.c25
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/backlight/hp680_bl.c2
-rw-r--r--drivers/video/console/.gitignore2
-rw-r--r--drivers/video/hitfb.c2
-rw-r--r--drivers/video/matrox/matroxfb_base.c2
-rw-r--r--drivers/video/pvr2fb.c6
-rw-r--r--drivers/watchdog/ar7_wdt.c29
-rw-r--r--drivers/watchdog/it8712f_wdt.c77
-rw-r--r--drivers/watchdog/s3c2410_wdt.c148
-rw-r--r--drivers/watchdog/sc1200wdt.c205
-rw-r--r--drivers/watchdog/wdt.c176
-rw-r--r--drivers/watchdog/wdt_pci.c301
138 files changed, 7070 insertions, 2656 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index 54ec5e718c0e..a280ab3d0833 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -97,3 +97,4 @@ obj-$(CONFIG_PPC_PS3) += ps3/
97obj-$(CONFIG_OF) += of/ 97obj-$(CONFIG_OF) += of/
98obj-$(CONFIG_SSB) += ssb/ 98obj-$(CONFIG_SSB) += ssb/
99obj-$(CONFIG_VIRTIO) += virtio/ 99obj-$(CONFIG_VIRTIO) += virtio/
100obj-$(CONFIG_REGULATOR) += regulator/
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index 44ad90c03c2e..d3d0886d637f 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -78,9 +78,9 @@ MODULE_LICENSE("GPL");
78static uid_t asus_uid; 78static uid_t asus_uid;
79static gid_t asus_gid; 79static gid_t asus_gid;
80module_param(asus_uid, uint, 0); 80module_param(asus_uid, uint, 0);
81MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus.\n"); 81MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus");
82module_param(asus_gid, uint, 0); 82module_param(asus_gid, uint, 0);
83MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus.\n"); 83MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus");
84 84
85/* For each model, all features implemented, 85/* For each model, all features implemented,
86 * those marked with R are relative to HOTK, A for absolute */ 86 * those marked with R are relative to HOTK, A for absolute */
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index a90ae03f56b2..c294121fd69e 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -250,6 +250,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
250 /* Mobile SATA Controller IDE (ICH8M), Apple */ 250 /* Mobile SATA Controller IDE (ICH8M), Apple */
251 { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata }, 251 { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata },
252 { 0x8086, 0x2828, 0x106b, 0x00a1, 0, 0, ich8m_apple_sata }, 252 { 0x8086, 0x2828, 0x106b, 0x00a1, 0, 0, ich8m_apple_sata },
253 { 0x8086, 0x2828, 0x106b, 0x00a3, 0, 0, ich8m_apple_sata },
253 /* Mobile SATA Controller IDE (ICH8M) */ 254 /* Mobile SATA Controller IDE (ICH8M) */
254 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 255 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
255 /* SATA Controller IDE (ICH9) */ 256 /* SATA Controller IDE (ICH9) */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9bef1a84fe3f..5ba96c5052c8 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -120,7 +120,7 @@ static char ata_force_param_buf[PAGE_SIZE] __initdata;
120module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0); 120module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0);
121MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)"); 121MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)");
122 122
123int atapi_enabled = 1; 123static int atapi_enabled = 1;
124module_param(atapi_enabled, int, 0444); 124module_param(atapi_enabled, int, 0444);
125MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); 125MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
126 126
@@ -1132,6 +1132,8 @@ void ata_id_string(const u16 *id, unsigned char *s,
1132{ 1132{
1133 unsigned int c; 1133 unsigned int c;
1134 1134
1135 BUG_ON(len & 1);
1136
1135 while (len > 0) { 1137 while (len > 0) {
1136 c = id[ofs] >> 8; 1138 c = id[ofs] >> 8;
1137 *s = c; 1139 *s = c;
@@ -1165,8 +1167,6 @@ void ata_id_c_string(const u16 *id, unsigned char *s,
1165{ 1167{
1166 unsigned char *p; 1168 unsigned char *p;
1167 1169
1168 WARN_ON(!(len & 1));
1169
1170 ata_id_string(id, s, ofs, len - 1); 1170 ata_id_string(id, s, ofs, len - 1);
1171 1171
1172 p = s + strnlen(s, len - 1); 1172 p = s + strnlen(s, len - 1);
@@ -1886,6 +1886,23 @@ static u32 ata_pio_mask_no_iordy(const struct ata_device *adev)
1886} 1886}
1887 1887
1888/** 1888/**
1889 * ata_do_dev_read_id - default ID read method
1890 * @dev: device
1891 * @tf: proposed taskfile
1892 * @id: data buffer
1893 *
1894 * Issue the identify taskfile and hand back the buffer containing
1895 * identify data. For some RAID controllers and for pre ATA devices
1896 * this function is wrapped or replaced by the driver
1897 */
1898unsigned int ata_do_dev_read_id(struct ata_device *dev,
1899 struct ata_taskfile *tf, u16 *id)
1900{
1901 return ata_exec_internal(dev, tf, NULL, DMA_FROM_DEVICE,
1902 id, sizeof(id[0]) * ATA_ID_WORDS, 0);
1903}
1904
1905/**
1889 * ata_dev_read_id - Read ID data from the specified device 1906 * ata_dev_read_id - Read ID data from the specified device
1890 * @dev: target device 1907 * @dev: target device
1891 * @p_class: pointer to class of the target device (may be changed) 1908 * @p_class: pointer to class of the target device (may be changed)
@@ -1920,7 +1937,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1920 if (ata_msg_ctl(ap)) 1937 if (ata_msg_ctl(ap))
1921 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 1938 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
1922 1939
1923 retry: 1940retry:
1924 ata_tf_init(dev, &tf); 1941 ata_tf_init(dev, &tf);
1925 1942
1926 switch (class) { 1943 switch (class) {
@@ -1948,8 +1965,11 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1948 */ 1965 */
1949 tf.flags |= ATA_TFLAG_POLLING; 1966 tf.flags |= ATA_TFLAG_POLLING;
1950 1967
1951 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, 1968 if (ap->ops->read_id)
1952 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 1969 err_mask = ap->ops->read_id(dev, &tf, id);
1970 else
1971 err_mask = ata_do_dev_read_id(dev, &tf, id);
1972
1953 if (err_mask) { 1973 if (err_mask) {
1954 if (err_mask & AC_ERR_NODEV_HINT) { 1974 if (err_mask & AC_ERR_NODEV_HINT) {
1955 ata_dev_printk(dev, KERN_DEBUG, 1975 ata_dev_printk(dev, KERN_DEBUG,
@@ -2142,6 +2162,16 @@ int ata_dev_configure(struct ata_device *dev)
2142 return 0; 2162 return 0;
2143 } 2163 }
2144 2164
2165 if ((!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) &&
2166 dev->class == ATA_DEV_ATAPI) {
2167 ata_dev_printk(dev, KERN_WARNING,
2168 "WARNING: ATAPI is %s, device ignored.\n",
2169 atapi_enabled ? "not supported with this driver"
2170 : "disabled");
2171 ata_dev_disable(dev);
2172 return 0;
2173 }
2174
2145 /* let ACPI work its magic */ 2175 /* let ACPI work its magic */
2146 rc = ata_acpi_on_devcfg(dev); 2176 rc = ata_acpi_on_devcfg(dev);
2147 if (rc) 2177 if (rc)
@@ -6088,16 +6118,20 @@ static int __init ata_init(void)
6088 6118
6089 ata_wq = create_workqueue("ata"); 6119 ata_wq = create_workqueue("ata");
6090 if (!ata_wq) 6120 if (!ata_wq)
6091 return -ENOMEM; 6121 goto free_force_tbl;
6092 6122
6093 ata_aux_wq = create_singlethread_workqueue("ata_aux"); 6123 ata_aux_wq = create_singlethread_workqueue("ata_aux");
6094 if (!ata_aux_wq) { 6124 if (!ata_aux_wq)
6095 destroy_workqueue(ata_wq); 6125 goto free_wq;
6096 return -ENOMEM;
6097 }
6098 6126
6099 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n"); 6127 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
6100 return 0; 6128 return 0;
6129
6130free_wq:
6131 destroy_workqueue(ata_wq);
6132free_force_tbl:
6133 kfree(ata_force_tbl);
6134 return -ENOMEM;
6101} 6135}
6102 6136
6103static void __exit ata_exit(void) 6137static void __exit ata_exit(void)
@@ -6269,6 +6303,7 @@ EXPORT_SYMBOL_GPL(ata_host_resume);
6269#endif /* CONFIG_PM */ 6303#endif /* CONFIG_PM */
6270EXPORT_SYMBOL_GPL(ata_id_string); 6304EXPORT_SYMBOL_GPL(ata_id_string);
6271EXPORT_SYMBOL_GPL(ata_id_c_string); 6305EXPORT_SYMBOL_GPL(ata_id_c_string);
6306EXPORT_SYMBOL_GPL(ata_do_dev_read_id);
6272EXPORT_SYMBOL_GPL(ata_scsi_simulate); 6307EXPORT_SYMBOL_GPL(ata_scsi_simulate);
6273 6308
6274EXPORT_SYMBOL_GPL(ata_pio_need_iordy); 6309EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index f3b4b15a8dc4..b9d3ba423cb2 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2551,36 +2551,6 @@ static struct ata_device *__ata_scsi_find_dev(struct ata_port *ap,
2551} 2551}
2552 2552
2553/** 2553/**
2554 * ata_scsi_dev_enabled - determine if device is enabled
2555 * @dev: ATA device
2556 *
2557 * Determine if commands should be sent to the specified device.
2558 *
2559 * LOCKING:
2560 * spin_lock_irqsave(host lock)
2561 *
2562 * RETURNS:
2563 * 0 if commands are not allowed / 1 if commands are allowed
2564 */
2565
2566static int ata_scsi_dev_enabled(struct ata_device *dev)
2567{
2568 if (unlikely(!ata_dev_enabled(dev)))
2569 return 0;
2570
2571 if (!atapi_enabled || (dev->link->ap->flags & ATA_FLAG_NO_ATAPI)) {
2572 if (unlikely(dev->class == ATA_DEV_ATAPI)) {
2573 ata_dev_printk(dev, KERN_WARNING,
2574 "WARNING: ATAPI is %s, device ignored.\n",
2575 atapi_enabled ? "not supported with this driver" : "disabled");
2576 return 0;
2577 }
2578 }
2579
2580 return 1;
2581}
2582
2583/**
2584 * ata_scsi_find_dev - lookup ata_device from scsi_cmnd 2554 * ata_scsi_find_dev - lookup ata_device from scsi_cmnd
2585 * @ap: ATA port to which the device is attached 2555 * @ap: ATA port to which the device is attached
2586 * @scsidev: SCSI device from which we derive the ATA device 2556 * @scsidev: SCSI device from which we derive the ATA device
@@ -2601,7 +2571,7 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
2601{ 2571{
2602 struct ata_device *dev = __ata_scsi_find_dev(ap, scsidev); 2572 struct ata_device *dev = __ata_scsi_find_dev(ap, scsidev);
2603 2573
2604 if (unlikely(!dev || !ata_scsi_dev_enabled(dev))) 2574 if (unlikely(!dev || !ata_dev_enabled(dev)))
2605 return NULL; 2575 return NULL;
2606 2576
2607 return dev; 2577 return dev;
@@ -3622,7 +3592,7 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
3622 3592
3623 ata_scsi_dump_cdb(ap, cmd); 3593 ata_scsi_dump_cdb(ap, cmd);
3624 3594
3625 if (likely(ata_scsi_dev_enabled(ap->link.device))) 3595 if (likely(ata_dev_enabled(ap->link.device)))
3626 rc = __ata_scsi_queuecmd(cmd, done, ap->link.device); 3596 rc = __ata_scsi_queuecmd(cmd, done, ap->link.device);
3627 else { 3597 else {
3628 cmd->result = (DID_BAD_TARGET << 16); 3598 cmd->result = (DID_BAD_TARGET << 16);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index f6f9c28ec7f8..ade5c75b6144 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -66,7 +66,6 @@ enum {
66 66
67extern unsigned int ata_print_id; 67extern unsigned int ata_print_id;
68extern struct workqueue_struct *ata_aux_wq; 68extern struct workqueue_struct *ata_aux_wq;
69extern int atapi_enabled;
70extern int atapi_passthru16; 69extern int atapi_passthru16;
71extern int libata_fua; 70extern int libata_fua;
72extern int libata_noacpi; 71extern int libata_noacpi;
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 0f3e659db99a..5ca70fa1f587 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -550,8 +550,9 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
550 pci_read_config_byte(isa_bridge, 0x5E, &tmp); 550 pci_read_config_byte(isa_bridge, 0x5E, &tmp);
551 if ((tmp & 0x1E) == 0x12) 551 if ((tmp & 0x1E) == 0x12)
552 ppi[0] = &info_20_udma; 552 ppi[0] = &info_20_udma;
553 pci_dev_put(isa_bridge);
554 } 553 }
554 pci_dev_put(isa_bridge);
555
555 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL); 556 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL);
556} 557}
557 558
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index e10816931b2f..27843c70eb9d 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -80,7 +80,7 @@
80 80
81 81
82#define DRV_NAME "pata_it821x" 82#define DRV_NAME "pata_it821x"
83#define DRV_VERSION "0.3.8" 83#define DRV_VERSION "0.4.0"
84 84
85struct it821x_dev 85struct it821x_dev
86{ 86{
@@ -425,6 +425,8 @@ static unsigned int it821x_smart_qc_issue(struct ata_queued_cmd *qc)
425 case ATA_CMD_WRITE_MULTI: 425 case ATA_CMD_WRITE_MULTI:
426 case ATA_CMD_WRITE_MULTI_EXT: 426 case ATA_CMD_WRITE_MULTI_EXT:
427 case ATA_CMD_ID_ATA: 427 case ATA_CMD_ID_ATA:
428 case ATA_CMD_INIT_DEV_PARAMS:
429 case 0xFC: /* Internal 'report rebuild state' */
428 /* Arguably should just no-op this one */ 430 /* Arguably should just no-op this one */
429 case ATA_CMD_SET_FEATURES: 431 case ATA_CMD_SET_FEATURES:
430 return ata_sff_qc_issue(qc); 432 return ata_sff_qc_issue(qc);
@@ -509,7 +511,7 @@ static void it821x_dev_config(struct ata_device *adev)
509 511
510 if (strstr(model_num, "Integrated Technology Express")) { 512 if (strstr(model_num, "Integrated Technology Express")) {
511 /* RAID mode */ 513 /* RAID mode */
512 printk(KERN_INFO "IT821x %sRAID%d volume", 514 ata_dev_printk(adev, KERN_INFO, "%sRAID%d volume",
513 adev->id[147]?"Bootable ":"", 515 adev->id[147]?"Bootable ":"",
514 adev->id[129]); 516 adev->id[129]);
515 if (adev->id[129] != 1) 517 if (adev->id[129] != 1)
@@ -519,37 +521,51 @@ static void it821x_dev_config(struct ata_device *adev)
519 /* This is a controller firmware triggered funny, don't 521 /* This is a controller firmware triggered funny, don't
520 report the drive faulty! */ 522 report the drive faulty! */
521 adev->horkage &= ~ATA_HORKAGE_DIAGNOSTIC; 523 adev->horkage &= ~ATA_HORKAGE_DIAGNOSTIC;
524 /* No HPA in 'smart' mode */
525 adev->horkage |= ATA_HORKAGE_BROKEN_HPA;
522} 526}
523 527
524/** 528/**
525 * it821x_ident_hack - Hack identify data up 529 * it821x_read_id - Hack identify data up
526 * @ap: Port 530 * @adev: device to read
531 * @tf: proposed taskfile
532 * @id: buffer for returned ident data
527 * 533 *
528 * Walk the devices on this firmware driven port and slightly 534 * Query the devices on this firmware driven port and slightly
529 * mash the identify data to stop us and common tools trying to 535 * mash the identify data to stop us and common tools trying to
530 * use features not firmware supported. The firmware itself does 536 * use features not firmware supported. The firmware itself does
531 * some masking (eg SMART) but not enough. 537 * some masking (eg SMART) but not enough.
532 *
533 * This is a bit of an abuse of the cable method, but it is the
534 * only method called at the right time. We could modify the libata
535 * core specifically for ident hacking but while we have one offender
536 * it seems better to keep the fallout localised.
537 */ 538 */
538 539
539static int it821x_ident_hack(struct ata_port *ap) 540static unsigned int it821x_read_id(struct ata_device *adev,
541 struct ata_taskfile *tf, u16 *id)
540{ 542{
541 struct ata_device *adev; 543 unsigned int err_mask;
542 ata_link_for_each_dev(adev, &ap->link) { 544 unsigned char model_num[ATA_ID_PROD_LEN + 1];
543 if (ata_dev_enabled(adev)) { 545
544 adev->id[84] &= ~(1 << 6); /* No FUA */ 546 err_mask = ata_do_dev_read_id(adev, tf, id);
545 adev->id[85] &= ~(1 << 10); /* No HPA */ 547 if (err_mask)
546 adev->id[76] = 0; /* No NCQ/AN etc */ 548 return err_mask;
547 } 549 ata_id_c_string(id, model_num, ATA_ID_PROD, sizeof(model_num));
550
551 id[83] &= ~(1 << 12); /* Cache flush is firmware handled */
552 id[83] &= ~(1 << 13); /* Ditto for LBA48 flushes */
553 id[84] &= ~(1 << 6); /* No FUA */
554 id[85] &= ~(1 << 10); /* No HPA */
555 id[76] = 0; /* No NCQ/AN etc */
556
557 if (strstr(model_num, "Integrated Technology Express")) {
558 /* Set feature bits the firmware neglects */
559 id[49] |= 0x0300; /* LBA, DMA */
560 id[82] |= 0x0400; /* LBA48 */
561 id[83] &= 0x7FFF;
562 id[83] |= 0x4000; /* Word 83 is valid */
563 id[86] |= 0x0400; /* LBA48 on */
564 id[ATA_ID_MAJOR_VER] |= 0x1F;
548 } 565 }
549 return ata_cable_unknown(ap); 566 return err_mask;
550} 567}
551 568
552
553/** 569/**
554 * it821x_check_atapi_dma - ATAPI DMA handler 570 * it821x_check_atapi_dma - ATAPI DMA handler
555 * @qc: Command we are about to issue 571 * @qc: Command we are about to issue
@@ -577,6 +593,136 @@ static int it821x_check_atapi_dma(struct ata_queued_cmd *qc)
577 return 0; 593 return 0;
578} 594}
579 595
596/**
597 * it821x_display_disk - display disk setup
598 * @n: Device number
599 * @buf: Buffer block from firmware
600 *
601 * Produce a nice informative display of the device setup as provided
602 * by the firmware.
603 */
604
605static void it821x_display_disk(int n, u8 *buf)
606{
607 unsigned char id[41];
608 int mode = 0;
609 char *mtype;
610 char mbuf[8];
611 char *cbl = "(40 wire cable)";
612
613 static const char *types[5] = {
614 "RAID0", "RAID1" "RAID 0+1", "JBOD", "DISK"
615 };
616
617 if (buf[52] > 4) /* No Disk */
618 return;
619
620 ata_id_c_string((u16 *)buf, id, 0, 41);
621
622 if (buf[51]) {
623 mode = ffs(buf[51]);
624 mtype = "UDMA";
625 } else if (buf[49]) {
626 mode = ffs(buf[49]);
627 mtype = "MWDMA";
628 }
629
630 if (buf[76])
631 cbl = "";
632
633 if (mode)
634 snprintf(mbuf, 8, "%5s%d", mtype, mode - 1);
635 else
636 strcpy(mbuf, "PIO");
637 if (buf[52] == 4)
638 printk(KERN_INFO "%d: %-6s %-8s %s %s\n",
639 n, mbuf, types[buf[52]], id, cbl);
640 else
641 printk(KERN_INFO "%d: %-6s %-8s Volume: %1d %s %s\n",
642 n, mbuf, types[buf[52]], buf[53], id, cbl);
643 if (buf[125] < 100)
644 printk(KERN_INFO "%d: Rebuilding: %d%%\n", n, buf[125]);
645}
646
647/**
648 * it821x_firmware_command - issue firmware command
649 * @ap: IT821x port to interrogate
650 * @cmd: command
651 * @len: length
652 *
653 * Issue firmware commands expecting data back from the controller. We
654 * use this to issue commands that do not go via the normal paths. Other
655 * commands such as 0xFC can be issued normally.
656 */
657
658static u8 *it821x_firmware_command(struct ata_port *ap, u8 cmd, int len)
659{
660 u8 status;
661 int n = 0;
662 u16 *buf = kmalloc(len, GFP_KERNEL);
663 if (buf == NULL) {
664 printk(KERN_ERR "it821x_firmware_command: Out of memory\n");
665 return NULL;
666 }
667 /* This isn't quite a normal ATA command as we are talking to the
668 firmware not the drives */
669 ap->ctl |= ATA_NIEN;
670 iowrite8(ap->ctl, ap->ioaddr.ctl_addr);
671 ata_wait_idle(ap);
672 iowrite8(ATA_DEVICE_OBS, ap->ioaddr.device_addr);
673 iowrite8(cmd, ap->ioaddr.command_addr);
674 udelay(1);
675 /* This should be almost immediate but a little paranoia goes a long
676 way. */
677 while(n++ < 10) {
678 status = ioread8(ap->ioaddr.status_addr);
679 if (status & ATA_ERR) {
680 kfree(buf);
681 printk(KERN_ERR "it821x_firmware_command: rejected\n");
682 return NULL;
683 }
684 if (status & ATA_DRQ) {
685 ioread16_rep(ap->ioaddr.data_addr, buf, len/2);
686 return (u8 *)buf;
687 }
688 mdelay(1);
689 }
690 kfree(buf);
691 printk(KERN_ERR "it821x_firmware_command: timeout\n");
692 return NULL;
693}
694
695/**
696 * it821x_probe_firmware - firmware reporting/setup
697 * @ap: IT821x port being probed
698 *
699 * Probe the firmware of the controller by issuing firmware command
700 * 0xFA and analysing the returned data.
701 */
702
703static void it821x_probe_firmware(struct ata_port *ap)
704{
705 u8 *buf;
706 int i;
707
708 /* This is a bit ugly as we can't just issue a task file to a device
709 as this is controller magic */
710
711 buf = it821x_firmware_command(ap, 0xFA, 512);
712
713 if (buf != NULL) {
714 printk(KERN_INFO "pata_it821x: Firmware %02X/%02X/%02X%02X\n",
715 buf[505],
716 buf[506],
717 buf[507],
718 buf[508]);
719 for (i = 0; i < 4; i++)
720 it821x_display_disk(i, buf + 128 * i);
721 kfree(buf);
722 }
723}
724
725
580 726
581/** 727/**
582 * it821x_port_start - port setup 728 * it821x_port_start - port setup
@@ -610,6 +756,8 @@ static int it821x_port_start(struct ata_port *ap)
610 /* Long I/O's although allowed in LBA48 space cause the 756 /* Long I/O's although allowed in LBA48 space cause the
611 onboard firmware to enter the twighlight zone */ 757 onboard firmware to enter the twighlight zone */
612 /* No ATAPI DMA in this mode either */ 758 /* No ATAPI DMA in this mode either */
759 if (ap->port_no == 0)
760 it821x_probe_firmware(ap);
613 } 761 }
614 /* Pull the current clocks from 0x50 */ 762 /* Pull the current clocks from 0x50 */
615 if (conf & (1 << (1 + ap->port_no))) 763 if (conf & (1 << (1 + ap->port_no)))
@@ -631,6 +779,25 @@ static int it821x_port_start(struct ata_port *ap)
631 return 0; 779 return 0;
632} 780}
633 781
782/**
783 * it821x_rdc_cable - Cable detect for RDC1010
784 * @ap: port we are checking
785 *
786 * Return the RDC1010 cable type. Unlike the IT821x we know how to do
787 * this and can do host side cable detect
788 */
789
790static int it821x_rdc_cable(struct ata_port *ap)
791{
792 u16 r40;
793 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
794
795 pci_read_config_word(pdev, 0x40, &r40);
796 if (r40 & (1 << (2 + ap->port_no)))
797 return ATA_CBL_PATA40;
798 return ATA_CBL_PATA80;
799}
800
634static struct scsi_host_template it821x_sht = { 801static struct scsi_host_template it821x_sht = {
635 ATA_BMDMA_SHT(DRV_NAME), 802 ATA_BMDMA_SHT(DRV_NAME),
636}; 803};
@@ -641,9 +808,10 @@ static struct ata_port_operations it821x_smart_port_ops = {
641 .check_atapi_dma= it821x_check_atapi_dma, 808 .check_atapi_dma= it821x_check_atapi_dma,
642 .qc_issue = it821x_smart_qc_issue, 809 .qc_issue = it821x_smart_qc_issue,
643 810
644 .cable_detect = it821x_ident_hack, 811 .cable_detect = ata_cable_80wire,
645 .set_mode = it821x_smart_set_mode, 812 .set_mode = it821x_smart_set_mode,
646 .dev_config = it821x_dev_config, 813 .dev_config = it821x_dev_config,
814 .read_id = it821x_read_id,
647 815
648 .port_start = it821x_port_start, 816 .port_start = it821x_port_start,
649}; 817};
@@ -664,8 +832,29 @@ static struct ata_port_operations it821x_passthru_port_ops = {
664 .port_start = it821x_port_start, 832 .port_start = it821x_port_start,
665}; 833};
666 834
835static struct ata_port_operations it821x_rdc_port_ops = {
836 .inherits = &ata_bmdma_port_ops,
837
838 .check_atapi_dma= it821x_check_atapi_dma,
839 .sff_dev_select = it821x_passthru_dev_select,
840 .bmdma_start = it821x_passthru_bmdma_start,
841 .bmdma_stop = it821x_passthru_bmdma_stop,
842 .qc_issue = it821x_passthru_qc_issue,
843
844 .cable_detect = it821x_rdc_cable,
845 .set_piomode = it821x_passthru_set_piomode,
846 .set_dmamode = it821x_passthru_set_dmamode,
847
848 .port_start = it821x_port_start,
849};
850
667static void it821x_disable_raid(struct pci_dev *pdev) 851static void it821x_disable_raid(struct pci_dev *pdev)
668{ 852{
853 /* Neither the RDC nor the IT8211 */
854 if (pdev->vendor != PCI_VENDOR_ID_ITE ||
855 pdev->device != PCI_DEVICE_ID_ITE_8212)
856 return;
857
669 /* Reset local CPU, and set BIOS not ready */ 858 /* Reset local CPU, and set BIOS not ready */
670 pci_write_config_byte(pdev, 0x5E, 0x01); 859 pci_write_config_byte(pdev, 0x5E, 0x01);
671 860
@@ -690,6 +879,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
690 .flags = ATA_FLAG_SLAVE_POSS, 879 .flags = ATA_FLAG_SLAVE_POSS,
691 .pio_mask = 0x1f, 880 .pio_mask = 0x1f,
692 .mwdma_mask = 0x07, 881 .mwdma_mask = 0x07,
882 .udma_mask = ATA_UDMA6,
693 .port_ops = &it821x_smart_port_ops 883 .port_ops = &it821x_smart_port_ops
694 }; 884 };
695 static const struct ata_port_info info_passthru = { 885 static const struct ata_port_info info_passthru = {
@@ -699,6 +889,13 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
699 .udma_mask = ATA_UDMA6, 889 .udma_mask = ATA_UDMA6,
700 .port_ops = &it821x_passthru_port_ops 890 .port_ops = &it821x_passthru_port_ops
701 }; 891 };
892 static const struct ata_port_info info_rdc = {
893 .flags = ATA_FLAG_SLAVE_POSS,
894 .pio_mask = 0x1f,
895 .mwdma_mask = 0x07,
896 /* No UDMA */
897 .port_ops = &it821x_rdc_port_ops
898 };
702 899
703 const struct ata_port_info *ppi[] = { NULL, NULL }; 900 const struct ata_port_info *ppi[] = { NULL, NULL };
704 static char *mode[2] = { "pass through", "smart" }; 901 static char *mode[2] = { "pass through", "smart" };
@@ -707,21 +904,25 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
707 rc = pcim_enable_device(pdev); 904 rc = pcim_enable_device(pdev);
708 if (rc) 905 if (rc)
709 return rc; 906 return rc;
907
908 if (pdev->vendor == PCI_VENDOR_ID_RDC) {
909 ppi[0] = &info_rdc;
910 } else {
911 /* Force the card into bypass mode if so requested */
912 if (it8212_noraid) {
913 printk(KERN_INFO DRV_NAME ": forcing bypass mode.\n");
914 it821x_disable_raid(pdev);
915 }
916 pci_read_config_byte(pdev, 0x50, &conf);
917 conf &= 1;
710 918
711 /* Force the card into bypass mode if so requested */ 919 printk(KERN_INFO DRV_NAME": controller in %s mode.\n",
712 if (it8212_noraid) { 920 mode[conf]);
713 printk(KERN_INFO DRV_NAME ": forcing bypass mode.\n"); 921 if (conf == 0)
714 it821x_disable_raid(pdev); 922 ppi[0] = &info_passthru;
923 else
924 ppi[0] = &info_smart;
715 } 925 }
716 pci_read_config_byte(pdev, 0x50, &conf);
717 conf &= 1;
718
719 printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]);
720 if (conf == 0)
721 ppi[0] = &info_passthru;
722 else
723 ppi[0] = &info_smart;
724
725 return ata_pci_sff_init_one(pdev, ppi, &it821x_sht, NULL); 926 return ata_pci_sff_init_one(pdev, ppi, &it821x_sht, NULL);
726} 927}
727 928
@@ -745,6 +946,7 @@ static int it821x_reinit_one(struct pci_dev *pdev)
745static const struct pci_device_id it821x[] = { 946static const struct pci_device_id it821x[] = {
746 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), }, 947 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), },
747 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), }, 948 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), },
949 { PCI_VDEVICE(RDC, 0x1010), },
748 950
749 { }, 951 { },
750}; 952};
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 708ed144ede9..57d951b11f2d 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -98,7 +98,8 @@ static const struct via_isa_bridge {
98 u8 rev_max; 98 u8 rev_max;
99 u16 flags; 99 u16 flags;
100} via_isa_bridges[] = { 100} via_isa_bridges[] = {
101 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 101 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 |
102 VIA_BAD_AST | VIA_SATA_PATA },
102 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 103 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
103 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 104 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
104 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA }, 105 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA },
@@ -322,6 +323,65 @@ static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev)
322 via_do_set_mode(ap, adev, adev->dma_mode, tclock[mode], set_ast, udma[mode]); 323 via_do_set_mode(ap, adev, adev->dma_mode, tclock[mode], set_ast, udma[mode]);
323} 324}
324 325
326/**
327 * via_ata_sff_tf_load - send taskfile registers to host controller
328 * @ap: Port to which output is sent
329 * @tf: ATA taskfile register set
330 *
331 * Outputs ATA taskfile to standard ATA host controller.
332 *
333 * Note: This is to fix the internal bug of via chipsets, which
334 * will reset the device register after changing the IEN bit on
335 * ctl register
336 */
337static void via_ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
338{
339 struct ata_ioports *ioaddr = &ap->ioaddr;
340 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
341
342 if (tf->ctl != ap->last_ctl) {
343 iowrite8(tf->ctl, ioaddr->ctl_addr);
344 iowrite8(tf->device, ioaddr->device_addr);
345 ap->last_ctl = tf->ctl;
346 ata_wait_idle(ap);
347 }
348
349 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
350 iowrite8(tf->hob_feature, ioaddr->feature_addr);
351 iowrite8(tf->hob_nsect, ioaddr->nsect_addr);
352 iowrite8(tf->hob_lbal, ioaddr->lbal_addr);
353 iowrite8(tf->hob_lbam, ioaddr->lbam_addr);
354 iowrite8(tf->hob_lbah, ioaddr->lbah_addr);
355 VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
356 tf->hob_feature,
357 tf->hob_nsect,
358 tf->hob_lbal,
359 tf->hob_lbam,
360 tf->hob_lbah);
361 }
362
363 if (is_addr) {
364 iowrite8(tf->feature, ioaddr->feature_addr);
365 iowrite8(tf->nsect, ioaddr->nsect_addr);
366 iowrite8(tf->lbal, ioaddr->lbal_addr);
367 iowrite8(tf->lbam, ioaddr->lbam_addr);
368 iowrite8(tf->lbah, ioaddr->lbah_addr);
369 VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n",
370 tf->feature,
371 tf->nsect,
372 tf->lbal,
373 tf->lbam,
374 tf->lbah);
375 }
376
377 if (tf->flags & ATA_TFLAG_DEVICE) {
378 iowrite8(tf->device, ioaddr->device_addr);
379 VPRINTK("device 0x%X\n", tf->device);
380 }
381
382 ata_wait_idle(ap);
383}
384
325static struct scsi_host_template via_sht = { 385static struct scsi_host_template via_sht = {
326 ATA_BMDMA_SHT(DRV_NAME), 386 ATA_BMDMA_SHT(DRV_NAME),
327}; 387};
@@ -332,11 +392,13 @@ static struct ata_port_operations via_port_ops = {
332 .set_piomode = via_set_piomode, 392 .set_piomode = via_set_piomode,
333 .set_dmamode = via_set_dmamode, 393 .set_dmamode = via_set_dmamode,
334 .prereset = via_pre_reset, 394 .prereset = via_pre_reset,
395 .sff_tf_load = via_ata_tf_load,
335}; 396};
336 397
337static struct ata_port_operations via_port_ops_noirq = { 398static struct ata_port_operations via_port_ops_noirq = {
338 .inherits = &via_port_ops, 399 .inherits = &via_port_ops,
339 .sff_data_xfer = ata_sff_data_xfer_noirq, 400 .sff_data_xfer = ata_sff_data_xfer_noirq,
401 .sff_tf_load = via_ata_tf_load,
340}; 402};
341 403
342/** 404/**
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 24df73ad326d..088885ed51b9 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -156,8 +156,8 @@ static void ia_hack_tcq(IADEV *dev) {
156 } 156 }
157 iavcc_r->vc_desc_cnt--; 157 iavcc_r->vc_desc_cnt--;
158 dev->desc_tbl[desc1 -1].timestamp = 0; 158 dev->desc_tbl[desc1 -1].timestamp = 0;
159 IF_EVENT(printk("ia_hack: return_q skb = 0x%x desc = %d\n", 159 IF_EVENT(printk("ia_hack: return_q skb = 0x%p desc = %d\n",
160 (u32)dev->desc_tbl[desc1 -1].txskb, desc1);) 160 dev->desc_tbl[desc1 -1].txskb, desc1);)
161 if (iavcc_r->pcr < dev->rate_limit) { 161 if (iavcc_r->pcr < dev->rate_limit) {
162 IA_SKB_STATE (dev->desc_tbl[desc1-1].txskb) |= IA_TX_DONE; 162 IA_SKB_STATE (dev->desc_tbl[desc1-1].txskb) |= IA_TX_DONE;
163 if (ia_enque_rtn_q(&dev->tx_return_q, dev->desc_tbl[desc1 -1]) < 0) 163 if (ia_enque_rtn_q(&dev->tx_return_q, dev->desc_tbl[desc1 -1]) < 0)
@@ -527,8 +527,8 @@ static int ia_cbr_setup (IADEV *dev, struct atm_vcc *vcc) {
527 inc = 0; 527 inc = 0;
528 testSlot = idealSlot; 528 testSlot = idealSlot;
529 TstSchedTbl = (u16*)(SchedTbl+testSlot); //set index and read in value 529 TstSchedTbl = (u16*)(SchedTbl+testSlot); //set index and read in value
530 IF_CBR(printk("CBR Testslot 0x%x AT Location 0x%x, NumToAssign=%d\n", 530 IF_CBR(printk("CBR Testslot 0x%x AT Location 0x%p, NumToAssign=%d\n",
531 testSlot, (u32)TstSchedTbl,toBeAssigned);) 531 testSlot, TstSchedTbl,toBeAssigned);)
532 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC)); 532 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC));
533 while (cbrVC) // If another VC at this location, we have to keep looking 533 while (cbrVC) // If another VC at this location, we have to keep looking
534 { 534 {
@@ -536,8 +536,8 @@ static int ia_cbr_setup (IADEV *dev, struct atm_vcc *vcc) {
536 testSlot = idealSlot - inc; 536 testSlot = idealSlot - inc;
537 if (testSlot < 0) { // Wrap if necessary 537 if (testSlot < 0) { // Wrap if necessary
538 testSlot += dev->CbrTotEntries; 538 testSlot += dev->CbrTotEntries;
539 IF_CBR(printk("Testslot Wrap. STable Start=0x%x,Testslot=%d\n", 539 IF_CBR(printk("Testslot Wrap. STable Start=0x%p,Testslot=%d\n",
540 (u32)SchedTbl,testSlot);) 540 SchedTbl,testSlot);)
541 } 541 }
542 TstSchedTbl = (u16 *)(SchedTbl + testSlot); // set table index 542 TstSchedTbl = (u16 *)(SchedTbl + testSlot); // set table index
543 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC)); 543 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC));
@@ -552,8 +552,8 @@ static int ia_cbr_setup (IADEV *dev, struct atm_vcc *vcc) {
552 } 552 }
553 // set table index and read in value 553 // set table index and read in value
554 TstSchedTbl = (u16*)(SchedTbl + testSlot); 554 TstSchedTbl = (u16*)(SchedTbl + testSlot);
555 IF_CBR(printk("Reading CBR Tbl from 0x%x, CbrVal=0x%x Iteration %d\n", 555 IF_CBR(printk("Reading CBR Tbl from 0x%p, CbrVal=0x%x Iteration %d\n",
556 (u32)TstSchedTbl,cbrVC,inc);) 556 TstSchedTbl,cbrVC,inc);)
557 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC)); 557 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC));
558 } /* while */ 558 } /* while */
559 // Move this VCI number into this location of the CBR Sched table. 559 // Move this VCI number into this location of the CBR Sched table.
@@ -1427,11 +1427,11 @@ static int rx_init(struct atm_dev *dev)
1427 /* We know this is 32bit bus addressed so the following is safe */ 1427 /* We know this is 32bit bus addressed so the following is safe */
1428 writel(iadev->rx_dle_dma & 0xfffff000, 1428 writel(iadev->rx_dle_dma & 0xfffff000,
1429 iadev->dma + IPHASE5575_RX_LIST_ADDR); 1429 iadev->dma + IPHASE5575_RX_LIST_ADDR);
1430 IF_INIT(printk("Tx Dle list addr: 0x%08x value: 0x%0x\n", 1430 IF_INIT(printk("Tx Dle list addr: 0x%p value: 0x%0x\n",
1431 (u32)(iadev->dma+IPHASE5575_TX_LIST_ADDR), 1431 iadev->dma+IPHASE5575_TX_LIST_ADDR,
1432 *(u32*)(iadev->dma+IPHASE5575_TX_LIST_ADDR)); 1432 *(u32*)(iadev->dma+IPHASE5575_TX_LIST_ADDR));
1433 printk("Rx Dle list addr: 0x%08x value: 0x%0x\n", 1433 printk("Rx Dle list addr: 0x%p value: 0x%0x\n",
1434 (u32)(iadev->dma+IPHASE5575_RX_LIST_ADDR), 1434 iadev->dma+IPHASE5575_RX_LIST_ADDR,
1435 *(u32*)(iadev->dma+IPHASE5575_RX_LIST_ADDR));) 1435 *(u32*)(iadev->dma+IPHASE5575_RX_LIST_ADDR));)
1436 1436
1437 writew(0xffff, iadev->reass_reg+REASS_MASK_REG); 1437 writew(0xffff, iadev->reass_reg+REASS_MASK_REG);
@@ -1470,7 +1470,7 @@ static int rx_init(struct atm_dev *dev)
1470 buf_desc_ptr++; 1470 buf_desc_ptr++;
1471 rx_pkt_start += iadev->rx_buf_sz; 1471 rx_pkt_start += iadev->rx_buf_sz;
1472 } 1472 }
1473 IF_INIT(printk("Rx Buffer desc ptr: 0x%0x\n", (u32)(buf_desc_ptr));) 1473 IF_INIT(printk("Rx Buffer desc ptr: 0x%p\n", buf_desc_ptr);)
1474 i = FREE_BUF_DESC_Q*iadev->memSize; 1474 i = FREE_BUF_DESC_Q*iadev->memSize;
1475 writew(i >> 16, iadev->reass_reg+REASS_QUEUE_BASE); 1475 writew(i >> 16, iadev->reass_reg+REASS_QUEUE_BASE);
1476 writew(i, iadev->reass_reg+FREEQ_ST_ADR); 1476 writew(i, iadev->reass_reg+FREEQ_ST_ADR);
@@ -1487,7 +1487,7 @@ static int rx_init(struct atm_dev *dev)
1487 *freeq_start = (u_short)i; 1487 *freeq_start = (u_short)i;
1488 freeq_start++; 1488 freeq_start++;
1489 } 1489 }
1490 IF_INIT(printk("freeq_start: 0x%0x\n", (u32)freeq_start);) 1490 IF_INIT(printk("freeq_start: 0x%p\n", freeq_start);)
1491 /* Packet Complete Queue */ 1491 /* Packet Complete Queue */
1492 i = (PKT_COMP_Q * iadev->memSize) & 0xffff; 1492 i = (PKT_COMP_Q * iadev->memSize) & 0xffff;
1493 writew(i, iadev->reass_reg+PCQ_ST_ADR); 1493 writew(i, iadev->reass_reg+PCQ_ST_ADR);
@@ -1713,7 +1713,7 @@ static void tx_dle_intr(struct atm_dev *dev)
1713 IA_SKB_STATE(skb) |= IA_DLED; 1713 IA_SKB_STATE(skb) |= IA_DLED;
1714 skb_queue_tail(&iavcc->txing_skb, skb); 1714 skb_queue_tail(&iavcc->txing_skb, skb);
1715 } 1715 }
1716 IF_EVENT(printk("tx_dle_intr: enque skb = 0x%x \n", (u32)skb);) 1716 IF_EVENT(printk("tx_dle_intr: enque skb = 0x%p \n", skb);)
1717 if (++dle == iadev->tx_dle_q.end) 1717 if (++dle == iadev->tx_dle_q.end)
1718 dle = iadev->tx_dle_q.start; 1718 dle = iadev->tx_dle_q.start;
1719 } 1719 }
@@ -2044,8 +2044,8 @@ static int tx_init(struct atm_dev *dev)
2044 writew(tmp16, iadev->seg_reg+CBR_TAB_END+1); // CBR_PTR; 2044 writew(tmp16, iadev->seg_reg+CBR_TAB_END+1); // CBR_PTR;
2045 tmp16 = (CBR_SCHED_TABLE*iadev->memSize + iadev->num_vc*6 - 2) >> 1; 2045 tmp16 = (CBR_SCHED_TABLE*iadev->memSize + iadev->num_vc*6 - 2) >> 1;
2046 writew(tmp16, iadev->seg_reg+CBR_TAB_END); 2046 writew(tmp16, iadev->seg_reg+CBR_TAB_END);
2047 IF_INIT(printk("iadev->seg_reg = 0x%x CBR_PTR_BASE = 0x%x\n", 2047 IF_INIT(printk("iadev->seg_reg = 0x%p CBR_PTR_BASE = 0x%x\n",
2048 (u32)iadev->seg_reg, readw(iadev->seg_reg+CBR_PTR_BASE));) 2048 iadev->seg_reg, readw(iadev->seg_reg+CBR_PTR_BASE));)
2049 IF_INIT(printk("CBR_TAB_BEG = 0x%x, CBR_TAB_END = 0x%x, CBR_PTR = 0x%x\n", 2049 IF_INIT(printk("CBR_TAB_BEG = 0x%x, CBR_TAB_END = 0x%x, CBR_PTR = 0x%x\n",
2050 readw(iadev->seg_reg+CBR_TAB_BEG), readw(iadev->seg_reg+CBR_TAB_END), 2050 readw(iadev->seg_reg+CBR_TAB_BEG), readw(iadev->seg_reg+CBR_TAB_END),
2051 readw(iadev->seg_reg+CBR_TAB_END+1));) 2051 readw(iadev->seg_reg+CBR_TAB_END+1));)
@@ -2963,8 +2963,8 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
2963 2963
2964 /* Put the packet in a tx buffer */ 2964 /* Put the packet in a tx buffer */
2965 trailer = iadev->tx_buf[desc-1].cpcs; 2965 trailer = iadev->tx_buf[desc-1].cpcs;
2966 IF_TX(printk("Sent: skb = 0x%x skb->data: 0x%x len: %d, desc: %d\n", 2966 IF_TX(printk("Sent: skb = 0x%p skb->data: 0x%p len: %d, desc: %d\n",
2967 (u32)skb, (u32)skb->data, skb->len, desc);) 2967 skb, skb->data, skb->len, desc);)
2968 trailer->control = 0; 2968 trailer->control = 0;
2969 /*big endian*/ 2969 /*big endian*/
2970 trailer->length = ((skb->len & 0xff) << 8) | ((skb->len & 0xff00) >> 8); 2970 trailer->length = ((skb->len & 0xff) << 8) | ((skb->len & 0xff00) >> 8);
@@ -3181,7 +3181,7 @@ static int __devinit ia_init_one(struct pci_dev *pdev,
3181 } 3181 }
3182 dev->dev_data = iadev; 3182 dev->dev_data = iadev;
3183 IF_INIT(printk(DEV_LABEL "registered at (itf :%d)\n", dev->number);) 3183 IF_INIT(printk(DEV_LABEL "registered at (itf :%d)\n", dev->number);)
3184 IF_INIT(printk("dev_id = 0x%x iadev->LineRate = %d \n", (u32)dev, 3184 IF_INIT(printk("dev_id = 0x%p iadev->LineRate = %d \n", dev,
3185 iadev->LineRate);) 3185 iadev->LineRate);)
3186 3186
3187 pci_set_drvdata(pdev, dev); 3187 pci_set_drvdata(pdev, dev);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 839d27cecb36..5667c2f02c51 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -198,6 +198,7 @@ static void class_create_release(struct class *cls)
198 * class_create - create a struct class structure 198 * class_create - create a struct class structure
199 * @owner: pointer to the module that is to "own" this struct class 199 * @owner: pointer to the module that is to "own" this struct class
200 * @name: pointer to a string for the name of this class. 200 * @name: pointer to a string for the name of this class.
201 * @key: the lock_class_key for this class; used by mutex lock debugging
201 * 202 *
202 * This is used to create a struct class pointer that can then be used 203 * This is used to create a struct class pointer that can then be used
203 * in calls to device_create(). 204 * in calls to device_create().
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index d625169c8e48..0c81ca731287 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -30,7 +30,7 @@ enum {
30 30
31static char aoe_iflist[IFLISTSZ]; 31static char aoe_iflist[IFLISTSZ];
32module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600); 32module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600);
33MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\"\n"); 33MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\"");
34 34
35#ifndef MODULE 35#ifndef MODULE
36static int __init aoe_iflist_setup(char *str) 36static int __init aoe_iflist_setup(char *str)
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 192522ebb771..c33bb59ed1fa 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -134,6 +134,13 @@ static struct usb_device_id blacklist_ids[] = {
134 134
135 /* Dell laptop with Broadcom chip */ 135 /* Dell laptop with Broadcom chip */
136 { USB_DEVICE(0x413c, 0x8126), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU }, 136 { USB_DEVICE(0x413c, 0x8126), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
137 /* Dell Wireless 370 */
138 { USB_DEVICE(0x413c, 0x8156), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
139 /* Dell Wireless 410 */
140 { USB_DEVICE(0x413c, 0x8152), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
141
142 /* Broadcom 2046 */
143 { USB_DEVICE(0x0a5c, 0x2151), .driver_info = HCI_RESET },
137 144
138 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ 145 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */
139 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET }, 146 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET },
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 71ec426ecffc..1e0455bd6df9 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -39,8 +39,8 @@
39#include <asm/io.h> 39#include <asm/io.h>
40#include <asm/dma.h> 40#include <asm/dma.h>
41#include <asm/delay.h> 41#include <asm/delay.h>
42#include <asm/mach/dma.h> 42#include <mach/dma.h>
43#include <asm/mach/sysasic.h> 43#include <mach/sysasic.h>
44 44
45#define GDROM_DEV_NAME "gdrom" 45#define GDROM_DEV_NAME "gdrom"
46#define GD_SESSION_OFFSET 150 46#define GD_SESSION_OFFSET 150
diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c
index 67fbd7aab5db..34d15d548236 100644
--- a/drivers/char/efirtc.c
+++ b/drivers/char/efirtc.c
@@ -37,7 +37,6 @@
37#include <linux/rtc.h> 37#include <linux/rtc.h>
38#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
39#include <linux/efi.h> 39#include <linux/efi.h>
40#include <linux/smp_lock.h>
41#include <linux/uaccess.h> 40#include <linux/uaccess.h>
42 41
43#include <asm/system.h> 42#include <asm/system.h>
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index 241cbdea65ab..f307f135cbfb 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -169,7 +169,7 @@ static int tty_ldisc_get(int disc, struct tty_ldisc *ld)
169 if (disc < N_TTY || disc >= NR_LDISCS) 169 if (disc < N_TTY || disc >= NR_LDISCS)
170 return -EINVAL; 170 return -EINVAL;
171 err = tty_ldisc_try_get(disc, ld); 171 err = tty_ldisc_try_get(disc, ld);
172 if (err == -EAGAIN) { 172 if (err < 0) {
173 request_module("tty-ldisc-%d", disc); 173 request_module("tty-ldisc-%d", disc);
174 err = tty_ldisc_try_get(disc, ld); 174 err = tty_ldisc_try_get(disc, ld);
175 } 175 }
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 82a51f38a546..1bc00c9d860d 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -916,7 +916,6 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines)
916 ws.ws_col = vc->vc_cols; 916 ws.ws_col = vc->vc_cols;
917 ws.ws_ypixel = vc->vc_scan_lines; 917 ws.ws_ypixel = vc->vc_scan_lines;
918 918
919 mutex_lock(&vc->vc_tty->termios_mutex);
920 spin_lock_irq(&vc->vc_tty->ctrl_lock); 919 spin_lock_irq(&vc->vc_tty->ctrl_lock);
921 if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col)) 920 if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col))
922 pgrp = get_pid(vc->vc_tty->pgrp); 921 pgrp = get_pid(vc->vc_tty->pgrp);
@@ -926,7 +925,6 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines)
926 put_pid(pgrp); 925 put_pid(pgrp);
927 } 926 }
928 *cws = ws; 927 *cws = ws;
929 mutex_unlock(&vc->vc_tty->termios_mutex);
930 } 928 }
931 929
932 if (CON_IS_VISIBLE(vc)) 930 if (CON_IS_VISIBLE(vc))
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 349ac3d3b848..637bd7faf132 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -38,7 +38,7 @@
38 38
39int radeon_no_wb; 39int radeon_no_wb;
40 40
41MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers\n"); 41MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
42module_param_named(no_wb, radeon_no_wb, int, 0444); 42module_param_named(no_wb, radeon_no_wb, int, 0444);
43 43
44static int dri_library_name(struct drm_device *dev, char *buf) 44static int dri_library_name(struct drm_device *dev, char *buf)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 00ff53348491..c882fd05cf29 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -394,13 +394,24 @@ config SENSORS_LM75
394 tristate "National Semiconductor LM75 and compatibles" 394 tristate "National Semiconductor LM75 and compatibles"
395 depends on I2C 395 depends on I2C
396 help 396 help
397 If you say yes here you get support for National Semiconductor LM75 397 If you say yes here you get support for one common type of
398 sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in 398 temperature sensor chip, with models including:
399 9-bit precision mode), and TelCom (now Microchip) TCN75. 399
400 400 - Dallas Semiconductor DS75 and DS1775
401 The DS75 and DS1775 in 10- to 12-bit precision modes will require 401 - Maxim MAX6625 and MAX6626
402 a force module parameter. The driver will not handle the extra 402 - Microchip MCP980x
403 precision anyhow. 403 - National Semiconductor LM75
404 - NXP's LM75A
405 - ST Microelectronics STDS75
406 - TelCom (now Microchip) TCN75
407 - Texas Instruments TMP100, TMP101, TMP75, TMP175, TMP275
408
409 This driver supports driver model based binding through board
410 specific I2C device tables.
411
412 It also supports the "legacy" style of driver binding. To use
413 that with some chips which don't replicate LM75 quirks exactly,
414 you may need the "force" module parameter.
404 415
405 This driver can also be built as a module. If so, the module 416 This driver can also be built as a module. If so, the module
406 will be called lm75. 417 will be called lm75.
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c
index ce4a7cb5a116..3a0b63136479 100644
--- a/drivers/hwmon/adt7473.c
+++ b/drivers/hwmon/adt7473.c
@@ -39,32 +39,20 @@ I2C_CLIENT_INSMOD_1(adt7473);
39#define ADT7473_REG_BASE_ADDR 0x20 39#define ADT7473_REG_BASE_ADDR 0x20
40 40
41#define ADT7473_REG_VOLT_BASE_ADDR 0x21 41#define ADT7473_REG_VOLT_BASE_ADDR 0x21
42#define ADT7473_REG_VOLT_MAX_ADDR 0x22
43#define ADT7473_REG_VOLT_MIN_BASE_ADDR 0x46 42#define ADT7473_REG_VOLT_MIN_BASE_ADDR 0x46
44#define ADT7473_REG_VOLT_MIN_MAX_ADDR 0x49
45 43
46#define ADT7473_REG_TEMP_BASE_ADDR 0x25 44#define ADT7473_REG_TEMP_BASE_ADDR 0x25
47#define ADT7473_REG_TEMP_MAX_ADDR 0x27
48#define ADT7473_REG_TEMP_LIMITS_BASE_ADDR 0x4E 45#define ADT7473_REG_TEMP_LIMITS_BASE_ADDR 0x4E
49#define ADT7473_REG_TEMP_LIMITS_MAX_ADDR 0x53
50#define ADT7473_REG_TEMP_TMIN_BASE_ADDR 0x67 46#define ADT7473_REG_TEMP_TMIN_BASE_ADDR 0x67
51#define ADT7473_REG_TEMP_TMIN_MAX_ADDR 0x69
52#define ADT7473_REG_TEMP_TMAX_BASE_ADDR 0x6A 47#define ADT7473_REG_TEMP_TMAX_BASE_ADDR 0x6A
53#define ADT7473_REG_TEMP_TMAX_MAX_ADDR 0x6C
54 48
55#define ADT7473_REG_FAN_BASE_ADDR 0x28 49#define ADT7473_REG_FAN_BASE_ADDR 0x28
56#define ADT7473_REG_FAN_MAX_ADDR 0x2F
57#define ADT7473_REG_FAN_MIN_BASE_ADDR 0x54 50#define ADT7473_REG_FAN_MIN_BASE_ADDR 0x54
58#define ADT7473_REG_FAN_MIN_MAX_ADDR 0x5B
59 51
60#define ADT7473_REG_PWM_BASE_ADDR 0x30 52#define ADT7473_REG_PWM_BASE_ADDR 0x30
61#define ADT7473_REG_PWM_MAX_ADDR 0x32
62#define ADT7473_REG_PWM_MIN_BASE_ADDR 0x64 53#define ADT7473_REG_PWM_MIN_BASE_ADDR 0x64
63#define ADT7473_REG_PWM_MIN_MAX_ADDR 0x66
64#define ADT7473_REG_PWM_MAX_BASE_ADDR 0x38 54#define ADT7473_REG_PWM_MAX_BASE_ADDR 0x38
65#define ADT7473_REG_PWM_MAX_MAX_ADDR 0x3A
66#define ADT7473_REG_PWM_BHVR_BASE_ADDR 0x5C 55#define ADT7473_REG_PWM_BHVR_BASE_ADDR 0x5C
67#define ADT7473_REG_PWM_BHVR_MAX_ADDR 0x5E
68#define ADT7473_PWM_BHVR_MASK 0xE0 56#define ADT7473_PWM_BHVR_MASK 0xE0
69#define ADT7473_PWM_BHVR_SHIFT 5 57#define ADT7473_PWM_BHVR_SHIFT 5
70 58
@@ -102,7 +90,6 @@ I2C_CLIENT_INSMOD_1(adt7473);
102#define ADT7473_FAN4_ALARM 0x20 90#define ADT7473_FAN4_ALARM 0x20
103#define ADT7473_R1T_SHORT 0x40 91#define ADT7473_R1T_SHORT 0x40
104#define ADT7473_R2T_SHORT 0x80 92#define ADT7473_R2T_SHORT 0x80
105#define ADT7473_REG_MAX_ADDR 0x80
106 93
107#define ALARM2(x) ((x) << 8) 94#define ALARM2(x) ((x) << 8)
108 95
@@ -583,10 +570,9 @@ static ssize_t set_max_duty_at_crit(struct device *dev,
583 struct i2c_client *client = to_i2c_client(dev); 570 struct i2c_client *client = to_i2c_client(dev);
584 struct adt7473_data *data = i2c_get_clientdata(client); 571 struct adt7473_data *data = i2c_get_clientdata(client);
585 int temp = simple_strtol(buf, NULL, 10); 572 int temp = simple_strtol(buf, NULL, 10);
586 temp = temp && 0xFF;
587 573
588 mutex_lock(&data->lock); 574 mutex_lock(&data->lock);
589 data->max_duty_at_overheat = temp; 575 data->max_duty_at_overheat = !!temp;
590 reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG4); 576 reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG4);
591 if (temp) 577 if (temp)
592 reg |= ADT7473_CFG4_MAX_DUTY_AT_OVT; 578 reg |= ADT7473_CFG4_MAX_DUTY_AT_OVT;
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index 7673f65877e1..5e2cf0aef480 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -48,6 +48,11 @@ static unsigned short force_id;
48module_param(force_id, ushort, 0); 48module_param(force_id, ushort, 0);
49MODULE_PARM_DESC(force_id, "Override the detected device ID"); 49MODULE_PARM_DESC(force_id, "Override the detected device ID");
50 50
51static int probe_all_addr;
52module_param(probe_all_addr, bool, 0);
53MODULE_PARM_DESC(probe_all_addr, "Include probing of non-standard LPC "
54 "addresses");
55
51/* Addresses to scan */ 56/* Addresses to scan */
52static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; 57static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END};
53 58
@@ -176,6 +181,7 @@ struct dme1737_data {
176 int valid; /* !=0 if following fields are valid */ 181 int valid; /* !=0 if following fields are valid */
177 unsigned long last_update; /* in jiffies */ 182 unsigned long last_update; /* in jiffies */
178 unsigned long last_vbat; /* in jiffies */ 183 unsigned long last_vbat; /* in jiffies */
184 enum chips type;
179 185
180 u8 vid; 186 u8 vid;
181 u8 pwm_rr_en; 187 u8 pwm_rr_en;
@@ -210,20 +216,27 @@ struct dme1737_data {
210}; 216};
211 217
212/* Nominal voltage values */ 218/* Nominal voltage values */
213static const int IN_NOMINAL[] = {5000, 2250, 3300, 5000, 12000, 3300, 3300}; 219static const int IN_NOMINAL_DME1737[] = {5000, 2250, 3300, 5000, 12000, 3300,
220 3300};
221static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300,
222 3300};
223#define IN_NOMINAL(ix, type) (((type) == dme1737) ? \
224 IN_NOMINAL_DME1737[(ix)] : \
225 IN_NOMINAL_SCH311x[(ix)])
214 226
215/* Voltage input 227/* Voltage input
216 * Voltage inputs have 16 bits resolution, limit values have 8 bits 228 * Voltage inputs have 16 bits resolution, limit values have 8 bits
217 * resolution. */ 229 * resolution. */
218static inline int IN_FROM_REG(int reg, int ix, int res) 230static inline int IN_FROM_REG(int reg, int ix, int res, int type)
219{ 231{
220 return (reg * IN_NOMINAL[ix] + (3 << (res - 3))) / (3 << (res - 2)); 232 return (reg * IN_NOMINAL(ix, type) + (3 << (res - 3))) /
233 (3 << (res - 2));
221} 234}
222 235
223static inline int IN_TO_REG(int val, int ix) 236static inline int IN_TO_REG(int val, int ix, int type)
224{ 237{
225 return SENSORS_LIMIT((val * 192 + IN_NOMINAL[ix] / 2) / 238 return SENSORS_LIMIT((val * 192 + IN_NOMINAL(ix, type) / 2) /
226 IN_NOMINAL[ix], 0, 255); 239 IN_NOMINAL(ix, type), 0, 255);
227} 240}
228 241
229/* Temperature input 242/* Temperature input
@@ -722,13 +735,13 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,
722 735
723 switch (fn) { 736 switch (fn) {
724 case SYS_IN_INPUT: 737 case SYS_IN_INPUT:
725 res = IN_FROM_REG(data->in[ix], ix, 16); 738 res = IN_FROM_REG(data->in[ix], ix, 16, data->type);
726 break; 739 break;
727 case SYS_IN_MIN: 740 case SYS_IN_MIN:
728 res = IN_FROM_REG(data->in_min[ix], ix, 8); 741 res = IN_FROM_REG(data->in_min[ix], ix, 8, data->type);
729 break; 742 break;
730 case SYS_IN_MAX: 743 case SYS_IN_MAX:
731 res = IN_FROM_REG(data->in_max[ix], ix, 8); 744 res = IN_FROM_REG(data->in_max[ix], ix, 8, data->type);
732 break; 745 break;
733 case SYS_IN_ALARM: 746 case SYS_IN_ALARM:
734 res = (data->alarms >> DME1737_BIT_ALARM_IN[ix]) & 0x01; 747 res = (data->alarms >> DME1737_BIT_ALARM_IN[ix]) & 0x01;
@@ -755,12 +768,12 @@ static ssize_t set_in(struct device *dev, struct device_attribute *attr,
755 mutex_lock(&data->update_lock); 768 mutex_lock(&data->update_lock);
756 switch (fn) { 769 switch (fn) {
757 case SYS_IN_MIN: 770 case SYS_IN_MIN:
758 data->in_min[ix] = IN_TO_REG(val, ix); 771 data->in_min[ix] = IN_TO_REG(val, ix, data->type);
759 dme1737_write(client, DME1737_REG_IN_MIN(ix), 772 dme1737_write(client, DME1737_REG_IN_MIN(ix),
760 data->in_min[ix]); 773 data->in_min[ix]);
761 break; 774 break;
762 case SYS_IN_MAX: 775 case SYS_IN_MAX:
763 data->in_max[ix] = IN_TO_REG(val, ix); 776 data->in_max[ix] = IN_TO_REG(val, ix, data->type);
764 dme1737_write(client, DME1737_REG_IN_MAX(ix), 777 dme1737_write(client, DME1737_REG_IN_MAX(ix),
765 data->in_max[ix]); 778 data->in_max[ix]);
766 break; 779 break;
@@ -1501,9 +1514,9 @@ SENSOR_DEVICE_ATTR_PWM_1TO3(3);
1501/* PWMs 5-6 */ 1514/* PWMs 5-6 */
1502 1515
1503#define SENSOR_DEVICE_ATTR_PWM_5TO6(ix) \ 1516#define SENSOR_DEVICE_ATTR_PWM_5TO6(ix) \
1504static SENSOR_DEVICE_ATTR_2(pwm##ix, S_IRUGO | S_IWUSR, \ 1517static SENSOR_DEVICE_ATTR_2(pwm##ix, S_IRUGO, \
1505 show_pwm, set_pwm, SYS_PWM, ix-1); \ 1518 show_pwm, set_pwm, SYS_PWM, ix-1); \
1506static SENSOR_DEVICE_ATTR_2(pwm##ix##_freq, S_IRUGO | S_IWUSR, \ 1519static SENSOR_DEVICE_ATTR_2(pwm##ix##_freq, S_IRUGO, \
1507 show_pwm, set_pwm, SYS_PWM_FREQ, ix-1); \ 1520 show_pwm, set_pwm, SYS_PWM_FREQ, ix-1); \
1508static SENSOR_DEVICE_ATTR_2(pwm##ix##_enable, S_IRUGO, \ 1521static SENSOR_DEVICE_ATTR_2(pwm##ix##_enable, S_IRUGO, \
1509 show_pwm, NULL, SYS_PWM_ENABLE, ix-1) 1522 show_pwm, NULL, SYS_PWM_ENABLE, ix-1)
@@ -1517,91 +1530,75 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
1517static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 1530static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
1518static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); /* for ISA devices */ 1531static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); /* for ISA devices */
1519 1532
1520#define SENSOR_DEV_ATTR_IN(ix) \
1521&sensor_dev_attr_in##ix##_input.dev_attr.attr, \
1522&sensor_dev_attr_in##ix##_min.dev_attr.attr, \
1523&sensor_dev_attr_in##ix##_max.dev_attr.attr, \
1524&sensor_dev_attr_in##ix##_alarm.dev_attr.attr
1525
1526/* These attributes are read-writeable only if the chip is *not* locked */
1527#define SENSOR_DEV_ATTR_TEMP_LOCK(ix) \
1528&sensor_dev_attr_temp##ix##_offset.dev_attr.attr
1529
1530#define SENSOR_DEV_ATTR_TEMP(ix) \
1531SENSOR_DEV_ATTR_TEMP_LOCK(ix), \
1532&sensor_dev_attr_temp##ix##_input.dev_attr.attr, \
1533&sensor_dev_attr_temp##ix##_min.dev_attr.attr, \
1534&sensor_dev_attr_temp##ix##_max.dev_attr.attr, \
1535&sensor_dev_attr_temp##ix##_alarm.dev_attr.attr, \
1536&sensor_dev_attr_temp##ix##_fault.dev_attr.attr
1537
1538/* These attributes are read-writeable only if the chip is *not* locked */
1539#define SENSOR_DEV_ATTR_ZONE_LOCK(ix) \
1540&sensor_dev_attr_zone##ix##_auto_point1_temp_hyst.dev_attr.attr, \
1541&sensor_dev_attr_zone##ix##_auto_point1_temp.dev_attr.attr, \
1542&sensor_dev_attr_zone##ix##_auto_point2_temp.dev_attr.attr, \
1543&sensor_dev_attr_zone##ix##_auto_point3_temp.dev_attr.attr
1544
1545#define SENSOR_DEV_ATTR_ZONE(ix) \
1546SENSOR_DEV_ATTR_ZONE_LOCK(ix), \
1547&sensor_dev_attr_zone##ix##_auto_channels_temp.dev_attr.attr
1548
1549#define SENSOR_DEV_ATTR_FAN_1TO4(ix) \
1550&sensor_dev_attr_fan##ix##_input.dev_attr.attr, \
1551&sensor_dev_attr_fan##ix##_min.dev_attr.attr, \
1552&sensor_dev_attr_fan##ix##_alarm.dev_attr.attr, \
1553&sensor_dev_attr_fan##ix##_type.dev_attr.attr
1554
1555#define SENSOR_DEV_ATTR_FAN_5TO6(ix) \
1556&sensor_dev_attr_fan##ix##_input.dev_attr.attr, \
1557&sensor_dev_attr_fan##ix##_min.dev_attr.attr, \
1558&sensor_dev_attr_fan##ix##_alarm.dev_attr.attr, \
1559&sensor_dev_attr_fan##ix##_max.dev_attr.attr
1560
1561/* These attributes are read-writeable only if the chip is *not* locked */
1562#define SENSOR_DEV_ATTR_PWM_1TO3_LOCK(ix) \
1563&sensor_dev_attr_pwm##ix##_freq.dev_attr.attr, \
1564&sensor_dev_attr_pwm##ix##_enable.dev_attr.attr, \
1565&sensor_dev_attr_pwm##ix##_ramp_rate.dev_attr.attr, \
1566&sensor_dev_attr_pwm##ix##_auto_channels_zone.dev_attr.attr, \
1567&sensor_dev_attr_pwm##ix##_auto_pwm_min.dev_attr.attr, \
1568&sensor_dev_attr_pwm##ix##_auto_point1_pwm.dev_attr.attr
1569
1570#define SENSOR_DEV_ATTR_PWM_1TO3(ix) \
1571SENSOR_DEV_ATTR_PWM_1TO3_LOCK(ix), \
1572&sensor_dev_attr_pwm##ix.dev_attr.attr, \
1573&sensor_dev_attr_pwm##ix##_auto_point2_pwm.dev_attr.attr
1574
1575/* These attributes are read-writeable only if the chip is *not* locked */
1576#define SENSOR_DEV_ATTR_PWM_5TO6_LOCK(ix) \
1577&sensor_dev_attr_pwm##ix.dev_attr.attr, \
1578&sensor_dev_attr_pwm##ix##_freq.dev_attr.attr
1579
1580#define SENSOR_DEV_ATTR_PWM_5TO6(ix) \
1581SENSOR_DEV_ATTR_PWM_5TO6_LOCK(ix), \
1582&sensor_dev_attr_pwm##ix##_enable.dev_attr.attr
1583
1584/* This struct holds all the attributes that are always present and need to be 1533/* This struct holds all the attributes that are always present and need to be
1585 * created unconditionally. The attributes that need modification of their 1534 * created unconditionally. The attributes that need modification of their
1586 * permissions are created read-only and write permissions are added or removed 1535 * permissions are created read-only and write permissions are added or removed
1587 * on the fly when required */ 1536 * on the fly when required */
1588static struct attribute *dme1737_attr[] ={ 1537static struct attribute *dme1737_attr[] ={
1589 /* Voltages */ 1538 /* Voltages */
1590 SENSOR_DEV_ATTR_IN(0), 1539 &sensor_dev_attr_in0_input.dev_attr.attr,
1591 SENSOR_DEV_ATTR_IN(1), 1540 &sensor_dev_attr_in0_min.dev_attr.attr,
1592 SENSOR_DEV_ATTR_IN(2), 1541 &sensor_dev_attr_in0_max.dev_attr.attr,
1593 SENSOR_DEV_ATTR_IN(3), 1542 &sensor_dev_attr_in0_alarm.dev_attr.attr,
1594 SENSOR_DEV_ATTR_IN(4), 1543 &sensor_dev_attr_in1_input.dev_attr.attr,
1595 SENSOR_DEV_ATTR_IN(5), 1544 &sensor_dev_attr_in1_min.dev_attr.attr,
1596 SENSOR_DEV_ATTR_IN(6), 1545 &sensor_dev_attr_in1_max.dev_attr.attr,
1546 &sensor_dev_attr_in1_alarm.dev_attr.attr,
1547 &sensor_dev_attr_in2_input.dev_attr.attr,
1548 &sensor_dev_attr_in2_min.dev_attr.attr,
1549 &sensor_dev_attr_in2_max.dev_attr.attr,
1550 &sensor_dev_attr_in2_alarm.dev_attr.attr,
1551 &sensor_dev_attr_in3_input.dev_attr.attr,
1552 &sensor_dev_attr_in3_min.dev_attr.attr,
1553 &sensor_dev_attr_in3_max.dev_attr.attr,
1554 &sensor_dev_attr_in3_alarm.dev_attr.attr,
1555 &sensor_dev_attr_in4_input.dev_attr.attr,
1556 &sensor_dev_attr_in4_min.dev_attr.attr,
1557 &sensor_dev_attr_in4_max.dev_attr.attr,
1558 &sensor_dev_attr_in4_alarm.dev_attr.attr,
1559 &sensor_dev_attr_in5_input.dev_attr.attr,
1560 &sensor_dev_attr_in5_min.dev_attr.attr,
1561 &sensor_dev_attr_in5_max.dev_attr.attr,
1562 &sensor_dev_attr_in5_alarm.dev_attr.attr,
1563 &sensor_dev_attr_in6_input.dev_attr.attr,
1564 &sensor_dev_attr_in6_min.dev_attr.attr,
1565 &sensor_dev_attr_in6_max.dev_attr.attr,
1566 &sensor_dev_attr_in6_alarm.dev_attr.attr,
1597 /* Temperatures */ 1567 /* Temperatures */
1598 SENSOR_DEV_ATTR_TEMP(1), 1568 &sensor_dev_attr_temp1_input.dev_attr.attr,
1599 SENSOR_DEV_ATTR_TEMP(2), 1569 &sensor_dev_attr_temp1_min.dev_attr.attr,
1600 SENSOR_DEV_ATTR_TEMP(3), 1570 &sensor_dev_attr_temp1_max.dev_attr.attr,
1571 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
1572 &sensor_dev_attr_temp1_fault.dev_attr.attr,
1573 &sensor_dev_attr_temp1_offset.dev_attr.attr,
1574 &sensor_dev_attr_temp2_input.dev_attr.attr,
1575 &sensor_dev_attr_temp2_min.dev_attr.attr,
1576 &sensor_dev_attr_temp2_max.dev_attr.attr,
1577 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
1578 &sensor_dev_attr_temp2_fault.dev_attr.attr,
1579 &sensor_dev_attr_temp2_offset.dev_attr.attr,
1580 &sensor_dev_attr_temp3_input.dev_attr.attr,
1581 &sensor_dev_attr_temp3_min.dev_attr.attr,
1582 &sensor_dev_attr_temp3_max.dev_attr.attr,
1583 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
1584 &sensor_dev_attr_temp3_fault.dev_attr.attr,
1585 &sensor_dev_attr_temp3_offset.dev_attr.attr,
1601 /* Zones */ 1586 /* Zones */
1602 SENSOR_DEV_ATTR_ZONE(1), 1587 &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr,
1603 SENSOR_DEV_ATTR_ZONE(2), 1588 &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr,
1604 SENSOR_DEV_ATTR_ZONE(3), 1589 &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr,
1590 &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr,
1591 &sensor_dev_attr_zone1_auto_channels_temp.dev_attr.attr,
1592 &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr,
1593 &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr,
1594 &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr,
1595 &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr,
1596 &sensor_dev_attr_zone2_auto_channels_temp.dev_attr.attr,
1597 &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr,
1598 &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr,
1599 &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr,
1600 &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr,
1601 &sensor_dev_attr_zone3_auto_channels_temp.dev_attr.attr,
1605 /* Misc */ 1602 /* Misc */
1606 &dev_attr_vrm.attr, 1603 &dev_attr_vrm.attr,
1607 &dev_attr_cpu0_vid.attr, 1604 &dev_attr_cpu0_vid.attr,
@@ -1616,23 +1613,48 @@ static const struct attribute_group dme1737_group = {
1616 * Their creation depends on the chip configuration which is determined during 1613 * Their creation depends on the chip configuration which is determined during
1617 * module load. */ 1614 * module load. */
1618static struct attribute *dme1737_attr_pwm1[] = { 1615static struct attribute *dme1737_attr_pwm1[] = {
1619 SENSOR_DEV_ATTR_PWM_1TO3(1), 1616 &sensor_dev_attr_pwm1.dev_attr.attr,
1617 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
1618 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1619 &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr,
1620 &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr,
1621 &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr,
1622 &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
1623 &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr,
1620 NULL 1624 NULL
1621}; 1625};
1622static struct attribute *dme1737_attr_pwm2[] = { 1626static struct attribute *dme1737_attr_pwm2[] = {
1623 SENSOR_DEV_ATTR_PWM_1TO3(2), 1627 &sensor_dev_attr_pwm2.dev_attr.attr,
1628 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
1629 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1630 &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr,
1631 &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr,
1632 &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr,
1633 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr,
1634 &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr,
1624 NULL 1635 NULL
1625}; 1636};
1626static struct attribute *dme1737_attr_pwm3[] = { 1637static struct attribute *dme1737_attr_pwm3[] = {
1627 SENSOR_DEV_ATTR_PWM_1TO3(3), 1638 &sensor_dev_attr_pwm3.dev_attr.attr,
1639 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
1640 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1641 &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr,
1642 &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr,
1643 &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr,
1644 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr,
1645 &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr,
1628 NULL 1646 NULL
1629}; 1647};
1630static struct attribute *dme1737_attr_pwm5[] = { 1648static struct attribute *dme1737_attr_pwm5[] = {
1631 SENSOR_DEV_ATTR_PWM_5TO6(5), 1649 &sensor_dev_attr_pwm5.dev_attr.attr,
1650 &sensor_dev_attr_pwm5_freq.dev_attr.attr,
1651 &sensor_dev_attr_pwm5_enable.dev_attr.attr,
1632 NULL 1652 NULL
1633}; 1653};
1634static struct attribute *dme1737_attr_pwm6[] = { 1654static struct attribute *dme1737_attr_pwm6[] = {
1635 SENSOR_DEV_ATTR_PWM_5TO6(6), 1655 &sensor_dev_attr_pwm6.dev_attr.attr,
1656 &sensor_dev_attr_pwm6_freq.dev_attr.attr,
1657 &sensor_dev_attr_pwm6_enable.dev_attr.attr,
1636 NULL 1658 NULL
1637}; 1659};
1638 1660
@@ -1649,27 +1671,45 @@ static const struct attribute_group dme1737_pwm_group[] = {
1649 * Their creation depends on the chip configuration which is determined during 1671 * Their creation depends on the chip configuration which is determined during
1650 * module load. */ 1672 * module load. */
1651static struct attribute *dme1737_attr_fan1[] = { 1673static struct attribute *dme1737_attr_fan1[] = {
1652 SENSOR_DEV_ATTR_FAN_1TO4(1), 1674 &sensor_dev_attr_fan1_input.dev_attr.attr,
1675 &sensor_dev_attr_fan1_min.dev_attr.attr,
1676 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
1677 &sensor_dev_attr_fan1_type.dev_attr.attr,
1653 NULL 1678 NULL
1654}; 1679};
1655static struct attribute *dme1737_attr_fan2[] = { 1680static struct attribute *dme1737_attr_fan2[] = {
1656 SENSOR_DEV_ATTR_FAN_1TO4(2), 1681 &sensor_dev_attr_fan2_input.dev_attr.attr,
1682 &sensor_dev_attr_fan2_min.dev_attr.attr,
1683 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
1684 &sensor_dev_attr_fan2_type.dev_attr.attr,
1657 NULL 1685 NULL
1658}; 1686};
1659static struct attribute *dme1737_attr_fan3[] = { 1687static struct attribute *dme1737_attr_fan3[] = {
1660 SENSOR_DEV_ATTR_FAN_1TO4(3), 1688 &sensor_dev_attr_fan3_input.dev_attr.attr,
1689 &sensor_dev_attr_fan3_min.dev_attr.attr,
1690 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1691 &sensor_dev_attr_fan3_type.dev_attr.attr,
1661 NULL 1692 NULL
1662}; 1693};
1663static struct attribute *dme1737_attr_fan4[] = { 1694static struct attribute *dme1737_attr_fan4[] = {
1664 SENSOR_DEV_ATTR_FAN_1TO4(4), 1695 &sensor_dev_attr_fan4_input.dev_attr.attr,
1696 &sensor_dev_attr_fan4_min.dev_attr.attr,
1697 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
1698 &sensor_dev_attr_fan4_type.dev_attr.attr,
1665 NULL 1699 NULL
1666}; 1700};
1667static struct attribute *dme1737_attr_fan5[] = { 1701static struct attribute *dme1737_attr_fan5[] = {
1668 SENSOR_DEV_ATTR_FAN_5TO6(5), 1702 &sensor_dev_attr_fan5_input.dev_attr.attr,
1703 &sensor_dev_attr_fan5_min.dev_attr.attr,
1704 &sensor_dev_attr_fan5_alarm.dev_attr.attr,
1705 &sensor_dev_attr_fan5_max.dev_attr.attr,
1669 NULL 1706 NULL
1670}; 1707};
1671static struct attribute *dme1737_attr_fan6[] = { 1708static struct attribute *dme1737_attr_fan6[] = {
1672 SENSOR_DEV_ATTR_FAN_5TO6(6), 1709 &sensor_dev_attr_fan6_input.dev_attr.attr,
1710 &sensor_dev_attr_fan6_min.dev_attr.attr,
1711 &sensor_dev_attr_fan6_alarm.dev_attr.attr,
1712 &sensor_dev_attr_fan6_max.dev_attr.attr,
1673 NULL 1713 NULL
1674}; 1714};
1675 1715
@@ -1686,13 +1726,22 @@ static const struct attribute_group dme1737_fan_group[] = {
1686 * writeable if the chip is *not* locked. Otherwise they stay read-only. */ 1726 * writeable if the chip is *not* locked. Otherwise they stay read-only. */
1687static struct attribute *dme1737_attr_lock[] = { 1727static struct attribute *dme1737_attr_lock[] = {
1688 /* Temperatures */ 1728 /* Temperatures */
1689 SENSOR_DEV_ATTR_TEMP_LOCK(1), 1729 &sensor_dev_attr_temp1_offset.dev_attr.attr,
1690 SENSOR_DEV_ATTR_TEMP_LOCK(2), 1730 &sensor_dev_attr_temp2_offset.dev_attr.attr,
1691 SENSOR_DEV_ATTR_TEMP_LOCK(3), 1731 &sensor_dev_attr_temp3_offset.dev_attr.attr,
1692 /* Zones */ 1732 /* Zones */
1693 SENSOR_DEV_ATTR_ZONE_LOCK(1), 1733 &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr,
1694 SENSOR_DEV_ATTR_ZONE_LOCK(2), 1734 &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr,
1695 SENSOR_DEV_ATTR_ZONE_LOCK(3), 1735 &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr,
1736 &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr,
1737 &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr,
1738 &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr,
1739 &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr,
1740 &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr,
1741 &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr,
1742 &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr,
1743 &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr,
1744 &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr,
1696 NULL 1745 NULL
1697}; 1746};
1698 1747
@@ -1704,23 +1753,40 @@ static const struct attribute_group dme1737_lock_group = {
1704 * writeable if the chip is *not* locked and the respective PWM is available. 1753 * writeable if the chip is *not* locked and the respective PWM is available.
1705 * Otherwise they stay read-only. */ 1754 * Otherwise they stay read-only. */
1706static struct attribute *dme1737_attr_pwm1_lock[] = { 1755static struct attribute *dme1737_attr_pwm1_lock[] = {
1707 SENSOR_DEV_ATTR_PWM_1TO3_LOCK(1), 1756 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
1757 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1758 &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr,
1759 &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr,
1760 &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr,
1761 &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
1708 NULL 1762 NULL
1709}; 1763};
1710static struct attribute *dme1737_attr_pwm2_lock[] = { 1764static struct attribute *dme1737_attr_pwm2_lock[] = {
1711 SENSOR_DEV_ATTR_PWM_1TO3_LOCK(2), 1765 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
1766 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1767 &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr,
1768 &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr,
1769 &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr,
1770 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr,
1712 NULL 1771 NULL
1713}; 1772};
1714static struct attribute *dme1737_attr_pwm3_lock[] = { 1773static struct attribute *dme1737_attr_pwm3_lock[] = {
1715 SENSOR_DEV_ATTR_PWM_1TO3_LOCK(3), 1774 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
1775 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1776 &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr,
1777 &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr,
1778 &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr,
1779 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr,
1716 NULL 1780 NULL
1717}; 1781};
1718static struct attribute *dme1737_attr_pwm5_lock[] = { 1782static struct attribute *dme1737_attr_pwm5_lock[] = {
1719 SENSOR_DEV_ATTR_PWM_5TO6_LOCK(5), 1783 &sensor_dev_attr_pwm5.dev_attr.attr,
1784 &sensor_dev_attr_pwm5_freq.dev_attr.attr,
1720 NULL 1785 NULL
1721}; 1786};
1722static struct attribute *dme1737_attr_pwm6_lock[] = { 1787static struct attribute *dme1737_attr_pwm6_lock[] = {
1723 SENSOR_DEV_ATTR_PWM_5TO6_LOCK(6), 1788 &sensor_dev_attr_pwm6.dev_attr.attr,
1789 &sensor_dev_attr_pwm6_freq.dev_attr.attr,
1724 NULL 1790 NULL
1725}; 1791};
1726 1792
@@ -2109,6 +2175,7 @@ static int dme1737_i2c_detect(struct i2c_adapter *adapter, int address,
2109 2175
2110 kind = dme1737; 2176 kind = dme1737;
2111 name = "dme1737"; 2177 name = "dme1737";
2178 data->type = kind;
2112 2179
2113 /* Fill in the remaining client fields and put it into the global 2180 /* Fill in the remaining client fields and put it into the global
2114 * list */ 2181 * list */
@@ -2301,6 +2368,7 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2301 err = -ENODEV; 2368 err = -ENODEV;
2302 goto exit_kfree; 2369 goto exit_kfree;
2303 } 2370 }
2371 data->type = -1;
2304 2372
2305 /* Fill in the remaining client fields and initialize the mutex */ 2373 /* Fill in the remaining client fields and initialize the mutex */
2306 strlcpy(client->name, "sch311x", I2C_NAME_SIZE); 2374 strlcpy(client->name, "sch311x", I2C_NAME_SIZE);
@@ -2377,7 +2445,10 @@ static int __init dme1737_init(void)
2377 } 2445 }
2378 2446
2379 if (dme1737_isa_detect(0x2e, &addr) && 2447 if (dme1737_isa_detect(0x2e, &addr) &&
2380 dme1737_isa_detect(0x4e, &addr)) { 2448 dme1737_isa_detect(0x4e, &addr) &&
2449 (!probe_all_addr ||
2450 (dme1737_isa_detect(0x162e, &addr) &&
2451 dme1737_isa_detect(0x164e, &addr)))) {
2381 /* Return 0 if we didn't find an ISA device */ 2452 /* Return 0 if we didn't find an ISA device */
2382 return 0; 2453 return 0;
2383 } 2454 }
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index de698dc73020..7880c273c2c5 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -30,14 +30,37 @@
30#include "lm75.h" 30#include "lm75.h"
31 31
32 32
33/* Addresses to scan */ 33/*
34 * This driver handles the LM75 and compatible digital temperature sensors.
35 * Only types which are _not_ listed in I2C_CLIENT_INSMOD_*() need to be
36 * listed here. We start at 9 since I2C_CLIENT_INSMOD_*() currently allow
37 * definition of up to 8 chip types (plus zero).
38 */
39
40enum lm75_type { /* keep sorted in alphabetical order */
41 ds1775 = 9,
42 ds75,
43 /* lm75 -- in I2C_CLIENT_INSMOD_1() */
44 lm75a,
45 max6625,
46 max6626,
47 mcp980x,
48 stds75,
49 tcn75,
50 tmp100,
51 tmp101,
52 tmp175,
53 tmp275,
54 tmp75,
55};
56
57/* Addresses scanned by legacy style driver binding */
34static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 58static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
35 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 59 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
36 60
37/* Insmod parameters */ 61/* Insmod parameters (only for legacy style driver binding) */
38I2C_CLIENT_INSMOD_1(lm75); 62I2C_CLIENT_INSMOD_1(lm75);
39 63
40/* Many LM75 constants specified below */
41 64
42/* The LM75 registers */ 65/* The LM75 registers */
43#define LM75_REG_CONF 0x01 66#define LM75_REG_CONF 0x01
@@ -49,10 +72,11 @@ static const u8 LM75_REG_TEMP[3] = {
49 72
50/* Each client has this additional data */ 73/* Each client has this additional data */
51struct lm75_data { 74struct lm75_data {
52 struct i2c_client client; 75 struct i2c_client *client;
53 struct device *hwmon_dev; 76 struct device *hwmon_dev;
54 struct mutex update_lock; 77 struct mutex update_lock;
55 char valid; /* !=0 if following fields are valid */ 78 u8 orig_conf;
79 char valid; /* !=0 if registers are valid */
56 unsigned long last_updated; /* In jiffies */ 80 unsigned long last_updated; /* In jiffies */
57 u16 temp[3]; /* Register values, 81 u16 temp[3]; /* Register values,
58 0 = input 82 0 = input
@@ -60,23 +84,14 @@ struct lm75_data {
60 2 = hyst */ 84 2 = hyst */
61}; 85};
62 86
63static int lm75_attach_adapter(struct i2c_adapter *adapter);
64static int lm75_detect(struct i2c_adapter *adapter, int address, int kind);
65static void lm75_init_client(struct i2c_client *client);
66static int lm75_detach_client(struct i2c_client *client);
67static int lm75_read_value(struct i2c_client *client, u8 reg); 87static int lm75_read_value(struct i2c_client *client, u8 reg);
68static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); 88static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value);
69static struct lm75_data *lm75_update_device(struct device *dev); 89static struct lm75_data *lm75_update_device(struct device *dev);
70 90
71 91
72/* This is the driver that will be inserted */ 92/*-----------------------------------------------------------------------*/
73static struct i2c_driver lm75_driver = { 93
74 .driver = { 94/* sysfs attributes for hwmon */
75 .name = "lm75",
76 },
77 .attach_adapter = lm75_attach_adapter,
78 .detach_client = lm75_detach_client,
79};
80 95
81static ssize_t show_temp(struct device *dev, struct device_attribute *da, 96static ssize_t show_temp(struct device *dev, struct device_attribute *da,
82 char *buf) 97 char *buf)
@@ -109,13 +124,6 @@ static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
109 show_temp, set_temp, 2); 124 show_temp, set_temp, 2);
110static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); 125static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
111 126
112static int lm75_attach_adapter(struct i2c_adapter *adapter)
113{
114 if (!(adapter->class & I2C_CLASS_HWMON))
115 return 0;
116 return i2c_probe(adapter, &addr_data, lm75_detect);
117}
118
119static struct attribute *lm75_attributes[] = { 127static struct attribute *lm75_attributes[] = {
120 &sensor_dev_attr_temp1_input.dev_attr.attr, 128 &sensor_dev_attr_temp1_input.dev_attr.attr,
121 &sensor_dev_attr_temp1_max.dev_attr.attr, 129 &sensor_dev_attr_temp1_max.dev_attr.attr,
@@ -128,32 +136,144 @@ static const struct attribute_group lm75_group = {
128 .attrs = lm75_attributes, 136 .attrs = lm75_attributes,
129}; 137};
130 138
139/*-----------------------------------------------------------------------*/
140
141/* "New style" I2C driver binding -- following the driver model */
142
143static int
144lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
145{
146 struct lm75_data *data;
147 int status;
148 u8 set_mask, clr_mask;
149 int new;
150
151 if (!i2c_check_functionality(client->adapter,
152 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
153 return -EIO;
154
155 data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL);
156 if (!data)
157 return -ENOMEM;
158
159 i2c_set_clientdata(client, data);
160
161 data->client = client;
162 mutex_init(&data->update_lock);
163
164 /* Set to LM75 resolution (9 bits, 1/2 degree C) and range.
165 * Then tweak to be more precise when appropriate.
166 */
167 set_mask = 0;
168 clr_mask = (1 << 0) /* continuous conversions */
169 | (1 << 6) | (1 << 5); /* 9-bit mode */
170
171 /* configure as specified */
172 status = lm75_read_value(client, LM75_REG_CONF);
173 if (status < 0) {
174 dev_dbg(&client->dev, "Can't read config? %d\n", status);
175 goto exit_free;
176 }
177 data->orig_conf = status;
178 new = status & ~clr_mask;
179 new |= set_mask;
180 if (status != new)
181 lm75_write_value(client, LM75_REG_CONF, new);
182 dev_dbg(&client->dev, "Config %02x\n", new);
183
184 /* Register sysfs hooks */
185 status = sysfs_create_group(&client->dev.kobj, &lm75_group);
186 if (status)
187 goto exit_free;
188
189 data->hwmon_dev = hwmon_device_register(&client->dev);
190 if (IS_ERR(data->hwmon_dev)) {
191 status = PTR_ERR(data->hwmon_dev);
192 goto exit_remove;
193 }
194
195 dev_info(&client->dev, "%s: sensor '%s'\n",
196 data->hwmon_dev->bus_id, client->name);
197
198 return 0;
199
200exit_remove:
201 sysfs_remove_group(&client->dev.kobj, &lm75_group);
202exit_free:
203 i2c_set_clientdata(client, NULL);
204 kfree(data);
205 return status;
206}
207
208static int lm75_remove(struct i2c_client *client)
209{
210 struct lm75_data *data = i2c_get_clientdata(client);
211
212 hwmon_device_unregister(data->hwmon_dev);
213 sysfs_remove_group(&client->dev.kobj, &lm75_group);
214 lm75_write_value(client, LM75_REG_CONF, data->orig_conf);
215 i2c_set_clientdata(client, NULL);
216 kfree(data);
217 return 0;
218}
219
220static const struct i2c_device_id lm75_ids[] = {
221 { "ds1775", ds1775, },
222 { "ds75", ds75, },
223 { "lm75", lm75, },
224 { "lm75a", lm75a, },
225 { "max6625", max6625, },
226 { "max6626", max6626, },
227 { "mcp980x", mcp980x, },
228 { "stds75", stds75, },
229 { "tcn75", tcn75, },
230 { "tmp100", tmp100, },
231 { "tmp101", tmp101, },
232 { "tmp175", tmp175, },
233 { "tmp275", tmp275, },
234 { "tmp75", tmp75, },
235 { /* LIST END */ }
236};
237MODULE_DEVICE_TABLE(i2c, lm75_ids);
238
239static struct i2c_driver lm75_driver = {
240 .driver = {
241 .name = "lm75",
242 },
243 .probe = lm75_probe,
244 .remove = lm75_remove,
245 .id_table = lm75_ids,
246};
247
248/*-----------------------------------------------------------------------*/
249
250/* "Legacy" I2C driver binding */
251
252static struct i2c_driver lm75_legacy_driver;
253
131/* This function is called by i2c_probe */ 254/* This function is called by i2c_probe */
132static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) 255static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
133{ 256{
134 int i; 257 int i;
135 struct i2c_client *new_client; 258 struct i2c_client *new_client;
136 struct lm75_data *data;
137 int err = 0; 259 int err = 0;
138 const char *name = "";
139 260
140 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 261 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
141 I2C_FUNC_SMBUS_WORD_DATA)) 262 I2C_FUNC_SMBUS_WORD_DATA))
142 goto exit; 263 goto exit;
143 264
144 /* OK. For now, we presume we have a valid client. We now create the 265 /* OK. For now, we presume we have a valid address. We create the
145 client structure, even though we cannot fill it completely yet. 266 client structure, even though there may be no sensor present.
146 But it allows us to access lm75_{read,write}_value. */ 267 But it allows us to use i2c_smbus_read_*_data() calls. */
147 if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) { 268 new_client = kzalloc(sizeof *new_client, GFP_KERNEL);
269 if (!new_client) {
148 err = -ENOMEM; 270 err = -ENOMEM;
149 goto exit; 271 goto exit;
150 } 272 }
151 273
152 new_client = &data->client;
153 i2c_set_clientdata(new_client, data);
154 new_client->addr = address; 274 new_client->addr = address;
155 new_client->adapter = adapter; 275 new_client->adapter = adapter;
156 new_client->driver = &lm75_driver; 276 new_client->driver = &lm75_legacy_driver;
157 new_client->flags = 0; 277 new_client->flags = 0;
158 278
159 /* Now, we do the remaining detection. There is no identification- 279 /* Now, we do the remaining detection. There is no identification-
@@ -174,17 +294,17 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
174 || i2c_smbus_read_word_data(new_client, 5) != hyst 294 || i2c_smbus_read_word_data(new_client, 5) != hyst
175 || i2c_smbus_read_word_data(new_client, 6) != hyst 295 || i2c_smbus_read_word_data(new_client, 6) != hyst
176 || i2c_smbus_read_word_data(new_client, 7) != hyst) 296 || i2c_smbus_read_word_data(new_client, 7) != hyst)
177 goto exit_free; 297 goto exit_free;
178 os = i2c_smbus_read_word_data(new_client, 3); 298 os = i2c_smbus_read_word_data(new_client, 3);
179 if (i2c_smbus_read_word_data(new_client, 4) != os 299 if (i2c_smbus_read_word_data(new_client, 4) != os
180 || i2c_smbus_read_word_data(new_client, 5) != os 300 || i2c_smbus_read_word_data(new_client, 5) != os
181 || i2c_smbus_read_word_data(new_client, 6) != os 301 || i2c_smbus_read_word_data(new_client, 6) != os
182 || i2c_smbus_read_word_data(new_client, 7) != os) 302 || i2c_smbus_read_word_data(new_client, 7) != os)
183 goto exit_free; 303 goto exit_free;
184 304
185 /* Unused bits */ 305 /* Unused bits */
186 if (conf & 0xe0) 306 if (conf & 0xe0)
187 goto exit_free; 307 goto exit_free;
188 308
189 /* Addresses cycling */ 309 /* Addresses cycling */
190 for (i = 8; i < 0xff; i += 8) 310 for (i = 8; i < 0xff; i += 8)
@@ -194,58 +314,57 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
194 goto exit_free; 314 goto exit_free;
195 } 315 }
196 316
197 /* Determine the chip type - only one kind supported! */ 317 /* NOTE: we treat "force=..." and "force_lm75=..." the same.
198 if (kind <= 0) 318 * Only new-style driver binding distinguishes chip types.
199 kind = lm75; 319 */
200 320 strlcpy(new_client->name, "lm75", I2C_NAME_SIZE);
201 if (kind == lm75) {
202 name = "lm75";
203 }
204
205 /* Fill in the remaining client fields and put it into the global list */
206 strlcpy(new_client->name, name, I2C_NAME_SIZE);
207 data->valid = 0;
208 mutex_init(&data->update_lock);
209 321
210 /* Tell the I2C layer a new client has arrived */ 322 /* Tell the I2C layer a new client has arrived */
211 if ((err = i2c_attach_client(new_client))) 323 err = i2c_attach_client(new_client);
324 if (err)
212 goto exit_free; 325 goto exit_free;
213 326
214 /* Initialize the LM75 chip */ 327 err = lm75_probe(new_client, NULL);
215 lm75_init_client(new_client); 328 if (err < 0)
216
217 /* Register sysfs hooks */
218 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm75_group)))
219 goto exit_detach; 329 goto exit_detach;
220 330
221 data->hwmon_dev = hwmon_device_register(&new_client->dev);
222 if (IS_ERR(data->hwmon_dev)) {
223 err = PTR_ERR(data->hwmon_dev);
224 goto exit_remove;
225 }
226
227 return 0; 331 return 0;
228 332
229exit_remove:
230 sysfs_remove_group(&new_client->dev.kobj, &lm75_group);
231exit_detach: 333exit_detach:
232 i2c_detach_client(new_client); 334 i2c_detach_client(new_client);
233exit_free: 335exit_free:
234 kfree(data); 336 kfree(new_client);
235exit: 337exit:
236 return err; 338 return err;
237} 339}
238 340
341static int lm75_attach_adapter(struct i2c_adapter *adapter)
342{
343 if (!(adapter->class & I2C_CLASS_HWMON))
344 return 0;
345 return i2c_probe(adapter, &addr_data, lm75_detect);
346}
347
239static int lm75_detach_client(struct i2c_client *client) 348static int lm75_detach_client(struct i2c_client *client)
240{ 349{
241 struct lm75_data *data = i2c_get_clientdata(client); 350 lm75_remove(client);
242 hwmon_device_unregister(data->hwmon_dev);
243 sysfs_remove_group(&client->dev.kobj, &lm75_group);
244 i2c_detach_client(client); 351 i2c_detach_client(client);
245 kfree(data); 352 kfree(client);
246 return 0; 353 return 0;
247} 354}
248 355
356static struct i2c_driver lm75_legacy_driver = {
357 .driver = {
358 .name = "lm75_legacy",
359 },
360 .attach_adapter = lm75_attach_adapter,
361 .detach_client = lm75_detach_client,
362};
363
364/*-----------------------------------------------------------------------*/
365
366/* register access */
367
249/* All registers are word-sized, except for the configuration register. 368/* All registers are word-sized, except for the configuration register.
250 LM75 uses a high-byte first convention, which is exactly opposite to 369 LM75 uses a high-byte first convention, which is exactly opposite to
251 the SMBus standard. */ 370 the SMBus standard. */
@@ -268,16 +387,6 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
268 return i2c_smbus_write_word_data(client, reg, swab16(value)); 387 return i2c_smbus_write_word_data(client, reg, swab16(value));
269} 388}
270 389
271static void lm75_init_client(struct i2c_client *client)
272{
273 int reg;
274
275 /* Enable if in shutdown mode */
276 reg = lm75_read_value(client, LM75_REG_CONF);
277 if (reg >= 0 && (reg & 0x01))
278 lm75_write_value(client, LM75_REG_CONF, reg & 0xfe);
279}
280
281static struct lm75_data *lm75_update_device(struct device *dev) 390static struct lm75_data *lm75_update_device(struct device *dev)
282{ 391{
283 struct i2c_client *client = to_i2c_client(dev); 392 struct i2c_client *client = to_i2c_client(dev);
@@ -309,13 +418,28 @@ static struct lm75_data *lm75_update_device(struct device *dev)
309 return data; 418 return data;
310} 419}
311 420
421/*-----------------------------------------------------------------------*/
422
423/* module glue */
424
312static int __init sensors_lm75_init(void) 425static int __init sensors_lm75_init(void)
313{ 426{
314 return i2c_add_driver(&lm75_driver); 427 int status;
428
429 status = i2c_add_driver(&lm75_driver);
430 if (status < 0)
431 return status;
432
433 status = i2c_add_driver(&lm75_legacy_driver);
434 if (status < 0)
435 i2c_del_driver(&lm75_driver);
436
437 return status;
315} 438}
316 439
317static void __exit sensors_lm75_exit(void) 440static void __exit sensors_lm75_exit(void)
318{ 441{
442 i2c_del_driver(&lm75_legacy_driver);
319 i2c_del_driver(&lm75_driver); 443 i2c_del_driver(&lm75_driver);
320} 444}
321 445
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index ee5eca1c1921..12d446f54f97 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1,7 +1,7 @@
1/* 1/*
2 lm85.c - Part of lm_sensors, Linux kernel modules for hardware 2 lm85.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring 3 monitoring
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> 4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
5 Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> 5 Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com>
6 Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> 6 Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de>
7 Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> 7 Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com>
@@ -51,24 +51,17 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
51#define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2) 51#define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2)
52 52
53/* Fan speeds are LSB, MSB (2 bytes) */ 53/* Fan speeds are LSB, MSB (2 bytes) */
54#define LM85_REG_FAN(nr) (0x28 + (nr) *2) 54#define LM85_REG_FAN(nr) (0x28 + (nr) * 2)
55#define LM85_REG_FAN_MIN(nr) (0x54 + (nr) *2) 55#define LM85_REG_FAN_MIN(nr) (0x54 + (nr) * 2)
56 56
57#define LM85_REG_PWM(nr) (0x30 + (nr)) 57#define LM85_REG_PWM(nr) (0x30 + (nr))
58 58
59#define ADT7463_REG_OPPOINT(nr) (0x33 + (nr))
60
61#define ADT7463_REG_TMIN_CTL1 0x36
62#define ADT7463_REG_TMIN_CTL2 0x37
63
64#define LM85_REG_DEVICE 0x3d
65#define LM85_REG_COMPANY 0x3e 59#define LM85_REG_COMPANY 0x3e
66#define LM85_REG_VERSTEP 0x3f 60#define LM85_REG_VERSTEP 0x3f
67/* These are the recognized values for the above regs */ 61/* These are the recognized values for the above regs */
68#define LM85_DEVICE_ADX 0x27
69#define LM85_COMPANY_NATIONAL 0x01 62#define LM85_COMPANY_NATIONAL 0x01
70#define LM85_COMPANY_ANALOG_DEV 0x41 63#define LM85_COMPANY_ANALOG_DEV 0x41
71#define LM85_COMPANY_SMSC 0x5c 64#define LM85_COMPANY_SMSC 0x5c
72#define LM85_VERSTEP_VMASK 0xf0 65#define LM85_VERSTEP_VMASK 0xf0
73#define LM85_VERSTEP_GENERIC 0x60 66#define LM85_VERSTEP_GENERIC 0x60
74#define LM85_VERSTEP_LM85C 0x60 67#define LM85_VERSTEP_LM85C 0x60
@@ -91,58 +84,45 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
91#define LM85_REG_AFAN_CONFIG(nr) (0x5c + (nr)) 84#define LM85_REG_AFAN_CONFIG(nr) (0x5c + (nr))
92#define LM85_REG_AFAN_RANGE(nr) (0x5f + (nr)) 85#define LM85_REG_AFAN_RANGE(nr) (0x5f + (nr))
93#define LM85_REG_AFAN_SPIKE1 0x62 86#define LM85_REG_AFAN_SPIKE1 0x62
94#define LM85_REG_AFAN_SPIKE2 0x63
95#define LM85_REG_AFAN_MINPWM(nr) (0x64 + (nr)) 87#define LM85_REG_AFAN_MINPWM(nr) (0x64 + (nr))
96#define LM85_REG_AFAN_LIMIT(nr) (0x67 + (nr)) 88#define LM85_REG_AFAN_LIMIT(nr) (0x67 + (nr))
97#define LM85_REG_AFAN_CRITICAL(nr) (0x6a + (nr)) 89#define LM85_REG_AFAN_CRITICAL(nr) (0x6a + (nr))
98#define LM85_REG_AFAN_HYST1 0x6d 90#define LM85_REG_AFAN_HYST1 0x6d
99#define LM85_REG_AFAN_HYST2 0x6e 91#define LM85_REG_AFAN_HYST2 0x6e
100 92
101#define LM85_REG_TACH_MODE 0x74
102#define LM85_REG_SPINUP_CTL 0x75
103
104#define ADM1027_REG_TEMP_OFFSET(nr) (0x70 + (nr))
105#define ADM1027_REG_CONFIG2 0x73
106#define ADM1027_REG_INTMASK1 0x74
107#define ADM1027_REG_INTMASK2 0x75
108#define ADM1027_REG_EXTEND_ADC1 0x76 93#define ADM1027_REG_EXTEND_ADC1 0x76
109#define ADM1027_REG_EXTEND_ADC2 0x77 94#define ADM1027_REG_EXTEND_ADC2 0x77
110#define ADM1027_REG_CONFIG3 0x78
111#define ADM1027_REG_FAN_PPR 0x7b
112
113#define ADT7463_REG_THERM 0x79
114#define ADT7463_REG_THERM_LIMIT 0x7A
115 95
116#define EMC6D100_REG_ALARM3 0x7d 96#define EMC6D100_REG_ALARM3 0x7d
117/* IN5, IN6 and IN7 */ 97/* IN5, IN6 and IN7 */
118#define EMC6D100_REG_IN(nr) (0x70 + ((nr)-5)) 98#define EMC6D100_REG_IN(nr) (0x70 + ((nr) - 5))
119#define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr)-5) * 2) 99#define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr) - 5) * 2)
120#define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr)-5) * 2) 100#define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr) - 5) * 2)
121#define EMC6D102_REG_EXTEND_ADC1 0x85 101#define EMC6D102_REG_EXTEND_ADC1 0x85
122#define EMC6D102_REG_EXTEND_ADC2 0x86 102#define EMC6D102_REG_EXTEND_ADC2 0x86
123#define EMC6D102_REG_EXTEND_ADC3 0x87 103#define EMC6D102_REG_EXTEND_ADC3 0x87
124#define EMC6D102_REG_EXTEND_ADC4 0x88 104#define EMC6D102_REG_EXTEND_ADC4 0x88
125 105
126 106
127/* Conversions. Rounding and limit checking is only done on the TO_REG 107/* Conversions. Rounding and limit checking is only done on the TO_REG
128 variants. Note that you should be a bit careful with which arguments 108 variants. Note that you should be a bit careful with which arguments
129 these macros are called: arguments may be evaluated more than once. 109 these macros are called: arguments may be evaluated more than once.
130 */ 110 */
131 111
132/* IN are scaled acording to built-in resistors */ 112/* IN are scaled acording to built-in resistors */
133static int lm85_scaling[] = { /* .001 Volts */ 113static const int lm85_scaling[] = { /* .001 Volts */
134 2500, 2250, 3300, 5000, 12000, 114 2500, 2250, 3300, 5000, 12000,
135 3300, 1500, 1800 /*EMC6D100*/ 115 3300, 1500, 1800 /*EMC6D100*/
136 }; 116};
137#define SCALE(val,from,to) (((val)*(to) + ((from)/2))/(from)) 117#define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from))
138 118
139#define INS_TO_REG(n,val) \ 119#define INS_TO_REG(n, val) \
140 SENSORS_LIMIT(SCALE(val,lm85_scaling[n],192),0,255) 120 SENSORS_LIMIT(SCALE(val, lm85_scaling[n], 192), 0, 255)
141 121
142#define INSEXT_FROM_REG(n,val,ext) \ 122#define INSEXT_FROM_REG(n, val, ext) \
143 SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n]) 123 SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n])
144 124
145#define INS_FROM_REG(n,val) SCALE((val), 192, lm85_scaling[n]) 125#define INS_FROM_REG(n, val) SCALE((val), 192, lm85_scaling[n])
146 126
147/* FAN speed is measured using 90kHz clock */ 127/* FAN speed is measured using 90kHz clock */
148static inline u16 FAN_TO_REG(unsigned long val) 128static inline u16 FAN_TO_REG(unsigned long val)
@@ -151,16 +131,17 @@ static inline u16 FAN_TO_REG(unsigned long val)
151 return 0xffff; 131 return 0xffff;
152 return SENSORS_LIMIT(5400000 / val, 1, 0xfffe); 132 return SENSORS_LIMIT(5400000 / val, 1, 0xfffe);
153} 133}
154#define FAN_FROM_REG(val) ((val)==0?-1:(val)==0xffff?0:5400000/(val)) 134#define FAN_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \
135 5400000 / (val))
155 136
156/* Temperature is reported in .001 degC increments */ 137/* Temperature is reported in .001 degC increments */
157#define TEMP_TO_REG(val) \ 138#define TEMP_TO_REG(val) \
158 SENSORS_LIMIT(SCALE(val,1000,1),-127,127) 139 SENSORS_LIMIT(SCALE(val, 1000, 1), -127, 127)
159#define TEMPEXT_FROM_REG(val,ext) \ 140#define TEMPEXT_FROM_REG(val, ext) \
160 SCALE(((val) << 4) + (ext), 16, 1000) 141 SCALE(((val) << 4) + (ext), 16, 1000)
161#define TEMP_FROM_REG(val) ((val) * 1000) 142#define TEMP_FROM_REG(val) ((val) * 1000)
162 143
163#define PWM_TO_REG(val) (SENSORS_LIMIT(val,0,255)) 144#define PWM_TO_REG(val) SENSORS_LIMIT(val, 0, 255)
164#define PWM_FROM_REG(val) (val) 145#define PWM_FROM_REG(val) (val)
165 146
166 147
@@ -183,17 +164,17 @@ static inline u16 FAN_TO_REG(unsigned long val)
183 */ 164 */
184 165
185/* These are the zone temperature range encodings in .001 degree C */ 166/* These are the zone temperature range encodings in .001 degree C */
186static int lm85_range_map[] = { 167static const int lm85_range_map[] = {
187 2000, 2500, 3300, 4000, 5000, 6600, 168 2000, 2500, 3300, 4000, 5000, 6600, 8000, 10000,
188 8000, 10000, 13300, 16000, 20000, 26600, 169 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000
189 32000, 40000, 53300, 80000 170};
190 }; 171
191static int RANGE_TO_REG( int range ) 172static int RANGE_TO_REG(int range)
192{ 173{
193 int i; 174 int i;
194 175
195 if (range >= lm85_range_map[15]) 176 if (range >= lm85_range_map[15])
196 return 15 ; 177 return 15;
197 178
198 /* Find the closest match */ 179 /* Find the closest match */
199 for (i = 14; i >= 0; --i) { 180 for (i = 14; i >= 0; --i) {
@@ -207,28 +188,25 @@ static int RANGE_TO_REG( int range )
207 188
208 return 0; 189 return 0;
209} 190}
210#define RANGE_FROM_REG(val) (lm85_range_map[(val)&0x0f]) 191#define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f]
211 192
212/* These are the Acoustic Enhancement, or Temperature smoothing encodings
213 * NOTE: The enable/disable bit is INCLUDED in these encodings as the
214 * MSB (bit 3, value 8). If the enable bit is 0, the encoded value
215 * is ignored, or set to 0.
216 */
217/* These are the PWM frequency encodings */ 193/* These are the PWM frequency encodings */
218static int lm85_freq_map[] = { /* .1 Hz */ 194static const int lm85_freq_map[] = { /* .1 Hz */
219 100, 150, 230, 300, 380, 470, 620, 940 195 100, 150, 230, 300, 380, 470, 620, 940
220 }; 196};
221static int FREQ_TO_REG( int freq ) 197
198static int FREQ_TO_REG(int freq)
222{ 199{
223 int i; 200 int i;
224 201
225 if( freq >= lm85_freq_map[7] ) { return 7 ; } 202 if (freq >= lm85_freq_map[7])
226 for( i = 0 ; i < 7 ; ++i ) 203 return 7;
227 if( freq <= lm85_freq_map[i] ) 204 for (i = 0; i < 7; ++i)
228 break ; 205 if (freq <= lm85_freq_map[i])
229 return( i & 0x07 ); 206 break;
207 return i;
230} 208}
231#define FREQ_FROM_REG(val) (lm85_freq_map[(val)&0x07]) 209#define FREQ_FROM_REG(val) lm85_freq_map[(val) & 0x07]
232 210
233/* Since we can't use strings, I'm abusing these numbers 211/* Since we can't use strings, I'm abusing these numbers
234 * to stand in for the following meanings: 212 * to stand in for the following meanings:
@@ -242,30 +220,23 @@ static int FREQ_TO_REG( int freq )
242 * -2 -- PWM responds to manual control 220 * -2 -- PWM responds to manual control
243 */ 221 */
244 222
245static int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 }; 223static const int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 };
246#define ZONE_FROM_REG(val) (lm85_zone_map[((val)>>5)&0x07]) 224#define ZONE_FROM_REG(val) lm85_zone_map[(val) >> 5]
247 225
248static int ZONE_TO_REG( int zone ) 226static int ZONE_TO_REG(int zone)
249{ 227{
250 int i; 228 int i;
251 229
252 for( i = 0 ; i <= 7 ; ++i ) 230 for (i = 0; i <= 7; ++i)
253 if( zone == lm85_zone_map[i] ) 231 if (zone == lm85_zone_map[i])
254 break ; 232 break;
255 if( i > 7 ) /* Not found. */ 233 if (i > 7) /* Not found. */
256 i = 3; /* Always 100% */ 234 i = 3; /* Always 100% */
257 return( (i & 0x07)<<5 ); 235 return i << 5;
258} 236}
259 237
260#define HYST_TO_REG(val) (SENSORS_LIMIT(((val)+500)/1000,0,15)) 238#define HYST_TO_REG(val) SENSORS_LIMIT(((val) + 500) / 1000, 0, 15)
261#define HYST_FROM_REG(val) ((val)*1000) 239#define HYST_FROM_REG(val) ((val) * 1000)
262
263#define OFFSET_TO_REG(val) (SENSORS_LIMIT((val)/25,-127,127))
264#define OFFSET_FROM_REG(val) ((val)*25)
265
266#define PPR_MASK(fan) (0x03<<(fan *2))
267#define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2))
268#define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1)
269 240
270/* Chip sampling rates 241/* Chip sampling rates
271 * 242 *
@@ -292,11 +263,11 @@ struct lm85_zone {
292 u8 hyst; /* Low limit hysteresis. (0-15) */ 263 u8 hyst; /* Low limit hysteresis. (0-15) */
293 u8 range; /* Temp range, encoded */ 264 u8 range; /* Temp range, encoded */
294 s8 critical; /* "All fans ON" temp limit */ 265 s8 critical; /* "All fans ON" temp limit */
295 u8 off_desired; /* Actual "off" temperature specified. Preserved 266 u8 off_desired; /* Actual "off" temperature specified. Preserved
296 * to prevent "drift" as other autofan control 267 * to prevent "drift" as other autofan control
297 * values change. 268 * values change.
298 */ 269 */
299 u8 max_desired; /* Actual "max" temperature specified. Preserved 270 u8 max_desired; /* Actual "max" temperature specified. Preserved
300 * to prevent "drift" as other autofan control 271 * to prevent "drift" as other autofan control
301 * values change. 272 * values change.
302 */ 273 */
@@ -327,23 +298,13 @@ struct lm85_data {
327 s8 temp[3]; /* Register value */ 298 s8 temp[3]; /* Register value */
328 s8 temp_min[3]; /* Register value */ 299 s8 temp_min[3]; /* Register value */
329 s8 temp_max[3]; /* Register value */ 300 s8 temp_max[3]; /* Register value */
330 s8 temp_offset[3]; /* Register value */
331 u16 fan[4]; /* Register value */ 301 u16 fan[4]; /* Register value */
332 u16 fan_min[4]; /* Register value */ 302 u16 fan_min[4]; /* Register value */
333 u8 pwm[3]; /* Register value */ 303 u8 pwm[3]; /* Register value */
334 u8 spinup_ctl; /* Register encoding, combined */
335 u8 tach_mode; /* Register encoding, combined */
336 u8 temp_ext[3]; /* Decoded values */ 304 u8 temp_ext[3]; /* Decoded values */
337 u8 in_ext[8]; /* Decoded values */ 305 u8 in_ext[8]; /* Decoded values */
338 u8 fan_ppr; /* Register value */
339 u8 smooth[3]; /* Register encoding */
340 u8 vid; /* Register value */ 306 u8 vid; /* Register value */
341 u8 vrm; /* VRM version */ 307 u8 vrm; /* VRM version */
342 u8 syncpwm3; /* Saved PWM3 for TACH 2,3,4 config */
343 u8 oppoint[3]; /* Register value */
344 u16 tmin_ctl; /* Register value */
345 unsigned long therm_total; /* Cummulative therm count */
346 u8 therm_limit; /* Register value */
347 u32 alarms; /* Register encoding, combined */ 308 u32 alarms; /* Register encoding, combined */
348 struct lm85_autofan autofan[3]; 309 struct lm85_autofan autofan[3];
349 struct lm85_zone zone[3]; 310 struct lm85_zone zone[3];
@@ -355,9 +316,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
355static int lm85_detach_client(struct i2c_client *client); 316static int lm85_detach_client(struct i2c_client *client);
356 317
357static int lm85_read_value(struct i2c_client *client, u8 reg); 318static int lm85_read_value(struct i2c_client *client, u8 reg);
358static int lm85_write_value(struct i2c_client *client, u8 reg, int value); 319static void lm85_write_value(struct i2c_client *client, u8 reg, int value);
359static struct lm85_data *lm85_update_device(struct device *dev); 320static struct lm85_data *lm85_update_device(struct device *dev);
360static void lm85_init_client(struct i2c_client *client);
361 321
362 322
363static struct i2c_driver lm85_driver = { 323static struct i2c_driver lm85_driver = {
@@ -375,7 +335,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
375{ 335{
376 int nr = to_sensor_dev_attr(attr)->index; 336 int nr = to_sensor_dev_attr(attr)->index;
377 struct lm85_data *data = lm85_update_device(dev); 337 struct lm85_data *data = lm85_update_device(dev);
378 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr]) ); 338 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr]));
379} 339}
380 340
381static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, 341static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
@@ -383,7 +343,7 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
383{ 343{
384 int nr = to_sensor_dev_attr(attr)->index; 344 int nr = to_sensor_dev_attr(attr)->index;
385 struct lm85_data *data = lm85_update_device(dev); 345 struct lm85_data *data = lm85_update_device(dev);
386 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr]) ); 346 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr]));
387} 347}
388 348
389static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, 349static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
@@ -414,7 +374,8 @@ show_fan_offset(4);
414 374
415/* vid, vrm, alarms */ 375/* vid, vrm, alarms */
416 376
417static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) 377static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr,
378 char *buf)
418{ 379{
419 struct lm85_data *data = lm85_update_device(dev); 380 struct lm85_data *data = lm85_update_device(dev);
420 int vid; 381 int vid;
@@ -432,13 +393,15 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c
432 393
433static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 394static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
434 395
435static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 396static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr,
397 char *buf)
436{ 398{
437 struct lm85_data *data = dev_get_drvdata(dev); 399 struct lm85_data *data = dev_get_drvdata(dev);
438 return sprintf(buf, "%ld\n", (long) data->vrm); 400 return sprintf(buf, "%ld\n", (long) data->vrm);
439} 401}
440 402
441static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 403static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
404 const char *buf, size_t count)
442{ 405{
443 struct lm85_data *data = dev_get_drvdata(dev); 406 struct lm85_data *data = dev_get_drvdata(dev);
444 data->vrm = simple_strtoul(buf, NULL, 10); 407 data->vrm = simple_strtoul(buf, NULL, 10);
@@ -447,7 +410,8 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
447 410
448static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 411static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
449 412
450static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 413static ssize_t show_alarms_reg(struct device *dev, struct device_attribute
414 *attr, char *buf)
451{ 415{
452 struct lm85_data *data = lm85_update_device(dev); 416 struct lm85_data *data = lm85_update_device(dev);
453 return sprintf(buf, "%u\n", data->alarms); 417 return sprintf(buf, "%u\n", data->alarms);
@@ -488,7 +452,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
488{ 452{
489 int nr = to_sensor_dev_attr(attr)->index; 453 int nr = to_sensor_dev_attr(attr)->index;
490 struct lm85_data *data = lm85_update_device(dev); 454 struct lm85_data *data = lm85_update_device(dev);
491 return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm[nr]) ); 455 return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr]));
492} 456}
493 457
494static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, 458static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
@@ -581,17 +545,16 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,
581{ 545{
582 int nr = to_sensor_dev_attr(attr)->index; 546 int nr = to_sensor_dev_attr(attr)->index;
583 struct lm85_data *data = lm85_update_device(dev); 547 struct lm85_data *data = lm85_update_device(dev);
584 return sprintf( buf, "%d\n", INSEXT_FROM_REG(nr, 548 return sprintf(buf, "%d\n", INSEXT_FROM_REG(nr, data->in[nr],
585 data->in[nr], 549 data->in_ext[nr]));
586 data->in_ext[nr]));
587} 550}
588 551
589static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, 552static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
590 char *buf) 553 char *buf)
591{ 554{
592 int nr = to_sensor_dev_attr(attr)->index; 555 int nr = to_sensor_dev_attr(attr)->index;
593 struct lm85_data *data = lm85_update_device(dev); 556 struct lm85_data *data = lm85_update_device(dev);
594 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr]) ); 557 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr]));
595} 558}
596 559
597static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, 560static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
@@ -614,7 +577,7 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
614{ 577{
615 int nr = to_sensor_dev_attr(attr)->index; 578 int nr = to_sensor_dev_attr(attr)->index;
616 struct lm85_data *data = lm85_update_device(dev); 579 struct lm85_data *data = lm85_update_device(dev);
617 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr]) ); 580 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr]));
618} 581}
619 582
620static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, 583static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
@@ -656,8 +619,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
656{ 619{
657 int nr = to_sensor_dev_attr(attr)->index; 620 int nr = to_sensor_dev_attr(attr)->index;
658 struct lm85_data *data = lm85_update_device(dev); 621 struct lm85_data *data = lm85_update_device(dev);
659 return sprintf(buf,"%d\n", TEMPEXT_FROM_REG(data->temp[nr], 622 return sprintf(buf, "%d\n", TEMPEXT_FROM_REG(data->temp[nr],
660 data->temp_ext[nr])); 623 data->temp_ext[nr]));
661} 624}
662 625
663static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, 626static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
@@ -665,7 +628,7 @@ static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
665{ 628{
666 int nr = to_sensor_dev_attr(attr)->index; 629 int nr = to_sensor_dev_attr(attr)->index;
667 struct lm85_data *data = lm85_update_device(dev); 630 struct lm85_data *data = lm85_update_device(dev);
668 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr]) ); 631 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr]));
669} 632}
670 633
671static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, 634static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -688,7 +651,7 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
688{ 651{
689 int nr = to_sensor_dev_attr(attr)->index; 652 int nr = to_sensor_dev_attr(attr)->index;
690 struct lm85_data *data = lm85_update_device(dev); 653 struct lm85_data *data = lm85_update_device(dev);
691 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr]) ); 654 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr]));
692} 655}
693 656
694static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, 657static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
@@ -697,7 +660,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
697 int nr = to_sensor_dev_attr(attr)->index; 660 int nr = to_sensor_dev_attr(attr)->index;
698 struct i2c_client *client = to_i2c_client(dev); 661 struct i2c_client *client = to_i2c_client(dev);
699 struct lm85_data *data = i2c_get_clientdata(client); 662 struct lm85_data *data = i2c_get_clientdata(client);
700 long val = simple_strtol(buf, NULL, 10); 663 long val = simple_strtol(buf, NULL, 10);
701 664
702 mutex_lock(&data->update_lock); 665 mutex_lock(&data->update_lock);
703 data->temp_max[nr] = TEMP_TO_REG(val); 666 data->temp_max[nr] = TEMP_TO_REG(val);
@@ -726,7 +689,7 @@ static ssize_t show_pwm_auto_channels(struct device *dev,
726{ 689{
727 int nr = to_sensor_dev_attr(attr)->index; 690 int nr = to_sensor_dev_attr(attr)->index;
728 struct lm85_data *data = lm85_update_device(dev); 691 struct lm85_data *data = lm85_update_device(dev);
729 return sprintf(buf,"%d\n", ZONE_FROM_REG(data->autofan[nr].config)); 692 return sprintf(buf, "%d\n", ZONE_FROM_REG(data->autofan[nr].config));
730} 693}
731 694
732static ssize_t set_pwm_auto_channels(struct device *dev, 695static ssize_t set_pwm_auto_channels(struct device *dev,
@@ -735,11 +698,11 @@ static ssize_t set_pwm_auto_channels(struct device *dev,
735 int nr = to_sensor_dev_attr(attr)->index; 698 int nr = to_sensor_dev_attr(attr)->index;
736 struct i2c_client *client = to_i2c_client(dev); 699 struct i2c_client *client = to_i2c_client(dev);
737 struct lm85_data *data = i2c_get_clientdata(client); 700 struct lm85_data *data = i2c_get_clientdata(client);
738 long val = simple_strtol(buf, NULL, 10); 701 long val = simple_strtol(buf, NULL, 10);
739 702
740 mutex_lock(&data->update_lock); 703 mutex_lock(&data->update_lock);
741 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) 704 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
742 | ZONE_TO_REG(val) ; 705 | ZONE_TO_REG(val);
743 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), 706 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
744 data->autofan[nr].config); 707 data->autofan[nr].config);
745 mutex_unlock(&data->update_lock); 708 mutex_unlock(&data->update_lock);
@@ -751,7 +714,7 @@ static ssize_t show_pwm_auto_pwm_min(struct device *dev,
751{ 714{
752 int nr = to_sensor_dev_attr(attr)->index; 715 int nr = to_sensor_dev_attr(attr)->index;
753 struct lm85_data *data = lm85_update_device(dev); 716 struct lm85_data *data = lm85_update_device(dev);
754 return sprintf(buf,"%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm)); 717 return sprintf(buf, "%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm));
755} 718}
756 719
757static ssize_t set_pwm_auto_pwm_min(struct device *dev, 720static ssize_t set_pwm_auto_pwm_min(struct device *dev,
@@ -775,7 +738,7 @@ static ssize_t show_pwm_auto_pwm_minctl(struct device *dev,
775{ 738{
776 int nr = to_sensor_dev_attr(attr)->index; 739 int nr = to_sensor_dev_attr(attr)->index;
777 struct lm85_data *data = lm85_update_device(dev); 740 struct lm85_data *data = lm85_update_device(dev);
778 return sprintf(buf,"%d\n", data->autofan[nr].min_off); 741 return sprintf(buf, "%d\n", data->autofan[nr].min_off);
779} 742}
780 743
781static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, 744static ssize_t set_pwm_auto_pwm_minctl(struct device *dev,
@@ -785,15 +748,15 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev,
785 struct i2c_client *client = to_i2c_client(dev); 748 struct i2c_client *client = to_i2c_client(dev);
786 struct lm85_data *data = i2c_get_clientdata(client); 749 struct lm85_data *data = i2c_get_clientdata(client);
787 long val = simple_strtol(buf, NULL, 10); 750 long val = simple_strtol(buf, NULL, 10);
751 u8 tmp;
788 752
789 mutex_lock(&data->update_lock); 753 mutex_lock(&data->update_lock);
790 data->autofan[nr].min_off = val; 754 data->autofan[nr].min_off = val;
791 lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] 755 tmp = lm85_read_value(client, LM85_REG_AFAN_SPIKE1);
792 | data->syncpwm3 756 tmp &= ~(0x20 << nr);
793 | (data->autofan[0].min_off ? 0x20 : 0) 757 if (data->autofan[nr].min_off)
794 | (data->autofan[1].min_off ? 0x40 : 0) 758 tmp |= 0x20 << nr;
795 | (data->autofan[2].min_off ? 0x80 : 0) 759 lm85_write_value(client, LM85_REG_AFAN_SPIKE1, tmp);
796 );
797 mutex_unlock(&data->update_lock); 760 mutex_unlock(&data->update_lock);
798 return count; 761 return count;
799} 762}
@@ -803,7 +766,7 @@ static ssize_t show_pwm_auto_pwm_freq(struct device *dev,
803{ 766{
804 int nr = to_sensor_dev_attr(attr)->index; 767 int nr = to_sensor_dev_attr(attr)->index;
805 struct lm85_data *data = lm85_update_device(dev); 768 struct lm85_data *data = lm85_update_device(dev);
806 return sprintf(buf,"%d\n", FREQ_FROM_REG(data->autofan[nr].freq)); 769 return sprintf(buf, "%d\n", FREQ_FROM_REG(data->autofan[nr].freq));
807} 770}
808 771
809static ssize_t set_pwm_auto_pwm_freq(struct device *dev, 772static ssize_t set_pwm_auto_pwm_freq(struct device *dev,
@@ -818,8 +781,7 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev,
818 data->autofan[nr].freq = FREQ_TO_REG(val); 781 data->autofan[nr].freq = FREQ_TO_REG(val);
819 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 782 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
820 (data->zone[nr].range << 4) 783 (data->zone[nr].range << 4)
821 | data->autofan[nr].freq 784 | data->autofan[nr].freq);
822 );
823 mutex_unlock(&data->update_lock); 785 mutex_unlock(&data->update_lock);
824 return count; 786 return count;
825} 787}
@@ -849,7 +811,7 @@ static ssize_t show_temp_auto_temp_off(struct device *dev,
849{ 811{
850 int nr = to_sensor_dev_attr(attr)->index; 812 int nr = to_sensor_dev_attr(attr)->index;
851 struct lm85_data *data = lm85_update_device(dev); 813 struct lm85_data *data = lm85_update_device(dev);
852 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) - 814 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) -
853 HYST_FROM_REG(data->zone[nr].hyst)); 815 HYST_FROM_REG(data->zone[nr].hyst));
854} 816}
855 817
@@ -866,15 +828,13 @@ static ssize_t set_temp_auto_temp_off(struct device *dev,
866 min = TEMP_FROM_REG(data->zone[nr].limit); 828 min = TEMP_FROM_REG(data->zone[nr].limit);
867 data->zone[nr].off_desired = TEMP_TO_REG(val); 829 data->zone[nr].off_desired = TEMP_TO_REG(val);
868 data->zone[nr].hyst = HYST_TO_REG(min - val); 830 data->zone[nr].hyst = HYST_TO_REG(min - val);
869 if ( nr == 0 || nr == 1 ) { 831 if (nr == 0 || nr == 1) {
870 lm85_write_value(client, LM85_REG_AFAN_HYST1, 832 lm85_write_value(client, LM85_REG_AFAN_HYST1,
871 (data->zone[0].hyst << 4) 833 (data->zone[0].hyst << 4)
872 | data->zone[1].hyst 834 | data->zone[1].hyst);
873 );
874 } else { 835 } else {
875 lm85_write_value(client, LM85_REG_AFAN_HYST2, 836 lm85_write_value(client, LM85_REG_AFAN_HYST2,
876 (data->zone[2].hyst << 4) 837 (data->zone[2].hyst << 4));
877 );
878 } 838 }
879 mutex_unlock(&data->update_lock); 839 mutex_unlock(&data->update_lock);
880 return count; 840 return count;
@@ -885,7 +845,7 @@ static ssize_t show_temp_auto_temp_min(struct device *dev,
885{ 845{
886 int nr = to_sensor_dev_attr(attr)->index; 846 int nr = to_sensor_dev_attr(attr)->index;
887 struct lm85_data *data = lm85_update_device(dev); 847 struct lm85_data *data = lm85_update_device(dev);
888 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) ); 848 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit));
889} 849}
890 850
891static ssize_t set_temp_auto_temp_min(struct device *dev, 851static ssize_t set_temp_auto_temp_min(struct device *dev,
@@ -913,15 +873,13 @@ static ssize_t set_temp_auto_temp_min(struct device *dev,
913 data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG( 873 data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG(
914 data->zone[nr].limit) - TEMP_FROM_REG( 874 data->zone[nr].limit) - TEMP_FROM_REG(
915 data->zone[nr].off_desired)); 875 data->zone[nr].off_desired));
916 if ( nr == 0 || nr == 1 ) { 876 if (nr == 0 || nr == 1) {
917 lm85_write_value(client, LM85_REG_AFAN_HYST1, 877 lm85_write_value(client, LM85_REG_AFAN_HYST1,
918 (data->zone[0].hyst << 4) 878 (data->zone[0].hyst << 4)
919 | data->zone[1].hyst 879 | data->zone[1].hyst);
920 );
921 } else { 880 } else {
922 lm85_write_value(client, LM85_REG_AFAN_HYST2, 881 lm85_write_value(client, LM85_REG_AFAN_HYST2,
923 (data->zone[2].hyst << 4) 882 (data->zone[2].hyst << 4));
924 );
925 } 883 }
926 mutex_unlock(&data->update_lock); 884 mutex_unlock(&data->update_lock);
927 return count; 885 return count;
@@ -932,7 +890,7 @@ static ssize_t show_temp_auto_temp_max(struct device *dev,
932{ 890{
933 int nr = to_sensor_dev_attr(attr)->index; 891 int nr = to_sensor_dev_attr(attr)->index;
934 struct lm85_data *data = lm85_update_device(dev); 892 struct lm85_data *data = lm85_update_device(dev);
935 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) + 893 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) +
936 RANGE_FROM_REG(data->zone[nr].range)); 894 RANGE_FROM_REG(data->zone[nr].range));
937} 895}
938 896
@@ -962,11 +920,11 @@ static ssize_t show_temp_auto_temp_crit(struct device *dev,
962{ 920{
963 int nr = to_sensor_dev_attr(attr)->index; 921 int nr = to_sensor_dev_attr(attr)->index;
964 struct lm85_data *data = lm85_update_device(dev); 922 struct lm85_data *data = lm85_update_device(dev);
965 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].critical)); 923 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].critical));
966} 924}
967 925
968static ssize_t set_temp_auto_temp_crit(struct device *dev, 926static ssize_t set_temp_auto_temp_crit(struct device *dev,
969 struct device_attribute *attr,const char *buf, size_t count) 927 struct device_attribute *attr, const char *buf, size_t count)
970{ 928{
971 int nr = to_sensor_dev_attr(attr)->index; 929 int nr = to_sensor_dev_attr(attr)->index;
972 struct i2c_client *client = to_i2c_client(dev); 930 struct i2c_client *client = to_i2c_client(dev);
@@ -1127,20 +1085,37 @@ static const struct attribute_group lm85_group_in567 = {
1127 .attrs = lm85_attributes_in567, 1085 .attrs = lm85_attributes_in567,
1128}; 1086};
1129 1087
1088static void lm85_init_client(struct i2c_client *client)
1089{
1090 int value;
1091
1092 /* Start monitoring if needed */
1093 value = lm85_read_value(client, LM85_REG_CONFIG);
1094 if (!(value & 0x01)) {
1095 dev_info(&client->dev, "Starting monitoring\n");
1096 lm85_write_value(client, LM85_REG_CONFIG, value | 0x01);
1097 }
1098
1099 /* Warn about unusual configuration bits */
1100 if (value & 0x02)
1101 dev_warn(&client->dev, "Device configuration is locked\n");
1102 if (!(value & 0x04))
1103 dev_warn(&client->dev, "Device is not ready\n");
1104}
1105
1130static int lm85_detect(struct i2c_adapter *adapter, int address, 1106static int lm85_detect(struct i2c_adapter *adapter, int address,
1131 int kind) 1107 int kind)
1132{ 1108{
1133 int company, verstep ; 1109 int company, verstep;
1134 struct i2c_client *new_client = NULL; 1110 struct i2c_client *client;
1135 struct lm85_data *data; 1111 struct lm85_data *data;
1136 int err = 0; 1112 int err = 0;
1137 const char *type_name = ""; 1113 const char *type_name;
1138 1114
1139 if (!i2c_check_functionality(adapter, 1115 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
1140 I2C_FUNC_SMBUS_BYTE_DATA)) {
1141 /* We need to be able to do byte I/O */ 1116 /* We need to be able to do byte I/O */
1142 goto ERROR0 ; 1117 goto ERROR0;
1143 }; 1118 }
1144 1119
1145 /* OK. For now, we presume we have a valid client. We now create the 1120 /* OK. For now, we presume we have a valid client. We now create the
1146 client structure, even though we cannot fill it completely yet. 1121 client structure, even though we cannot fill it completely yet.
@@ -1151,138 +1126,145 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1151 goto ERROR0; 1126 goto ERROR0;
1152 } 1127 }
1153 1128
1154 new_client = &data->client; 1129 client = &data->client;
1155 i2c_set_clientdata(new_client, data); 1130 i2c_set_clientdata(client, data);
1156 new_client->addr = address; 1131 client->addr = address;
1157 new_client->adapter = adapter; 1132 client->adapter = adapter;
1158 new_client->driver = &lm85_driver; 1133 client->driver = &lm85_driver;
1159 new_client->flags = 0;
1160 1134
1161 /* Now, we do the remaining detection. */ 1135 /* Now, we do the remaining detection. */
1162 1136
1163 company = lm85_read_value(new_client, LM85_REG_COMPANY); 1137 company = lm85_read_value(client, LM85_REG_COMPANY);
1164 verstep = lm85_read_value(new_client, LM85_REG_VERSTEP); 1138 verstep = lm85_read_value(client, LM85_REG_VERSTEP);
1165 1139
1166 dev_dbg(&adapter->dev, "Detecting device at %d,0x%02x with" 1140 dev_dbg(&adapter->dev, "Detecting device at %d,0x%02x with"
1167 " COMPANY: 0x%02x and VERSTEP: 0x%02x\n", 1141 " COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
1168 i2c_adapter_id(new_client->adapter), new_client->addr, 1142 i2c_adapter_id(client->adapter), client->addr,
1169 company, verstep); 1143 company, verstep);
1170 1144
1171 /* If auto-detecting, Determine the chip type. */ 1145 /* If auto-detecting, Determine the chip type. */
1172 if (kind <= 0) { 1146 if (kind <= 0) {
1173 dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x ...\n", 1147 dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x ...\n",
1174 i2c_adapter_id(adapter), address ); 1148 i2c_adapter_id(adapter), address);
1175 if( company == LM85_COMPANY_NATIONAL 1149 if (company == LM85_COMPANY_NATIONAL
1176 && verstep == LM85_VERSTEP_LM85C ) { 1150 && verstep == LM85_VERSTEP_LM85C) {
1177 kind = lm85c ; 1151 kind = lm85c;
1178 } else if( company == LM85_COMPANY_NATIONAL 1152 } else if (company == LM85_COMPANY_NATIONAL
1179 && verstep == LM85_VERSTEP_LM85B ) { 1153 && verstep == LM85_VERSTEP_LM85B) {
1180 kind = lm85b ; 1154 kind = lm85b;
1181 } else if( company == LM85_COMPANY_NATIONAL 1155 } else if (company == LM85_COMPANY_NATIONAL
1182 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) { 1156 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1183 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" 1157 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
1184 " Defaulting to LM85.\n", verstep); 1158 " Defaulting to LM85.\n", verstep);
1185 kind = any_chip ; 1159 kind = any_chip;
1186 } else if( company == LM85_COMPANY_ANALOG_DEV 1160 } else if (company == LM85_COMPANY_ANALOG_DEV
1187 && verstep == LM85_VERSTEP_ADM1027 ) { 1161 && verstep == LM85_VERSTEP_ADM1027) {
1188 kind = adm1027 ; 1162 kind = adm1027;
1189 } else if( company == LM85_COMPANY_ANALOG_DEV 1163 } else if (company == LM85_COMPANY_ANALOG_DEV
1190 && (verstep == LM85_VERSTEP_ADT7463 1164 && (verstep == LM85_VERSTEP_ADT7463
1191 || verstep == LM85_VERSTEP_ADT7463C) ) { 1165 || verstep == LM85_VERSTEP_ADT7463C)) {
1192 kind = adt7463 ; 1166 kind = adt7463;
1193 } else if( company == LM85_COMPANY_ANALOG_DEV 1167 } else if (company == LM85_COMPANY_ANALOG_DEV
1194 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) { 1168 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1195 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" 1169 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
1196 " Defaulting to Generic LM85.\n", verstep ); 1170 " Defaulting to Generic LM85.\n", verstep);
1197 kind = any_chip ; 1171 kind = any_chip;
1198 } else if( company == LM85_COMPANY_SMSC 1172 } else if (company == LM85_COMPANY_SMSC
1199 && (verstep == LM85_VERSTEP_EMC6D100_A0 1173 && (verstep == LM85_VERSTEP_EMC6D100_A0
1200 || verstep == LM85_VERSTEP_EMC6D100_A1) ) { 1174 || verstep == LM85_VERSTEP_EMC6D100_A1)) {
1201 /* Unfortunately, we can't tell a '100 from a '101 1175 /* Unfortunately, we can't tell a '100 from a '101
1202 * from the registers. Since a '101 is a '100 1176 * from the registers. Since a '101 is a '100
1203 * in a package with fewer pins and therefore no 1177 * in a package with fewer pins and therefore no
1204 * 3.3V, 1.5V or 1.8V inputs, perhaps if those 1178 * 3.3V, 1.5V or 1.8V inputs, perhaps if those
1205 * inputs read 0, then it's a '101. 1179 * inputs read 0, then it's a '101.
1206 */ 1180 */
1207 kind = emc6d100 ; 1181 kind = emc6d100;
1208 } else if( company == LM85_COMPANY_SMSC 1182 } else if (company == LM85_COMPANY_SMSC
1209 && verstep == LM85_VERSTEP_EMC6D102) { 1183 && verstep == LM85_VERSTEP_EMC6D102) {
1210 kind = emc6d102 ; 1184 kind = emc6d102;
1211 } else if( company == LM85_COMPANY_SMSC 1185 } else if (company == LM85_COMPANY_SMSC
1212 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { 1186 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1213 dev_err(&adapter->dev, "lm85: Detected SMSC chip\n"); 1187 dev_err(&adapter->dev, "lm85: Detected SMSC chip\n");
1214 dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x" 1188 dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x"
1215 " Defaulting to Generic LM85.\n", verstep ); 1189 " Defaulting to Generic LM85.\n", verstep);
1216 kind = any_chip ; 1190 kind = any_chip;
1217 } else if( kind == any_chip 1191 } else if (kind == any_chip
1218 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { 1192 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1219 dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n"); 1193 dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n");
1220 /* Leave kind as "any_chip" */ 1194 /* Leave kind as "any_chip" */
1221 } else { 1195 } else {
1222 dev_dbg(&adapter->dev, "Autodetection failed\n"); 1196 dev_dbg(&adapter->dev, "Autodetection failed\n");
1223 /* Not an LM85 ... */ 1197 /* Not an LM85... */
1224 if( kind == any_chip ) { /* User used force=x,y */ 1198 if (kind == any_chip) { /* User used force=x,y */
1225 dev_err(&adapter->dev, "Generic LM85 Version 6 not" 1199 dev_err(&adapter->dev, "Generic LM85 Version 6 not"
1226 " found at %d,0x%02x. Try force_lm85c.\n", 1200 " found at %d,0x%02x. Try force_lm85c.\n",
1227 i2c_adapter_id(adapter), address ); 1201 i2c_adapter_id(adapter), address);
1228 } 1202 }
1229 err = 0 ; 1203 err = 0;
1230 goto ERROR1; 1204 goto ERROR1;
1231 } 1205 }
1232 } 1206 }
1233 1207
1234 /* Fill in the chip specific driver values */ 1208 /* Fill in the chip specific driver values */
1235 if ( kind == any_chip ) { 1209 switch (kind) {
1236 type_name = "lm85"; 1210 case lm85b:
1237 } else if ( kind == lm85b ) {
1238 type_name = "lm85b"; 1211 type_name = "lm85b";
1239 } else if ( kind == lm85c ) { 1212 break;
1213 case lm85c:
1240 type_name = "lm85c"; 1214 type_name = "lm85c";
1241 } else if ( kind == adm1027 ) { 1215 break;
1216 case adm1027:
1242 type_name = "adm1027"; 1217 type_name = "adm1027";
1243 } else if ( kind == adt7463 ) { 1218 break;
1219 case adt7463:
1244 type_name = "adt7463"; 1220 type_name = "adt7463";
1245 } else if ( kind == emc6d100){ 1221 break;
1222 case emc6d100:
1246 type_name = "emc6d100"; 1223 type_name = "emc6d100";
1247 } else if ( kind == emc6d102 ) { 1224 break;
1225 case emc6d102:
1248 type_name = "emc6d102"; 1226 type_name = "emc6d102";
1227 break;
1228 default:
1229 type_name = "lm85";
1249 } 1230 }
1250 strlcpy(new_client->name, type_name, I2C_NAME_SIZE); 1231 strlcpy(client->name, type_name, I2C_NAME_SIZE);
1251 1232
1252 /* Fill in the remaining client fields */ 1233 /* Fill in the remaining client fields */
1253 data->type = kind; 1234 data->type = kind;
1254 data->valid = 0;
1255 mutex_init(&data->update_lock); 1235 mutex_init(&data->update_lock);
1256 1236
1257 /* Tell the I2C layer a new client has arrived */ 1237 /* Tell the I2C layer a new client has arrived */
1258 if ((err = i2c_attach_client(new_client))) 1238 err = i2c_attach_client(client);
1239 if (err)
1259 goto ERROR1; 1240 goto ERROR1;
1260 1241
1261 /* Set the VRM version */ 1242 /* Set the VRM version */
1262 data->vrm = vid_which_vrm(); 1243 data->vrm = vid_which_vrm();
1263 1244
1264 /* Initialize the LM85 chip */ 1245 /* Initialize the LM85 chip */
1265 lm85_init_client(new_client); 1246 lm85_init_client(client);
1266 1247
1267 /* Register sysfs hooks */ 1248 /* Register sysfs hooks */
1268 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm85_group))) 1249 err = sysfs_create_group(&client->dev.kobj, &lm85_group);
1250 if (err)
1269 goto ERROR2; 1251 goto ERROR2;
1270 1252
1271 /* The ADT7463 has an optional VRM 10 mode where pin 21 is used 1253 /* The ADT7463 has an optional VRM 10 mode where pin 21 is used
1272 as a sixth digital VID input rather than an analog input. */ 1254 as a sixth digital VID input rather than an analog input. */
1273 data->vid = lm85_read_value(new_client, LM85_REG_VID); 1255 data->vid = lm85_read_value(client, LM85_REG_VID);
1274 if (!(kind == adt7463 && (data->vid & 0x80))) 1256 if (!(kind == adt7463 && (data->vid & 0x80)))
1275 if ((err = sysfs_create_group(&new_client->dev.kobj, 1257 if ((err = sysfs_create_group(&client->dev.kobj,
1276 &lm85_group_in4))) 1258 &lm85_group_in4)))
1277 goto ERROR3; 1259 goto ERROR3;
1278 1260
1279 /* The EMC6D100 has 3 additional voltage inputs */ 1261 /* The EMC6D100 has 3 additional voltage inputs */
1280 if (kind == emc6d100) 1262 if (kind == emc6d100)
1281 if ((err = sysfs_create_group(&new_client->dev.kobj, 1263 if ((err = sysfs_create_group(&client->dev.kobj,
1282 &lm85_group_in567))) 1264 &lm85_group_in567)))
1283 goto ERROR3; 1265 goto ERROR3;
1284 1266
1285 data->hwmon_dev = hwmon_device_register(&new_client->dev); 1267 data->hwmon_dev = hwmon_device_register(&client->dev);
1286 if (IS_ERR(data->hwmon_dev)) { 1268 if (IS_ERR(data->hwmon_dev)) {
1287 err = PTR_ERR(data->hwmon_dev); 1269 err = PTR_ERR(data->hwmon_dev);
1288 goto ERROR3; 1270 goto ERROR3;
@@ -1291,16 +1273,16 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1291 return 0; 1273 return 0;
1292 1274
1293 /* Error out and cleanup code */ 1275 /* Error out and cleanup code */
1294 ERROR3: 1276 ERROR3:
1295 sysfs_remove_group(&new_client->dev.kobj, &lm85_group); 1277 sysfs_remove_group(&client->dev.kobj, &lm85_group);
1296 sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in4); 1278 sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
1297 if (kind == emc6d100) 1279 if (kind == emc6d100)
1298 sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in567); 1280 sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
1299 ERROR2: 1281 ERROR2:
1300 i2c_detach_client(new_client); 1282 i2c_detach_client(client);
1301 ERROR1: 1283 ERROR1:
1302 kfree(data); 1284 kfree(data);
1303 ERROR0: 1285 ERROR0:
1304 return err; 1286 return err;
1305} 1287}
1306 1288
@@ -1323,100 +1305,46 @@ static int lm85_read_value(struct i2c_client *client, u8 reg)
1323 int res; 1305 int res;
1324 1306
1325 /* What size location is it? */ 1307 /* What size location is it? */
1326 switch( reg ) { 1308 switch (reg) {
1327 case LM85_REG_FAN(0) : /* Read WORD data */ 1309 case LM85_REG_FAN(0): /* Read WORD data */
1328 case LM85_REG_FAN(1) : 1310 case LM85_REG_FAN(1):
1329 case LM85_REG_FAN(2) : 1311 case LM85_REG_FAN(2):
1330 case LM85_REG_FAN(3) : 1312 case LM85_REG_FAN(3):
1331 case LM85_REG_FAN_MIN(0) : 1313 case LM85_REG_FAN_MIN(0):
1332 case LM85_REG_FAN_MIN(1) : 1314 case LM85_REG_FAN_MIN(1):
1333 case LM85_REG_FAN_MIN(2) : 1315 case LM85_REG_FAN_MIN(2):
1334 case LM85_REG_FAN_MIN(3) : 1316 case LM85_REG_FAN_MIN(3):
1335 case LM85_REG_ALARM1 : /* Read both bytes at once */ 1317 case LM85_REG_ALARM1: /* Read both bytes at once */
1336 res = i2c_smbus_read_byte_data(client, reg) & 0xff ; 1318 res = i2c_smbus_read_byte_data(client, reg) & 0xff;
1337 res |= i2c_smbus_read_byte_data(client, reg+1) << 8 ; 1319 res |= i2c_smbus_read_byte_data(client, reg + 1) << 8;
1338 break ; 1320 break;
1339 case ADT7463_REG_TMIN_CTL1 : /* Read WORD MSB, LSB */
1340 res = i2c_smbus_read_byte_data(client, reg) << 8 ;
1341 res |= i2c_smbus_read_byte_data(client, reg+1) & 0xff ;
1342 break ;
1343 default: /* Read BYTE data */ 1321 default: /* Read BYTE data */
1344 res = i2c_smbus_read_byte_data(client, reg); 1322 res = i2c_smbus_read_byte_data(client, reg);
1345 break ; 1323 break;
1346 } 1324 }
1347 1325
1348 return res ; 1326 return res;
1349} 1327}
1350 1328
1351static int lm85_write_value(struct i2c_client *client, u8 reg, int value) 1329static void lm85_write_value(struct i2c_client *client, u8 reg, int value)
1352{ 1330{
1353 int res ; 1331 switch (reg) {
1354 1332 case LM85_REG_FAN(0): /* Write WORD data */
1355 switch( reg ) { 1333 case LM85_REG_FAN(1):
1356 case LM85_REG_FAN(0) : /* Write WORD data */ 1334 case LM85_REG_FAN(2):
1357 case LM85_REG_FAN(1) : 1335 case LM85_REG_FAN(3):
1358 case LM85_REG_FAN(2) : 1336 case LM85_REG_FAN_MIN(0):
1359 case LM85_REG_FAN(3) : 1337 case LM85_REG_FAN_MIN(1):
1360 case LM85_REG_FAN_MIN(0) : 1338 case LM85_REG_FAN_MIN(2):
1361 case LM85_REG_FAN_MIN(1) : 1339 case LM85_REG_FAN_MIN(3):
1362 case LM85_REG_FAN_MIN(2) :
1363 case LM85_REG_FAN_MIN(3) :
1364 /* NOTE: ALARM is read only, so not included here */ 1340 /* NOTE: ALARM is read only, so not included here */
1365 res = i2c_smbus_write_byte_data(client, reg, value & 0xff) ; 1341 i2c_smbus_write_byte_data(client, reg, value & 0xff);
1366 res |= i2c_smbus_write_byte_data(client, reg+1, (value>>8) & 0xff) ; 1342 i2c_smbus_write_byte_data(client, reg + 1, value >> 8);
1367 break ; 1343 break;
1368 case ADT7463_REG_TMIN_CTL1 : /* Write WORD MSB, LSB */
1369 res = i2c_smbus_write_byte_data(client, reg, (value>>8) & 0xff);
1370 res |= i2c_smbus_write_byte_data(client, reg+1, value & 0xff) ;
1371 break ;
1372 default: /* Write BYTE data */ 1344 default: /* Write BYTE data */
1373 res = i2c_smbus_write_byte_data(client, reg, value); 1345 i2c_smbus_write_byte_data(client, reg, value);
1374 break ; 1346 break;
1375 } 1347 }
1376
1377 return res ;
1378}
1379
1380static void lm85_init_client(struct i2c_client *client)
1381{
1382 int value;
1383 struct lm85_data *data = i2c_get_clientdata(client);
1384
1385 dev_dbg(&client->dev, "Initializing device\n");
1386
1387 /* Warn if part was not "READY" */
1388 value = lm85_read_value(client, LM85_REG_CONFIG);
1389 dev_dbg(&client->dev, "LM85_REG_CONFIG is: 0x%02x\n", value);
1390 if( value & 0x02 ) {
1391 dev_err(&client->dev, "Client (%d,0x%02x) config is locked.\n",
1392 i2c_adapter_id(client->adapter), client->addr );
1393 };
1394 if( ! (value & 0x04) ) {
1395 dev_err(&client->dev, "Client (%d,0x%02x) is not ready.\n",
1396 i2c_adapter_id(client->adapter), client->addr );
1397 };
1398 if( value & 0x10
1399 && ( data->type == adm1027
1400 || data->type == adt7463 ) ) {
1401 dev_err(&client->dev, "Client (%d,0x%02x) VxI mode is set. "
1402 "Please report this to the lm85 maintainer.\n",
1403 i2c_adapter_id(client->adapter), client->addr );
1404 };
1405
1406 /* WE INTENTIONALLY make no changes to the limits,
1407 * offsets, pwms, fans and zones. If they were
1408 * configured, we don't want to mess with them.
1409 * If they weren't, the default is 100% PWM, no
1410 * control and will suffice until 'sensors -s'
1411 * can be run by the user.
1412 */
1413
1414 /* Start monitoring */
1415 value = lm85_read_value(client, LM85_REG_CONFIG);
1416 /* Try to clear LOCK, Set START, save everything else */
1417 value = (value & ~ 0x02) | 0x01 ;
1418 dev_dbg(&client->dev, "Setting CONFIG to: 0x%02x\n", value);
1419 lm85_write_value(client, LM85_REG_CONFIG, value);
1420} 1348}
1421 1349
1422static struct lm85_data *lm85_update_device(struct device *dev) 1350static struct lm85_data *lm85_update_device(struct device *dev)
@@ -1427,28 +1355,30 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1427 1355
1428 mutex_lock(&data->update_lock); 1356 mutex_lock(&data->update_lock);
1429 1357
1430 if ( !data->valid || 1358 if (!data->valid ||
1431 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { 1359 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL)) {
1432 /* Things that change quickly */ 1360 /* Things that change quickly */
1433 dev_dbg(&client->dev, "Reading sensor values\n"); 1361 dev_dbg(&client->dev, "Reading sensor values\n");
1434 1362
1435 /* Have to read extended bits first to "freeze" the 1363 /* Have to read extended bits first to "freeze" the
1436 * more significant bits that are read later. 1364 * more significant bits that are read later.
1437 * There are 2 additional resolution bits per channel and we 1365 * There are 2 additional resolution bits per channel and we
1438 * have room for 4, so we shift them to the left. 1366 * have room for 4, so we shift them to the left.
1439 */ 1367 */
1440 if ( (data->type == adm1027) || (data->type == adt7463) ) { 1368 if (data->type == adm1027 || data->type == adt7463) {
1441 int ext1 = lm85_read_value(client, 1369 int ext1 = lm85_read_value(client,
1442 ADM1027_REG_EXTEND_ADC1); 1370 ADM1027_REG_EXTEND_ADC1);
1443 int ext2 = lm85_read_value(client, 1371 int ext2 = lm85_read_value(client,
1444 ADM1027_REG_EXTEND_ADC2); 1372 ADM1027_REG_EXTEND_ADC2);
1445 int val = (ext1 << 8) + ext2; 1373 int val = (ext1 << 8) + ext2;
1446 1374
1447 for(i = 0; i <= 4; i++) 1375 for (i = 0; i <= 4; i++)
1448 data->in_ext[i] = ((val>>(i * 2))&0x03) << 2; 1376 data->in_ext[i] =
1377 ((val >> (i * 2)) & 0x03) << 2;
1449 1378
1450 for(i = 0; i <= 2; i++) 1379 for (i = 0; i <= 2; i++)
1451 data->temp_ext[i] = (val>>((i + 4) * 2))&0x0c; 1380 data->temp_ext[i] =
1381 (val >> ((i + 4) * 2)) & 0x0c;
1452 } 1382 }
1453 1383
1454 data->vid = lm85_read_value(client, LM85_REG_VID); 1384 data->vid = lm85_read_value(client, LM85_REG_VID);
@@ -1456,6 +1386,8 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1456 for (i = 0; i <= 3; ++i) { 1386 for (i = 0; i <= 3; ++i) {
1457 data->in[i] = 1387 data->in[i] =
1458 lm85_read_value(client, LM85_REG_IN(i)); 1388 lm85_read_value(client, LM85_REG_IN(i));
1389 data->fan[i] =
1390 lm85_read_value(client, LM85_REG_FAN(i));
1459 } 1391 }
1460 1392
1461 if (!(data->type == adt7463 && (data->vid & 0x80))) { 1393 if (!(data->type == adt7463 && (data->vid & 0x80))) {
@@ -1463,38 +1395,25 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1463 LM85_REG_IN(4)); 1395 LM85_REG_IN(4));
1464 } 1396 }
1465 1397
1466 for (i = 0; i <= 3; ++i) {
1467 data->fan[i] =
1468 lm85_read_value(client, LM85_REG_FAN(i));
1469 }
1470
1471 for (i = 0; i <= 2; ++i) { 1398 for (i = 0; i <= 2; ++i) {
1472 data->temp[i] = 1399 data->temp[i] =
1473 lm85_read_value(client, LM85_REG_TEMP(i)); 1400 lm85_read_value(client, LM85_REG_TEMP(i));
1474 }
1475
1476 for (i = 0; i <= 2; ++i) {
1477 data->pwm[i] = 1401 data->pwm[i] =
1478 lm85_read_value(client, LM85_REG_PWM(i)); 1402 lm85_read_value(client, LM85_REG_PWM(i));
1479 } 1403 }
1480 1404
1481 data->alarms = lm85_read_value(client, LM85_REG_ALARM1); 1405 data->alarms = lm85_read_value(client, LM85_REG_ALARM1);
1482 1406
1483 if ( data->type == adt7463 ) { 1407 if (data->type == emc6d100) {
1484 if( data->therm_total < ULONG_MAX - 256 ) {
1485 data->therm_total +=
1486 lm85_read_value(client, ADT7463_REG_THERM );
1487 }
1488 } else if ( data->type == emc6d100 ) {
1489 /* Three more voltage sensors */ 1408 /* Three more voltage sensors */
1490 for (i = 5; i <= 7; ++i) { 1409 for (i = 5; i <= 7; ++i) {
1491 data->in[i] = 1410 data->in[i] = lm85_read_value(client,
1492 lm85_read_value(client, EMC6D100_REG_IN(i)); 1411 EMC6D100_REG_IN(i));
1493 } 1412 }
1494 /* More alarm bits */ 1413 /* More alarm bits */
1495 data->alarms |= 1414 data->alarms |= lm85_read_value(client,
1496 lm85_read_value(client, EMC6D100_REG_ALARM3) << 16; 1415 EMC6D100_REG_ALARM3) << 16;
1497 } else if (data->type == emc6d102 ) { 1416 } else if (data->type == emc6d102) {
1498 /* Have to read LSB bits after the MSB ones because 1417 /* Have to read LSB bits after the MSB ones because
1499 the reading of the MSB bits has frozen the 1418 the reading of the MSB bits has frozen the
1500 LSBs (backward from the ADM1027). 1419 LSBs (backward from the ADM1027).
@@ -1509,20 +1428,20 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1509 EMC6D102_REG_EXTEND_ADC4); 1428 EMC6D102_REG_EXTEND_ADC4);
1510 data->in_ext[0] = ext3 & 0x0f; 1429 data->in_ext[0] = ext3 & 0x0f;
1511 data->in_ext[1] = ext4 & 0x0f; 1430 data->in_ext[1] = ext4 & 0x0f;
1512 data->in_ext[2] = (ext4 >> 4) & 0x0f; 1431 data->in_ext[2] = ext4 >> 4;
1513 data->in_ext[3] = (ext3 >> 4) & 0x0f; 1432 data->in_ext[3] = ext3 >> 4;
1514 data->in_ext[4] = (ext2 >> 4) & 0x0f; 1433 data->in_ext[4] = ext2 >> 4;
1515 1434
1516 data->temp_ext[0] = ext1 & 0x0f; 1435 data->temp_ext[0] = ext1 & 0x0f;
1517 data->temp_ext[1] = ext2 & 0x0f; 1436 data->temp_ext[1] = ext2 & 0x0f;
1518 data->temp_ext[2] = (ext1 >> 4) & 0x0f; 1437 data->temp_ext[2] = ext1 >> 4;
1519 } 1438 }
1520 1439
1521 data->last_reading = jiffies ; 1440 data->last_reading = jiffies;
1522 }; /* last_reading */ 1441 } /* last_reading */
1523 1442
1524 if ( !data->valid || 1443 if (!data->valid ||
1525 time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL) ) { 1444 time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL)) {
1526 /* Things that don't change often */ 1445 /* Things that don't change often */
1527 dev_dbg(&client->dev, "Reading config values\n"); 1446 dev_dbg(&client->dev, "Reading config values\n");
1528 1447
@@ -1531,6 +1450,8 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1531 lm85_read_value(client, LM85_REG_IN_MIN(i)); 1450 lm85_read_value(client, LM85_REG_IN_MIN(i));
1532 data->in_max[i] = 1451 data->in_max[i] =
1533 lm85_read_value(client, LM85_REG_IN_MAX(i)); 1452 lm85_read_value(client, LM85_REG_IN_MAX(i));
1453 data->fan_min[i] =
1454 lm85_read_value(client, LM85_REG_FAN_MIN(i));
1534 } 1455 }
1535 1456
1536 if (!(data->type == adt7463 && (data->vid & 0x80))) { 1457 if (!(data->type == adt7463 && (data->vid & 0x80))) {
@@ -1540,34 +1461,28 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1540 LM85_REG_IN_MAX(4)); 1461 LM85_REG_IN_MAX(4));
1541 } 1462 }
1542 1463
1543 if ( data->type == emc6d100 ) { 1464 if (data->type == emc6d100) {
1544 for (i = 5; i <= 7; ++i) { 1465 for (i = 5; i <= 7; ++i) {
1545 data->in_min[i] = 1466 data->in_min[i] = lm85_read_value(client,
1546 lm85_read_value(client, EMC6D100_REG_IN_MIN(i)); 1467 EMC6D100_REG_IN_MIN(i));
1547 data->in_max[i] = 1468 data->in_max[i] = lm85_read_value(client,
1548 lm85_read_value(client, EMC6D100_REG_IN_MAX(i)); 1469 EMC6D100_REG_IN_MAX(i));
1549 } 1470 }
1550 } 1471 }
1551 1472
1552 for (i = 0; i <= 3; ++i) {
1553 data->fan_min[i] =
1554 lm85_read_value(client, LM85_REG_FAN_MIN(i));
1555 }
1556
1557 for (i = 0; i <= 2; ++i) { 1473 for (i = 0; i <= 2; ++i) {
1474 int val;
1475
1558 data->temp_min[i] = 1476 data->temp_min[i] =
1559 lm85_read_value(client, LM85_REG_TEMP_MIN(i)); 1477 lm85_read_value(client, LM85_REG_TEMP_MIN(i));
1560 data->temp_max[i] = 1478 data->temp_max[i] =
1561 lm85_read_value(client, LM85_REG_TEMP_MAX(i)); 1479 lm85_read_value(client, LM85_REG_TEMP_MAX(i));
1562 }
1563 1480
1564 for (i = 0; i <= 2; ++i) {
1565 int val ;
1566 data->autofan[i].config = 1481 data->autofan[i].config =
1567 lm85_read_value(client, LM85_REG_AFAN_CONFIG(i)); 1482 lm85_read_value(client, LM85_REG_AFAN_CONFIG(i));
1568 val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i)); 1483 val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i));
1569 data->autofan[i].freq = val & 0x07 ; 1484 data->autofan[i].freq = val & 0x07;
1570 data->zone[i].range = (val >> 4) & 0x0f ; 1485 data->zone[i].range = val >> 4;
1571 data->autofan[i].min_pwm = 1486 data->autofan[i].min_pwm =
1572 lm85_read_value(client, LM85_REG_AFAN_MINPWM(i)); 1487 lm85_read_value(client, LM85_REG_AFAN_MINPWM(i));
1573 data->zone[i].limit = 1488 data->zone[i].limit =
@@ -1577,50 +1492,19 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1577 } 1492 }
1578 1493
1579 i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); 1494 i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1);
1580 data->smooth[0] = i & 0x0f ; 1495 data->autofan[0].min_off = (i & 0x20) != 0;
1581 data->syncpwm3 = i & 0x10 ; /* Save PWM3 config */ 1496 data->autofan[1].min_off = (i & 0x40) != 0;
1582 data->autofan[0].min_off = (i & 0x20) != 0 ; 1497 data->autofan[2].min_off = (i & 0x80) != 0;
1583 data->autofan[1].min_off = (i & 0x40) != 0 ;
1584 data->autofan[2].min_off = (i & 0x80) != 0 ;
1585 i = lm85_read_value(client, LM85_REG_AFAN_SPIKE2);
1586 data->smooth[1] = (i>>4) & 0x0f ;
1587 data->smooth[2] = i & 0x0f ;
1588 1498
1589 i = lm85_read_value(client, LM85_REG_AFAN_HYST1); 1499 i = lm85_read_value(client, LM85_REG_AFAN_HYST1);
1590 data->zone[0].hyst = (i>>4) & 0x0f ; 1500 data->zone[0].hyst = i >> 4;
1591 data->zone[1].hyst = i & 0x0f ; 1501 data->zone[1].hyst = i & 0x0f;
1592 1502
1593 i = lm85_read_value(client, LM85_REG_AFAN_HYST2); 1503 i = lm85_read_value(client, LM85_REG_AFAN_HYST2);
1594 data->zone[2].hyst = (i>>4) & 0x0f ; 1504 data->zone[2].hyst = i >> 4;
1595 1505
1596 if ( (data->type == lm85b) || (data->type == lm85c) ) {
1597 data->tach_mode = lm85_read_value(client,
1598 LM85_REG_TACH_MODE );
1599 data->spinup_ctl = lm85_read_value(client,
1600 LM85_REG_SPINUP_CTL );
1601 } else if ( (data->type == adt7463) || (data->type == adm1027) ) {
1602 if ( data->type == adt7463 ) {
1603 for (i = 0; i <= 2; ++i) {
1604 data->oppoint[i] = lm85_read_value(client,
1605 ADT7463_REG_OPPOINT(i) );
1606 }
1607 data->tmin_ctl = lm85_read_value(client,
1608 ADT7463_REG_TMIN_CTL1 );
1609 data->therm_limit = lm85_read_value(client,
1610 ADT7463_REG_THERM_LIMIT );
1611 }
1612 for (i = 0; i <= 2; ++i) {
1613 data->temp_offset[i] = lm85_read_value(client,
1614 ADM1027_REG_TEMP_OFFSET(i) );
1615 }
1616 data->tach_mode = lm85_read_value(client,
1617 ADM1027_REG_CONFIG3 );
1618 data->fan_ppr = lm85_read_value(client,
1619 ADM1027_REG_FAN_PPR );
1620 }
1621
1622 data->last_config = jiffies; 1506 data->last_config = jiffies;
1623 }; /* last_config */ 1507 } /* last_config */
1624 1508
1625 data->valid = 1; 1509 data->valid = 1;
1626 1510
@@ -1635,17 +1519,15 @@ static int __init sm_lm85_init(void)
1635 return i2c_add_driver(&lm85_driver); 1519 return i2c_add_driver(&lm85_driver);
1636} 1520}
1637 1521
1638static void __exit sm_lm85_exit(void) 1522static void __exit sm_lm85_exit(void)
1639{ 1523{
1640 i2c_del_driver(&lm85_driver); 1524 i2c_del_driver(&lm85_driver);
1641} 1525}
1642 1526
1643/* Thanks to Richard Barrington for adding the LM85 to sensors-detect.
1644 * Thanks to Margit Schubert-While <margitsw@t-online.de> for help with
1645 * post 2.7.0 CVS changes.
1646 */
1647MODULE_LICENSE("GPL"); 1527MODULE_LICENSE("GPL");
1648MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>, Justin Thiessen <jthiessen@penguincomputing.com"); 1528MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, "
1529 "Margit Schubert-While <margitsw@t-online.de>, "
1530 "Justin Thiessen <jthiessen@penguincomputing.com>");
1649MODULE_DESCRIPTION("LM85-B, LM85-C driver"); 1531MODULE_DESCRIPTION("LM85-B, LM85-C driver");
1650 1532
1651module_init(sm_lm85_init); 1533module_init(sm_lm85_init);
diff --git a/drivers/infiniband/hw/ipath/ipath_iba7220.c b/drivers/infiniband/hw/ipath/ipath_iba7220.c
index fb70712ac85c..fadbfbf55a6a 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba7220.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba7220.c
@@ -528,7 +528,7 @@ static const struct ipath_cregs ipath_7220_cregs = {
528 528
529static char int_type[16] = "auto"; 529static char int_type[16] = "auto";
530module_param_string(interrupt_type, int_type, sizeof(int_type), 0444); 530module_param_string(interrupt_type, int_type, sizeof(int_type), 0444);
531MODULE_PARM_DESC(int_type, " interrupt_type=auto|force_msi|force_intx\n"); 531MODULE_PARM_DESC(int_type, " interrupt_type=auto|force_msi|force_intx");
532 532
533/* packet rate matching delay; chip has support */ 533/* packet rate matching delay; chip has support */
534static u8 rate_to_delay[2][2] = { 534static u8 rate_to_delay[2][2] = {
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
index 2b404284c28a..7797ef6e5e64 100644
--- a/drivers/input/keyboard/maple_keyb.c
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -27,7 +27,6 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/maple.h> 29#include <linux/maple.h>
30#include <asm/mach/maple.h>
31 30
32/* Very simple mutex to ensure proper cleanup */ 31/* Very simple mutex to ensure proper cleanup */
33static DEFINE_MUTEX(maple_keyb_mutex); 32static DEFINE_MUTEX(maple_keyb_mutex);
diff --git a/drivers/isdn/Makefile b/drivers/isdn/Makefile
index 8380a4568d11..f1f777570e8e 100644
--- a/drivers/isdn/Makefile
+++ b/drivers/isdn/Makefile
@@ -5,7 +5,7 @@
5obj-$(CONFIG_ISDN_I4L) += i4l/ 5obj-$(CONFIG_ISDN_I4L) += i4l/
6obj-$(CONFIG_ISDN_CAPI) += capi/ 6obj-$(CONFIG_ISDN_CAPI) += capi/
7obj-$(CONFIG_MISDN) += mISDN/ 7obj-$(CONFIG_MISDN) += mISDN/
8obj-$(CONFIG_ISDN_CAPI) += hardware/ 8obj-$(CONFIG_ISDN) += hardware/
9obj-$(CONFIG_ISDN_DIVERSION) += divert/ 9obj-$(CONFIG_ISDN_DIVERSION) += divert/
10obj-$(CONFIG_ISDN_DRV_HISAX) += hisax/ 10obj-$(CONFIG_ISDN_DRV_HISAX) += hisax/
11obj-$(CONFIG_ISDN_DRV_ICN) += icn/ 11obj-$(CONFIG_ISDN_DRV_ICN) += icn/
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index e30a7773f93c..fbce5222d83c 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -247,7 +247,6 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
247#ifdef CONFIG_GIGASET_DEBUG 247#ifdef CONFIG_GIGASET_DEBUG
248 unsigned char c; 248 unsigned char c;
249 static char dbgline[3 * 32 + 1]; 249 static char dbgline[3 * 32 + 1];
250 static const char hexdigit[] = "0123456789abcdef";
251 int i = 0; 250 int i = 0;
252 while (count-- > 0) { 251 while (count-- > 0) {
253 if (i > sizeof(dbgline) - 4) { 252 if (i > sizeof(dbgline) - 4) {
@@ -258,8 +257,8 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
258 c = *bytes++; 257 c = *bytes++;
259 dbgline[i] = (i && !(i % 12)) ? '-' : ' '; 258 dbgline[i] = (i && !(i % 12)) ? '-' : ' ';
260 i++; 259 i++;
261 dbgline[i++] = hexdigit[(c >> 4) & 0x0f]; 260 dbgline[i++] = hex_asc_hi(c);
262 dbgline[i++] = hexdigit[c & 0x0f]; 261 dbgline[i++] = hex_asc_lo(c);
263 } 262 }
264 dbgline[i] = '\0'; 263 dbgline[i] = '\0';
265 gig_dbg(level, "%s:%s", tag, dbgline); 264 gig_dbg(level, "%s:%s", tag, dbgline);
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 2649ea55a9e8..1eac03f39d00 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -140,7 +140,7 @@
140 * #define HFC_REGISTER_DEBUG 140 * #define HFC_REGISTER_DEBUG
141 */ 141 */
142 142
143static const char *hfcmulti_revision = "2.00"; 143static const char *hfcmulti_revision = "2.02";
144 144
145#include <linux/module.h> 145#include <linux/module.h>
146#include <linux/pci.h> 146#include <linux/pci.h>
@@ -427,12 +427,12 @@ write_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
427{ 427{
428 outb(A_FIFO_DATA0, (hc->pci_iobase)+4); 428 outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
429 while (len>>2) { 429 while (len>>2) {
430 outl(*(u32 *)data, hc->pci_iobase); 430 outl(cpu_to_le32(*(u32 *)data), hc->pci_iobase);
431 data += 4; 431 data += 4;
432 len -= 4; 432 len -= 4;
433 } 433 }
434 while (len>>1) { 434 while (len>>1) {
435 outw(*(u16 *)data, hc->pci_iobase); 435 outw(cpu_to_le16(*(u16 *)data), hc->pci_iobase);
436 data += 2; 436 data += 2;
437 len -= 2; 437 len -= 2;
438 } 438 }
@@ -447,17 +447,19 @@ void
447write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len) 447write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
448{ 448{
449 while (len>>2) { 449 while (len>>2) {
450 writel(*(u32 *)data, (hc->pci_membase)+A_FIFO_DATA0); 450 writel(cpu_to_le32(*(u32 *)data),
451 hc->pci_membase + A_FIFO_DATA0);
451 data += 4; 452 data += 4;
452 len -= 4; 453 len -= 4;
453 } 454 }
454 while (len>>1) { 455 while (len>>1) {
455 writew(*(u16 *)data, (hc->pci_membase)+A_FIFO_DATA0); 456 writew(cpu_to_le16(*(u16 *)data),
457 hc->pci_membase + A_FIFO_DATA0);
456 data += 2; 458 data += 2;
457 len -= 2; 459 len -= 2;
458 } 460 }
459 while (len) { 461 while (len) {
460 writeb(*data, (hc->pci_membase)+A_FIFO_DATA0); 462 writeb(*data, hc->pci_membase + A_FIFO_DATA0);
461 data++; 463 data++;
462 len--; 464 len--;
463 } 465 }
@@ -468,12 +470,12 @@ read_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
468{ 470{
469 outb(A_FIFO_DATA0, (hc->pci_iobase)+4); 471 outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
470 while (len>>2) { 472 while (len>>2) {
471 *(u32 *)data = inl(hc->pci_iobase); 473 *(u32 *)data = le32_to_cpu(inl(hc->pci_iobase));
472 data += 4; 474 data += 4;
473 len -= 4; 475 len -= 4;
474 } 476 }
475 while (len>>1) { 477 while (len>>1) {
476 *(u16 *)data = inw(hc->pci_iobase); 478 *(u16 *)data = le16_to_cpu(inw(hc->pci_iobase));
477 data += 2; 479 data += 2;
478 len -= 2; 480 len -= 2;
479 } 481 }
@@ -490,18 +492,18 @@ read_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
490{ 492{
491 while (len>>2) { 493 while (len>>2) {
492 *(u32 *)data = 494 *(u32 *)data =
493 readl((hc->pci_membase)+A_FIFO_DATA0); 495 le32_to_cpu(readl(hc->pci_membase + A_FIFO_DATA0));
494 data += 4; 496 data += 4;
495 len -= 4; 497 len -= 4;
496 } 498 }
497 while (len>>1) { 499 while (len>>1) {
498 *(u16 *)data = 500 *(u16 *)data =
499 readw((hc->pci_membase)+A_FIFO_DATA0); 501 le16_to_cpu(readw(hc->pci_membase + A_FIFO_DATA0));
500 data += 2; 502 data += 2;
501 len -= 2; 503 len -= 2;
502 } 504 }
503 while (len) { 505 while (len) {
504 *data = readb((hc->pci_membase)+A_FIFO_DATA0); 506 *data = readb(hc->pci_membase + A_FIFO_DATA0);
505 data++; 507 data++;
506 len--; 508 len--;
507 } 509 }
@@ -3971,7 +3973,7 @@ open_bchannel(struct hfc_multi *hc, struct dchannel *dch,
3971 struct bchannel *bch; 3973 struct bchannel *bch;
3972 int ch; 3974 int ch;
3973 3975
3974 if (!test_bit(rq->adr.channel, &dch->dev.channelmap[0])) 3976 if (!test_channelmap(rq->adr.channel, dch->dev.channelmap))
3975 return -EINVAL; 3977 return -EINVAL;
3976 if (rq->protocol == ISDN_P_NONE) 3978 if (rq->protocol == ISDN_P_NONE)
3977 return -EINVAL; 3979 return -EINVAL;
@@ -4587,7 +4589,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
4587 list_add(&bch->ch.list, &dch->dev.bchannels); 4589 list_add(&bch->ch.list, &dch->dev.bchannels);
4588 hc->chan[ch].bch = bch; 4590 hc->chan[ch].bch = bch;
4589 hc->chan[ch].port = 0; 4591 hc->chan[ch].port = 0;
4590 test_and_set_bit(bch->nr, &dch->dev.channelmap[0]); 4592 set_channelmap(bch->nr, dch->dev.channelmap);
4591 } 4593 }
4592 /* set optical line type */ 4594 /* set optical line type */
4593 if (port[Port_cnt] & 0x001) { 4595 if (port[Port_cnt] & 0x001) {
@@ -4755,7 +4757,7 @@ init_multi_port(struct hfc_multi *hc, int pt)
4755 list_add(&bch->ch.list, &dch->dev.bchannels); 4757 list_add(&bch->ch.list, &dch->dev.bchannels);
4756 hc->chan[i + ch].bch = bch; 4758 hc->chan[i + ch].bch = bch;
4757 hc->chan[i + ch].port = pt; 4759 hc->chan[i + ch].port = pt;
4758 test_and_set_bit(bch->nr, &dch->dev.channelmap[0]); 4760 set_channelmap(bch->nr, dch->dev.channelmap);
4759 } 4761 }
4760 /* set master clock */ 4762 /* set master clock */
4761 if (port[Port_cnt] & 0x001) { 4763 if (port[Port_cnt] & 0x001) {
@@ -5050,12 +5052,12 @@ static void __devexit hfc_remove_pci(struct pci_dev *pdev)
5050 5052
5051static const struct hm_map hfcm_map[] = { 5053static const struct hm_map hfcm_map[] = {
5052/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0}, 5054/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0},
5053/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S}, 5055/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S, 0},
5054/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0}, 5056/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0},
5055/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0}, 5057/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0},
5056/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0}, 5058/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0},
5057/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0}, 5059/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0},
5058/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, 0, 0}, 5060/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, DIP_4S, 0},
5059/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0}, 5061/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0},
5060/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO}, 5062/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO},
5061/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0}, 5063/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0},
@@ -5251,9 +5253,6 @@ HFCmulti_init(void)
5251 if (debug & DEBUG_HFCMULTI_INIT) 5253 if (debug & DEBUG_HFCMULTI_INIT)
5252 printk(KERN_DEBUG "%s: init entered\n", __func__); 5254 printk(KERN_DEBUG "%s: init entered\n", __func__);
5253 5255
5254#ifdef __BIG_ENDIAN
5255#error "not running on big endian machines now"
5256#endif
5257 hfc_interrupt = symbol_get(ztdummy_extern_interrupt); 5256 hfc_interrupt = symbol_get(ztdummy_extern_interrupt);
5258 register_interrupt = symbol_get(ztdummy_register_interrupt); 5257 register_interrupt = symbol_get(ztdummy_register_interrupt);
5259 unregister_interrupt = symbol_get(ztdummy_unregister_interrupt); 5258 unregister_interrupt = symbol_get(ztdummy_unregister_interrupt);
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 3231814e7efa..9cf5edbb1a9b 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -2056,7 +2056,7 @@ setup_card(struct hfc_pci *card)
2056 card->dch.dev.nrbchan = 2; 2056 card->dch.dev.nrbchan = 2;
2057 for (i = 0; i < 2; i++) { 2057 for (i = 0; i < 2; i++) {
2058 card->bch[i].nr = i + 1; 2058 card->bch[i].nr = i + 1;
2059 test_and_set_bit(i + 1, &card->dch.dev.channelmap[0]); 2059 set_channelmap(i + 1, card->dch.dev.channelmap);
2060 card->bch[i].debug = debug; 2060 card->bch[i].debug = debug;
2061 mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM); 2061 mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM);
2062 card->bch[i].hw = card; 2062 card->bch[i].hw = card;
diff --git a/drivers/isdn/hysdn/hysdn_pof.h b/drivers/isdn/hysdn/hysdn_pof.h
index a368d6caca0e..3a72b908900f 100644
--- a/drivers/isdn/hysdn/hysdn_pof.h
+++ b/drivers/isdn/hysdn/hysdn_pof.h
@@ -60,7 +60,7 @@ typedef struct PofRecHdr_tag { /* Pof record header */
60 60
61typedef struct PofTimeStamp_tag { 61typedef struct PofTimeStamp_tag {
62/*00 */ unsigned long UnixTime __attribute__((packed)); 62/*00 */ unsigned long UnixTime __attribute__((packed));
63 /*04 */ unsigned char DateTimeText[0x28] __attribute__((packed)); 63 /*04 */ unsigned char DateTimeText[0x28];
64 /* =40 */ 64 /* =40 */
65/*2C */ 65/*2C */
66} tPofTimeStamp; 66} tPofTimeStamp;
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 155b99780c4f..e42150a57780 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -1006,8 +1006,7 @@ open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq)
1006 struct bchannel *bch; 1006 struct bchannel *bch;
1007 int ch; 1007 int ch;
1008 1008
1009 if (!test_bit(rq->adr.channel & 0x1f, 1009 if (!test_channelmap(rq->adr.channel, dch->dev.channelmap))
1010 &dch->dev.channelmap[rq->adr.channel >> 5]))
1011 return -EINVAL; 1010 return -EINVAL;
1012 if (rq->protocol == ISDN_P_NONE) 1011 if (rq->protocol == ISDN_P_NONE)
1013 return -EINVAL; 1012 return -EINVAL;
@@ -1412,8 +1411,7 @@ init_card(struct l1oip *hc, int pri, int bundle)
1412 bch->ch.nr = i + ch; 1411 bch->ch.nr = i + ch;
1413 list_add(&bch->ch.list, &dch->dev.bchannels); 1412 list_add(&bch->ch.list, &dch->dev.bchannels);
1414 hc->chan[i + ch].bch = bch; 1413 hc->chan[i + ch].bch = bch;
1415 test_and_set_bit(bch->nr & 0x1f, 1414 set_channelmap(bch->nr, dch->dev.channelmap);
1416 &dch->dev.channelmap[bch->nr >> 5]);
1417 } 1415 }
1418 ret = mISDN_register_device(&dch->dev, hc->name); 1416 ret = mISDN_register_device(&dch->dev, hc->name);
1419 if (ret) 1417 if (ret)
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 4ba4cc364c9e..e5a20f9542d1 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -379,7 +379,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
379 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols(); 379 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
380 di.protocol = dev->D.protocol; 380 di.protocol = dev->D.protocol;
381 memcpy(di.channelmap, dev->channelmap, 381 memcpy(di.channelmap, dev->channelmap,
382 MISDN_CHMAP_SIZE * 4); 382 sizeof(di.channelmap));
383 di.nrbchan = dev->nrbchan; 383 di.nrbchan = dev->nrbchan;
384 strcpy(di.name, dev->name); 384 strcpy(di.name, dev->name);
385 if (copy_to_user((void __user *)arg, &di, sizeof(di))) 385 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
@@ -637,7 +637,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
637 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols(); 637 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
638 di.protocol = dev->D.protocol; 638 di.protocol = dev->D.protocol;
639 memcpy(di.channelmap, dev->channelmap, 639 memcpy(di.channelmap, dev->channelmap,
640 MISDN_CHMAP_SIZE * 4); 640 sizeof(di.channelmap));
641 di.nrbchan = dev->nrbchan; 641 di.nrbchan = dev->nrbchan;
642 strcpy(di.name, dev->name); 642 strcpy(di.name, dev->name);
643 if (copy_to_user((void __user *)arg, &di, sizeof(di))) 643 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 621a272a2c74..7e65bad522cb 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1234,7 +1234,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
1234 case 0: 1234 case 0:
1235 bitmap_file_set_bit(bitmap, offset); 1235 bitmap_file_set_bit(bitmap, offset);
1236 bitmap_count_page(bitmap,offset, 1); 1236 bitmap_count_page(bitmap,offset, 1);
1237 blk_plug_device(bitmap->mddev->queue); 1237 blk_plug_device_unlocked(bitmap->mddev->queue);
1238 /* fall through */ 1238 /* fall through */
1239 case 1: 1239 case 1:
1240 *bmc = 2; 1240 *bmc = 2;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 798e468103b8..61f441409234 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -316,29 +316,12 @@ static inline int check_space(struct dm_table *t)
316 */ 316 */
317static int lookup_device(const char *path, dev_t *dev) 317static int lookup_device(const char *path, dev_t *dev)
318{ 318{
319 int r; 319 struct block_device *bdev = lookup_bdev(path);
320 struct nameidata nd; 320 if (IS_ERR(bdev))
321 struct inode *inode; 321 return PTR_ERR(bdev);
322 322 *dev = bdev->bd_dev;
323 if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd))) 323 bdput(bdev);
324 return r; 324 return 0;
325
326 inode = nd.path.dentry->d_inode;
327 if (!inode) {
328 r = -ENOENT;
329 goto out;
330 }
331
332 if (!S_ISBLK(inode->i_mode)) {
333 r = -ENOTBLK;
334 goto out;
335 }
336
337 *dev = inode->i_rdev;
338
339 out:
340 path_put(&nd.path);
341 return r;
342} 325}
343 326
344/* 327/*
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c2ff77ccec50..c7aae66c6f9b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3483,7 +3483,7 @@ static void md_safemode_timeout(unsigned long data)
3483 if (!atomic_read(&mddev->writes_pending)) { 3483 if (!atomic_read(&mddev->writes_pending)) {
3484 mddev->safemode = 1; 3484 mddev->safemode = 1;
3485 if (mddev->external) 3485 if (mddev->external)
3486 sysfs_notify(&mddev->kobj, NULL, "array_state"); 3486 set_bit(MD_NOTIFY_ARRAY_STATE, &mddev->flags);
3487 } 3487 }
3488 md_wakeup_thread(mddev->thread); 3488 md_wakeup_thread(mddev->thread);
3489} 3489}
@@ -5996,7 +5996,8 @@ static int remove_and_add_spares(mddev_t *mddev)
5996 if (mddev->degraded) { 5996 if (mddev->degraded) {
5997 rdev_for_each(rdev, rtmp, mddev) { 5997 rdev_for_each(rdev, rtmp, mddev) {
5998 if (rdev->raid_disk >= 0 && 5998 if (rdev->raid_disk >= 0 &&
5999 !test_bit(In_sync, &rdev->flags)) 5999 !test_bit(In_sync, &rdev->flags) &&
6000 !test_bit(Blocked, &rdev->flags))
6000 spares++; 6001 spares++;
6001 if (rdev->raid_disk < 0 6002 if (rdev->raid_disk < 0
6002 && !test_bit(Faulty, &rdev->flags)) { 6003 && !test_bit(Faulty, &rdev->flags)) {
@@ -6051,6 +6052,9 @@ void md_check_recovery(mddev_t *mddev)
6051 if (mddev->bitmap) 6052 if (mddev->bitmap)
6052 bitmap_daemon_work(mddev->bitmap); 6053 bitmap_daemon_work(mddev->bitmap);
6053 6054
6055 if (test_and_clear_bit(MD_NOTIFY_ARRAY_STATE, &mddev->flags))
6056 sysfs_notify(&mddev->kobj, NULL, "array_state");
6057
6054 if (mddev->ro) 6058 if (mddev->ro)
6055 return; 6059 return;
6056 6060
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 159535d73567..d41bebb6da0f 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -215,6 +215,9 @@ static void reschedule_retry(r10bio_t *r10_bio)
215 conf->nr_queued ++; 215 conf->nr_queued ++;
216 spin_unlock_irqrestore(&conf->device_lock, flags); 216 spin_unlock_irqrestore(&conf->device_lock, flags);
217 217
218 /* wake up frozen array... */
219 wake_up(&conf->wait_barrier);
220
218 md_wakeup_thread(mddev->thread); 221 md_wakeup_thread(mddev->thread);
219} 222}
220 223
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 55e7c56045a0..40e939675657 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2507,7 +2507,7 @@ static void handle_stripe_expansion(raid5_conf_t *conf, struct stripe_head *sh,
2507 * 2507 *
2508 */ 2508 */
2509 2509
2510static void handle_stripe5(struct stripe_head *sh) 2510static bool handle_stripe5(struct stripe_head *sh)
2511{ 2511{
2512 raid5_conf_t *conf = sh->raid_conf; 2512 raid5_conf_t *conf = sh->raid_conf;
2513 int disks = sh->disks, i; 2513 int disks = sh->disks, i;
@@ -2717,10 +2717,11 @@ static void handle_stripe5(struct stripe_head *sh)
2717 if (sh->reconstruct_state == reconstruct_state_result) { 2717 if (sh->reconstruct_state == reconstruct_state_result) {
2718 sh->reconstruct_state = reconstruct_state_idle; 2718 sh->reconstruct_state = reconstruct_state_idle;
2719 clear_bit(STRIPE_EXPANDING, &sh->state); 2719 clear_bit(STRIPE_EXPANDING, &sh->state);
2720 for (i = conf->raid_disks; i--; ) 2720 for (i = conf->raid_disks; i--; ) {
2721 set_bit(R5_Wantwrite, &sh->dev[i].flags); 2721 set_bit(R5_Wantwrite, &sh->dev[i].flags);
2722 set_bit(R5_LOCKED, &dev->flags); 2722 set_bit(R5_LOCKED, &sh->dev[i].flags);
2723 s.locked++; 2723 s.locked++;
2724 }
2724 } 2725 }
2725 2726
2726 if (s.expanded && test_bit(STRIPE_EXPANDING, &sh->state) && 2727 if (s.expanded && test_bit(STRIPE_EXPANDING, &sh->state) &&
@@ -2754,9 +2755,11 @@ static void handle_stripe5(struct stripe_head *sh)
2754 ops_run_io(sh, &s); 2755 ops_run_io(sh, &s);
2755 2756
2756 return_io(return_bi); 2757 return_io(return_bi);
2758
2759 return blocked_rdev == NULL;
2757} 2760}
2758 2761
2759static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) 2762static bool handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
2760{ 2763{
2761 raid6_conf_t *conf = sh->raid_conf; 2764 raid6_conf_t *conf = sh->raid_conf;
2762 int disks = sh->disks; 2765 int disks = sh->disks;
@@ -2967,14 +2970,17 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
2967 ops_run_io(sh, &s); 2970 ops_run_io(sh, &s);
2968 2971
2969 return_io(return_bi); 2972 return_io(return_bi);
2973
2974 return blocked_rdev == NULL;
2970} 2975}
2971 2976
2972static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) 2977/* returns true if the stripe was handled */
2978static bool handle_stripe(struct stripe_head *sh, struct page *tmp_page)
2973{ 2979{
2974 if (sh->raid_conf->level == 6) 2980 if (sh->raid_conf->level == 6)
2975 handle_stripe6(sh, tmp_page); 2981 return handle_stripe6(sh, tmp_page);
2976 else 2982 else
2977 handle_stripe5(sh); 2983 return handle_stripe5(sh);
2978} 2984}
2979 2985
2980 2986
@@ -3692,7 +3698,9 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski
3692 clear_bit(STRIPE_INSYNC, &sh->state); 3698 clear_bit(STRIPE_INSYNC, &sh->state);
3693 spin_unlock(&sh->lock); 3699 spin_unlock(&sh->lock);
3694 3700
3695 handle_stripe(sh, NULL); 3701 /* wait for any blocked device to be handled */
3702 while(unlikely(!handle_stripe(sh, NULL)))
3703 ;
3696 release_stripe(sh); 3704 release_stripe(sh);
3697 3705
3698 return STRIPE_SECTORS; 3706 return STRIPE_SECTORS;
@@ -3811,10 +3819,8 @@ static void raid5d(mddev_t *mddev)
3811 3819
3812 sh = __get_priority_stripe(conf); 3820 sh = __get_priority_stripe(conf);
3813 3821
3814 if (!sh) { 3822 if (!sh)
3815 async_tx_issue_pending_all();
3816 break; 3823 break;
3817 }
3818 spin_unlock_irq(&conf->device_lock); 3824 spin_unlock_irq(&conf->device_lock);
3819 3825
3820 handled++; 3826 handled++;
@@ -3827,6 +3833,7 @@ static void raid5d(mddev_t *mddev)
3827 3833
3828 spin_unlock_irq(&conf->device_lock); 3834 spin_unlock_irq(&conf->device_lock);
3829 3835
3836 async_tx_issue_pending_all();
3830 unplug_slaves(mddev); 3837 unplug_slaves(mddev);
3831 3838
3832 pr_debug("--- raid5d inactive\n"); 3839 pr_debug("--- raid5d inactive\n");
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 61d14d26686f..a662b15d5b90 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -35,7 +35,7 @@ static int debug;
35 35
36module_param(debug, bool, 0644); 36module_param(debug, bool, 0644);
37 37
38MODULE_PARM_DESC(debug, "Debugging messages\n\t\t\t0=Off (default), 1=On"); 38MODULE_PARM_DESC(debug, "Debugging messages, 0=Off (default), 1=On");
39 39
40 40
41/* ----------------------------------------------------------------------- */ 41/* ----------------------------------------------------------------------- */
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index e30a589c0e18..c4444500b330 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -39,7 +39,7 @@ static int debug;
39 39
40module_param(debug, bool, 0644); 40module_param(debug, bool, 0644);
41 41
42MODULE_PARM_DESC(debug, "Debugging messages\n\t\t\t0=Off (default), 1=On"); 42MODULE_PARM_DESC(debug, "Debugging messages, 0=Off (default), 1=On");
43 43
44static unsigned short normal_i2c[] = { 0x22 >> 1, I2C_CLIENT_END }; 44static unsigned short normal_i2c[] = { 0x22 >> 1, I2C_CLIENT_END };
45 45
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index b31ba4e09327..56808cd2f8a9 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -25,7 +25,7 @@
25 25
26static char *sensor_type; 26static char *sensor_type;
27module_param(sensor_type, charp, S_IRUGO); 27module_param(sensor_type, charp, S_IRUGO);
28MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"\n"); 28MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"");
29 29
30/* mt9v022 selected register addresses */ 30/* mt9v022 selected register addresses */
31#define MT9V022_CHIP_VERSION 0x00 31#define MT9V022_CHIP_VERSION 0x00
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/drivers/media/video/planb.c
+++ /dev/null
diff --git a/drivers/media/video/planb.h b/drivers/media/video/planb.h
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/drivers/media/video/planb.h
+++ /dev/null
diff --git a/drivers/media/video/saa7196.h b/drivers/media/video/saa7196.h
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/drivers/media/video/saa7196.h
+++ /dev/null
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/drivers/media/video/videodev.c
+++ /dev/null
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index fa50e9ede0e6..82af385460e4 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -426,9 +426,11 @@ config ENCLOSURE_SERVICES
426 426
427config SGI_XP 427config SGI_XP
428 tristate "Support communication between SGI SSIs" 428 tristate "Support communication between SGI SSIs"
429 depends on NET
429 depends on IA64_GENERIC || IA64_SGI_SN2 || IA64_SGI_UV || (X86_64 && SMP) 430 depends on IA64_GENERIC || IA64_SGI_SN2 || IA64_SGI_UV || (X86_64 && SMP)
430 select IA64_UNCACHED_ALLOCATOR if IA64_GENERIC || IA64_SGI_SN2 431 select IA64_UNCACHED_ALLOCATOR if IA64_GENERIC || IA64_SGI_SN2
431 select GENERIC_ALLOCATOR if IA64_GENERIC || IA64_SGI_SN2 432 select GENERIC_ALLOCATOR if IA64_GENERIC || IA64_SGI_SN2
433 select SGI_GRU if IA64_GENERIC || IA64_SGI_UV || (X86_64 && SMP)
432 ---help--- 434 ---help---
433 An SGI machine can be divided into multiple Single System 435 An SGI machine can be divided into multiple Single System
434 Images which act independently of each other and have 436 Images which act independently of each other and have
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 66e5a5487c20..86dbb366415a 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -213,7 +213,8 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
213 struct mmc_blk_data *md = mq->data; 213 struct mmc_blk_data *md = mq->data;
214 struct mmc_card *card = md->queue.card; 214 struct mmc_card *card = md->queue.card;
215 struct mmc_blk_request brq; 215 struct mmc_blk_request brq;
216 int ret = 1, sg_pos, data_size; 216 int ret = 1, data_size, i;
217 struct scatterlist *sg;
217 218
218 mmc_claim_host(card->host); 219 mmc_claim_host(card->host);
219 220
@@ -267,18 +268,22 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
267 268
268 mmc_queue_bounce_pre(mq); 269 mmc_queue_bounce_pre(mq);
269 270
271 /*
272 * Adjust the sg list so it is the same size as the
273 * request.
274 */
270 if (brq.data.blocks != 275 if (brq.data.blocks !=
271 (req->nr_sectors >> (md->block_bits - 9))) { 276 (req->nr_sectors >> (md->block_bits - 9))) {
272 data_size = brq.data.blocks * brq.data.blksz; 277 data_size = brq.data.blocks * brq.data.blksz;
273 for (sg_pos = 0; sg_pos < brq.data.sg_len; sg_pos++) { 278 for_each_sg(brq.data.sg, sg, brq.data.sg_len, i) {
274 data_size -= mq->sg[sg_pos].length; 279 data_size -= sg->length;
275 if (data_size <= 0) { 280 if (data_size <= 0) {
276 mq->sg[sg_pos].length += data_size; 281 sg->length += data_size;
277 sg_pos++; 282 i++;
278 break; 283 break;
279 } 284 }
280 } 285 }
281 brq.data.sg_len = sg_pos; 286 brq.data.sg_len = i;
282 } 287 }
283 288
284 mmc_wait_for_req(card->host, &brq.mrq); 289 mmc_wait_for_req(card->host, &brq.mrq);
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index a067fe436301..f26b01d811ae 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -388,16 +388,14 @@ static int mmc_test_transfer(struct mmc_test_card *test,
388 int ret, i; 388 int ret, i;
389 unsigned long flags; 389 unsigned long flags;
390 390
391 BUG_ON(blocks * blksz > BUFFER_SIZE);
392
393 if (write) { 391 if (write) {
394 for (i = 0;i < blocks * blksz;i++) 392 for (i = 0;i < blocks * blksz;i++)
395 test->scratch[i] = i; 393 test->scratch[i] = i;
396 } else { 394 } else {
397 memset(test->scratch, 0, blocks * blksz); 395 memset(test->scratch, 0, BUFFER_SIZE);
398 } 396 }
399 local_irq_save(flags); 397 local_irq_save(flags);
400 sg_copy_from_buffer(sg, sg_len, test->scratch, blocks * blksz); 398 sg_copy_from_buffer(sg, sg_len, test->scratch, BUFFER_SIZE);
401 local_irq_restore(flags); 399 local_irq_restore(flags);
402 400
403 ret = mmc_test_set_blksize(test, blksz); 401 ret = mmc_test_set_blksize(test, blksz);
@@ -444,7 +442,7 @@ static int mmc_test_transfer(struct mmc_test_card *test,
444 } 442 }
445 } else { 443 } else {
446 local_irq_save(flags); 444 local_irq_save(flags);
447 sg_copy_to_buffer(sg, sg_len, test->scratch, blocks * blksz); 445 sg_copy_to_buffer(sg, sg_len, test->scratch, BUFFER_SIZE);
448 local_irq_restore(flags); 446 local_irq_restore(flags);
449 for (i = 0;i < blocks * blksz;i++) { 447 for (i = 0;i < blocks * blksz;i++) {
450 if (test->scratch[i] != (u8)i) 448 if (test->scratch[i] != (u8)i)
@@ -805,69 +803,6 @@ static int mmc_test_multi_xfersize_read(struct mmc_test_card *test)
805 return 0; 803 return 0;
806} 804}
807 805
808static int mmc_test_bigsg_write(struct mmc_test_card *test)
809{
810 int ret;
811 unsigned int size;
812 struct scatterlist sg;
813
814 if (test->card->host->max_blk_count == 1)
815 return RESULT_UNSUP_HOST;
816
817 size = PAGE_SIZE * 2;
818 size = min(size, test->card->host->max_req_size);
819 size = min(size, test->card->host->max_seg_size);
820 size = min(size, test->card->host->max_blk_count * 512);
821
822 memset(test->buffer, 0, BUFFER_SIZE);
823
824 if (size < 1024)
825 return RESULT_UNSUP_HOST;
826
827 sg_init_table(&sg, 1);
828 sg_init_one(&sg, test->buffer, BUFFER_SIZE);
829
830 ret = mmc_test_transfer(test, &sg, 1, 0, size/512, 512, 1);
831 if (ret)
832 return ret;
833
834 return 0;
835}
836
837static int mmc_test_bigsg_read(struct mmc_test_card *test)
838{
839 int ret, i;
840 unsigned int size;
841 struct scatterlist sg;
842
843 if (test->card->host->max_blk_count == 1)
844 return RESULT_UNSUP_HOST;
845
846 size = PAGE_SIZE * 2;
847 size = min(size, test->card->host->max_req_size);
848 size = min(size, test->card->host->max_seg_size);
849 size = min(size, test->card->host->max_blk_count * 512);
850
851 if (size < 1024)
852 return RESULT_UNSUP_HOST;
853
854 memset(test->buffer, 0xCD, BUFFER_SIZE);
855
856 sg_init_table(&sg, 1);
857 sg_init_one(&sg, test->buffer, BUFFER_SIZE);
858 ret = mmc_test_transfer(test, &sg, 1, 0, size/512, 512, 0);
859 if (ret)
860 return ret;
861
862 /* mmc_test_transfer() doesn't check for read overflows */
863 for (i = size;i < BUFFER_SIZE;i++) {
864 if (test->buffer[i] != 0xCD)
865 return RESULT_FAIL;
866 }
867
868 return 0;
869}
870
871#ifdef CONFIG_HIGHMEM 806#ifdef CONFIG_HIGHMEM
872 807
873static int mmc_test_write_high(struct mmc_test_card *test) 808static int mmc_test_write_high(struct mmc_test_card *test)
@@ -1071,20 +1006,6 @@ static const struct mmc_test_case mmc_test_cases[] = {
1071 .run = mmc_test_multi_xfersize_read, 1006 .run = mmc_test_multi_xfersize_read,
1072 }, 1007 },
1073 1008
1074 {
1075 .name = "Over-sized SG list write",
1076 .prepare = mmc_test_prepare_write,
1077 .run = mmc_test_bigsg_write,
1078 .cleanup = mmc_test_cleanup,
1079 },
1080
1081 {
1082 .name = "Over-sized SG list read",
1083 .prepare = mmc_test_prepare_read,
1084 .run = mmc_test_bigsg_read,
1085 .cleanup = mmc_test_cleanup,
1086 },
1087
1088#ifdef CONFIG_HIGHMEM 1009#ifdef CONFIG_HIGHMEM
1089 1010
1090 { 1011 {
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 3ee5b8c3b5ce..044d84eeed7c 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -121,6 +121,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
121{ 121{
122#ifdef CONFIG_MMC_DEBUG 122#ifdef CONFIG_MMC_DEBUG
123 unsigned int i, sz; 123 unsigned int i, sz;
124 struct scatterlist *sg;
124#endif 125#endif
125 126
126 pr_debug("%s: starting CMD%u arg %08x flags %08x\n", 127 pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
@@ -156,8 +157,8 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
156 157
157#ifdef CONFIG_MMC_DEBUG 158#ifdef CONFIG_MMC_DEBUG
158 sz = 0; 159 sz = 0;
159 for (i = 0;i < mrq->data->sg_len;i++) 160 for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i)
160 sz += mrq->data->sg[i].length; 161 sz += sg->length;
161 BUG_ON(sz != mrq->data->blocks * mrq->data->blksz); 162 BUG_ON(sz != mrq->data->blocks * mrq->data->blksz);
162#endif 163#endif
163 164
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 99b20917cc0f..d3f55615c099 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -61,7 +61,13 @@
61 61
62/* Hardware definitions */ 62/* Hardware definitions */
63#define AU1XMMC_DESCRIPTOR_COUNT 1 63#define AU1XMMC_DESCRIPTOR_COUNT 1
64#define AU1XMMC_DESCRIPTOR_SIZE 2048 64
65/* max DMA seg size: 64KB on Au1100, 4MB on Au1200 */
66#ifdef CONFIG_SOC_AU1100
67#define AU1XMMC_DESCRIPTOR_SIZE 0x0000ffff
68#else /* Au1200 */
69#define AU1XMMC_DESCRIPTOR_SIZE 0x003fffff
70#endif
65 71
66#define AU1XMMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 | \ 72#define AU1XMMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 | \
67 MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 | \ 73 MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 | \
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index deb607c52c0d..fcb14c2346cc 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -143,7 +143,8 @@ static int jmicron_probe(struct sdhci_pci_chip *chip)
143 chip->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR | 143 chip->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR |
144 SDHCI_QUIRK_32BIT_DMA_SIZE | 144 SDHCI_QUIRK_32BIT_DMA_SIZE |
145 SDHCI_QUIRK_32BIT_ADMA_SIZE | 145 SDHCI_QUIRK_32BIT_ADMA_SIZE |
146 SDHCI_QUIRK_RESET_AFTER_REQUEST; 146 SDHCI_QUIRK_RESET_AFTER_REQUEST |
147 SDHCI_QUIRK_BROKEN_SMALL_PIO;
147 } 148 }
148 149
149 /* 150 /*
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 5f95e10229b5..e3a8133560a2 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -278,6 +278,15 @@ static void sdhci_transfer_pio(struct sdhci_host *host)
278 else 278 else
279 mask = SDHCI_SPACE_AVAILABLE; 279 mask = SDHCI_SPACE_AVAILABLE;
280 280
281 /*
282 * Some controllers (JMicron JMB38x) mess up the buffer bits
283 * for transfers < 4 bytes. As long as it is just one block,
284 * we can ignore the bits.
285 */
286 if ((host->quirks & SDHCI_QUIRK_BROKEN_SMALL_PIO) &&
287 (host->data->blocks == 1))
288 mask = ~0;
289
281 while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) { 290 while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) {
282 if (host->data->flags & MMC_DATA_READ) 291 if (host->data->flags & MMC_DATA_READ)
283 sdhci_read_block_pio(host); 292 sdhci_read_block_pio(host);
@@ -439,7 +448,7 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
439 448
440 host->adma_addr = dma_map_single(mmc_dev(host->mmc), 449 host->adma_addr = dma_map_single(mmc_dev(host->mmc),
441 host->adma_desc, (128 * 2 + 1) * 4, DMA_TO_DEVICE); 450 host->adma_desc, (128 * 2 + 1) * 4, DMA_TO_DEVICE);
442 if (dma_mapping_error(mmc_dev(host->mmc), host->align_addr)) 451 if (dma_mapping_error(mmc_dev(host->mmc), host->adma_addr))
443 goto unmap_entries; 452 goto unmap_entries;
444 BUG_ON(host->adma_addr & 0x3); 453 BUG_ON(host->adma_addr & 0x3);
445 454
@@ -645,7 +654,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
645 * us an invalid request. 654 * us an invalid request.
646 */ 655 */
647 WARN_ON(1); 656 WARN_ON(1);
648 host->flags &= ~SDHCI_USE_DMA; 657 host->flags &= ~SDHCI_REQ_USE_DMA;
649 } else { 658 } else {
650 writel(host->adma_addr, 659 writel(host->adma_addr,
651 host->ioaddr + SDHCI_ADMA_ADDRESS); 660 host->ioaddr + SDHCI_ADMA_ADDRESS);
@@ -664,7 +673,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
664 * us an invalid request. 673 * us an invalid request.
665 */ 674 */
666 WARN_ON(1); 675 WARN_ON(1);
667 host->flags &= ~SDHCI_USE_DMA; 676 host->flags &= ~SDHCI_REQ_USE_DMA;
668 } else { 677 } else {
669 WARN_ON(sg_cnt != 1); 678 WARN_ON(sg_cnt != 1);
670 writel(sg_dma_address(data->sg), 679 writel(sg_dma_address(data->sg),
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index e354faee5df0..197d4a05f4ae 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -206,6 +206,8 @@ struct sdhci_host {
206#define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1<<11) 206#define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1<<11)
207/* Controller provides an incorrect timeout value for transfers */ 207/* Controller provides an incorrect timeout value for transfers */
208#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12) 208#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12)
209/* Controller has an issue with buffer bits for small transfers */
210#define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13)
209 211
210 int irq; /* Device IRQ */ 212 int irq; /* Device IRQ */
211 void __iomem * ioaddr; /* Mapped address */ 213 void __iomem * ioaddr; /* Mapped address */
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
index dbba5abf0db8..f84ab6182148 100644
--- a/drivers/mtd/chips/jedec_probe.c
+++ b/drivers/mtd/chips/jedec_probe.c
@@ -41,7 +41,7 @@
41 41
42 42
43/* AMD */ 43/* AMD */
44#define AM29DL800BB 0x22C8 44#define AM29DL800BB 0x22CB
45#define AM29DL800BT 0x224A 45#define AM29DL800BT 0x224A
46 46
47#define AM29F800BB 0x2258 47#define AM29F800BB 0x2258
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 54e36bfc2c3b..8bd0dea6885f 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -15,6 +15,8 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/err.h>
19
18#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
19#include <linux/spi/flash.h> 21#include <linux/spi/flash.h>
20 22
@@ -487,9 +489,8 @@ add_dataflash(struct spi_device *spi, char *name,
487 device->write = dataflash_write; 489 device->write = dataflash_write;
488 device->priv = priv; 490 device->priv = priv;
489 491
490 dev_info(&spi->dev, "%s (%d KBytes) pagesize %d bytes, " 492 dev_info(&spi->dev, "%s (%d KBytes) pagesize %d bytes\n",
491 "erasesize %d bytes\n", name, device->size/1024, 493 name, DIV_ROUND_UP(device->size, 1024), pagesize);
492 pagesize, pagesize * 8); /* 8 pages = 1 block */
493 dev_set_drvdata(&spi->dev, priv); 494 dev_set_drvdata(&spi->dev, priv);
494 495
495 if (mtd_has_partitions()) { 496 if (mtd_has_partitions()) {
@@ -518,65 +519,57 @@ add_dataflash(struct spi_device *spi, char *name,
518 return add_mtd_device(device) == 1 ? -ENODEV : 0; 519 return add_mtd_device(device) == 1 ? -ENODEV : 0;
519} 520}
520 521
521/*
522 * Detect and initialize DataFlash device:
523 *
524 * Device Density ID code #Pages PageSize Offset
525 * AT45DB011B 1Mbit (128K) xx0011xx (0x0c) 512 264 9
526 * AT45DB021B 2Mbit (256K) xx0101xx (0x14) 1024 264 9
527 * AT45DB041B 4Mbit (512K) xx0111xx (0x1c) 2048 264 9
528 * AT45DB081B 8Mbit (1M) xx1001xx (0x24) 4096 264 9
529 * AT45DB0161B 16Mbit (2M) xx1011xx (0x2c) 4096 528 10
530 * AT45DB0321B 32Mbit (4M) xx1101xx (0x34) 8192 528 10
531 * AT45DB0642 64Mbit (8M) xx111xxx (0x3c) 8192 1056 11
532 * AT45DB1282 128Mbit (16M) xx0100xx (0x10) 16384 1056 11
533 */
534
535struct flash_info { 522struct flash_info {
536 char *name; 523 char *name;
537 524
538 /* JEDEC id zero means "no ID" (most older chips); otherwise it has 525 /* JEDEC id has a high byte of zero plus three data bytes:
539 * a high byte of zero plus three data bytes: the manufacturer id, 526 * the manufacturer id, then a two byte device id.
540 * then a two byte device id.
541 */ 527 */
542 uint32_t jedec_id; 528 uint32_t jedec_id;
543 529
544 /* The size listed here is what works with OPCODE_SE, which isn't 530 /* The size listed here is what works with OP_ERASE_PAGE. */
545 * necessarily called a "sector" by the vendor.
546 */
547 unsigned nr_pages; 531 unsigned nr_pages;
548 uint16_t pagesize; 532 uint16_t pagesize;
549 uint16_t pageoffset; 533 uint16_t pageoffset;
550 534
551 uint16_t flags; 535 uint16_t flags;
552#define SUP_POW2PS 0x02 536#define SUP_POW2PS 0x0002 /* supports 2^N byte pages */
553#define IS_POW2PS 0x01 537#define IS_POW2PS 0x0001 /* uses 2^N byte pages */
554}; 538};
555 539
556static struct flash_info __devinitdata dataflash_data [] = { 540static struct flash_info __devinitdata dataflash_data [] = {
557 541
558 { "at45db011d", 0x1f2200, 512, 264, 9, SUP_POW2PS}, 542 /*
543 * NOTE: chips with SUP_POW2PS (rev D and up) need two entries,
544 * one with IS_POW2PS and the other without. The entry with the
545 * non-2^N byte page size can't name exact chip revisions without
546 * losing backwards compatibility for cmdlinepart.
547 *
548 * These newer chips also support 128-byte security registers (with
549 * 64 bytes one-time-programmable) and software write-protection.
550 */
551 { "AT45DB011B", 0x1f2200, 512, 264, 9, SUP_POW2PS},
559 { "at45db011d", 0x1f2200, 512, 256, 8, SUP_POW2PS | IS_POW2PS}, 552 { "at45db011d", 0x1f2200, 512, 256, 8, SUP_POW2PS | IS_POW2PS},
560 553
561 { "at45db021d", 0x1f2300, 1024, 264, 9, SUP_POW2PS}, 554 { "AT45DB021B", 0x1f2300, 1024, 264, 9, SUP_POW2PS},
562 { "at45db021d", 0x1f2300, 1024, 256, 8, SUP_POW2PS | IS_POW2PS}, 555 { "at45db021d", 0x1f2300, 1024, 256, 8, SUP_POW2PS | IS_POW2PS},
563 556
564 { "at45db041d", 0x1f2400, 2048, 264, 9, SUP_POW2PS}, 557 { "AT45DB041x", 0x1f2400, 2048, 264, 9, SUP_POW2PS},
565 { "at45db041d", 0x1f2400, 2048, 256, 8, SUP_POW2PS | IS_POW2PS}, 558 { "at45db041d", 0x1f2400, 2048, 256, 8, SUP_POW2PS | IS_POW2PS},
566 559
567 { "at45db081d", 0x1f2500, 4096, 264, 9, SUP_POW2PS}, 560 { "AT45DB081B", 0x1f2500, 4096, 264, 9, SUP_POW2PS},
568 { "at45db081d", 0x1f2500, 4096, 256, 8, SUP_POW2PS | IS_POW2PS}, 561 { "at45db081d", 0x1f2500, 4096, 256, 8, SUP_POW2PS | IS_POW2PS},
569 562
570 { "at45db161d", 0x1f2600, 4096, 528, 10, SUP_POW2PS}, 563 { "AT45DB161x", 0x1f2600, 4096, 528, 10, SUP_POW2PS},
571 { "at45db161d", 0x1f2600, 4096, 512, 9, SUP_POW2PS | IS_POW2PS}, 564 { "at45db161d", 0x1f2600, 4096, 512, 9, SUP_POW2PS | IS_POW2PS},
572 565
573 { "at45db321c", 0x1f2700, 8192, 528, 10, }, 566 { "AT45DB321x", 0x1f2700, 8192, 528, 10, 0}, /* rev C */
574 567
575 { "at45db321d", 0x1f2701, 8192, 528, 10, SUP_POW2PS}, 568 { "AT45DB321x", 0x1f2701, 8192, 528, 10, SUP_POW2PS},
576 { "at45db321d", 0x1f2701, 8192, 512, 9, SUP_POW2PS | IS_POW2PS}, 569 { "at45db321d", 0x1f2701, 8192, 512, 9, SUP_POW2PS | IS_POW2PS},
577 570
578 { "at45db641d", 0x1f2800, 8192, 1056, 11, SUP_POW2PS}, 571 { "AT45DB642x", 0x1f2800, 8192, 1056, 11, SUP_POW2PS},
579 { "at45db641d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS}, 572 { "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
580}; 573};
581 574
582static struct flash_info *__devinit jedec_probe(struct spi_device *spi) 575static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
@@ -588,17 +581,23 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
588 struct flash_info *info; 581 struct flash_info *info;
589 int status; 582 int status;
590 583
591
592 /* JEDEC also defines an optional "extended device information" 584 /* JEDEC also defines an optional "extended device information"
593 * string for after vendor-specific data, after the three bytes 585 * string for after vendor-specific data, after the three bytes
594 * we use here. Supporting some chips might require using it. 586 * we use here. Supporting some chips might require using it.
587 *
588 * If the vendor ID isn't Atmel's (0x1f), assume this call failed.
589 * That's not an error; only rev C and newer chips handle it, and
590 * only Atmel sells these chips.
595 */ 591 */
596 tmp = spi_write_then_read(spi, &code, 1, id, 3); 592 tmp = spi_write_then_read(spi, &code, 1, id, 3);
597 if (tmp < 0) { 593 if (tmp < 0) {
598 DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", 594 DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n",
599 spi->dev.bus_id, tmp); 595 spi->dev.bus_id, tmp);
600 return NULL; 596 return ERR_PTR(tmp);
601 } 597 }
598 if (id[0] != 0x1f)
599 return NULL;
600
602 jedec = id[0]; 601 jedec = id[0];
603 jedec = jedec << 8; 602 jedec = jedec << 8;
604 jedec |= id[1]; 603 jedec |= id[1];
@@ -609,19 +608,53 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
609 tmp < ARRAY_SIZE(dataflash_data); 608 tmp < ARRAY_SIZE(dataflash_data);
610 tmp++, info++) { 609 tmp++, info++) {
611 if (info->jedec_id == jedec) { 610 if (info->jedec_id == jedec) {
611 DEBUG(MTD_DEBUG_LEVEL1, "%s: OTP, sector protect%s\n",
612 dev_name(&spi->dev),
613 (info->flags & SUP_POW2PS)
614 ? ", binary pagesize" : ""
615 );
612 if (info->flags & SUP_POW2PS) { 616 if (info->flags & SUP_POW2PS) {
613 status = dataflash_status(spi); 617 status = dataflash_status(spi);
614 if (status & 0x1) 618 if (status < 0) {
615 /* return power of 2 pagesize */ 619 DEBUG(MTD_DEBUG_LEVEL1,
616 return ++info; 620 "%s: status error %d\n",
617 else 621 dev_name(&spi->dev), status);
618 return info; 622 return ERR_PTR(status);
623 }
624 if (status & 0x1) {
625 if (info->flags & IS_POW2PS)
626 return info;
627 } else {
628 if (!(info->flags & IS_POW2PS))
629 return info;
630 }
619 } 631 }
620 } 632 }
621 } 633 }
622 return NULL; 634
635 /*
636 * Treat other chips as errors ... we won't know the right page
637 * size (it might be binary) even when we can tell which density
638 * class is involved (legacy chip id scheme).
639 */
640 dev_warn(&spi->dev, "JEDEC id %06x not handled\n", jedec);
641 return ERR_PTR(-ENODEV);
623} 642}
624 643
644/*
645 * Detect and initialize DataFlash device, using JEDEC IDs on newer chips
646 * or else the ID code embedded in the status bits:
647 *
648 * Device Density ID code #Pages PageSize Offset
649 * AT45DB011B 1Mbit (128K) xx0011xx (0x0c) 512 264 9
650 * AT45DB021B 2Mbit (256K) xx0101xx (0x14) 1024 264 9
651 * AT45DB041B 4Mbit (512K) xx0111xx (0x1c) 2048 264 9
652 * AT45DB081B 8Mbit (1M) xx1001xx (0x24) 4096 264 9
653 * AT45DB0161B 16Mbit (2M) xx1011xx (0x2c) 4096 528 10
654 * AT45DB0321B 32Mbit (4M) xx1101xx (0x34) 8192 528 10
655 * AT45DB0642 64Mbit (8M) xx111xxx (0x3c) 8192 1056 11
656 * AT45DB1282 128Mbit (16M) xx0100xx (0x10) 16384 1056 11
657 */
625static int __devinit dataflash_probe(struct spi_device *spi) 658static int __devinit dataflash_probe(struct spi_device *spi)
626{ 659{
627 int status; 660 int status;
@@ -632,14 +665,17 @@ static int __devinit dataflash_probe(struct spi_device *spi)
632 * If it succeeds we know we have either a C or D part. 665 * If it succeeds we know we have either a C or D part.
633 * D will support power of 2 pagesize option. 666 * D will support power of 2 pagesize option.
634 */ 667 */
635
636 info = jedec_probe(spi); 668 info = jedec_probe(spi);
637 669 if (IS_ERR(info))
670 return PTR_ERR(info);
638 if (info != NULL) 671 if (info != NULL)
639 return add_dataflash(spi, info->name, info->nr_pages, 672 return add_dataflash(spi, info->name, info->nr_pages,
640 info->pagesize, info->pageoffset); 673 info->pagesize, info->pageoffset);
641 674
642 675 /*
676 * Older chips support only legacy commands, identifing
677 * capacity using bits in the status byte.
678 */
643 status = dataflash_status(spi); 679 status = dataflash_status(spi);
644 if (status <= 0 || status == 0xff) { 680 if (status <= 0 || status == 0xff) {
645 DEBUG(MTD_DEBUG_LEVEL1, "%s: status error %d\n", 681 DEBUG(MTD_DEBUG_LEVEL1, "%s: status error %d\n",
@@ -661,13 +697,13 @@ static int __devinit dataflash_probe(struct spi_device *spi)
661 status = add_dataflash(spi, "AT45DB021B", 1024, 264, 9); 697 status = add_dataflash(spi, "AT45DB021B", 1024, 264, 9);
662 break; 698 break;
663 case 0x1c: /* 0 1 1 1 x x */ 699 case 0x1c: /* 0 1 1 1 x x */
664 status = add_dataflash(spi, "AT45DB041B", 2048, 264, 9); 700 status = add_dataflash(spi, "AT45DB041x", 2048, 264, 9);
665 break; 701 break;
666 case 0x24: /* 1 0 0 1 x x */ 702 case 0x24: /* 1 0 0 1 x x */
667 status = add_dataflash(spi, "AT45DB081B", 4096, 264, 9); 703 status = add_dataflash(spi, "AT45DB081B", 4096, 264, 9);
668 break; 704 break;
669 case 0x2c: /* 1 0 1 1 x x */ 705 case 0x2c: /* 1 0 1 1 x x */
670 status = add_dataflash(spi, "AT45DB161B", 4096, 528, 10); 706 status = add_dataflash(spi, "AT45DB161x", 4096, 528, 10);
671 break; 707 break;
672 case 0x34: /* 1 1 0 1 x x */ 708 case 0x34: /* 1 1 0 1 x x */
673 status = add_dataflash(spi, "AT45DB321x", 8192, 528, 10); 709 status = add_dataflash(spi, "AT45DB321x", 8192, 528, 10);
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
index a806119797e0..113b1062020d 100644
--- a/drivers/mtd/maps/ipaq-flash.c
+++ b/drivers/mtd/maps/ipaq-flash.c
@@ -25,7 +25,7 @@
25#endif 25#endif
26 26
27#include <asm/hardware.h> 27#include <asm/hardware.h>
28#include <asm/arch-sa1100/h3600.h> 28#include <asm/arch/h3600.h>
29#include <asm/io.h> 29#include <asm/io.h>
30 30
31 31
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index 28cc6787a800..00d46e137b2a 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -125,8 +125,11 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
125 int (*fill_super)(struct super_block *, void *, int), 125 int (*fill_super)(struct super_block *, void *, int),
126 struct vfsmount *mnt) 126 struct vfsmount *mnt)
127{ 127{
128 struct nameidata nd; 128#ifdef CONFIG_BLOCK
129 int mtdnr, ret; 129 struct block_device *bdev;
130 int ret, major;
131#endif
132 int mtdnr;
130 133
131 if (!dev_name) 134 if (!dev_name)
132 return -EINVAL; 135 return -EINVAL;
@@ -178,45 +181,38 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
178 } 181 }
179 } 182 }
180 183
184#ifdef CONFIG_BLOCK
181 /* try the old way - the hack where we allowed users to mount 185 /* try the old way - the hack where we allowed users to mount
182 * /dev/mtdblock$(n) but didn't actually _use_ the blockdev 186 * /dev/mtdblock$(n) but didn't actually _use_ the blockdev
183 */ 187 */
184 ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); 188 bdev = lookup_bdev(dev_name);
185 189 if (IS_ERR(bdev)) {
186 DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n", 190 ret = PTR_ERR(bdev);
187 ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL); 191 DEBUG(1, "MTDSB: lookup_bdev() returned %d\n", ret);
188
189 if (ret)
190 return ret; 192 return ret;
193 }
194 DEBUG(1, "MTDSB: lookup_bdev() returned 0\n");
191 195
192 ret = -EINVAL; 196 ret = -EINVAL;
193 197
194 if (!S_ISBLK(nd.path.dentry->d_inode->i_mode)) 198 major = MAJOR(bdev->bd_dev);
195 goto out; 199 mtdnr = MINOR(bdev->bd_dev);
196 200 bdput(bdev);
197 if (nd.path.mnt->mnt_flags & MNT_NODEV) {
198 ret = -EACCES;
199 goto out;
200 }
201 201
202 if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR) 202 if (major != MTD_BLOCK_MAJOR)
203 goto not_an_MTD_device; 203 goto not_an_MTD_device;
204 204
205 mtdnr = iminor(nd.path.dentry->d_inode);
206 path_put(&nd.path);
207
208 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, 205 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super,
209 mnt); 206 mnt);
210 207
211not_an_MTD_device: 208not_an_MTD_device:
209#endif /* CONFIG_BLOCK */
210
212 if (!(flags & MS_SILENT)) 211 if (!(flags & MS_SILENT))
213 printk(KERN_NOTICE 212 printk(KERN_NOTICE
214 "MTD: Attempt to mount non-MTD device \"%s\"\n", 213 "MTD: Attempt to mount non-MTD device \"%s\"\n",
215 dev_name); 214 dev_name);
216out: 215 return -EINVAL;
217 path_put(&nd.path);
218 return ret;
219
220} 216}
221 217
222EXPORT_SYMBOL_GPL(get_sb_mtd); 218EXPORT_SYMBOL_GPL(get_sb_mtd);
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 71406e517857..02f9cc30d77b 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -104,11 +104,24 @@ config MTD_NAND_BF5XX
104 104
105config MTD_NAND_BF5XX_HWECC 105config MTD_NAND_BF5XX_HWECC
106 bool "BF5XX NAND Hardware ECC" 106 bool "BF5XX NAND Hardware ECC"
107 default y
107 depends on MTD_NAND_BF5XX 108 depends on MTD_NAND_BF5XX
108 help 109 help
109 Enable the use of the BF5XX's internal ECC generator when 110 Enable the use of the BF5XX's internal ECC generator when
110 using NAND. 111 using NAND.
111 112
113config MTD_NAND_BF5XX_BOOTROM_ECC
114 bool "Use Blackfin BootROM ECC Layout"
115 default n
116 depends on MTD_NAND_BF5XX_HWECC
117 help
118 If you wish to modify NAND pages and allow the Blackfin on-chip
119 BootROM to boot from them, say Y here. This is only necessary
120 if you are booting U-Boot out of NAND and you wish to update
121 U-Boot from Linux' userspace. Otherwise, you should say N here.
122
123 If unsure, say N.
124
112config MTD_NAND_RTC_FROM4 125config MTD_NAND_RTC_FROM4
113 tristate "Renesas Flash ROM 4-slot interface board (FROM_BOARD4)" 126 tristate "Renesas Flash ROM 4-slot interface board (FROM_BOARD4)"
114 depends on SH_SOLUTION_ENGINE 127 depends on SH_SOLUTION_ENGINE
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index e87a57297328..9af2a2cc1153 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -91,6 +91,41 @@ static const unsigned short bfin_nfc_pin_req[] =
91 P_NAND_ALE, 91 P_NAND_ALE,
92 0}; 92 0};
93 93
94#ifdef CONFIG_MTD_NAND_BF5XX_BOOTROM_ECC
95static uint8_t bbt_pattern[] = { 0xff };
96
97static struct nand_bbt_descr bootrom_bbt = {
98 .options = 0,
99 .offs = 63,
100 .len = 1,
101 .pattern = bbt_pattern,
102};
103
104static struct nand_ecclayout bootrom_ecclayout = {
105 .eccbytes = 24,
106 .eccpos = {
107 0x8 * 0, 0x8 * 0 + 1, 0x8 * 0 + 2,
108 0x8 * 1, 0x8 * 1 + 1, 0x8 * 1 + 2,
109 0x8 * 2, 0x8 * 2 + 1, 0x8 * 2 + 2,
110 0x8 * 3, 0x8 * 3 + 1, 0x8 * 3 + 2,
111 0x8 * 4, 0x8 * 4 + 1, 0x8 * 4 + 2,
112 0x8 * 5, 0x8 * 5 + 1, 0x8 * 5 + 2,
113 0x8 * 6, 0x8 * 6 + 1, 0x8 * 6 + 2,
114 0x8 * 7, 0x8 * 7 + 1, 0x8 * 7 + 2
115 },
116 .oobfree = {
117 { 0x8 * 0 + 3, 5 },
118 { 0x8 * 1 + 3, 5 },
119 { 0x8 * 2 + 3, 5 },
120 { 0x8 * 3 + 3, 5 },
121 { 0x8 * 4 + 3, 5 },
122 { 0x8 * 5 + 3, 5 },
123 { 0x8 * 6 + 3, 5 },
124 { 0x8 * 7 + 3, 5 },
125 }
126};
127#endif
128
94/* 129/*
95 * Data structures for bf5xx nand flash controller driver 130 * Data structures for bf5xx nand flash controller driver
96 */ 131 */
@@ -273,7 +308,7 @@ static int bf5xx_nand_correct_data(struct mtd_info *mtd, u_char *dat,
273 dat += 256; 308 dat += 256;
274 read_ecc += 8; 309 read_ecc += 8;
275 calc_ecc += 8; 310 calc_ecc += 8;
276 ret = bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc); 311 ret |= bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc);
277 } 312 }
278 313
279 return ret; 314 return ret;
@@ -298,7 +333,7 @@ static int bf5xx_nand_calculate_ecc(struct mtd_info *mtd,
298 ecc0 = bfin_read_NFC_ECC0(); 333 ecc0 = bfin_read_NFC_ECC0();
299 ecc1 = bfin_read_NFC_ECC1(); 334 ecc1 = bfin_read_NFC_ECC1();
300 335
301 code[0] = (ecc0 & 0x3FF) | ((ecc1 & 0x3FF) << 11); 336 code[0] = (ecc0 & 0x7ff) | ((ecc1 & 0x7ff) << 11);
302 337
303 dev_dbg(info->device, "returning ecc 0x%08x\n", code[0]); 338 dev_dbg(info->device, "returning ecc 0x%08x\n", code[0]);
304 339
@@ -310,7 +345,7 @@ static int bf5xx_nand_calculate_ecc(struct mtd_info *mtd,
310 if (page_size == 512) { 345 if (page_size == 512) {
311 ecc0 = bfin_read_NFC_ECC2(); 346 ecc0 = bfin_read_NFC_ECC2();
312 ecc1 = bfin_read_NFC_ECC3(); 347 ecc1 = bfin_read_NFC_ECC3();
313 code[1] = (ecc0 & 0x3FF) | ((ecc1 & 0x3FF) << 11); 348 code[1] = (ecc0 & 0x7ff) | ((ecc1 & 0x7ff) << 11);
314 349
315 /* second 3 bytes in ecc_code for second 256 350 /* second 3 bytes in ecc_code for second 256
316 * bytes of 512 page size 351 * bytes of 512 page size
@@ -514,7 +549,6 @@ static void bf5xx_nand_dma_write_buf(struct mtd_info *mtd,
514/* 549/*
515 * System initialization functions 550 * System initialization functions
516 */ 551 */
517
518static int bf5xx_nand_dma_init(struct bf5xx_nand_info *info) 552static int bf5xx_nand_dma_init(struct bf5xx_nand_info *info)
519{ 553{
520 int ret; 554 int ret;
@@ -547,6 +581,13 @@ static int bf5xx_nand_dma_init(struct bf5xx_nand_info *info)
547 return 0; 581 return 0;
548} 582}
549 583
584static void bf5xx_nand_dma_remove(struct bf5xx_nand_info *info)
585{
586 /* Free NFC DMA channel */
587 if (hardware_ecc)
588 free_dma(CH_NFC);
589}
590
550/* 591/*
551 * BF5XX NFC hardware initialization 592 * BF5XX NFC hardware initialization
552 * - pin mux setup 593 * - pin mux setup
@@ -605,7 +646,7 @@ static int bf5xx_nand_add_partition(struct bf5xx_nand_info *info)
605#endif 646#endif
606} 647}
607 648
608static int bf5xx_nand_remove(struct platform_device *pdev) 649static int __devexit bf5xx_nand_remove(struct platform_device *pdev)
609{ 650{
610 struct bf5xx_nand_info *info = to_nand_info(pdev); 651 struct bf5xx_nand_info *info = to_nand_info(pdev);
611 struct mtd_info *mtd = NULL; 652 struct mtd_info *mtd = NULL;
@@ -623,6 +664,7 @@ static int bf5xx_nand_remove(struct platform_device *pdev)
623 } 664 }
624 665
625 peripheral_free_list(bfin_nfc_pin_req); 666 peripheral_free_list(bfin_nfc_pin_req);
667 bf5xx_nand_dma_remove(info);
626 668
627 /* free the common resources */ 669 /* free the common resources */
628 kfree(info); 670 kfree(info);
@@ -638,7 +680,7 @@ static int bf5xx_nand_remove(struct platform_device *pdev)
638 * it can allocate all necessary resources then calls the 680 * it can allocate all necessary resources then calls the
639 * nand layer to look for devices 681 * nand layer to look for devices
640 */ 682 */
641static int bf5xx_nand_probe(struct platform_device *pdev) 683static int __devinit bf5xx_nand_probe(struct platform_device *pdev)
642{ 684{
643 struct bf5xx_nand_platform *plat = to_nand_plat(pdev); 685 struct bf5xx_nand_platform *plat = to_nand_plat(pdev);
644 struct bf5xx_nand_info *info = NULL; 686 struct bf5xx_nand_info *info = NULL;
@@ -648,22 +690,21 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
648 690
649 dev_dbg(&pdev->dev, "(%p)\n", pdev); 691 dev_dbg(&pdev->dev, "(%p)\n", pdev);
650 692
651 if (peripheral_request_list(bfin_nfc_pin_req, DRV_NAME)) {
652 printk(KERN_ERR DRV_NAME
653 ": Requesting Peripherals failed\n");
654 return -EFAULT;
655 }
656
657 if (!plat) { 693 if (!plat) {
658 dev_err(&pdev->dev, "no platform specific information\n"); 694 dev_err(&pdev->dev, "no platform specific information\n");
659 goto exit_error; 695 return -EINVAL;
696 }
697
698 if (peripheral_request_list(bfin_nfc_pin_req, DRV_NAME)) {
699 dev_err(&pdev->dev, "requesting Peripherals failed\n");
700 return -EFAULT;
660 } 701 }
661 702
662 info = kzalloc(sizeof(*info), GFP_KERNEL); 703 info = kzalloc(sizeof(*info), GFP_KERNEL);
663 if (info == NULL) { 704 if (info == NULL) {
664 dev_err(&pdev->dev, "no memory for flash info\n"); 705 dev_err(&pdev->dev, "no memory for flash info\n");
665 err = -ENOMEM; 706 err = -ENOMEM;
666 goto exit_error; 707 goto out_err_kzalloc;
667 } 708 }
668 709
669 platform_set_drvdata(pdev, info); 710 platform_set_drvdata(pdev, info);
@@ -707,11 +748,16 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
707 748
708 /* initialise the hardware */ 749 /* initialise the hardware */
709 err = bf5xx_nand_hw_init(info); 750 err = bf5xx_nand_hw_init(info);
710 if (err != 0) 751 if (err)
711 goto exit_error; 752 goto out_err_hw_init;
712 753
713 /* setup hardware ECC data struct */ 754 /* setup hardware ECC data struct */
714 if (hardware_ecc) { 755 if (hardware_ecc) {
756#ifdef CONFIG_MTD_NAND_BF5XX_BOOTROM_ECC
757 chip->badblock_pattern = &bootrom_bbt;
758 chip->ecc.layout = &bootrom_ecclayout;
759#endif
760
715 if (plat->page_size == NFC_PG_SIZE_256) { 761 if (plat->page_size == NFC_PG_SIZE_256) {
716 chip->ecc.bytes = 3; 762 chip->ecc.bytes = 3;
717 chip->ecc.size = 256; 763 chip->ecc.size = 256;
@@ -733,7 +779,7 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
733 /* scan hardware nand chip and setup mtd info data struct */ 779 /* scan hardware nand chip and setup mtd info data struct */
734 if (nand_scan(mtd, 1)) { 780 if (nand_scan(mtd, 1)) {
735 err = -ENXIO; 781 err = -ENXIO;
736 goto exit_error; 782 goto out_err_nand_scan;
737 } 783 }
738 784
739 /* add NAND partition */ 785 /* add NAND partition */
@@ -742,11 +788,14 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
742 dev_dbg(&pdev->dev, "initialised ok\n"); 788 dev_dbg(&pdev->dev, "initialised ok\n");
743 return 0; 789 return 0;
744 790
745exit_error: 791out_err_nand_scan:
746 bf5xx_nand_remove(pdev); 792 bf5xx_nand_dma_remove(info);
793out_err_hw_init:
794 platform_set_drvdata(pdev, NULL);
795 kfree(info);
796out_err_kzalloc:
797 peripheral_free_list(bfin_nfc_pin_req);
747 798
748 if (err == 0)
749 err = -EINVAL;
750 return err; 799 return err;
751} 800}
752 801
@@ -775,7 +824,7 @@ static int bf5xx_nand_resume(struct platform_device *dev)
775/* driver device registration */ 824/* driver device registration */
776static struct platform_driver bf5xx_nand_driver = { 825static struct platform_driver bf5xx_nand_driver = {
777 .probe = bf5xx_nand_probe, 826 .probe = bf5xx_nand_probe,
778 .remove = bf5xx_nand_remove, 827 .remove = __devexit_p(bf5xx_nand_remove),
779 .suspend = bf5xx_nand_suspend, 828 .suspend = bf5xx_nand_suspend,
780 .resume = bf5xx_nand_resume, 829 .resume = bf5xx_nand_resume,
781 .driver = { 830 .driver = {
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 765d4f0f7c86..e4226e02d63e 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -1125,9 +1125,9 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partitio
1125 goto out; 1125 goto out;
1126 mh = (struct NFTLMediaHeader *)buf; 1126 mh = (struct NFTLMediaHeader *)buf;
1127 1127
1128 mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits); 1128 le16_to_cpus(&mh->NumEraseUnits);
1129 mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN); 1129 le16_to_cpus(&mh->FirstPhysicalEUN);
1130 mh->FormattedSize = le32_to_cpu(mh->FormattedSize); 1130 le32_to_cpus(&mh->FormattedSize);
1131 1131
1132 printk(KERN_INFO " DataOrgID = %s\n" 1132 printk(KERN_INFO " DataOrgID = %s\n"
1133 " NumEraseUnits = %d\n" 1133 " NumEraseUnits = %d\n"
@@ -1235,12 +1235,12 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partiti
1235 doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift); 1235 doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift);
1236 mh = (struct INFTLMediaHeader *)buf; 1236 mh = (struct INFTLMediaHeader *)buf;
1237 1237
1238 mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks); 1238 le32_to_cpus(&mh->NoOfBootImageBlocks);
1239 mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions); 1239 le32_to_cpus(&mh->NoOfBinaryPartitions);
1240 mh->NoOfBDTLPartitions = le32_to_cpu(mh->NoOfBDTLPartitions); 1240 le32_to_cpus(&mh->NoOfBDTLPartitions);
1241 mh->BlockMultiplierBits = le32_to_cpu(mh->BlockMultiplierBits); 1241 le32_to_cpus(&mh->BlockMultiplierBits);
1242 mh->FormatFlags = le32_to_cpu(mh->FormatFlags); 1242 le32_to_cpus(&mh->FormatFlags);
1243 mh->PercentUsed = le32_to_cpu(mh->PercentUsed); 1243 le32_to_cpus(&mh->PercentUsed);
1244 1244
1245 printk(KERN_INFO " bootRecordID = %s\n" 1245 printk(KERN_INFO " bootRecordID = %s\n"
1246 " NoOfBootImageBlocks = %d\n" 1246 " NoOfBootImageBlocks = %d\n"
@@ -1277,12 +1277,12 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partiti
1277 /* Scan the partitions */ 1277 /* Scan the partitions */
1278 for (i = 0; (i < 4); i++) { 1278 for (i = 0; (i < 4); i++) {
1279 ip = &(mh->Partitions[i]); 1279 ip = &(mh->Partitions[i]);
1280 ip->virtualUnits = le32_to_cpu(ip->virtualUnits); 1280 le32_to_cpus(&ip->virtualUnits);
1281 ip->firstUnit = le32_to_cpu(ip->firstUnit); 1281 le32_to_cpus(&ip->firstUnit);
1282 ip->lastUnit = le32_to_cpu(ip->lastUnit); 1282 le32_to_cpus(&ip->lastUnit);
1283 ip->flags = le32_to_cpu(ip->flags); 1283 le32_to_cpus(&ip->flags);
1284 ip->spareUnits = le32_to_cpu(ip->spareUnits); 1284 le32_to_cpus(&ip->spareUnits);
1285 ip->Reserved0 = le32_to_cpu(ip->Reserved0); 1285 le32_to_cpus(&ip->Reserved0);
1286 1286
1287 printk(KERN_INFO " PARTITION[%d] ->\n" 1287 printk(KERN_INFO " PARTITION[%d] ->\n"
1288 " virtualUnits = %d\n" 1288 " virtualUnits = %d\n"
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 9dff51351f4f..98ad3cefcaf4 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -887,7 +887,7 @@ static int __devinit fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
887 goto err; 887 goto err;
888 } 888 }
889 889
890 priv->mtd.name = kasprintf(GFP_KERNEL, "%x.flash", res.start); 890 priv->mtd.name = kasprintf(GFP_KERNEL, "%x.flash", (unsigned)res.start);
891 if (!priv->mtd.name) { 891 if (!priv->mtd.name) {
892 ret = -ENOMEM; 892 ret = -ENOMEM;
893 goto err; 893 goto err;
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index ecd70e2504f6..556e8131ecdc 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -28,6 +28,7 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31#include <asm/div64.h>
31#include <linux/slab.h> 32#include <linux/slab.h>
32#include <linux/errno.h> 33#include <linux/errno.h>
33#include <linux/string.h> 34#include <linux/string.h>
@@ -207,13 +208,16 @@ MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the I
207#define STATE_CMD_READID 0x0000000A /* read ID */ 208#define STATE_CMD_READID 0x0000000A /* read ID */
208#define STATE_CMD_ERASE2 0x0000000B /* sector erase second command */ 209#define STATE_CMD_ERASE2 0x0000000B /* sector erase second command */
209#define STATE_CMD_RESET 0x0000000C /* reset */ 210#define STATE_CMD_RESET 0x0000000C /* reset */
211#define STATE_CMD_RNDOUT 0x0000000D /* random output command */
212#define STATE_CMD_RNDOUTSTART 0x0000000E /* random output start command */
210#define STATE_CMD_MASK 0x0000000F /* command states mask */ 213#define STATE_CMD_MASK 0x0000000F /* command states mask */
211 214
212/* After an address is input, the simulator goes to one of these states */ 215/* After an address is input, the simulator goes to one of these states */
213#define STATE_ADDR_PAGE 0x00000010 /* full (row, column) address is accepted */ 216#define STATE_ADDR_PAGE 0x00000010 /* full (row, column) address is accepted */
214#define STATE_ADDR_SEC 0x00000020 /* sector address was accepted */ 217#define STATE_ADDR_SEC 0x00000020 /* sector address was accepted */
215#define STATE_ADDR_ZERO 0x00000030 /* one byte zero address was accepted */ 218#define STATE_ADDR_COLUMN 0x00000030 /* column address was accepted */
216#define STATE_ADDR_MASK 0x00000030 /* address states mask */ 219#define STATE_ADDR_ZERO 0x00000040 /* one byte zero address was accepted */
220#define STATE_ADDR_MASK 0x00000070 /* address states mask */
217 221
218/* Durind data input/output the simulator is in these states */ 222/* Durind data input/output the simulator is in these states */
219#define STATE_DATAIN 0x00000100 /* waiting for data input */ 223#define STATE_DATAIN 0x00000100 /* waiting for data input */
@@ -240,7 +244,7 @@ MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the I
240#define ACTION_OOBOFF 0x00600000 /* add to address OOB offset */ 244#define ACTION_OOBOFF 0x00600000 /* add to address OOB offset */
241#define ACTION_MASK 0x00700000 /* action mask */ 245#define ACTION_MASK 0x00700000 /* action mask */
242 246
243#define NS_OPER_NUM 12 /* Number of operations supported by the simulator */ 247#define NS_OPER_NUM 13 /* Number of operations supported by the simulator */
244#define NS_OPER_STATES 6 /* Maximum number of states in operation */ 248#define NS_OPER_STATES 6 /* Maximum number of states in operation */
245 249
246#define OPT_ANY 0xFFFFFFFF /* any chip supports this operation */ 250#define OPT_ANY 0xFFFFFFFF /* any chip supports this operation */
@@ -373,7 +377,10 @@ static struct nandsim_operations {
373 {OPT_ANY, {STATE_CMD_READID, STATE_ADDR_ZERO, STATE_DATAOUT_ID, STATE_READY}}, 377 {OPT_ANY, {STATE_CMD_READID, STATE_ADDR_ZERO, STATE_DATAOUT_ID, STATE_READY}},
374 /* Large page devices read page */ 378 /* Large page devices read page */
375 {OPT_LARGEPAGE, {STATE_CMD_READ0, STATE_ADDR_PAGE, STATE_CMD_READSTART | ACTION_CPY, 379 {OPT_LARGEPAGE, {STATE_CMD_READ0, STATE_ADDR_PAGE, STATE_CMD_READSTART | ACTION_CPY,
376 STATE_DATAOUT, STATE_READY}} 380 STATE_DATAOUT, STATE_READY}},
381 /* Large page devices random page read */
382 {OPT_LARGEPAGE, {STATE_CMD_RNDOUT, STATE_ADDR_COLUMN, STATE_CMD_RNDOUTSTART | ACTION_CPY,
383 STATE_DATAOUT, STATE_READY}},
377}; 384};
378 385
379struct weak_block { 386struct weak_block {
@@ -579,7 +586,8 @@ static int init_nandsim(struct mtd_info *mtd)
579 if (ns->busw == 16) 586 if (ns->busw == 16)
580 NS_WARN("16-bit flashes support wasn't tested\n"); 587 NS_WARN("16-bit flashes support wasn't tested\n");
581 588
582 printk("flash size: %llu MiB\n", ns->geom.totsz >> 20); 589 printk("flash size: %llu MiB\n",
590 (unsigned long long)ns->geom.totsz >> 20);
583 printk("page size: %u bytes\n", ns->geom.pgsz); 591 printk("page size: %u bytes\n", ns->geom.pgsz);
584 printk("OOB area size: %u bytes\n", ns->geom.oobsz); 592 printk("OOB area size: %u bytes\n", ns->geom.oobsz);
585 printk("sector size: %u KiB\n", ns->geom.secsz >> 10); 593 printk("sector size: %u KiB\n", ns->geom.secsz >> 10);
@@ -588,8 +596,9 @@ static int init_nandsim(struct mtd_info *mtd)
588 printk("bus width: %u\n", ns->busw); 596 printk("bus width: %u\n", ns->busw);
589 printk("bits in sector size: %u\n", ns->geom.secshift); 597 printk("bits in sector size: %u\n", ns->geom.secshift);
590 printk("bits in page size: %u\n", ns->geom.pgshift); 598 printk("bits in page size: %u\n", ns->geom.pgshift);
591 printk("bits in OOB size: %u\n", ns->geom.oobshift); 599 printk("bits in OOB size: %u\n", ns->geom.oobshift);
592 printk("flash size with OOB: %llu KiB\n", ns->geom.totszoob >> 10); 600 printk("flash size with OOB: %llu KiB\n",
601 (unsigned long long)ns->geom.totszoob >> 10);
593 printk("page address bytes: %u\n", ns->geom.pgaddrbytes); 602 printk("page address bytes: %u\n", ns->geom.pgaddrbytes);
594 printk("sector address bytes: %u\n", ns->geom.secaddrbytes); 603 printk("sector address bytes: %u\n", ns->geom.secaddrbytes);
595 printk("options: %#x\n", ns->options); 604 printk("options: %#x\n", ns->options);
@@ -937,12 +946,18 @@ static char *get_state_name(uint32_t state)
937 return "STATE_CMD_ERASE2"; 946 return "STATE_CMD_ERASE2";
938 case STATE_CMD_RESET: 947 case STATE_CMD_RESET:
939 return "STATE_CMD_RESET"; 948 return "STATE_CMD_RESET";
949 case STATE_CMD_RNDOUT:
950 return "STATE_CMD_RNDOUT";
951 case STATE_CMD_RNDOUTSTART:
952 return "STATE_CMD_RNDOUTSTART";
940 case STATE_ADDR_PAGE: 953 case STATE_ADDR_PAGE:
941 return "STATE_ADDR_PAGE"; 954 return "STATE_ADDR_PAGE";
942 case STATE_ADDR_SEC: 955 case STATE_ADDR_SEC:
943 return "STATE_ADDR_SEC"; 956 return "STATE_ADDR_SEC";
944 case STATE_ADDR_ZERO: 957 case STATE_ADDR_ZERO:
945 return "STATE_ADDR_ZERO"; 958 return "STATE_ADDR_ZERO";
959 case STATE_ADDR_COLUMN:
960 return "STATE_ADDR_COLUMN";
946 case STATE_DATAIN: 961 case STATE_DATAIN:
947 return "STATE_DATAIN"; 962 return "STATE_DATAIN";
948 case STATE_DATAOUT: 963 case STATE_DATAOUT:
@@ -973,6 +988,7 @@ static int check_command(int cmd)
973 switch (cmd) { 988 switch (cmd) {
974 989
975 case NAND_CMD_READ0: 990 case NAND_CMD_READ0:
991 case NAND_CMD_READ1:
976 case NAND_CMD_READSTART: 992 case NAND_CMD_READSTART:
977 case NAND_CMD_PAGEPROG: 993 case NAND_CMD_PAGEPROG:
978 case NAND_CMD_READOOB: 994 case NAND_CMD_READOOB:
@@ -982,7 +998,8 @@ static int check_command(int cmd)
982 case NAND_CMD_READID: 998 case NAND_CMD_READID:
983 case NAND_CMD_ERASE2: 999 case NAND_CMD_ERASE2:
984 case NAND_CMD_RESET: 1000 case NAND_CMD_RESET:
985 case NAND_CMD_READ1: 1001 case NAND_CMD_RNDOUT:
1002 case NAND_CMD_RNDOUTSTART:
986 return 0; 1003 return 0;
987 1004
988 case NAND_CMD_STATUS_MULTI: 1005 case NAND_CMD_STATUS_MULTI:
@@ -1021,6 +1038,10 @@ static uint32_t get_state_by_command(unsigned command)
1021 return STATE_CMD_ERASE2; 1038 return STATE_CMD_ERASE2;
1022 case NAND_CMD_RESET: 1039 case NAND_CMD_RESET:
1023 return STATE_CMD_RESET; 1040 return STATE_CMD_RESET;
1041 case NAND_CMD_RNDOUT:
1042 return STATE_CMD_RNDOUT;
1043 case NAND_CMD_RNDOUTSTART:
1044 return STATE_CMD_RNDOUTSTART;
1024 } 1045 }
1025 1046
1026 NS_ERR("get_state_by_command: unknown command, BUG\n"); 1047 NS_ERR("get_state_by_command: unknown command, BUG\n");
@@ -1582,6 +1603,11 @@ static void switch_state(struct nandsim *ns)
1582 ns->regs.num = 1; 1603 ns->regs.num = 1;
1583 break; 1604 break;
1584 1605
1606 case STATE_ADDR_COLUMN:
1607 /* Column address is always 2 bytes */
1608 ns->regs.num = ns->geom.pgaddrbytes - ns->geom.secaddrbytes;
1609 break;
1610
1585 default: 1611 default:
1586 NS_ERR("switch_state: BUG! unknown address state\n"); 1612 NS_ERR("switch_state: BUG! unknown address state\n");
1587 } 1613 }
@@ -1693,15 +1719,21 @@ static void ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1693 return; 1719 return;
1694 } 1720 }
1695 1721
1696 /* 1722 /* Check that the command byte is correct */
1697 * Chip might still be in STATE_DATAOUT 1723 if (check_command(byte)) {
1698 * (if OPT_AUTOINCR feature is supported), STATE_DATAOUT_STATUS or 1724 NS_ERR("write_byte: unknown command %#x\n", (uint)byte);
1699 * STATE_DATAOUT_STATUS_M state. If so, switch state. 1725 return;
1700 */ 1726 }
1727
1701 if (NS_STATE(ns->state) == STATE_DATAOUT_STATUS 1728 if (NS_STATE(ns->state) == STATE_DATAOUT_STATUS
1702 || NS_STATE(ns->state) == STATE_DATAOUT_STATUS_M 1729 || NS_STATE(ns->state) == STATE_DATAOUT_STATUS_M
1703 || ((ns->options & OPT_AUTOINCR) && NS_STATE(ns->state) == STATE_DATAOUT)) 1730 || NS_STATE(ns->state) == STATE_DATAOUT) {
1731 int row = ns->regs.row;
1732
1704 switch_state(ns); 1733 switch_state(ns);
1734 if (byte == NAND_CMD_RNDOUT)
1735 ns->regs.row = row;
1736 }
1705 1737
1706 /* Check if chip is expecting command */ 1738 /* Check if chip is expecting command */
1707 if (NS_STATE(ns->nxstate) != STATE_UNKNOWN && !(ns->nxstate & STATE_CMD_MASK)) { 1739 if (NS_STATE(ns->nxstate) != STATE_UNKNOWN && !(ns->nxstate & STATE_CMD_MASK)) {
@@ -1715,12 +1747,6 @@ static void ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1715 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); 1747 switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
1716 } 1748 }
1717 1749
1718 /* Check that the command byte is correct */
1719 if (check_command(byte)) {
1720 NS_ERR("write_byte: unknown command %#x\n", (uint)byte);
1721 return;
1722 }
1723
1724 NS_DBG("command byte corresponding to %s state accepted\n", 1750 NS_DBG("command byte corresponding to %s state accepted\n",
1725 get_state_name(get_state_by_command(byte))); 1751 get_state_name(get_state_by_command(byte)));
1726 ns->regs.command = byte; 1752 ns->regs.command = byte;
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index fa533c27052a..8a03875ec877 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -510,14 +510,14 @@ config STNIC
510config SH_ETH 510config SH_ETH
511 tristate "Renesas SuperH Ethernet support" 511 tristate "Renesas SuperH Ethernet support"
512 depends on SUPERH && \ 512 depends on SUPERH && \
513 (CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712) 513 (CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7763)
514 select CRC32 514 select CRC32
515 select MII 515 select MII
516 select MDIO_BITBANG 516 select MDIO_BITBANG
517 select PHYLIB 517 select PHYLIB
518 help 518 help
519 Renesas SuperH Ethernet device driver. 519 Renesas SuperH Ethernet device driver.
520 This driver support SH7710 and SH7712. 520 This driver support SH7710, SH7712 and SH7763.
521 521
522config SUNLANCE 522config SUNLANCE
523 tristate "Sun LANCE support" 523 tristate "Sun LANCE support"
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index a8ec60e1ed75..3db7db1828e7 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -605,36 +605,87 @@ adjust_head:
605static int bfin_mac_hard_start_xmit(struct sk_buff *skb, 605static int bfin_mac_hard_start_xmit(struct sk_buff *skb,
606 struct net_device *dev) 606 struct net_device *dev)
607{ 607{
608 unsigned int data; 608 u16 *data;
609 609
610 current_tx_ptr->skb = skb; 610 current_tx_ptr->skb = skb;
611 611
612 /* 612 if (ANOMALY_05000285) {
613 * Is skb->data always 16-bit aligned? 613 /*
614 * Do we need to memcpy((char *)(tail->packet + 2), skb->data, len)? 614 * TXDWA feature is not avaible to older revision < 0.3 silicon
615 */ 615 * of BF537
616 if ((((unsigned int)(skb->data)) & 0x02) == 2) { 616 *
617 /* move skb->data to current_tx_ptr payload */ 617 * Only if data buffer is ODD WORD alignment, we do not
618 data = (unsigned int)(skb->data) - 2; 618 * need to memcpy
619 *((unsigned short *)data) = (unsigned short)(skb->len); 619 */
620 current_tx_ptr->desc_a.start_addr = (unsigned long)data; 620 u32 data_align = (u32)(skb->data) & 0x3;
621 /* this is important! */ 621 if (data_align == 0x2) {
622 blackfin_dcache_flush_range(data, (data + (skb->len)) + 2); 622 /* move skb->data to current_tx_ptr payload */
623 623 data = (u16 *)(skb->data) - 1;
624 *data = (u16)(skb->len);
625 current_tx_ptr->desc_a.start_addr = (u32)data;
626 /* this is important! */
627 blackfin_dcache_flush_range((u32)data,
628 (u32)((u8 *)data + skb->len + 4));
629 } else {
630 *((u16 *)(current_tx_ptr->packet)) = (u16)(skb->len);
631 memcpy((u8 *)(current_tx_ptr->packet + 2), skb->data,
632 skb->len);
633 current_tx_ptr->desc_a.start_addr =
634 (u32)current_tx_ptr->packet;
635 if (current_tx_ptr->status.status_word != 0)
636 current_tx_ptr->status.status_word = 0;
637 blackfin_dcache_flush_range(
638 (u32)current_tx_ptr->packet,
639 (u32)(current_tx_ptr->packet + skb->len + 2));
640 }
624 } else { 641 } else {
625 *((unsigned short *)(current_tx_ptr->packet)) = 642 /*
626 (unsigned short)(skb->len); 643 * TXDWA feature is avaible to revision < 0.3 silicon of
627 memcpy((char *)(current_tx_ptr->packet + 2), skb->data, 644 * BF537 and always avaible to BF52x
628 (skb->len)); 645 */
629 current_tx_ptr->desc_a.start_addr = 646 u32 data_align = (u32)(skb->data) & 0x3;
630 (unsigned long)current_tx_ptr->packet; 647 if (data_align == 0x0) {
631 if (current_tx_ptr->status.status_word != 0) 648 u16 sysctl = bfin_read_EMAC_SYSCTL();
632 current_tx_ptr->status.status_word = 0; 649 sysctl |= TXDWA;
633 blackfin_dcache_flush_range((unsigned int)current_tx_ptr-> 650 bfin_write_EMAC_SYSCTL(sysctl);
634 packet, 651
635 (unsigned int)(current_tx_ptr-> 652 /* move skb->data to current_tx_ptr payload */
636 packet + skb->len) + 653 data = (u16 *)(skb->data) - 2;
637 2); 654 *data = (u16)(skb->len);
655 current_tx_ptr->desc_a.start_addr = (u32)data;
656 /* this is important! */
657 blackfin_dcache_flush_range(
658 (u32)data,
659 (u32)((u8 *)data + skb->len + 4));
660 } else if (data_align == 0x2) {
661 u16 sysctl = bfin_read_EMAC_SYSCTL();
662 sysctl &= ~TXDWA;
663 bfin_write_EMAC_SYSCTL(sysctl);
664
665 /* move skb->data to current_tx_ptr payload */
666 data = (u16 *)(skb->data) - 1;
667 *data = (u16)(skb->len);
668 current_tx_ptr->desc_a.start_addr = (u32)data;
669 /* this is important! */
670 blackfin_dcache_flush_range(
671 (u32)data,
672 (u32)((u8 *)data + skb->len + 4));
673 } else {
674 u16 sysctl = bfin_read_EMAC_SYSCTL();
675 sysctl &= ~TXDWA;
676 bfin_write_EMAC_SYSCTL(sysctl);
677
678 *((u16 *)(current_tx_ptr->packet)) = (u16)(skb->len);
679 memcpy((u8 *)(current_tx_ptr->packet + 2), skb->data,
680 skb->len);
681 current_tx_ptr->desc_a.start_addr =
682 (u32)current_tx_ptr->packet;
683 if (current_tx_ptr->status.status_word != 0)
684 current_tx_ptr->status.status_word = 0;
685 blackfin_dcache_flush_range(
686 (u32)current_tx_ptr->packet,
687 (u32)(current_tx_ptr->packet + skb->len + 2));
688 }
638 } 689 }
639 690
640 /* enable this packet's dma */ 691 /* enable this packet's dma */
@@ -691,7 +742,6 @@ static void bfin_mac_rx(struct net_device *dev)
691 (unsigned long)skb->tail); 742 (unsigned long)skb->tail);
692 743
693 dev->last_rx = jiffies; 744 dev->last_rx = jiffies;
694 skb->dev = dev;
695 skb->protocol = eth_type_trans(skb, dev); 745 skb->protocol = eth_type_trans(skb, dev);
696#if defined(BFIN_MAC_CSUM_OFFLOAD) 746#if defined(BFIN_MAC_CSUM_OFFLOAD)
697 skb->csum = current_rx_ptr->status.ip_payload_csum; 747 skb->csum = current_rx_ptr->status.ip_payload_csum;
@@ -920,6 +970,7 @@ static int bfin_mac_open(struct net_device *dev)
920 phy_start(lp->phydev); 970 phy_start(lp->phydev);
921 phy_write(lp->phydev, MII_BMCR, BMCR_RESET); 971 phy_write(lp->phydev, MII_BMCR, BMCR_RESET);
922 setup_system_regs(dev); 972 setup_system_regs(dev);
973 setup_mac_addr(dev->dev_addr);
923 bfin_mac_disable(); 974 bfin_mac_disable();
924 bfin_mac_enable(); 975 bfin_mac_enable();
925 pr_debug("hardware init finished\n"); 976 pr_debug("hardware init finished\n");
@@ -955,7 +1006,7 @@ static int bfin_mac_close(struct net_device *dev)
955 return 0; 1006 return 0;
956} 1007}
957 1008
958static int __init bfin_mac_probe(struct platform_device *pdev) 1009static int __devinit bfin_mac_probe(struct platform_device *pdev)
959{ 1010{
960 struct net_device *ndev; 1011 struct net_device *ndev;
961 struct bfin_mac_local *lp; 1012 struct bfin_mac_local *lp;
@@ -1081,7 +1132,7 @@ out_err_probe_mac:
1081 return rc; 1132 return rc;
1082} 1133}
1083 1134
1084static int bfin_mac_remove(struct platform_device *pdev) 1135static int __devexit bfin_mac_remove(struct platform_device *pdev)
1085{ 1136{
1086 struct net_device *ndev = platform_get_drvdata(pdev); 1137 struct net_device *ndev = platform_get_drvdata(pdev);
1087 struct bfin_mac_local *lp = netdev_priv(ndev); 1138 struct bfin_mac_local *lp = netdev_priv(ndev);
@@ -1128,7 +1179,7 @@ static int bfin_mac_resume(struct platform_device *pdev)
1128 1179
1129static struct platform_driver bfin_mac_driver = { 1180static struct platform_driver bfin_mac_driver = {
1130 .probe = bfin_mac_probe, 1181 .probe = bfin_mac_probe,
1131 .remove = bfin_mac_remove, 1182 .remove = __devexit_p(bfin_mac_remove),
1132 .resume = bfin_mac_resume, 1183 .resume = bfin_mac_resume,
1133 .suspend = bfin_mac_suspend, 1184 .suspend = bfin_mac_suspend,
1134 .driver = { 1185 .driver = {
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index 47d51788a462..04c0e90119af 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -683,7 +683,7 @@ enum {
683 SF_ERASE_SECTOR = 0xd8, /* erase sector */ 683 SF_ERASE_SECTOR = 0xd8, /* erase sector */
684 684
685 FW_FLASH_BOOT_ADDR = 0x70000, /* start address of FW in flash */ 685 FW_FLASH_BOOT_ADDR = 0x70000, /* start address of FW in flash */
686 FW_VERS_ADDR = 0x77ffc, /* flash address holding FW version */ 686 FW_VERS_ADDR = 0x7fffc, /* flash address holding FW version */
687 FW_MIN_SIZE = 8 /* at least version and csum */ 687 FW_MIN_SIZE = 8 /* at least version and csum */
688}; 688};
689 689
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 0920b796bd78..b70c5314f537 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -2937,9 +2937,9 @@ static void ehea_rereg_mrs(struct work_struct *work)
2937 } 2937 }
2938 } 2938 }
2939 } 2939 }
2940 mutex_unlock(&dlpar_mem_lock); 2940 ehea_info("re-initializing driver complete");
2941 ehea_info("re-initializing driver complete");
2942out: 2941out:
2942 mutex_unlock(&dlpar_mem_lock);
2943 return; 2943 return;
2944} 2944}
2945 2945
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index c05cb159c772..aa0bf6e1c694 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -1547,8 +1547,10 @@ static int __devinit enc28j60_probe(struct spi_device *spi)
1547 random_ether_addr(dev->dev_addr); 1547 random_ether_addr(dev->dev_addr);
1548 enc28j60_set_hw_macaddr(dev); 1548 enc28j60_set_hw_macaddr(dev);
1549 1549
1550 ret = request_irq(spi->irq, enc28j60_irq, IRQF_TRIGGER_FALLING, 1550 /* Board setup must set the relevant edge trigger type;
1551 DRV_NAME, priv); 1551 * level triggers won't currently work.
1552 */
1553 ret = request_irq(spi->irq, enc28j60_irq, 0, DRV_NAME, priv);
1552 if (ret < 0) { 1554 if (ret < 0) {
1553 if (netif_msg_probe(priv)) 1555 if (netif_msg_probe(priv))
1554 dev_err(&spi->dev, DRV_NAME ": request irq %d failed " 1556 dev_err(&spi->dev, DRV_NAME ": request irq %d failed "
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 4ed89fa9ae46..01b38b092c76 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -333,6 +333,7 @@ enum {
333 NvRegPowerState2 = 0x600, 333 NvRegPowerState2 = 0x600,
334#define NVREG_POWERSTATE2_POWERUP_MASK 0x0F11 334#define NVREG_POWERSTATE2_POWERUP_MASK 0x0F11
335#define NVREG_POWERSTATE2_POWERUP_REV_A3 0x0001 335#define NVREG_POWERSTATE2_POWERUP_REV_A3 0x0001
336#define NVREG_POWERSTATE2_PHY_RESET 0x0004
336}; 337};
337 338
338/* Big endian: should work, but is untested */ 339/* Big endian: should work, but is untested */
@@ -529,6 +530,7 @@ union ring_type {
529#define PHY_REALTEK_INIT_REG4 0x14 530#define PHY_REALTEK_INIT_REG4 0x14
530#define PHY_REALTEK_INIT_REG5 0x18 531#define PHY_REALTEK_INIT_REG5 0x18
531#define PHY_REALTEK_INIT_REG6 0x11 532#define PHY_REALTEK_INIT_REG6 0x11
533#define PHY_REALTEK_INIT_REG7 0x01
532#define PHY_REALTEK_INIT1 0x0000 534#define PHY_REALTEK_INIT1 0x0000
533#define PHY_REALTEK_INIT2 0x8e00 535#define PHY_REALTEK_INIT2 0x8e00
534#define PHY_REALTEK_INIT3 0x0001 536#define PHY_REALTEK_INIT3 0x0001
@@ -537,6 +539,9 @@ union ring_type {
537#define PHY_REALTEK_INIT6 0xf5c7 539#define PHY_REALTEK_INIT6 0xf5c7
538#define PHY_REALTEK_INIT7 0x1000 540#define PHY_REALTEK_INIT7 0x1000
539#define PHY_REALTEK_INIT8 0x0003 541#define PHY_REALTEK_INIT8 0x0003
542#define PHY_REALTEK_INIT9 0x0008
543#define PHY_REALTEK_INIT10 0x0005
544#define PHY_REALTEK_INIT11 0x0200
540#define PHY_REALTEK_INIT_MSK1 0x0003 545#define PHY_REALTEK_INIT_MSK1 0x0003
541 546
542#define PHY_GIGABIT 0x0100 547#define PHY_GIGABIT 0x0100
@@ -1149,6 +1154,42 @@ static int phy_init(struct net_device *dev)
1149 return PHY_ERROR; 1154 return PHY_ERROR;
1150 } 1155 }
1151 } 1156 }
1157 if (np->phy_model == PHY_MODEL_REALTEK_8211 &&
1158 np->phy_rev == PHY_REV_REALTEK_8211C) {
1159 u32 powerstate = readl(base + NvRegPowerState2);
1160
1161 /* need to perform hw phy reset */
1162 powerstate |= NVREG_POWERSTATE2_PHY_RESET;
1163 writel(powerstate, base + NvRegPowerState2);
1164 msleep(25);
1165
1166 powerstate &= ~NVREG_POWERSTATE2_PHY_RESET;
1167 writel(powerstate, base + NvRegPowerState2);
1168 msleep(25);
1169
1170 reg = mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG6, MII_READ);
1171 reg |= PHY_REALTEK_INIT9;
1172 if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG6, reg)) {
1173 printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
1174 return PHY_ERROR;
1175 }
1176 if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT10)) {
1177 printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
1178 return PHY_ERROR;
1179 }
1180 reg = mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG7, MII_READ);
1181 if (!(reg & PHY_REALTEK_INIT11)) {
1182 reg |= PHY_REALTEK_INIT11;
1183 if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG7, reg)) {
1184 printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
1185 return PHY_ERROR;
1186 }
1187 }
1188 if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT1)) {
1189 printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
1190 return PHY_ERROR;
1191 }
1192 }
1152 if (np->phy_model == PHY_MODEL_REALTEK_8201) { 1193 if (np->phy_model == PHY_MODEL_REALTEK_8201) {
1153 if (np->device_id == PCI_DEVICE_ID_NVIDIA_NVENET_32 || 1194 if (np->device_id == PCI_DEVICE_ID_NVIDIA_NVENET_32 ||
1154 np->device_id == PCI_DEVICE_ID_NVIDIA_NVENET_33 || 1195 np->device_id == PCI_DEVICE_ID_NVIDIA_NVENET_33 ||
@@ -1201,12 +1242,23 @@ static int phy_init(struct net_device *dev)
1201 mii_control = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); 1242 mii_control = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
1202 mii_control |= BMCR_ANENABLE; 1243 mii_control |= BMCR_ANENABLE;
1203 1244
1204 /* reset the phy 1245 if (np->phy_oui == PHY_OUI_REALTEK &&
1205 * (certain phys need bmcr to be setup with reset) 1246 np->phy_model == PHY_MODEL_REALTEK_8211 &&
1206 */ 1247 np->phy_rev == PHY_REV_REALTEK_8211C) {
1207 if (phy_reset(dev, mii_control)) { 1248 /* start autoneg since we already performed hw reset above */
1208 printk(KERN_INFO "%s: phy reset failed\n", pci_name(np->pci_dev)); 1249 mii_control |= BMCR_ANRESTART;
1209 return PHY_ERROR; 1250 if (mii_rw(dev, np->phyaddr, MII_BMCR, mii_control)) {
1251 printk(KERN_INFO "%s: phy init failed\n", pci_name(np->pci_dev));
1252 return PHY_ERROR;
1253 }
1254 } else {
1255 /* reset the phy
1256 * (certain phys need bmcr to be setup with reset)
1257 */
1258 if (phy_reset(dev, mii_control)) {
1259 printk(KERN_INFO "%s: phy reset failed\n", pci_name(np->pci_dev));
1260 return PHY_ERROR;
1261 }
1210 } 1262 }
1211 1263
1212 /* phy vendor specific configuration */ 1264 /* phy vendor specific configuration */
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 0960e69b2da4..e4fbefc8c82f 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -69,18 +69,20 @@ static void ri_tasklet(unsigned long dev)
69 struct net_device *_dev = (struct net_device *)dev; 69 struct net_device *_dev = (struct net_device *)dev;
70 struct ifb_private *dp = netdev_priv(_dev); 70 struct ifb_private *dp = netdev_priv(_dev);
71 struct net_device_stats *stats = &_dev->stats; 71 struct net_device_stats *stats = &_dev->stats;
72 struct netdev_queue *txq;
72 struct sk_buff *skb; 73 struct sk_buff *skb;
73 74
75 txq = netdev_get_tx_queue(_dev, 0);
74 dp->st_task_enter++; 76 dp->st_task_enter++;
75 if ((skb = skb_peek(&dp->tq)) == NULL) { 77 if ((skb = skb_peek(&dp->tq)) == NULL) {
76 dp->st_txq_refl_try++; 78 dp->st_txq_refl_try++;
77 if (netif_tx_trylock(_dev)) { 79 if (__netif_tx_trylock(txq)) {
78 dp->st_rxq_enter++; 80 dp->st_rxq_enter++;
79 while ((skb = skb_dequeue(&dp->rq)) != NULL) { 81 while ((skb = skb_dequeue(&dp->rq)) != NULL) {
80 skb_queue_tail(&dp->tq, skb); 82 skb_queue_tail(&dp->tq, skb);
81 dp->st_rx2tx_tran++; 83 dp->st_rx2tx_tran++;
82 } 84 }
83 netif_tx_unlock(_dev); 85 __netif_tx_unlock(txq);
84 } else { 86 } else {
85 /* reschedule */ 87 /* reschedule */
86 dp->st_rxq_notenter++; 88 dp->st_rxq_notenter++;
@@ -115,7 +117,7 @@ static void ri_tasklet(unsigned long dev)
115 BUG(); 117 BUG();
116 } 118 }
117 119
118 if (netif_tx_trylock(_dev)) { 120 if (__netif_tx_trylock(txq)) {
119 dp->st_rxq_check++; 121 dp->st_rxq_check++;
120 if ((skb = skb_peek(&dp->rq)) == NULL) { 122 if ((skb = skb_peek(&dp->rq)) == NULL) {
121 dp->tasklet_pending = 0; 123 dp->tasklet_pending = 0;
@@ -123,10 +125,10 @@ static void ri_tasklet(unsigned long dev)
123 netif_wake_queue(_dev); 125 netif_wake_queue(_dev);
124 } else { 126 } else {
125 dp->st_rxq_rsch++; 127 dp->st_rxq_rsch++;
126 netif_tx_unlock(_dev); 128 __netif_tx_unlock(txq);
127 goto resched; 129 goto resched;
128 } 130 }
129 netif_tx_unlock(_dev); 131 __netif_tx_unlock(txq);
130 } else { 132 } else {
131resched: 133resched:
132 dp->tasklet_pending = 1; 134 dp->tasklet_pending = 1;
diff --git a/drivers/net/irda/act200l-sir.c b/drivers/net/irda/act200l-sir.c
index d8b89c74aabd..37ab8c855719 100644
--- a/drivers/net/irda/act200l-sir.c
+++ b/drivers/net/irda/act200l-sir.c
@@ -107,7 +107,7 @@ static int act200l_open(struct sir_dev *dev)
107{ 107{
108 struct qos_info *qos = &dev->qos; 108 struct qos_info *qos = &dev->qos;
109 109
110 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 110 IRDA_DEBUG(2, "%s()\n", __func__ );
111 111
112 /* Power on the dongle */ 112 /* Power on the dongle */
113 sirdev_set_dtr_rts(dev, TRUE, TRUE); 113 sirdev_set_dtr_rts(dev, TRUE, TRUE);
@@ -124,7 +124,7 @@ static int act200l_open(struct sir_dev *dev)
124 124
125static int act200l_close(struct sir_dev *dev) 125static int act200l_close(struct sir_dev *dev)
126{ 126{
127 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 127 IRDA_DEBUG(2, "%s()\n", __func__ );
128 128
129 /* Power off the dongle */ 129 /* Power off the dongle */
130 sirdev_set_dtr_rts(dev, FALSE, FALSE); 130 sirdev_set_dtr_rts(dev, FALSE, FALSE);
@@ -143,7 +143,7 @@ static int act200l_change_speed(struct sir_dev *dev, unsigned speed)
143 u8 control[3]; 143 u8 control[3];
144 int ret = 0; 144 int ret = 0;
145 145
146 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 146 IRDA_DEBUG(2, "%s()\n", __func__ );
147 147
148 /* Clear DTR and set RTS to enter command mode */ 148 /* Clear DTR and set RTS to enter command mode */
149 sirdev_set_dtr_rts(dev, FALSE, TRUE); 149 sirdev_set_dtr_rts(dev, FALSE, TRUE);
@@ -212,7 +212,7 @@ static int act200l_reset(struct sir_dev *dev)
212 }; 212 };
213 int ret = 0; 213 int ret = 0;
214 214
215 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 215 IRDA_DEBUG(2, "%s()\n", __func__ );
216 216
217 switch (state) { 217 switch (state) {
218 case SIRDEV_STATE_DONGLE_RESET: 218 case SIRDEV_STATE_DONGLE_RESET:
@@ -240,7 +240,7 @@ static int act200l_reset(struct sir_dev *dev)
240 dev->speed = 9600; 240 dev->speed = 9600;
241 break; 241 break;
242 default: 242 default:
243 IRDA_ERROR("%s(), unknown state %d\n", __FUNCTION__, state); 243 IRDA_ERROR("%s(), unknown state %d\n", __func__, state);
244 ret = -1; 244 ret = -1;
245 break; 245 break;
246 } 246 }
diff --git a/drivers/net/irda/actisys-sir.c b/drivers/net/irda/actisys-sir.c
index 736d2473b7e1..50b2141a6103 100644
--- a/drivers/net/irda/actisys-sir.c
+++ b/drivers/net/irda/actisys-sir.c
@@ -165,7 +165,7 @@ static int actisys_change_speed(struct sir_dev *dev, unsigned speed)
165 int ret = 0; 165 int ret = 0;
166 int i = 0; 166 int i = 0;
167 167
168 IRDA_DEBUG(4, "%s(), speed=%d (was %d)\n", __FUNCTION__, 168 IRDA_DEBUG(4, "%s(), speed=%d (was %d)\n", __func__,
169 speed, dev->speed); 169 speed, dev->speed);
170 170
171 /* dongle was already resetted from irda_request state machine, 171 /* dongle was already resetted from irda_request state machine,
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 083b0dd70fef..2ff181861d2d 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -152,7 +152,7 @@ static int __init ali_ircc_init(void)
152 int reg, revision; 152 int reg, revision;
153 int i = 0; 153 int i = 0;
154 154
155 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 155 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
156 156
157 ret = platform_driver_register(&ali_ircc_driver); 157 ret = platform_driver_register(&ali_ircc_driver);
158 if (ret) { 158 if (ret) {
@@ -166,7 +166,7 @@ static int __init ali_ircc_init(void)
166 /* Probe for all the ALi chipsets we know about */ 166 /* Probe for all the ALi chipsets we know about */
167 for (chip= chips; chip->name; chip++, i++) 167 for (chip= chips; chip->name; chip++, i++)
168 { 168 {
169 IRDA_DEBUG(2, "%s(), Probing for %s ...\n", __FUNCTION__, chip->name); 169 IRDA_DEBUG(2, "%s(), Probing for %s ...\n", __func__, chip->name);
170 170
171 /* Try all config registers for this chip */ 171 /* Try all config registers for this chip */
172 for (cfg=0; cfg<2; cfg++) 172 for (cfg=0; cfg<2; cfg++)
@@ -196,11 +196,11 @@ static int __init ali_ircc_init(void)
196 196
197 if (reg == chip->cid_value) 197 if (reg == chip->cid_value)
198 { 198 {
199 IRDA_DEBUG(2, "%s(), Chip found at 0x%03x\n", __FUNCTION__, cfg_base); 199 IRDA_DEBUG(2, "%s(), Chip found at 0x%03x\n", __func__, cfg_base);
200 200
201 outb(0x1F, cfg_base); 201 outb(0x1F, cfg_base);
202 revision = inb(cfg_base+1); 202 revision = inb(cfg_base+1);
203 IRDA_DEBUG(2, "%s(), Found %s chip, revision=%d\n", __FUNCTION__, 203 IRDA_DEBUG(2, "%s(), Found %s chip, revision=%d\n", __func__,
204 chip->name, revision); 204 chip->name, revision);
205 205
206 /* 206 /*
@@ -223,14 +223,14 @@ static int __init ali_ircc_init(void)
223 } 223 }
224 else 224 else
225 { 225 {
226 IRDA_DEBUG(2, "%s(), No %s chip at 0x%03x\n", __FUNCTION__, chip->name, cfg_base); 226 IRDA_DEBUG(2, "%s(), No %s chip at 0x%03x\n", __func__, chip->name, cfg_base);
227 } 227 }
228 /* Exit configuration */ 228 /* Exit configuration */
229 outb(0xbb, cfg_base); 229 outb(0xbb, cfg_base);
230 } 230 }
231 } 231 }
232 232
233 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 233 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
234 234
235 if (ret) 235 if (ret)
236 platform_driver_unregister(&ali_ircc_driver); 236 platform_driver_unregister(&ali_ircc_driver);
@@ -248,7 +248,7 @@ static void __exit ali_ircc_cleanup(void)
248{ 248{
249 int i; 249 int i;
250 250
251 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 251 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
252 252
253 for (i=0; i < ARRAY_SIZE(dev_self); i++) { 253 for (i=0; i < ARRAY_SIZE(dev_self); i++) {
254 if (dev_self[i]) 254 if (dev_self[i])
@@ -257,7 +257,7 @@ static void __exit ali_ircc_cleanup(void)
257 257
258 platform_driver_unregister(&ali_ircc_driver); 258 platform_driver_unregister(&ali_ircc_driver);
259 259
260 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 260 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
261} 261}
262 262
263/* 263/*
@@ -273,11 +273,11 @@ static int ali_ircc_open(int i, chipio_t *info)
273 int dongle_id; 273 int dongle_id;
274 int err; 274 int err;
275 275
276 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 276 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
277 277
278 if (i >= ARRAY_SIZE(dev_self)) { 278 if (i >= ARRAY_SIZE(dev_self)) {
279 IRDA_ERROR("%s(), maximum number of supported chips reached!\n", 279 IRDA_ERROR("%s(), maximum number of supported chips reached!\n",
280 __FUNCTION__); 280 __func__);
281 return -ENOMEM; 281 return -ENOMEM;
282 } 282 }
283 283
@@ -288,7 +288,7 @@ static int ali_ircc_open(int i, chipio_t *info)
288 dev = alloc_irdadev(sizeof(*self)); 288 dev = alloc_irdadev(sizeof(*self));
289 if (dev == NULL) { 289 if (dev == NULL) {
290 IRDA_ERROR("%s(), can't allocate memory for control block!\n", 290 IRDA_ERROR("%s(), can't allocate memory for control block!\n",
291 __FUNCTION__); 291 __func__);
292 return -ENOMEM; 292 return -ENOMEM;
293 } 293 }
294 294
@@ -312,7 +312,7 @@ static int ali_ircc_open(int i, chipio_t *info)
312 /* Reserve the ioports that we need */ 312 /* Reserve the ioports that we need */
313 if (!request_region(self->io.fir_base, self->io.fir_ext, 313 if (!request_region(self->io.fir_base, self->io.fir_ext,
314 ALI_IRCC_DRIVER_NAME)) { 314 ALI_IRCC_DRIVER_NAME)) {
315 IRDA_WARNING("%s(), can't get iobase of 0x%03x\n", __FUNCTION__, 315 IRDA_WARNING("%s(), can't get iobase of 0x%03x\n", __func__,
316 self->io.fir_base); 316 self->io.fir_base);
317 err = -ENODEV; 317 err = -ENODEV;
318 goto err_out1; 318 goto err_out1;
@@ -370,19 +370,19 @@ static int ali_ircc_open(int i, chipio_t *info)
370 370
371 err = register_netdev(dev); 371 err = register_netdev(dev);
372 if (err) { 372 if (err) {
373 IRDA_ERROR("%s(), register_netdev() failed!\n", __FUNCTION__); 373 IRDA_ERROR("%s(), register_netdev() failed!\n", __func__);
374 goto err_out4; 374 goto err_out4;
375 } 375 }
376 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name); 376 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
377 377
378 /* Check dongle id */ 378 /* Check dongle id */
379 dongle_id = ali_ircc_read_dongle_id(i, info); 379 dongle_id = ali_ircc_read_dongle_id(i, info);
380 IRDA_MESSAGE("%s(), %s, Found dongle: %s\n", __FUNCTION__, 380 IRDA_MESSAGE("%s(), %s, Found dongle: %s\n", __func__,
381 ALI_IRCC_DRIVER_NAME, dongle_types[dongle_id]); 381 ALI_IRCC_DRIVER_NAME, dongle_types[dongle_id]);
382 382
383 self->io.dongle_id = dongle_id; 383 self->io.dongle_id = dongle_id;
384 384
385 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 385 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
386 386
387 return 0; 387 return 0;
388 388
@@ -411,7 +411,7 @@ static int __exit ali_ircc_close(struct ali_ircc_cb *self)
411{ 411{
412 int iobase; 412 int iobase;
413 413
414 IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 414 IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __func__);
415 415
416 IRDA_ASSERT(self != NULL, return -1;); 416 IRDA_ASSERT(self != NULL, return -1;);
417 417
@@ -421,7 +421,7 @@ static int __exit ali_ircc_close(struct ali_ircc_cb *self)
421 unregister_netdev(self->netdev); 421 unregister_netdev(self->netdev);
422 422
423 /* Release the PORT that this driver is using */ 423 /* Release the PORT that this driver is using */
424 IRDA_DEBUG(4, "%s(), Releasing Region %03x\n", __FUNCTION__, self->io.fir_base); 424 IRDA_DEBUG(4, "%s(), Releasing Region %03x\n", __func__, self->io.fir_base);
425 release_region(self->io.fir_base, self->io.fir_ext); 425 release_region(self->io.fir_base, self->io.fir_ext);
426 426
427 if (self->tx_buff.head) 427 if (self->tx_buff.head)
@@ -435,7 +435,7 @@ static int __exit ali_ircc_close(struct ali_ircc_cb *self)
435 dev_self[self->index] = NULL; 435 dev_self[self->index] = NULL;
436 free_netdev(self->netdev); 436 free_netdev(self->netdev);
437 437
438 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 438 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
439 439
440 return 0; 440 return 0;
441} 441}
@@ -478,7 +478,7 @@ static int ali_ircc_probe_53(ali_chip_t *chip, chipio_t *info)
478 int cfg_base = info->cfg_base; 478 int cfg_base = info->cfg_base;
479 int hi, low, reg; 479 int hi, low, reg;
480 480
481 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 481 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
482 482
483 /* Enter Configuration */ 483 /* Enter Configuration */
484 outb(chip->entr1, cfg_base); 484 outb(chip->entr1, cfg_base);
@@ -497,13 +497,13 @@ static int ali_ircc_probe_53(ali_chip_t *chip, chipio_t *info)
497 497
498 info->sir_base = info->fir_base; 498 info->sir_base = info->fir_base;
499 499
500 IRDA_DEBUG(2, "%s(), probing fir_base=0x%03x\n", __FUNCTION__, info->fir_base); 500 IRDA_DEBUG(2, "%s(), probing fir_base=0x%03x\n", __func__, info->fir_base);
501 501
502 /* Read IRQ control register */ 502 /* Read IRQ control register */
503 outb(0x70, cfg_base); 503 outb(0x70, cfg_base);
504 reg = inb(cfg_base+1); 504 reg = inb(cfg_base+1);
505 info->irq = reg & 0x0f; 505 info->irq = reg & 0x0f;
506 IRDA_DEBUG(2, "%s(), probing irq=%d\n", __FUNCTION__, info->irq); 506 IRDA_DEBUG(2, "%s(), probing irq=%d\n", __func__, info->irq);
507 507
508 /* Read DMA channel */ 508 /* Read DMA channel */
509 outb(0x74, cfg_base); 509 outb(0x74, cfg_base);
@@ -511,26 +511,26 @@ static int ali_ircc_probe_53(ali_chip_t *chip, chipio_t *info)
511 info->dma = reg & 0x07; 511 info->dma = reg & 0x07;
512 512
513 if(info->dma == 0x04) 513 if(info->dma == 0x04)
514 IRDA_WARNING("%s(), No DMA channel assigned !\n", __FUNCTION__); 514 IRDA_WARNING("%s(), No DMA channel assigned !\n", __func__);
515 else 515 else
516 IRDA_DEBUG(2, "%s(), probing dma=%d\n", __FUNCTION__, info->dma); 516 IRDA_DEBUG(2, "%s(), probing dma=%d\n", __func__, info->dma);
517 517
518 /* Read Enabled Status */ 518 /* Read Enabled Status */
519 outb(0x30, cfg_base); 519 outb(0x30, cfg_base);
520 reg = inb(cfg_base+1); 520 reg = inb(cfg_base+1);
521 info->enabled = (reg & 0x80) && (reg & 0x01); 521 info->enabled = (reg & 0x80) && (reg & 0x01);
522 IRDA_DEBUG(2, "%s(), probing enabled=%d\n", __FUNCTION__, info->enabled); 522 IRDA_DEBUG(2, "%s(), probing enabled=%d\n", __func__, info->enabled);
523 523
524 /* Read Power Status */ 524 /* Read Power Status */
525 outb(0x22, cfg_base); 525 outb(0x22, cfg_base);
526 reg = inb(cfg_base+1); 526 reg = inb(cfg_base+1);
527 info->suspended = (reg & 0x20); 527 info->suspended = (reg & 0x20);
528 IRDA_DEBUG(2, "%s(), probing suspended=%d\n", __FUNCTION__, info->suspended); 528 IRDA_DEBUG(2, "%s(), probing suspended=%d\n", __func__, info->suspended);
529 529
530 /* Exit configuration */ 530 /* Exit configuration */
531 outb(0xbb, cfg_base); 531 outb(0xbb, cfg_base);
532 532
533 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 533 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __func__);
534 534
535 return 0; 535 return 0;
536} 536}
@@ -548,7 +548,7 @@ static int ali_ircc_setup(chipio_t *info)
548 int version; 548 int version;
549 int iobase = info->fir_base; 549 int iobase = info->fir_base;
550 550
551 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 551 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
552 552
553 /* Locking comments : 553 /* Locking comments :
554 * Most operations here need to be protected. We are called before 554 * Most operations here need to be protected. We are called before
@@ -609,7 +609,7 @@ static int ali_ircc_setup(chipio_t *info)
609 // outb(UART_IER_RDI, iobase+UART_IER); //benjamin 2000/11/23 01:25PM 609 // outb(UART_IER_RDI, iobase+UART_IER); //benjamin 2000/11/23 01:25PM
610 // Turn on the interrupts in ali_ircc_net_open 610 // Turn on the interrupts in ali_ircc_net_open
611 611
612 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__); 612 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
613 613
614 return 0; 614 return 0;
615} 615}
@@ -626,7 +626,7 @@ static int ali_ircc_read_dongle_id (int i, chipio_t *info)
626 int dongle_id, reg; 626 int dongle_id, reg;
627 int cfg_base = info->cfg_base; 627 int cfg_base = info->cfg_base;
628 628
629 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 629 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
630 630
631 /* Enter Configuration */ 631 /* Enter Configuration */
632 outb(chips[i].entr1, cfg_base); 632 outb(chips[i].entr1, cfg_base);
@@ -640,13 +640,13 @@ static int ali_ircc_read_dongle_id (int i, chipio_t *info)
640 outb(0xf0, cfg_base); 640 outb(0xf0, cfg_base);
641 reg = inb(cfg_base+1); 641 reg = inb(cfg_base+1);
642 dongle_id = ((reg>>6)&0x02) | ((reg>>5)&0x01); 642 dongle_id = ((reg>>6)&0x02) | ((reg>>5)&0x01);
643 IRDA_DEBUG(2, "%s(), probing dongle_id=%d, dongle_types=%s\n", __FUNCTION__, 643 IRDA_DEBUG(2, "%s(), probing dongle_id=%d, dongle_types=%s\n", __func__,
644 dongle_id, dongle_types[dongle_id]); 644 dongle_id, dongle_types[dongle_id]);
645 645
646 /* Exit configuration */ 646 /* Exit configuration */
647 outb(0xbb, cfg_base); 647 outb(0xbb, cfg_base);
648 648
649 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__); 649 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
650 650
651 return dongle_id; 651 return dongle_id;
652} 652}
@@ -663,7 +663,7 @@ static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id)
663 struct ali_ircc_cb *self; 663 struct ali_ircc_cb *self;
664 int ret; 664 int ret;
665 665
666 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 666 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
667 667
668 self = dev->priv; 668 self = dev->priv;
669 669
@@ -677,7 +677,7 @@ static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id)
677 677
678 spin_unlock(&self->lock); 678 spin_unlock(&self->lock);
679 679
680 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__); 680 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
681 return ret; 681 return ret;
682} 682}
683/* 683/*
@@ -691,7 +691,7 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
691 __u8 eir, OldMessageCount; 691 __u8 eir, OldMessageCount;
692 int iobase, tmp; 692 int iobase, tmp;
693 693
694 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 694 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__);
695 695
696 iobase = self->io.fir_base; 696 iobase = self->io.fir_base;
697 697
@@ -704,10 +704,10 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
704 //self->ier = inb(iobase+FIR_IER); 2000/12/1 04:32PM 704 //self->ier = inb(iobase+FIR_IER); 2000/12/1 04:32PM
705 eir = self->InterruptID & self->ier; /* Mask out the interesting ones */ 705 eir = self->InterruptID & self->ier; /* Mask out the interesting ones */
706 706
707 IRDA_DEBUG(1, "%s(), self->InterruptID = %x\n", __FUNCTION__,self->InterruptID); 707 IRDA_DEBUG(1, "%s(), self->InterruptID = %x\n", __func__,self->InterruptID);
708 IRDA_DEBUG(1, "%s(), self->LineStatus = %x\n", __FUNCTION__,self->LineStatus); 708 IRDA_DEBUG(1, "%s(), self->LineStatus = %x\n", __func__,self->LineStatus);
709 IRDA_DEBUG(1, "%s(), self->ier = %x\n", __FUNCTION__,self->ier); 709 IRDA_DEBUG(1, "%s(), self->ier = %x\n", __func__,self->ier);
710 IRDA_DEBUG(1, "%s(), eir = %x\n", __FUNCTION__,eir); 710 IRDA_DEBUG(1, "%s(), eir = %x\n", __func__,eir);
711 711
712 /* Disable interrupts */ 712 /* Disable interrupts */
713 SetCOMInterrupts(self, FALSE); 713 SetCOMInterrupts(self, FALSE);
@@ -718,7 +718,7 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
718 { 718 {
719 if (self->io.direction == IO_XMIT) /* TX */ 719 if (self->io.direction == IO_XMIT) /* TX */
720 { 720 {
721 IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Tx) *******\n", __FUNCTION__); 721 IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Tx) *******\n", __func__);
722 722
723 if(ali_ircc_dma_xmit_complete(self)) 723 if(ali_ircc_dma_xmit_complete(self))
724 { 724 {
@@ -737,23 +737,23 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
737 } 737 }
738 else /* RX */ 738 else /* RX */
739 { 739 {
740 IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Rx) *******\n", __FUNCTION__); 740 IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Rx) *******\n", __func__);
741 741
742 if(OldMessageCount > ((self->LineStatus+1) & 0x07)) 742 if(OldMessageCount > ((self->LineStatus+1) & 0x07))
743 { 743 {
744 self->rcvFramesOverflow = TRUE; 744 self->rcvFramesOverflow = TRUE;
745 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******** \n", __FUNCTION__); 745 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******** \n", __func__);
746 } 746 }
747 747
748 if (ali_ircc_dma_receive_complete(self)) 748 if (ali_ircc_dma_receive_complete(self))
749 { 749 {
750 IRDA_DEBUG(1, "%s(), ******* receive complete ******** \n", __FUNCTION__); 750 IRDA_DEBUG(1, "%s(), ******* receive complete ******** \n", __func__);
751 751
752 self->ier = IER_EOM; 752 self->ier = IER_EOM;
753 } 753 }
754 else 754 else
755 { 755 {
756 IRDA_DEBUG(1, "%s(), ******* Not receive complete ******** \n", __FUNCTION__); 756 IRDA_DEBUG(1, "%s(), ******* Not receive complete ******** \n", __func__);
757 757
758 self->ier = IER_EOM | IER_TIMER; 758 self->ier = IER_EOM | IER_TIMER;
759 } 759 }
@@ -766,7 +766,7 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
766 if(OldMessageCount > ((self->LineStatus+1) & 0x07)) 766 if(OldMessageCount > ((self->LineStatus+1) & 0x07))
767 { 767 {
768 self->rcvFramesOverflow = TRUE; 768 self->rcvFramesOverflow = TRUE;
769 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******* \n", __FUNCTION__); 769 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******* \n", __func__);
770 } 770 }
771 /* Disable Timer */ 771 /* Disable Timer */
772 switch_bank(iobase, BANK1); 772 switch_bank(iobase, BANK1);
@@ -798,7 +798,7 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
798 /* Restore Interrupt */ 798 /* Restore Interrupt */
799 SetCOMInterrupts(self, TRUE); 799 SetCOMInterrupts(self, TRUE);
800 800
801 IRDA_DEBUG(1, "%s(), ----------------- End ---------------\n", __FUNCTION__); 801 IRDA_DEBUG(1, "%s(), ----------------- End ---------------\n", __func__);
802 return IRQ_RETVAL(eir); 802 return IRQ_RETVAL(eir);
803} 803}
804 804
@@ -813,7 +813,7 @@ static irqreturn_t ali_ircc_sir_interrupt(struct ali_ircc_cb *self)
813 int iobase; 813 int iobase;
814 int iir, lsr; 814 int iir, lsr;
815 815
816 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 816 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
817 817
818 iobase = self->io.sir_base; 818 iobase = self->io.sir_base;
819 819
@@ -822,13 +822,13 @@ static irqreturn_t ali_ircc_sir_interrupt(struct ali_ircc_cb *self)
822 /* Clear interrupt */ 822 /* Clear interrupt */
823 lsr = inb(iobase+UART_LSR); 823 lsr = inb(iobase+UART_LSR);
824 824
825 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n", __FUNCTION__, 825 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n", __func__,
826 iir, lsr, iobase); 826 iir, lsr, iobase);
827 827
828 switch (iir) 828 switch (iir)
829 { 829 {
830 case UART_IIR_RLSI: 830 case UART_IIR_RLSI:
831 IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__); 831 IRDA_DEBUG(2, "%s(), RLSI\n", __func__);
832 break; 832 break;
833 case UART_IIR_RDI: 833 case UART_IIR_RDI:
834 /* Receive interrupt */ 834 /* Receive interrupt */
@@ -842,14 +842,14 @@ static irqreturn_t ali_ircc_sir_interrupt(struct ali_ircc_cb *self)
842 } 842 }
843 break; 843 break;
844 default: 844 default:
845 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n", __FUNCTION__, iir); 845 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n", __func__, iir);
846 break; 846 break;
847 } 847 }
848 848
849 } 849 }
850 850
851 851
852 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__); 852 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__);
853 853
854 return IRQ_RETVAL(iir); 854 return IRQ_RETVAL(iir);
855} 855}
@@ -866,7 +866,7 @@ static void ali_ircc_sir_receive(struct ali_ircc_cb *self)
866 int boguscount = 0; 866 int boguscount = 0;
867 int iobase; 867 int iobase;
868 868
869 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 869 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__);
870 IRDA_ASSERT(self != NULL, return;); 870 IRDA_ASSERT(self != NULL, return;);
871 871
872 iobase = self->io.sir_base; 872 iobase = self->io.sir_base;
@@ -881,12 +881,12 @@ static void ali_ircc_sir_receive(struct ali_ircc_cb *self)
881 881
882 /* Make sure we don't stay here too long */ 882 /* Make sure we don't stay here too long */
883 if (boguscount++ > 32) { 883 if (boguscount++ > 32) {
884 IRDA_DEBUG(2,"%s(), breaking!\n", __FUNCTION__); 884 IRDA_DEBUG(2,"%s(), breaking!\n", __func__);
885 break; 885 break;
886 } 886 }
887 } while (inb(iobase+UART_LSR) & UART_LSR_DR); 887 } while (inb(iobase+UART_LSR) & UART_LSR_DR);
888 888
889 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 889 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
890} 890}
891 891
892/* 892/*
@@ -903,7 +903,7 @@ static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb *self)
903 903
904 IRDA_ASSERT(self != NULL, return;); 904 IRDA_ASSERT(self != NULL, return;);
905 905
906 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 906 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
907 907
908 iobase = self->io.sir_base; 908 iobase = self->io.sir_base;
909 909
@@ -922,16 +922,16 @@ static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb *self)
922 { 922 {
923 /* We must wait until all data are gone */ 923 /* We must wait until all data are gone */
924 while(!(inb(iobase+UART_LSR) & UART_LSR_TEMT)) 924 while(!(inb(iobase+UART_LSR) & UART_LSR_TEMT))
925 IRDA_DEBUG(1, "%s(), UART_LSR_THRE\n", __FUNCTION__ ); 925 IRDA_DEBUG(1, "%s(), UART_LSR_THRE\n", __func__ );
926 926
927 IRDA_DEBUG(1, "%s(), Changing speed! self->new_speed = %d\n", __FUNCTION__ , self->new_speed); 927 IRDA_DEBUG(1, "%s(), Changing speed! self->new_speed = %d\n", __func__ , self->new_speed);
928 ali_ircc_change_speed(self, self->new_speed); 928 ali_ircc_change_speed(self, self->new_speed);
929 self->new_speed = 0; 929 self->new_speed = 0;
930 930
931 // benjamin 2000/11/10 06:32PM 931 // benjamin 2000/11/10 06:32PM
932 if (self->io.speed > 115200) 932 if (self->io.speed > 115200)
933 { 933 {
934 IRDA_DEBUG(2, "%s(), ali_ircc_change_speed from UART_LSR_TEMT \n", __FUNCTION__ ); 934 IRDA_DEBUG(2, "%s(), ali_ircc_change_speed from UART_LSR_TEMT \n", __func__ );
935 935
936 self->ier = IER_EOM; 936 self->ier = IER_EOM;
937 // SetCOMInterrupts(self, TRUE); 937 // SetCOMInterrupts(self, TRUE);
@@ -949,7 +949,7 @@ static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb *self)
949 outb(UART_IER_RDI, iobase+UART_IER); 949 outb(UART_IER_RDI, iobase+UART_IER);
950 } 950 }
951 951
952 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 952 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
953} 953}
954 954
955static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud) 955static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud)
@@ -957,9 +957,9 @@ static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud)
957 struct net_device *dev = self->netdev; 957 struct net_device *dev = self->netdev;
958 int iobase; 958 int iobase;
959 959
960 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 960 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
961 961
962 IRDA_DEBUG(2, "%s(), setting speed = %d \n", __FUNCTION__ , baud); 962 IRDA_DEBUG(2, "%s(), setting speed = %d \n", __func__ , baud);
963 963
964 /* This function *must* be called with irq off and spin-lock. 964 /* This function *must* be called with irq off and spin-lock.
965 * - Jean II */ 965 * - Jean II */
@@ -998,7 +998,7 @@ static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud)
998 998
999 netif_wake_queue(self->netdev); 999 netif_wake_queue(self->netdev);
1000 1000
1001 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1001 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
1002} 1002}
1003 1003
1004static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 baud) 1004static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 baud)
@@ -1008,14 +1008,14 @@ static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 baud)
1008 struct ali_ircc_cb *self = (struct ali_ircc_cb *) priv; 1008 struct ali_ircc_cb *self = (struct ali_ircc_cb *) priv;
1009 struct net_device *dev; 1009 struct net_device *dev;
1010 1010
1011 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 1011 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
1012 1012
1013 IRDA_ASSERT(self != NULL, return;); 1013 IRDA_ASSERT(self != NULL, return;);
1014 1014
1015 dev = self->netdev; 1015 dev = self->netdev;
1016 iobase = self->io.fir_base; 1016 iobase = self->io.fir_base;
1017 1017
1018 IRDA_DEBUG(1, "%s(), self->io.speed = %d, change to speed = %d\n", __FUNCTION__ ,self->io.speed,baud); 1018 IRDA_DEBUG(1, "%s(), self->io.speed = %d, change to speed = %d\n", __func__ ,self->io.speed,baud);
1019 1019
1020 /* Come from SIR speed */ 1020 /* Come from SIR speed */
1021 if(self->io.speed <=115200) 1021 if(self->io.speed <=115200)
@@ -1029,7 +1029,7 @@ static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 baud)
1029 // Set Dongle Speed mode 1029 // Set Dongle Speed mode
1030 ali_ircc_change_dongle_speed(self, baud); 1030 ali_ircc_change_dongle_speed(self, baud);
1031 1031
1032 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1032 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1033} 1033}
1034 1034
1035/* 1035/*
@@ -1047,9 +1047,9 @@ static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
1047 int lcr; /* Line control reg */ 1047 int lcr; /* Line control reg */
1048 int divisor; 1048 int divisor;
1049 1049
1050 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 1050 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
1051 1051
1052 IRDA_DEBUG(1, "%s(), Setting speed to: %d\n", __FUNCTION__ , speed); 1052 IRDA_DEBUG(1, "%s(), Setting speed to: %d\n", __func__ , speed);
1053 1053
1054 IRDA_ASSERT(self != NULL, return;); 1054 IRDA_ASSERT(self != NULL, return;);
1055 1055
@@ -1103,7 +1103,7 @@ static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
1103 1103
1104 spin_unlock_irqrestore(&self->lock, flags); 1104 spin_unlock_irqrestore(&self->lock, flags);
1105 1105
1106 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1106 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1107} 1107}
1108 1108
1109static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed) 1109static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed)
@@ -1113,14 +1113,14 @@ static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed)
1113 int iobase,dongle_id; 1113 int iobase,dongle_id;
1114 int tmp = 0; 1114 int tmp = 0;
1115 1115
1116 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 1116 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
1117 1117
1118 iobase = self->io.fir_base; /* or iobase = self->io.sir_base; */ 1118 iobase = self->io.fir_base; /* or iobase = self->io.sir_base; */
1119 dongle_id = self->io.dongle_id; 1119 dongle_id = self->io.dongle_id;
1120 1120
1121 /* We are already locked, no need to do it again */ 1121 /* We are already locked, no need to do it again */
1122 1122
1123 IRDA_DEBUG(1, "%s(), Set Speed for %s , Speed = %d\n", __FUNCTION__ , dongle_types[dongle_id], speed); 1123 IRDA_DEBUG(1, "%s(), Set Speed for %s , Speed = %d\n", __func__ , dongle_types[dongle_id], speed);
1124 1124
1125 switch_bank(iobase, BANK2); 1125 switch_bank(iobase, BANK2);
1126 tmp = inb(iobase+FIR_IRDA_CR); 1126 tmp = inb(iobase+FIR_IRDA_CR);
@@ -1284,7 +1284,7 @@ static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed)
1284 1284
1285 switch_bank(iobase, BANK0); 1285 switch_bank(iobase, BANK0);
1286 1286
1287 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1287 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1288} 1288}
1289 1289
1290/* 1290/*
@@ -1297,11 +1297,11 @@ static int ali_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
1297{ 1297{
1298 int actual = 0; 1298 int actual = 0;
1299 1299
1300 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 1300 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
1301 1301
1302 /* Tx FIFO should be empty! */ 1302 /* Tx FIFO should be empty! */
1303 if (!(inb(iobase+UART_LSR) & UART_LSR_THRE)) { 1303 if (!(inb(iobase+UART_LSR) & UART_LSR_THRE)) {
1304 IRDA_DEBUG(0, "%s(), failed, fifo not empty!\n", __FUNCTION__ ); 1304 IRDA_DEBUG(0, "%s(), failed, fifo not empty!\n", __func__ );
1305 return 0; 1305 return 0;
1306 } 1306 }
1307 1307
@@ -1313,7 +1313,7 @@ static int ali_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
1313 actual++; 1313 actual++;
1314 } 1314 }
1315 1315
1316 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1316 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
1317 return actual; 1317 return actual;
1318} 1318}
1319 1319
@@ -1329,7 +1329,7 @@ static int ali_ircc_net_open(struct net_device *dev)
1329 int iobase; 1329 int iobase;
1330 char hwname[32]; 1330 char hwname[32];
1331 1331
1332 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 1332 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
1333 1333
1334 IRDA_ASSERT(dev != NULL, return -1;); 1334 IRDA_ASSERT(dev != NULL, return -1;);
1335 1335
@@ -1375,7 +1375,7 @@ static int ali_ircc_net_open(struct net_device *dev)
1375 */ 1375 */
1376 self->irlap = irlap_open(dev, &self->qos, hwname); 1376 self->irlap = irlap_open(dev, &self->qos, hwname);
1377 1377
1378 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1378 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
1379 1379
1380 return 0; 1380 return 0;
1381} 1381}
@@ -1392,7 +1392,7 @@ static int ali_ircc_net_close(struct net_device *dev)
1392 struct ali_ircc_cb *self; 1392 struct ali_ircc_cb *self;
1393 //int iobase; 1393 //int iobase;
1394 1394
1395 IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 1395 IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __func__ );
1396 1396
1397 IRDA_ASSERT(dev != NULL, return -1;); 1397 IRDA_ASSERT(dev != NULL, return -1;);
1398 1398
@@ -1415,7 +1415,7 @@ static int ali_ircc_net_close(struct net_device *dev)
1415 free_irq(self->io.irq, dev); 1415 free_irq(self->io.irq, dev);
1416 free_dma(self->io.dma); 1416 free_dma(self->io.dma);
1417 1417
1418 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1418 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
1419 1419
1420 return 0; 1420 return 0;
1421} 1421}
@@ -1434,7 +1434,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1434 __u32 speed; 1434 __u32 speed;
1435 int mtt, diff; 1435 int mtt, diff;
1436 1436
1437 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__ ); 1437 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
1438 1438
1439 self = (struct ali_ircc_cb *) dev->priv; 1439 self = (struct ali_ircc_cb *) dev->priv;
1440 iobase = self->io.fir_base; 1440 iobase = self->io.fir_base;
@@ -1488,7 +1488,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1488 diff = self->now.tv_usec - self->stamp.tv_usec; 1488 diff = self->now.tv_usec - self->stamp.tv_usec;
1489 /* self->stamp is set from ali_ircc_dma_receive_complete() */ 1489 /* self->stamp is set from ali_ircc_dma_receive_complete() */
1490 1490
1491 IRDA_DEBUG(1, "%s(), ******* diff = %d ******* \n", __FUNCTION__ , diff); 1491 IRDA_DEBUG(1, "%s(), ******* diff = %d ******* \n", __func__ , diff);
1492 1492
1493 if (diff < 0) 1493 if (diff < 0)
1494 diff += 1000000; 1494 diff += 1000000;
@@ -1510,7 +1510,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1510 /* Adjust for timer resolution */ 1510 /* Adjust for timer resolution */
1511 mtt = (mtt+250) / 500; /* 4 discard, 5 get advanced, Let's round off */ 1511 mtt = (mtt+250) / 500; /* 4 discard, 5 get advanced, Let's round off */
1512 1512
1513 IRDA_DEBUG(1, "%s(), ************** mtt = %d ***********\n", __FUNCTION__ , mtt); 1513 IRDA_DEBUG(1, "%s(), ************** mtt = %d ***********\n", __func__ , mtt);
1514 1514
1515 /* Setup timer */ 1515 /* Setup timer */
1516 if (mtt == 1) /* 500 us */ 1516 if (mtt == 1) /* 500 us */
@@ -1567,7 +1567,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1567 spin_unlock_irqrestore(&self->lock, flags); 1567 spin_unlock_irqrestore(&self->lock, flags);
1568 dev_kfree_skb(skb); 1568 dev_kfree_skb(skb);
1569 1569
1570 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1570 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1571 return 0; 1571 return 0;
1572} 1572}
1573 1573
@@ -1578,7 +1578,7 @@ static void ali_ircc_dma_xmit(struct ali_ircc_cb *self)
1578 unsigned char FIFO_OPTI, Hi, Lo; 1578 unsigned char FIFO_OPTI, Hi, Lo;
1579 1579
1580 1580
1581 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__ ); 1581 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
1582 1582
1583 iobase = self->io.fir_base; 1583 iobase = self->io.fir_base;
1584 1584
@@ -1629,7 +1629,7 @@ static void ali_ircc_dma_xmit(struct ali_ircc_cb *self)
1629 tmp = inb(iobase+FIR_LCR_B); 1629 tmp = inb(iobase+FIR_LCR_B);
1630 tmp &= ~0x20; // Disable SIP 1630 tmp &= ~0x20; // Disable SIP
1631 outb(((unsigned char)(tmp & 0x3f) | LCR_B_TX_MODE) & ~LCR_B_BW, iobase+FIR_LCR_B); 1631 outb(((unsigned char)(tmp & 0x3f) | LCR_B_TX_MODE) & ~LCR_B_BW, iobase+FIR_LCR_B);
1632 IRDA_DEBUG(1, "%s(), ******* Change to TX mode: FIR_LCR_B = 0x%x ******* \n", __FUNCTION__ , inb(iobase+FIR_LCR_B)); 1632 IRDA_DEBUG(1, "%s(), ******* Change to TX mode: FIR_LCR_B = 0x%x ******* \n", __func__ , inb(iobase+FIR_LCR_B));
1633 1633
1634 outb(0, iobase+FIR_LSR); 1634 outb(0, iobase+FIR_LSR);
1635 1635
@@ -1639,7 +1639,7 @@ static void ali_ircc_dma_xmit(struct ali_ircc_cb *self)
1639 1639
1640 switch_bank(iobase, BANK0); 1640 switch_bank(iobase, BANK0);
1641 1641
1642 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1642 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1643} 1643}
1644 1644
1645static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self) 1645static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self)
@@ -1647,7 +1647,7 @@ static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self)
1647 int iobase; 1647 int iobase;
1648 int ret = TRUE; 1648 int ret = TRUE;
1649 1649
1650 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__ ); 1650 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
1651 1651
1652 iobase = self->io.fir_base; 1652 iobase = self->io.fir_base;
1653 1653
@@ -1660,7 +1660,7 @@ static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self)
1660 if((inb(iobase+FIR_LSR) & LSR_FRAME_ABORT) == LSR_FRAME_ABORT) 1660 if((inb(iobase+FIR_LSR) & LSR_FRAME_ABORT) == LSR_FRAME_ABORT)
1661 1661
1662 { 1662 {
1663 IRDA_ERROR("%s(), ********* LSR_FRAME_ABORT *********\n", __FUNCTION__); 1663 IRDA_ERROR("%s(), ********* LSR_FRAME_ABORT *********\n", __func__);
1664 self->stats.tx_errors++; 1664 self->stats.tx_errors++;
1665 self->stats.tx_fifo_errors++; 1665 self->stats.tx_fifo_errors++;
1666 } 1666 }
@@ -1703,7 +1703,7 @@ static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self)
1703 1703
1704 switch_bank(iobase, BANK0); 1704 switch_bank(iobase, BANK0);
1705 1705
1706 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1706 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1707 return ret; 1707 return ret;
1708} 1708}
1709 1709
@@ -1718,7 +1718,7 @@ static int ali_ircc_dma_receive(struct ali_ircc_cb *self)
1718{ 1718{
1719 int iobase, tmp; 1719 int iobase, tmp;
1720 1720
1721 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__ ); 1721 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
1722 1722
1723 iobase = self->io.fir_base; 1723 iobase = self->io.fir_base;
1724 1724
@@ -1756,7 +1756,7 @@ static int ali_ircc_dma_receive(struct ali_ircc_cb *self)
1756 //switch_bank(iobase, BANK0); 1756 //switch_bank(iobase, BANK0);
1757 tmp = inb(iobase+FIR_LCR_B); 1757 tmp = inb(iobase+FIR_LCR_B);
1758 outb((unsigned char)(tmp &0x3f) | LCR_B_RX_MODE | LCR_B_BW , iobase + FIR_LCR_B); // 2000/12/1 05:16PM 1758 outb((unsigned char)(tmp &0x3f) | LCR_B_RX_MODE | LCR_B_BW , iobase + FIR_LCR_B); // 2000/12/1 05:16PM
1759 IRDA_DEBUG(1, "%s(), *** Change To RX mode: FIR_LCR_B = 0x%x *** \n", __FUNCTION__ , inb(iobase+FIR_LCR_B)); 1759 IRDA_DEBUG(1, "%s(), *** Change To RX mode: FIR_LCR_B = 0x%x *** \n", __func__ , inb(iobase+FIR_LCR_B));
1760 1760
1761 /* Set Rx Threshold */ 1761 /* Set Rx Threshold */
1762 switch_bank(iobase, BANK1); 1762 switch_bank(iobase, BANK1);
@@ -1768,7 +1768,7 @@ static int ali_ircc_dma_receive(struct ali_ircc_cb *self)
1768 outb(CR_DMA_EN | CR_DMA_BURST, iobase+FIR_CR); 1768 outb(CR_DMA_EN | CR_DMA_BURST, iobase+FIR_CR);
1769 1769
1770 switch_bank(iobase, BANK0); 1770 switch_bank(iobase, BANK0);
1771 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1771 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1772 return 0; 1772 return 0;
1773} 1773}
1774 1774
@@ -1779,7 +1779,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1779 __u8 status, MessageCount; 1779 __u8 status, MessageCount;
1780 int len, i, iobase, val; 1780 int len, i, iobase, val;
1781 1781
1782 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__ ); 1782 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __func__ );
1783 1783
1784 st_fifo = &self->st_fifo; 1784 st_fifo = &self->st_fifo;
1785 iobase = self->io.fir_base; 1785 iobase = self->io.fir_base;
@@ -1788,7 +1788,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1788 MessageCount = inb(iobase+ FIR_LSR)&0x07; 1788 MessageCount = inb(iobase+ FIR_LSR)&0x07;
1789 1789
1790 if (MessageCount > 0) 1790 if (MessageCount > 0)
1791 IRDA_DEBUG(0, "%s(), Messsage count = %d,\n", __FUNCTION__ , MessageCount); 1791 IRDA_DEBUG(0, "%s(), Messsage count = %d,\n", __func__ , MessageCount);
1792 1792
1793 for (i=0; i<=MessageCount; i++) 1793 for (i=0; i<=MessageCount; i++)
1794 { 1794 {
@@ -1801,11 +1801,11 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1801 len = len << 8; 1801 len = len << 8;
1802 len |= inb(iobase+FIR_RX_DSR_LO); 1802 len |= inb(iobase+FIR_RX_DSR_LO);
1803 1803
1804 IRDA_DEBUG(1, "%s(), RX Length = 0x%.2x,\n", __FUNCTION__ , len); 1804 IRDA_DEBUG(1, "%s(), RX Length = 0x%.2x,\n", __func__ , len);
1805 IRDA_DEBUG(1, "%s(), RX Status = 0x%.2x,\n", __FUNCTION__ , status); 1805 IRDA_DEBUG(1, "%s(), RX Status = 0x%.2x,\n", __func__ , status);
1806 1806
1807 if (st_fifo->tail >= MAX_RX_WINDOW) { 1807 if (st_fifo->tail >= MAX_RX_WINDOW) {
1808 IRDA_DEBUG(0, "%s(), window is full!\n", __FUNCTION__ ); 1808 IRDA_DEBUG(0, "%s(), window is full!\n", __func__ );
1809 continue; 1809 continue;
1810 } 1810 }
1811 1811
@@ -1828,7 +1828,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1828 /* Check for errors */ 1828 /* Check for errors */
1829 if ((status & 0xd8) || self->rcvFramesOverflow || (len==0)) 1829 if ((status & 0xd8) || self->rcvFramesOverflow || (len==0))
1830 { 1830 {
1831 IRDA_DEBUG(0,"%s(), ************* RX Errors ************ \n", __FUNCTION__ ); 1831 IRDA_DEBUG(0,"%s(), ************* RX Errors ************ \n", __func__ );
1832 1832
1833 /* Skip frame */ 1833 /* Skip frame */
1834 self->stats.rx_errors++; 1834 self->stats.rx_errors++;
@@ -1838,29 +1838,29 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1838 if (status & LSR_FIFO_UR) 1838 if (status & LSR_FIFO_UR)
1839 { 1839 {
1840 self->stats.rx_frame_errors++; 1840 self->stats.rx_frame_errors++;
1841 IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************ \n", __FUNCTION__ ); 1841 IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************ \n", __func__ );
1842 } 1842 }
1843 if (status & LSR_FRAME_ERROR) 1843 if (status & LSR_FRAME_ERROR)
1844 { 1844 {
1845 self->stats.rx_frame_errors++; 1845 self->stats.rx_frame_errors++;
1846 IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************ \n", __FUNCTION__ ); 1846 IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************ \n", __func__ );
1847 } 1847 }
1848 1848
1849 if (status & LSR_CRC_ERROR) 1849 if (status & LSR_CRC_ERROR)
1850 { 1850 {
1851 self->stats.rx_crc_errors++; 1851 self->stats.rx_crc_errors++;
1852 IRDA_DEBUG(0,"%s(), ************* CRC Errors ************ \n", __FUNCTION__ ); 1852 IRDA_DEBUG(0,"%s(), ************* CRC Errors ************ \n", __func__ );
1853 } 1853 }
1854 1854
1855 if(self->rcvFramesOverflow) 1855 if(self->rcvFramesOverflow)
1856 { 1856 {
1857 self->stats.rx_frame_errors++; 1857 self->stats.rx_frame_errors++;
1858 IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************ \n", __FUNCTION__ ); 1858 IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************ \n", __func__ );
1859 } 1859 }
1860 if(len == 0) 1860 if(len == 0)
1861 { 1861 {
1862 self->stats.rx_frame_errors++; 1862 self->stats.rx_frame_errors++;
1863 IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 ********* \n", __FUNCTION__ ); 1863 IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 ********* \n", __func__ );
1864 } 1864 }
1865 } 1865 }
1866 else 1866 else
@@ -1872,7 +1872,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1872 val = inb(iobase+FIR_BSR); 1872 val = inb(iobase+FIR_BSR);
1873 if ((val& BSR_FIFO_NOT_EMPTY)== 0x80) 1873 if ((val& BSR_FIFO_NOT_EMPTY)== 0x80)
1874 { 1874 {
1875 IRDA_DEBUG(0, "%s(), ************* BSR_FIFO_NOT_EMPTY ************ \n", __FUNCTION__ ); 1875 IRDA_DEBUG(0, "%s(), ************* BSR_FIFO_NOT_EMPTY ************ \n", __func__ );
1876 1876
1877 /* Put this entry back in fifo */ 1877 /* Put this entry back in fifo */
1878 st_fifo->head--; 1878 st_fifo->head--;
@@ -1909,7 +1909,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1909 { 1909 {
1910 IRDA_WARNING("%s(), memory squeeze, " 1910 IRDA_WARNING("%s(), memory squeeze, "
1911 "dropping frame.\n", 1911 "dropping frame.\n",
1912 __FUNCTION__); 1912 __func__);
1913 self->stats.rx_dropped++; 1913 self->stats.rx_dropped++;
1914 1914
1915 return FALSE; 1915 return FALSE;
@@ -1937,7 +1937,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1937 1937
1938 switch_bank(iobase, BANK0); 1938 switch_bank(iobase, BANK0);
1939 1939
1940 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 1940 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
1941 return TRUE; 1941 return TRUE;
1942} 1942}
1943 1943
@@ -1956,7 +1956,7 @@ static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1956 int iobase; 1956 int iobase;
1957 __u32 speed; 1957 __u32 speed;
1958 1958
1959 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 1959 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
1960 1960
1961 IRDA_ASSERT(dev != NULL, return 0;); 1961 IRDA_ASSERT(dev != NULL, return 0;);
1962 1962
@@ -2005,7 +2005,7 @@ static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
2005 2005
2006 dev_kfree_skb(skb); 2006 dev_kfree_skb(skb);
2007 2007
2008 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2008 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
2009 2009
2010 return 0; 2010 return 0;
2011} 2011}
@@ -2024,7 +2024,7 @@ static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2024 unsigned long flags; 2024 unsigned long flags;
2025 int ret = 0; 2025 int ret = 0;
2026 2026
2027 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 2027 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
2028 2028
2029 IRDA_ASSERT(dev != NULL, return -1;); 2029 IRDA_ASSERT(dev != NULL, return -1;);
2030 2030
@@ -2032,11 +2032,11 @@ static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2032 2032
2033 IRDA_ASSERT(self != NULL, return -1;); 2033 IRDA_ASSERT(self != NULL, return -1;);
2034 2034
2035 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__ , dev->name, cmd); 2035 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__ , dev->name, cmd);
2036 2036
2037 switch (cmd) { 2037 switch (cmd) {
2038 case SIOCSBANDWIDTH: /* Set bandwidth */ 2038 case SIOCSBANDWIDTH: /* Set bandwidth */
2039 IRDA_DEBUG(1, "%s(), SIOCSBANDWIDTH\n", __FUNCTION__ ); 2039 IRDA_DEBUG(1, "%s(), SIOCSBANDWIDTH\n", __func__ );
2040 /* 2040 /*
2041 * This function will also be used by IrLAP to change the 2041 * This function will also be used by IrLAP to change the
2042 * speed, so we still must allow for speed change within 2042 * speed, so we still must allow for speed change within
@@ -2050,13 +2050,13 @@ static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2050 spin_unlock_irqrestore(&self->lock, flags); 2050 spin_unlock_irqrestore(&self->lock, flags);
2051 break; 2051 break;
2052 case SIOCSMEDIABUSY: /* Set media busy */ 2052 case SIOCSMEDIABUSY: /* Set media busy */
2053 IRDA_DEBUG(1, "%s(), SIOCSMEDIABUSY\n", __FUNCTION__ ); 2053 IRDA_DEBUG(1, "%s(), SIOCSMEDIABUSY\n", __func__ );
2054 if (!capable(CAP_NET_ADMIN)) 2054 if (!capable(CAP_NET_ADMIN))
2055 return -EPERM; 2055 return -EPERM;
2056 irda_device_set_media_busy(self->netdev, TRUE); 2056 irda_device_set_media_busy(self->netdev, TRUE);
2057 break; 2057 break;
2058 case SIOCGRECEIVING: /* Check if we are receiving right now */ 2058 case SIOCGRECEIVING: /* Check if we are receiving right now */
2059 IRDA_DEBUG(2, "%s(), SIOCGRECEIVING\n", __FUNCTION__ ); 2059 IRDA_DEBUG(2, "%s(), SIOCGRECEIVING\n", __func__ );
2060 /* This is protected */ 2060 /* This is protected */
2061 irq->ifr_receiving = ali_ircc_is_receiving(self); 2061 irq->ifr_receiving = ali_ircc_is_receiving(self);
2062 break; 2062 break;
@@ -2064,7 +2064,7 @@ static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2064 ret = -EOPNOTSUPP; 2064 ret = -EOPNOTSUPP;
2065 } 2065 }
2066 2066
2067 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2067 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
2068 2068
2069 return ret; 2069 return ret;
2070} 2070}
@@ -2081,7 +2081,7 @@ static int ali_ircc_is_receiving(struct ali_ircc_cb *self)
2081 int status = FALSE; 2081 int status = FALSE;
2082 int iobase; 2082 int iobase;
2083 2083
2084 IRDA_DEBUG(2, "%s(), ---------------- Start -----------------\n", __FUNCTION__ ); 2084 IRDA_DEBUG(2, "%s(), ---------------- Start -----------------\n", __func__ );
2085 2085
2086 IRDA_ASSERT(self != NULL, return FALSE;); 2086 IRDA_ASSERT(self != NULL, return FALSE;);
2087 2087
@@ -2095,7 +2095,7 @@ static int ali_ircc_is_receiving(struct ali_ircc_cb *self)
2095 if((inb(iobase+FIR_FIFO_FR) & 0x3f) != 0) 2095 if((inb(iobase+FIR_FIFO_FR) & 0x3f) != 0)
2096 { 2096 {
2097 /* We are receiving something */ 2097 /* We are receiving something */
2098 IRDA_DEBUG(1, "%s(), We are receiving something\n", __FUNCTION__ ); 2098 IRDA_DEBUG(1, "%s(), We are receiving something\n", __func__ );
2099 status = TRUE; 2099 status = TRUE;
2100 } 2100 }
2101 switch_bank(iobase, BANK0); 2101 switch_bank(iobase, BANK0);
@@ -2107,7 +2107,7 @@ static int ali_ircc_is_receiving(struct ali_ircc_cb *self)
2107 2107
2108 spin_unlock_irqrestore(&self->lock, flags); 2108 spin_unlock_irqrestore(&self->lock, flags);
2109 2109
2110 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2110 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
2111 2111
2112 return status; 2112 return status;
2113} 2113}
@@ -2116,9 +2116,9 @@ static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev)
2116{ 2116{
2117 struct ali_ircc_cb *self = (struct ali_ircc_cb *) dev->priv; 2117 struct ali_ircc_cb *self = (struct ali_ircc_cb *) dev->priv;
2118 2118
2119 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 2119 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
2120 2120
2121 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2121 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
2122 2122
2123 return &self->stats; 2123 return &self->stats;
2124} 2124}
@@ -2164,7 +2164,7 @@ static void SetCOMInterrupts(struct ali_ircc_cb *self , unsigned char enable)
2164 2164
2165 int iobase = self->io.fir_base; /* or sir_base */ 2165 int iobase = self->io.fir_base; /* or sir_base */
2166 2166
2167 IRDA_DEBUG(2, "%s(), -------- Start -------- ( Enable = %d )\n", __FUNCTION__ , enable); 2167 IRDA_DEBUG(2, "%s(), -------- Start -------- ( Enable = %d )\n", __func__ , enable);
2168 2168
2169 /* Enable the interrupt which we wish to */ 2169 /* Enable the interrupt which we wish to */
2170 if (enable){ 2170 if (enable){
@@ -2205,14 +2205,14 @@ static void SetCOMInterrupts(struct ali_ircc_cb *self , unsigned char enable)
2205 else 2205 else
2206 outb(newMask, iobase+UART_IER); 2206 outb(newMask, iobase+UART_IER);
2207 2207
2208 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2208 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
2209} 2209}
2210 2210
2211static void SIR2FIR(int iobase) 2211static void SIR2FIR(int iobase)
2212{ 2212{
2213 //unsigned char tmp; 2213 //unsigned char tmp;
2214 2214
2215 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 2215 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
2216 2216
2217 /* Already protected (change_speed() or setup()), no need to lock. 2217 /* Already protected (change_speed() or setup()), no need to lock.
2218 * Jean II */ 2218 * Jean II */
@@ -2228,14 +2228,14 @@ static void SIR2FIR(int iobase)
2228 //tmp |= 0x20; 2228 //tmp |= 0x20;
2229 //outb(tmp, iobase+FIR_LCR_B); 2229 //outb(tmp, iobase+FIR_LCR_B);
2230 2230
2231 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2231 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
2232} 2232}
2233 2233
2234static void FIR2SIR(int iobase) 2234static void FIR2SIR(int iobase)
2235{ 2235{
2236 unsigned char val; 2236 unsigned char val;
2237 2237
2238 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 2238 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
2239 2239
2240 /* Already protected (change_speed() or setup()), no need to lock. 2240 /* Already protected (change_speed() or setup()), no need to lock.
2241 * Jean II */ 2241 * Jean II */
@@ -2251,7 +2251,7 @@ static void FIR2SIR(int iobase)
2251 val = inb(iobase+UART_LSR); 2251 val = inb(iobase+UART_LSR);
2252 val = inb(iobase+UART_MSR); 2252 val = inb(iobase+UART_MSR);
2253 2253
2254 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2254 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ );
2255} 2255}
2256 2256
2257MODULE_AUTHOR("Benjamin Kong <benjamin_kong@ali.com.tw>"); 2257MODULE_AUTHOR("Benjamin Kong <benjamin_kong@ali.com.tw>");
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 34ad189fff67..69d16b30323b 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -245,7 +245,7 @@ toshoboe_dumpregs (struct toshoboe_cb *self)
245{ 245{
246 __u32 ringbase; 246 __u32 ringbase;
247 247
248 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 248 IRDA_DEBUG (4, "%s()\n", __func__);
249 249
250 ringbase = INB (OBOE_RING_BASE0) << 10; 250 ringbase = INB (OBOE_RING_BASE0) << 10;
251 ringbase |= INB (OBOE_RING_BASE1) << 18; 251 ringbase |= INB (OBOE_RING_BASE1) << 18;
@@ -293,7 +293,7 @@ static void
293toshoboe_disablebm (struct toshoboe_cb *self) 293toshoboe_disablebm (struct toshoboe_cb *self)
294{ 294{
295 __u8 command; 295 __u8 command;
296 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 296 IRDA_DEBUG (4, "%s()\n", __func__);
297 297
298 pci_read_config_byte (self->pdev, PCI_COMMAND, &command); 298 pci_read_config_byte (self->pdev, PCI_COMMAND, &command);
299 command &= ~PCI_COMMAND_MASTER; 299 command &= ~PCI_COMMAND_MASTER;
@@ -305,7 +305,7 @@ toshoboe_disablebm (struct toshoboe_cb *self)
305static void 305static void
306toshoboe_stopchip (struct toshoboe_cb *self) 306toshoboe_stopchip (struct toshoboe_cb *self)
307{ 307{
308 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 308 IRDA_DEBUG (4, "%s()\n", __func__);
309 309
310 /*Disable interrupts */ 310 /*Disable interrupts */
311 OUTB (0x0, OBOE_IER); 311 OUTB (0x0, OBOE_IER);
@@ -350,7 +350,7 @@ toshoboe_setbaud (struct toshoboe_cb *self)
350 __u16 pconfig = 0; 350 __u16 pconfig = 0;
351 __u8 config0l = 0; 351 __u8 config0l = 0;
352 352
353 IRDA_DEBUG (2, "%s(%d/%d)\n", __FUNCTION__, self->speed, self->io.speed); 353 IRDA_DEBUG (2, "%s(%d/%d)\n", __func__, self->speed, self->io.speed);
354 354
355 switch (self->speed) 355 switch (self->speed)
356 { 356 {
@@ -482,7 +482,7 @@ toshoboe_setbaud (struct toshoboe_cb *self)
482static void 482static void
483toshoboe_enablebm (struct toshoboe_cb *self) 483toshoboe_enablebm (struct toshoboe_cb *self)
484{ 484{
485 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 485 IRDA_DEBUG (4, "%s()\n", __func__);
486 pci_set_master (self->pdev); 486 pci_set_master (self->pdev);
487} 487}
488 488
@@ -492,7 +492,7 @@ toshoboe_initring (struct toshoboe_cb *self)
492{ 492{
493 int i; 493 int i;
494 494
495 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 495 IRDA_DEBUG (4, "%s()\n", __func__);
496 496
497 for (i = 0; i < TX_SLOTS; ++i) 497 for (i = 0; i < TX_SLOTS; ++i)
498 { 498 {
@@ -550,7 +550,7 @@ toshoboe_startchip (struct toshoboe_cb *self)
550{ 550{
551 __u32 physaddr; 551 __u32 physaddr;
552 552
553 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 553 IRDA_DEBUG (4, "%s()\n", __func__);
554 554
555 toshoboe_initring (self); 555 toshoboe_initring (self);
556 toshoboe_enablebm (self); 556 toshoboe_enablebm (self);
@@ -824,7 +824,7 @@ toshoboe_probe (struct toshoboe_cb *self)
824#endif 824#endif
825 unsigned long flags; 825 unsigned long flags;
826 826
827 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 827 IRDA_DEBUG (4, "%s()\n", __func__);
828 828
829 if (request_irq (self->io.irq, toshoboe_probeinterrupt, 829 if (request_irq (self->io.irq, toshoboe_probeinterrupt,
830 self->io.irqflags, "toshoboe", (void *) self)) 830 self->io.irqflags, "toshoboe", (void *) self))
@@ -983,10 +983,10 @@ toshoboe_hard_xmit (struct sk_buff *skb, struct net_device *dev)
983 983
984 IRDA_ASSERT (self != NULL, return 0; ); 984 IRDA_ASSERT (self != NULL, return 0; );
985 985
986 IRDA_DEBUG (1, "%s.tx:%x(%x)%x\n", __FUNCTION__ 986 IRDA_DEBUG (1, "%s.tx:%x(%x)%x\n", __func__
987 ,skb->len,self->txpending,INB (OBOE_ENABLEH)); 987 ,skb->len,self->txpending,INB (OBOE_ENABLEH));
988 if (!cb->magic) { 988 if (!cb->magic) {
989 IRDA_DEBUG (2, "%s.Not IrLAP:%x\n", __FUNCTION__, cb->magic); 989 IRDA_DEBUG (2, "%s.Not IrLAP:%x\n", __func__, cb->magic);
990#ifdef DUMP_PACKETS 990#ifdef DUMP_PACKETS
991 _dumpbufs(skb->data,skb->len,'>'); 991 _dumpbufs(skb->data,skb->len,'>');
992#endif 992#endif
@@ -1015,7 +1015,7 @@ toshoboe_hard_xmit (struct sk_buff *skb, struct net_device *dev)
1015 { 1015 {
1016 self->new_speed = speed; 1016 self->new_speed = speed;
1017 IRDA_DEBUG (1, "%s: Queued TxDone scheduled speed change %d\n" , 1017 IRDA_DEBUG (1, "%s: Queued TxDone scheduled speed change %d\n" ,
1018 __FUNCTION__, speed); 1018 __func__, speed);
1019 /* if no data, that's all! */ 1019 /* if no data, that's all! */
1020 if (!skb->len) 1020 if (!skb->len)
1021 { 1021 {
@@ -1057,7 +1057,7 @@ toshoboe_hard_xmit (struct sk_buff *skb, struct net_device *dev)
1057 /* which we will add a wrong checksum to */ 1057 /* which we will add a wrong checksum to */
1058 1058
1059 mtt = toshoboe_makemttpacket (self, self->tx_bufs[self->txs], mtt); 1059 mtt = toshoboe_makemttpacket (self, self->tx_bufs[self->txs], mtt);
1060 IRDA_DEBUG (1, "%s.mtt:%x(%x)%d\n", __FUNCTION__ 1060 IRDA_DEBUG (1, "%s.mtt:%x(%x)%d\n", __func__
1061 ,skb->len,mtt,self->txpending); 1061 ,skb->len,mtt,self->txpending);
1062 if (mtt) 1062 if (mtt)
1063 { 1063 {
@@ -1101,7 +1101,7 @@ dumpbufs(skb->data,skb->len,'>');
1101 1101
1102 if (self->ring->tx[self->txs].control & OBOE_CTL_TX_HW_OWNS) 1102 if (self->ring->tx[self->txs].control & OBOE_CTL_TX_HW_OWNS)
1103 { 1103 {
1104 IRDA_DEBUG (0, "%s.ful:%x(%x)%x\n", __FUNCTION__ 1104 IRDA_DEBUG (0, "%s.ful:%x(%x)%x\n", __func__
1105 ,skb->len, self->ring->tx[self->txs].control, self->txpending); 1105 ,skb->len, self->ring->tx[self->txs].control, self->txpending);
1106 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX); 1106 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX);
1107 spin_unlock_irqrestore(&self->spinlock, flags); 1107 spin_unlock_irqrestore(&self->spinlock, flags);
@@ -1179,7 +1179,7 @@ toshoboe_interrupt (int irq, void *dev_id)
1179 if (self->ring->tx[i].control & OBOE_CTL_TX_HW_OWNS) 1179 if (self->ring->tx[i].control & OBOE_CTL_TX_HW_OWNS)
1180 self->txpending++; 1180 self->txpending++;
1181 } 1181 }
1182 IRDA_DEBUG (1, "%s.txd(%x)%x/%x\n", __FUNCTION__ 1182 IRDA_DEBUG (1, "%s.txd(%x)%x/%x\n", __func__
1183 ,irqstat,txp,self->txpending); 1183 ,irqstat,txp,self->txpending);
1184 1184
1185 txp = INB (OBOE_TXSLOT) & OBOE_SLOT_MASK; 1185 txp = INB (OBOE_TXSLOT) & OBOE_SLOT_MASK;
@@ -1209,7 +1209,7 @@ toshoboe_interrupt (int irq, void *dev_id)
1209 { 1209 {
1210 self->speed = self->new_speed; 1210 self->speed = self->new_speed;
1211 IRDA_DEBUG (1, "%s: Executed TxDone scheduled speed change %d\n", 1211 IRDA_DEBUG (1, "%s: Executed TxDone scheduled speed change %d\n",
1212 __FUNCTION__, self->speed); 1212 __func__, self->speed);
1213 toshoboe_setbaud (self); 1213 toshoboe_setbaud (self);
1214 } 1214 }
1215 1215
@@ -1224,7 +1224,7 @@ toshoboe_interrupt (int irq, void *dev_id)
1224 { 1224 {
1225 int len = self->ring->rx[self->rxs].len; 1225 int len = self->ring->rx[self->rxs].len;
1226 skb = NULL; 1226 skb = NULL;
1227 IRDA_DEBUG (3, "%s.rcv:%x(%x)\n", __FUNCTION__ 1227 IRDA_DEBUG (3, "%s.rcv:%x(%x)\n", __func__
1228 ,len,self->ring->rx[self->rxs].control); 1228 ,len,self->ring->rx[self->rxs].control);
1229 1229
1230#ifdef DUMP_PACKETS 1230#ifdef DUMP_PACKETS
@@ -1246,7 +1246,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1246 len -= 2; 1246 len -= 2;
1247 else 1247 else
1248 len = 0; 1248 len = 0;
1249 IRDA_DEBUG (1, "%s.SIR:%x(%x)\n", __FUNCTION__, len,enable); 1249 IRDA_DEBUG (1, "%s.SIR:%x(%x)\n", __func__, len,enable);
1250 } 1250 }
1251 1251
1252#ifdef USE_MIR 1252#ifdef USE_MIR
@@ -1256,7 +1256,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1256 len -= 2; 1256 len -= 2;
1257 else 1257 else
1258 len = 0; 1258 len = 0;
1259 IRDA_DEBUG (2, "%s.MIR:%x(%x)\n", __FUNCTION__, len,enable); 1259 IRDA_DEBUG (2, "%s.MIR:%x(%x)\n", __func__, len,enable);
1260 } 1260 }
1261#endif 1261#endif
1262 else if (enable & OBOE_ENABLEH_FIRON) 1262 else if (enable & OBOE_ENABLEH_FIRON)
@@ -1265,10 +1265,10 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1265 len -= 4; /*FIXME: check this */ 1265 len -= 4; /*FIXME: check this */
1266 else 1266 else
1267 len = 0; 1267 len = 0;
1268 IRDA_DEBUG (1, "%s.FIR:%x(%x)\n", __FUNCTION__, len,enable); 1268 IRDA_DEBUG (1, "%s.FIR:%x(%x)\n", __func__, len,enable);
1269 } 1269 }
1270 else 1270 else
1271 IRDA_DEBUG (0, "%s.?IR:%x(%x)\n", __FUNCTION__, len,enable); 1271 IRDA_DEBUG (0, "%s.?IR:%x(%x)\n", __func__, len,enable);
1272 1272
1273 if (len) 1273 if (len)
1274 { 1274 {
@@ -1289,7 +1289,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1289 { 1289 {
1290 printk (KERN_INFO 1290 printk (KERN_INFO
1291 "%s(), memory squeeze, dropping frame.\n", 1291 "%s(), memory squeeze, dropping frame.\n",
1292 __FUNCTION__); 1292 __func__);
1293 } 1293 }
1294 } 1294 }
1295 } 1295 }
@@ -1301,7 +1301,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1301 /* (SIR) data is splitted in several slots. */ 1301 /* (SIR) data is splitted in several slots. */
1302 /* we have to join all the received buffers received */ 1302 /* we have to join all the received buffers received */
1303 /*in a large buffer before checking CRC. */ 1303 /*in a large buffer before checking CRC. */
1304 IRDA_DEBUG (0, "%s.err:%x(%x)\n", __FUNCTION__ 1304 IRDA_DEBUG (0, "%s.err:%x(%x)\n", __func__
1305 ,len,self->ring->rx[self->rxs].control); 1305 ,len,self->ring->rx[self->rxs].control);
1306 } 1306 }
1307 1307
@@ -1329,7 +1329,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1329 if (irqstat & OBOE_INT_SIP) 1329 if (irqstat & OBOE_INT_SIP)
1330 { 1330 {
1331 self->int_sip++; 1331 self->int_sip++;
1332 IRDA_DEBUG (1, "%s.sip:%x(%x)%x\n", __FUNCTION__ 1332 IRDA_DEBUG (1, "%s.sip:%x(%x)%x\n", __func__
1333 ,self->int_sip,irqstat,self->txpending); 1333 ,self->int_sip,irqstat,self->txpending);
1334 } 1334 }
1335 return IRQ_HANDLED; 1335 return IRQ_HANDLED;
@@ -1343,7 +1343,7 @@ toshoboe_net_open (struct net_device *dev)
1343 unsigned long flags; 1343 unsigned long flags;
1344 int rc; 1344 int rc;
1345 1345
1346 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 1346 IRDA_DEBUG (4, "%s()\n", __func__);
1347 1347
1348 self = netdev_priv(dev); 1348 self = netdev_priv(dev);
1349 1349
@@ -1381,7 +1381,7 @@ toshoboe_net_close (struct net_device *dev)
1381{ 1381{
1382 struct toshoboe_cb *self; 1382 struct toshoboe_cb *self;
1383 1383
1384 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 1384 IRDA_DEBUG (4, "%s()\n", __func__);
1385 1385
1386 IRDA_ASSERT (dev != NULL, return -1; ); 1386 IRDA_ASSERT (dev != NULL, return -1; );
1387 self = (struct toshoboe_cb *) dev->priv; 1387 self = (struct toshoboe_cb *) dev->priv;
@@ -1426,7 +1426,7 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1426 1426
1427 IRDA_ASSERT (self != NULL, return -1; ); 1427 IRDA_ASSERT (self != NULL, return -1; );
1428 1428
1429 IRDA_DEBUG (5, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd); 1429 IRDA_DEBUG (5, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name, cmd);
1430 1430
1431 /* Disable interrupts & save flags */ 1431 /* Disable interrupts & save flags */
1432 spin_lock_irqsave(&self->spinlock, flags); 1432 spin_lock_irqsave(&self->spinlock, flags);
@@ -1438,7 +1438,7 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1438 * speed, so we still must allow for speed change within 1438 * speed, so we still must allow for speed change within
1439 * interrupt context. 1439 * interrupt context.
1440 */ 1440 */
1441 IRDA_DEBUG (1, "%s(BANDWIDTH), %s, (%X/%ld\n", __FUNCTION__ 1441 IRDA_DEBUG (1, "%s(BANDWIDTH), %s, (%X/%ld\n", __func__
1442 ,dev->name, INB (OBOE_STATUS), irq->ifr_baudrate ); 1442 ,dev->name, INB (OBOE_STATUS), irq->ifr_baudrate );
1443 if (!in_interrupt () && !capable (CAP_NET_ADMIN)) { 1443 if (!in_interrupt () && !capable (CAP_NET_ADMIN)) {
1444 ret = -EPERM; 1444 ret = -EPERM;
@@ -1451,7 +1451,7 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1451 self->new_speed = irq->ifr_baudrate; 1451 self->new_speed = irq->ifr_baudrate;
1452 break; 1452 break;
1453 case SIOCSMEDIABUSY: /* Set media busy */ 1453 case SIOCSMEDIABUSY: /* Set media busy */
1454 IRDA_DEBUG (1, "%s(MEDIABUSY), %s, (%X/%x)\n", __FUNCTION__ 1454 IRDA_DEBUG (1, "%s(MEDIABUSY), %s, (%X/%x)\n", __func__
1455 ,dev->name, INB (OBOE_STATUS), capable (CAP_NET_ADMIN) ); 1455 ,dev->name, INB (OBOE_STATUS), capable (CAP_NET_ADMIN) );
1456 if (!capable (CAP_NET_ADMIN)) { 1456 if (!capable (CAP_NET_ADMIN)) {
1457 ret = -EPERM; 1457 ret = -EPERM;
@@ -1461,11 +1461,11 @@ toshoboe_net_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1461 break; 1461 break;
1462 case SIOCGRECEIVING: /* Check if we are receiving right now */ 1462 case SIOCGRECEIVING: /* Check if we are receiving right now */
1463 irq->ifr_receiving = (INB (OBOE_STATUS) & OBOE_STATUS_RXBUSY) ? 1 : 0; 1463 irq->ifr_receiving = (INB (OBOE_STATUS) & OBOE_STATUS_RXBUSY) ? 1 : 0;
1464 IRDA_DEBUG (3, "%s(RECEIVING), %s, (%X/%x)\n", __FUNCTION__ 1464 IRDA_DEBUG (3, "%s(RECEIVING), %s, (%X/%x)\n", __func__
1465 ,dev->name, INB (OBOE_STATUS), irq->ifr_receiving ); 1465 ,dev->name, INB (OBOE_STATUS), irq->ifr_receiving );
1466 break; 1466 break;
1467 default: 1467 default:
1468 IRDA_DEBUG (1, "%s(?), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd); 1468 IRDA_DEBUG (1, "%s(?), %s, (cmd=0x%X)\n", __func__, dev->name, cmd);
1469 ret = -EOPNOTSUPP; 1469 ret = -EOPNOTSUPP;
1470 } 1470 }
1471out: 1471out:
@@ -1492,7 +1492,7 @@ toshoboe_close (struct pci_dev *pci_dev)
1492 int i; 1492 int i;
1493 struct toshoboe_cb *self = (struct toshoboe_cb*)pci_get_drvdata(pci_dev); 1493 struct toshoboe_cb *self = (struct toshoboe_cb*)pci_get_drvdata(pci_dev);
1494 1494
1495 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 1495 IRDA_DEBUG (4, "%s()\n", __func__);
1496 1496
1497 IRDA_ASSERT (self != NULL, return; ); 1497 IRDA_ASSERT (self != NULL, return; );
1498 1498
@@ -1533,7 +1533,7 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid)
1533 int ok = 0; 1533 int ok = 0;
1534 int err; 1534 int err;
1535 1535
1536 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 1536 IRDA_DEBUG (4, "%s()\n", __func__);
1537 1537
1538 if ((err=pci_enable_device(pci_dev))) 1538 if ((err=pci_enable_device(pci_dev)))
1539 return err; 1539 return err;
@@ -1700,7 +1700,7 @@ toshoboe_gotosleep (struct pci_dev *pci_dev, pm_message_t crap)
1700 unsigned long flags; 1700 unsigned long flags;
1701 int i = 10; 1701 int i = 10;
1702 1702
1703 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 1703 IRDA_DEBUG (4, "%s()\n", __func__);
1704 1704
1705 if (!self || self->stopped) 1705 if (!self || self->stopped)
1706 return 0; 1706 return 0;
@@ -1728,7 +1728,7 @@ toshoboe_wakeup (struct pci_dev *pci_dev)
1728 struct toshoboe_cb *self = (struct toshoboe_cb*)pci_get_drvdata(pci_dev); 1728 struct toshoboe_cb *self = (struct toshoboe_cb*)pci_get_drvdata(pci_dev);
1729 unsigned long flags; 1729 unsigned long flags;
1730 1730
1731 IRDA_DEBUG (4, "%s()\n", __FUNCTION__); 1731 IRDA_DEBUG (4, "%s()\n", __func__);
1732 1732
1733 if (!self || !self->stopped) 1733 if (!self || !self->stopped)
1734 return 0; 1734 return 0;
diff --git a/drivers/net/irda/girbil-sir.c b/drivers/net/irda/girbil-sir.c
index 738531b16bd3..a31b8fa8aaa9 100644
--- a/drivers/net/irda/girbil-sir.c
+++ b/drivers/net/irda/girbil-sir.c
@@ -86,7 +86,7 @@ static int girbil_open(struct sir_dev *dev)
86{ 86{
87 struct qos_info *qos = &dev->qos; 87 struct qos_info *qos = &dev->qos;
88 88
89 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 89 IRDA_DEBUG(2, "%s()\n", __func__);
90 90
91 /* Power on dongle */ 91 /* Power on dongle */
92 sirdev_set_dtr_rts(dev, TRUE, TRUE); 92 sirdev_set_dtr_rts(dev, TRUE, TRUE);
@@ -102,7 +102,7 @@ static int girbil_open(struct sir_dev *dev)
102 102
103static int girbil_close(struct sir_dev *dev) 103static int girbil_close(struct sir_dev *dev)
104{ 104{
105 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 105 IRDA_DEBUG(2, "%s()\n", __func__);
106 106
107 /* Power off dongle */ 107 /* Power off dongle */
108 sirdev_set_dtr_rts(dev, FALSE, FALSE); 108 sirdev_set_dtr_rts(dev, FALSE, FALSE);
@@ -126,7 +126,7 @@ static int girbil_change_speed(struct sir_dev *dev, unsigned speed)
126 u8 control[2]; 126 u8 control[2];
127 static int ret = 0; 127 static int ret = 0;
128 128
129 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 129 IRDA_DEBUG(2, "%s()\n", __func__);
130 130
131 /* dongle alread reset - port and dongle at default speed */ 131 /* dongle alread reset - port and dongle at default speed */
132 132
@@ -179,7 +179,7 @@ static int girbil_change_speed(struct sir_dev *dev, unsigned speed)
179 break; 179 break;
180 180
181 default: 181 default:
182 IRDA_ERROR("%s - undefined state %d\n", __FUNCTION__, state); 182 IRDA_ERROR("%s - undefined state %d\n", __func__, state);
183 ret = -EINVAL; 183 ret = -EINVAL;
184 break; 184 break;
185 } 185 }
@@ -209,7 +209,7 @@ static int girbil_reset(struct sir_dev *dev)
209 u8 control = GIRBIL_TXEN | GIRBIL_RXEN; 209 u8 control = GIRBIL_TXEN | GIRBIL_RXEN;
210 int ret = 0; 210 int ret = 0;
211 211
212 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 212 IRDA_DEBUG(2, "%s()\n", __func__);
213 213
214 switch (state) { 214 switch (state) {
215 case SIRDEV_STATE_DONGLE_RESET: 215 case SIRDEV_STATE_DONGLE_RESET:
@@ -241,7 +241,7 @@ static int girbil_reset(struct sir_dev *dev)
241 break; 241 break;
242 242
243 default: 243 default:
244 IRDA_ERROR("%s(), undefined state %d\n", __FUNCTION__, state); 244 IRDA_ERROR("%s(), undefined state %d\n", __func__, state);
245 ret = -1; 245 ret = -1;
246 break; 246 break;
247 } 247 }
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 18b471cd1447..b5d6b9ac162a 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -177,12 +177,12 @@ static void irda_usb_build_header(struct irda_usb_cb *self,
177 (!force) && (self->speed != -1)) { 177 (!force) && (self->speed != -1)) {
178 /* No speed and xbofs change here 178 /* No speed and xbofs change here
179 * (we'll do it later in the write callback) */ 179 * (we'll do it later in the write callback) */
180 IRDA_DEBUG(2, "%s(), not changing speed yet\n", __FUNCTION__); 180 IRDA_DEBUG(2, "%s(), not changing speed yet\n", __func__);
181 *header = 0; 181 *header = 0;
182 return; 182 return;
183 } 183 }
184 184
185 IRDA_DEBUG(2, "%s(), changing speed to %d\n", __FUNCTION__, self->new_speed); 185 IRDA_DEBUG(2, "%s(), changing speed to %d\n", __func__, self->new_speed);
186 self->speed = self->new_speed; 186 self->speed = self->new_speed;
187 /* We will do ` self->new_speed = -1; ' in the completion 187 /* We will do ` self->new_speed = -1; ' in the completion
188 * handler just in case the current URB fail - Jean II */ 188 * handler just in case the current URB fail - Jean II */
@@ -228,7 +228,7 @@ static void irda_usb_build_header(struct irda_usb_cb *self,
228 228
229 /* Set the negotiated additional XBOFS */ 229 /* Set the negotiated additional XBOFS */
230 if (self->new_xbofs != -1) { 230 if (self->new_xbofs != -1) {
231 IRDA_DEBUG(2, "%s(), changing xbofs to %d\n", __FUNCTION__, self->new_xbofs); 231 IRDA_DEBUG(2, "%s(), changing xbofs to %d\n", __func__, self->new_xbofs);
232 self->xbofs = self->new_xbofs; 232 self->xbofs = self->new_xbofs;
233 /* We will do ` self->new_xbofs = -1; ' in the completion 233 /* We will do ` self->new_xbofs = -1; ' in the completion
234 * handler just in case the current URB fail - Jean II */ 234 * handler just in case the current URB fail - Jean II */
@@ -302,13 +302,13 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self)
302 struct urb *urb; 302 struct urb *urb;
303 int ret; 303 int ret;
304 304
305 IRDA_DEBUG(2, "%s(), speed=%d, xbofs=%d\n", __FUNCTION__, 305 IRDA_DEBUG(2, "%s(), speed=%d, xbofs=%d\n", __func__,
306 self->new_speed, self->new_xbofs); 306 self->new_speed, self->new_xbofs);
307 307
308 /* Grab the speed URB */ 308 /* Grab the speed URB */
309 urb = self->speed_urb; 309 urb = self->speed_urb;
310 if (urb->status != 0) { 310 if (urb->status != 0) {
311 IRDA_WARNING("%s(), URB still in use!\n", __FUNCTION__); 311 IRDA_WARNING("%s(), URB still in use!\n", __func__);
312 return; 312 return;
313 } 313 }
314 314
@@ -334,7 +334,7 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self)
334 334
335 /* Irq disabled -> GFP_ATOMIC */ 335 /* Irq disabled -> GFP_ATOMIC */
336 if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) { 336 if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) {
337 IRDA_WARNING("%s(), failed Speed URB\n", __FUNCTION__); 337 IRDA_WARNING("%s(), failed Speed URB\n", __func__);
338 } 338 }
339} 339}
340 340
@@ -347,7 +347,7 @@ static void speed_bulk_callback(struct urb *urb)
347{ 347{
348 struct irda_usb_cb *self = urb->context; 348 struct irda_usb_cb *self = urb->context;
349 349
350 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 350 IRDA_DEBUG(2, "%s()\n", __func__);
351 351
352 /* We should always have a context */ 352 /* We should always have a context */
353 IRDA_ASSERT(self != NULL, return;); 353 IRDA_ASSERT(self != NULL, return;);
@@ -357,7 +357,7 @@ static void speed_bulk_callback(struct urb *urb)
357 /* Check for timeout and other USB nasties */ 357 /* Check for timeout and other USB nasties */
358 if (urb->status != 0) { 358 if (urb->status != 0) {
359 /* I get a lot of -ECONNABORTED = -103 here - Jean II */ 359 /* I get a lot of -ECONNABORTED = -103 here - Jean II */
360 IRDA_DEBUG(0, "%s(), URB complete status %d, transfer_flags 0x%04X\n", __FUNCTION__, urb->status, urb->transfer_flags); 360 IRDA_DEBUG(0, "%s(), URB complete status %d, transfer_flags 0x%04X\n", __func__, urb->status, urb->transfer_flags);
361 361
362 /* Don't do anything here, that might confuse the USB layer. 362 /* Don't do anything here, that might confuse the USB layer.
363 * Instead, we will wait for irda_usb_net_timeout(), the 363 * Instead, we will wait for irda_usb_net_timeout(), the
@@ -392,7 +392,7 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
392 int res, mtt; 392 int res, mtt;
393 int err = 1; /* Failed */ 393 int err = 1; /* Failed */
394 394
395 IRDA_DEBUG(4, "%s() on %s\n", __FUNCTION__, netdev->name); 395 IRDA_DEBUG(4, "%s() on %s\n", __func__, netdev->name);
396 396
397 netif_stop_queue(netdev); 397 netif_stop_queue(netdev);
398 398
@@ -403,7 +403,7 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
403 * We need to check self->present under the spinlock because 403 * We need to check self->present under the spinlock because
404 * of irda_usb_disconnect() is synchronous - Jean II */ 404 * of irda_usb_disconnect() is synchronous - Jean II */
405 if (!self->present) { 405 if (!self->present) {
406 IRDA_DEBUG(0, "%s(), Device is gone...\n", __FUNCTION__); 406 IRDA_DEBUG(0, "%s(), Device is gone...\n", __func__);
407 goto drop; 407 goto drop;
408 } 408 }
409 409
@@ -437,7 +437,7 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
437 } 437 }
438 438
439 if (urb->status != 0) { 439 if (urb->status != 0) {
440 IRDA_WARNING("%s(), URB still in use!\n", __FUNCTION__); 440 IRDA_WARNING("%s(), URB still in use!\n", __func__);
441 goto drop; 441 goto drop;
442 } 442 }
443 443
@@ -524,7 +524,7 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
524 524
525 /* Ask USB to send the packet - Irq disabled -> GFP_ATOMIC */ 525 /* Ask USB to send the packet - Irq disabled -> GFP_ATOMIC */
526 if ((res = usb_submit_urb(urb, GFP_ATOMIC))) { 526 if ((res = usb_submit_urb(urb, GFP_ATOMIC))) {
527 IRDA_WARNING("%s(), failed Tx URB\n", __FUNCTION__); 527 IRDA_WARNING("%s(), failed Tx URB\n", __func__);
528 self->stats.tx_errors++; 528 self->stats.tx_errors++;
529 /* Let USB recover : We will catch that in the watchdog */ 529 /* Let USB recover : We will catch that in the watchdog */
530 /*netif_start_queue(netdev);*/ 530 /*netif_start_queue(netdev);*/
@@ -556,7 +556,7 @@ static void write_bulk_callback(struct urb *urb)
556 struct sk_buff *skb = urb->context; 556 struct sk_buff *skb = urb->context;
557 struct irda_usb_cb *self = ((struct irda_skb_cb *) skb->cb)->context; 557 struct irda_usb_cb *self = ((struct irda_skb_cb *) skb->cb)->context;
558 558
559 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 559 IRDA_DEBUG(2, "%s()\n", __func__);
560 560
561 /* We should always have a context */ 561 /* We should always have a context */
562 IRDA_ASSERT(self != NULL, return;); 562 IRDA_ASSERT(self != NULL, return;);
@@ -570,7 +570,7 @@ static void write_bulk_callback(struct urb *urb)
570 /* Check for timeout and other USB nasties */ 570 /* Check for timeout and other USB nasties */
571 if (urb->status != 0) { 571 if (urb->status != 0) {
572 /* I get a lot of -ECONNABORTED = -103 here - Jean II */ 572 /* I get a lot of -ECONNABORTED = -103 here - Jean II */
573 IRDA_DEBUG(0, "%s(), URB complete status %d, transfer_flags 0x%04X\n", __FUNCTION__, urb->status, urb->transfer_flags); 573 IRDA_DEBUG(0, "%s(), URB complete status %d, transfer_flags 0x%04X\n", __func__, urb->status, urb->transfer_flags);
574 574
575 /* Don't do anything here, that might confuse the USB layer, 575 /* Don't do anything here, that might confuse the USB layer,
576 * and we could go in recursion and blow the kernel stack... 576 * and we could go in recursion and blow the kernel stack...
@@ -589,7 +589,7 @@ static void write_bulk_callback(struct urb *urb)
589 589
590 /* If the network is closed, stop everything */ 590 /* If the network is closed, stop everything */
591 if ((!self->netopen) || (!self->present)) { 591 if ((!self->netopen) || (!self->present)) {
592 IRDA_DEBUG(0, "%s(), Network is gone...\n", __FUNCTION__); 592 IRDA_DEBUG(0, "%s(), Network is gone...\n", __func__);
593 spin_unlock_irqrestore(&self->lock, flags); 593 spin_unlock_irqrestore(&self->lock, flags);
594 return; 594 return;
595 } 595 }
@@ -600,7 +600,7 @@ static void write_bulk_callback(struct urb *urb)
600 (self->new_xbofs != self->xbofs)) { 600 (self->new_xbofs != self->xbofs)) {
601 /* We haven't changed speed yet (because of 601 /* We haven't changed speed yet (because of
602 * IUC_SPEED_BUG), so do it now - Jean II */ 602 * IUC_SPEED_BUG), so do it now - Jean II */
603 IRDA_DEBUG(1, "%s(), Changing speed now...\n", __FUNCTION__); 603 IRDA_DEBUG(1, "%s(), Changing speed now...\n", __func__);
604 irda_usb_change_speed_xbofs(self); 604 irda_usb_change_speed_xbofs(self);
605 } else { 605 } else {
606 /* New speed and xbof is now commited in hardware */ 606 /* New speed and xbof is now commited in hardware */
@@ -632,7 +632,7 @@ static void irda_usb_net_timeout(struct net_device *netdev)
632 struct urb *urb; 632 struct urb *urb;
633 int done = 0; /* If we have made any progress */ 633 int done = 0; /* If we have made any progress */
634 634
635 IRDA_DEBUG(0, "%s(), Network layer thinks we timed out!\n", __FUNCTION__); 635 IRDA_DEBUG(0, "%s(), Network layer thinks we timed out!\n", __func__);
636 IRDA_ASSERT(self != NULL, return;); 636 IRDA_ASSERT(self != NULL, return;);
637 637
638 /* Protect us from USB callbacks, net Tx and else. */ 638 /* Protect us from USB callbacks, net Tx and else. */
@@ -640,7 +640,7 @@ static void irda_usb_net_timeout(struct net_device *netdev)
640 640
641 /* self->present *MUST* be read under spinlock */ 641 /* self->present *MUST* be read under spinlock */
642 if (!self->present) { 642 if (!self->present) {
643 IRDA_WARNING("%s(), device not present!\n", __FUNCTION__); 643 IRDA_WARNING("%s(), device not present!\n", __func__);
644 netif_stop_queue(netdev); 644 netif_stop_queue(netdev);
645 spin_unlock_irqrestore(&self->lock, flags); 645 spin_unlock_irqrestore(&self->lock, flags);
646 return; 646 return;
@@ -763,7 +763,7 @@ static void irda_usb_submit(struct irda_usb_cb *self, struct sk_buff *skb, struc
763 struct irda_skb_cb *cb; 763 struct irda_skb_cb *cb;
764 int ret; 764 int ret;
765 765
766 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 766 IRDA_DEBUG(2, "%s()\n", __func__);
767 767
768 /* This should never happen */ 768 /* This should never happen */
769 IRDA_ASSERT(skb != NULL, return;); 769 IRDA_ASSERT(skb != NULL, return;);
@@ -786,7 +786,7 @@ static void irda_usb_submit(struct irda_usb_cb *self, struct sk_buff *skb, struc
786 /* If this ever happen, we are in deep s***. 786 /* If this ever happen, we are in deep s***.
787 * Basically, the Rx path will stop... */ 787 * Basically, the Rx path will stop... */
788 IRDA_WARNING("%s(), Failed to submit Rx URB %d\n", 788 IRDA_WARNING("%s(), Failed to submit Rx URB %d\n",
789 __FUNCTION__, ret); 789 __func__, ret);
790 } 790 }
791} 791}
792 792
@@ -807,7 +807,7 @@ static void irda_usb_receive(struct urb *urb)
807 struct urb *next_urb; 807 struct urb *next_urb;
808 unsigned int len, docopy; 808 unsigned int len, docopy;
809 809
810 IRDA_DEBUG(2, "%s(), len=%d\n", __FUNCTION__, urb->actual_length); 810 IRDA_DEBUG(2, "%s(), len=%d\n", __func__, urb->actual_length);
811 811
812 /* Find ourselves */ 812 /* Find ourselves */
813 cb = (struct irda_skb_cb *) skb->cb; 813 cb = (struct irda_skb_cb *) skb->cb;
@@ -817,7 +817,7 @@ static void irda_usb_receive(struct urb *urb)
817 817
818 /* If the network is closed or the device gone, stop everything */ 818 /* If the network is closed or the device gone, stop everything */
819 if ((!self->netopen) || (!self->present)) { 819 if ((!self->netopen) || (!self->present)) {
820 IRDA_DEBUG(0, "%s(), Network is gone!\n", __FUNCTION__); 820 IRDA_DEBUG(0, "%s(), Network is gone!\n", __func__);
821 /* Don't re-submit the URB : will stall the Rx path */ 821 /* Don't re-submit the URB : will stall the Rx path */
822 return; 822 return;
823 } 823 }
@@ -840,7 +840,7 @@ static void irda_usb_receive(struct urb *urb)
840 /* Usually precursor to a hot-unplug on OHCI. */ 840 /* Usually precursor to a hot-unplug on OHCI. */
841 default: 841 default:
842 self->stats.rx_errors++; 842 self->stats.rx_errors++;
843 IRDA_DEBUG(0, "%s(), RX status %d, transfer_flags 0x%04X \n", __FUNCTION__, urb->status, urb->transfer_flags); 843 IRDA_DEBUG(0, "%s(), RX status %d, transfer_flags 0x%04X \n", __func__, urb->status, urb->transfer_flags);
844 break; 844 break;
845 } 845 }
846 /* If we received an error, we don't want to resubmit the 846 /* If we received an error, we don't want to resubmit the
@@ -861,7 +861,7 @@ static void irda_usb_receive(struct urb *urb)
861 861
862 /* Check for empty frames */ 862 /* Check for empty frames */
863 if (urb->actual_length <= self->header_length) { 863 if (urb->actual_length <= self->header_length) {
864 IRDA_WARNING("%s(), empty frame!\n", __FUNCTION__); 864 IRDA_WARNING("%s(), empty frame!\n", __func__);
865 goto done; 865 goto done;
866 } 866 }
867 867
@@ -967,7 +967,7 @@ static void irda_usb_rx_defer_expired(unsigned long data)
967 struct irda_skb_cb *cb; 967 struct irda_skb_cb *cb;
968 struct urb *next_urb; 968 struct urb *next_urb;
969 969
970 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 970 IRDA_DEBUG(2, "%s()\n", __func__);
971 971
972 /* Find ourselves */ 972 /* Find ourselves */
973 cb = (struct irda_skb_cb *) skb->cb; 973 cb = (struct irda_skb_cb *) skb->cb;
@@ -1053,7 +1053,7 @@ static int stir421x_fw_upload(struct irda_usb_cb *self,
1053 patch_block, block_size, 1053 patch_block, block_size,
1054 &actual_len, msecs_to_jiffies(500)); 1054 &actual_len, msecs_to_jiffies(500));
1055 IRDA_DEBUG(3,"%s(): Bulk send %u bytes, ret=%d\n", 1055 IRDA_DEBUG(3,"%s(): Bulk send %u bytes, ret=%d\n",
1056 __FUNCTION__, actual_len, ret); 1056 __func__, actual_len, ret);
1057 1057
1058 if (ret < 0) 1058 if (ret < 0)
1059 break; 1059 break;
@@ -1092,7 +1092,7 @@ static int stir421x_patch_device(struct irda_usb_cb *self)
1092 1092
1093 /* We get a patch from userspace */ 1093 /* We get a patch from userspace */
1094 IRDA_MESSAGE("%s(): Received firmware %s (%zu bytes)\n", 1094 IRDA_MESSAGE("%s(): Received firmware %s (%zu bytes)\n",
1095 __FUNCTION__, stir421x_fw_name, fw->size); 1095 __func__, stir421x_fw_name, fw->size);
1096 1096
1097 ret = -EINVAL; 1097 ret = -EINVAL;
1098 1098
@@ -1116,7 +1116,7 @@ static int stir421x_patch_device(struct irda_usb_cb *self)
1116 + (build % 10); 1116 + (build % 10);
1117 1117
1118 IRDA_DEBUG(3, "%s(): Firmware Product version %ld\n", 1118 IRDA_DEBUG(3, "%s(): Firmware Product version %ld\n",
1119 __FUNCTION__, fw_version); 1119 __func__, fw_version);
1120 } 1120 }
1121 } 1121 }
1122 1122
@@ -1172,7 +1172,7 @@ static int irda_usb_net_open(struct net_device *netdev)
1172 char hwname[16]; 1172 char hwname[16];
1173 int i; 1173 int i;
1174 1174
1175 IRDA_DEBUG(1, "%s()\n", __FUNCTION__); 1175 IRDA_DEBUG(1, "%s()\n", __func__);
1176 1176
1177 IRDA_ASSERT(netdev != NULL, return -1;); 1177 IRDA_ASSERT(netdev != NULL, return -1;);
1178 self = (struct irda_usb_cb *) netdev->priv; 1178 self = (struct irda_usb_cb *) netdev->priv;
@@ -1182,13 +1182,13 @@ static int irda_usb_net_open(struct net_device *netdev)
1182 /* Can only open the device if it's there */ 1182 /* Can only open the device if it's there */
1183 if(!self->present) { 1183 if(!self->present) {
1184 spin_unlock_irqrestore(&self->lock, flags); 1184 spin_unlock_irqrestore(&self->lock, flags);
1185 IRDA_WARNING("%s(), device not present!\n", __FUNCTION__); 1185 IRDA_WARNING("%s(), device not present!\n", __func__);
1186 return -1; 1186 return -1;
1187 } 1187 }
1188 1188
1189 if(self->needspatch) { 1189 if(self->needspatch) {
1190 spin_unlock_irqrestore(&self->lock, flags); 1190 spin_unlock_irqrestore(&self->lock, flags);
1191 IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ; 1191 IRDA_WARNING("%s(), device needs patch\n", __func__) ;
1192 return -EIO ; 1192 return -EIO ;
1193 } 1193 }
1194 1194
@@ -1231,7 +1231,7 @@ static int irda_usb_net_open(struct net_device *netdev)
1231 /* If this ever happen, we are in deep s***. 1231 /* If this ever happen, we are in deep s***.
1232 * Basically, we can't start the Rx path... */ 1232 * Basically, we can't start the Rx path... */
1233 IRDA_WARNING("%s(), Failed to allocate Rx skb\n", 1233 IRDA_WARNING("%s(), Failed to allocate Rx skb\n",
1234 __FUNCTION__); 1234 __func__);
1235 return -1; 1235 return -1;
1236 } 1236 }
1237 //skb_reserve(newskb, USB_IRDA_HEADER - 1); 1237 //skb_reserve(newskb, USB_IRDA_HEADER - 1);
@@ -1254,7 +1254,7 @@ static int irda_usb_net_close(struct net_device *netdev)
1254 struct irda_usb_cb *self; 1254 struct irda_usb_cb *self;
1255 int i; 1255 int i;
1256 1256
1257 IRDA_DEBUG(1, "%s()\n", __FUNCTION__); 1257 IRDA_DEBUG(1, "%s()\n", __func__);
1258 1258
1259 IRDA_ASSERT(netdev != NULL, return -1;); 1259 IRDA_ASSERT(netdev != NULL, return -1;);
1260 self = (struct irda_usb_cb *) netdev->priv; 1260 self = (struct irda_usb_cb *) netdev->priv;
@@ -1309,7 +1309,7 @@ static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1309 self = dev->priv; 1309 self = dev->priv;
1310 IRDA_ASSERT(self != NULL, return -1;); 1310 IRDA_ASSERT(self != NULL, return -1;);
1311 1311
1312 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd); 1312 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name, cmd);
1313 1313
1314 switch (cmd) { 1314 switch (cmd) {
1315 case SIOCSBANDWIDTH: /* Set bandwidth */ 1315 case SIOCSBANDWIDTH: /* Set bandwidth */
@@ -1367,7 +1367,7 @@ static inline void irda_usb_init_qos(struct irda_usb_cb *self)
1367{ 1367{
1368 struct irda_class_desc *desc; 1368 struct irda_class_desc *desc;
1369 1369
1370 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 1370 IRDA_DEBUG(3, "%s()\n", __func__);
1371 1371
1372 desc = self->irda_desc; 1372 desc = self->irda_desc;
1373 1373
@@ -1384,7 +1384,7 @@ static inline void irda_usb_init_qos(struct irda_usb_cb *self)
1384 self->qos.data_size.bits = desc->bmDataSize; 1384 self->qos.data_size.bits = desc->bmDataSize;
1385 1385
1386 IRDA_DEBUG(0, "%s(), dongle says speed=0x%X, size=0x%X, window=0x%X, bofs=0x%X, turn=0x%X\n", 1386 IRDA_DEBUG(0, "%s(), dongle says speed=0x%X, size=0x%X, window=0x%X, bofs=0x%X, turn=0x%X\n",
1387 __FUNCTION__, self->qos.baud_rate.bits, self->qos.data_size.bits, self->qos.window_size.bits, self->qos.additional_bofs.bits, self->qos.min_turn_time.bits); 1387 __func__, self->qos.baud_rate.bits, self->qos.data_size.bits, self->qos.window_size.bits, self->qos.additional_bofs.bits, self->qos.min_turn_time.bits);
1388 1388
1389 /* Don't always trust what the dongle tell us */ 1389 /* Don't always trust what the dongle tell us */
1390 if(self->capability & IUC_SIR_ONLY) 1390 if(self->capability & IUC_SIR_ONLY)
@@ -1419,7 +1419,7 @@ static inline int irda_usb_open(struct irda_usb_cb *self)
1419{ 1419{
1420 struct net_device *netdev = self->netdev; 1420 struct net_device *netdev = self->netdev;
1421 1421
1422 IRDA_DEBUG(1, "%s()\n", __FUNCTION__); 1422 IRDA_DEBUG(1, "%s()\n", __func__);
1423 1423
1424 irda_usb_init_qos(self); 1424 irda_usb_init_qos(self);
1425 1425
@@ -1442,7 +1442,7 @@ static inline int irda_usb_open(struct irda_usb_cb *self)
1442 */ 1442 */
1443static inline void irda_usb_close(struct irda_usb_cb *self) 1443static inline void irda_usb_close(struct irda_usb_cb *self)
1444{ 1444{
1445 IRDA_DEBUG(1, "%s()\n", __FUNCTION__); 1445 IRDA_DEBUG(1, "%s()\n", __func__);
1446 1446
1447 /* Remove netdevice */ 1447 /* Remove netdevice */
1448 unregister_netdev(self->netdev); 1448 unregister_netdev(self->netdev);
@@ -1515,13 +1515,13 @@ static inline int irda_usb_parse_endpoints(struct irda_usb_cb *self, struct usb_
1515 /* This is our interrupt endpoint */ 1515 /* This is our interrupt endpoint */
1516 self->bulk_int_ep = ep; 1516 self->bulk_int_ep = ep;
1517 } else { 1517 } else {
1518 IRDA_ERROR("%s(), Unrecognised endpoint %02X.\n", __FUNCTION__, ep); 1518 IRDA_ERROR("%s(), Unrecognised endpoint %02X.\n", __func__, ep);
1519 } 1519 }
1520 } 1520 }
1521 } 1521 }
1522 1522
1523 IRDA_DEBUG(0, "%s(), And our endpoints are : in=%02X, out=%02X (%d), int=%02X\n", 1523 IRDA_DEBUG(0, "%s(), And our endpoints are : in=%02X, out=%02X (%d), int=%02X\n",
1524 __FUNCTION__, self->bulk_in_ep, self->bulk_out_ep, self->bulk_out_mtu, self->bulk_int_ep); 1524 __func__, self->bulk_in_ep, self->bulk_out_ep, self->bulk_out_mtu, self->bulk_int_ep);
1525 1525
1526 return((self->bulk_in_ep != 0) && (self->bulk_out_ep != 0)); 1526 return((self->bulk_in_ep != 0) && (self->bulk_out_ep != 0));
1527} 1527}
@@ -1583,7 +1583,7 @@ static inline struct irda_class_desc *irda_usb_find_class_desc(struct usb_interf
1583 0, intf->altsetting->desc.bInterfaceNumber, desc, 1583 0, intf->altsetting->desc.bInterfaceNumber, desc,
1584 sizeof(*desc), 500); 1584 sizeof(*desc), 500);
1585 1585
1586 IRDA_DEBUG(1, "%s(), ret=%d\n", __FUNCTION__, ret); 1586 IRDA_DEBUG(1, "%s(), ret=%d\n", __func__, ret);
1587 if (ret < sizeof(*desc)) { 1587 if (ret < sizeof(*desc)) {
1588 IRDA_WARNING("usb-irda: class_descriptor read %s (%d)\n", 1588 IRDA_WARNING("usb-irda: class_descriptor read %s (%d)\n",
1589 (ret<0) ? "failed" : "too short", ret); 1589 (ret<0) ? "failed" : "too short", ret);
@@ -1696,10 +1696,10 @@ static int irda_usb_probe(struct usb_interface *intf,
1696 /* Martin Diehl says if we get a -EPIPE we should 1696 /* Martin Diehl says if we get a -EPIPE we should
1697 * be fine and we don't need to do a usb_clear_halt(). 1697 * be fine and we don't need to do a usb_clear_halt().
1698 * - Jean II */ 1698 * - Jean II */
1699 IRDA_DEBUG(0, "%s(), Received -EPIPE, ignoring...\n", __FUNCTION__); 1699 IRDA_DEBUG(0, "%s(), Received -EPIPE, ignoring...\n", __func__);
1700 break; 1700 break;
1701 default: 1701 default:
1702 IRDA_DEBUG(0, "%s(), Unknown error %d\n", __FUNCTION__, ret); 1702 IRDA_DEBUG(0, "%s(), Unknown error %d\n", __func__, ret);
1703 ret = -EIO; 1703 ret = -EIO;
1704 goto err_out_3; 1704 goto err_out_3;
1705 } 1705 }
@@ -1708,7 +1708,7 @@ static int irda_usb_probe(struct usb_interface *intf,
1708 interface = intf->cur_altsetting; 1708 interface = intf->cur_altsetting;
1709 if(!irda_usb_parse_endpoints(self, interface->endpoint, 1709 if(!irda_usb_parse_endpoints(self, interface->endpoint,
1710 interface->desc.bNumEndpoints)) { 1710 interface->desc.bNumEndpoints)) {
1711 IRDA_ERROR("%s(), Bogus endpoints...\n", __FUNCTION__); 1711 IRDA_ERROR("%s(), Bogus endpoints...\n", __func__);
1712 ret = -EIO; 1712 ret = -EIO;
1713 goto err_out_3; 1713 goto err_out_3;
1714 } 1714 }
@@ -1815,7 +1815,7 @@ static void irda_usb_disconnect(struct usb_interface *intf)
1815 struct irda_usb_cb *self = usb_get_intfdata(intf); 1815 struct irda_usb_cb *self = usb_get_intfdata(intf);
1816 int i; 1816 int i;
1817 1817
1818 IRDA_DEBUG(1, "%s()\n", __FUNCTION__); 1818 IRDA_DEBUG(1, "%s()\n", __func__);
1819 1819
1820 usb_set_intfdata(intf, NULL); 1820 usb_set_intfdata(intf, NULL);
1821 if (!self) 1821 if (!self)
@@ -1865,7 +1865,7 @@ static void irda_usb_disconnect(struct usb_interface *intf)
1865 1865
1866 /* Free self and network device */ 1866 /* Free self and network device */
1867 free_netdev(self->netdev); 1867 free_netdev(self->netdev);
1868 IRDA_DEBUG(0, "%s(), USB IrDA Disconnected\n", __FUNCTION__); 1868 IRDA_DEBUG(0, "%s(), USB IrDA Disconnected\n", __func__);
1869} 1869}
1870 1870
1871/*------------------------------------------------------------------*/ 1871/*------------------------------------------------------------------*/
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 9e33196f9459..6bcee01c684c 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -231,7 +231,7 @@ static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
231 231
232 dev = priv->dev; 232 dev = priv->dev;
233 if (!dev) { 233 if (!dev) {
234 IRDA_WARNING("%s(), not ready yet!\n", __FUNCTION__); 234 IRDA_WARNING("%s(), not ready yet!\n", __func__);
235 return; 235 return;
236 } 236 }
237 237
@@ -388,7 +388,7 @@ static int irtty_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
388 IRDA_ASSERT(priv != NULL, return -ENODEV;); 388 IRDA_ASSERT(priv != NULL, return -ENODEV;);
389 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -EBADR;); 389 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -EBADR;);
390 390
391 IRDA_DEBUG(3, "%s(cmd=0x%X)\n", __FUNCTION__, cmd); 391 IRDA_DEBUG(3, "%s(cmd=0x%X)\n", __func__, cmd);
392 392
393 dev = priv->dev; 393 dev = priv->dev;
394 IRDA_ASSERT(dev != NULL, return -1;); 394 IRDA_ASSERT(dev != NULL, return -1;);
@@ -476,7 +476,7 @@ static int irtty_open(struct tty_struct *tty)
476 476
477 mutex_unlock(&irtty_mutex); 477 mutex_unlock(&irtty_mutex);
478 478
479 IRDA_DEBUG(0, "%s - %s: irda line discipline opened\n", __FUNCTION__, tty->name); 479 IRDA_DEBUG(0, "%s - %s: irda line discipline opened\n", __func__, tty->name);
480 480
481 return 0; 481 return 0;
482 482
@@ -528,7 +528,7 @@ static void irtty_close(struct tty_struct *tty)
528 528
529 kfree(priv); 529 kfree(priv);
530 530
531 IRDA_DEBUG(0, "%s - %s: irda line discipline closed\n", __FUNCTION__, tty->name); 531 IRDA_DEBUG(0, "%s - %s: irda line discipline closed\n", __func__, tty->name);
532} 532}
533 533
534/* ------------------------------------------------------- */ 534/* ------------------------------------------------------- */
@@ -566,7 +566,7 @@ static void __exit irtty_sir_cleanup(void)
566 566
567 if ((err = tty_unregister_ldisc(N_IRDA))) { 567 if ((err = tty_unregister_ldisc(N_IRDA))) {
568 IRDA_ERROR("%s(), can't unregister line discipline (err = %d)\n", 568 IRDA_ERROR("%s(), can't unregister line discipline (err = %d)\n",
569 __FUNCTION__, err); 569 __func__, err);
570 } 570 }
571} 571}
572 572
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c
index 648e54b3f00e..73fe83be34fe 100644
--- a/drivers/net/irda/kingsun-sir.c
+++ b/drivers/net/irda/kingsun-sir.c
@@ -243,7 +243,7 @@ static void kingsun_rcv_irq(struct urb *urb)
243 } 243 }
244 } else if (urb->actual_length > 0) { 244 } else if (urb->actual_length > 0) {
245 err("%s(): Unexpected response length, expected %d got %d", 245 err("%s(): Unexpected response length, expected %d got %d",
246 __FUNCTION__, kingsun->max_rx, urb->actual_length); 246 __func__, kingsun->max_rx, urb->actual_length);
247 } 247 }
248 /* This urb has already been filled in kingsun_net_open */ 248 /* This urb has already been filled in kingsun_net_open */
249 ret = usb_submit_urb(urb, GFP_ATOMIC); 249 ret = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/net/irda/litelink-sir.c b/drivers/net/irda/litelink-sir.c
index 73261c54bbfd..d6d9d2e5ad49 100644
--- a/drivers/net/irda/litelink-sir.c
+++ b/drivers/net/irda/litelink-sir.c
@@ -78,7 +78,7 @@ static int litelink_open(struct sir_dev *dev)
78{ 78{
79 struct qos_info *qos = &dev->qos; 79 struct qos_info *qos = &dev->qos;
80 80
81 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 81 IRDA_DEBUG(2, "%s()\n", __func__);
82 82
83 /* Power up dongle */ 83 /* Power up dongle */
84 sirdev_set_dtr_rts(dev, TRUE, TRUE); 84 sirdev_set_dtr_rts(dev, TRUE, TRUE);
@@ -95,7 +95,7 @@ static int litelink_open(struct sir_dev *dev)
95 95
96static int litelink_close(struct sir_dev *dev) 96static int litelink_close(struct sir_dev *dev)
97{ 97{
98 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 98 IRDA_DEBUG(2, "%s()\n", __func__);
99 99
100 /* Power off dongle */ 100 /* Power off dongle */
101 sirdev_set_dtr_rts(dev, FALSE, FALSE); 101 sirdev_set_dtr_rts(dev, FALSE, FALSE);
@@ -113,7 +113,7 @@ static int litelink_change_speed(struct sir_dev *dev, unsigned speed)
113{ 113{
114 int i; 114 int i;
115 115
116 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 116 IRDA_DEBUG(2, "%s()\n", __func__);
117 117
118 /* dongle already reset by irda-thread - current speed (dongle and 118 /* dongle already reset by irda-thread - current speed (dongle and
119 * port) is the default speed (115200 for litelink!) 119 * port) is the default speed (115200 for litelink!)
@@ -156,7 +156,7 @@ static int litelink_change_speed(struct sir_dev *dev, unsigned speed)
156 */ 156 */
157static int litelink_reset(struct sir_dev *dev) 157static int litelink_reset(struct sir_dev *dev)
158{ 158{
159 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 159 IRDA_DEBUG(2, "%s()\n", __func__);
160 160
161 /* probably the power-up can be dropped here, but with only 161 /* probably the power-up can be dropped here, but with only
162 * 15 usec delay it's not worth the risk unless somebody with 162 * 15 usec delay it's not worth the risk unless somebody with
diff --git a/drivers/net/irda/ma600-sir.c b/drivers/net/irda/ma600-sir.c
index 809906d94762..1ceed9cfb7c4 100644
--- a/drivers/net/irda/ma600-sir.c
+++ b/drivers/net/irda/ma600-sir.c
@@ -67,13 +67,13 @@ static struct dongle_driver ma600 = {
67 67
68static int __init ma600_sir_init(void) 68static int __init ma600_sir_init(void)
69{ 69{
70 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 70 IRDA_DEBUG(2, "%s()\n", __func__);
71 return irda_register_dongle(&ma600); 71 return irda_register_dongle(&ma600);
72} 72}
73 73
74static void __exit ma600_sir_cleanup(void) 74static void __exit ma600_sir_cleanup(void)
75{ 75{
76 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 76 IRDA_DEBUG(2, "%s()\n", __func__);
77 irda_unregister_dongle(&ma600); 77 irda_unregister_dongle(&ma600);
78} 78}
79 79
@@ -88,7 +88,7 @@ static int ma600_open(struct sir_dev *dev)
88{ 88{
89 struct qos_info *qos = &dev->qos; 89 struct qos_info *qos = &dev->qos;
90 90
91 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 91 IRDA_DEBUG(2, "%s()\n", __func__);
92 92
93 sirdev_set_dtr_rts(dev, TRUE, TRUE); 93 sirdev_set_dtr_rts(dev, TRUE, TRUE);
94 94
@@ -106,7 +106,7 @@ static int ma600_open(struct sir_dev *dev)
106 106
107static int ma600_close(struct sir_dev *dev) 107static int ma600_close(struct sir_dev *dev)
108{ 108{
109 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 109 IRDA_DEBUG(2, "%s()\n", __func__);
110 110
111 /* Power off dongle */ 111 /* Power off dongle */
112 sirdev_set_dtr_rts(dev, FALSE, FALSE); 112 sirdev_set_dtr_rts(dev, FALSE, FALSE);
@@ -176,7 +176,7 @@ static int ma600_change_speed(struct sir_dev *dev, unsigned speed)
176{ 176{
177 u8 byte; 177 u8 byte;
178 178
179 IRDA_DEBUG(2, "%s(), speed=%d (was %d)\n", __FUNCTION__, 179 IRDA_DEBUG(2, "%s(), speed=%d (was %d)\n", __func__,
180 speed, dev->speed); 180 speed, dev->speed);
181 181
182 /* dongle already reset, dongle and port at default speed (9600) */ 182 /* dongle already reset, dongle and port at default speed (9600) */
@@ -201,12 +201,12 @@ static int ma600_change_speed(struct sir_dev *dev, unsigned speed)
201 sirdev_raw_read(dev, &byte, sizeof(byte)); 201 sirdev_raw_read(dev, &byte, sizeof(byte));
202 if (byte != get_control_byte(speed)) { 202 if (byte != get_control_byte(speed)) {
203 IRDA_WARNING("%s(): bad control byte read-back %02x != %02x\n", 203 IRDA_WARNING("%s(): bad control byte read-back %02x != %02x\n",
204 __FUNCTION__, (unsigned) byte, 204 __func__, (unsigned) byte,
205 (unsigned) get_control_byte(speed)); 205 (unsigned) get_control_byte(speed));
206 return -1; 206 return -1;
207 } 207 }
208 else 208 else
209 IRDA_DEBUG(2, "%s() control byte write read OK\n", __FUNCTION__); 209 IRDA_DEBUG(2, "%s() control byte write read OK\n", __func__);
210#endif 210#endif
211 211
212 /* Set DTR, Set RTS */ 212 /* Set DTR, Set RTS */
@@ -238,7 +238,7 @@ static int ma600_change_speed(struct sir_dev *dev, unsigned speed)
238 238
239int ma600_reset(struct sir_dev *dev) 239int ma600_reset(struct sir_dev *dev)
240{ 240{
241 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 241 IRDA_DEBUG(2, "%s()\n", __func__);
242 242
243 /* Reset the dongle : set DTR low for 10 ms */ 243 /* Reset the dongle : set DTR low for 10 ms */
244 sirdev_set_dtr_rts(dev, FALSE, TRUE); 244 sirdev_set_dtr_rts(dev, FALSE, TRUE);
diff --git a/drivers/net/irda/mcp2120-sir.c b/drivers/net/irda/mcp2120-sir.c
index 67bd016e4df8..5e2f4859cee7 100644
--- a/drivers/net/irda/mcp2120-sir.c
+++ b/drivers/net/irda/mcp2120-sir.c
@@ -63,7 +63,7 @@ static int mcp2120_open(struct sir_dev *dev)
63{ 63{
64 struct qos_info *qos = &dev->qos; 64 struct qos_info *qos = &dev->qos;
65 65
66 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 66 IRDA_DEBUG(2, "%s()\n", __func__);
67 67
68 /* seems no explicit power-on required here and reset switching it on anyway */ 68 /* seems no explicit power-on required here and reset switching it on anyway */
69 69
@@ -76,7 +76,7 @@ static int mcp2120_open(struct sir_dev *dev)
76 76
77static int mcp2120_close(struct sir_dev *dev) 77static int mcp2120_close(struct sir_dev *dev)
78{ 78{
79 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 79 IRDA_DEBUG(2, "%s()\n", __func__);
80 80
81 /* Power off dongle */ 81 /* Power off dongle */
82 /* reset and inhibit mcp2120 */ 82 /* reset and inhibit mcp2120 */
@@ -102,7 +102,7 @@ static int mcp2120_change_speed(struct sir_dev *dev, unsigned speed)
102 u8 control[2]; 102 u8 control[2];
103 static int ret = 0; 103 static int ret = 0;
104 104
105 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 105 IRDA_DEBUG(2, "%s()\n", __func__);
106 106
107 switch (state) { 107 switch (state) {
108 case SIRDEV_STATE_DONGLE_SPEED: 108 case SIRDEV_STATE_DONGLE_SPEED:
@@ -155,7 +155,7 @@ static int mcp2120_change_speed(struct sir_dev *dev, unsigned speed)
155 break; 155 break;
156 156
157 default: 157 default:
158 IRDA_ERROR("%s(), undefine state %d\n", __FUNCTION__, state); 158 IRDA_ERROR("%s(), undefine state %d\n", __func__, state);
159 ret = -EINVAL; 159 ret = -EINVAL;
160 break; 160 break;
161 } 161 }
@@ -187,7 +187,7 @@ static int mcp2120_reset(struct sir_dev *dev)
187 unsigned delay = 0; 187 unsigned delay = 0;
188 int ret = 0; 188 int ret = 0;
189 189
190 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 190 IRDA_DEBUG(2, "%s()\n", __func__);
191 191
192 switch (state) { 192 switch (state) {
193 case SIRDEV_STATE_DONGLE_RESET: 193 case SIRDEV_STATE_DONGLE_RESET:
@@ -213,7 +213,7 @@ static int mcp2120_reset(struct sir_dev *dev)
213 break; 213 break;
214 214
215 default: 215 default:
216 IRDA_ERROR("%s(), undefined state %d\n", __FUNCTION__, state); 216 IRDA_ERROR("%s(), undefined state %d\n", __func__, state);
217 ret = -EINVAL; 217 ret = -EINVAL;
218 break; 218 break;
219 } 219 }
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index effc1ce8179a..8583d951a6ad 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -151,8 +151,8 @@ static char *dongle_types[] = {
151static chipio_t pnp_info; 151static chipio_t pnp_info;
152static const struct pnp_device_id nsc_ircc_pnp_table[] = { 152static const struct pnp_device_id nsc_ircc_pnp_table[] = {
153 { .id = "NSC6001", .driver_data = 0 }, 153 { .id = "NSC6001", .driver_data = 0 },
154 { .id = "IBM0071", .driver_data = 0 },
155 { .id = "HWPC224", .driver_data = 0 }, 154 { .id = "HWPC224", .driver_data = 0 },
155 { .id = "IBM0071", .driver_data = NSC_FORCE_DONGLE_TYPE9 },
156 { } 156 { }
157}; 157};
158 158
@@ -223,7 +223,7 @@ static int __init nsc_ircc_init(void)
223 223
224 /* Probe for all the NSC chipsets we know about */ 224 /* Probe for all the NSC chipsets we know about */
225 for (chip = chips; chip->name ; chip++) { 225 for (chip = chips; chip->name ; chip++) {
226 IRDA_DEBUG(2, "%s(), Probing for %s ...\n", __FUNCTION__, 226 IRDA_DEBUG(2, "%s(), Probing for %s ...\n", __func__,
227 chip->name); 227 chip->name);
228 228
229 /* Try all config registers for this chip */ 229 /* Try all config registers for this chip */
@@ -235,7 +235,7 @@ static int __init nsc_ircc_init(void)
235 /* Read index register */ 235 /* Read index register */
236 reg = inb(cfg_base); 236 reg = inb(cfg_base);
237 if (reg == 0xff) { 237 if (reg == 0xff) {
238 IRDA_DEBUG(2, "%s() no chip at 0x%03x\n", __FUNCTION__, cfg_base); 238 IRDA_DEBUG(2, "%s() no chip at 0x%03x\n", __func__, cfg_base);
239 continue; 239 continue;
240 } 240 }
241 241
@@ -244,7 +244,7 @@ static int __init nsc_ircc_init(void)
244 id = inb(cfg_base+1); 244 id = inb(cfg_base+1);
245 if ((id & chip->cid_mask) == chip->cid_value) { 245 if ((id & chip->cid_mask) == chip->cid_value) {
246 IRDA_DEBUG(2, "%s() Found %s chip, revision=%d\n", 246 IRDA_DEBUG(2, "%s() Found %s chip, revision=%d\n",
247 __FUNCTION__, chip->name, id & ~chip->cid_mask); 247 __func__, chip->name, id & ~chip->cid_mask);
248 248
249 /* 249 /*
250 * If we found a correct PnP setting, 250 * If we found a correct PnP setting,
@@ -295,7 +295,7 @@ static int __init nsc_ircc_init(void)
295 } 295 }
296 i++; 296 i++;
297 } else { 297 } else {
298 IRDA_DEBUG(2, "%s(), Wrong chip id=0x%02x\n", __FUNCTION__, id); 298 IRDA_DEBUG(2, "%s(), Wrong chip id=0x%02x\n", __func__, id);
299 } 299 }
300 } 300 }
301 } 301 }
@@ -345,7 +345,7 @@ static int __init nsc_ircc_open(chipio_t *info)
345 void *ret; 345 void *ret;
346 int err, chip_index; 346 int err, chip_index;
347 347
348 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 348 IRDA_DEBUG(2, "%s()\n", __func__);
349 349
350 350
351 for (chip_index = 0; chip_index < ARRAY_SIZE(dev_self); chip_index++) { 351 for (chip_index = 0; chip_index < ARRAY_SIZE(dev_self); chip_index++) {
@@ -354,7 +354,7 @@ static int __init nsc_ircc_open(chipio_t *info)
354 } 354 }
355 355
356 if (chip_index == ARRAY_SIZE(dev_self)) { 356 if (chip_index == ARRAY_SIZE(dev_self)) {
357 IRDA_ERROR("%s(), maximum number of supported chips reached!\n", __FUNCTION__); 357 IRDA_ERROR("%s(), maximum number of supported chips reached!\n", __func__);
358 return -ENOMEM; 358 return -ENOMEM;
359 } 359 }
360 360
@@ -369,7 +369,7 @@ static int __init nsc_ircc_open(chipio_t *info)
369 dev = alloc_irdadev(sizeof(struct nsc_ircc_cb)); 369 dev = alloc_irdadev(sizeof(struct nsc_ircc_cb));
370 if (dev == NULL) { 370 if (dev == NULL) {
371 IRDA_ERROR("%s(), can't allocate memory for " 371 IRDA_ERROR("%s(), can't allocate memory for "
372 "control block!\n", __FUNCTION__); 372 "control block!\n", __func__);
373 return -ENOMEM; 373 return -ENOMEM;
374 } 374 }
375 375
@@ -393,7 +393,7 @@ static int __init nsc_ircc_open(chipio_t *info)
393 ret = request_region(self->io.fir_base, self->io.fir_ext, driver_name); 393 ret = request_region(self->io.fir_base, self->io.fir_ext, driver_name);
394 if (!ret) { 394 if (!ret) {
395 IRDA_WARNING("%s(), can't get iobase of 0x%03x\n", 395 IRDA_WARNING("%s(), can't get iobase of 0x%03x\n",
396 __FUNCTION__, self->io.fir_base); 396 __func__, self->io.fir_base);
397 err = -ENODEV; 397 err = -ENODEV;
398 goto out1; 398 goto out1;
399 } 399 }
@@ -450,7 +450,7 @@ static int __init nsc_ircc_open(chipio_t *info)
450 450
451 err = register_netdev(dev); 451 err = register_netdev(dev);
452 if (err) { 452 if (err) {
453 IRDA_ERROR("%s(), register_netdev() failed!\n", __FUNCTION__); 453 IRDA_ERROR("%s(), register_netdev() failed!\n", __func__);
454 goto out4; 454 goto out4;
455 } 455 }
456 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name); 456 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
@@ -506,7 +506,7 @@ static int __exit nsc_ircc_close(struct nsc_ircc_cb *self)
506{ 506{
507 int iobase; 507 int iobase;
508 508
509 IRDA_DEBUG(4, "%s()\n", __FUNCTION__); 509 IRDA_DEBUG(4, "%s()\n", __func__);
510 510
511 IRDA_ASSERT(self != NULL, return -1;); 511 IRDA_ASSERT(self != NULL, return -1;);
512 512
@@ -519,7 +519,7 @@ static int __exit nsc_ircc_close(struct nsc_ircc_cb *self)
519 519
520 /* Release the PORT that this driver is using */ 520 /* Release the PORT that this driver is using */
521 IRDA_DEBUG(4, "%s(), Releasing Region %03x\n", 521 IRDA_DEBUG(4, "%s(), Releasing Region %03x\n",
522 __FUNCTION__, self->io.fir_base); 522 __func__, self->io.fir_base);
523 release_region(self->io.fir_base, self->io.fir_ext); 523 release_region(self->io.fir_base, self->io.fir_ext);
524 524
525 if (self->tx_buff.head) 525 if (self->tx_buff.head)
@@ -557,7 +557,7 @@ static int nsc_ircc_init_108(nsc_chip_t *chip, chipio_t *info)
557 case 0x2e8: outb(0x15, cfg_base+1); break; 557 case 0x2e8: outb(0x15, cfg_base+1); break;
558 case 0x3f8: outb(0x16, cfg_base+1); break; 558 case 0x3f8: outb(0x16, cfg_base+1); break;
559 case 0x2f8: outb(0x17, cfg_base+1); break; 559 case 0x2f8: outb(0x17, cfg_base+1); break;
560 default: IRDA_ERROR("%s(), invalid base_address", __FUNCTION__); 560 default: IRDA_ERROR("%s(), invalid base_address", __func__);
561 } 561 }
562 562
563 /* Control Signal Routing Register (CSRT) */ 563 /* Control Signal Routing Register (CSRT) */
@@ -569,7 +569,7 @@ static int nsc_ircc_init_108(nsc_chip_t *chip, chipio_t *info)
569 case 9: temp = 0x05; break; 569 case 9: temp = 0x05; break;
570 case 11: temp = 0x06; break; 570 case 11: temp = 0x06; break;
571 case 15: temp = 0x07; break; 571 case 15: temp = 0x07; break;
572 default: IRDA_ERROR("%s(), invalid irq", __FUNCTION__); 572 default: IRDA_ERROR("%s(), invalid irq", __func__);
573 } 573 }
574 outb(CFG_108_CSRT, cfg_base); 574 outb(CFG_108_CSRT, cfg_base);
575 575
@@ -577,7 +577,7 @@ static int nsc_ircc_init_108(nsc_chip_t *chip, chipio_t *info)
577 case 0: outb(0x08+temp, cfg_base+1); break; 577 case 0: outb(0x08+temp, cfg_base+1); break;
578 case 1: outb(0x10+temp, cfg_base+1); break; 578 case 1: outb(0x10+temp, cfg_base+1); break;
579 case 3: outb(0x18+temp, cfg_base+1); break; 579 case 3: outb(0x18+temp, cfg_base+1); break;
580 default: IRDA_ERROR("%s(), invalid dma", __FUNCTION__); 580 default: IRDA_ERROR("%s(), invalid dma", __func__);
581 } 581 }
582 582
583 outb(CFG_108_MCTL, cfg_base); /* Mode Control Register (MCTL) */ 583 outb(CFG_108_MCTL, cfg_base); /* Mode Control Register (MCTL) */
@@ -616,7 +616,7 @@ static int nsc_ircc_probe_108(nsc_chip_t *chip, chipio_t *info)
616 break; 616 break;
617 } 617 }
618 info->sir_base = info->fir_base; 618 info->sir_base = info->fir_base;
619 IRDA_DEBUG(2, "%s(), probing fir_base=0x%03x\n", __FUNCTION__, 619 IRDA_DEBUG(2, "%s(), probing fir_base=0x%03x\n", __func__,
620 info->fir_base); 620 info->fir_base);
621 621
622 /* Read control signals routing register (CSRT) */ 622 /* Read control signals routing register (CSRT) */
@@ -649,7 +649,7 @@ static int nsc_ircc_probe_108(nsc_chip_t *chip, chipio_t *info)
649 info->irq = 15; 649 info->irq = 15;
650 break; 650 break;
651 } 651 }
652 IRDA_DEBUG(2, "%s(), probing irq=%d\n", __FUNCTION__, info->irq); 652 IRDA_DEBUG(2, "%s(), probing irq=%d\n", __func__, info->irq);
653 653
654 /* Currently we only read Rx DMA but it will also be used for Tx */ 654 /* Currently we only read Rx DMA but it will also be used for Tx */
655 switch ((reg >> 3) & 0x03) { 655 switch ((reg >> 3) & 0x03) {
@@ -666,7 +666,7 @@ static int nsc_ircc_probe_108(nsc_chip_t *chip, chipio_t *info)
666 info->dma = 3; 666 info->dma = 3;
667 break; 667 break;
668 } 668 }
669 IRDA_DEBUG(2, "%s(), probing dma=%d\n", __FUNCTION__, info->dma); 669 IRDA_DEBUG(2, "%s(), probing dma=%d\n", __func__, info->dma);
670 670
671 /* Read mode control register (MCTL) */ 671 /* Read mode control register (MCTL) */
672 outb(CFG_108_MCTL, cfg_base); 672 outb(CFG_108_MCTL, cfg_base);
@@ -823,7 +823,7 @@ static int nsc_ircc_init_39x(nsc_chip_t *chip, chipio_t *info)
823 /* User is sure about his config... accept it. */ 823 /* User is sure about his config... accept it. */
824 IRDA_DEBUG(2, "%s(): nsc_ircc_init_39x (user settings): " 824 IRDA_DEBUG(2, "%s(): nsc_ircc_init_39x (user settings): "
825 "io=0x%04x, irq=%d, dma=%d\n", 825 "io=0x%04x, irq=%d, dma=%d\n",
826 __FUNCTION__, info->fir_base, info->irq, info->dma); 826 __func__, info->fir_base, info->irq, info->dma);
827 827
828 /* Access bank for SP2 */ 828 /* Access bank for SP2 */
829 outb(CFG_39X_LDN, cfg_base); 829 outb(CFG_39X_LDN, cfg_base);
@@ -864,7 +864,7 @@ static int nsc_ircc_probe_39x(nsc_chip_t *chip, chipio_t *info)
864 int enabled, susp; 864 int enabled, susp;
865 865
866 IRDA_DEBUG(2, "%s(), nsc_ircc_probe_39x, base=%d\n", 866 IRDA_DEBUG(2, "%s(), nsc_ircc_probe_39x, base=%d\n",
867 __FUNCTION__, cfg_base); 867 __func__, cfg_base);
868 868
869 /* This function should be executed with irq off to avoid 869 /* This function should be executed with irq off to avoid
870 * another driver messing with the Super I/O bank - Jean II */ 870 * another driver messing with the Super I/O bank - Jean II */
@@ -898,7 +898,7 @@ static int nsc_ircc_probe_39x(nsc_chip_t *chip, chipio_t *info)
898 outb(CFG_39X_SPC, cfg_base); 898 outb(CFG_39X_SPC, cfg_base);
899 susp = 1 - ((inb(cfg_base+1) & 0x02) >> 1); 899 susp = 1 - ((inb(cfg_base+1) & 0x02) >> 1);
900 900
901 IRDA_DEBUG(2, "%s(): io=0x%02x%02x, irq=%d (type %d), rxdma=%d, txdma=%d, enabled=%d (suspended=%d)\n", __FUNCTION__, reg1,reg2,irq,irqt,dma1,dma2,enabled,susp); 901 IRDA_DEBUG(2, "%s(): io=0x%02x%02x, irq=%d (type %d), rxdma=%d, txdma=%d, enabled=%d (suspended=%d)\n", __func__, reg1,reg2,irq,irqt,dma1,dma2,enabled,susp);
902 902
903 /* Configure SP2 */ 903 /* Configure SP2 */
904 904
@@ -930,7 +930,10 @@ static int nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *i
930 pnp_info.dma = -1; 930 pnp_info.dma = -1;
931 pnp_succeeded = 1; 931 pnp_succeeded = 1;
932 932
933 /* There don't seem to be any way to get the cfg_base. 933 if (id->driver_data & NSC_FORCE_DONGLE_TYPE9)
934 dongle_id = 0x9;
935
936 /* There doesn't seem to be any way of getting the cfg_base.
934 * On my box, cfg_base is in the PnP descriptor of the 937 * On my box, cfg_base is in the PnP descriptor of the
935 * motherboard. Oh well... Jean II */ 938 * motherboard. Oh well... Jean II */
936 939
@@ -947,7 +950,7 @@ static int nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *i
947 pnp_info.dma = pnp_dma(dev, 0); 950 pnp_info.dma = pnp_dma(dev, 0);
948 951
949 IRDA_DEBUG(0, "%s() : From PnP, found firbase 0x%03X ; irq %d ; dma %d.\n", 952 IRDA_DEBUG(0, "%s() : From PnP, found firbase 0x%03X ; irq %d ; dma %d.\n",
950 __FUNCTION__, pnp_info.fir_base, pnp_info.irq, pnp_info.dma); 953 __func__, pnp_info.fir_base, pnp_info.irq, pnp_info.dma);
951 954
952 if((pnp_info.fir_base == 0) || 955 if((pnp_info.fir_base == 0) ||
953 (pnp_info.irq == -1) || (pnp_info.dma == -1)) { 956 (pnp_info.irq == -1) || (pnp_info.dma == -1)) {
@@ -976,7 +979,7 @@ static int nsc_ircc_setup(chipio_t *info)
976 version = inb(iobase+MID); 979 version = inb(iobase+MID);
977 980
978 IRDA_DEBUG(2, "%s() Driver %s Found chip version %02x\n", 981 IRDA_DEBUG(2, "%s() Driver %s Found chip version %02x\n",
979 __FUNCTION__, driver_name, version); 982 __func__, driver_name, version);
980 983
981 /* Should be 0x2? */ 984 /* Should be 0x2? */
982 if (0x20 != (version & 0xf0)) { 985 if (0x20 != (version & 0xf0)) {
@@ -1080,30 +1083,30 @@ static void nsc_ircc_init_dongle_interface (int iobase, int dongle_id)
1080 case 0x00: /* same as */ 1083 case 0x00: /* same as */
1081 case 0x01: /* Differential serial interface */ 1084 case 0x01: /* Differential serial interface */
1082 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1085 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1083 __FUNCTION__, dongle_types[dongle_id]); 1086 __func__, dongle_types[dongle_id]);
1084 break; 1087 break;
1085 case 0x02: /* same as */ 1088 case 0x02: /* same as */
1086 case 0x03: /* Reserved */ 1089 case 0x03: /* Reserved */
1087 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1090 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1088 __FUNCTION__, dongle_types[dongle_id]); 1091 __func__, dongle_types[dongle_id]);
1089 break; 1092 break;
1090 case 0x04: /* Sharp RY5HD01 */ 1093 case 0x04: /* Sharp RY5HD01 */
1091 break; 1094 break;
1092 case 0x05: /* Reserved, but this is what the Thinkpad reports */ 1095 case 0x05: /* Reserved, but this is what the Thinkpad reports */
1093 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1096 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1094 __FUNCTION__, dongle_types[dongle_id]); 1097 __func__, dongle_types[dongle_id]);
1095 break; 1098 break;
1096 case 0x06: /* Single-ended serial interface */ 1099 case 0x06: /* Single-ended serial interface */
1097 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1100 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1098 __FUNCTION__, dongle_types[dongle_id]); 1101 __func__, dongle_types[dongle_id]);
1099 break; 1102 break;
1100 case 0x07: /* Consumer-IR only */ 1103 case 0x07: /* Consumer-IR only */
1101 IRDA_DEBUG(0, "%s(), %s is not for IrDA mode\n", 1104 IRDA_DEBUG(0, "%s(), %s is not for IrDA mode\n",
1102 __FUNCTION__, dongle_types[dongle_id]); 1105 __func__, dongle_types[dongle_id]);
1103 break; 1106 break;
1104 case 0x08: /* HP HSDL-2300, HP HSDL-3600/HSDL-3610 */ 1107 case 0x08: /* HP HSDL-2300, HP HSDL-3600/HSDL-3610 */
1105 IRDA_DEBUG(0, "%s(), %s\n", 1108 IRDA_DEBUG(0, "%s(), %s\n",
1106 __FUNCTION__, dongle_types[dongle_id]); 1109 __func__, dongle_types[dongle_id]);
1107 break; 1110 break;
1108 case 0x09: /* IBM31T1100 or Temic TFDS6000/TFDS6500 */ 1111 case 0x09: /* IBM31T1100 or Temic TFDS6000/TFDS6500 */
1109 outb(0x28, iobase+7); /* Set irsl[0-2] as output */ 1112 outb(0x28, iobase+7); /* Set irsl[0-2] as output */
@@ -1111,7 +1114,7 @@ static void nsc_ircc_init_dongle_interface (int iobase, int dongle_id)
1111 case 0x0A: /* same as */ 1114 case 0x0A: /* same as */
1112 case 0x0B: /* Reserved */ 1115 case 0x0B: /* Reserved */
1113 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1116 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1114 __FUNCTION__, dongle_types[dongle_id]); 1117 __func__, dongle_types[dongle_id]);
1115 break; 1118 break;
1116 case 0x0C: /* same as */ 1119 case 0x0C: /* same as */
1117 case 0x0D: /* HP HSDL-1100/HSDL-2100 */ 1120 case 0x0D: /* HP HSDL-1100/HSDL-2100 */
@@ -1126,14 +1129,14 @@ static void nsc_ircc_init_dongle_interface (int iobase, int dongle_id)
1126 break; 1129 break;
1127 case 0x0F: /* No dongle connected */ 1130 case 0x0F: /* No dongle connected */
1128 IRDA_DEBUG(0, "%s(), %s\n", 1131 IRDA_DEBUG(0, "%s(), %s\n",
1129 __FUNCTION__, dongle_types[dongle_id]); 1132 __func__, dongle_types[dongle_id]);
1130 1133
1131 switch_bank(iobase, BANK0); 1134 switch_bank(iobase, BANK0);
1132 outb(0x62, iobase+MCR); 1135 outb(0x62, iobase+MCR);
1133 break; 1136 break;
1134 default: 1137 default:
1135 IRDA_DEBUG(0, "%s(), invalid dongle_id %#x", 1138 IRDA_DEBUG(0, "%s(), invalid dongle_id %#x",
1136 __FUNCTION__, dongle_id); 1139 __func__, dongle_id);
1137 } 1140 }
1138 1141
1139 /* IRCFG1: IRSL1 and 2 are set to IrDA mode */ 1142 /* IRCFG1: IRSL1 and 2 are set to IrDA mode */
@@ -1165,30 +1168,30 @@ static void nsc_ircc_change_dongle_speed(int iobase, int speed, int dongle_id)
1165 case 0x00: /* same as */ 1168 case 0x00: /* same as */
1166 case 0x01: /* Differential serial interface */ 1169 case 0x01: /* Differential serial interface */
1167 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1170 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1168 __FUNCTION__, dongle_types[dongle_id]); 1171 __func__, dongle_types[dongle_id]);
1169 break; 1172 break;
1170 case 0x02: /* same as */ 1173 case 0x02: /* same as */
1171 case 0x03: /* Reserved */ 1174 case 0x03: /* Reserved */
1172 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1175 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1173 __FUNCTION__, dongle_types[dongle_id]); 1176 __func__, dongle_types[dongle_id]);
1174 break; 1177 break;
1175 case 0x04: /* Sharp RY5HD01 */ 1178 case 0x04: /* Sharp RY5HD01 */
1176 break; 1179 break;
1177 case 0x05: /* Reserved */ 1180 case 0x05: /* Reserved */
1178 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1181 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1179 __FUNCTION__, dongle_types[dongle_id]); 1182 __func__, dongle_types[dongle_id]);
1180 break; 1183 break;
1181 case 0x06: /* Single-ended serial interface */ 1184 case 0x06: /* Single-ended serial interface */
1182 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1185 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1183 __FUNCTION__, dongle_types[dongle_id]); 1186 __func__, dongle_types[dongle_id]);
1184 break; 1187 break;
1185 case 0x07: /* Consumer-IR only */ 1188 case 0x07: /* Consumer-IR only */
1186 IRDA_DEBUG(0, "%s(), %s is not for IrDA mode\n", 1189 IRDA_DEBUG(0, "%s(), %s is not for IrDA mode\n",
1187 __FUNCTION__, dongle_types[dongle_id]); 1190 __func__, dongle_types[dongle_id]);
1188 break; 1191 break;
1189 case 0x08: /* HP HSDL-2300, HP HSDL-3600/HSDL-3610 */ 1192 case 0x08: /* HP HSDL-2300, HP HSDL-3600/HSDL-3610 */
1190 IRDA_DEBUG(0, "%s(), %s\n", 1193 IRDA_DEBUG(0, "%s(), %s\n",
1191 __FUNCTION__, dongle_types[dongle_id]); 1194 __func__, dongle_types[dongle_id]);
1192 outb(0x00, iobase+4); 1195 outb(0x00, iobase+4);
1193 if (speed > 115200) 1196 if (speed > 115200)
1194 outb(0x01, iobase+4); 1197 outb(0x01, iobase+4);
@@ -1207,7 +1210,7 @@ static void nsc_ircc_change_dongle_speed(int iobase, int speed, int dongle_id)
1207 case 0x0A: /* same as */ 1210 case 0x0A: /* same as */
1208 case 0x0B: /* Reserved */ 1211 case 0x0B: /* Reserved */
1209 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n", 1212 IRDA_DEBUG(0, "%s(), %s not defined by irda yet\n",
1210 __FUNCTION__, dongle_types[dongle_id]); 1213 __func__, dongle_types[dongle_id]);
1211 break; 1214 break;
1212 case 0x0C: /* same as */ 1215 case 0x0C: /* same as */
1213 case 0x0D: /* HP HSDL-1100/HSDL-2100 */ 1216 case 0x0D: /* HP HSDL-1100/HSDL-2100 */
@@ -1216,13 +1219,13 @@ static void nsc_ircc_change_dongle_speed(int iobase, int speed, int dongle_id)
1216 break; 1219 break;
1217 case 0x0F: /* No dongle connected */ 1220 case 0x0F: /* No dongle connected */
1218 IRDA_DEBUG(0, "%s(), %s is not for IrDA mode\n", 1221 IRDA_DEBUG(0, "%s(), %s is not for IrDA mode\n",
1219 __FUNCTION__, dongle_types[dongle_id]); 1222 __func__, dongle_types[dongle_id]);
1220 1223
1221 switch_bank(iobase, BANK0); 1224 switch_bank(iobase, BANK0);
1222 outb(0x62, iobase+MCR); 1225 outb(0x62, iobase+MCR);
1223 break; 1226 break;
1224 default: 1227 default:
1225 IRDA_DEBUG(0, "%s(), invalid data_rate\n", __FUNCTION__); 1228 IRDA_DEBUG(0, "%s(), invalid data_rate\n", __func__);
1226 } 1229 }
1227 /* Restore bank register */ 1230 /* Restore bank register */
1228 outb(bank, iobase+BSR); 1231 outb(bank, iobase+BSR);
@@ -1243,7 +1246,7 @@ static __u8 nsc_ircc_change_speed(struct nsc_ircc_cb *self, __u32 speed)
1243 __u8 bank; 1246 __u8 bank;
1244 __u8 ier; /* Interrupt enable register */ 1247 __u8 ier; /* Interrupt enable register */
1245 1248
1246 IRDA_DEBUG(2, "%s(), speed=%d\n", __FUNCTION__, speed); 1249 IRDA_DEBUG(2, "%s(), speed=%d\n", __func__, speed);
1247 1250
1248 IRDA_ASSERT(self != NULL, return 0;); 1251 IRDA_ASSERT(self != NULL, return 0;);
1249 1252
@@ -1276,20 +1279,20 @@ static __u8 nsc_ircc_change_speed(struct nsc_ircc_cb *self, __u32 speed)
1276 outb(inb(iobase+4) | 0x04, iobase+4); 1279 outb(inb(iobase+4) | 0x04, iobase+4);
1277 1280
1278 mcr = MCR_MIR; 1281 mcr = MCR_MIR;
1279 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__); 1282 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __func__);
1280 break; 1283 break;
1281 case 1152000: 1284 case 1152000:
1282 mcr = MCR_MIR; 1285 mcr = MCR_MIR;
1283 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", __FUNCTION__); 1286 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", __func__);
1284 break; 1287 break;
1285 case 4000000: 1288 case 4000000:
1286 mcr = MCR_FIR; 1289 mcr = MCR_FIR;
1287 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", __FUNCTION__); 1290 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", __func__);
1288 break; 1291 break;
1289 default: 1292 default:
1290 mcr = MCR_FIR; 1293 mcr = MCR_FIR;
1291 IRDA_DEBUG(0, "%s(), unknown baud rate of %d\n", 1294 IRDA_DEBUG(0, "%s(), unknown baud rate of %d\n",
1292 __FUNCTION__, speed); 1295 __func__, speed);
1293 break; 1296 break;
1294 } 1297 }
1295 1298
@@ -1594,7 +1597,7 @@ static int nsc_ircc_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
1594 int actual = 0; 1597 int actual = 0;
1595 __u8 bank; 1598 __u8 bank;
1596 1599
1597 IRDA_DEBUG(4, "%s()\n", __FUNCTION__); 1600 IRDA_DEBUG(4, "%s()\n", __func__);
1598 1601
1599 /* Save current bank */ 1602 /* Save current bank */
1600 bank = inb(iobase+BSR); 1603 bank = inb(iobase+BSR);
@@ -1602,7 +1605,7 @@ static int nsc_ircc_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
1602 switch_bank(iobase, BANK0); 1605 switch_bank(iobase, BANK0);
1603 if (!(inb_p(iobase+LSR) & LSR_TXEMP)) { 1606 if (!(inb_p(iobase+LSR) & LSR_TXEMP)) {
1604 IRDA_DEBUG(4, "%s(), warning, FIFO not empty yet!\n", 1607 IRDA_DEBUG(4, "%s(), warning, FIFO not empty yet!\n",
1605 __FUNCTION__); 1608 __func__);
1606 1609
1607 /* FIFO may still be filled to the Tx interrupt threshold */ 1610 /* FIFO may still be filled to the Tx interrupt threshold */
1608 fifo_size -= 17; 1611 fifo_size -= 17;
@@ -1615,7 +1618,7 @@ static int nsc_ircc_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
1615 } 1618 }
1616 1619
1617 IRDA_DEBUG(4, "%s(), fifo_size %d ; %d sent of %d\n", 1620 IRDA_DEBUG(4, "%s(), fifo_size %d ; %d sent of %d\n",
1618 __FUNCTION__, fifo_size, actual, len); 1621 __func__, fifo_size, actual, len);
1619 1622
1620 /* Restore bank */ 1623 /* Restore bank */
1621 outb(bank, iobase+BSR); 1624 outb(bank, iobase+BSR);
@@ -1636,7 +1639,7 @@ static int nsc_ircc_dma_xmit_complete(struct nsc_ircc_cb *self)
1636 __u8 bank; 1639 __u8 bank;
1637 int ret = TRUE; 1640 int ret = TRUE;
1638 1641
1639 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 1642 IRDA_DEBUG(2, "%s()\n", __func__);
1640 1643
1641 iobase = self->io.fir_base; 1644 iobase = self->io.fir_base;
1642 1645
@@ -1767,7 +1770,7 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
1767 len = inb(iobase+RFLFL) | ((inb(iobase+RFLFH) & 0x1f) << 8); 1770 len = inb(iobase+RFLFL) | ((inb(iobase+RFLFH) & 0x1f) << 8);
1768 1771
1769 if (st_fifo->tail >= MAX_RX_WINDOW) { 1772 if (st_fifo->tail >= MAX_RX_WINDOW) {
1770 IRDA_DEBUG(0, "%s(), window is full!\n", __FUNCTION__); 1773 IRDA_DEBUG(0, "%s(), window is full!\n", __func__);
1771 continue; 1774 continue;
1772 } 1775 }
1773 1776
@@ -1859,7 +1862,7 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
1859 if (skb == NULL) { 1862 if (skb == NULL) {
1860 IRDA_WARNING("%s(), memory squeeze, " 1863 IRDA_WARNING("%s(), memory squeeze, "
1861 "dropping frame.\n", 1864 "dropping frame.\n",
1862 __FUNCTION__); 1865 __func__);
1863 self->stats.rx_dropped++; 1866 self->stats.rx_dropped++;
1864 1867
1865 /* Restore bank register */ 1868 /* Restore bank register */
@@ -1965,7 +1968,7 @@ static void nsc_ircc_sir_interrupt(struct nsc_ircc_cb *self, int eir)
1965 * Need to be after self->io.direction to avoid race with 1968 * Need to be after self->io.direction to avoid race with
1966 * nsc_ircc_hard_xmit_sir() - Jean II */ 1969 * nsc_ircc_hard_xmit_sir() - Jean II */
1967 if (self->new_speed) { 1970 if (self->new_speed) {
1968 IRDA_DEBUG(2, "%s(), Changing speed!\n", __FUNCTION__); 1971 IRDA_DEBUG(2, "%s(), Changing speed!\n", __func__);
1969 self->ier = nsc_ircc_change_speed(self, 1972 self->ier = nsc_ircc_change_speed(self,
1970 self->new_speed); 1973 self->new_speed);
1971 self->new_speed = 0; 1974 self->new_speed = 0;
@@ -2051,7 +2054,7 @@ static void nsc_ircc_fir_interrupt(struct nsc_ircc_cb *self, int iobase,
2051 } else 2054 } else
2052 IRDA_WARNING("%s(), potential " 2055 IRDA_WARNING("%s(), potential "
2053 "Tx queue lockup !\n", 2056 "Tx queue lockup !\n",
2054 __FUNCTION__); 2057 __func__);
2055 } 2058 }
2056 } else { 2059 } else {
2057 /* Not finished yet, so interrupt on DMA again */ 2060 /* Not finished yet, so interrupt on DMA again */
@@ -2160,7 +2163,7 @@ static int nsc_ircc_net_open(struct net_device *dev)
2160 char hwname[32]; 2163 char hwname[32];
2161 __u8 bank; 2164 __u8 bank;
2162 2165
2163 IRDA_DEBUG(4, "%s()\n", __FUNCTION__); 2166 IRDA_DEBUG(4, "%s()\n", __func__);
2164 2167
2165 IRDA_ASSERT(dev != NULL, return -1;); 2168 IRDA_ASSERT(dev != NULL, return -1;);
2166 self = (struct nsc_ircc_cb *) dev->priv; 2169 self = (struct nsc_ircc_cb *) dev->priv;
@@ -2222,7 +2225,7 @@ static int nsc_ircc_net_close(struct net_device *dev)
2222 int iobase; 2225 int iobase;
2223 __u8 bank; 2226 __u8 bank;
2224 2227
2225 IRDA_DEBUG(4, "%s()\n", __FUNCTION__); 2228 IRDA_DEBUG(4, "%s()\n", __func__);
2226 2229
2227 IRDA_ASSERT(dev != NULL, return -1;); 2230 IRDA_ASSERT(dev != NULL, return -1;);
2228 2231
@@ -2276,7 +2279,7 @@ static int nsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2276 2279
2277 IRDA_ASSERT(self != NULL, return -1;); 2280 IRDA_ASSERT(self != NULL, return -1;);
2278 2281
2279 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd); 2282 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name, cmd);
2280 2283
2281 switch (cmd) { 2284 switch (cmd) {
2282 case SIOCSBANDWIDTH: /* Set bandwidth */ 2285 case SIOCSBANDWIDTH: /* Set bandwidth */
diff --git a/drivers/net/irda/nsc-ircc.h b/drivers/net/irda/nsc-ircc.h
index 29398a4f73fd..71cd3c5a0762 100644
--- a/drivers/net/irda/nsc-ircc.h
+++ b/drivers/net/irda/nsc-ircc.h
@@ -35,6 +35,9 @@
35#include <linux/types.h> 35#include <linux/types.h>
36#include <asm/io.h> 36#include <asm/io.h>
37 37
38/* Features for chips (set in driver_data) */
39#define NSC_FORCE_DONGLE_TYPE9 0x00000001
40
38/* DMA modes needed */ 41/* DMA modes needed */
39#define DMA_TX_MODE 0x08 /* Mem to I/O, ++, demand. */ 42#define DMA_TX_MODE 0x08 /* Mem to I/O, ++, demand. */
40#define DMA_RX_MODE 0x04 /* I/O to mem, ++, demand. */ 43#define DMA_RX_MODE 0x04 /* I/O to mem, ++, demand. */
diff --git a/drivers/net/irda/old_belkin-sir.c b/drivers/net/irda/old_belkin-sir.c
index 8c22c7374a23..75714bc71030 100644
--- a/drivers/net/irda/old_belkin-sir.c
+++ b/drivers/net/irda/old_belkin-sir.c
@@ -92,7 +92,7 @@ static int old_belkin_open(struct sir_dev *dev)
92{ 92{
93 struct qos_info *qos = &dev->qos; 93 struct qos_info *qos = &dev->qos;
94 94
95 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 95 IRDA_DEBUG(2, "%s()\n", __func__);
96 96
97 /* Power on dongle */ 97 /* Power on dongle */
98 sirdev_set_dtr_rts(dev, TRUE, TRUE); 98 sirdev_set_dtr_rts(dev, TRUE, TRUE);
@@ -110,7 +110,7 @@ static int old_belkin_open(struct sir_dev *dev)
110 110
111static int old_belkin_close(struct sir_dev *dev) 111static int old_belkin_close(struct sir_dev *dev)
112{ 112{
113 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 113 IRDA_DEBUG(2, "%s()\n", __func__);
114 114
115 /* Power off dongle */ 115 /* Power off dongle */
116 sirdev_set_dtr_rts(dev, FALSE, FALSE); 116 sirdev_set_dtr_rts(dev, FALSE, FALSE);
@@ -125,7 +125,7 @@ static int old_belkin_close(struct sir_dev *dev)
125 */ 125 */
126static int old_belkin_change_speed(struct sir_dev *dev, unsigned speed) 126static int old_belkin_change_speed(struct sir_dev *dev, unsigned speed)
127{ 127{
128 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 128 IRDA_DEBUG(2, "%s()\n", __func__);
129 129
130 dev->speed = 9600; 130 dev->speed = 9600;
131 return (speed==dev->speed) ? 0 : -EINVAL; 131 return (speed==dev->speed) ? 0 : -EINVAL;
@@ -139,7 +139,7 @@ static int old_belkin_change_speed(struct sir_dev *dev, unsigned speed)
139 */ 139 */
140static int old_belkin_reset(struct sir_dev *dev) 140static int old_belkin_reset(struct sir_dev *dev)
141{ 141{
142 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 142 IRDA_DEBUG(2, "%s()\n", __func__);
143 143
144 /* This dongles speed "defaults" to 9600 bps ;-) */ 144 /* This dongles speed "defaults" to 9600 bps ;-) */
145 dev->speed = 9600; 145 dev->speed = 9600;
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 6078e03de9a8..3f32909c24c8 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -80,7 +80,7 @@ static int sirdev_tx_complete_fsm(struct sir_dev *dev)
80 return 0; 80 return 0;
81 81
82 default: 82 default:
83 IRDA_ERROR("%s - undefined state\n", __FUNCTION__); 83 IRDA_ERROR("%s - undefined state\n", __func__);
84 return -EINVAL; 84 return -EINVAL;
85 } 85 }
86 fsm->substate = next_state; 86 fsm->substate = next_state;
@@ -107,11 +107,11 @@ static void sirdev_config_fsm(struct work_struct *work)
107 int ret = -1; 107 int ret = -1;
108 unsigned delay; 108 unsigned delay;
109 109
110 IRDA_DEBUG(2, "%s(), <%ld>\n", __FUNCTION__, jiffies); 110 IRDA_DEBUG(2, "%s(), <%ld>\n", __func__, jiffies);
111 111
112 do { 112 do {
113 IRDA_DEBUG(3, "%s - state=0x%04x / substate=0x%04x\n", 113 IRDA_DEBUG(3, "%s - state=0x%04x / substate=0x%04x\n",
114 __FUNCTION__, fsm->state, fsm->substate); 114 __func__, fsm->state, fsm->substate);
115 115
116 next_state = fsm->state; 116 next_state = fsm->state;
117 delay = 0; 117 delay = 0;
@@ -249,12 +249,12 @@ static void sirdev_config_fsm(struct work_struct *work)
249 break; 249 break;
250 250
251 default: 251 default:
252 IRDA_ERROR("%s - undefined state\n", __FUNCTION__); 252 IRDA_ERROR("%s - undefined state\n", __func__);
253 fsm->result = -EINVAL; 253 fsm->result = -EINVAL;
254 /* fall thru */ 254 /* fall thru */
255 255
256 case SIRDEV_STATE_ERROR: 256 case SIRDEV_STATE_ERROR:
257 IRDA_ERROR("%s - error: %d\n", __FUNCTION__, fsm->result); 257 IRDA_ERROR("%s - error: %d\n", __func__, fsm->result);
258 258
259#if 0 /* don't enable this before we have netdev->tx_timeout to recover */ 259#if 0 /* don't enable this before we have netdev->tx_timeout to recover */
260 netif_stop_queue(dev->netdev); 260 netif_stop_queue(dev->netdev);
@@ -284,11 +284,12 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
284{ 284{
285 struct sir_fsm *fsm = &dev->fsm; 285 struct sir_fsm *fsm = &dev->fsm;
286 286
287 IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param); 287 IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __func__,
288 initial_state, param);
288 289
289 if (down_trylock(&fsm->sem)) { 290 if (down_trylock(&fsm->sem)) {
290 if (in_interrupt() || in_atomic() || irqs_disabled()) { 291 if (in_interrupt() || in_atomic() || irqs_disabled()) {
291 IRDA_DEBUG(1, "%s(), state machine busy!\n", __FUNCTION__); 292 IRDA_DEBUG(1, "%s(), state machine busy!\n", __func__);
292 return -EWOULDBLOCK; 293 return -EWOULDBLOCK;
293 } else 294 } else
294 down(&fsm->sem); 295 down(&fsm->sem);
@@ -296,7 +297,7 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
296 297
297 if (fsm->state == SIRDEV_STATE_DEAD) { 298 if (fsm->state == SIRDEV_STATE_DEAD) {
298 /* race with sirdev_close should never happen */ 299 /* race with sirdev_close should never happen */
299 IRDA_ERROR("%s(), instance staled!\n", __FUNCTION__); 300 IRDA_ERROR("%s(), instance staled!\n", __func__);
300 up(&fsm->sem); 301 up(&fsm->sem);
301 return -ESTALE; /* or better EPIPE? */ 302 return -ESTALE; /* or better EPIPE? */
302 } 303 }
@@ -341,7 +342,7 @@ int sirdev_set_dongle(struct sir_dev *dev, IRDA_DONGLE type)
341{ 342{
342 int err; 343 int err;
343 344
344 IRDA_DEBUG(3, "%s : requesting dongle %d.\n", __FUNCTION__, type); 345 IRDA_DEBUG(3, "%s : requesting dongle %d.\n", __func__, type);
345 346
346 err = sirdev_schedule_dongle_open(dev, type); 347 err = sirdev_schedule_dongle_open(dev, type);
347 if (unlikely(err)) 348 if (unlikely(err))
@@ -376,7 +377,7 @@ int sirdev_raw_write(struct sir_dev *dev, const char *buf, int len)
376 377
377 ret = dev->drv->do_write(dev, dev->tx_buff.data, dev->tx_buff.len); 378 ret = dev->drv->do_write(dev, dev->tx_buff.data, dev->tx_buff.len);
378 if (ret > 0) { 379 if (ret > 0) {
379 IRDA_DEBUG(3, "%s(), raw-tx started\n", __FUNCTION__); 380 IRDA_DEBUG(3, "%s(), raw-tx started\n", __func__);
380 381
381 dev->tx_buff.data += ret; 382 dev->tx_buff.data += ret;
382 dev->tx_buff.len -= ret; 383 dev->tx_buff.len -= ret;
@@ -437,7 +438,7 @@ void sirdev_write_complete(struct sir_dev *dev)
437 spin_lock_irqsave(&dev->tx_lock, flags); 438 spin_lock_irqsave(&dev->tx_lock, flags);
438 439
439 IRDA_DEBUG(3, "%s() - dev->tx_buff.len = %d\n", 440 IRDA_DEBUG(3, "%s() - dev->tx_buff.len = %d\n",
440 __FUNCTION__, dev->tx_buff.len); 441 __func__, dev->tx_buff.len);
441 442
442 if (likely(dev->tx_buff.len > 0)) { 443 if (likely(dev->tx_buff.len > 0)) {
443 /* Write data left in transmit buffer */ 444 /* Write data left in transmit buffer */
@@ -450,7 +451,7 @@ void sirdev_write_complete(struct sir_dev *dev)
450 else if (unlikely(actual<0)) { 451 else if (unlikely(actual<0)) {
451 /* could be dropped later when we have tx_timeout to recover */ 452 /* could be dropped later when we have tx_timeout to recover */
452 IRDA_ERROR("%s: drv->do_write failed (%d)\n", 453 IRDA_ERROR("%s: drv->do_write failed (%d)\n",
453 __FUNCTION__, actual); 454 __func__, actual);
454 if ((skb=dev->tx_skb) != NULL) { 455 if ((skb=dev->tx_skb) != NULL) {
455 dev->tx_skb = NULL; 456 dev->tx_skb = NULL;
456 dev_kfree_skb_any(skb); 457 dev_kfree_skb_any(skb);
@@ -471,7 +472,7 @@ void sirdev_write_complete(struct sir_dev *dev)
471 * restarted when the irda-thread has completed the request. 472 * restarted when the irda-thread has completed the request.
472 */ 473 */
473 474
474 IRDA_DEBUG(3, "%s(), raw-tx done\n", __FUNCTION__); 475 IRDA_DEBUG(3, "%s(), raw-tx done\n", __func__);
475 dev->raw_tx = 0; 476 dev->raw_tx = 0;
476 goto done; /* no post-frame handling in raw mode */ 477 goto done; /* no post-frame handling in raw mode */
477 } 478 }
@@ -488,7 +489,7 @@ void sirdev_write_complete(struct sir_dev *dev)
488 * re-activated. 489 * re-activated.
489 */ 490 */
490 491
491 IRDA_DEBUG(5, "%s(), finished with frame!\n", __FUNCTION__); 492 IRDA_DEBUG(5, "%s(), finished with frame!\n", __func__);
492 493
493 if ((skb=dev->tx_skb) != NULL) { 494 if ((skb=dev->tx_skb) != NULL) {
494 dev->tx_skb = NULL; 495 dev->tx_skb = NULL;
@@ -498,14 +499,14 @@ void sirdev_write_complete(struct sir_dev *dev)
498 } 499 }
499 500
500 if (unlikely(dev->new_speed > 0)) { 501 if (unlikely(dev->new_speed > 0)) {
501 IRDA_DEBUG(5, "%s(), Changing speed!\n", __FUNCTION__); 502 IRDA_DEBUG(5, "%s(), Changing speed!\n", __func__);
502 err = sirdev_schedule_speed(dev, dev->new_speed); 503 err = sirdev_schedule_speed(dev, dev->new_speed);
503 if (unlikely(err)) { 504 if (unlikely(err)) {
504 /* should never happen 505 /* should never happen
505 * forget the speed change and hope the stack recovers 506 * forget the speed change and hope the stack recovers
506 */ 507 */
507 IRDA_ERROR("%s - schedule speed change failed: %d\n", 508 IRDA_ERROR("%s - schedule speed change failed: %d\n",
508 __FUNCTION__, err); 509 __func__, err);
509 netif_wake_queue(dev->netdev); 510 netif_wake_queue(dev->netdev);
510 } 511 }
511 /* else: success 512 /* else: success
@@ -532,13 +533,13 @@ EXPORT_SYMBOL(sirdev_write_complete);
532int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count) 533int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count)
533{ 534{
534 if (!dev || !dev->netdev) { 535 if (!dev || !dev->netdev) {
535 IRDA_WARNING("%s(), not ready yet!\n", __FUNCTION__); 536 IRDA_WARNING("%s(), not ready yet!\n", __func__);
536 return -1; 537 return -1;
537 } 538 }
538 539
539 if (!dev->irlap) { 540 if (!dev->irlap) {
540 IRDA_WARNING("%s - too early: %p / %zd!\n", 541 IRDA_WARNING("%s - too early: %p / %zd!\n",
541 __FUNCTION__, cp, count); 542 __func__, cp, count);
542 return -1; 543 return -1;
543 } 544 }
544 545
@@ -548,7 +549,7 @@ int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count)
548 */ 549 */
549 irda_device_set_media_busy(dev->netdev, TRUE); 550 irda_device_set_media_busy(dev->netdev, TRUE);
550 dev->stats.rx_dropped++; 551 dev->stats.rx_dropped++;
551 IRDA_DEBUG(0, "%s; rx-drop: %zd\n", __FUNCTION__, count); 552 IRDA_DEBUG(0, "%s; rx-drop: %zd\n", __func__, count);
552 return 0; 553 return 0;
553 } 554 }
554 555
@@ -600,7 +601,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
600 601
601 netif_stop_queue(ndev); 602 netif_stop_queue(ndev);
602 603
603 IRDA_DEBUG(3, "%s(), skb->len = %d\n", __FUNCTION__, skb->len); 604 IRDA_DEBUG(3, "%s(), skb->len = %d\n", __func__, skb->len);
604 605
605 speed = irda_get_next_speed(skb); 606 speed = irda_get_next_speed(skb);
606 if ((speed != dev->speed) && (speed != -1)) { 607 if ((speed != dev->speed) && (speed != -1)) {
@@ -637,7 +638,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
637 638
638 /* Check problems */ 639 /* Check problems */
639 if(spin_is_locked(&dev->tx_lock)) { 640 if(spin_is_locked(&dev->tx_lock)) {
640 IRDA_DEBUG(3, "%s(), write not completed\n", __FUNCTION__); 641 IRDA_DEBUG(3, "%s(), write not completed\n", __func__);
641 } 642 }
642 643
643 /* serialize with write completion */ 644 /* serialize with write completion */
@@ -666,7 +667,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
666 else if (unlikely(actual < 0)) { 667 else if (unlikely(actual < 0)) {
667 /* could be dropped later when we have tx_timeout to recover */ 668 /* could be dropped later when we have tx_timeout to recover */
668 IRDA_ERROR("%s: drv->do_write failed (%d)\n", 669 IRDA_ERROR("%s: drv->do_write failed (%d)\n",
669 __FUNCTION__, actual); 670 __func__, actual);
670 dev_kfree_skb_any(skb); 671 dev_kfree_skb_any(skb);
671 dev->stats.tx_errors++; 672 dev->stats.tx_errors++;
672 dev->stats.tx_dropped++; 673 dev->stats.tx_dropped++;
@@ -687,7 +688,7 @@ static int sirdev_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
687 688
688 IRDA_ASSERT(dev != NULL, return -1;); 689 IRDA_ASSERT(dev != NULL, return -1;);
689 690
690 IRDA_DEBUG(3, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, ndev->name, cmd); 691 IRDA_DEBUG(3, "%s(), %s, (cmd=0x%X)\n", __func__, ndev->name, cmd);
691 692
692 switch (cmd) { 693 switch (cmd) {
693 case SIOCSBANDWIDTH: /* Set bandwidth */ 694 case SIOCSBANDWIDTH: /* Set bandwidth */
@@ -804,7 +805,7 @@ static int sirdev_open(struct net_device *ndev)
804 if (!try_module_get(drv->owner)) 805 if (!try_module_get(drv->owner))
805 return -ESTALE; 806 return -ESTALE;
806 807
807 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 808 IRDA_DEBUG(2, "%s()\n", __func__);
808 809
809 if (sirdev_alloc_buffers(dev)) 810 if (sirdev_alloc_buffers(dev))
810 goto errout_dec; 811 goto errout_dec;
@@ -822,7 +823,7 @@ static int sirdev_open(struct net_device *ndev)
822 823
823 netif_wake_queue(ndev); 824 netif_wake_queue(ndev);
824 825
825 IRDA_DEBUG(2, "%s - done, speed = %d\n", __FUNCTION__, dev->speed); 826 IRDA_DEBUG(2, "%s - done, speed = %d\n", __func__, dev->speed);
826 827
827 return 0; 828 return 0;
828 829
@@ -842,7 +843,7 @@ static int sirdev_close(struct net_device *ndev)
842 struct sir_dev *dev = ndev->priv; 843 struct sir_dev *dev = ndev->priv;
843 const struct sir_driver *drv; 844 const struct sir_driver *drv;
844 845
845// IRDA_DEBUG(0, "%s\n", __FUNCTION__); 846// IRDA_DEBUG(0, "%s\n", __func__);
846 847
847 netif_stop_queue(ndev); 848 netif_stop_queue(ndev);
848 849
@@ -878,7 +879,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
878 struct net_device *ndev; 879 struct net_device *ndev;
879 struct sir_dev *dev; 880 struct sir_dev *dev;
880 881
881 IRDA_DEBUG(0, "%s - %s\n", __FUNCTION__, name); 882 IRDA_DEBUG(0, "%s - %s\n", __func__, name);
882 883
883 /* instead of adding tests to protect against drv->do_write==NULL 884 /* instead of adding tests to protect against drv->do_write==NULL
884 * at several places we refuse to create a sir_dev instance for 885 * at several places we refuse to create a sir_dev instance for
@@ -892,7 +893,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
892 */ 893 */
893 ndev = alloc_irdadev(sizeof(*dev)); 894 ndev = alloc_irdadev(sizeof(*dev));
894 if (ndev == NULL) { 895 if (ndev == NULL) {
895 IRDA_ERROR("%s - Can't allocate memory for IrDA control block!\n", __FUNCTION__); 896 IRDA_ERROR("%s - Can't allocate memory for IrDA control block!\n", __func__);
896 goto out; 897 goto out;
897 } 898 }
898 dev = ndev->priv; 899 dev = ndev->priv;
@@ -921,7 +922,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
921 ndev->do_ioctl = sirdev_ioctl; 922 ndev->do_ioctl = sirdev_ioctl;
922 923
923 if (register_netdev(ndev)) { 924 if (register_netdev(ndev)) {
924 IRDA_ERROR("%s(), register_netdev() failed!\n", __FUNCTION__); 925 IRDA_ERROR("%s(), register_netdev() failed!\n", __func__);
925 goto out_freenetdev; 926 goto out_freenetdev;
926 } 927 }
927 928
@@ -938,7 +939,7 @@ int sirdev_put_instance(struct sir_dev *dev)
938{ 939{
939 int err = 0; 940 int err = 0;
940 941
941 IRDA_DEBUG(0, "%s\n", __FUNCTION__); 942 IRDA_DEBUG(0, "%s\n", __func__);
942 943
943 atomic_set(&dev->enable_rx, 0); 944 atomic_set(&dev->enable_rx, 0);
944 945
@@ -948,7 +949,7 @@ int sirdev_put_instance(struct sir_dev *dev)
948 if (dev->dongle_drv) 949 if (dev->dongle_drv)
949 err = sirdev_schedule_dongle_close(dev); 950 err = sirdev_schedule_dongle_close(dev);
950 if (err) 951 if (err)
951 IRDA_ERROR("%s - error %d\n", __FUNCTION__, err); 952 IRDA_ERROR("%s - error %d\n", __func__, err);
952 953
953 sirdev_close(dev->netdev); 954 sirdev_close(dev->netdev);
954 955
diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c
index 25d5b8a96bdc..36030241f7a9 100644
--- a/drivers/net/irda/sir_dongle.c
+++ b/drivers/net/irda/sir_dongle.c
@@ -36,7 +36,7 @@ int irda_register_dongle(struct dongle_driver *new)
36 struct dongle_driver *drv; 36 struct dongle_driver *drv;
37 37
38 IRDA_DEBUG(0, "%s : registering dongle \"%s\" (%d).\n", 38 IRDA_DEBUG(0, "%s : registering dongle \"%s\" (%d).\n",
39 __FUNCTION__, new->driver_name, new->type); 39 __func__, new->driver_name, new->type);
40 40
41 mutex_lock(&dongle_list_lock); 41 mutex_lock(&dongle_list_lock);
42 list_for_each(entry, &dongle_list) { 42 list_for_each(entry, &dongle_list) {
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index 78dc8e7837f0..b5360fe99d3a 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -460,7 +460,7 @@ static int __init smsc_ircc_init(void)
460{ 460{
461 int ret; 461 int ret;
462 462
463 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 463 IRDA_DEBUG(1, "%s\n", __func__);
464 464
465 ret = platform_driver_register(&smsc_ircc_driver); 465 ret = platform_driver_register(&smsc_ircc_driver);
466 if (ret) { 466 if (ret) {
@@ -500,7 +500,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u
500 struct net_device *dev; 500 struct net_device *dev;
501 int err; 501 int err;
502 502
503 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 503 IRDA_DEBUG(1, "%s\n", __func__);
504 504
505 err = smsc_ircc_present(fir_base, sir_base); 505 err = smsc_ircc_present(fir_base, sir_base);
506 if (err) 506 if (err)
@@ -508,7 +508,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u
508 508
509 err = -ENOMEM; 509 err = -ENOMEM;
510 if (dev_count >= ARRAY_SIZE(dev_self)) { 510 if (dev_count >= ARRAY_SIZE(dev_self)) {
511 IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__); 511 IRDA_WARNING("%s(), too many devices!\n", __func__);
512 goto err_out1; 512 goto err_out1;
513 } 513 }
514 514
@@ -517,7 +517,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u
517 */ 517 */
518 dev = alloc_irdadev(sizeof(struct smsc_ircc_cb)); 518 dev = alloc_irdadev(sizeof(struct smsc_ircc_cb));
519 if (!dev) { 519 if (!dev) {
520 IRDA_WARNING("%s() can't allocate net device\n", __FUNCTION__); 520 IRDA_WARNING("%s() can't allocate net device\n", __func__);
521 goto err_out1; 521 goto err_out1;
522 } 522 }
523 523
@@ -633,14 +633,14 @@ static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base)
633 if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT, 633 if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT,
634 driver_name)) { 634 driver_name)) {
635 IRDA_WARNING("%s: can't get fir_base of 0x%03x\n", 635 IRDA_WARNING("%s: can't get fir_base of 0x%03x\n",
636 __FUNCTION__, fir_base); 636 __func__, fir_base);
637 goto out1; 637 goto out1;
638 } 638 }
639 639
640 if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT, 640 if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT,
641 driver_name)) { 641 driver_name)) {
642 IRDA_WARNING("%s: can't get sir_base of 0x%03x\n", 642 IRDA_WARNING("%s: can't get sir_base of 0x%03x\n",
643 __FUNCTION__, sir_base); 643 __func__, sir_base);
644 goto out2; 644 goto out2;
645 } 645 }
646 646
@@ -656,7 +656,7 @@ static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base)
656 656
657 if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) { 657 if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) {
658 IRDA_WARNING("%s(), addr 0x%04x - no device found!\n", 658 IRDA_WARNING("%s(), addr 0x%04x - no device found!\n",
659 __FUNCTION__, fir_base); 659 __func__, fir_base);
660 goto out3; 660 goto out3;
661 } 661 }
662 IRDA_MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, " 662 IRDA_MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, "
@@ -793,7 +793,7 @@ static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd
793 793
794 IRDA_ASSERT(self != NULL, return -1;); 794 IRDA_ASSERT(self != NULL, return -1;);
795 795
796 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd); 796 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name, cmd);
797 797
798 switch (cmd) { 798 switch (cmd) {
799 case SIOCSBANDWIDTH: /* Set bandwidth */ 799 case SIOCSBANDWIDTH: /* Set bandwidth */
@@ -878,7 +878,7 @@ int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
878 unsigned long flags; 878 unsigned long flags;
879 s32 speed; 879 s32 speed;
880 880
881 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 881 IRDA_DEBUG(1, "%s\n", __func__);
882 882
883 IRDA_ASSERT(dev != NULL, return 0;); 883 IRDA_ASSERT(dev != NULL, return 0;);
884 884
@@ -953,21 +953,21 @@ static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed)
953 ir_mode = IRCC_CFGA_IRDA_HDLC; 953 ir_mode = IRCC_CFGA_IRDA_HDLC;
954 ctrl = IRCC_CRC; 954 ctrl = IRCC_CRC;
955 fast = 0; 955 fast = 0;
956 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__); 956 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __func__);
957 break; 957 break;
958 case 1152000: 958 case 1152000:
959 ir_mode = IRCC_CFGA_IRDA_HDLC; 959 ir_mode = IRCC_CFGA_IRDA_HDLC;
960 ctrl = IRCC_1152 | IRCC_CRC; 960 ctrl = IRCC_1152 | IRCC_CRC;
961 fast = IRCC_LCR_A_FAST | IRCC_LCR_A_GP_DATA; 961 fast = IRCC_LCR_A_FAST | IRCC_LCR_A_GP_DATA;
962 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", 962 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n",
963 __FUNCTION__); 963 __func__);
964 break; 964 break;
965 case 4000000: 965 case 4000000:
966 ir_mode = IRCC_CFGA_IRDA_4PPM; 966 ir_mode = IRCC_CFGA_IRDA_4PPM;
967 ctrl = IRCC_CRC; 967 ctrl = IRCC_CRC;
968 fast = IRCC_LCR_A_FAST; 968 fast = IRCC_LCR_A_FAST;
969 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", 969 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n",
970 __FUNCTION__); 970 __func__);
971 break; 971 break;
972 } 972 }
973 #if 0 973 #if 0
@@ -995,7 +995,7 @@ static void smsc_ircc_fir_start(struct smsc_ircc_cb *self)
995 struct net_device *dev; 995 struct net_device *dev;
996 int fir_base; 996 int fir_base;
997 997
998 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 998 IRDA_DEBUG(1, "%s\n", __func__);
999 999
1000 IRDA_ASSERT(self != NULL, return;); 1000 IRDA_ASSERT(self != NULL, return;);
1001 dev = self->netdev; 1001 dev = self->netdev;
@@ -1043,7 +1043,7 @@ static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self)
1043{ 1043{
1044 int fir_base; 1044 int fir_base;
1045 1045
1046 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 1046 IRDA_DEBUG(1, "%s\n", __func__);
1047 1047
1048 IRDA_ASSERT(self != NULL, return;); 1048 IRDA_ASSERT(self != NULL, return;);
1049 1049
@@ -1067,7 +1067,7 @@ static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed)
1067 struct net_device *dev; 1067 struct net_device *dev;
1068 int last_speed_was_sir; 1068 int last_speed_was_sir;
1069 1069
1070 IRDA_DEBUG(0, "%s() changing speed to: %d\n", __FUNCTION__, speed); 1070 IRDA_DEBUG(0, "%s() changing speed to: %d\n", __func__, speed);
1071 1071
1072 IRDA_ASSERT(self != NULL, return;); 1072 IRDA_ASSERT(self != NULL, return;);
1073 dev = self->netdev; 1073 dev = self->netdev;
@@ -1135,7 +1135,7 @@ void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, __u32 speed)
1135 int lcr; /* Line control reg */ 1135 int lcr; /* Line control reg */
1136 int divisor; 1136 int divisor;
1137 1137
1138 IRDA_DEBUG(0, "%s(), Setting speed to: %d\n", __FUNCTION__, speed); 1138 IRDA_DEBUG(0, "%s(), Setting speed to: %d\n", __func__, speed);
1139 1139
1140 IRDA_ASSERT(self != NULL, return;); 1140 IRDA_ASSERT(self != NULL, return;);
1141 iobase = self->io.sir_base; 1141 iobase = self->io.sir_base;
@@ -1170,7 +1170,7 @@ void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, __u32 speed)
1170 /* Turn on interrups */ 1170 /* Turn on interrups */
1171 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); 1171 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
1172 1172
1173 IRDA_DEBUG(2, "%s() speed changed to: %d\n", __FUNCTION__, speed); 1173 IRDA_DEBUG(2, "%s() speed changed to: %d\n", __func__, speed);
1174} 1174}
1175 1175
1176 1176
@@ -1253,7 +1253,7 @@ static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs)
1253 int iobase = self->io.fir_base; 1253 int iobase = self->io.fir_base;
1254 u8 ctrl; 1254 u8 ctrl;
1255 1255
1256 IRDA_DEBUG(3, "%s\n", __FUNCTION__); 1256 IRDA_DEBUG(3, "%s\n", __func__);
1257#if 1 1257#if 1
1258 /* Disable Rx */ 1258 /* Disable Rx */
1259 register_bank(iobase, 0); 1259 register_bank(iobase, 0);
@@ -1307,7 +1307,7 @@ static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self)
1307{ 1307{
1308 int iobase = self->io.fir_base; 1308 int iobase = self->io.fir_base;
1309 1309
1310 IRDA_DEBUG(3, "%s\n", __FUNCTION__); 1310 IRDA_DEBUG(3, "%s\n", __func__);
1311#if 0 1311#if 0
1312 /* Disable Tx */ 1312 /* Disable Tx */
1313 register_bank(iobase, 0); 1313 register_bank(iobase, 0);
@@ -1411,7 +1411,7 @@ static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
1411 1411
1412 register_bank(iobase, 0); 1412 register_bank(iobase, 0);
1413 1413
1414 IRDA_DEBUG(3, "%s\n", __FUNCTION__); 1414 IRDA_DEBUG(3, "%s\n", __func__);
1415#if 0 1415#if 0
1416 /* Disable Rx */ 1416 /* Disable Rx */
1417 register_bank(iobase, 0); 1417 register_bank(iobase, 0);
@@ -1422,7 +1422,7 @@ static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
1422 lsr= inb(iobase + IRCC_LSR); 1422 lsr= inb(iobase + IRCC_LSR);
1423 msgcnt = inb(iobase + IRCC_LCR_B) & 0x08; 1423 msgcnt = inb(iobase + IRCC_LCR_B) & 0x08;
1424 1424
1425 IRDA_DEBUG(2, "%s: dma count = %d\n", __FUNCTION__, 1425 IRDA_DEBUG(2, "%s: dma count = %d\n", __func__,
1426 get_dma_residue(self->io.dma)); 1426 get_dma_residue(self->io.dma));
1427 1427
1428 len = self->rx_buff.truesize - get_dma_residue(self->io.dma); 1428 len = self->rx_buff.truesize - get_dma_residue(self->io.dma);
@@ -1445,15 +1445,15 @@ static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
1445 len -= self->io.speed < 4000000 ? 2 : 4; 1445 len -= self->io.speed < 4000000 ? 2 : 4;
1446 1446
1447 if (len < 2 || len > 2050) { 1447 if (len < 2 || len > 2050) {
1448 IRDA_WARNING("%s(), bogus len=%d\n", __FUNCTION__, len); 1448 IRDA_WARNING("%s(), bogus len=%d\n", __func__, len);
1449 return; 1449 return;
1450 } 1450 }
1451 IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __FUNCTION__, msgcnt, len); 1451 IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __func__, msgcnt, len);
1452 1452
1453 skb = dev_alloc_skb(len + 1); 1453 skb = dev_alloc_skb(len + 1);
1454 if (!skb) { 1454 if (!skb) {
1455 IRDA_WARNING("%s(), memory squeeze, dropping frame.\n", 1455 IRDA_WARNING("%s(), memory squeeze, dropping frame.\n",
1456 __FUNCTION__); 1456 __func__);
1457 return; 1457 return;
1458 } 1458 }
1459 /* Make sure IP header gets aligned */ 1459 /* Make sure IP header gets aligned */
@@ -1494,7 +1494,7 @@ static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self)
1494 1494
1495 /* Make sure we don't stay here to long */ 1495 /* Make sure we don't stay here to long */
1496 if (boguscount++ > 32) { 1496 if (boguscount++ > 32) {
1497 IRDA_DEBUG(2, "%s(), breaking!\n", __FUNCTION__); 1497 IRDA_DEBUG(2, "%s(), breaking!\n", __func__);
1498 break; 1498 break;
1499 } 1499 }
1500 } while (inb(iobase + UART_LSR) & UART_LSR_DR); 1500 } while (inb(iobase + UART_LSR) & UART_LSR_DR);
@@ -1536,7 +1536,7 @@ static irqreturn_t smsc_ircc_interrupt(int dummy, void *dev_id)
1536 lcra = inb(iobase + IRCC_LCR_A); 1536 lcra = inb(iobase + IRCC_LCR_A);
1537 lsr = inb(iobase + IRCC_LSR); 1537 lsr = inb(iobase + IRCC_LSR);
1538 1538
1539 IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __FUNCTION__, iir); 1539 IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __func__, iir);
1540 1540
1541 if (iir & IRCC_IIR_EOM) { 1541 if (iir & IRCC_IIR_EOM) {
1542 if (self->io.direction == IO_RECV) 1542 if (self->io.direction == IO_RECV)
@@ -1548,7 +1548,7 @@ static irqreturn_t smsc_ircc_interrupt(int dummy, void *dev_id)
1548 } 1548 }
1549 1549
1550 if (iir & IRCC_IIR_ACTIVE_FRAME) { 1550 if (iir & IRCC_IIR_ACTIVE_FRAME) {
1551 /*printk(KERN_WARNING "%s(): Active Frame\n", __FUNCTION__);*/ 1551 /*printk(KERN_WARNING "%s(): Active Frame\n", __func__);*/
1552 } 1552 }
1553 1553
1554 /* Enable interrupts again */ 1554 /* Enable interrupts again */
@@ -1587,11 +1587,11 @@ static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev)
1587 lsr = inb(iobase + UART_LSR); 1587 lsr = inb(iobase + UART_LSR);
1588 1588
1589 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n", 1589 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n",
1590 __FUNCTION__, iir, lsr, iobase); 1590 __func__, iir, lsr, iobase);
1591 1591
1592 switch (iir) { 1592 switch (iir) {
1593 case UART_IIR_RLSI: 1593 case UART_IIR_RLSI:
1594 IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__); 1594 IRDA_DEBUG(2, "%s(), RLSI\n", __func__);
1595 break; 1595 break;
1596 case UART_IIR_RDI: 1596 case UART_IIR_RDI:
1597 /* Receive interrupt */ 1597 /* Receive interrupt */
@@ -1604,7 +1604,7 @@ static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev)
1604 break; 1604 break;
1605 default: 1605 default:
1606 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n", 1606 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n",
1607 __FUNCTION__, iir); 1607 __func__, iir);
1608 break; 1608 break;
1609 } 1609 }
1610 1610
@@ -1631,11 +1631,11 @@ static int ircc_is_receiving(struct smsc_ircc_cb *self)
1631 int status = FALSE; 1631 int status = FALSE;
1632 /* int iobase; */ 1632 /* int iobase; */
1633 1633
1634 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 1634 IRDA_DEBUG(1, "%s\n", __func__);
1635 1635
1636 IRDA_ASSERT(self != NULL, return FALSE;); 1636 IRDA_ASSERT(self != NULL, return FALSE;);
1637 1637
1638 IRDA_DEBUG(0, "%s: dma count = %d\n", __FUNCTION__, 1638 IRDA_DEBUG(0, "%s: dma count = %d\n", __func__,
1639 get_dma_residue(self->io.dma)); 1639 get_dma_residue(self->io.dma));
1640 1640
1641 status = (self->rx_buff.state != OUTSIDE_FRAME); 1641 status = (self->rx_buff.state != OUTSIDE_FRAME);
@@ -1652,7 +1652,7 @@ static int smsc_ircc_request_irq(struct smsc_ircc_cb *self)
1652 self->netdev->name, self->netdev); 1652 self->netdev->name, self->netdev);
1653 if (error) 1653 if (error)
1654 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d, err=%d\n", 1654 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d, err=%d\n",
1655 __FUNCTION__, self->io.irq, error); 1655 __func__, self->io.irq, error);
1656 1656
1657 return error; 1657 return error;
1658} 1658}
@@ -1696,21 +1696,21 @@ static int smsc_ircc_net_open(struct net_device *dev)
1696 struct smsc_ircc_cb *self; 1696 struct smsc_ircc_cb *self;
1697 char hwname[16]; 1697 char hwname[16];
1698 1698
1699 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 1699 IRDA_DEBUG(1, "%s\n", __func__);
1700 1700
1701 IRDA_ASSERT(dev != NULL, return -1;); 1701 IRDA_ASSERT(dev != NULL, return -1;);
1702 self = netdev_priv(dev); 1702 self = netdev_priv(dev);
1703 IRDA_ASSERT(self != NULL, return 0;); 1703 IRDA_ASSERT(self != NULL, return 0;);
1704 1704
1705 if (self->io.suspended) { 1705 if (self->io.suspended) {
1706 IRDA_DEBUG(0, "%s(), device is suspended\n", __FUNCTION__); 1706 IRDA_DEBUG(0, "%s(), device is suspended\n", __func__);
1707 return -EAGAIN; 1707 return -EAGAIN;
1708 } 1708 }
1709 1709
1710 if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name, 1710 if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name,
1711 (void *) dev)) { 1711 (void *) dev)) {
1712 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n", 1712 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n",
1713 __FUNCTION__, self->io.irq); 1713 __func__, self->io.irq);
1714 return -EAGAIN; 1714 return -EAGAIN;
1715 } 1715 }
1716 1716
@@ -1734,7 +1734,7 @@ static int smsc_ircc_net_open(struct net_device *dev)
1734 smsc_ircc_net_close(dev); 1734 smsc_ircc_net_close(dev);
1735 1735
1736 IRDA_WARNING("%s(), unable to allocate DMA=%d\n", 1736 IRDA_WARNING("%s(), unable to allocate DMA=%d\n",
1737 __FUNCTION__, self->io.dma); 1737 __func__, self->io.dma);
1738 return -EAGAIN; 1738 return -EAGAIN;
1739 } 1739 }
1740 1740
@@ -1753,7 +1753,7 @@ static int smsc_ircc_net_close(struct net_device *dev)
1753{ 1753{
1754 struct smsc_ircc_cb *self; 1754 struct smsc_ircc_cb *self;
1755 1755
1756 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 1756 IRDA_DEBUG(1, "%s\n", __func__);
1757 1757
1758 IRDA_ASSERT(dev != NULL, return -1;); 1758 IRDA_ASSERT(dev != NULL, return -1;);
1759 self = netdev_priv(dev); 1759 self = netdev_priv(dev);
@@ -1836,7 +1836,7 @@ static int smsc_ircc_resume(struct platform_device *dev)
1836 */ 1836 */
1837static int __exit smsc_ircc_close(struct smsc_ircc_cb *self) 1837static int __exit smsc_ircc_close(struct smsc_ircc_cb *self)
1838{ 1838{
1839 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 1839 IRDA_DEBUG(1, "%s\n", __func__);
1840 1840
1841 IRDA_ASSERT(self != NULL, return -1;); 1841 IRDA_ASSERT(self != NULL, return -1;);
1842 1842
@@ -1848,12 +1848,12 @@ static int __exit smsc_ircc_close(struct smsc_ircc_cb *self)
1848 smsc_ircc_stop_interrupts(self); 1848 smsc_ircc_stop_interrupts(self);
1849 1849
1850 /* Release the PORTS that this driver is using */ 1850 /* Release the PORTS that this driver is using */
1851 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__, 1851 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __func__,
1852 self->io.fir_base); 1852 self->io.fir_base);
1853 1853
1854 release_region(self->io.fir_base, self->io.fir_ext); 1854 release_region(self->io.fir_base, self->io.fir_ext);
1855 1855
1856 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__, 1856 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __func__,
1857 self->io.sir_base); 1857 self->io.sir_base);
1858 1858
1859 release_region(self->io.sir_base, self->io.sir_ext); 1859 release_region(self->io.sir_base, self->io.sir_ext);
@@ -1875,7 +1875,7 @@ static void __exit smsc_ircc_cleanup(void)
1875{ 1875{
1876 int i; 1876 int i;
1877 1877
1878 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 1878 IRDA_DEBUG(1, "%s\n", __func__);
1879 1879
1880 for (i = 0; i < 2; i++) { 1880 for (i = 0; i < 2; i++) {
1881 if (dev_self[i]) 1881 if (dev_self[i])
@@ -1899,7 +1899,7 @@ void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
1899 struct net_device *dev; 1899 struct net_device *dev;
1900 int fir_base, sir_base; 1900 int fir_base, sir_base;
1901 1901
1902 IRDA_DEBUG(3, "%s\n", __FUNCTION__); 1902 IRDA_DEBUG(3, "%s\n", __func__);
1903 1903
1904 IRDA_ASSERT(self != NULL, return;); 1904 IRDA_ASSERT(self != NULL, return;);
1905 dev = self->netdev; 1905 dev = self->netdev;
@@ -1926,7 +1926,7 @@ void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
1926 /* Turn on interrups */ 1926 /* Turn on interrups */
1927 outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base + UART_IER); 1927 outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base + UART_IER);
1928 1928
1929 IRDA_DEBUG(3, "%s() - exit\n", __FUNCTION__); 1929 IRDA_DEBUG(3, "%s() - exit\n", __func__);
1930 1930
1931 outb(0x00, fir_base + IRCC_MASTER); 1931 outb(0x00, fir_base + IRCC_MASTER);
1932} 1932}
@@ -1936,7 +1936,7 @@ void smsc_ircc_sir_stop(struct smsc_ircc_cb *self)
1936{ 1936{
1937 int iobase; 1937 int iobase;
1938 1938
1939 IRDA_DEBUG(3, "%s\n", __FUNCTION__); 1939 IRDA_DEBUG(3, "%s\n", __func__);
1940 iobase = self->io.sir_base; 1940 iobase = self->io.sir_base;
1941 1941
1942 /* Reset UART */ 1942 /* Reset UART */
@@ -1962,7 +1962,7 @@ static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
1962 1962
1963 IRDA_ASSERT(self != NULL, return;); 1963 IRDA_ASSERT(self != NULL, return;);
1964 1964
1965 IRDA_DEBUG(4, "%s\n", __FUNCTION__); 1965 IRDA_DEBUG(4, "%s\n", __func__);
1966 1966
1967 iobase = self->io.sir_base; 1967 iobase = self->io.sir_base;
1968 1968
@@ -1984,7 +1984,7 @@ static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
1984 */ 1984 */
1985 if (self->new_speed) { 1985 if (self->new_speed) {
1986 IRDA_DEBUG(5, "%s(), Changing speed to %d.\n", 1986 IRDA_DEBUG(5, "%s(), Changing speed to %d.\n",
1987 __FUNCTION__, self->new_speed); 1987 __func__, self->new_speed);
1988 smsc_ircc_sir_wait_hw_transmitter_finish(self); 1988 smsc_ircc_sir_wait_hw_transmitter_finish(self);
1989 smsc_ircc_change_speed(self, self->new_speed); 1989 smsc_ircc_change_speed(self, self->new_speed);
1990 self->new_speed = 0; 1990 self->new_speed = 0;
@@ -2023,7 +2023,7 @@ static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
2023 2023
2024 /* Tx FIFO should be empty! */ 2024 /* Tx FIFO should be empty! */
2025 if (!(inb(iobase + UART_LSR) & UART_LSR_THRE)) { 2025 if (!(inb(iobase + UART_LSR) & UART_LSR_THRE)) {
2026 IRDA_WARNING("%s(), failed, fifo not empty!\n", __FUNCTION__); 2026 IRDA_WARNING("%s(), failed, fifo not empty!\n", __func__);
2027 return 0; 2027 return 0;
2028 } 2028 }
2029 2029
@@ -2123,7 +2123,7 @@ static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self)
2123 udelay(1); 2123 udelay(1);
2124 2124
2125 if (count == 0) 2125 if (count == 0)
2126 IRDA_DEBUG(0, "%s(): stuck transmitter\n", __FUNCTION__); 2126 IRDA_DEBUG(0, "%s(): stuck transmitter\n", __func__);
2127} 2127}
2128 2128
2129 2129
@@ -2145,7 +2145,7 @@ static int __init smsc_ircc_look_for_chips(void)
2145 while (address->cfg_base) { 2145 while (address->cfg_base) {
2146 cfg_base = address->cfg_base; 2146 cfg_base = address->cfg_base;
2147 2147
2148 /*printk(KERN_WARNING "%s(): probing: 0x%02x for: 0x%02x\n", __FUNCTION__, cfg_base, address->type);*/ 2148 /*printk(KERN_WARNING "%s(): probing: 0x%02x for: 0x%02x\n", __func__, cfg_base, address->type);*/
2149 2149
2150 if (address->type & SMSCSIO_TYPE_FDC) { 2150 if (address->type & SMSCSIO_TYPE_FDC) {
2151 type = "FDC"; 2151 type = "FDC";
@@ -2184,7 +2184,7 @@ static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned shor
2184 u8 mode, dma, irq; 2184 u8 mode, dma, irq;
2185 int ret = -ENODEV; 2185 int ret = -ENODEV;
2186 2186
2187 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 2187 IRDA_DEBUG(1, "%s\n", __func__);
2188 2188
2189 if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type) == NULL) 2189 if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type) == NULL)
2190 return ret; 2190 return ret;
@@ -2192,10 +2192,10 @@ static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned shor
2192 outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase); 2192 outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase);
2193 mode = inb(cfgbase + 1); 2193 mode = inb(cfgbase + 1);
2194 2194
2195 /*printk(KERN_WARNING "%s(): mode: 0x%02x\n", __FUNCTION__, mode);*/ 2195 /*printk(KERN_WARNING "%s(): mode: 0x%02x\n", __func__, mode);*/
2196 2196
2197 if (!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA)) 2197 if (!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA))
2198 IRDA_WARNING("%s(): IrDA not enabled\n", __FUNCTION__); 2198 IRDA_WARNING("%s(): IrDA not enabled\n", __func__);
2199 2199
2200 outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase); 2200 outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase);
2201 sirbase = inb(cfgbase + 1) << 2; 2201 sirbase = inb(cfgbase + 1) << 2;
@@ -2212,7 +2212,7 @@ static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned shor
2212 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase); 2212 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase);
2213 irq = inb(cfgbase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK; 2213 irq = inb(cfgbase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
2214 2214
2215 IRDA_MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __FUNCTION__, firbase, sirbase, dma, irq, mode); 2215 IRDA_MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __func__, firbase, sirbase, dma, irq, mode);
2216 2216
2217 if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0) 2217 if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0)
2218 ret = 0; 2218 ret = 0;
@@ -2234,7 +2234,7 @@ static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned sho
2234 unsigned short fir_io, sir_io; 2234 unsigned short fir_io, sir_io;
2235 int ret = -ENODEV; 2235 int ret = -ENODEV;
2236 2236
2237 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 2237 IRDA_DEBUG(1, "%s\n", __func__);
2238 2238
2239 if (smsc_ircc_probe(cfg_base, 0x20, chips, type) == NULL) 2239 if (smsc_ircc_probe(cfg_base, 0x20, chips, type) == NULL)
2240 return ret; 2240 return ret;
@@ -2268,7 +2268,7 @@ static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned sho
2268 2268
2269static int __init smsc_access(unsigned short cfg_base, unsigned char reg) 2269static int __init smsc_access(unsigned short cfg_base, unsigned char reg)
2270{ 2270{
2271 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 2271 IRDA_DEBUG(1, "%s\n", __func__);
2272 2272
2273 outb(reg, cfg_base); 2273 outb(reg, cfg_base);
2274 return inb(cfg_base) != reg ? -1 : 0; 2274 return inb(cfg_base) != reg ? -1 : 0;
@@ -2278,7 +2278,7 @@ static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base,
2278{ 2278{
2279 u8 devid, xdevid, rev; 2279 u8 devid, xdevid, rev;
2280 2280
2281 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 2281 IRDA_DEBUG(1, "%s\n", __func__);
2282 2282
2283 /* Leave configuration */ 2283 /* Leave configuration */
2284 2284
@@ -2353,7 +2353,7 @@ static int __init smsc_superio_fdc(unsigned short cfg_base)
2353 2353
2354 if (!request_region(cfg_base, 2, driver_name)) { 2354 if (!request_region(cfg_base, 2, driver_name)) {
2355 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n", 2355 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2356 __FUNCTION__, cfg_base); 2356 __func__, cfg_base);
2357 } else { 2357 } else {
2358 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, "FDC") || 2358 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, "FDC") ||
2359 !smsc_superio_paged(fdc_chips_paged, cfg_base, "FDC")) 2359 !smsc_superio_paged(fdc_chips_paged, cfg_base, "FDC"))
@@ -2371,7 +2371,7 @@ static int __init smsc_superio_lpc(unsigned short cfg_base)
2371 2371
2372 if (!request_region(cfg_base, 2, driver_name)) { 2372 if (!request_region(cfg_base, 2, driver_name)) {
2373 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n", 2373 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2374 __FUNCTION__, cfg_base); 2374 __func__, cfg_base);
2375 } else { 2375 } else {
2376 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, "LPC") || 2376 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, "LPC") ||
2377 !smsc_superio_paged(lpc_chips_paged, cfg_base, "LPC")) 2377 !smsc_superio_paged(lpc_chips_paged, cfg_base, "LPC"))
@@ -2932,7 +2932,7 @@ static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed)
2932 /* empty */; 2932 /* empty */;
2933 2933
2934 if (val) 2934 if (val)
2935 IRDA_WARNING("%s(): ATC: 0x%02x\n", __FUNCTION__, 2935 IRDA_WARNING("%s(): ATC: 0x%02x\n", __func__,
2936 inb(fir_base + IRCC_ATC)); 2936 inb(fir_base + IRCC_ATC));
2937} 2937}
2938 2938
diff --git a/drivers/net/irda/tekram-sir.c b/drivers/net/irda/tekram-sir.c
index d1ce5ae6a172..048a15422844 100644
--- a/drivers/net/irda/tekram-sir.c
+++ b/drivers/net/irda/tekram-sir.c
@@ -77,7 +77,7 @@ static int tekram_open(struct sir_dev *dev)
77{ 77{
78 struct qos_info *qos = &dev->qos; 78 struct qos_info *qos = &dev->qos;
79 79
80 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 80 IRDA_DEBUG(2, "%s()\n", __func__);
81 81
82 sirdev_set_dtr_rts(dev, TRUE, TRUE); 82 sirdev_set_dtr_rts(dev, TRUE, TRUE);
83 83
@@ -92,7 +92,7 @@ static int tekram_open(struct sir_dev *dev)
92 92
93static int tekram_close(struct sir_dev *dev) 93static int tekram_close(struct sir_dev *dev)
94{ 94{
95 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 95 IRDA_DEBUG(2, "%s()\n", __func__);
96 96
97 /* Power off dongle */ 97 /* Power off dongle */
98 sirdev_set_dtr_rts(dev, FALSE, FALSE); 98 sirdev_set_dtr_rts(dev, FALSE, FALSE);
@@ -130,7 +130,7 @@ static int tekram_change_speed(struct sir_dev *dev, unsigned speed)
130 u8 byte; 130 u8 byte;
131 static int ret = 0; 131 static int ret = 0;
132 132
133 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 133 IRDA_DEBUG(2, "%s()\n", __func__);
134 134
135 switch(state) { 135 switch(state) {
136 case SIRDEV_STATE_DONGLE_SPEED: 136 case SIRDEV_STATE_DONGLE_SPEED:
@@ -179,7 +179,7 @@ static int tekram_change_speed(struct sir_dev *dev, unsigned speed)
179 break; 179 break;
180 180
181 default: 181 default:
182 IRDA_ERROR("%s - undefined state %d\n", __FUNCTION__, state); 182 IRDA_ERROR("%s - undefined state %d\n", __func__, state);
183 ret = -EINVAL; 183 ret = -EINVAL;
184 break; 184 break;
185 } 185 }
@@ -204,7 +204,7 @@ static int tekram_change_speed(struct sir_dev *dev, unsigned speed)
204 204
205static int tekram_reset(struct sir_dev *dev) 205static int tekram_reset(struct sir_dev *dev)
206{ 206{
207 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 207 IRDA_DEBUG(2, "%s()\n", __func__);
208 208
209 /* Clear DTR, Set RTS */ 209 /* Clear DTR, Set RTS */
210 sirdev_set_dtr_rts(dev, FALSE, TRUE); 210 sirdev_set_dtr_rts(dev, FALSE, TRUE);
diff --git a/drivers/net/irda/toim3232-sir.c b/drivers/net/irda/toim3232-sir.c
index aa1a9b0ed83e..fcf287b749db 100644
--- a/drivers/net/irda/toim3232-sir.c
+++ b/drivers/net/irda/toim3232-sir.c
@@ -181,7 +181,7 @@ static int toim3232_open(struct sir_dev *dev)
181{ 181{
182 struct qos_info *qos = &dev->qos; 182 struct qos_info *qos = &dev->qos;
183 183
184 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 184 IRDA_DEBUG(2, "%s()\n", __func__);
185 185
186 /* Pull the lines high to start with. 186 /* Pull the lines high to start with.
187 * 187 *
@@ -209,7 +209,7 @@ static int toim3232_open(struct sir_dev *dev)
209 209
210static int toim3232_close(struct sir_dev *dev) 210static int toim3232_close(struct sir_dev *dev)
211{ 211{
212 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 212 IRDA_DEBUG(2, "%s()\n", __func__);
213 213
214 /* Power off dongle */ 214 /* Power off dongle */
215 sirdev_set_dtr_rts(dev, FALSE, FALSE); 215 sirdev_set_dtr_rts(dev, FALSE, FALSE);
@@ -241,7 +241,7 @@ static int toim3232_change_speed(struct sir_dev *dev, unsigned speed)
241 u8 byte; 241 u8 byte;
242 static int ret = 0; 242 static int ret = 0;
243 243
244 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 244 IRDA_DEBUG(2, "%s()\n", __func__);
245 245
246 switch(state) { 246 switch(state) {
247 case SIRDEV_STATE_DONGLE_SPEED: 247 case SIRDEV_STATE_DONGLE_SPEED:
@@ -299,7 +299,7 @@ static int toim3232_change_speed(struct sir_dev *dev, unsigned speed)
299 break; 299 break;
300 300
301 default: 301 default:
302 printk(KERN_ERR "%s - undefined state %d\n", __FUNCTION__, state); 302 printk(KERN_ERR "%s - undefined state %d\n", __func__, state);
303 ret = -EINVAL; 303 ret = -EINVAL;
304 break; 304 break;
305 } 305 }
@@ -344,7 +344,7 @@ static int toim3232_change_speed(struct sir_dev *dev, unsigned speed)
344 344
345static int toim3232_reset(struct sir_dev *dev) 345static int toim3232_reset(struct sir_dev *dev)
346{ 346{
347 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 347 IRDA_DEBUG(2, "%s()\n", __func__);
348 348
349 /* Switch off both DTR and RTS to switch off dongle */ 349 /* Switch off both DTR and RTS to switch off dongle */
350 sirdev_set_dtr_rts(dev, FALSE, FALSE); 350 sirdev_set_dtr_rts(dev, FALSE, FALSE);
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 04ad3573b159..84e609ea5fbb 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -152,12 +152,12 @@ static int __init via_ircc_init(void)
152{ 152{
153 int rc; 153 int rc;
154 154
155 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 155 IRDA_DEBUG(3, "%s()\n", __func__);
156 156
157 rc = pci_register_driver(&via_driver); 157 rc = pci_register_driver(&via_driver);
158 if (rc < 0) { 158 if (rc < 0) {
159 IRDA_DEBUG(0, "%s(): error rc = %d, returning -ENODEV...\n", 159 IRDA_DEBUG(0, "%s(): error rc = %d, returning -ENODEV...\n",
160 __FUNCTION__, rc); 160 __func__, rc);
161 return -ENODEV; 161 return -ENODEV;
162 } 162 }
163 return 0; 163 return 0;
@@ -170,11 +170,11 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
170 u16 Chipset,FirDRQ1,FirDRQ0,FirIRQ,FirIOBase; 170 u16 Chipset,FirDRQ1,FirDRQ0,FirIRQ,FirIOBase;
171 chipio_t info; 171 chipio_t info;
172 172
173 IRDA_DEBUG(2, "%s(): Device ID=(0X%X)\n", __FUNCTION__, id->device); 173 IRDA_DEBUG(2, "%s(): Device ID=(0X%X)\n", __func__, id->device);
174 174
175 rc = pci_enable_device (pcidev); 175 rc = pci_enable_device (pcidev);
176 if (rc) { 176 if (rc) {
177 IRDA_DEBUG(0, "%s(): error rc = %d\n", __FUNCTION__, rc); 177 IRDA_DEBUG(0, "%s(): error rc = %d\n", __func__, rc);
178 return -ENODEV; 178 return -ENODEV;
179 } 179 }
180 180
@@ -185,7 +185,7 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
185 Chipset=0x3076; 185 Chipset=0x3076;
186 186
187 if (Chipset==0x3076) { 187 if (Chipset==0x3076) {
188 IRDA_DEBUG(2, "%s(): Chipset = 3076\n", __FUNCTION__); 188 IRDA_DEBUG(2, "%s(): Chipset = 3076\n", __func__);
189 189
190 WriteLPCReg(7,0x0c ); 190 WriteLPCReg(7,0x0c );
191 temp=ReadLPCReg(0x30);//check if BIOS Enable Fir 191 temp=ReadLPCReg(0x30);//check if BIOS Enable Fir
@@ -222,7 +222,7 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
222 } else 222 } else
223 rc = -ENODEV; //IR not turn on 223 rc = -ENODEV; //IR not turn on
224 } else { //Not VT1211 224 } else { //Not VT1211
225 IRDA_DEBUG(2, "%s(): Chipset = 3096\n", __FUNCTION__); 225 IRDA_DEBUG(2, "%s(): Chipset = 3096\n", __func__);
226 226
227 pci_read_config_byte(pcidev,0x67,&bTmp);//check if BIOS Enable Fir 227 pci_read_config_byte(pcidev,0x67,&bTmp);//check if BIOS Enable Fir
228 if((bTmp&0x01)==1) { // BIOS enable FIR 228 if((bTmp&0x01)==1) { // BIOS enable FIR
@@ -262,7 +262,7 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
262 rc = -ENODEV; //IR not turn on !!!!! 262 rc = -ENODEV; //IR not turn on !!!!!
263 }//Not VT1211 263 }//Not VT1211
264 264
265 IRDA_DEBUG(2, "%s(): End - rc = %d\n", __FUNCTION__, rc); 265 IRDA_DEBUG(2, "%s(): End - rc = %d\n", __func__, rc);
266 return rc; 266 return rc;
267} 267}
268 268
@@ -276,7 +276,7 @@ static void via_ircc_clean(void)
276{ 276{
277 int i; 277 int i;
278 278
279 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 279 IRDA_DEBUG(3, "%s()\n", __func__);
280 280
281 for (i=0; i < ARRAY_SIZE(dev_self); i++) { 281 for (i=0; i < ARRAY_SIZE(dev_self); i++) {
282 if (dev_self[i]) 282 if (dev_self[i])
@@ -286,7 +286,7 @@ static void via_ircc_clean(void)
286 286
287static void __devexit via_remove_one (struct pci_dev *pdev) 287static void __devexit via_remove_one (struct pci_dev *pdev)
288{ 288{
289 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 289 IRDA_DEBUG(3, "%s()\n", __func__);
290 290
291 /* FIXME : This is ugly. We should use pci_get_drvdata(pdev); 291 /* FIXME : This is ugly. We should use pci_get_drvdata(pdev);
292 * to get our driver instance and call directly via_ircc_close(). 292 * to get our driver instance and call directly via_ircc_close().
@@ -301,7 +301,7 @@ static void __devexit via_remove_one (struct pci_dev *pdev)
301 301
302static void __exit via_ircc_cleanup(void) 302static void __exit via_ircc_cleanup(void)
303{ 303{
304 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 304 IRDA_DEBUG(3, "%s()\n", __func__);
305 305
306 /* FIXME : This should be redundant, as pci_unregister_driver() 306 /* FIXME : This should be redundant, as pci_unregister_driver()
307 * should call via_remove_one() on each device. 307 * should call via_remove_one() on each device.
@@ -324,7 +324,7 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
324 struct via_ircc_cb *self; 324 struct via_ircc_cb *self;
325 int err; 325 int err;
326 326
327 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 327 IRDA_DEBUG(3, "%s()\n", __func__);
328 328
329 if (i >= ARRAY_SIZE(dev_self)) 329 if (i >= ARRAY_SIZE(dev_self))
330 return -ENOMEM; 330 return -ENOMEM;
@@ -360,7 +360,7 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
360 /* Reserve the ioports that we need */ 360 /* Reserve the ioports that we need */
361 if (!request_region(self->io.fir_base, self->io.fir_ext, driver_name)) { 361 if (!request_region(self->io.fir_base, self->io.fir_ext, driver_name)) {
362 IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n", 362 IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
363 __FUNCTION__, self->io.fir_base); 363 __func__, self->io.fir_base);
364 err = -ENODEV; 364 err = -ENODEV;
365 goto err_out1; 365 goto err_out1;
366 } 366 }
@@ -471,7 +471,7 @@ static int via_ircc_close(struct via_ircc_cb *self)
471{ 471{
472 int iobase; 472 int iobase;
473 473
474 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 474 IRDA_DEBUG(3, "%s()\n", __func__);
475 475
476 IRDA_ASSERT(self != NULL, return -1;); 476 IRDA_ASSERT(self != NULL, return -1;);
477 477
@@ -483,7 +483,7 @@ static int via_ircc_close(struct via_ircc_cb *self)
483 483
484 /* Release the PORT that this driver is using */ 484 /* Release the PORT that this driver is using */
485 IRDA_DEBUG(2, "%s(), Releasing Region %03x\n", 485 IRDA_DEBUG(2, "%s(), Releasing Region %03x\n",
486 __FUNCTION__, self->io.fir_base); 486 __func__, self->io.fir_base);
487 release_region(self->io.fir_base, self->io.fir_ext); 487 release_region(self->io.fir_base, self->io.fir_ext);
488 if (self->tx_buff.head) 488 if (self->tx_buff.head)
489 dma_free_coherent(NULL, self->tx_buff.truesize, 489 dma_free_coherent(NULL, self->tx_buff.truesize,
@@ -509,7 +509,7 @@ static void via_hw_init(struct via_ircc_cb *self)
509{ 509{
510 int iobase = self->io.fir_base; 510 int iobase = self->io.fir_base;
511 511
512 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 512 IRDA_DEBUG(3, "%s()\n", __func__);
513 513
514 SetMaxRxPacketSize(iobase, 0x0fff); //set to max:4095 514 SetMaxRxPacketSize(iobase, 0x0fff); //set to max:4095
515 // FIFO Init 515 // FIFO Init
@@ -582,7 +582,7 @@ static void via_ircc_change_dongle_speed(int iobase, int speed,
582 speed = speed; 582 speed = speed;
583 583
584 IRDA_DEBUG(1, "%s(): change_dongle_speed to %d for 0x%x, %d\n", 584 IRDA_DEBUG(1, "%s(): change_dongle_speed to %d for 0x%x, %d\n",
585 __FUNCTION__, speed, iobase, dongle_id); 585 __func__, speed, iobase, dongle_id);
586 586
587 switch (dongle_id) { 587 switch (dongle_id) {
588 588
@@ -671,7 +671,7 @@ static void via_ircc_change_dongle_speed(int iobase, int speed,
671 671
672 case 0x11: /* Temic TFDS4500 */ 672 case 0x11: /* Temic TFDS4500 */
673 673
674 IRDA_DEBUG(2, "%s: Temic TFDS4500: One RX pin, TX normal, RX inverted.\n", __FUNCTION__); 674 IRDA_DEBUG(2, "%s: Temic TFDS4500: One RX pin, TX normal, RX inverted.\n", __func__);
675 675
676 UseOneRX(iobase, ON); //use ONE RX....RX1 676 UseOneRX(iobase, ON); //use ONE RX....RX1
677 InvertTX(iobase, OFF); 677 InvertTX(iobase, OFF);
@@ -689,7 +689,7 @@ static void via_ircc_change_dongle_speed(int iobase, int speed,
689 SlowIRRXLowActive(iobase, OFF); 689 SlowIRRXLowActive(iobase, OFF);
690 690
691 } else{ 691 } else{
692 IRDA_DEBUG(0, "%s: Warning: TFDS4500 not running in SIR mode !\n", __FUNCTION__); 692 IRDA_DEBUG(0, "%s: Warning: TFDS4500 not running in SIR mode !\n", __func__);
693 } 693 }
694 break; 694 break;
695 695
@@ -707,7 +707,7 @@ static void via_ircc_change_dongle_speed(int iobase, int speed,
707 707
708 default: 708 default:
709 IRDA_ERROR("%s: Error: dongle_id %d unsupported !\n", 709 IRDA_ERROR("%s: Error: dongle_id %d unsupported !\n",
710 __FUNCTION__, dongle_id); 710 __func__, dongle_id);
711 } 711 }
712} 712}
713 713
@@ -726,7 +726,7 @@ static void via_ircc_change_speed(struct via_ircc_cb *self, __u32 speed)
726 iobase = self->io.fir_base; 726 iobase = self->io.fir_base;
727 /* Update accounting for new speed */ 727 /* Update accounting for new speed */
728 self->io.speed = speed; 728 self->io.speed = speed;
729 IRDA_DEBUG(1, "%s: change_speed to %d bps.\n", __FUNCTION__, speed); 729 IRDA_DEBUG(1, "%s: change_speed to %d bps.\n", __func__, speed);
730 730
731 WriteReg(iobase, I_ST_CT_0, 0x0); 731 WriteReg(iobase, I_ST_CT_0, 0x0);
732 732
@@ -957,7 +957,7 @@ static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase)
957 self->tx_buff.head) + self->tx_buff_dma, 957 self->tx_buff.head) + self->tx_buff_dma,
958 self->tx_fifo.queue[self->tx_fifo.ptr].len, DMA_TX_MODE); 958 self->tx_fifo.queue[self->tx_fifo.ptr].len, DMA_TX_MODE);
959 IRDA_DEBUG(1, "%s: tx_fifo.ptr=%x,len=%x,tx_fifo.len=%x..\n", 959 IRDA_DEBUG(1, "%s: tx_fifo.ptr=%x,len=%x,tx_fifo.len=%x..\n",
960 __FUNCTION__, self->tx_fifo.ptr, 960 __func__, self->tx_fifo.ptr,
961 self->tx_fifo.queue[self->tx_fifo.ptr].len, 961 self->tx_fifo.queue[self->tx_fifo.ptr].len,
962 self->tx_fifo.len); 962 self->tx_fifo.len);
963 963
@@ -981,7 +981,7 @@ static int via_ircc_dma_xmit_complete(struct via_ircc_cb *self)
981 int ret = TRUE; 981 int ret = TRUE;
982 u8 Tx_status; 982 u8 Tx_status;
983 983
984 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 984 IRDA_DEBUG(3, "%s()\n", __func__);
985 985
986 iobase = self->io.fir_base; 986 iobase = self->io.fir_base;
987 /* Disable DMA */ 987 /* Disable DMA */
@@ -1014,7 +1014,7 @@ static int via_ircc_dma_xmit_complete(struct via_ircc_cb *self)
1014 } 1014 }
1015 IRDA_DEBUG(1, 1015 IRDA_DEBUG(1,
1016 "%s: tx_fifo.len=%x ,tx_fifo.ptr=%x,tx_fifo.free=%x...\n", 1016 "%s: tx_fifo.len=%x ,tx_fifo.ptr=%x,tx_fifo.free=%x...\n",
1017 __FUNCTION__, 1017 __func__,
1018 self->tx_fifo.len, self->tx_fifo.ptr, self->tx_fifo.free); 1018 self->tx_fifo.len, self->tx_fifo.ptr, self->tx_fifo.free);
1019/* F01_S 1019/* F01_S
1020 // Any frames to be sent back-to-back? 1020 // Any frames to be sent back-to-back?
@@ -1050,7 +1050,7 @@ static int via_ircc_dma_receive(struct via_ircc_cb *self)
1050 1050
1051 iobase = self->io.fir_base; 1051 iobase = self->io.fir_base;
1052 1052
1053 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 1053 IRDA_DEBUG(3, "%s()\n", __func__);
1054 1054
1055 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0; 1055 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
1056 self->tx_fifo.tail = self->tx_buff.head; 1056 self->tx_fifo.tail = self->tx_buff.head;
@@ -1134,13 +1134,13 @@ static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
1134 return TRUE; //interrupt only, data maybe move by RxT 1134 return TRUE; //interrupt only, data maybe move by RxT
1135 if (((len - 4) < 2) || ((len - 4) > 2048)) { 1135 if (((len - 4) < 2) || ((len - 4) > 2048)) {
1136 IRDA_DEBUG(1, "%s(): Trouble:len=%x,CurCount=%x,LastCount=%x..\n", 1136 IRDA_DEBUG(1, "%s(): Trouble:len=%x,CurCount=%x,LastCount=%x..\n",
1137 __FUNCTION__, len, RxCurCount(iobase, self), 1137 __func__, len, RxCurCount(iobase, self),
1138 self->RxLastCount); 1138 self->RxLastCount);
1139 hwreset(self); 1139 hwreset(self);
1140 return FALSE; 1140 return FALSE;
1141 } 1141 }
1142 IRDA_DEBUG(2, "%s(): fifo.len=%x,len=%x,CurCount=%x..\n", 1142 IRDA_DEBUG(2, "%s(): fifo.len=%x,len=%x,CurCount=%x..\n",
1143 __FUNCTION__, 1143 __func__,
1144 st_fifo->len, len - 4, RxCurCount(iobase, self)); 1144 st_fifo->len, len - 4, RxCurCount(iobase, self));
1145 1145
1146 st_fifo->entries[st_fifo->tail].status = status; 1146 st_fifo->entries[st_fifo->tail].status = status;
@@ -1187,7 +1187,7 @@ F01_E */
1187 skb_put(skb, len - 4); 1187 skb_put(skb, len - 4);
1188 1188
1189 skb_copy_to_linear_data(skb, self->rx_buff.data, len - 4); 1189 skb_copy_to_linear_data(skb, self->rx_buff.data, len - 4);
1190 IRDA_DEBUG(2, "%s(): len=%x.rx_buff=%p\n", __FUNCTION__, 1190 IRDA_DEBUG(2, "%s(): len=%x.rx_buff=%p\n", __func__,
1191 len - 4, self->rx_buff.data); 1191 len - 4, self->rx_buff.data);
1192 1192
1193 // Move to next frame 1193 // Move to next frame
@@ -1217,7 +1217,7 @@ static int upload_rxdata(struct via_ircc_cb *self, int iobase)
1217 1217
1218 len = GetRecvByte(iobase, self); 1218 len = GetRecvByte(iobase, self);
1219 1219
1220 IRDA_DEBUG(2, "%s(): len=%x\n", __FUNCTION__, len); 1220 IRDA_DEBUG(2, "%s(): len=%x\n", __func__, len);
1221 1221
1222 if ((len - 4) < 2) { 1222 if ((len - 4) < 2) {
1223 self->stats.rx_dropped++; 1223 self->stats.rx_dropped++;
@@ -1302,7 +1302,7 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
1302 skb_put(skb, len - 4); 1302 skb_put(skb, len - 4);
1303 skb_copy_to_linear_data(skb, self->rx_buff.data, len - 4); 1303 skb_copy_to_linear_data(skb, self->rx_buff.data, len - 4);
1304 1304
1305 IRDA_DEBUG(2, "%s(): len=%x.head=%x\n", __FUNCTION__, 1305 IRDA_DEBUG(2, "%s(): len=%x.head=%x\n", __func__,
1306 len - 4, st_fifo->head); 1306 len - 4, st_fifo->head);
1307 1307
1308 // Move to next frame 1308 // Move to next frame
@@ -1318,7 +1318,7 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
1318 1318
1319 IRDA_DEBUG(2, 1319 IRDA_DEBUG(2,
1320 "%s(): End of upload HostStatus=%x,RxStatus=%x\n", 1320 "%s(): End of upload HostStatus=%x,RxStatus=%x\n",
1321 __FUNCTION__, 1321 __func__,
1322 GetHostStatus(iobase), GetRXStatus(iobase)); 1322 GetHostStatus(iobase), GetRXStatus(iobase));
1323 1323
1324 /* 1324 /*
@@ -1358,7 +1358,7 @@ static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id)
1358 iHostIntType = GetHostStatus(iobase); 1358 iHostIntType = GetHostStatus(iobase);
1359 1359
1360 IRDA_DEBUG(4, "%s(): iHostIntType %02x: %s %s %s %02x\n", 1360 IRDA_DEBUG(4, "%s(): iHostIntType %02x: %s %s %s %02x\n",
1361 __FUNCTION__, iHostIntType, 1361 __func__, iHostIntType,
1362 (iHostIntType & 0x40) ? "Timer" : "", 1362 (iHostIntType & 0x40) ? "Timer" : "",
1363 (iHostIntType & 0x20) ? "Tx" : "", 1363 (iHostIntType & 0x20) ? "Tx" : "",
1364 (iHostIntType & 0x10) ? "Rx" : "", 1364 (iHostIntType & 0x10) ? "Rx" : "",
@@ -1388,7 +1388,7 @@ static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id)
1388 iTxIntType = GetTXStatus(iobase); 1388 iTxIntType = GetTXStatus(iobase);
1389 1389
1390 IRDA_DEBUG(4, "%s(): iTxIntType %02x: %s %s %s %s\n", 1390 IRDA_DEBUG(4, "%s(): iTxIntType %02x: %s %s %s %s\n",
1391 __FUNCTION__, iTxIntType, 1391 __func__, iTxIntType,
1392 (iTxIntType & 0x08) ? "FIFO underr." : "", 1392 (iTxIntType & 0x08) ? "FIFO underr." : "",
1393 (iTxIntType & 0x04) ? "EOM" : "", 1393 (iTxIntType & 0x04) ? "EOM" : "",
1394 (iTxIntType & 0x02) ? "FIFO ready" : "", 1394 (iTxIntType & 0x02) ? "FIFO ready" : "",
@@ -1412,7 +1412,7 @@ static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id)
1412 iRxIntType = GetRXStatus(iobase); 1412 iRxIntType = GetRXStatus(iobase);
1413 1413
1414 IRDA_DEBUG(4, "%s(): iRxIntType %02x: %s %s %s %s %s %s %s\n", 1414 IRDA_DEBUG(4, "%s(): iRxIntType %02x: %s %s %s %s %s %s %s\n",
1415 __FUNCTION__, iRxIntType, 1415 __func__, iRxIntType,
1416 (iRxIntType & 0x80) ? "PHY err." : "", 1416 (iRxIntType & 0x80) ? "PHY err." : "",
1417 (iRxIntType & 0x40) ? "CRC err" : "", 1417 (iRxIntType & 0x40) ? "CRC err" : "",
1418 (iRxIntType & 0x20) ? "FIFO overr." : "", 1418 (iRxIntType & 0x20) ? "FIFO overr." : "",
@@ -1421,7 +1421,7 @@ static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id)
1421 (iRxIntType & 0x02) ? "RxMaxLen" : "", 1421 (iRxIntType & 0x02) ? "RxMaxLen" : "",
1422 (iRxIntType & 0x01) ? "SIR bad" : ""); 1422 (iRxIntType & 0x01) ? "SIR bad" : "");
1423 if (!iRxIntType) 1423 if (!iRxIntType)
1424 IRDA_DEBUG(3, "%s(): RxIRQ =0\n", __FUNCTION__); 1424 IRDA_DEBUG(3, "%s(): RxIRQ =0\n", __func__);
1425 1425
1426 if (iRxIntType & 0x10) { 1426 if (iRxIntType & 0x10) {
1427 if (via_ircc_dma_receive_complete(self, iobase)) { 1427 if (via_ircc_dma_receive_complete(self, iobase)) {
@@ -1431,7 +1431,7 @@ static irqreturn_t via_ircc_interrupt(int dummy, void *dev_id)
1431 } // No ERR 1431 } // No ERR
1432 else { //ERR 1432 else { //ERR
1433 IRDA_DEBUG(4, "%s(): RxIRQ ERR:iRxIntType=%x,HostIntType=%x,CurCount=%x,RxLastCount=%x_____\n", 1433 IRDA_DEBUG(4, "%s(): RxIRQ ERR:iRxIntType=%x,HostIntType=%x,CurCount=%x,RxLastCount=%x_____\n",
1434 __FUNCTION__, iRxIntType, iHostIntType, 1434 __func__, iRxIntType, iHostIntType,
1435 RxCurCount(iobase, self), 1435 RxCurCount(iobase, self),
1436 self->RxLastCount); 1436 self->RxLastCount);
1437 1437
@@ -1456,7 +1456,7 @@ static void hwreset(struct via_ircc_cb *self)
1456 int iobase; 1456 int iobase;
1457 iobase = self->io.fir_base; 1457 iobase = self->io.fir_base;
1458 1458
1459 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 1459 IRDA_DEBUG(3, "%s()\n", __func__);
1460 1460
1461 ResetChip(iobase, 5); 1461 ResetChip(iobase, 5);
1462 EnableDMA(iobase, OFF); 1462 EnableDMA(iobase, OFF);
@@ -1501,7 +1501,7 @@ static int via_ircc_is_receiving(struct via_ircc_cb *self)
1501 if (CkRxRecv(iobase, self)) 1501 if (CkRxRecv(iobase, self))
1502 status = TRUE; 1502 status = TRUE;
1503 1503
1504 IRDA_DEBUG(2, "%s(): status=%x....\n", __FUNCTION__, status); 1504 IRDA_DEBUG(2, "%s(): status=%x....\n", __func__, status);
1505 1505
1506 return status; 1506 return status;
1507} 1507}
@@ -1519,7 +1519,7 @@ static int via_ircc_net_open(struct net_device *dev)
1519 int iobase; 1519 int iobase;
1520 char hwname[32]; 1520 char hwname[32];
1521 1521
1522 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 1522 IRDA_DEBUG(3, "%s()\n", __func__);
1523 1523
1524 IRDA_ASSERT(dev != NULL, return -1;); 1524 IRDA_ASSERT(dev != NULL, return -1;);
1525 self = (struct via_ircc_cb *) dev->priv; 1525 self = (struct via_ircc_cb *) dev->priv;
@@ -1586,7 +1586,7 @@ static int via_ircc_net_close(struct net_device *dev)
1586 struct via_ircc_cb *self; 1586 struct via_ircc_cb *self;
1587 int iobase; 1587 int iobase;
1588 1588
1589 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 1589 IRDA_DEBUG(3, "%s()\n", __func__);
1590 1590
1591 IRDA_ASSERT(dev != NULL, return -1;); 1591 IRDA_ASSERT(dev != NULL, return -1;);
1592 self = (struct via_ircc_cb *) dev->priv; 1592 self = (struct via_ircc_cb *) dev->priv;
@@ -1630,7 +1630,7 @@ static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
1630 IRDA_ASSERT(dev != NULL, return -1;); 1630 IRDA_ASSERT(dev != NULL, return -1;);
1631 self = dev->priv; 1631 self = dev->priv;
1632 IRDA_ASSERT(self != NULL, return -1;); 1632 IRDA_ASSERT(self != NULL, return -1;);
1633 IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, 1633 IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __func__, dev->name,
1634 cmd); 1634 cmd);
1635 /* Disable interrupts & save flags */ 1635 /* Disable interrupts & save flags */
1636 spin_lock_irqsave(&self->lock, flags); 1636 spin_lock_irqsave(&self->lock, flags);
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index d15e00b8591e..18f4b3a96aed 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -140,15 +140,15 @@ static void vlsi_ring_debug(struct vlsi_ring *r)
140 unsigned i; 140 unsigned i;
141 141
142 printk(KERN_DEBUG "%s - ring %p / size %u / mask 0x%04x / len %u / dir %d / hw %p\n", 142 printk(KERN_DEBUG "%s - ring %p / size %u / mask 0x%04x / len %u / dir %d / hw %p\n",
143 __FUNCTION__, r, r->size, r->mask, r->len, r->dir, r->rd[0].hw); 143 __func__, r, r->size, r->mask, r->len, r->dir, r->rd[0].hw);
144 printk(KERN_DEBUG "%s - head = %d / tail = %d\n", __FUNCTION__, 144 printk(KERN_DEBUG "%s - head = %d / tail = %d\n", __func__,
145 atomic_read(&r->head) & r->mask, atomic_read(&r->tail) & r->mask); 145 atomic_read(&r->head) & r->mask, atomic_read(&r->tail) & r->mask);
146 for (i = 0; i < r->size; i++) { 146 for (i = 0; i < r->size; i++) {
147 rd = &r->rd[i]; 147 rd = &r->rd[i];
148 printk(KERN_DEBUG "%s - ring descr %u: ", __FUNCTION__, i); 148 printk(KERN_DEBUG "%s - ring descr %u: ", __func__, i);
149 printk("skb=%p data=%p hw=%p\n", rd->skb, rd->buf, rd->hw); 149 printk("skb=%p data=%p hw=%p\n", rd->skb, rd->buf, rd->hw);
150 printk(KERN_DEBUG "%s - hw: status=%02x count=%u addr=0x%08x\n", 150 printk(KERN_DEBUG "%s - hw: status=%02x count=%u addr=0x%08x\n",
151 __FUNCTION__, (unsigned) rd_get_status(rd), 151 __func__, (unsigned) rd_get_status(rd),
152 (unsigned) rd_get_count(rd), (unsigned) rd_get_addr(rd)); 152 (unsigned) rd_get_count(rd), (unsigned) rd_get_addr(rd));
153 } 153 }
154} 154}
@@ -435,7 +435,7 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr
435 || !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) { 435 || !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) {
436 if (rd->buf) { 436 if (rd->buf) {
437 IRDA_ERROR("%s: failed to create PCI-MAP for %p", 437 IRDA_ERROR("%s: failed to create PCI-MAP for %p",
438 __FUNCTION__, rd->buf); 438 __func__, rd->buf);
439 kfree(rd->buf); 439 kfree(rd->buf);
440 rd->buf = NULL; 440 rd->buf = NULL;
441 } 441 }
@@ -489,7 +489,7 @@ static int vlsi_create_hwif(vlsi_irda_dev_t *idev)
489 ringarea = pci_alloc_consistent(idev->pdev, HW_RING_AREA_SIZE, &idev->busaddr); 489 ringarea = pci_alloc_consistent(idev->pdev, HW_RING_AREA_SIZE, &idev->busaddr);
490 if (!ringarea) { 490 if (!ringarea) {
491 IRDA_ERROR("%s: insufficient memory for descriptor rings\n", 491 IRDA_ERROR("%s: insufficient memory for descriptor rings\n",
492 __FUNCTION__); 492 __func__);
493 goto out; 493 goto out;
494 } 494 }
495 memset(ringarea, 0, HW_RING_AREA_SIZE); 495 memset(ringarea, 0, HW_RING_AREA_SIZE);
@@ -564,7 +564,7 @@ static int vlsi_process_rx(struct vlsi_ring *r, struct ring_descr *rd)
564 crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16); 564 crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16);
565 len -= crclen; /* remove trailing CRC */ 565 len -= crclen; /* remove trailing CRC */
566 if (len <= 0) { 566 if (len <= 0) {
567 IRDA_DEBUG(0, "%s: strange frame (len=%d)\n", __FUNCTION__, len); 567 IRDA_DEBUG(0, "%s: strange frame (len=%d)\n", __func__, len);
568 ret |= VLSI_RX_DROP; 568 ret |= VLSI_RX_DROP;
569 goto done; 569 goto done;
570 } 570 }
@@ -579,14 +579,14 @@ static int vlsi_process_rx(struct vlsi_ring *r, struct ring_descr *rd)
579 */ 579 */
580 le16_to_cpus(rd->buf+len); 580 le16_to_cpus(rd->buf+len);
581 if (irda_calc_crc16(INIT_FCS,rd->buf,len+crclen) != GOOD_FCS) { 581 if (irda_calc_crc16(INIT_FCS,rd->buf,len+crclen) != GOOD_FCS) {
582 IRDA_DEBUG(0, "%s: crc error\n", __FUNCTION__); 582 IRDA_DEBUG(0, "%s: crc error\n", __func__);
583 ret |= VLSI_RX_CRC; 583 ret |= VLSI_RX_CRC;
584 goto done; 584 goto done;
585 } 585 }
586 } 586 }
587 587
588 if (!rd->skb) { 588 if (!rd->skb) {
589 IRDA_WARNING("%s: rx packet lost\n", __FUNCTION__); 589 IRDA_WARNING("%s: rx packet lost\n", __func__);
590 ret |= VLSI_RX_DROP; 590 ret |= VLSI_RX_DROP;
591 goto done; 591 goto done;
592 } 592 }
@@ -617,7 +617,7 @@ static void vlsi_fill_rx(struct vlsi_ring *r)
617 for (rd = ring_last(r); rd != NULL; rd = ring_put(r)) { 617 for (rd = ring_last(r); rd != NULL; rd = ring_put(r)) {
618 if (rd_is_active(rd)) { 618 if (rd_is_active(rd)) {
619 IRDA_WARNING("%s: driver bug: rx descr race with hw\n", 619 IRDA_WARNING("%s: driver bug: rx descr race with hw\n",
620 __FUNCTION__); 620 __func__);
621 vlsi_ring_debug(r); 621 vlsi_ring_debug(r);
622 break; 622 break;
623 } 623 }
@@ -676,7 +676,7 @@ static void vlsi_rx_interrupt(struct net_device *ndev)
676 676
677 if (ring_first(r) == NULL) { 677 if (ring_first(r) == NULL) {
678 /* we are in big trouble, if this should ever happen */ 678 /* we are in big trouble, if this should ever happen */
679 IRDA_ERROR("%s: rx ring exhausted!\n", __FUNCTION__); 679 IRDA_ERROR("%s: rx ring exhausted!\n", __func__);
680 vlsi_ring_debug(r); 680 vlsi_ring_debug(r);
681 } 681 }
682 else 682 else
@@ -697,7 +697,7 @@ static void vlsi_unarm_rx(vlsi_irda_dev_t *idev)
697 if (rd_is_active(rd)) { 697 if (rd_is_active(rd)) {
698 rd_set_status(rd, 0); 698 rd_set_status(rd, 0);
699 if (rd_get_count(rd)) { 699 if (rd_get_count(rd)) {
700 IRDA_DEBUG(0, "%s - dropping rx packet\n", __FUNCTION__); 700 IRDA_DEBUG(0, "%s - dropping rx packet\n", __func__);
701 ret = -VLSI_RX_DROP; 701 ret = -VLSI_RX_DROP;
702 } 702 }
703 rd_set_count(rd, 0); 703 rd_set_count(rd, 0);
@@ -772,7 +772,7 @@ static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
772 int fifocnt; 772 int fifocnt;
773 773
774 baudrate = idev->new_baud; 774 baudrate = idev->new_baud;
775 IRDA_DEBUG(2, "%s: %d -> %d\n", __FUNCTION__, idev->baud, idev->new_baud); 775 IRDA_DEBUG(2, "%s: %d -> %d\n", __func__, idev->baud, idev->new_baud);
776 if (baudrate == 4000000) { 776 if (baudrate == 4000000) {
777 mode = IFF_FIR; 777 mode = IFF_FIR;
778 config = IRCFG_FIR; 778 config = IRCFG_FIR;
@@ -789,7 +789,7 @@ static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
789 switch(baudrate) { 789 switch(baudrate) {
790 default: 790 default:
791 IRDA_WARNING("%s: undefined baudrate %d - fallback to 9600!\n", 791 IRDA_WARNING("%s: undefined baudrate %d - fallback to 9600!\n",
792 __FUNCTION__, baudrate); 792 __func__, baudrate);
793 baudrate = 9600; 793 baudrate = 9600;
794 /* fallthru */ 794 /* fallthru */
795 case 2400: 795 case 2400:
@@ -806,7 +806,7 @@ static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
806 806
807 fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK; 807 fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
808 if (fifocnt != 0) { 808 if (fifocnt != 0) {
809 IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt); 809 IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __func__, fifocnt);
810 } 810 }
811 811
812 outw(0, iobase+VLSI_PIO_IRENABLE); 812 outw(0, iobase+VLSI_PIO_IRENABLE);
@@ -830,14 +830,14 @@ static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
830 config ^= IRENABLE_SIR_ON; 830 config ^= IRENABLE_SIR_ON;
831 831
832 if (config != (IRENABLE_PHYANDCLOCK|IRENABLE_ENRXST)) { 832 if (config != (IRENABLE_PHYANDCLOCK|IRENABLE_ENRXST)) {
833 IRDA_WARNING("%s: failed to set %s mode!\n", __FUNCTION__, 833 IRDA_WARNING("%s: failed to set %s mode!\n", __func__,
834 (mode==IFF_SIR)?"SIR":((mode==IFF_MIR)?"MIR":"FIR")); 834 (mode==IFF_SIR)?"SIR":((mode==IFF_MIR)?"MIR":"FIR"));
835 ret = -1; 835 ret = -1;
836 } 836 }
837 else { 837 else {
838 if (inw(iobase+VLSI_PIO_PHYCTL) != nphyctl) { 838 if (inw(iobase+VLSI_PIO_PHYCTL) != nphyctl) {
839 IRDA_WARNING("%s: failed to apply baudrate %d\n", 839 IRDA_WARNING("%s: failed to apply baudrate %d\n",
840 __FUNCTION__, baudrate); 840 __func__, baudrate);
841 ret = -1; 841 ret = -1;
842 } 842 }
843 else { 843 else {
@@ -849,7 +849,7 @@ static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
849 } 849 }
850 850
851 if (ret) 851 if (ret)
852 vlsi_reg_debug(iobase,__FUNCTION__); 852 vlsi_reg_debug(iobase,__func__);
853 853
854 return ret; 854 return ret;
855} 855}
@@ -982,7 +982,7 @@ static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
982 982
983 if (len >= r->len-5) 983 if (len >= r->len-5)
984 IRDA_WARNING("%s: possible buffer overflow with SIR wrapping!\n", 984 IRDA_WARNING("%s: possible buffer overflow with SIR wrapping!\n",
985 __FUNCTION__); 985 __func__);
986 } 986 }
987 else { 987 else {
988 /* hw deals with MIR/FIR mode wrapping */ 988 /* hw deals with MIR/FIR mode wrapping */
@@ -1027,7 +1027,7 @@ static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1027 1027
1028 fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK; 1028 fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
1029 if (fifocnt != 0) { 1029 if (fifocnt != 0) {
1030 IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt); 1030 IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __func__, fifocnt);
1031 } 1031 }
1032 1032
1033 config = inw(iobase+VLSI_PIO_IRCFG); 1033 config = inw(iobase+VLSI_PIO_IRCFG);
@@ -1040,7 +1040,7 @@ static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1040 1040
1041 if (ring_put(r) == NULL) { 1041 if (ring_put(r) == NULL) {
1042 netif_stop_queue(ndev); 1042 netif_stop_queue(ndev);
1043 IRDA_DEBUG(3, "%s: tx ring full - queue stopped\n", __FUNCTION__); 1043 IRDA_DEBUG(3, "%s: tx ring full - queue stopped\n", __func__);
1044 } 1044 }
1045 spin_unlock_irqrestore(&idev->lock, flags); 1045 spin_unlock_irqrestore(&idev->lock, flags);
1046 1046
@@ -1049,7 +1049,7 @@ static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1049drop_unlock: 1049drop_unlock:
1050 spin_unlock_irqrestore(&idev->lock, flags); 1050 spin_unlock_irqrestore(&idev->lock, flags);
1051drop: 1051drop:
1052 IRDA_WARNING("%s: dropping packet - %s\n", __FUNCTION__, msg); 1052 IRDA_WARNING("%s: dropping packet - %s\n", __func__, msg);
1053 dev_kfree_skb_any(skb); 1053 dev_kfree_skb_any(skb);
1054 idev->stats.tx_errors++; 1054 idev->stats.tx_errors++;
1055 idev->stats.tx_dropped++; 1055 idev->stats.tx_dropped++;
@@ -1106,7 +1106,7 @@ static void vlsi_tx_interrupt(struct net_device *ndev)
1106 fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK; 1106 fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
1107 if (fifocnt != 0) { 1107 if (fifocnt != 0) {
1108 IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", 1108 IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n",
1109 __FUNCTION__, fifocnt); 1109 __func__, fifocnt);
1110 } 1110 }
1111 outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG); 1111 outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
1112 } 1112 }
@@ -1115,7 +1115,7 @@ static void vlsi_tx_interrupt(struct net_device *ndev)
1115 1115
1116 if (netif_queue_stopped(ndev) && !idev->new_baud) { 1116 if (netif_queue_stopped(ndev) && !idev->new_baud) {
1117 netif_wake_queue(ndev); 1117 netif_wake_queue(ndev);
1118 IRDA_DEBUG(3, "%s: queue awoken\n", __FUNCTION__); 1118 IRDA_DEBUG(3, "%s: queue awoken\n", __func__);
1119 } 1119 }
1120} 1120}
1121 1121
@@ -1138,7 +1138,7 @@ static void vlsi_unarm_tx(vlsi_irda_dev_t *idev)
1138 dev_kfree_skb_any(rd->skb); 1138 dev_kfree_skb_any(rd->skb);
1139 rd->skb = NULL; 1139 rd->skb = NULL;
1140 } 1140 }
1141 IRDA_DEBUG(0, "%s - dropping tx packet\n", __FUNCTION__); 1141 IRDA_DEBUG(0, "%s - dropping tx packet\n", __func__);
1142 ret = -VLSI_TX_DROP; 1142 ret = -VLSI_TX_DROP;
1143 } 1143 }
1144 else 1144 else
@@ -1188,7 +1188,7 @@ static int vlsi_start_clock(struct pci_dev *pdev)
1188 if (count < 3) { 1188 if (count < 3) {
1189 if (clksrc == 1) { /* explicitly asked for PLL hence bail out */ 1189 if (clksrc == 1) { /* explicitly asked for PLL hence bail out */
1190 IRDA_ERROR("%s: no PLL or failed to lock!\n", 1190 IRDA_ERROR("%s: no PLL or failed to lock!\n",
1191 __FUNCTION__); 1191 __func__);
1192 clkctl = CLKCTL_CLKSTP; 1192 clkctl = CLKCTL_CLKSTP;
1193 pci_write_config_byte(pdev, VLSI_PCI_CLKCTL, clkctl); 1193 pci_write_config_byte(pdev, VLSI_PCI_CLKCTL, clkctl);
1194 return -1; 1194 return -1;
@@ -1197,7 +1197,7 @@ static int vlsi_start_clock(struct pci_dev *pdev)
1197 clksrc = 3; /* fallback to 40MHz XCLK (OB800) */ 1197 clksrc = 3; /* fallback to 40MHz XCLK (OB800) */
1198 1198
1199 IRDA_DEBUG(0, "%s: PLL not locked, fallback to clksrc=%d\n", 1199 IRDA_DEBUG(0, "%s: PLL not locked, fallback to clksrc=%d\n",
1200 __FUNCTION__, clksrc); 1200 __func__, clksrc);
1201 } 1201 }
1202 else 1202 else
1203 clksrc = 1; /* got successful PLL lock */ 1203 clksrc = 1; /* got successful PLL lock */
@@ -1269,7 +1269,7 @@ static int vlsi_init_chip(struct pci_dev *pdev)
1269 /* start the clock and clean the registers */ 1269 /* start the clock and clean the registers */
1270 1270
1271 if (vlsi_start_clock(pdev)) { 1271 if (vlsi_start_clock(pdev)) {
1272 IRDA_ERROR("%s: no valid clock source\n", __FUNCTION__); 1272 IRDA_ERROR("%s: no valid clock source\n", __func__);
1273 return -1; 1273 return -1;
1274 } 1274 }
1275 iobase = ndev->base_addr; 1275 iobase = ndev->base_addr;
@@ -1386,7 +1386,7 @@ static void vlsi_tx_timeout(struct net_device *ndev)
1386 vlsi_irda_dev_t *idev = ndev->priv; 1386 vlsi_irda_dev_t *idev = ndev->priv;
1387 1387
1388 1388
1389 vlsi_reg_debug(ndev->base_addr, __FUNCTION__); 1389 vlsi_reg_debug(ndev->base_addr, __func__);
1390 vlsi_ring_debug(idev->tx_ring); 1390 vlsi_ring_debug(idev->tx_ring);
1391 1391
1392 if (netif_running(ndev)) 1392 if (netif_running(ndev))
@@ -1401,7 +1401,7 @@ static void vlsi_tx_timeout(struct net_device *ndev)
1401 1401
1402 if (vlsi_start_hw(idev)) 1402 if (vlsi_start_hw(idev))
1403 IRDA_ERROR("%s: failed to restart hw - %s(%s) unusable!\n", 1403 IRDA_ERROR("%s: failed to restart hw - %s(%s) unusable!\n",
1404 __FUNCTION__, pci_name(idev->pdev), ndev->name); 1404 __func__, pci_name(idev->pdev), ndev->name);
1405 else 1405 else
1406 netif_start_queue(ndev); 1406 netif_start_queue(ndev);
1407} 1407}
@@ -1446,7 +1446,7 @@ static int vlsi_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
1446 break; 1446 break;
1447 default: 1447 default:
1448 IRDA_WARNING("%s: notsupp - cmd=%04x\n", 1448 IRDA_WARNING("%s: notsupp - cmd=%04x\n",
1449 __FUNCTION__, cmd); 1449 __func__, cmd);
1450 ret = -EOPNOTSUPP; 1450 ret = -EOPNOTSUPP;
1451 } 1451 }
1452 1452
@@ -1491,7 +1491,7 @@ static irqreturn_t vlsi_interrupt(int irq, void *dev_instance)
1491 1491
1492 if (boguscount <= 0) 1492 if (boguscount <= 0)
1493 IRDA_MESSAGE("%s: too much work in interrupt!\n", 1493 IRDA_MESSAGE("%s: too much work in interrupt!\n",
1494 __FUNCTION__); 1494 __func__);
1495 return IRQ_RETVAL(handled); 1495 return IRQ_RETVAL(handled);
1496} 1496}
1497 1497
@@ -1504,7 +1504,7 @@ static int vlsi_open(struct net_device *ndev)
1504 char hwname[32]; 1504 char hwname[32];
1505 1505
1506 if (pci_request_regions(idev->pdev, drivername)) { 1506 if (pci_request_regions(idev->pdev, drivername)) {
1507 IRDA_WARNING("%s: io resource busy\n", __FUNCTION__); 1507 IRDA_WARNING("%s: io resource busy\n", __func__);
1508 goto errout; 1508 goto errout;
1509 } 1509 }
1510 ndev->base_addr = pci_resource_start(idev->pdev,0); 1510 ndev->base_addr = pci_resource_start(idev->pdev,0);
@@ -1519,7 +1519,7 @@ static int vlsi_open(struct net_device *ndev)
1519 if (request_irq(ndev->irq, vlsi_interrupt, IRQF_SHARED, 1519 if (request_irq(ndev->irq, vlsi_interrupt, IRQF_SHARED,
1520 drivername, ndev)) { 1520 drivername, ndev)) {
1521 IRDA_WARNING("%s: couldn't get IRQ: %d\n", 1521 IRDA_WARNING("%s: couldn't get IRQ: %d\n",
1522 __FUNCTION__, ndev->irq); 1522 __func__, ndev->irq);
1523 goto errout_io; 1523 goto errout_io;
1524 } 1524 }
1525 1525
@@ -1540,7 +1540,7 @@ static int vlsi_open(struct net_device *ndev)
1540 1540
1541 netif_start_queue(ndev); 1541 netif_start_queue(ndev);
1542 1542
1543 IRDA_MESSAGE("%s: device %s operational\n", __FUNCTION__, ndev->name); 1543 IRDA_MESSAGE("%s: device %s operational\n", __func__, ndev->name);
1544 1544
1545 return 0; 1545 return 0;
1546 1546
@@ -1574,7 +1574,7 @@ static int vlsi_close(struct net_device *ndev)
1574 1574
1575 pci_release_regions(idev->pdev); 1575 pci_release_regions(idev->pdev);
1576 1576
1577 IRDA_MESSAGE("%s: device %s stopped\n", __FUNCTION__, ndev->name); 1577 IRDA_MESSAGE("%s: device %s stopped\n", __func__, ndev->name);
1578 1578
1579 return 0; 1579 return 0;
1580} 1580}
@@ -1593,7 +1593,7 @@ static int vlsi_irda_init(struct net_device *ndev)
1593 1593
1594 if (pci_set_dma_mask(pdev,DMA_MASK_USED_BY_HW) 1594 if (pci_set_dma_mask(pdev,DMA_MASK_USED_BY_HW)
1595 || pci_set_dma_mask(pdev,DMA_MASK_MSTRPAGE)) { 1595 || pci_set_dma_mask(pdev,DMA_MASK_MSTRPAGE)) {
1596 IRDA_ERROR("%s: aborting due to PCI BM-DMA address limitations\n", __FUNCTION__); 1596 IRDA_ERROR("%s: aborting due to PCI BM-DMA address limitations\n", __func__);
1597 return -1; 1597 return -1;
1598 } 1598 }
1599 1599
@@ -1645,14 +1645,14 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1645 1645
1646 if ( !pci_resource_start(pdev,0) 1646 if ( !pci_resource_start(pdev,0)
1647 || !(pci_resource_flags(pdev,0) & IORESOURCE_IO) ) { 1647 || !(pci_resource_flags(pdev,0) & IORESOURCE_IO) ) {
1648 IRDA_ERROR("%s: bar 0 invalid", __FUNCTION__); 1648 IRDA_ERROR("%s: bar 0 invalid", __func__);
1649 goto out_disable; 1649 goto out_disable;
1650 } 1650 }
1651 1651
1652 ndev = alloc_irdadev(sizeof(*idev)); 1652 ndev = alloc_irdadev(sizeof(*idev));
1653 if (ndev==NULL) { 1653 if (ndev==NULL) {
1654 IRDA_ERROR("%s: Unable to allocate device memory.\n", 1654 IRDA_ERROR("%s: Unable to allocate device memory.\n",
1655 __FUNCTION__); 1655 __func__);
1656 goto out_disable; 1656 goto out_disable;
1657 } 1657 }
1658 1658
@@ -1667,7 +1667,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1667 goto out_freedev; 1667 goto out_freedev;
1668 1668
1669 if (register_netdev(ndev) < 0) { 1669 if (register_netdev(ndev) < 0) {
1670 IRDA_ERROR("%s: register_netdev failed\n", __FUNCTION__); 1670 IRDA_ERROR("%s: register_netdev failed\n", __func__);
1671 goto out_freedev; 1671 goto out_freedev;
1672 } 1672 }
1673 1673
@@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1678 vlsi_proc_root, VLSI_PROC_FOPS, ndev); 1678 vlsi_proc_root, VLSI_PROC_FOPS, ndev);
1679 if (!ent) { 1679 if (!ent) {
1680 IRDA_WARNING("%s: failed to create proc entry\n", 1680 IRDA_WARNING("%s: failed to create proc entry\n",
1681 __FUNCTION__); 1681 __func__);
1682 } else { 1682 } else {
1683 ent->size = 0; 1683 ent->size = 0;
1684 } 1684 }
@@ -1745,7 +1745,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
1745 1745
1746 if (!ndev) { 1746 if (!ndev) {
1747 IRDA_ERROR("%s - %s: no netdevice \n", 1747 IRDA_ERROR("%s - %s: no netdevice \n",
1748 __FUNCTION__, pci_name(pdev)); 1748 __func__, pci_name(pdev));
1749 return 0; 1749 return 0;
1750 } 1750 }
1751 idev = ndev->priv; 1751 idev = ndev->priv;
@@ -1756,7 +1756,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
1756 pdev->current_state = state.event; 1756 pdev->current_state = state.event;
1757 } 1757 }
1758 else 1758 else
1759 IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __FUNCTION__, pci_name(pdev), pdev->current_state, state.event); 1759 IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __func__, pci_name(pdev), pdev->current_state, state.event);
1760 mutex_unlock(&idev->mtx); 1760 mutex_unlock(&idev->mtx);
1761 return 0; 1761 return 0;
1762 } 1762 }
@@ -1784,7 +1784,7 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
1784 1784
1785 if (!ndev) { 1785 if (!ndev) {
1786 IRDA_ERROR("%s - %s: no netdevice \n", 1786 IRDA_ERROR("%s - %s: no netdevice \n",
1787 __FUNCTION__, pci_name(pdev)); 1787 __func__, pci_name(pdev));
1788 return 0; 1788 return 0;
1789 } 1789 }
1790 idev = ndev->priv; 1790 idev = ndev->priv;
@@ -1792,7 +1792,7 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
1792 if (pdev->current_state == 0) { 1792 if (pdev->current_state == 0) {
1793 mutex_unlock(&idev->mtx); 1793 mutex_unlock(&idev->mtx);
1794 IRDA_WARNING("%s - %s: already resumed\n", 1794 IRDA_WARNING("%s - %s: already resumed\n",
1795 __FUNCTION__, pci_name(pdev)); 1795 __func__, pci_name(pdev));
1796 return 0; 1796 return 0;
1797 } 1797 }
1798 1798
@@ -1811,7 +1811,7 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
1811 * now we explicitly set pdev->current_state = 0 after enabling the 1811 * now we explicitly set pdev->current_state = 0 after enabling the
1812 * device and independently resume_ok should catch any garbage config. 1812 * device and independently resume_ok should catch any garbage config.
1813 */ 1813 */
1814 IRDA_WARNING("%s - hm, nothing to resume?\n", __FUNCTION__); 1814 IRDA_WARNING("%s - hm, nothing to resume?\n", __func__);
1815 mutex_unlock(&idev->mtx); 1815 mutex_unlock(&idev->mtx);
1816 return 0; 1816 return 0;
1817 } 1817 }
diff --git a/drivers/net/irda/vlsi_ir.h b/drivers/net/irda/vlsi_ir.h
index c8b9c74eea52..9b1884329fba 100644
--- a/drivers/net/irda/vlsi_ir.h
+++ b/drivers/net/irda/vlsi_ir.h
@@ -617,7 +617,7 @@ static inline void rd_set_addr_status(struct ring_descr *rd, dma_addr_t a, u8 s)
617 */ 617 */
618 618
619 if ((a & ~DMA_MASK_MSTRPAGE)>>24 != MSTRPAGE_VALUE) { 619 if ((a & ~DMA_MASK_MSTRPAGE)>>24 != MSTRPAGE_VALUE) {
620 IRDA_ERROR("%s: pci busaddr inconsistency!\n", __FUNCTION__); 620 IRDA_ERROR("%s: pci busaddr inconsistency!\n", __func__);
621 dump_stack(); 621 dump_stack();
622 return; 622 return;
623 } 623 }
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index 9fd2451b0fb2..002a6d769f21 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -114,7 +114,7 @@ static int __init w83977af_init(void)
114{ 114{
115 int i; 115 int i;
116 116
117 IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); 117 IRDA_DEBUG(0, "%s()\n", __func__ );
118 118
119 for (i=0; (io[i] < 2000) && (i < ARRAY_SIZE(dev_self)); i++) { 119 for (i=0; (io[i] < 2000) && (i < ARRAY_SIZE(dev_self)); i++) {
120 if (w83977af_open(i, io[i], irq[i], dma[i]) == 0) 120 if (w83977af_open(i, io[i], irq[i], dma[i]) == 0)
@@ -133,7 +133,7 @@ static void __exit w83977af_cleanup(void)
133{ 133{
134 int i; 134 int i;
135 135
136 IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); 136 IRDA_DEBUG(4, "%s()\n", __func__ );
137 137
138 for (i=0; i < ARRAY_SIZE(dev_self); i++) { 138 for (i=0; i < ARRAY_SIZE(dev_self); i++) {
139 if (dev_self[i]) 139 if (dev_self[i])
@@ -154,12 +154,12 @@ int w83977af_open(int i, unsigned int iobase, unsigned int irq,
154 struct w83977af_ir *self; 154 struct w83977af_ir *self;
155 int err; 155 int err;
156 156
157 IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); 157 IRDA_DEBUG(0, "%s()\n", __func__ );
158 158
159 /* Lock the port that we need */ 159 /* Lock the port that we need */
160 if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) { 160 if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) {
161 IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n", 161 IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
162 __FUNCTION__ , iobase); 162 __func__ , iobase);
163 return -ENODEV; 163 return -ENODEV;
164 } 164 }
165 165
@@ -241,7 +241,7 @@ int w83977af_open(int i, unsigned int iobase, unsigned int irq,
241 241
242 err = register_netdev(dev); 242 err = register_netdev(dev);
243 if (err) { 243 if (err) {
244 IRDA_ERROR("%s(), register_netdevice() failed!\n", __FUNCTION__); 244 IRDA_ERROR("%s(), register_netdevice() failed!\n", __func__);
245 goto err_out3; 245 goto err_out3;
246 } 246 }
247 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name); 247 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
@@ -273,7 +273,7 @@ static int w83977af_close(struct w83977af_ir *self)
273{ 273{
274 int iobase; 274 int iobase;
275 275
276 IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); 276 IRDA_DEBUG(0, "%s()\n", __func__ );
277 277
278 iobase = self->io.fir_base; 278 iobase = self->io.fir_base;
279 279
@@ -294,7 +294,7 @@ static int w83977af_close(struct w83977af_ir *self)
294 294
295 /* Release the PORT that this driver is using */ 295 /* Release the PORT that this driver is using */
296 IRDA_DEBUG(0 , "%s(), Releasing Region %03x\n", 296 IRDA_DEBUG(0 , "%s(), Releasing Region %03x\n",
297 __FUNCTION__ , self->io.fir_base); 297 __func__ , self->io.fir_base);
298 release_region(self->io.fir_base, self->io.fir_ext); 298 release_region(self->io.fir_base, self->io.fir_ext);
299 299
300 if (self->tx_buff.head) 300 if (self->tx_buff.head)
@@ -316,7 +316,7 @@ int w83977af_probe( int iobase, int irq, int dma)
316 int i; 316 int i;
317 317
318 for (i=0; i < 2; i++) { 318 for (i=0; i < 2; i++) {
319 IRDA_DEBUG( 0, "%s()\n", __FUNCTION__ ); 319 IRDA_DEBUG( 0, "%s()\n", __func__ );
320#ifdef CONFIG_USE_W977_PNP 320#ifdef CONFIG_USE_W977_PNP
321 /* Enter PnP configuration mode */ 321 /* Enter PnP configuration mode */
322 w977_efm_enter(efbase[i]); 322 w977_efm_enter(efbase[i]);
@@ -403,7 +403,7 @@ int w83977af_probe( int iobase, int irq, int dma)
403 return 0; 403 return 0;
404 } else { 404 } else {
405 /* Try next extented function register address */ 405 /* Try next extented function register address */
406 IRDA_DEBUG( 0, "%s(), Wrong chip version", __FUNCTION__ ); 406 IRDA_DEBUG( 0, "%s(), Wrong chip version", __func__ );
407 } 407 }
408 } 408 }
409 return -1; 409 return -1;
@@ -439,19 +439,19 @@ void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
439 case 115200: outb(0x01, iobase+ABLL); break; 439 case 115200: outb(0x01, iobase+ABLL); break;
440 case 576000: 440 case 576000:
441 ir_mode = HCR_MIR_576; 441 ir_mode = HCR_MIR_576;
442 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__ ); 442 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __func__ );
443 break; 443 break;
444 case 1152000: 444 case 1152000:
445 ir_mode = HCR_MIR_1152; 445 ir_mode = HCR_MIR_1152;
446 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", __FUNCTION__ ); 446 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", __func__ );
447 break; 447 break;
448 case 4000000: 448 case 4000000:
449 ir_mode = HCR_FIR; 449 ir_mode = HCR_FIR;
450 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", __FUNCTION__ ); 450 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", __func__ );
451 break; 451 break;
452 default: 452 default:
453 ir_mode = HCR_FIR; 453 ir_mode = HCR_FIR;
454 IRDA_DEBUG(0, "%s(), unknown baud rate of %d\n", __FUNCTION__ , speed); 454 IRDA_DEBUG(0, "%s(), unknown baud rate of %d\n", __func__ , speed);
455 break; 455 break;
456 } 456 }
457 457
@@ -501,7 +501,7 @@ int w83977af_hard_xmit(struct sk_buff *skb, struct net_device *dev)
501 501
502 iobase = self->io.fir_base; 502 iobase = self->io.fir_base;
503 503
504 IRDA_DEBUG(4, "%s(%ld), skb->len=%d\n", __FUNCTION__ , jiffies, 504 IRDA_DEBUG(4, "%s(%ld), skb->len=%d\n", __func__ , jiffies,
505 (int) skb->len); 505 (int) skb->len);
506 506
507 /* Lock transmit buffer */ 507 /* Lock transmit buffer */
@@ -549,7 +549,7 @@ int w83977af_hard_xmit(struct sk_buff *skb, struct net_device *dev)
549 outb(ICR_ETMRI, iobase+ICR); 549 outb(ICR_ETMRI, iobase+ICR);
550 } else { 550 } else {
551#endif 551#endif
552 IRDA_DEBUG(4, "%s(%ld), mtt=%d\n", __FUNCTION__ , jiffies, mtt); 552 IRDA_DEBUG(4, "%s(%ld), mtt=%d\n", __func__ , jiffies, mtt);
553 if (mtt) 553 if (mtt)
554 udelay(mtt); 554 udelay(mtt);
555 555
@@ -591,7 +591,7 @@ static void w83977af_dma_write(struct w83977af_ir *self, int iobase)
591 unsigned long flags; 591 unsigned long flags;
592 __u8 hcr; 592 __u8 hcr;
593#endif 593#endif
594 IRDA_DEBUG(4, "%s(), len=%d\n", __FUNCTION__ , self->tx_buff.len); 594 IRDA_DEBUG(4, "%s(), len=%d\n", __func__ , self->tx_buff.len);
595 595
596 /* Save current set */ 596 /* Save current set */
597 set = inb(iobase+SSR); 597 set = inb(iobase+SSR);
@@ -643,7 +643,7 @@ static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
643 int actual = 0; 643 int actual = 0;
644 __u8 set; 644 __u8 set;
645 645
646 IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); 646 IRDA_DEBUG(4, "%s()\n", __func__ );
647 647
648 /* Save current bank */ 648 /* Save current bank */
649 set = inb(iobase+SSR); 649 set = inb(iobase+SSR);
@@ -651,11 +651,11 @@ static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
651 switch_bank(iobase, SET0); 651 switch_bank(iobase, SET0);
652 if (!(inb_p(iobase+USR) & USR_TSRE)) { 652 if (!(inb_p(iobase+USR) & USR_TSRE)) {
653 IRDA_DEBUG(4, 653 IRDA_DEBUG(4,
654 "%s(), warning, FIFO not empty yet!\n", __FUNCTION__ ); 654 "%s(), warning, FIFO not empty yet!\n", __func__ );
655 655
656 fifo_size -= 17; 656 fifo_size -= 17;
657 IRDA_DEBUG(4, "%s(), %d bytes left in tx fifo\n", 657 IRDA_DEBUG(4, "%s(), %d bytes left in tx fifo\n",
658 __FUNCTION__ , fifo_size); 658 __func__ , fifo_size);
659 } 659 }
660 660
661 /* Fill FIFO with current frame */ 661 /* Fill FIFO with current frame */
@@ -665,7 +665,7 @@ static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
665 } 665 }
666 666
667 IRDA_DEBUG(4, "%s(), fifo_size %d ; %d sent of %d\n", 667 IRDA_DEBUG(4, "%s(), fifo_size %d ; %d sent of %d\n",
668 __FUNCTION__ , fifo_size, actual, len); 668 __func__ , fifo_size, actual, len);
669 669
670 /* Restore bank */ 670 /* Restore bank */
671 outb(set, iobase+SSR); 671 outb(set, iobase+SSR);
@@ -685,7 +685,7 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
685 int iobase; 685 int iobase;
686 __u8 set; 686 __u8 set;
687 687
688 IRDA_DEBUG(4, "%s(%ld)\n", __FUNCTION__ , jiffies); 688 IRDA_DEBUG(4, "%s(%ld)\n", __func__ , jiffies);
689 689
690 IRDA_ASSERT(self != NULL, return;); 690 IRDA_ASSERT(self != NULL, return;);
691 691
@@ -700,7 +700,7 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
700 700
701 /* Check for underrrun! */ 701 /* Check for underrrun! */
702 if (inb(iobase+AUDR) & AUDR_UNDR) { 702 if (inb(iobase+AUDR) & AUDR_UNDR) {
703 IRDA_DEBUG(0, "%s(), Transmit underrun!\n", __FUNCTION__ ); 703 IRDA_DEBUG(0, "%s(), Transmit underrun!\n", __func__ );
704 704
705 self->stats.tx_errors++; 705 self->stats.tx_errors++;
706 self->stats.tx_fifo_errors++; 706 self->stats.tx_fifo_errors++;
@@ -741,7 +741,7 @@ int w83977af_dma_receive(struct w83977af_ir *self)
741#endif 741#endif
742 IRDA_ASSERT(self != NULL, return -1;); 742 IRDA_ASSERT(self != NULL, return -1;);
743 743
744 IRDA_DEBUG(4, "%s\n", __FUNCTION__ ); 744 IRDA_DEBUG(4, "%s\n", __func__ );
745 745
746 iobase= self->io.fir_base; 746 iobase= self->io.fir_base;
747 747
@@ -812,7 +812,7 @@ int w83977af_dma_receive_complete(struct w83977af_ir *self)
812 __u8 set; 812 __u8 set;
813 __u8 status; 813 __u8 status;
814 814
815 IRDA_DEBUG(4, "%s\n", __FUNCTION__ ); 815 IRDA_DEBUG(4, "%s\n", __func__ );
816 816
817 st_fifo = &self->st_fifo; 817 st_fifo = &self->st_fifo;
818 818
@@ -892,7 +892,7 @@ int w83977af_dma_receive_complete(struct w83977af_ir *self)
892 skb = dev_alloc_skb(len+1); 892 skb = dev_alloc_skb(len+1);
893 if (skb == NULL) { 893 if (skb == NULL) {
894 printk(KERN_INFO 894 printk(KERN_INFO
895 "%s(), memory squeeze, dropping frame.\n", __FUNCTION__); 895 "%s(), memory squeeze, dropping frame.\n", __func__);
896 /* Restore set register */ 896 /* Restore set register */
897 outb(set, iobase+SSR); 897 outb(set, iobase+SSR);
898 898
@@ -943,7 +943,7 @@ static void w83977af_pio_receive(struct w83977af_ir *self)
943 __u8 byte = 0x00; 943 __u8 byte = 0x00;
944 int iobase; 944 int iobase;
945 945
946 IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); 946 IRDA_DEBUG(4, "%s()\n", __func__ );
947 947
948 IRDA_ASSERT(self != NULL, return;); 948 IRDA_ASSERT(self != NULL, return;);
949 949
@@ -970,7 +970,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
970 __u8 set; 970 __u8 set;
971 int iobase; 971 int iobase;
972 972
973 IRDA_DEBUG(4, "%s(), isr=%#x\n", __FUNCTION__ , isr); 973 IRDA_DEBUG(4, "%s(), isr=%#x\n", __func__ , isr);
974 974
975 iobase = self->io.fir_base; 975 iobase = self->io.fir_base;
976 /* Transmit FIFO low on data */ 976 /* Transmit FIFO low on data */
@@ -1007,7 +1007,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
1007 /* Check if we need to change the speed? */ 1007 /* Check if we need to change the speed? */
1008 if (self->new_speed) { 1008 if (self->new_speed) {
1009 IRDA_DEBUG(2, 1009 IRDA_DEBUG(2,
1010 "%s(), Changing speed!\n", __FUNCTION__ ); 1010 "%s(), Changing speed!\n", __func__ );
1011 w83977af_change_speed(self, self->new_speed); 1011 w83977af_change_speed(self, self->new_speed);
1012 self->new_speed = 0; 1012 self->new_speed = 0;
1013 } 1013 }
@@ -1189,7 +1189,7 @@ static int w83977af_net_open(struct net_device *dev)
1189 char hwname[32]; 1189 char hwname[32];
1190 __u8 set; 1190 __u8 set;
1191 1191
1192 IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); 1192 IRDA_DEBUG(0, "%s()\n", __func__ );
1193 1193
1194 IRDA_ASSERT(dev != NULL, return -1;); 1194 IRDA_ASSERT(dev != NULL, return -1;);
1195 self = (struct w83977af_ir *) dev->priv; 1195 self = (struct w83977af_ir *) dev->priv;
@@ -1252,7 +1252,7 @@ static int w83977af_net_close(struct net_device *dev)
1252 int iobase; 1252 int iobase;
1253 __u8 set; 1253 __u8 set;
1254 1254
1255 IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); 1255 IRDA_DEBUG(0, "%s()\n", __func__ );
1256 1256
1257 IRDA_ASSERT(dev != NULL, return -1;); 1257 IRDA_ASSERT(dev != NULL, return -1;);
1258 1258
@@ -1307,7 +1307,7 @@ static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1307 1307
1308 IRDA_ASSERT(self != NULL, return -1;); 1308 IRDA_ASSERT(self != NULL, return -1;);
1309 1309
1310 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__ , dev->name, cmd); 1310 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__ , dev->name, cmd);
1311 1311
1312 spin_lock_irqsave(&self->lock, flags); 1312 spin_lock_irqsave(&self->lock, flags);
1313 1313
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 8a97a0066a88..46819af3b062 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -55,7 +55,7 @@
55#include <asm/system.h> 55#include <asm/system.h>
56 56
57static char mv643xx_eth_driver_name[] = "mv643xx_eth"; 57static char mv643xx_eth_driver_name[] = "mv643xx_eth";
58static char mv643xx_eth_driver_version[] = "1.1"; 58static char mv643xx_eth_driver_version[] = "1.2";
59 59
60#define MV643XX_ETH_CHECKSUM_OFFLOAD_TX 60#define MV643XX_ETH_CHECKSUM_OFFLOAD_TX
61#define MV643XX_ETH_NAPI 61#define MV643XX_ETH_NAPI
@@ -90,12 +90,21 @@ static char mv643xx_eth_driver_version[] = "1.1";
90#define PORT_SERIAL_CONTROL(p) (0x043c + ((p) << 10)) 90#define PORT_SERIAL_CONTROL(p) (0x043c + ((p) << 10))
91#define PORT_STATUS(p) (0x0444 + ((p) << 10)) 91#define PORT_STATUS(p) (0x0444 + ((p) << 10))
92#define TX_FIFO_EMPTY 0x00000400 92#define TX_FIFO_EMPTY 0x00000400
93#define TX_IN_PROGRESS 0x00000080
94#define PORT_SPEED_MASK 0x00000030
95#define PORT_SPEED_1000 0x00000010
96#define PORT_SPEED_100 0x00000020
97#define PORT_SPEED_10 0x00000000
98#define FLOW_CONTROL_ENABLED 0x00000008
99#define FULL_DUPLEX 0x00000004
100#define LINK_UP 0x00000002
93#define TXQ_COMMAND(p) (0x0448 + ((p) << 10)) 101#define TXQ_COMMAND(p) (0x0448 + ((p) << 10))
94#define TXQ_FIX_PRIO_CONF(p) (0x044c + ((p) << 10)) 102#define TXQ_FIX_PRIO_CONF(p) (0x044c + ((p) << 10))
95#define TX_BW_RATE(p) (0x0450 + ((p) << 10)) 103#define TX_BW_RATE(p) (0x0450 + ((p) << 10))
96#define TX_BW_MTU(p) (0x0458 + ((p) << 10)) 104#define TX_BW_MTU(p) (0x0458 + ((p) << 10))
97#define TX_BW_BURST(p) (0x045c + ((p) << 10)) 105#define TX_BW_BURST(p) (0x045c + ((p) << 10))
98#define INT_CAUSE(p) (0x0460 + ((p) << 10)) 106#define INT_CAUSE(p) (0x0460 + ((p) << 10))
107#define INT_TX_END_0 0x00080000
99#define INT_TX_END 0x07f80000 108#define INT_TX_END 0x07f80000
100#define INT_RX 0x0007fbfc 109#define INT_RX 0x0007fbfc
101#define INT_EXT 0x00000002 110#define INT_EXT 0x00000002
@@ -127,21 +136,21 @@ static char mv643xx_eth_driver_version[] = "1.1";
127/* 136/*
128 * SDMA configuration register. 137 * SDMA configuration register.
129 */ 138 */
130#define RX_BURST_SIZE_4_64BIT (2 << 1) 139#define RX_BURST_SIZE_16_64BIT (4 << 1)
131#define BLM_RX_NO_SWAP (1 << 4) 140#define BLM_RX_NO_SWAP (1 << 4)
132#define BLM_TX_NO_SWAP (1 << 5) 141#define BLM_TX_NO_SWAP (1 << 5)
133#define TX_BURST_SIZE_4_64BIT (2 << 22) 142#define TX_BURST_SIZE_16_64BIT (4 << 22)
134 143
135#if defined(__BIG_ENDIAN) 144#if defined(__BIG_ENDIAN)
136#define PORT_SDMA_CONFIG_DEFAULT_VALUE \ 145#define PORT_SDMA_CONFIG_DEFAULT_VALUE \
137 RX_BURST_SIZE_4_64BIT | \ 146 RX_BURST_SIZE_16_64BIT | \
138 TX_BURST_SIZE_4_64BIT 147 TX_BURST_SIZE_16_64BIT
139#elif defined(__LITTLE_ENDIAN) 148#elif defined(__LITTLE_ENDIAN)
140#define PORT_SDMA_CONFIG_DEFAULT_VALUE \ 149#define PORT_SDMA_CONFIG_DEFAULT_VALUE \
141 RX_BURST_SIZE_4_64BIT | \ 150 RX_BURST_SIZE_16_64BIT | \
142 BLM_RX_NO_SWAP | \ 151 BLM_RX_NO_SWAP | \
143 BLM_TX_NO_SWAP | \ 152 BLM_TX_NO_SWAP | \
144 TX_BURST_SIZE_4_64BIT 153 TX_BURST_SIZE_16_64BIT
145#else 154#else
146#error One of __BIG_ENDIAN or __LITTLE_ENDIAN must be defined 155#error One of __BIG_ENDIAN or __LITTLE_ENDIAN must be defined
147#endif 156#endif
@@ -153,9 +162,7 @@ static char mv643xx_eth_driver_version[] = "1.1";
153#define SET_MII_SPEED_TO_100 (1 << 24) 162#define SET_MII_SPEED_TO_100 (1 << 24)
154#define SET_GMII_SPEED_TO_1000 (1 << 23) 163#define SET_GMII_SPEED_TO_1000 (1 << 23)
155#define SET_FULL_DUPLEX_MODE (1 << 21) 164#define SET_FULL_DUPLEX_MODE (1 << 21)
156#define MAX_RX_PACKET_1522BYTE (1 << 17)
157#define MAX_RX_PACKET_9700BYTE (5 << 17) 165#define MAX_RX_PACKET_9700BYTE (5 << 17)
158#define MAX_RX_PACKET_MASK (7 << 17)
159#define DISABLE_AUTO_NEG_SPEED_GMII (1 << 13) 166#define DISABLE_AUTO_NEG_SPEED_GMII (1 << 13)
160#define DO_NOT_FORCE_LINK_FAIL (1 << 10) 167#define DO_NOT_FORCE_LINK_FAIL (1 << 10)
161#define SERIAL_PORT_CONTROL_RESERVED (1 << 9) 168#define SERIAL_PORT_CONTROL_RESERVED (1 << 9)
@@ -228,6 +235,8 @@ struct tx_desc {
228#define GEN_IP_V4_CHECKSUM 0x00040000 235#define GEN_IP_V4_CHECKSUM 0x00040000
229#define GEN_TCP_UDP_CHECKSUM 0x00020000 236#define GEN_TCP_UDP_CHECKSUM 0x00020000
230#define UDP_FRAME 0x00010000 237#define UDP_FRAME 0x00010000
238#define MAC_HDR_EXTRA_4_BYTES 0x00008000
239#define MAC_HDR_EXTRA_8_BYTES 0x00000200
231 240
232#define TX_IHL_SHIFT 11 241#define TX_IHL_SHIFT 11
233 242
@@ -404,6 +413,17 @@ static void rxq_disable(struct rx_queue *rxq)
404 udelay(10); 413 udelay(10);
405} 414}
406 415
416static void txq_reset_hw_ptr(struct tx_queue *txq)
417{
418 struct mv643xx_eth_private *mp = txq_to_mp(txq);
419 int off = TXQ_CURRENT_DESC_PTR(mp->port_num, txq->index);
420 u32 addr;
421
422 addr = (u32)txq->tx_desc_dma;
423 addr += txq->tx_curr_desc * sizeof(struct tx_desc);
424 wrl(mp, off, addr);
425}
426
407static void txq_enable(struct tx_queue *txq) 427static void txq_enable(struct tx_queue *txq)
408{ 428{
409 struct mv643xx_eth_private *mp = txq_to_mp(txq); 429 struct mv643xx_eth_private *mp = txq_to_mp(txq);
@@ -614,6 +634,12 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
614 for (i = 0; i < 8; i++) 634 for (i = 0; i < 8; i++)
615 if (mp->txq_mask & (1 << i)) 635 if (mp->txq_mask & (1 << i))
616 txq_reclaim(mp->txq + i, 0); 636 txq_reclaim(mp->txq + i, 0);
637
638 if (netif_carrier_ok(mp->dev)) {
639 spin_lock(&mp->lock);
640 __txq_maybe_wake(mp->txq + mp->txq_primary);
641 spin_unlock(&mp->lock);
642 }
617 } 643 }
618#endif 644#endif
619 645
@@ -706,6 +732,7 @@ static inline __be16 sum16_as_be(__sum16 sum)
706 732
707static void txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb) 733static void txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)
708{ 734{
735 struct mv643xx_eth_private *mp = txq_to_mp(txq);
709 int nr_frags = skb_shinfo(skb)->nr_frags; 736 int nr_frags = skb_shinfo(skb)->nr_frags;
710 int tx_index; 737 int tx_index;
711 struct tx_desc *desc; 738 struct tx_desc *desc;
@@ -732,12 +759,36 @@ static void txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)
732 desc->buf_ptr = dma_map_single(NULL, skb->data, length, DMA_TO_DEVICE); 759 desc->buf_ptr = dma_map_single(NULL, skb->data, length, DMA_TO_DEVICE);
733 760
734 if (skb->ip_summed == CHECKSUM_PARTIAL) { 761 if (skb->ip_summed == CHECKSUM_PARTIAL) {
735 BUG_ON(skb->protocol != htons(ETH_P_IP)); 762 int mac_hdr_len;
763
764 BUG_ON(skb->protocol != htons(ETH_P_IP) &&
765 skb->protocol != htons(ETH_P_8021Q));
736 766
737 cmd_sts |= GEN_TCP_UDP_CHECKSUM | 767 cmd_sts |= GEN_TCP_UDP_CHECKSUM |
738 GEN_IP_V4_CHECKSUM | 768 GEN_IP_V4_CHECKSUM |
739 ip_hdr(skb)->ihl << TX_IHL_SHIFT; 769 ip_hdr(skb)->ihl << TX_IHL_SHIFT;
740 770
771 mac_hdr_len = (void *)ip_hdr(skb) - (void *)skb->data;
772 switch (mac_hdr_len - ETH_HLEN) {
773 case 0:
774 break;
775 case 4:
776 cmd_sts |= MAC_HDR_EXTRA_4_BYTES;
777 break;
778 case 8:
779 cmd_sts |= MAC_HDR_EXTRA_8_BYTES;
780 break;
781 case 12:
782 cmd_sts |= MAC_HDR_EXTRA_4_BYTES;
783 cmd_sts |= MAC_HDR_EXTRA_8_BYTES;
784 break;
785 default:
786 if (net_ratelimit())
787 dev_printk(KERN_ERR, &txq_to_mp(txq)->dev->dev,
788 "mac header length is %d?!\n", mac_hdr_len);
789 break;
790 }
791
741 switch (ip_hdr(skb)->protocol) { 792 switch (ip_hdr(skb)->protocol) {
742 case IPPROTO_UDP: 793 case IPPROTO_UDP:
743 cmd_sts |= UDP_FRAME; 794 cmd_sts |= UDP_FRAME;
@@ -759,6 +810,10 @@ static void txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)
759 wmb(); 810 wmb();
760 desc->cmd_sts = cmd_sts; 811 desc->cmd_sts = cmd_sts;
761 812
813 /* clear TX_END interrupt status */
814 wrl(mp, INT_CAUSE(mp->port_num), ~(INT_TX_END_0 << txq->index));
815 rdl(mp, INT_CAUSE(mp->port_num));
816
762 /* ensure all descriptors are written before poking hardware */ 817 /* ensure all descriptors are written before poking hardware */
763 wmb(); 818 wmb();
764 txq_enable(txq); 819 txq_enable(txq);
@@ -1112,10 +1167,28 @@ static int mv643xx_eth_get_settings(struct net_device *dev, struct ethtool_cmd *
1112 1167
1113static int mv643xx_eth_get_settings_phyless(struct net_device *dev, struct ethtool_cmd *cmd) 1168static int mv643xx_eth_get_settings_phyless(struct net_device *dev, struct ethtool_cmd *cmd)
1114{ 1169{
1170 struct mv643xx_eth_private *mp = netdev_priv(dev);
1171 u32 port_status;
1172
1173 port_status = rdl(mp, PORT_STATUS(mp->port_num));
1174
1115 cmd->supported = SUPPORTED_MII; 1175 cmd->supported = SUPPORTED_MII;
1116 cmd->advertising = ADVERTISED_MII; 1176 cmd->advertising = ADVERTISED_MII;
1117 cmd->speed = SPEED_1000; 1177 switch (port_status & PORT_SPEED_MASK) {
1118 cmd->duplex = DUPLEX_FULL; 1178 case PORT_SPEED_10:
1179 cmd->speed = SPEED_10;
1180 break;
1181 case PORT_SPEED_100:
1182 cmd->speed = SPEED_100;
1183 break;
1184 case PORT_SPEED_1000:
1185 cmd->speed = SPEED_1000;
1186 break;
1187 default:
1188 cmd->speed = -1;
1189 break;
1190 }
1191 cmd->duplex = (port_status & FULL_DUPLEX) ? DUPLEX_FULL : DUPLEX_HALF;
1119 cmd->port = PORT_MII; 1192 cmd->port = PORT_MII;
1120 cmd->phy_address = 0; 1193 cmd->phy_address = 0;
1121 cmd->transceiver = XCVR_INTERNAL; 1194 cmd->transceiver = XCVR_INTERNAL;
@@ -1539,8 +1612,11 @@ static int txq_init(struct mv643xx_eth_private *mp, int index)
1539 1612
1540 tx_desc = (struct tx_desc *)txq->tx_desc_area; 1613 tx_desc = (struct tx_desc *)txq->tx_desc_area;
1541 for (i = 0; i < txq->tx_ring_size; i++) { 1614 for (i = 0; i < txq->tx_ring_size; i++) {
1615 struct tx_desc *txd = tx_desc + i;
1542 int nexti = (i + 1) % txq->tx_ring_size; 1616 int nexti = (i + 1) % txq->tx_ring_size;
1543 tx_desc[i].next_desc_ptr = txq->tx_desc_dma + 1617
1618 txd->cmd_sts = 0;
1619 txd->next_desc_ptr = txq->tx_desc_dma +
1544 nexti * sizeof(struct tx_desc); 1620 nexti * sizeof(struct tx_desc);
1545 } 1621 }
1546 1622
@@ -1577,8 +1653,11 @@ static void txq_reclaim(struct tx_queue *txq, int force)
1577 desc = &txq->tx_desc_area[tx_index]; 1653 desc = &txq->tx_desc_area[tx_index];
1578 cmd_sts = desc->cmd_sts; 1654 cmd_sts = desc->cmd_sts;
1579 1655
1580 if (!force && (cmd_sts & BUFFER_OWNED_BY_DMA)) 1656 if (cmd_sts & BUFFER_OWNED_BY_DMA) {
1581 break; 1657 if (!force)
1658 break;
1659 desc->cmd_sts = cmd_sts & ~BUFFER_OWNED_BY_DMA;
1660 }
1582 1661
1583 txq->tx_used_desc = (tx_index + 1) % txq->tx_ring_size; 1662 txq->tx_used_desc = (tx_index + 1) % txq->tx_ring_size;
1584 txq->tx_desc_count--; 1663 txq->tx_desc_count--;
@@ -1632,49 +1711,61 @@ static void txq_deinit(struct tx_queue *txq)
1632 1711
1633 1712
1634/* netdev ops and related ***************************************************/ 1713/* netdev ops and related ***************************************************/
1635static void update_pscr(struct mv643xx_eth_private *mp, int speed, int duplex) 1714static void handle_link_event(struct mv643xx_eth_private *mp)
1636{ 1715{
1637 u32 pscr_o; 1716 struct net_device *dev = mp->dev;
1638 u32 pscr_n; 1717 u32 port_status;
1639 1718 int speed;
1640 pscr_o = rdl(mp, PORT_SERIAL_CONTROL(mp->port_num)); 1719 int duplex;
1720 int fc;
1721
1722 port_status = rdl(mp, PORT_STATUS(mp->port_num));
1723 if (!(port_status & LINK_UP)) {
1724 if (netif_carrier_ok(dev)) {
1725 int i;
1641 1726
1642 /* clear speed, duplex and rx buffer size fields */ 1727 printk(KERN_INFO "%s: link down\n", dev->name);
1643 pscr_n = pscr_o & ~(SET_MII_SPEED_TO_100 |
1644 SET_GMII_SPEED_TO_1000 |
1645 SET_FULL_DUPLEX_MODE |
1646 MAX_RX_PACKET_MASK);
1647 1728
1648 if (speed == SPEED_1000) { 1729 netif_carrier_off(dev);
1649 pscr_n |= SET_GMII_SPEED_TO_1000 | MAX_RX_PACKET_9700BYTE; 1730 netif_stop_queue(dev);
1650 } else {
1651 if (speed == SPEED_100)
1652 pscr_n |= SET_MII_SPEED_TO_100;
1653 pscr_n |= MAX_RX_PACKET_1522BYTE;
1654 }
1655 1731
1656 if (duplex == DUPLEX_FULL) 1732 for (i = 0; i < 8; i++) {
1657 pscr_n |= SET_FULL_DUPLEX_MODE; 1733 struct tx_queue *txq = mp->txq + i;
1658 1734
1659 if (pscr_n != pscr_o) { 1735 if (mp->txq_mask & (1 << i)) {
1660 if ((pscr_o & SERIAL_PORT_ENABLE) == 0) 1736 txq_reclaim(txq, 1);
1661 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr_n); 1737 txq_reset_hw_ptr(txq);
1662 else { 1738 }
1663 int i; 1739 }
1740 }
1741 return;
1742 }
1664 1743
1665 for (i = 0; i < 8; i++) 1744 switch (port_status & PORT_SPEED_MASK) {
1666 if (mp->txq_mask & (1 << i)) 1745 case PORT_SPEED_10:
1667 txq_disable(mp->txq + i); 1746 speed = 10;
1747 break;
1748 case PORT_SPEED_100:
1749 speed = 100;
1750 break;
1751 case PORT_SPEED_1000:
1752 speed = 1000;
1753 break;
1754 default:
1755 speed = -1;
1756 break;
1757 }
1758 duplex = (port_status & FULL_DUPLEX) ? 1 : 0;
1759 fc = (port_status & FLOW_CONTROL_ENABLED) ? 1 : 0;
1668 1760
1669 pscr_o &= ~SERIAL_PORT_ENABLE; 1761 printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, "
1670 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr_o); 1762 "flow control %sabled\n", dev->name,
1671 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr_n); 1763 speed, duplex ? "full" : "half",
1672 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr_n); 1764 fc ? "en" : "dis");
1673 1765
1674 for (i = 0; i < 8; i++) 1766 if (!netif_carrier_ok(dev)) {
1675 if (mp->txq_mask & (1 << i)) 1767 netif_carrier_on(dev);
1676 txq_enable(mp->txq + i); 1768 netif_wake_queue(dev);
1677 }
1678 } 1769 }
1679} 1770}
1680 1771
@@ -1684,7 +1775,6 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id)
1684 struct mv643xx_eth_private *mp = netdev_priv(dev); 1775 struct mv643xx_eth_private *mp = netdev_priv(dev);
1685 u32 int_cause; 1776 u32 int_cause;
1686 u32 int_cause_ext; 1777 u32 int_cause_ext;
1687 u32 txq_active;
1688 1778
1689 int_cause = rdl(mp, INT_CAUSE(mp->port_num)) & 1779 int_cause = rdl(mp, INT_CAUSE(mp->port_num)) &
1690 (INT_TX_END | INT_RX | INT_EXT); 1780 (INT_TX_END | INT_RX | INT_EXT);
@@ -1698,30 +1788,8 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id)
1698 wrl(mp, INT_CAUSE_EXT(mp->port_num), ~int_cause_ext); 1788 wrl(mp, INT_CAUSE_EXT(mp->port_num), ~int_cause_ext);
1699 } 1789 }
1700 1790
1701 if (int_cause_ext & (INT_EXT_PHY | INT_EXT_LINK)) { 1791 if (int_cause_ext & (INT_EXT_PHY | INT_EXT_LINK))
1702 if (mp->phy_addr == -1 || mii_link_ok(&mp->mii)) { 1792 handle_link_event(mp);
1703 int i;
1704
1705 if (mp->phy_addr != -1) {
1706 struct ethtool_cmd cmd;
1707
1708 mii_ethtool_gset(&mp->mii, &cmd);
1709 update_pscr(mp, cmd.speed, cmd.duplex);
1710 }
1711
1712 for (i = 0; i < 8; i++)
1713 if (mp->txq_mask & (1 << i))
1714 txq_enable(mp->txq + i);
1715
1716 if (!netif_carrier_ok(dev)) {
1717 netif_carrier_on(dev);
1718 __txq_maybe_wake(mp->txq + mp->txq_primary);
1719 }
1720 } else if (netif_carrier_ok(dev)) {
1721 netif_stop_queue(dev);
1722 netif_carrier_off(dev);
1723 }
1724 }
1725 1793
1726 /* 1794 /*
1727 * RxBuffer or RxError set for any of the 8 queues? 1795 * RxBuffer or RxError set for any of the 8 queues?
@@ -1743,8 +1811,6 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id)
1743 } 1811 }
1744#endif 1812#endif
1745 1813
1746 txq_active = rdl(mp, TXQ_COMMAND(mp->port_num));
1747
1748 /* 1814 /*
1749 * TxBuffer or TxError set for any of the 8 queues? 1815 * TxBuffer or TxError set for any of the 8 queues?
1750 */ 1816 */
@@ -1754,6 +1820,16 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id)
1754 for (i = 0; i < 8; i++) 1820 for (i = 0; i < 8; i++)
1755 if (mp->txq_mask & (1 << i)) 1821 if (mp->txq_mask & (1 << i))
1756 txq_reclaim(mp->txq + i, 0); 1822 txq_reclaim(mp->txq + i, 0);
1823
1824 /*
1825 * Enough space again in the primary TX queue for a
1826 * full packet?
1827 */
1828 if (netif_carrier_ok(dev)) {
1829 spin_lock(&mp->lock);
1830 __txq_maybe_wake(mp->txq + mp->txq_primary);
1831 spin_unlock(&mp->lock);
1832 }
1757 } 1833 }
1758 1834
1759 /* 1835 /*
@@ -1763,19 +1839,25 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id)
1763 int i; 1839 int i;
1764 1840
1765 wrl(mp, INT_CAUSE(mp->port_num), ~(int_cause & INT_TX_END)); 1841 wrl(mp, INT_CAUSE(mp->port_num), ~(int_cause & INT_TX_END));
1842
1843 spin_lock(&mp->lock);
1766 for (i = 0; i < 8; i++) { 1844 for (i = 0; i < 8; i++) {
1767 struct tx_queue *txq = mp->txq + i; 1845 struct tx_queue *txq = mp->txq + i;
1768 if (txq->tx_desc_count && !((txq_active >> i) & 1)) 1846 u32 hw_desc_ptr;
1847 u32 expected_ptr;
1848
1849 if ((int_cause & (INT_TX_END_0 << i)) == 0)
1850 continue;
1851
1852 hw_desc_ptr =
1853 rdl(mp, TXQ_CURRENT_DESC_PTR(mp->port_num, i));
1854 expected_ptr = (u32)txq->tx_desc_dma +
1855 txq->tx_curr_desc * sizeof(struct tx_desc);
1856
1857 if (hw_desc_ptr != expected_ptr)
1769 txq_enable(txq); 1858 txq_enable(txq);
1770 } 1859 }
1771 } 1860 spin_unlock(&mp->lock);
1772
1773 /*
1774 * Enough space again in the primary TX queue for a full packet?
1775 */
1776 if (int_cause_ext & INT_EXT_TX) {
1777 struct tx_queue *txq = mp->txq + mp->txq_primary;
1778 __txq_maybe_wake(txq);
1779 } 1861 }
1780 1862
1781 return IRQ_HANDLED; 1863 return IRQ_HANDLED;
@@ -1785,14 +1867,14 @@ static void phy_reset(struct mv643xx_eth_private *mp)
1785{ 1867{
1786 unsigned int data; 1868 unsigned int data;
1787 1869
1788 smi_reg_read(mp, mp->phy_addr, 0, &data); 1870 smi_reg_read(mp, mp->phy_addr, MII_BMCR, &data);
1789 data |= 0x8000; 1871 data |= BMCR_RESET;
1790 smi_reg_write(mp, mp->phy_addr, 0, data); 1872 smi_reg_write(mp, mp->phy_addr, MII_BMCR, data);
1791 1873
1792 do { 1874 do {
1793 udelay(1); 1875 udelay(1);
1794 smi_reg_read(mp, mp->phy_addr, 0, &data); 1876 smi_reg_read(mp, mp->phy_addr, MII_BMCR, &data);
1795 } while (data & 0x8000); 1877 } while (data & BMCR_RESET);
1796} 1878}
1797 1879
1798static void port_start(struct mv643xx_eth_private *mp) 1880static void port_start(struct mv643xx_eth_private *mp)
@@ -1801,23 +1883,6 @@ static void port_start(struct mv643xx_eth_private *mp)
1801 int i; 1883 int i;
1802 1884
1803 /* 1885 /*
1804 * Configure basic link parameters.
1805 */
1806 pscr = rdl(mp, PORT_SERIAL_CONTROL(mp->port_num));
1807 pscr &= ~(SERIAL_PORT_ENABLE | FORCE_LINK_PASS);
1808 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr);
1809 pscr |= DISABLE_AUTO_NEG_FOR_FLOW_CTRL |
1810 DISABLE_AUTO_NEG_SPEED_GMII |
1811 DISABLE_AUTO_NEG_FOR_DUPLEX |
1812 DO_NOT_FORCE_LINK_FAIL |
1813 SERIAL_PORT_CONTROL_RESERVED;
1814 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr);
1815 pscr |= SERIAL_PORT_ENABLE;
1816 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr);
1817
1818 wrl(mp, SDMA_CONFIG(mp->port_num), PORT_SDMA_CONFIG_DEFAULT_VALUE);
1819
1820 /*
1821 * Perform PHY reset, if there is a PHY. 1886 * Perform PHY reset, if there is a PHY.
1822 */ 1887 */
1823 if (mp->phy_addr != -1) { 1888 if (mp->phy_addr != -1) {
@@ -1829,21 +1894,31 @@ static void port_start(struct mv643xx_eth_private *mp)
1829 } 1894 }
1830 1895
1831 /* 1896 /*
1897 * Configure basic link parameters.
1898 */
1899 pscr = rdl(mp, PORT_SERIAL_CONTROL(mp->port_num));
1900
1901 pscr |= SERIAL_PORT_ENABLE;
1902 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr);
1903
1904 pscr |= DO_NOT_FORCE_LINK_FAIL;
1905 if (mp->phy_addr == -1)
1906 pscr |= FORCE_LINK_PASS;
1907 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr);
1908
1909 wrl(mp, SDMA_CONFIG(mp->port_num), PORT_SDMA_CONFIG_DEFAULT_VALUE);
1910
1911 /*
1832 * Configure TX path and queues. 1912 * Configure TX path and queues.
1833 */ 1913 */
1834 tx_set_rate(mp, 1000000000, 16777216); 1914 tx_set_rate(mp, 1000000000, 16777216);
1835 for (i = 0; i < 8; i++) { 1915 for (i = 0; i < 8; i++) {
1836 struct tx_queue *txq = mp->txq + i; 1916 struct tx_queue *txq = mp->txq + i;
1837 int off = TXQ_CURRENT_DESC_PTR(mp->port_num, i);
1838 u32 addr;
1839 1917
1840 if ((mp->txq_mask & (1 << i)) == 0) 1918 if ((mp->txq_mask & (1 << i)) == 0)
1841 continue; 1919 continue;
1842 1920
1843 addr = (u32)txq->tx_desc_dma; 1921 txq_reset_hw_ptr(txq);
1844 addr += txq->tx_curr_desc * sizeof(struct tx_desc);
1845 wrl(mp, off, addr);
1846
1847 txq_set_rate(txq, 1000000000, 16777216); 1922 txq_set_rate(txq, 1000000000, 16777216);
1848 txq_set_fixed_prio_mode(txq); 1923 txq_set_fixed_prio_mode(txq);
1849 } 1924 }
@@ -1965,6 +2040,9 @@ static int mv643xx_eth_open(struct net_device *dev)
1965 napi_enable(&mp->napi); 2040 napi_enable(&mp->napi);
1966#endif 2041#endif
1967 2042
2043 netif_carrier_off(dev);
2044 netif_stop_queue(dev);
2045
1968 port_start(mp); 2046 port_start(mp);
1969 2047
1970 set_rx_coal(mp, 0); 2048 set_rx_coal(mp, 0);
@@ -1999,8 +2077,14 @@ static void port_reset(struct mv643xx_eth_private *mp)
1999 if (mp->txq_mask & (1 << i)) 2077 if (mp->txq_mask & (1 << i))
2000 txq_disable(mp->txq + i); 2078 txq_disable(mp->txq + i);
2001 } 2079 }
2002 while (!(rdl(mp, PORT_STATUS(mp->port_num)) & TX_FIFO_EMPTY)) 2080
2081 while (1) {
2082 u32 ps = rdl(mp, PORT_STATUS(mp->port_num));
2083
2084 if ((ps & (TX_IN_PROGRESS | TX_FIFO_EMPTY)) == TX_FIFO_EMPTY)
2085 break;
2003 udelay(10); 2086 udelay(10);
2087 }
2004 2088
2005 /* Reset the Enable bit in the Configuration Register */ 2089 /* Reset the Enable bit in the Configuration Register */
2006 data = rdl(mp, PORT_SERIAL_CONTROL(mp->port_num)); 2090 data = rdl(mp, PORT_SERIAL_CONTROL(mp->port_num));
@@ -2202,7 +2286,8 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2202 int ret; 2286 int ret;
2203 2287
2204 if (!mv643xx_eth_version_printed++) 2288 if (!mv643xx_eth_version_printed++)
2205 printk(KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n"); 2289 printk(KERN_NOTICE "MV-643xx 10/100/1000 ethernet "
2290 "driver version %s\n", mv643xx_eth_driver_version);
2206 2291
2207 ret = -EINVAL; 2292 ret = -EINVAL;
2208 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2293 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -2338,14 +2423,14 @@ static int phy_detect(struct mv643xx_eth_private *mp)
2338 unsigned int data; 2423 unsigned int data;
2339 unsigned int data2; 2424 unsigned int data2;
2340 2425
2341 smi_reg_read(mp, mp->phy_addr, 0, &data); 2426 smi_reg_read(mp, mp->phy_addr, MII_BMCR, &data);
2342 smi_reg_write(mp, mp->phy_addr, 0, data ^ 0x1000); 2427 smi_reg_write(mp, mp->phy_addr, MII_BMCR, data ^ BMCR_ANENABLE);
2343 2428
2344 smi_reg_read(mp, mp->phy_addr, 0, &data2); 2429 smi_reg_read(mp, mp->phy_addr, MII_BMCR, &data2);
2345 if (((data ^ data2) & 0x1000) == 0) 2430 if (((data ^ data2) & BMCR_ANENABLE) == 0)
2346 return -ENODEV; 2431 return -ENODEV;
2347 2432
2348 smi_reg_write(mp, mp->phy_addr, 0, data); 2433 smi_reg_write(mp, mp->phy_addr, MII_BMCR, data);
2349 2434
2350 return 0; 2435 return 0;
2351} 2436}
@@ -2393,12 +2478,39 @@ static int phy_init(struct mv643xx_eth_private *mp,
2393 cmd.duplex = pd->duplex; 2478 cmd.duplex = pd->duplex;
2394 } 2479 }
2395 2480
2396 update_pscr(mp, cmd.speed, cmd.duplex);
2397 mv643xx_eth_set_settings(mp->dev, &cmd); 2481 mv643xx_eth_set_settings(mp->dev, &cmd);
2398 2482
2399 return 0; 2483 return 0;
2400} 2484}
2401 2485
2486static void init_pscr(struct mv643xx_eth_private *mp, int speed, int duplex)
2487{
2488 u32 pscr;
2489
2490 pscr = rdl(mp, PORT_SERIAL_CONTROL(mp->port_num));
2491 if (pscr & SERIAL_PORT_ENABLE) {
2492 pscr &= ~SERIAL_PORT_ENABLE;
2493 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr);
2494 }
2495
2496 pscr = MAX_RX_PACKET_9700BYTE | SERIAL_PORT_CONTROL_RESERVED;
2497 if (mp->phy_addr == -1) {
2498 pscr |= DISABLE_AUTO_NEG_SPEED_GMII;
2499 if (speed == SPEED_1000)
2500 pscr |= SET_GMII_SPEED_TO_1000;
2501 else if (speed == SPEED_100)
2502 pscr |= SET_MII_SPEED_TO_100;
2503
2504 pscr |= DISABLE_AUTO_NEG_FOR_FLOW_CTRL;
2505
2506 pscr |= DISABLE_AUTO_NEG_FOR_DUPLEX;
2507 if (duplex == DUPLEX_FULL)
2508 pscr |= SET_FULL_DUPLEX_MODE;
2509 }
2510
2511 wrl(mp, PORT_SERIAL_CONTROL(mp->port_num), pscr);
2512}
2513
2402static int mv643xx_eth_probe(struct platform_device *pdev) 2514static int mv643xx_eth_probe(struct platform_device *pdev)
2403{ 2515{
2404 struct mv643xx_eth_platform_data *pd; 2516 struct mv643xx_eth_platform_data *pd;
@@ -2452,6 +2564,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
2452 } else { 2564 } else {
2453 SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops_phyless); 2565 SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops_phyless);
2454 } 2566 }
2567 init_pscr(mp, pd->speed, pd->duplex);
2455 2568
2456 2569
2457 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2570 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -2478,6 +2591,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
2478 * have to map the buffers to ISA memory which is only 16 MB 2591 * have to map the buffers to ISA memory which is only 16 MB
2479 */ 2592 */
2480 dev->features = NETIF_F_SG | NETIF_F_IP_CSUM; 2593 dev->features = NETIF_F_SG | NETIF_F_IP_CSUM;
2594 dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM;
2481#endif 2595#endif
2482 2596
2483 SET_NETDEV_DEV(dev, &pdev->dev); 2597 SET_NETDEV_DEV(dev, &pdev->dev);
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index 2fec6122c7fa..42443d697423 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -536,7 +536,7 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
536#ifdef CONFIG_NET_POLL_CONTROLLER 536#ifdef CONFIG_NET_POLL_CONTROLLER
537 dev->poll_controller = eip_poll; 537 dev->poll_controller = eip_poll;
538#endif 538#endif
539 NS8390_init(dev, 0); 539 NS8390p_init(dev, 0);
540 540
541 ret = register_netdev(dev); 541 ret = register_netdev(dev);
542 if (ret) 542 if (ret)
@@ -794,7 +794,7 @@ retry:
794 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */ 794 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
795 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name); 795 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
796 ne_reset_8390(dev); 796 ne_reset_8390(dev);
797 NS8390_init(dev,1); 797 NS8390p_init(dev, 1);
798 break; 798 break;
799 } 799 }
800 800
@@ -855,7 +855,7 @@ static int ne_drv_resume(struct platform_device *pdev)
855 855
856 if (netif_running(dev)) { 856 if (netif_running(dev)) {
857 ne_reset_8390(dev); 857 ne_reset_8390(dev);
858 NS8390_init(dev, 1); 858 NS8390p_init(dev, 1);
859 netif_device_attach(dev); 859 netif_device_attach(dev);
860 } 860 }
861 return 0; 861 return 0;
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index e13966bb5f77..9681618c3232 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -53,7 +53,7 @@ MODULE_LICENSE("GPL");
53 53
54static char config[MAX_PARAM_LENGTH]; 54static char config[MAX_PARAM_LENGTH];
55module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0); 55module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0);
56MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n"); 56MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]");
57 57
58#ifndef MODULE 58#ifndef MODULE
59static int __init option_setup(char *opt) 59static int __init option_setup(char *opt)
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 86d77d05190a..a2b073097e5c 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -3143,7 +3143,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
3143 pkt_cnt++; 3143 pkt_cnt++;
3144 3144
3145 /* Updating the statistics block */ 3145 /* Updating the statistics block */
3146 nic->stats.tx_bytes += skb->len; 3146 nic->dev->stats.tx_bytes += skb->len;
3147 nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; 3147 nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
3148 dev_kfree_skb_irq(skb); 3148 dev_kfree_skb_irq(skb);
3149 3149
@@ -4896,25 +4896,42 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4896 /* Configure Stats for immediate updt */ 4896 /* Configure Stats for immediate updt */
4897 s2io_updt_stats(sp); 4897 s2io_updt_stats(sp);
4898 4898
4899 /* Using sp->stats as a staging area, because reset (due to mtu
4900 change, for example) will clear some hardware counters */
4901 dev->stats.tx_packets +=
4902 le32_to_cpu(mac_control->stats_info->tmac_frms) -
4903 sp->stats.tx_packets;
4899 sp->stats.tx_packets = 4904 sp->stats.tx_packets =
4900 le32_to_cpu(mac_control->stats_info->tmac_frms); 4905 le32_to_cpu(mac_control->stats_info->tmac_frms);
4906 dev->stats.tx_errors +=
4907 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms) -
4908 sp->stats.tx_errors;
4901 sp->stats.tx_errors = 4909 sp->stats.tx_errors =
4902 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms); 4910 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms);
4911 dev->stats.rx_errors +=
4912 le64_to_cpu(mac_control->stats_info->rmac_drop_frms) -
4913 sp->stats.rx_errors;
4903 sp->stats.rx_errors = 4914 sp->stats.rx_errors =
4904 le64_to_cpu(mac_control->stats_info->rmac_drop_frms); 4915 le64_to_cpu(mac_control->stats_info->rmac_drop_frms);
4916 dev->stats.multicast =
4917 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms) -
4918 sp->stats.multicast;
4905 sp->stats.multicast = 4919 sp->stats.multicast =
4906 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms); 4920 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms);
4921 dev->stats.rx_length_errors =
4922 le64_to_cpu(mac_control->stats_info->rmac_long_frms) -
4923 sp->stats.rx_length_errors;
4907 sp->stats.rx_length_errors = 4924 sp->stats.rx_length_errors =
4908 le64_to_cpu(mac_control->stats_info->rmac_long_frms); 4925 le64_to_cpu(mac_control->stats_info->rmac_long_frms);
4909 4926
4910 /* collect per-ring rx_packets and rx_bytes */ 4927 /* collect per-ring rx_packets and rx_bytes */
4911 sp->stats.rx_packets = sp->stats.rx_bytes = 0; 4928 dev->stats.rx_packets = dev->stats.rx_bytes = 0;
4912 for (i = 0; i < config->rx_ring_num; i++) { 4929 for (i = 0; i < config->rx_ring_num; i++) {
4913 sp->stats.rx_packets += mac_control->rings[i].rx_packets; 4930 dev->stats.rx_packets += mac_control->rings[i].rx_packets;
4914 sp->stats.rx_bytes += mac_control->rings[i].rx_bytes; 4931 dev->stats.rx_bytes += mac_control->rings[i].rx_bytes;
4915 } 4932 }
4916 4933
4917 return (&sp->stats); 4934 return (&dev->stats);
4918} 4935}
4919 4936
4920/** 4937/**
@@ -7419,7 +7436,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7419 if (err_mask != 0x5) { 7436 if (err_mask != 0x5) {
7420 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%x\n", 7437 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%x\n",
7421 dev->name, err_mask); 7438 dev->name, err_mask);
7422 sp->stats.rx_crc_errors++; 7439 dev->stats.rx_crc_errors++;
7423 sp->mac_control.stats_info->sw_stat.mem_freed 7440 sp->mac_control.stats_info->sw_stat.mem_freed
7424 += skb->truesize; 7441 += skb->truesize;
7425 dev_kfree_skb(skb); 7442 dev_kfree_skb(skb);
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index c69ba1395fa9..6a06b9503e4f 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * SuperH Ethernet device driver 2 * SuperH Ethernet device driver
3 * 3 *
4 * Copyright (C) 2006,2007 Nobuhiro Iwamatsu 4 * Copyright (C) 2006-2008 Nobuhiro Iwamatsu
5 * Copyright (C) 2008 Renesas Solutions Corp. 5 * Copyright (C) 2008 Renesas Solutions Corp.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
@@ -143,13 +143,39 @@ static struct mdiobb_ops bb_ops = {
143 .get_mdio_data = sh_get_mdio, 143 .get_mdio_data = sh_get_mdio,
144}; 144};
145 145
146/* Chip Reset */
146static void sh_eth_reset(struct net_device *ndev) 147static void sh_eth_reset(struct net_device *ndev)
147{ 148{
148 u32 ioaddr = ndev->base_addr; 149 u32 ioaddr = ndev->base_addr;
149 150
151#if defined(CONFIG_CPU_SUBTYPE_SH7763)
152 int cnt = 100;
153
154 ctrl_outl(EDSR_ENALL, ioaddr + EDSR);
155 ctrl_outl(ctrl_inl(ioaddr + EDMR) | EDMR_SRST, ioaddr + EDMR);
156 while (cnt > 0) {
157 if (!(ctrl_inl(ioaddr + EDMR) & 0x3))
158 break;
159 mdelay(1);
160 cnt--;
161 }
162 if (cnt < 0)
163 printk(KERN_ERR "Device reset fail\n");
164
165 /* Table Init */
166 ctrl_outl(0x0, ioaddr + TDLAR);
167 ctrl_outl(0x0, ioaddr + TDFAR);
168 ctrl_outl(0x0, ioaddr + TDFXR);
169 ctrl_outl(0x0, ioaddr + TDFFR);
170 ctrl_outl(0x0, ioaddr + RDLAR);
171 ctrl_outl(0x0, ioaddr + RDFAR);
172 ctrl_outl(0x0, ioaddr + RDFXR);
173 ctrl_outl(0x0, ioaddr + RDFFR);
174#else
150 ctrl_outl(ctrl_inl(ioaddr + EDMR) | EDMR_SRST, ioaddr + EDMR); 175 ctrl_outl(ctrl_inl(ioaddr + EDMR) | EDMR_SRST, ioaddr + EDMR);
151 mdelay(3); 176 mdelay(3);
152 ctrl_outl(ctrl_inl(ioaddr + EDMR) & ~EDMR_SRST, ioaddr + EDMR); 177 ctrl_outl(ctrl_inl(ioaddr + EDMR) & ~EDMR_SRST, ioaddr + EDMR);
178#endif
153} 179}
154 180
155/* free skb and descriptor buffer */ 181/* free skb and descriptor buffer */
@@ -180,6 +206,7 @@ static void sh_eth_ring_free(struct net_device *ndev)
180/* format skb and descriptor buffer */ 206/* format skb and descriptor buffer */
181static void sh_eth_ring_format(struct net_device *ndev) 207static void sh_eth_ring_format(struct net_device *ndev)
182{ 208{
209 u32 ioaddr = ndev->base_addr, reserve = 0;
183 struct sh_eth_private *mdp = netdev_priv(ndev); 210 struct sh_eth_private *mdp = netdev_priv(ndev);
184 int i; 211 int i;
185 struct sk_buff *skb; 212 struct sk_buff *skb;
@@ -201,9 +228,15 @@ static void sh_eth_ring_format(struct net_device *ndev)
201 mdp->rx_skbuff[i] = skb; 228 mdp->rx_skbuff[i] = skb;
202 if (skb == NULL) 229 if (skb == NULL)
203 break; 230 break;
204 skb->dev = ndev; /* Mark as being used by this device. */ 231 skb->dev = ndev; /* Mark as being used by this device. */
232#if defined(CONFIG_CPU_SUBTYPE_SH7763)
233 reserve = SH7763_SKB_ALIGN
234 - ((uint32_t)skb->data & (SH7763_SKB_ALIGN-1));
235 if (reserve)
236 skb_reserve(skb, reserve);
237#else
205 skb_reserve(skb, RX_OFFSET); 238 skb_reserve(skb, RX_OFFSET);
206 239#endif
207 /* RX descriptor */ 240 /* RX descriptor */
208 rxdesc = &mdp->rx_ring[i]; 241 rxdesc = &mdp->rx_ring[i];
209 rxdesc->addr = (u32)skb->data & ~0x3UL; 242 rxdesc->addr = (u32)skb->data & ~0x3UL;
@@ -211,12 +244,25 @@ static void sh_eth_ring_format(struct net_device *ndev)
211 244
212 /* The size of the buffer is 16 byte boundary. */ 245 /* The size of the buffer is 16 byte boundary. */
213 rxdesc->buffer_length = (mdp->rx_buf_sz + 16) & ~0x0F; 246 rxdesc->buffer_length = (mdp->rx_buf_sz + 16) & ~0x0F;
247 /* Rx descriptor address set */
248 if (i == 0) {
249 ctrl_outl((u32)rxdesc, ioaddr + RDLAR);
250#if defined(CONFIG_CPU_SUBTYPE_SH7763)
251 ctrl_outl((u32)rxdesc, ioaddr + RDFAR);
252#endif
253 }
214 } 254 }
215 255
256 /* Rx descriptor address set */
257#if defined(CONFIG_CPU_SUBTYPE_SH7763)
258 ctrl_outl((u32)rxdesc, ioaddr + RDFXR);
259 ctrl_outl(0x1, ioaddr + RDFFR);
260#endif
261
216 mdp->dirty_rx = (u32) (i - RX_RING_SIZE); 262 mdp->dirty_rx = (u32) (i - RX_RING_SIZE);
217 263
218 /* Mark the last entry as wrapping the ring. */ 264 /* Mark the last entry as wrapping the ring. */
219 rxdesc->status |= cpu_to_le32(RC_RDEL); 265 rxdesc->status |= cpu_to_le32(RD_RDEL);
220 266
221 memset(mdp->tx_ring, 0, tx_ringsize); 267 memset(mdp->tx_ring, 0, tx_ringsize);
222 268
@@ -226,8 +272,21 @@ static void sh_eth_ring_format(struct net_device *ndev)
226 txdesc = &mdp->tx_ring[i]; 272 txdesc = &mdp->tx_ring[i];
227 txdesc->status = cpu_to_le32(TD_TFP); 273 txdesc->status = cpu_to_le32(TD_TFP);
228 txdesc->buffer_length = 0; 274 txdesc->buffer_length = 0;
275 if (i == 0) {
276 /* Rx descriptor address set */
277 ctrl_outl((u32)txdesc, ioaddr + TDLAR);
278#if defined(CONFIG_CPU_SUBTYPE_SH7763)
279 ctrl_outl((u32)txdesc, ioaddr + TDFAR);
280#endif
281 }
229 } 282 }
230 283
284 /* Rx descriptor address set */
285#if defined(CONFIG_CPU_SUBTYPE_SH7763)
286 ctrl_outl((u32)txdesc, ioaddr + TDFXR);
287 ctrl_outl(0x1, ioaddr + TDFFR);
288#endif
289
231 txdesc->status |= cpu_to_le32(TD_TDLE); 290 txdesc->status |= cpu_to_le32(TD_TDLE);
232} 291}
233 292
@@ -311,31 +370,43 @@ static int sh_eth_dev_init(struct net_device *ndev)
311 /* Soft Reset */ 370 /* Soft Reset */
312 sh_eth_reset(ndev); 371 sh_eth_reset(ndev);
313 372
314 ctrl_outl(RPADIR_PADS1, ioaddr + RPADIR); /* SH7712-DMA-RX-PAD2 */ 373 /* Descriptor format */
374 sh_eth_ring_format(ndev);
375 ctrl_outl(RPADIR_INIT, ioaddr + RPADIR);
315 376
316 /* all sh_eth int mask */ 377 /* all sh_eth int mask */
317 ctrl_outl(0, ioaddr + EESIPR); 378 ctrl_outl(0, ioaddr + EESIPR);
318 379
319 /* FIFO size set */ 380#if defined(CONFIG_CPU_SUBTYPE_SH7763)
381 ctrl_outl(EDMR_EL, ioaddr + EDMR);
382#else
320 ctrl_outl(0, ioaddr + EDMR); /* Endian change */ 383 ctrl_outl(0, ioaddr + EDMR); /* Endian change */
384#endif
321 385
386 /* FIFO size set */
322 ctrl_outl((FIFO_SIZE_T | FIFO_SIZE_R), ioaddr + FDR); 387 ctrl_outl((FIFO_SIZE_T | FIFO_SIZE_R), ioaddr + FDR);
323 ctrl_outl(0, ioaddr + TFTR); 388 ctrl_outl(0, ioaddr + TFTR);
324 389
390 /* Frame recv control */
325 ctrl_outl(0, ioaddr + RMCR); 391 ctrl_outl(0, ioaddr + RMCR);
326 392
327 rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5; 393 rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5;
328 tx_int_var = mdp->tx_int_var = DESC_I_TINT2; 394 tx_int_var = mdp->tx_int_var = DESC_I_TINT2;
329 ctrl_outl(rx_int_var | tx_int_var, ioaddr + TRSCER); 395 ctrl_outl(rx_int_var | tx_int_var, ioaddr + TRSCER);
330 396
397#if defined(CONFIG_CPU_SUBTYPE_SH7763)
398 /* Burst sycle set */
399 ctrl_outl(0x800, ioaddr + BCULR);
400#endif
401
331 ctrl_outl((FIFO_F_D_RFF | FIFO_F_D_RFD), ioaddr + FCFTR); 402 ctrl_outl((FIFO_F_D_RFF | FIFO_F_D_RFD), ioaddr + FCFTR);
332 ctrl_outl(0, ioaddr + TRIMD);
333 403
334 /* Descriptor format */ 404#if !defined(CONFIG_CPU_SUBTYPE_SH7763)
335 sh_eth_ring_format(ndev); 405 ctrl_outl(0, ioaddr + TRIMD);
406#endif
336 407
337 ctrl_outl((u32)mdp->rx_ring, ioaddr + RDLAR); 408 /* Recv frame limit set register */
338 ctrl_outl((u32)mdp->tx_ring, ioaddr + TDLAR); 409 ctrl_outl(RFLR_VALUE, ioaddr + RFLR);
339 410
340 ctrl_outl(ctrl_inl(ioaddr + EESR), ioaddr + EESR); 411 ctrl_outl(ctrl_inl(ioaddr + EESR), ioaddr + EESR);
341 ctrl_outl((DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff), ioaddr + EESIPR); 412 ctrl_outl((DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff), ioaddr + EESIPR);
@@ -345,21 +416,26 @@ static int sh_eth_dev_init(struct net_device *ndev)
345 ECMR_ZPF | (mdp->duplex ? ECMR_DM : 0) | ECMR_TE | ECMR_RE; 416 ECMR_ZPF | (mdp->duplex ? ECMR_DM : 0) | ECMR_TE | ECMR_RE;
346 417
347 ctrl_outl(val, ioaddr + ECMR); 418 ctrl_outl(val, ioaddr + ECMR);
348 ctrl_outl(ECSR_BRCRX | ECSR_PSRTO | ECSR_LCHNG | ECSR_ICD | 419
349 ECSIPR_MPDIP, ioaddr + ECSR); 420 /* E-MAC Status Register clear */
350 ctrl_outl(ECSIPR_BRCRXIP | ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | 421 ctrl_outl(ECSR_INIT, ioaddr + ECSR);
351 ECSIPR_ICDIP | ECSIPR_MPDIP, ioaddr + ECSIPR); 422
423 /* E-MAC Interrupt Enable register */
424 ctrl_outl(ECSIPR_INIT, ioaddr + ECSIPR);
352 425
353 /* Set MAC address */ 426 /* Set MAC address */
354 update_mac_address(ndev); 427 update_mac_address(ndev);
355 428
356 /* mask reset */ 429 /* mask reset */
357#if defined(CONFIG_CPU_SUBTYPE_SH7710) 430#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7763)
358 ctrl_outl(APR_AP, ioaddr + APR); 431 ctrl_outl(APR_AP, ioaddr + APR);
359 ctrl_outl(MPR_MP, ioaddr + MPR); 432 ctrl_outl(MPR_MP, ioaddr + MPR);
360 ctrl_outl(TPAUSER_UNLIMITED, ioaddr + TPAUSER); 433 ctrl_outl(TPAUSER_UNLIMITED, ioaddr + TPAUSER);
434#endif
435#if defined(CONFIG_CPU_SUBTYPE_SH7710)
361 ctrl_outl(BCFR_UNLIMITED, ioaddr + BCFR); 436 ctrl_outl(BCFR_UNLIMITED, ioaddr + BCFR);
362#endif 437#endif
438
363 /* Setting the Rx mode will start the Rx process. */ 439 /* Setting the Rx mode will start the Rx process. */
364 ctrl_outl(EDRRR_R, ioaddr + EDRRR); 440 ctrl_outl(EDRRR_R, ioaddr + EDRRR);
365 441
@@ -407,7 +483,7 @@ static int sh_eth_rx(struct net_device *ndev)
407 int boguscnt = (mdp->dirty_rx + RX_RING_SIZE) - mdp->cur_rx; 483 int boguscnt = (mdp->dirty_rx + RX_RING_SIZE) - mdp->cur_rx;
408 struct sk_buff *skb; 484 struct sk_buff *skb;
409 u16 pkt_len = 0; 485 u16 pkt_len = 0;
410 u32 desc_status; 486 u32 desc_status, reserve = 0;
411 487
412 rxdesc = &mdp->rx_ring[entry]; 488 rxdesc = &mdp->rx_ring[entry];
413 while (!(rxdesc->status & cpu_to_le32(RD_RACT))) { 489 while (!(rxdesc->status & cpu_to_le32(RD_RACT))) {
@@ -454,28 +530,38 @@ static int sh_eth_rx(struct net_device *ndev)
454 for (; mdp->cur_rx - mdp->dirty_rx > 0; mdp->dirty_rx++) { 530 for (; mdp->cur_rx - mdp->dirty_rx > 0; mdp->dirty_rx++) {
455 entry = mdp->dirty_rx % RX_RING_SIZE; 531 entry = mdp->dirty_rx % RX_RING_SIZE;
456 rxdesc = &mdp->rx_ring[entry]; 532 rxdesc = &mdp->rx_ring[entry];
533 /* The size of the buffer is 16 byte boundary. */
534 rxdesc->buffer_length = (mdp->rx_buf_sz + 16) & ~0x0F;
535
457 if (mdp->rx_skbuff[entry] == NULL) { 536 if (mdp->rx_skbuff[entry] == NULL) {
458 skb = dev_alloc_skb(mdp->rx_buf_sz); 537 skb = dev_alloc_skb(mdp->rx_buf_sz);
459 mdp->rx_skbuff[entry] = skb; 538 mdp->rx_skbuff[entry] = skb;
460 if (skb == NULL) 539 if (skb == NULL)
461 break; /* Better luck next round. */ 540 break; /* Better luck next round. */
462 skb->dev = ndev; 541 skb->dev = ndev;
542#if defined(CONFIG_CPU_SUBTYPE_SH7763)
543 reserve = SH7763_SKB_ALIGN
544 - ((uint32_t)skb->data & (SH7763_SKB_ALIGN-1));
545 if (reserve)
546 skb_reserve(skb, reserve);
547#else
463 skb_reserve(skb, RX_OFFSET); 548 skb_reserve(skb, RX_OFFSET);
549#endif
550 skb->ip_summed = CHECKSUM_NONE;
464 rxdesc->addr = (u32)skb->data & ~0x3UL; 551 rxdesc->addr = (u32)skb->data & ~0x3UL;
465 } 552 }
466 /* The size of the buffer is 16 byte boundary. */
467 rxdesc->buffer_length = (mdp->rx_buf_sz + 16) & ~0x0F;
468 if (entry >= RX_RING_SIZE - 1) 553 if (entry >= RX_RING_SIZE - 1)
469 rxdesc->status |= 554 rxdesc->status |=
470 cpu_to_le32(RD_RACT | RD_RFP | RC_RDEL); 555 cpu_to_le32(RD_RACT | RD_RFP | RD_RDEL);
471 else 556 else
472 rxdesc->status |= 557 rxdesc->status |=
473 cpu_to_le32(RD_RACT | RD_RFP); 558 cpu_to_le32(RD_RACT | RD_RFP);
474 } 559 }
475 560
476 /* Restart Rx engine if stopped. */ 561 /* Restart Rx engine if stopped. */
477 /* If we don't need to check status, don't. -KDU */ 562 /* If we don't need to check status, don't. -KDU */
478 ctrl_outl(EDRRR_R, ndev->base_addr + EDRRR); 563 if (!(ctrl_inl(ndev->base_addr + EDRRR) & EDRRR_R))
564 ctrl_outl(EDRRR_R, ndev->base_addr + EDRRR);
479 565
480 return 0; 566 return 0;
481} 567}
@@ -529,13 +615,14 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
529 printk(KERN_ERR "Receive Frame Overflow\n"); 615 printk(KERN_ERR "Receive Frame Overflow\n");
530 } 616 }
531 } 617 }
532 618#if !defined(CONFIG_CPU_SUBTYPE_SH7763)
533 if (intr_status & EESR_ADE) { 619 if (intr_status & EESR_ADE) {
534 if (intr_status & EESR_TDE) { 620 if (intr_status & EESR_TDE) {
535 if (intr_status & EESR_TFE) 621 if (intr_status & EESR_TFE)
536 mdp->stats.tx_fifo_errors++; 622 mdp->stats.tx_fifo_errors++;
537 } 623 }
538 } 624 }
625#endif
539 626
540 if (intr_status & EESR_RDE) { 627 if (intr_status & EESR_RDE) {
541 /* Receive Descriptor Empty int */ 628 /* Receive Descriptor Empty int */
@@ -550,8 +637,11 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
550 mdp->stats.rx_fifo_errors++; 637 mdp->stats.rx_fifo_errors++;
551 printk(KERN_ERR "Receive FIFO Overflow\n"); 638 printk(KERN_ERR "Receive FIFO Overflow\n");
552 } 639 }
553 if (intr_status & 640 if (intr_status & (EESR_TWB | EESR_TABT |
554 (EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | EESR_TFE)) { 641#if !defined(CONFIG_CPU_SUBTYPE_SH7763)
642 EESR_ADE |
643#endif
644 EESR_TDE | EESR_TFE)) {
555 /* Tx error */ 645 /* Tx error */
556 u32 edtrr = ctrl_inl(ndev->base_addr + EDTRR); 646 u32 edtrr = ctrl_inl(ndev->base_addr + EDTRR);
557 /* dmesg */ 647 /* dmesg */
@@ -582,17 +672,23 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
582 ioaddr = ndev->base_addr; 672 ioaddr = ndev->base_addr;
583 spin_lock(&mdp->lock); 673 spin_lock(&mdp->lock);
584 674
675 /* Get interrpt stat */
585 intr_status = ctrl_inl(ioaddr + EESR); 676 intr_status = ctrl_inl(ioaddr + EESR);
586 /* Clear interrupt */ 677 /* Clear interrupt */
587 ctrl_outl(intr_status, ioaddr + EESR); 678 ctrl_outl(intr_status, ioaddr + EESR);
588 679
589 if (intr_status & (EESR_FRC | EESR_RINT8 | 680 if (intr_status & (EESR_FRC | /* Frame recv*/
590 EESR_RINT5 | EESR_RINT4 | EESR_RINT3 | EESR_RINT2 | 681 EESR_RMAF | /* Multi cast address recv*/
591 EESR_RINT1)) 682 EESR_RRF | /* Bit frame recv */
683 EESR_RTLF | /* Long frame recv*/
684 EESR_RTSF | /* short frame recv */
685 EESR_PRE | /* PHY-LSI recv error */
686 EESR_CERF)){ /* recv frame CRC error */
592 sh_eth_rx(ndev); 687 sh_eth_rx(ndev);
593 if (intr_status & (EESR_FTC | 688 }
594 EESR_TINT4 | EESR_TINT3 | EESR_TINT2 | EESR_TINT1)) {
595 689
690 /* Tx Check */
691 if (intr_status & TX_CHECK) {
596 sh_eth_txfree(ndev); 692 sh_eth_txfree(ndev);
597 netif_wake_queue(ndev); 693 netif_wake_queue(ndev);
598 } 694 }
@@ -631,11 +727,32 @@ static void sh_eth_adjust_link(struct net_device *ndev)
631 if (phydev->duplex != mdp->duplex) { 727 if (phydev->duplex != mdp->duplex) {
632 new_state = 1; 728 new_state = 1;
633 mdp->duplex = phydev->duplex; 729 mdp->duplex = phydev->duplex;
730#if defined(CONFIG_CPU_SUBTYPE_SH7763)
731 if (mdp->duplex) { /* FULL */
732 ctrl_outl(ctrl_inl(ioaddr + ECMR) | ECMR_DM,
733 ioaddr + ECMR);
734 } else { /* Half */
735 ctrl_outl(ctrl_inl(ioaddr + ECMR) & ~ECMR_DM,
736 ioaddr + ECMR);
737 }
738#endif
634 } 739 }
635 740
636 if (phydev->speed != mdp->speed) { 741 if (phydev->speed != mdp->speed) {
637 new_state = 1; 742 new_state = 1;
638 mdp->speed = phydev->speed; 743 mdp->speed = phydev->speed;
744#if defined(CONFIG_CPU_SUBTYPE_SH7763)
745 switch (mdp->speed) {
746 case 10: /* 10BASE */
747 ctrl_outl(GECMR_10, ioaddr + GECMR); break;
748 case 100:/* 100BASE */
749 ctrl_outl(GECMR_100, ioaddr + GECMR); break;
750 case 1000: /* 1000BASE */
751 ctrl_outl(GECMR_1000, ioaddr + GECMR); break;
752 default:
753 break;
754 }
755#endif
639 } 756 }
640 if (mdp->link == PHY_DOWN) { 757 if (mdp->link == PHY_DOWN) {
641 ctrl_outl((ctrl_inl(ioaddr + ECMR) & ~ECMR_TXF) 758 ctrl_outl((ctrl_inl(ioaddr + ECMR) & ~ECMR_TXF)
@@ -730,7 +847,7 @@ static int sh_eth_open(struct net_device *ndev)
730 /* Set the timer to check for link beat. */ 847 /* Set the timer to check for link beat. */
731 init_timer(&mdp->timer); 848 init_timer(&mdp->timer);
732 mdp->timer.expires = (jiffies + (24 * HZ)) / 10;/* 2.4 sec. */ 849 mdp->timer.expires = (jiffies + (24 * HZ)) / 10;/* 2.4 sec. */
733 setup_timer(&mdp->timer, sh_eth_timer, ndev); 850 setup_timer(&mdp->timer, sh_eth_timer, (unsigned long)ndev);
734 851
735 return ret; 852 return ret;
736 853
@@ -820,7 +937,9 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
820 937
821 mdp->cur_tx++; 938 mdp->cur_tx++;
822 939
823 ctrl_outl(EDTRR_TRNS, ndev->base_addr + EDTRR); 940 if (!(ctrl_inl(ndev->base_addr + EDTRR) & EDTRR_TRNS))
941 ctrl_outl(EDTRR_TRNS, ndev->base_addr + EDTRR);
942
824 ndev->trans_start = jiffies; 943 ndev->trans_start = jiffies;
825 944
826 return 0; 945 return 0;
@@ -877,9 +996,15 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
877 ctrl_outl(0, ioaddr + CDCR); /* (write clear) */ 996 ctrl_outl(0, ioaddr + CDCR); /* (write clear) */
878 mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + LCCR); 997 mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + LCCR);
879 ctrl_outl(0, ioaddr + LCCR); /* (write clear) */ 998 ctrl_outl(0, ioaddr + LCCR); /* (write clear) */
999#if defined(CONFIG_CPU_SUBTYPE_SH7763)
1000 mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + CERCR);/* CERCR */
1001 ctrl_outl(0, ioaddr + CERCR); /* (write clear) */
1002 mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + CEECR);/* CEECR */
1003 ctrl_outl(0, ioaddr + CEECR); /* (write clear) */
1004#else
880 mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + CNDCR); 1005 mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + CNDCR);
881 ctrl_outl(0, ioaddr + CNDCR); /* (write clear) */ 1006 ctrl_outl(0, ioaddr + CNDCR); /* (write clear) */
882 1007#endif
883 return &mdp->stats; 1008 return &mdp->stats;
884} 1009}
885 1010
@@ -929,8 +1054,13 @@ static void sh_eth_tsu_init(u32 ioaddr)
929 ctrl_outl(0, ioaddr + TSU_FWSL0); 1054 ctrl_outl(0, ioaddr + TSU_FWSL0);
930 ctrl_outl(0, ioaddr + TSU_FWSL1); 1055 ctrl_outl(0, ioaddr + TSU_FWSL1);
931 ctrl_outl(TSU_FWSLC_POSTENU | TSU_FWSLC_POSTENL, ioaddr + TSU_FWSLC); 1056 ctrl_outl(TSU_FWSLC_POSTENU | TSU_FWSLC_POSTENL, ioaddr + TSU_FWSLC);
1057#if defined(CONFIG_CPU_SUBTYPE_SH7763)
1058 ctrl_outl(0, ioaddr + TSU_QTAG0); /* Disable QTAG(0->1) */
1059 ctrl_outl(0, ioaddr + TSU_QTAG1); /* Disable QTAG(1->0) */
1060#else
932 ctrl_outl(0, ioaddr + TSU_QTAGM0); /* Disable QTAG(0->1) */ 1061 ctrl_outl(0, ioaddr + TSU_QTAGM0); /* Disable QTAG(0->1) */
933 ctrl_outl(0, ioaddr + TSU_QTAGM1); /* Disable QTAG(1->0) */ 1062 ctrl_outl(0, ioaddr + TSU_QTAGM1); /* Disable QTAG(1->0) */
1063#endif
934 ctrl_outl(0, ioaddr + TSU_FWSR); /* all interrupt status clear */ 1064 ctrl_outl(0, ioaddr + TSU_FWSR); /* all interrupt status clear */
935 ctrl_outl(0, ioaddr + TSU_FWINMK); /* Disable all interrupt */ 1065 ctrl_outl(0, ioaddr + TSU_FWINMK); /* Disable all interrupt */
936 ctrl_outl(0, ioaddr + TSU_TEN); /* Disable all CAM entry */ 1066 ctrl_outl(0, ioaddr + TSU_TEN); /* Disable all CAM entry */
@@ -1088,7 +1218,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
1088 /* First device only init */ 1218 /* First device only init */
1089 if (!devno) { 1219 if (!devno) {
1090 /* reset device */ 1220 /* reset device */
1091 ctrl_outl(ARSTR_ARSTR, ndev->base_addr + ARSTR); 1221 ctrl_outl(ARSTR_ARSTR, ARSTR);
1092 mdelay(1); 1222 mdelay(1);
1093 1223
1094 /* TSU init (Init only)*/ 1224 /* TSU init (Init only)*/
@@ -1110,8 +1240,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
1110 ndev->name, CARDNAME, (u32) ndev->base_addr); 1240 ndev->name, CARDNAME, (u32) ndev->base_addr);
1111 1241
1112 for (i = 0; i < 5; i++) 1242 for (i = 0; i < 5; i++)
1113 printk(KERN_INFO "%2.2x:", ndev->dev_addr[i]); 1243 printk(KERN_INFO "%02X:", ndev->dev_addr[i]);
1114 printk(KERN_INFO "%2.2x, IRQ %d.\n", ndev->dev_addr[i], ndev->irq); 1244 printk(KERN_INFO "%02X, IRQ %d.\n", ndev->dev_addr[i], ndev->irq);
1115 1245
1116 platform_set_drvdata(pdev, ndev); 1246 platform_set_drvdata(pdev, ndev);
1117 1247
diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
index e01e1c347715..45ad1b09ca5a 100644
--- a/drivers/net/sh_eth.h
+++ b/drivers/net/sh_eth.h
@@ -32,118 +32,249 @@
32 32
33#define CARDNAME "sh-eth" 33#define CARDNAME "sh-eth"
34#define TX_TIMEOUT (5*HZ) 34#define TX_TIMEOUT (5*HZ)
35 35#define TX_RING_SIZE 64 /* Tx ring size */
36#define TX_RING_SIZE 128 /* Tx ring size */ 36#define RX_RING_SIZE 64 /* Rx ring size */
37#define RX_RING_SIZE 128 /* Rx ring size */
38#define RX_OFFSET 2 /* skb offset */
39#define ETHERSMALL 60 37#define ETHERSMALL 60
40#define PKT_BUF_SZ 1538 38#define PKT_BUF_SZ 1538
41 39
40#ifdef CONFIG_CPU_SUBTYPE_SH7763
41
42#define SH7763_SKB_ALIGN 32
42/* Chip Base Address */ 43/* Chip Base Address */
43#define SH_TSU_ADDR 0xA7000804 44# define SH_TSU_ADDR 0xFFE01800
45# define ARSTR 0xFFE01800
46
47/* Chip Registers */
48/* E-DMAC */
49# define EDSR 0x000
50# define EDMR 0x400
51# define EDTRR 0x408
52# define EDRRR 0x410
53# define EESR 0x428
54# define EESIPR 0x430
55# define TDLAR 0x010
56# define TDFAR 0x014
57# define TDFXR 0x018
58# define TDFFR 0x01C
59# define RDLAR 0x030
60# define RDFAR 0x034
61# define RDFXR 0x038
62# define RDFFR 0x03C
63# define TRSCER 0x438
64# define RMFCR 0x440
65# define TFTR 0x448
66# define FDR 0x450
67# define RMCR 0x458
68# define RPADIR 0x460
69# define FCFTR 0x468
70
71/* Ether Register */
72# define ECMR 0x500
73# define ECSR 0x510
74# define ECSIPR 0x518
75# define PIR 0x520
76# define PSR 0x528
77# define PIPR 0x52C
78# define RFLR 0x508
79# define APR 0x554
80# define MPR 0x558
81# define PFTCR 0x55C
82# define PFRCR 0x560
83# define TPAUSER 0x564
84# define GECMR 0x5B0
85# define BCULR 0x5B4
86# define MAHR 0x5C0
87# define MALR 0x5C8
88# define TROCR 0x700
89# define CDCR 0x708
90# define LCCR 0x710
91# define CEFCR 0x740
92# define FRECR 0x748
93# define TSFRCR 0x750
94# define TLFRCR 0x758
95# define RFCR 0x760
96# define CERCR 0x768
97# define CEECR 0x770
98# define MAFCR 0x778
99
100/* TSU Absolute Address */
101# define TSU_CTRST 0x004
102# define TSU_FWEN0 0x010
103# define TSU_FWEN1 0x014
104# define TSU_FCM 0x18
105# define TSU_BSYSL0 0x20
106# define TSU_BSYSL1 0x24
107# define TSU_PRISL0 0x28
108# define TSU_PRISL1 0x2C
109# define TSU_FWSL0 0x30
110# define TSU_FWSL1 0x34
111# define TSU_FWSLC 0x38
112# define TSU_QTAG0 0x40
113# define TSU_QTAG1 0x44
114# define TSU_FWSR 0x50
115# define TSU_FWINMK 0x54
116# define TSU_ADQT0 0x48
117# define TSU_ADQT1 0x4C
118# define TSU_VTAG0 0x58
119# define TSU_VTAG1 0x5C
120# define TSU_ADSBSY 0x60
121# define TSU_TEN 0x64
122# define TSU_POST1 0x70
123# define TSU_POST2 0x74
124# define TSU_POST3 0x78
125# define TSU_POST4 0x7C
126# define TSU_ADRH0 0x100
127# define TSU_ADRL0 0x104
128# define TSU_ADRH31 0x1F8
129# define TSU_ADRL31 0x1FC
130
131# define TXNLCR0 0x80
132# define TXALCR0 0x84
133# define RXNLCR0 0x88
134# define RXALCR0 0x8C
135# define FWNLCR0 0x90
136# define FWALCR0 0x94
137# define TXNLCR1 0xA0
138# define TXALCR1 0xA4
139# define RXNLCR1 0xA8
140# define RXALCR1 0xAC
141# define FWNLCR1 0xB0
142# define FWALCR1 0x40
143
144#else /* CONFIG_CPU_SUBTYPE_SH7763 */
145# define RX_OFFSET 2 /* skb offset */
146/* Chip base address */
147# define SH_TSU_ADDR 0xA7000804
148# define ARSTR 0xA7000800
44 149
45/* Chip Registers */ 150/* Chip Registers */
46/* E-DMAC */ 151/* E-DMAC */
47#define EDMR 0x0000 152# define EDMR 0x0000
48#define EDTRR 0x0004 153# define EDTRR 0x0004
49#define EDRRR 0x0008 154# define EDRRR 0x0008
50#define TDLAR 0x000C 155# define TDLAR 0x000C
51#define RDLAR 0x0010 156# define RDLAR 0x0010
52#define EESR 0x0014 157# define EESR 0x0014
53#define EESIPR 0x0018 158# define EESIPR 0x0018
54#define TRSCER 0x001C 159# define TRSCER 0x001C
55#define RMFCR 0x0020 160# define RMFCR 0x0020
56#define TFTR 0x0024 161# define TFTR 0x0024
57#define FDR 0x0028 162# define FDR 0x0028
58#define RMCR 0x002C 163# define RMCR 0x002C
59#define EDOCR 0x0030 164# define EDOCR 0x0030
60#define FCFTR 0x0034 165# define FCFTR 0x0034
61#define RPADIR 0x0038 166# define RPADIR 0x0038
62#define TRIMD 0x003C 167# define TRIMD 0x003C
63#define RBWAR 0x0040 168# define RBWAR 0x0040
64#define RDFAR 0x0044 169# define RDFAR 0x0044
65#define TBRAR 0x004C 170# define TBRAR 0x004C
66#define TDFAR 0x0050 171# define TDFAR 0x0050
172
67/* Ether Register */ 173/* Ether Register */
68#define ECMR 0x0160 174# define ECMR 0x0160
69#define ECSR 0x0164 175# define ECSR 0x0164
70#define ECSIPR 0x0168 176# define ECSIPR 0x0168
71#define PIR 0x016C 177# define PIR 0x016C
72#define MAHR 0x0170 178# define MAHR 0x0170
73#define MALR 0x0174 179# define MALR 0x0174
74#define RFLR 0x0178 180# define RFLR 0x0178
75#define PSR 0x017C 181# define PSR 0x017C
76#define TROCR 0x0180 182# define TROCR 0x0180
77#define CDCR 0x0184 183# define CDCR 0x0184
78#define LCCR 0x0188 184# define LCCR 0x0188
79#define CNDCR 0x018C 185# define CNDCR 0x018C
80#define CEFCR 0x0194 186# define CEFCR 0x0194
81#define FRECR 0x0198 187# define FRECR 0x0198
82#define TSFRCR 0x019C 188# define TSFRCR 0x019C
83#define TLFRCR 0x01A0 189# define TLFRCR 0x01A0
84#define RFCR 0x01A4 190# define RFCR 0x01A4
85#define MAFCR 0x01A8 191# define MAFCR 0x01A8
86#define IPGR 0x01B4 192# define IPGR 0x01B4
87#if defined(CONFIG_CPU_SUBTYPE_SH7710) 193# if defined(CONFIG_CPU_SUBTYPE_SH7710)
88#define APR 0x01B8 194# define APR 0x01B8
89#define MPR 0x01BC 195# define MPR 0x01BC
90#define TPAUSER 0x1C4 196# define TPAUSER 0x1C4
91#define BCFR 0x1CC 197# define BCFR 0x1CC
92#endif /* CONFIG_CPU_SH7710 */ 198# endif /* CONFIG_CPU_SH7710 */
93
94#define ARSTR 0x0800
95 199
96/* TSU */ 200/* TSU */
97#define TSU_CTRST 0x004 201# define TSU_CTRST 0x004
98#define TSU_FWEN0 0x010 202# define TSU_FWEN0 0x010
99#define TSU_FWEN1 0x014 203# define TSU_FWEN1 0x014
100#define TSU_FCM 0x018 204# define TSU_FCM 0x018
101#define TSU_BSYSL0 0x020 205# define TSU_BSYSL0 0x020
102#define TSU_BSYSL1 0x024 206# define TSU_BSYSL1 0x024
103#define TSU_PRISL0 0x028 207# define TSU_PRISL0 0x028
104#define TSU_PRISL1 0x02C 208# define TSU_PRISL1 0x02C
105#define TSU_FWSL0 0x030 209# define TSU_FWSL0 0x030
106#define TSU_FWSL1 0x034 210# define TSU_FWSL1 0x034
107#define TSU_FWSLC 0x038 211# define TSU_FWSLC 0x038
108#define TSU_QTAGM0 0x040 212# define TSU_QTAGM0 0x040
109#define TSU_QTAGM1 0x044 213# define TSU_QTAGM1 0x044
110#define TSU_ADQT0 0x048 214# define TSU_ADQT0 0x048
111#define TSU_ADQT1 0x04C 215# define TSU_ADQT1 0x04C
112#define TSU_FWSR 0x050 216# define TSU_FWSR 0x050
113#define TSU_FWINMK 0x054 217# define TSU_FWINMK 0x054
114#define TSU_ADSBSY 0x060 218# define TSU_ADSBSY 0x060
115#define TSU_TEN 0x064 219# define TSU_TEN 0x064
116#define TSU_POST1 0x070 220# define TSU_POST1 0x070
117#define TSU_POST2 0x074 221# define TSU_POST2 0x074
118#define TSU_POST3 0x078 222# define TSU_POST3 0x078
119#define TSU_POST4 0x07C 223# define TSU_POST4 0x07C
120#define TXNLCR0 0x080 224# define TXNLCR0 0x080
121#define TXALCR0 0x084 225# define TXALCR0 0x084
122#define RXNLCR0 0x088 226# define RXNLCR0 0x088
123#define RXALCR0 0x08C 227# define RXALCR0 0x08C
124#define FWNLCR0 0x090 228# define FWNLCR0 0x090
125#define FWALCR0 0x094 229# define FWALCR0 0x094
126#define TXNLCR1 0x0A0 230# define TXNLCR1 0x0A0
127#define TXALCR1 0x0A4 231# define TXALCR1 0x0A4
128#define RXNLCR1 0x0A8 232# define RXNLCR1 0x0A8
129#define RXALCR1 0x0AC 233# define RXALCR1 0x0AC
130#define FWNLCR1 0x0B0 234# define FWNLCR1 0x0B0
131#define FWALCR1 0x0B4 235# define FWALCR1 0x0B4
132 236
133#define TSU_ADRH0 0x0100 237#define TSU_ADRH0 0x0100
134#define TSU_ADRL0 0x0104 238#define TSU_ADRL0 0x0104
135#define TSU_ADRL31 0x01FC 239#define TSU_ADRL31 0x01FC
136 240
137/* Register's bits */ 241#endif /* CONFIG_CPU_SUBTYPE_SH7763 */
242
243/*
244 * Register's bits
245 */
246#ifdef CONFIG_CPU_SUBTYPE_SH7763
247/* EDSR */
248enum EDSR_BIT {
249 EDSR_ENT = 0x01, EDSR_ENR = 0x02,
250};
251#define EDSR_ENALL (EDSR_ENT|EDSR_ENR)
252
253/* GECMR */
254enum GECMR_BIT {
255 GECMR_10 = 0x0, GECMR_100 = 0x04, GECMR_1000 = 0x01,
256};
257#endif
138 258
139/* EDMR */ 259/* EDMR */
140enum DMAC_M_BIT { 260enum DMAC_M_BIT {
141 EDMR_DL1 = 0x20, EDMR_DL0 = 0x10, EDMR_SRST = 0x01, 261 EDMR_DL1 = 0x20, EDMR_DL0 = 0x10,
262#ifdef CONFIG_CPU_SUBTYPE_SH7763
263 EDMR_SRST = 0x03,
264 EMDR_DESC_R = 0x30, /* Descriptor reserve size */
265 EDMR_EL = 0x40, /* Litte endian */
266#else /* CONFIG_CPU_SUBTYPE_SH7763 */
267 EDMR_SRST = 0x01,
268#endif
142}; 269};
143 270
144/* EDTRR */ 271/* EDTRR */
145enum DMAC_T_BIT { 272enum DMAC_T_BIT {
273#ifdef CONFIG_CPU_SUBTYPE_SH7763
274 EDTRR_TRNS = 0x03,
275#else
146 EDTRR_TRNS = 0x01, 276 EDTRR_TRNS = 0x01,
277#endif
147}; 278};
148 279
149/* EDRRR*/ 280/* EDRRR*/
@@ -173,21 +304,47 @@ enum PHY_STATUS_BIT { PHY_ST_LINK = 0x01, };
173 304
174/* EESR */ 305/* EESR */
175enum EESR_BIT { 306enum EESR_BIT {
176 EESR_TWB = 0x40000000, EESR_TABT = 0x04000000, 307#ifndef CONFIG_CPU_SUBTYPE_SH7763
308 EESR_TWB = 0x40000000,
309#else
310 EESR_TWB = 0xC0000000,
311 EESR_TC1 = 0x20000000,
312 EESR_TUC = 0x10000000,
313 EESR_ROC = 0x80000000,
314#endif
315 EESR_TABT = 0x04000000,
177 EESR_RABT = 0x02000000, EESR_RFRMER = 0x01000000, 316 EESR_RABT = 0x02000000, EESR_RFRMER = 0x01000000,
178 EESR_ADE = 0x00800000, EESR_ECI = 0x00400000, 317#ifndef CONFIG_CPU_SUBTYPE_SH7763
179 EESR_FTC = 0x00200000, EESR_TDE = 0x00100000, 318 EESR_ADE = 0x00800000,
180 EESR_TFE = 0x00080000, EESR_FRC = 0x00040000, 319#endif
181 EESR_RDE = 0x00020000, EESR_RFE = 0x00010000, 320 EESR_ECI = 0x00400000,
182 EESR_TINT4 = 0x00000800, EESR_TINT3 = 0x00000400, 321 EESR_FTC = 0x00200000, EESR_TDE = 0x00100000,
183 EESR_TINT2 = 0x00000200, EESR_TINT1 = 0x00000100, 322 EESR_TFE = 0x00080000, EESR_FRC = 0x00040000,
184 EESR_RINT8 = 0x00000080, EESR_RINT5 = 0x00000010, 323 EESR_RDE = 0x00020000, EESR_RFE = 0x00010000,
185 EESR_RINT4 = 0x00000008, EESR_RINT3 = 0x00000004, 324#ifndef CONFIG_CPU_SUBTYPE_SH7763
186 EESR_RINT2 = 0x00000002, EESR_RINT1 = 0x00000001, 325 EESR_CND = 0x00000800,
187}; 326#endif
188 327 EESR_DLC = 0x00000400,
189#define EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE \ 328 EESR_CD = 0x00000200, EESR_RTO = 0x00000100,
329 EESR_RMAF = 0x00000080, EESR_CEEF = 0x00000040,
330 EESR_CELF = 0x00000020, EESR_RRF = 0x00000010,
331 EESR_RTLF = 0x00000008, EESR_RTSF = 0x00000004,
332 EESR_PRE = 0x00000002, EESR_CERF = 0x00000001,
333};
334
335
336#ifdef CONFIG_CPU_SUBTYPE_SH7763
337# define TX_CHECK (EESR_TC1 | EESR_FTC)
338# define EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE \
339 | EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI)
340# define TX_ERROR_CEHCK (EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE)
341
342#else
343# define TX_CHECK (EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO)
344# define EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE \
190 | EESR_RFRMER | EESR_ADE | EESR_TFE | EESR_TDE | EESR_ECI) 345 | EESR_RFRMER | EESR_ADE | EESR_TFE | EESR_TDE | EESR_ECI)
346# define TX_ERROR_CEHCK (EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | EESR_TFE)
347#endif
191 348
192/* EESIPR */ 349/* EESIPR */
193enum DMAC_IM_BIT { 350enum DMAC_IM_BIT {
@@ -207,8 +364,8 @@ enum DMAC_IM_BIT {
207 364
208/* Receive descriptor bit */ 365/* Receive descriptor bit */
209enum RD_STS_BIT { 366enum RD_STS_BIT {
210 RD_RACT = 0x80000000, RC_RDEL = 0x40000000, 367 RD_RACT = 0x80000000, RD_RDEL = 0x40000000,
211 RC_RFP1 = 0x20000000, RC_RFP0 = 0x10000000, 368 RD_RFP1 = 0x20000000, RD_RFP0 = 0x10000000,
212 RD_RFE = 0x08000000, RD_RFS10 = 0x00000200, 369 RD_RFE = 0x08000000, RD_RFS10 = 0x00000200,
213 RD_RFS9 = 0x00000100, RD_RFS8 = 0x00000080, 370 RD_RFS9 = 0x00000100, RD_RFS8 = 0x00000080,
214 RD_RFS7 = 0x00000040, RD_RFS6 = 0x00000020, 371 RD_RFS7 = 0x00000040, RD_RFS6 = 0x00000020,
@@ -216,9 +373,9 @@ enum RD_STS_BIT {
216 RD_RFS3 = 0x00000004, RD_RFS2 = 0x00000002, 373 RD_RFS3 = 0x00000004, RD_RFS2 = 0x00000002,
217 RD_RFS1 = 0x00000001, 374 RD_RFS1 = 0x00000001,
218}; 375};
219#define RDF1ST RC_RFP1 376#define RDF1ST RD_RFP1
220#define RDFEND RC_RFP0 377#define RDFEND RD_RFP0
221#define RD_RFP (RC_RFP1|RC_RFP0) 378#define RD_RFP (RD_RFP1|RD_RFP0)
222 379
223/* FCFTR */ 380/* FCFTR */
224enum FCFTR_BIT { 381enum FCFTR_BIT {
@@ -231,7 +388,8 @@ enum FCFTR_BIT {
231 388
232/* Transfer descriptor bit */ 389/* Transfer descriptor bit */
233enum TD_STS_BIT { 390enum TD_STS_BIT {
234 TD_TACT = 0x80000000, TD_TDLE = 0x40000000, TD_TFP1 = 0x20000000, 391 TD_TACT = 0x80000000,
392 TD_TDLE = 0x40000000, TD_TFP1 = 0x20000000,
235 TD_TFP0 = 0x10000000, 393 TD_TFP0 = 0x10000000,
236}; 394};
237#define TDF1ST TD_TFP1 395#define TDF1ST TD_TFP1
@@ -242,6 +400,10 @@ enum TD_STS_BIT {
242enum RECV_RST_BIT { RMCR_RST = 0x01, }; 400enum RECV_RST_BIT { RMCR_RST = 0x01, };
243/* ECMR */ 401/* ECMR */
244enum FELIC_MODE_BIT { 402enum FELIC_MODE_BIT {
403#ifdef CONFIG_CPU_SUBTYPE_SH7763
404 ECMR_TRCCM = 0x04000000, ECMR_RCSC = 0x00800000,
405 ECMR_DPAD = 0x00200000, ECMR_RZPF = 0x00100000,
406#endif
245 ECMR_ZPF = 0x00080000, ECMR_PFR = 0x00040000, ECMR_RXF = 0x00020000, 407 ECMR_ZPF = 0x00080000, ECMR_PFR = 0x00040000, ECMR_RXF = 0x00020000,
246 ECMR_TXF = 0x00010000, ECMR_MCT = 0x00002000, ECMR_PRCEF = 0x00001000, 408 ECMR_TXF = 0x00010000, ECMR_MCT = 0x00002000, ECMR_PRCEF = 0x00001000,
247 ECMR_PMDE = 0x00000200, ECMR_RE = 0x00000040, ECMR_TE = 0x00000020, 409 ECMR_PMDE = 0x00000200, ECMR_RE = 0x00000040, ECMR_TE = 0x00000020,
@@ -249,18 +411,45 @@ enum FELIC_MODE_BIT {
249 ECMR_PRM = 0x00000001, 411 ECMR_PRM = 0x00000001,
250}; 412};
251 413
414#ifdef CONFIG_CPU_SUBTYPE_SH7763
415#define ECMR_CHG_DM (ECMR_TRCCM | ECMR_RZPF | ECMR_ZPF |\
416 ECMR_PFR | ECMR_RXF | ECMR_TXF | ECMR_MCT)
417#else
418#define ECMR_CHG_DM (ECMR_ZPF | ECMR_PFR ECMR_RXF | ECMR_TXF | ECMR_MCT)
419#endif
420
252/* ECSR */ 421/* ECSR */
253enum ECSR_STATUS_BIT { 422enum ECSR_STATUS_BIT {
254 ECSR_BRCRX = 0x20, ECSR_PSRTO = 0x10, ECSR_LCHNG = 0x04, 423#ifndef CONFIG_CPU_SUBTYPE_SH7763
424 ECSR_BRCRX = 0x20, ECSR_PSRTO = 0x10,
425#endif
426 ECSR_LCHNG = 0x04,
255 ECSR_MPD = 0x02, ECSR_ICD = 0x01, 427 ECSR_MPD = 0x02, ECSR_ICD = 0x01,
256}; 428};
257 429
430#ifdef CONFIG_CPU_SUBTYPE_SH7763
431# define ECSR_INIT (ECSR_ICD | ECSIPR_MPDIP)
432#else
433# define ECSR_INIT (ECSR_BRCRX | ECSR_PSRTO | \
434 ECSR_LCHNG | ECSR_ICD | ECSIPR_MPDIP)
435#endif
436
258/* ECSIPR */ 437/* ECSIPR */
259enum ECSIPR_STATUS_MASK_BIT { 438enum ECSIPR_STATUS_MASK_BIT {
260 ECSIPR_BRCRXIP = 0x20, ECSIPR_PSRTOIP = 0x10, ECSIPR_LCHNGIP = 0x04, 439#ifndef CONFIG_CPU_SUBTYPE_SH7763
440 ECSIPR_BRCRXIP = 0x20, ECSIPR_PSRTOIP = 0x10,
441#endif
442 ECSIPR_LCHNGIP = 0x04,
261 ECSIPR_MPDIP = 0x02, ECSIPR_ICDIP = 0x01, 443 ECSIPR_MPDIP = 0x02, ECSIPR_ICDIP = 0x01,
262}; 444};
263 445
446#ifdef CONFIG_CPU_SUBTYPE_SH7763
447# define ECSIPR_INIT (ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP)
448#else
449# define ECSIPR_INIT (ECSIPR_BRCRXIP | ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | \
450 ECSIPR_ICDIP | ECSIPR_MPDIP)
451#endif
452
264/* APR */ 453/* APR */
265enum APR_BIT { 454enum APR_BIT {
266 APR_AP = 0x00000001, 455 APR_AP = 0x00000001,
@@ -285,6 +474,15 @@ enum RPADIR_BIT {
285 RPADIR_PADR = 0x0003f, 474 RPADIR_PADR = 0x0003f,
286}; 475};
287 476
477#if defined(CONFIG_CPU_SUBTYPE_SH7763)
478# define RPADIR_INIT (0x00)
479#else
480# define RPADIR_INIT (RPADIR_PADS1)
481#endif
482
483/* RFLR */
484#define RFLR_VALUE 0x1000
485
288/* FDR */ 486/* FDR */
289enum FIFO_SIZE_BIT { 487enum FIFO_SIZE_BIT {
290 FIFO_SIZE_T = 0x00000700, FIFO_SIZE_R = 0x00000007, 488 FIFO_SIZE_T = 0x00000700, FIFO_SIZE_R = 0x00000007,
@@ -316,7 +514,7 @@ enum PHY_ANA_BIT {
316 PHY_A_NP = 0x8000, PHY_A_ACK = 0x4000, PHY_A_RF = 0x2000, 514 PHY_A_NP = 0x8000, PHY_A_ACK = 0x4000, PHY_A_RF = 0x2000,
317 PHY_A_FCS = 0x0400, PHY_A_T4 = 0x0200, PHY_A_FDX = 0x0100, 515 PHY_A_FCS = 0x0400, PHY_A_T4 = 0x0200, PHY_A_FDX = 0x0100,
318 PHY_A_HDX = 0x0080, PHY_A_10FDX = 0x0040, PHY_A_10HDX = 0x0020, 516 PHY_A_HDX = 0x0080, PHY_A_10FDX = 0x0040, PHY_A_10HDX = 0x0020,
319 PHY_A_SEL = 0x001f, 517 PHY_A_SEL = 0x001e,
320}; 518};
321/* PHY_ANL */ 519/* PHY_ANL */
322enum PHY_ANL_BIT { 520enum PHY_ANL_BIT {
@@ -449,6 +647,10 @@ struct sh_eth_private {
449 struct net_device_stats tsu_stats; /* TSU forward status */ 647 struct net_device_stats tsu_stats; /* TSU forward status */
450}; 648};
451 649
650#ifdef CONFIG_CPU_SUBTYPE_SH7763
651/* SH7763 has endian control register */
652#define swaps(x, y)
653#else
452static void swaps(char *src, int len) 654static void swaps(char *src, int len)
453{ 655{
454#ifdef __LITTLE_ENDIAN__ 656#ifdef __LITTLE_ENDIAN__
@@ -460,5 +662,5 @@ static void swaps(char *src, int len)
460 *p = swab32(*p); 662 *p = swab32(*p);
461#endif 663#endif
462} 664}
463 665#endif /* CONFIG_CPU_SUBTYPE_SH7763 */
464#endif 666#endif
diff --git a/drivers/net/skfp/smt.c b/drivers/net/skfp/smt.c
index ffbfb1b79f97..805383b33d3c 100644
--- a/drivers/net/skfp/smt.c
+++ b/drivers/net/skfp/smt.c
@@ -19,6 +19,7 @@
19#include "h/smc.h" 19#include "h/smc.h"
20#include "h/smt_p.h" 20#include "h/smt_p.h"
21#include <linux/bitrev.h> 21#include <linux/bitrev.h>
22#include <linux/kernel.h>
22 23
23#define KERNEL 24#define KERNEL
24#include "h/smtstate.h" 25#include "h/smtstate.h"
@@ -1730,20 +1731,18 @@ void fddi_send_antc(struct s_smc *smc, struct fddi_addr *dest)
1730#endif 1731#endif
1731 1732
1732#ifdef DEBUG 1733#ifdef DEBUG
1733#define hextoasc(x) "0123456789abcdef"[x]
1734
1735char *addr_to_string(struct fddi_addr *addr) 1734char *addr_to_string(struct fddi_addr *addr)
1736{ 1735{
1737 int i ; 1736 int i ;
1738 static char string[6*3] = "****" ; 1737 static char string[6*3] = "****" ;
1739 1738
1740 for (i = 0 ; i < 6 ; i++) { 1739 for (i = 0 ; i < 6 ; i++) {
1741 string[i*3] = hextoasc((addr->a[i]>>4)&0xf) ; 1740 string[i * 3] = hex_asc_hi(addr->a[i]);
1742 string[i*3+1] = hextoasc((addr->a[i])&0xf) ; 1741 string[i * 3 + 1] = hex_asc_lo(addr->a[i]);
1743 string[i*3+2] = ':' ; 1742 string[i * 3 + 2] = ':';
1744 } 1743 }
1745 string[5*3+2] = 0 ; 1744 string[5 * 3 + 2] = 0;
1746 return(string) ; 1745 return(string);
1747} 1746}
1748#endif 1747#endif
1749 1748
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 633c128a6228..26aa37aa531f 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -1982,8 +1982,6 @@ static void tg3_power_down_phy(struct tg3 *tp)
1982static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) 1982static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1983{ 1983{
1984 u32 misc_host_ctrl; 1984 u32 misc_host_ctrl;
1985 u16 power_control, power_caps;
1986 int pm = tp->pm_cap;
1987 1985
1988 /* Make sure register accesses (indirect or otherwise) 1986 /* Make sure register accesses (indirect or otherwise)
1989 * will function correctly. 1987 * will function correctly.
@@ -1992,18 +1990,10 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1992 TG3PCI_MISC_HOST_CTRL, 1990 TG3PCI_MISC_HOST_CTRL,
1993 tp->misc_host_ctrl); 1991 tp->misc_host_ctrl);
1994 1992
1995 pci_read_config_word(tp->pdev,
1996 pm + PCI_PM_CTRL,
1997 &power_control);
1998 power_control |= PCI_PM_CTRL_PME_STATUS;
1999 power_control &= ~(PCI_PM_CTRL_STATE_MASK);
2000 switch (state) { 1993 switch (state) {
2001 case PCI_D0: 1994 case PCI_D0:
2002 power_control |= 0; 1995 pci_enable_wake(tp->pdev, state, false);
2003 pci_write_config_word(tp->pdev, 1996 pci_set_power_state(tp->pdev, PCI_D0);
2004 pm + PCI_PM_CTRL,
2005 power_control);
2006 udelay(100); /* Delay after power state change */
2007 1997
2008 /* Switch out of Vaux if it is a NIC */ 1998 /* Switch out of Vaux if it is a NIC */
2009 if (tp->tg3_flags2 & TG3_FLG2_IS_NIC) 1999 if (tp->tg3_flags2 & TG3_FLG2_IS_NIC)
@@ -2012,26 +2002,15 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2012 return 0; 2002 return 0;
2013 2003
2014 case PCI_D1: 2004 case PCI_D1:
2015 power_control |= 1;
2016 break;
2017
2018 case PCI_D2: 2005 case PCI_D2:
2019 power_control |= 2;
2020 break;
2021
2022 case PCI_D3hot: 2006 case PCI_D3hot:
2023 power_control |= 3;
2024 break; 2007 break;
2025 2008
2026 default: 2009 default:
2027 printk(KERN_WARNING PFX "%s: Invalid power state (%d) " 2010 printk(KERN_ERR PFX "%s: Invalid power state (D%d) requested\n",
2028 "requested.\n", 2011 tp->dev->name, state);
2029 tp->dev->name, state);
2030 return -EINVAL; 2012 return -EINVAL;
2031 } 2013 }
2032
2033 power_control |= PCI_PM_CTRL_PME_ENABLE;
2034
2035 misc_host_ctrl = tr32(TG3PCI_MISC_HOST_CTRL); 2014 misc_host_ctrl = tr32(TG3PCI_MISC_HOST_CTRL);
2036 tw32(TG3PCI_MISC_HOST_CTRL, 2015 tw32(TG3PCI_MISC_HOST_CTRL,
2037 misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT); 2016 misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT);
@@ -2109,8 +2088,6 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2109 WOL_DRV_WOL | 2088 WOL_DRV_WOL |
2110 WOL_SET_MAGIC_PKT); 2089 WOL_SET_MAGIC_PKT);
2111 2090
2112 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps);
2113
2114 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) { 2091 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) {
2115 u32 mac_mode; 2092 u32 mac_mode;
2116 2093
@@ -2143,8 +2120,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2143 if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) 2120 if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
2144 tw32(MAC_LED_CTRL, tp->led_ctrl); 2121 tw32(MAC_LED_CTRL, tp->led_ctrl);
2145 2122
2146 if (((power_caps & PCI_PM_CAP_PME_D3cold) && 2123 if (pci_pme_capable(tp->pdev, state) &&
2147 (tp->tg3_flags & TG3_FLAG_WOL_ENABLE))) 2124 (tp->tg3_flags & TG3_FLAG_WOL_ENABLE))
2148 mac_mode |= MAC_MODE_MAGIC_PKT_ENABLE; 2125 mac_mode |= MAC_MODE_MAGIC_PKT_ENABLE;
2149 2126
2150 tw32_f(MAC_MODE, mac_mode); 2127 tw32_f(MAC_MODE, mac_mode);
@@ -2236,9 +2213,11 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2236 2213
2237 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); 2214 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);
2238 2215
2216 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)
2217 pci_enable_wake(tp->pdev, state, true);
2218
2239 /* Finally, set the new power state. */ 2219 /* Finally, set the new power state. */
2240 pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control); 2220 pci_set_power_state(tp->pdev, state);
2241 udelay(100); /* Delay after power state change */
2242 2221
2243 return 0; 2222 return 0;
2244} 2223}
@@ -9065,7 +9044,8 @@ static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
9065{ 9044{
9066 struct tg3 *tp = netdev_priv(dev); 9045 struct tg3 *tp = netdev_priv(dev);
9067 9046
9068 if (tp->tg3_flags & TG3_FLAG_WOL_CAP) 9047 if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) &&
9048 device_can_wakeup(&tp->pdev->dev))
9069 wol->supported = WAKE_MAGIC; 9049 wol->supported = WAKE_MAGIC;
9070 else 9050 else
9071 wol->supported = 0; 9051 wol->supported = 0;
@@ -9078,18 +9058,22 @@ static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
9078static int tg3_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 9058static int tg3_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
9079{ 9059{
9080 struct tg3 *tp = netdev_priv(dev); 9060 struct tg3 *tp = netdev_priv(dev);
9061 struct device *dp = &tp->pdev->dev;
9081 9062
9082 if (wol->wolopts & ~WAKE_MAGIC) 9063 if (wol->wolopts & ~WAKE_MAGIC)
9083 return -EINVAL; 9064 return -EINVAL;
9084 if ((wol->wolopts & WAKE_MAGIC) && 9065 if ((wol->wolopts & WAKE_MAGIC) &&
9085 !(tp->tg3_flags & TG3_FLAG_WOL_CAP)) 9066 !((tp->tg3_flags & TG3_FLAG_WOL_CAP) && device_can_wakeup(dp)))
9086 return -EINVAL; 9067 return -EINVAL;
9087 9068
9088 spin_lock_bh(&tp->lock); 9069 spin_lock_bh(&tp->lock);
9089 if (wol->wolopts & WAKE_MAGIC) 9070 if (wol->wolopts & WAKE_MAGIC) {
9090 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 9071 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
9091 else 9072 device_set_wakeup_enable(dp, true);
9073 } else {
9092 tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE; 9074 tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE;
9075 device_set_wakeup_enable(dp, false);
9076 }
9093 spin_unlock_bh(&tp->lock); 9077 spin_unlock_bh(&tp->lock);
9094 9078
9095 return 0; 9079 return 0;
@@ -11296,7 +11280,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11296 if (val & VCPU_CFGSHDW_ASPM_DBNC) 11280 if (val & VCPU_CFGSHDW_ASPM_DBNC)
11297 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; 11281 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND;
11298 if ((val & VCPU_CFGSHDW_WOL_ENABLE) && 11282 if ((val & VCPU_CFGSHDW_WOL_ENABLE) &&
11299 (val & VCPU_CFGSHDW_WOL_MAGPKT)) 11283 (val & VCPU_CFGSHDW_WOL_MAGPKT) &&
11284 device_may_wakeup(&tp->pdev->dev))
11300 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 11285 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
11301 return; 11286 return;
11302 } 11287 }
@@ -11426,8 +11411,9 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
11426 !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)) 11411 !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL))
11427 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; 11412 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP;
11428 11413
11429 if (tp->tg3_flags & TG3_FLAG_WOL_CAP && 11414 if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) &&
11430 nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE) 11415 (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE) &&
11416 device_may_wakeup(&tp->pdev->dev))
11431 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 11417 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
11432 11418
11433 if (cfg2 & (1 << 17)) 11419 if (cfg2 & (1 << 17))
@@ -13613,6 +13599,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
13613{ 13599{
13614 struct net_device *dev = pci_get_drvdata(pdev); 13600 struct net_device *dev = pci_get_drvdata(pdev);
13615 struct tg3 *tp = netdev_priv(dev); 13601 struct tg3 *tp = netdev_priv(dev);
13602 pci_power_t target_state;
13616 int err; 13603 int err;
13617 13604
13618 /* PCI register 4 needs to be saved whether netif_running() or not. 13605 /* PCI register 4 needs to be saved whether netif_running() or not.
@@ -13641,7 +13628,9 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
13641 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; 13628 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
13642 tg3_full_unlock(tp); 13629 tg3_full_unlock(tp);
13643 13630
13644 err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); 13631 target_state = pdev->pm_cap ? pci_target_state(pdev) : PCI_D3hot;
13632
13633 err = tg3_set_power_state(tp, target_state);
13645 if (err) { 13634 if (err) {
13646 int err2; 13635 int err2;
13647 13636
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 7766cde0d63d..bf621328b601 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -95,20 +95,20 @@ MODULE_DESCRIPTION("3Com 3C359 Velocity XL Token Ring Adapter Driver \n") ;
95static int ringspeed[XL_MAX_ADAPTERS] = {0,} ; 95static int ringspeed[XL_MAX_ADAPTERS] = {0,} ;
96 96
97module_param_array(ringspeed, int, NULL, 0); 97module_param_array(ringspeed, int, NULL, 0);
98MODULE_PARM_DESC(ringspeed,"3c359: Ringspeed selection - 4,16 or 0") ; 98MODULE_PARM_DESC(ringspeed,"3c359: Ringspeed selection - 4,16 or 0") ;
99 99
100/* Packet buffer size */ 100/* Packet buffer size */
101 101
102static int pkt_buf_sz[XL_MAX_ADAPTERS] = {0,} ; 102static int pkt_buf_sz[XL_MAX_ADAPTERS] = {0,} ;
103 103
104module_param_array(pkt_buf_sz, int, NULL, 0) ; 104module_param_array(pkt_buf_sz, int, NULL, 0) ;
105MODULE_PARM_DESC(pkt_buf_sz,"3c359: Initial buffer size") ; 105MODULE_PARM_DESC(pkt_buf_sz,"3c359: Initial buffer size") ;
106/* Message Level */ 106/* Message Level */
107 107
108static int message_level[XL_MAX_ADAPTERS] = {0,} ; 108static int message_level[XL_MAX_ADAPTERS] = {0,} ;
109 109
110module_param_array(message_level, int, NULL, 0) ; 110module_param_array(message_level, int, NULL, 0) ;
111MODULE_PARM_DESC(message_level, "3c359: Level of reported messages \n") ; 111MODULE_PARM_DESC(message_level, "3c359: Level of reported messages") ;
112/* 112/*
113 * This is a real nasty way of doing this, but otherwise you 113 * This is a real nasty way of doing this, but otherwise you
114 * will be stuck with 1555 lines of hex #'s in the code. 114 * will be stuck with 1555 lines of hex #'s in the code.
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index f7319d326912..78df2be8a728 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -55,12 +55,28 @@
55 55
56static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data) 56static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data)
57{ 57{
58 void *buf;
59 int err = -ENOMEM;
60
58 devdbg(dev, "dm_read() reg=0x%02x length=%d", reg, length); 61 devdbg(dev, "dm_read() reg=0x%02x length=%d", reg, length);
59 return usb_control_msg(dev->udev, 62
60 usb_rcvctrlpipe(dev->udev, 0), 63 buf = kmalloc(length, GFP_KERNEL);
61 DM_READ_REGS, 64 if (!buf)
62 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 65 goto out;
63 0, reg, data, length, USB_CTRL_SET_TIMEOUT); 66
67 err = usb_control_msg(dev->udev,
68 usb_rcvctrlpipe(dev->udev, 0),
69 DM_READ_REGS,
70 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
71 0, reg, buf, length, USB_CTRL_SET_TIMEOUT);
72 if (err == length)
73 memcpy(data, buf, length);
74 else if (err >= 0)
75 err = -EINVAL;
76 kfree(buf);
77
78 out:
79 return err;
64} 80}
65 81
66static int dm_read_reg(struct usbnet *dev, u8 reg, u8 *value) 82static int dm_read_reg(struct usbnet *dev, u8 reg, u8 *value)
@@ -70,12 +86,28 @@ static int dm_read_reg(struct usbnet *dev, u8 reg, u8 *value)
70 86
71static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data) 87static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data)
72{ 88{
89 void *buf = NULL;
90 int err = -ENOMEM;
91
73 devdbg(dev, "dm_write() reg=0x%02x, length=%d", reg, length); 92 devdbg(dev, "dm_write() reg=0x%02x, length=%d", reg, length);
74 return usb_control_msg(dev->udev, 93
75 usb_sndctrlpipe(dev->udev, 0), 94 if (data) {
76 DM_WRITE_REGS, 95 buf = kmalloc(length, GFP_KERNEL);
77 USB_DIR_OUT | USB_TYPE_VENDOR |USB_RECIP_DEVICE, 96 if (!buf)
78 0, reg, data, length, USB_CTRL_SET_TIMEOUT); 97 goto out;
98 memcpy(buf, data, length);
99 }
100
101 err = usb_control_msg(dev->udev,
102 usb_sndctrlpipe(dev->udev, 0),
103 DM_WRITE_REGS,
104 USB_DIR_OUT | USB_TYPE_VENDOR |USB_RECIP_DEVICE,
105 0, reg, buf, length, USB_CTRL_SET_TIMEOUT);
106 kfree(buf);
107 if (err >= 0 && err < length)
108 err = -EINVAL;
109 out:
110 return err;
79} 111}
80 112
81static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) 113static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value)
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index fa14255282af..6f9aa1643743 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -337,7 +337,7 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr)
337#ifdef CONFIG_NET_POLL_CONTROLLER 337#ifdef CONFIG_NET_POLL_CONTROLLER
338 dev->poll_controller = ei_poll; 338 dev->poll_controller = ei_poll;
339#endif 339#endif
340 NS8390_init(dev, 0); 340 NS8390p_init(dev, 0);
341 341
342#if 1 342#if 1
343 /* Enable interrupt generation on softconfig cards -- M.U */ 343 /* Enable interrupt generation on softconfig cards -- M.U */
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 1acfbcd3703c..846a7d051851 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -11946,7 +11946,7 @@ module_param(auto_create, int, 0444);
11946MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)"); 11946MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)");
11947 11947
11948module_param(led, int, 0444); 11948module_param(led, int, 0444);
11949MODULE_PARM_DESC(led, "enable led control on some systems (default 0 off)\n"); 11949MODULE_PARM_DESC(led, "enable led control on some systems (default 0 off)");
11950 11950
11951module_param(debug, int, 0444); 11951module_param(debug, int, 0444);
11952MODULE_PARM_DESC(debug, "debug output mask"); 11952MODULE_PARM_DESC(debug, "debug output mask");
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 9afecb813716..ba2df1ba32d2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2469,7 +2469,7 @@ MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
2469module_param_named(disable, iwl4965_mod_params.disable, int, 0444); 2469module_param_named(disable, iwl4965_mod_params.disable, int, 0444);
2470MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])"); 2470MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
2471module_param_named(swcrypto, iwl4965_mod_params.sw_crypto, int, 0444); 2471module_param_named(swcrypto, iwl4965_mod_params.sw_crypto, int, 0444);
2472MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])\n"); 2472MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
2473module_param_named(debug, iwl4965_mod_params.debug, int, 0444); 2473module_param_named(debug, iwl4965_mod_params.debug, int, 0444);
2474MODULE_PARM_DESC(debug, "debug output mask"); 2474MODULE_PARM_DESC(debug, "debug output mask");
2475module_param_named( 2475module_param_named(
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index d0c1d63d1891..203e579ebbd2 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -275,7 +275,7 @@ static int readable(struct pcmcia_socket *s, struct resource *res,
275 destroy_cis_cache(s); 275 destroy_cis_cache(s);
276 } 276 }
277 s->cis_mem.res = NULL; 277 s->cis_mem.res = NULL;
278 if ((ret != 0) || (count == 0)) 278 if ((ret != 0) || (*count == 0))
279 return 0; 279 return 0;
280 return 1; 280 return 1;
281} 281}
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c
index bbf78ef4ba02..b42df1620718 100644
--- a/drivers/pnp/support.c
+++ b/drivers/pnp/support.c
@@ -77,7 +77,7 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc)
77{ 77{
78#ifdef DEBUG 78#ifdef DEBUG
79 char buf[128]; 79 char buf[128];
80 int len = 0; 80 int len;
81 struct pnp_resource *pnp_res; 81 struct pnp_resource *pnp_res;
82 struct resource *res; 82 struct resource *res;
83 83
@@ -89,9 +89,10 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc)
89 dev_dbg(&dev->dev, "%s: current resources:\n", desc); 89 dev_dbg(&dev->dev, "%s: current resources:\n", desc);
90 list_for_each_entry(pnp_res, &dev->resources, list) { 90 list_for_each_entry(pnp_res, &dev->resources, list) {
91 res = &pnp_res->res; 91 res = &pnp_res->res;
92 len = 0;
92 93
93 len += snprintf(buf + len, sizeof(buf) - len, " %-3s ", 94 len += scnprintf(buf + len, sizeof(buf) - len, " %-3s ",
94 pnp_resource_type_name(res)); 95 pnp_resource_type_name(res));
95 96
96 if (res->flags & IORESOURCE_DISABLED) { 97 if (res->flags & IORESOURCE_DISABLED) {
97 dev_dbg(&dev->dev, "%sdisabled\n", buf); 98 dev_dbg(&dev->dev, "%sdisabled\n", buf);
@@ -101,18 +102,18 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc)
101 switch (pnp_resource_type(res)) { 102 switch (pnp_resource_type(res)) {
102 case IORESOURCE_IO: 103 case IORESOURCE_IO:
103 case IORESOURCE_MEM: 104 case IORESOURCE_MEM:
104 len += snprintf(buf + len, sizeof(buf) - len, 105 len += scnprintf(buf + len, sizeof(buf) - len,
105 "%#llx-%#llx flags %#lx", 106 "%#llx-%#llx flags %#lx",
106 (unsigned long long) res->start, 107 (unsigned long long) res->start,
107 (unsigned long long) res->end, 108 (unsigned long long) res->end,
108 res->flags); 109 res->flags);
109 break; 110 break;
110 case IORESOURCE_IRQ: 111 case IORESOURCE_IRQ:
111 case IORESOURCE_DMA: 112 case IORESOURCE_DMA:
112 len += snprintf(buf + len, sizeof(buf) - len, 113 len += scnprintf(buf + len, sizeof(buf) - len,
113 "%lld flags %#lx", 114 "%lld flags %#lx",
114 (unsigned long long) res->start, 115 (unsigned long long) res->start,
115 res->flags); 116 res->flags);
116 break; 117 break;
117 } 118 }
118 dev_dbg(&dev->dev, "%s\n", buf); 119 dev_dbg(&dev->dev, "%s\n", buf);
@@ -144,66 +145,67 @@ void dbg_pnp_show_option(struct pnp_dev *dev, struct pnp_option *option)
144 struct pnp_dma *dma; 145 struct pnp_dma *dma;
145 146
146 if (pnp_option_is_dependent(option)) 147 if (pnp_option_is_dependent(option))
147 len += snprintf(buf + len, sizeof(buf) - len, 148 len += scnprintf(buf + len, sizeof(buf) - len,
148 " dependent set %d (%s) ", 149 " dependent set %d (%s) ",
149 pnp_option_set(option), 150 pnp_option_set(option),
150 pnp_option_priority_name(option)); 151 pnp_option_priority_name(option));
151 else 152 else
152 len += snprintf(buf + len, sizeof(buf) - len, " independent "); 153 len += scnprintf(buf + len, sizeof(buf) - len,
154 " independent ");
153 155
154 switch (option->type) { 156 switch (option->type) {
155 case IORESOURCE_IO: 157 case IORESOURCE_IO:
156 port = &option->u.port; 158 port = &option->u.port;
157 len += snprintf(buf + len, sizeof(buf) - len, "io min %#llx " 159 len += scnprintf(buf + len, sizeof(buf) - len, "io min %#llx "
158 "max %#llx align %lld size %lld flags %#x", 160 "max %#llx align %lld size %lld flags %#x",
159 (unsigned long long) port->min, 161 (unsigned long long) port->min,
160 (unsigned long long) port->max, 162 (unsigned long long) port->max,
161 (unsigned long long) port->align, 163 (unsigned long long) port->align,
162 (unsigned long long) port->size, port->flags); 164 (unsigned long long) port->size, port->flags);
163 break; 165 break;
164 case IORESOURCE_MEM: 166 case IORESOURCE_MEM:
165 mem = &option->u.mem; 167 mem = &option->u.mem;
166 len += snprintf(buf + len, sizeof(buf) - len, "mem min %#llx " 168 len += scnprintf(buf + len, sizeof(buf) - len, "mem min %#llx "
167 "max %#llx align %lld size %lld flags %#x", 169 "max %#llx align %lld size %lld flags %#x",
168 (unsigned long long) mem->min, 170 (unsigned long long) mem->min,
169 (unsigned long long) mem->max, 171 (unsigned long long) mem->max,
170 (unsigned long long) mem->align, 172 (unsigned long long) mem->align,
171 (unsigned long long) mem->size, mem->flags); 173 (unsigned long long) mem->size, mem->flags);
172 break; 174 break;
173 case IORESOURCE_IRQ: 175 case IORESOURCE_IRQ:
174 irq = &option->u.irq; 176 irq = &option->u.irq;
175 len += snprintf(buf + len, sizeof(buf) - len, "irq"); 177 len += scnprintf(buf + len, sizeof(buf) - len, "irq");
176 if (bitmap_empty(irq->map.bits, PNP_IRQ_NR)) 178 if (bitmap_empty(irq->map.bits, PNP_IRQ_NR))
177 len += snprintf(buf + len, sizeof(buf) - len, 179 len += scnprintf(buf + len, sizeof(buf) - len,
178 " <none>"); 180 " <none>");
179 else { 181 else {
180 for (i = 0; i < PNP_IRQ_NR; i++) 182 for (i = 0; i < PNP_IRQ_NR; i++)
181 if (test_bit(i, irq->map.bits)) 183 if (test_bit(i, irq->map.bits))
182 len += snprintf(buf + len, 184 len += scnprintf(buf + len,
183 sizeof(buf) - len, 185 sizeof(buf) - len,
184 " %d", i); 186 " %d", i);
185 } 187 }
186 len += snprintf(buf + len, sizeof(buf) - len, " flags %#x", 188 len += scnprintf(buf + len, sizeof(buf) - len, " flags %#x",
187 irq->flags); 189 irq->flags);
188 if (irq->flags & IORESOURCE_IRQ_OPTIONAL) 190 if (irq->flags & IORESOURCE_IRQ_OPTIONAL)
189 len += snprintf(buf + len, sizeof(buf) - len, 191 len += scnprintf(buf + len, sizeof(buf) - len,
190 " (optional)"); 192 " (optional)");
191 break; 193 break;
192 case IORESOURCE_DMA: 194 case IORESOURCE_DMA:
193 dma = &option->u.dma; 195 dma = &option->u.dma;
194 len += snprintf(buf + len, sizeof(buf) - len, "dma"); 196 len += scnprintf(buf + len, sizeof(buf) - len, "dma");
195 if (!dma->map) 197 if (!dma->map)
196 len += snprintf(buf + len, sizeof(buf) - len, 198 len += scnprintf(buf + len, sizeof(buf) - len,
197 " <none>"); 199 " <none>");
198 else { 200 else {
199 for (i = 0; i < 8; i++) 201 for (i = 0; i < 8; i++)
200 if (dma->map & (1 << i)) 202 if (dma->map & (1 << i))
201 len += snprintf(buf + len, 203 len += scnprintf(buf + len,
202 sizeof(buf) - len, 204 sizeof(buf) - len,
203 " %d", i); 205 " %d", i);
204 } 206 }
205 len += snprintf(buf + len, sizeof(buf) - len, " (bitmask %#x) " 207 len += scnprintf(buf + len, sizeof(buf) - len, " (bitmask %#x) "
206 "flags %#x", dma->map, dma->flags); 208 "flags %#x", dma->map, dma->flags);
207 break; 209 break;
208 } 210 }
209 dev_dbg(&dev->dev, "%s\n", buf); 211 dev_dbg(&dev->dev, "%s\n", buf);
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 4d17d384578d..9ce55850271a 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -49,6 +49,13 @@ config BATTERY_OLPC
49 help 49 help
50 Say Y to enable support for the battery on the OLPC laptop. 50 Say Y to enable support for the battery on the OLPC laptop.
51 51
52config BATTERY_TOSA
53 tristate "Sharp SL-6000 (tosa) battery"
54 depends on MACH_TOSA && MFD_TC6393XB
55 help
56 Say Y to enable support for the battery on the Sharp Zaurus
57 SL-6000 (tosa) models.
58
52config BATTERY_PALMTX 59config BATTERY_PALMTX
53 tristate "Palm T|X battery" 60 tristate "Palm T|X battery"
54 depends on MACH_PALMTX 61 depends on MACH_PALMTX
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 6f43a54ee420..4706bf8ff459 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -20,4 +20,5 @@ obj-$(CONFIG_APM_POWER) += apm_power.o
20obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o 20obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
21obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o 21obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o
22obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o 22obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o
23obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o
23obj-$(CONFIG_BATTERY_PALMTX) += palmtx_battery.o 24obj-$(CONFIG_BATTERY_PALMTX) += palmtx_battery.o
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index ab1e8289f07f..32570af3c5c9 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -19,7 +19,7 @@
19 19
20#define EC_BAT_VOLTAGE 0x10 /* uint16_t, *9.76/32, mV */ 20#define EC_BAT_VOLTAGE 0x10 /* uint16_t, *9.76/32, mV */
21#define EC_BAT_CURRENT 0x11 /* int16_t, *15.625/120, mA */ 21#define EC_BAT_CURRENT 0x11 /* int16_t, *15.625/120, mA */
22#define EC_BAT_ACR 0x12 22#define EC_BAT_ACR 0x12 /* int16_t, *6250/15, µAh */
23#define EC_BAT_TEMP 0x13 /* uint16_t, *100/256, °C */ 23#define EC_BAT_TEMP 0x13 /* uint16_t, *100/256, °C */
24#define EC_AMB_TEMP 0x14 /* uint16_t, *100/256, °C */ 24#define EC_AMB_TEMP 0x14 /* uint16_t, *100/256, °C */
25#define EC_BAT_STATUS 0x15 /* uint8_t, bitmask */ 25#define EC_BAT_STATUS 0x15 /* uint8_t, bitmask */
@@ -84,6 +84,119 @@ static struct power_supply olpc_ac = {
84 .get_property = olpc_ac_get_prop, 84 .get_property = olpc_ac_get_prop,
85}; 85};
86 86
87static char bat_serial[17]; /* Ick */
88
89static int olpc_bat_get_status(union power_supply_propval *val, uint8_t ec_byte)
90{
91 if (olpc_platform_info.ecver > 0x44) {
92 if (ec_byte & BAT_STAT_CHARGING)
93 val->intval = POWER_SUPPLY_STATUS_CHARGING;
94 else if (ec_byte & BAT_STAT_DISCHARGING)
95 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
96 else if (ec_byte & BAT_STAT_FULL)
97 val->intval = POWER_SUPPLY_STATUS_FULL;
98 else /* er,... */
99 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
100 } else {
101 /* Older EC didn't report charge/discharge bits */
102 if (!(ec_byte & BAT_STAT_AC)) /* No AC means discharging */
103 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
104 else if (ec_byte & BAT_STAT_FULL)
105 val->intval = POWER_SUPPLY_STATUS_FULL;
106 else /* Not _necessarily_ true but EC doesn't tell all yet */
107 val->intval = POWER_SUPPLY_STATUS_CHARGING;
108 }
109
110 return 0;
111}
112
113static int olpc_bat_get_health(union power_supply_propval *val)
114{
115 uint8_t ec_byte;
116 int ret;
117
118 ret = olpc_ec_cmd(EC_BAT_ERRCODE, NULL, 0, &ec_byte, 1);
119 if (ret)
120 return ret;
121
122 switch (ec_byte) {
123 case 0:
124 val->intval = POWER_SUPPLY_HEALTH_GOOD;
125 break;
126
127 case BAT_ERR_OVERTEMP:
128 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
129 break;
130
131 case BAT_ERR_OVERVOLTAGE:
132 val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
133 break;
134
135 case BAT_ERR_INFOFAIL:
136 case BAT_ERR_OUT_OF_CONTROL:
137 case BAT_ERR_ID_FAIL:
138 case BAT_ERR_ACR_FAIL:
139 val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
140 break;
141
142 default:
143 /* Eep. We don't know this failure code */
144 ret = -EIO;
145 }
146
147 return ret;
148}
149
150static int olpc_bat_get_mfr(union power_supply_propval *val)
151{
152 uint8_t ec_byte;
153 int ret;
154
155 ec_byte = BAT_ADDR_MFR_TYPE;
156 ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1);
157 if (ret)
158 return ret;
159
160 switch (ec_byte >> 4) {
161 case 1:
162 val->strval = "Gold Peak";
163 break;
164 case 2:
165 val->strval = "BYD";
166 break;
167 default:
168 val->strval = "Unknown";
169 break;
170 }
171
172 return ret;
173}
174
175static int olpc_bat_get_tech(union power_supply_propval *val)
176{
177 uint8_t ec_byte;
178 int ret;
179
180 ec_byte = BAT_ADDR_MFR_TYPE;
181 ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1);
182 if (ret)
183 return ret;
184
185 switch (ec_byte & 0xf) {
186 case 1:
187 val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH;
188 break;
189 case 2:
190 val->intval = POWER_SUPPLY_TECHNOLOGY_LiFe;
191 break;
192 default:
193 val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
194 break;
195 }
196
197 return ret;
198}
199
87/********************************************************************* 200/*********************************************************************
88 * Battery properties 201 * Battery properties
89 *********************************************************************/ 202 *********************************************************************/
@@ -94,6 +207,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
94 int ret = 0; 207 int ret = 0;
95 int16_t ec_word; 208 int16_t ec_word;
96 uint8_t ec_byte; 209 uint8_t ec_byte;
210 uint64_t ser_buf;
97 211
98 ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1); 212 ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1);
99 if (ret) 213 if (ret)
@@ -110,25 +224,10 @@ static int olpc_bat_get_property(struct power_supply *psy,
110 224
111 switch (psp) { 225 switch (psp) {
112 case POWER_SUPPLY_PROP_STATUS: 226 case POWER_SUPPLY_PROP_STATUS:
113 if (olpc_platform_info.ecver > 0x44) { 227 ret = olpc_bat_get_status(val, ec_byte);
114 if (ec_byte & BAT_STAT_CHARGING) 228 if (ret)
115 val->intval = POWER_SUPPLY_STATUS_CHARGING; 229 return ret;
116 else if (ec_byte & BAT_STAT_DISCHARGING) 230 break;
117 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
118 else if (ec_byte & BAT_STAT_FULL)
119 val->intval = POWER_SUPPLY_STATUS_FULL;
120 else /* er,... */
121 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
122 } else {
123 /* Older EC didn't report charge/discharge bits */
124 if (!(ec_byte & BAT_STAT_AC)) /* No AC means discharging */
125 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
126 else if (ec_byte & BAT_STAT_FULL)
127 val->intval = POWER_SUPPLY_STATUS_FULL;
128 else /* Not _necessarily_ true but EC doesn't tell all yet */
129 val->intval = POWER_SUPPLY_STATUS_CHARGING;
130 break;
131 }
132 case POWER_SUPPLY_PROP_PRESENT: 231 case POWER_SUPPLY_PROP_PRESENT:
133 val->intval = !!(ec_byte & BAT_STAT_PRESENT); 232 val->intval = !!(ec_byte & BAT_STAT_PRESENT);
134 break; 233 break;
@@ -137,72 +236,21 @@ static int olpc_bat_get_property(struct power_supply *psy,
137 if (ec_byte & BAT_STAT_DESTROY) 236 if (ec_byte & BAT_STAT_DESTROY)
138 val->intval = POWER_SUPPLY_HEALTH_DEAD; 237 val->intval = POWER_SUPPLY_HEALTH_DEAD;
139 else { 238 else {
140 ret = olpc_ec_cmd(EC_BAT_ERRCODE, NULL, 0, &ec_byte, 1); 239 ret = olpc_bat_get_health(val);
141 if (ret) 240 if (ret)
142 return ret; 241 return ret;
143
144 switch (ec_byte) {
145 case 0:
146 val->intval = POWER_SUPPLY_HEALTH_GOOD;
147 break;
148
149 case BAT_ERR_OVERTEMP:
150 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
151 break;
152
153 case BAT_ERR_OVERVOLTAGE:
154 val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
155 break;
156
157 case BAT_ERR_INFOFAIL:
158 case BAT_ERR_OUT_OF_CONTROL:
159 case BAT_ERR_ID_FAIL:
160 case BAT_ERR_ACR_FAIL:
161 val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
162 break;
163
164 default:
165 /* Eep. We don't know this failure code */
166 return -EIO;
167 }
168 } 242 }
169 break; 243 break;
170 244
171 case POWER_SUPPLY_PROP_MANUFACTURER: 245 case POWER_SUPPLY_PROP_MANUFACTURER:
172 ec_byte = BAT_ADDR_MFR_TYPE; 246 ret = olpc_bat_get_mfr(val);
173 ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1);
174 if (ret) 247 if (ret)
175 return ret; 248 return ret;
176
177 switch (ec_byte >> 4) {
178 case 1:
179 val->strval = "Gold Peak";
180 break;
181 case 2:
182 val->strval = "BYD";
183 break;
184 default:
185 val->strval = "Unknown";
186 break;
187 }
188 break; 249 break;
189 case POWER_SUPPLY_PROP_TECHNOLOGY: 250 case POWER_SUPPLY_PROP_TECHNOLOGY:
190 ec_byte = BAT_ADDR_MFR_TYPE; 251 ret = olpc_bat_get_tech(val);
191 ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1);
192 if (ret) 252 if (ret)
193 return ret; 253 return ret;
194
195 switch (ec_byte & 0xf) {
196 case 1:
197 val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH;
198 break;
199 case 2:
200 val->intval = POWER_SUPPLY_TECHNOLOGY_LiFe;
201 break;
202 default:
203 val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
204 break;
205 }
206 break; 254 break;
207 case POWER_SUPPLY_PROP_VOLTAGE_AVG: 255 case POWER_SUPPLY_PROP_VOLTAGE_AVG:
208 ret = olpc_ec_cmd(EC_BAT_VOLTAGE, NULL, 0, (void *)&ec_word, 2); 256 ret = olpc_ec_cmd(EC_BAT_VOLTAGE, NULL, 0, (void *)&ec_word, 2);
@@ -241,6 +289,22 @@ static int olpc_bat_get_property(struct power_supply *psy,
241 ec_word = be16_to_cpu(ec_word); 289 ec_word = be16_to_cpu(ec_word);
242 val->intval = ec_word * 100 / 256; 290 val->intval = ec_word * 100 / 256;
243 break; 291 break;
292 case POWER_SUPPLY_PROP_CHARGE_COUNTER:
293 ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2);
294 if (ret)
295 return ret;
296
297 ec_word = be16_to_cpu(ec_word);
298 val->intval = ec_word * 6250 / 15;
299 break;
300 case POWER_SUPPLY_PROP_SERIAL_NUMBER:
301 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8);
302 if (ret)
303 return ret;
304
305 sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf));
306 val->strval = bat_serial;
307 break;
244 default: 308 default:
245 ret = -EINVAL; 309 ret = -EINVAL;
246 break; 310 break;
@@ -260,6 +324,50 @@ static enum power_supply_property olpc_bat_props[] = {
260 POWER_SUPPLY_PROP_TEMP, 324 POWER_SUPPLY_PROP_TEMP,
261 POWER_SUPPLY_PROP_TEMP_AMBIENT, 325 POWER_SUPPLY_PROP_TEMP_AMBIENT,
262 POWER_SUPPLY_PROP_MANUFACTURER, 326 POWER_SUPPLY_PROP_MANUFACTURER,
327 POWER_SUPPLY_PROP_SERIAL_NUMBER,
328 POWER_SUPPLY_PROP_CHARGE_COUNTER,
329};
330
331/* EEPROM reading goes completely around the power_supply API, sadly */
332
333#define EEPROM_START 0x20
334#define EEPROM_END 0x80
335#define EEPROM_SIZE (EEPROM_END - EEPROM_START)
336
337static ssize_t olpc_bat_eeprom_read(struct kobject *kobj,
338 struct bin_attribute *attr, char *buf, loff_t off, size_t count)
339{
340 uint8_t ec_byte;
341 int ret, end;
342
343 if (off >= EEPROM_SIZE)
344 return 0;
345 if (off + count > EEPROM_SIZE)
346 count = EEPROM_SIZE - off;
347
348 end = EEPROM_START + off + count;
349 for (ec_byte = EEPROM_START + off; ec_byte < end; ec_byte++) {
350 ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1,
351 &buf[ec_byte - EEPROM_START], 1);
352 if (ret) {
353 printk(KERN_ERR "olpc-battery: EC command "
354 "EC_BAT_EEPROM @ 0x%x failed -"
355 " %d!\n", ec_byte, ret);
356 return -EIO;
357 }
358 }
359
360 return count;
361}
362
363static struct bin_attribute olpc_bat_eeprom = {
364 .attr = {
365 .name = "eeprom",
366 .mode = S_IRUGO,
367 .owner = THIS_MODULE,
368 },
369 .size = 0,
370 .read = olpc_bat_eeprom_read,
263}; 371};
264 372
265/********************************************************************* 373/*********************************************************************
@@ -290,8 +398,14 @@ static int __init olpc_bat_init(void)
290 398
291 if (!olpc_platform_info.ecver) 399 if (!olpc_platform_info.ecver)
292 return -ENXIO; 400 return -ENXIO;
293 if (olpc_platform_info.ecver < 0x43) { 401
294 printk(KERN_NOTICE "OLPC EC version 0x%02x too old for battery driver.\n", olpc_platform_info.ecver); 402 /*
403 * We've seen a number of EC protocol changes; this driver requires
404 * the latest EC protocol, supported by 0x44 and above.
405 */
406 if (olpc_platform_info.ecver < 0x44) {
407 printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
408 "battery driver.\n", olpc_platform_info.ecver);
295 return -ENXIO; 409 return -ENXIO;
296 } 410 }
297 411
@@ -315,8 +429,14 @@ static int __init olpc_bat_init(void)
315 if (ret) 429 if (ret)
316 goto battery_failed; 430 goto battery_failed;
317 431
432 ret = device_create_bin_file(olpc_bat.dev, &olpc_bat_eeprom);
433 if (ret)
434 goto eeprom_failed;
435
318 goto success; 436 goto success;
319 437
438eeprom_failed:
439 power_supply_unregister(&olpc_bat);
320battery_failed: 440battery_failed:
321 power_supply_unregister(&olpc_ac); 441 power_supply_unregister(&olpc_ac);
322ac_failed: 442ac_failed:
@@ -327,6 +447,7 @@ success:
327 447
328static void __exit olpc_bat_exit(void) 448static void __exit olpc_bat_exit(void)
329{ 449{
450 device_remove_bin_file(olpc_bat.dev, &olpc_bat_eeprom);
330 power_supply_unregister(&olpc_bat); 451 power_supply_unregister(&olpc_bat);
331 power_supply_unregister(&olpc_ac); 452 power_supply_unregister(&olpc_ac);
332 platform_device_unregister(bat_pdev); 453 platform_device_unregister(bat_pdev);
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 49215da5249b..fe2aeb11939b 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -99,6 +99,7 @@ static struct device_attribute power_supply_attrs[] = {
99 POWER_SUPPLY_ATTR(charge_empty), 99 POWER_SUPPLY_ATTR(charge_empty),
100 POWER_SUPPLY_ATTR(charge_now), 100 POWER_SUPPLY_ATTR(charge_now),
101 POWER_SUPPLY_ATTR(charge_avg), 101 POWER_SUPPLY_ATTR(charge_avg),
102 POWER_SUPPLY_ATTR(charge_counter),
102 POWER_SUPPLY_ATTR(energy_full_design), 103 POWER_SUPPLY_ATTR(energy_full_design),
103 POWER_SUPPLY_ATTR(energy_empty_design), 104 POWER_SUPPLY_ATTR(energy_empty_design),
104 POWER_SUPPLY_ATTR(energy_full), 105 POWER_SUPPLY_ATTR(energy_full),
diff --git a/drivers/power/tosa_battery.c b/drivers/power/tosa_battery.c
new file mode 100644
index 000000000000..bf664fbd6610
--- /dev/null
+++ b/drivers/power/tosa_battery.c
@@ -0,0 +1,486 @@
1/*
2 * Battery and Power Management code for the Sharp SL-6000x
3 *
4 * Copyright (c) 2005 Dirk Opfer
5 * Copyright (c) 2008 Dmitry Baryshkov
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/power_supply.h>
15#include <linux/wm97xx.h>
16#include <linux/delay.h>
17#include <linux/spinlock.h>
18#include <linux/interrupt.h>
19#include <linux/gpio.h>
20
21#include <asm/mach-types.h>
22#include <asm/arch/tosa.h>
23
24static DEFINE_MUTEX(bat_lock); /* protects gpio pins */
25static struct work_struct bat_work;
26
27struct tosa_bat {
28 int status;
29 struct power_supply psy;
30 int full_chrg;
31
32 struct mutex work_lock; /* protects data */
33
34 bool (*is_present)(struct tosa_bat *bat);
35 int gpio_full;
36 int gpio_charge_off;
37
38 int technology;
39
40 int gpio_bat;
41 int adc_bat;
42 int adc_bat_divider;
43 int bat_max;
44 int bat_min;
45
46 int gpio_temp;
47 int adc_temp;
48 int adc_temp_divider;
49};
50
51static struct tosa_bat tosa_bat_main;
52static struct tosa_bat tosa_bat_jacket;
53
54static unsigned long tosa_read_bat(struct tosa_bat *bat)
55{
56 unsigned long value = 0;
57
58 if (bat->gpio_bat < 0 || bat->adc_bat < 0)
59 return 0;
60
61 mutex_lock(&bat_lock);
62 gpio_set_value(bat->gpio_bat, 1);
63 msleep(5);
64 value = wm97xx_read_aux_adc(bat->psy.dev->parent->driver_data,
65 bat->adc_bat);
66 gpio_set_value(bat->gpio_bat, 0);
67 mutex_unlock(&bat_lock);
68
69 value = value * 1000000 / bat->adc_bat_divider;
70
71 return value;
72}
73
74static unsigned long tosa_read_temp(struct tosa_bat *bat)
75{
76 unsigned long value = 0;
77
78 if (bat->gpio_temp < 0 || bat->adc_temp < 0)
79 return 0;
80
81 mutex_lock(&bat_lock);
82 gpio_set_value(bat->gpio_temp, 1);
83 msleep(5);
84 value = wm97xx_read_aux_adc(bat->psy.dev->parent->driver_data,
85 bat->adc_temp);
86 gpio_set_value(bat->gpio_temp, 0);
87 mutex_unlock(&bat_lock);
88
89 value = value * 10000 / bat->adc_temp_divider;
90
91 return value;
92}
93
94static int tosa_bat_get_property(struct power_supply *psy,
95 enum power_supply_property psp,
96 union power_supply_propval *val)
97{
98 int ret = 0;
99 struct tosa_bat *bat = container_of(psy, struct tosa_bat, psy);
100
101 if (bat->is_present && !bat->is_present(bat)
102 && psp != POWER_SUPPLY_PROP_PRESENT) {
103 return -ENODEV;
104 }
105
106 switch (psp) {
107 case POWER_SUPPLY_PROP_STATUS:
108 val->intval = bat->status;
109 break;
110 case POWER_SUPPLY_PROP_TECHNOLOGY:
111 val->intval = bat->technology;
112 break;
113 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
114 val->intval = tosa_read_bat(bat);
115 break;
116 case POWER_SUPPLY_PROP_VOLTAGE_MAX:
117 if (bat->full_chrg == -1)
118 val->intval = bat->bat_max;
119 else
120 val->intval = bat->full_chrg;
121 break;
122 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
123 val->intval = bat->bat_max;
124 break;
125 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
126 val->intval = bat->bat_min;
127 break;
128 case POWER_SUPPLY_PROP_TEMP:
129 val->intval = tosa_read_temp(bat);
130 break;
131 case POWER_SUPPLY_PROP_PRESENT:
132 val->intval = bat->is_present ? bat->is_present(bat) : 1;
133 break;
134 default:
135 ret = -EINVAL;
136 break;
137 }
138 return ret;
139}
140
141static bool tosa_jacket_bat_is_present(struct tosa_bat *bat)
142{
143 return gpio_get_value(TOSA_GPIO_JACKET_DETECT) == 0;
144}
145
146static void tosa_bat_external_power_changed(struct power_supply *psy)
147{
148 schedule_work(&bat_work);
149}
150
151static irqreturn_t tosa_bat_gpio_isr(int irq, void *data)
152{
153 pr_info("tosa_bat_gpio irq: %d\n", gpio_get_value(irq_to_gpio(irq)));
154 schedule_work(&bat_work);
155 return IRQ_HANDLED;
156}
157
158static void tosa_bat_update(struct tosa_bat *bat)
159{
160 int old;
161 struct power_supply *psy = &bat->psy;
162
163 mutex_lock(&bat->work_lock);
164
165 old = bat->status;
166
167 if (bat->is_present && !bat->is_present(bat)) {
168 printk(KERN_NOTICE "%s not present\n", psy->name);
169 bat->status = POWER_SUPPLY_STATUS_UNKNOWN;
170 bat->full_chrg = -1;
171 } else if (power_supply_am_i_supplied(psy)) {
172 if (bat->status == POWER_SUPPLY_STATUS_DISCHARGING) {
173 gpio_set_value(bat->gpio_charge_off, 0);
174 mdelay(15);
175 }
176
177 if (gpio_get_value(bat->gpio_full)) {
178 if (old == POWER_SUPPLY_STATUS_CHARGING ||
179 bat->full_chrg == -1)
180 bat->full_chrg = tosa_read_bat(bat);
181
182 gpio_set_value(bat->gpio_charge_off, 1);
183 bat->status = POWER_SUPPLY_STATUS_FULL;
184 } else {
185 gpio_set_value(bat->gpio_charge_off, 0);
186 bat->status = POWER_SUPPLY_STATUS_CHARGING;
187 }
188 } else {
189 gpio_set_value(bat->gpio_charge_off, 1);
190 bat->status = POWER_SUPPLY_STATUS_DISCHARGING;
191 }
192
193 if (old != bat->status)
194 power_supply_changed(psy);
195
196 mutex_unlock(&bat->work_lock);
197}
198
199static void tosa_bat_work(struct work_struct *work)
200{
201 tosa_bat_update(&tosa_bat_main);
202 tosa_bat_update(&tosa_bat_jacket);
203}
204
205
206static enum power_supply_property tosa_bat_main_props[] = {
207 POWER_SUPPLY_PROP_STATUS,
208 POWER_SUPPLY_PROP_TECHNOLOGY,
209 POWER_SUPPLY_PROP_VOLTAGE_NOW,
210 POWER_SUPPLY_PROP_VOLTAGE_MAX,
211 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
212 POWER_SUPPLY_PROP_TEMP,
213 POWER_SUPPLY_PROP_PRESENT,
214};
215
216static enum power_supply_property tosa_bat_bu_props[] = {
217 POWER_SUPPLY_PROP_STATUS,
218 POWER_SUPPLY_PROP_TECHNOLOGY,
219 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
220 POWER_SUPPLY_PROP_VOLTAGE_NOW,
221 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
222 POWER_SUPPLY_PROP_PRESENT,
223};
224
225static struct tosa_bat tosa_bat_main = {
226 .status = POWER_SUPPLY_STATUS_DISCHARGING,
227 .full_chrg = -1,
228 .psy = {
229 .name = "main-battery",
230 .type = POWER_SUPPLY_TYPE_BATTERY,
231 .properties = tosa_bat_main_props,
232 .num_properties = ARRAY_SIZE(tosa_bat_main_props),
233 .get_property = tosa_bat_get_property,
234 .external_power_changed = tosa_bat_external_power_changed,
235 .use_for_apm = 1,
236 },
237
238 .gpio_full = TOSA_GPIO_BAT0_CRG,
239 .gpio_charge_off = TOSA_GPIO_CHARGE_OFF,
240
241 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
242
243 .gpio_bat = TOSA_GPIO_BAT0_V_ON,
244 .adc_bat = WM97XX_AUX_ID3,
245 .adc_bat_divider = 414,
246 .bat_max = 4310000,
247 .bat_min = 1551 * 1000000 / 414,
248
249 .gpio_temp = TOSA_GPIO_BAT1_TH_ON,
250 .adc_temp = WM97XX_AUX_ID2,
251 .adc_temp_divider = 10000,
252};
253
254static struct tosa_bat tosa_bat_jacket = {
255 .status = POWER_SUPPLY_STATUS_DISCHARGING,
256 .full_chrg = -1,
257 .psy = {
258 .name = "jacket-battery",
259 .type = POWER_SUPPLY_TYPE_BATTERY,
260 .properties = tosa_bat_main_props,
261 .num_properties = ARRAY_SIZE(tosa_bat_main_props),
262 .get_property = tosa_bat_get_property,
263 .external_power_changed = tosa_bat_external_power_changed,
264 },
265
266 .is_present = tosa_jacket_bat_is_present,
267 .gpio_full = TOSA_GPIO_BAT1_CRG,
268 .gpio_charge_off = TOSA_GPIO_CHARGE_OFF_JC,
269
270 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
271
272 .gpio_bat = TOSA_GPIO_BAT1_V_ON,
273 .adc_bat = WM97XX_AUX_ID3,
274 .adc_bat_divider = 414,
275 .bat_max = 4310000,
276 .bat_min = 1551 * 1000000 / 414,
277
278 .gpio_temp = TOSA_GPIO_BAT0_TH_ON,
279 .adc_temp = WM97XX_AUX_ID2,
280 .adc_temp_divider = 10000,
281};
282
283static struct tosa_bat tosa_bat_bu = {
284 .status = POWER_SUPPLY_STATUS_UNKNOWN,
285 .full_chrg = -1,
286
287 .psy = {
288 .name = "backup-battery",
289 .type = POWER_SUPPLY_TYPE_BATTERY,
290 .properties = tosa_bat_bu_props,
291 .num_properties = ARRAY_SIZE(tosa_bat_bu_props),
292 .get_property = tosa_bat_get_property,
293 .external_power_changed = tosa_bat_external_power_changed,
294 },
295
296 .gpio_full = -1,
297 .gpio_charge_off = -1,
298
299 .technology = POWER_SUPPLY_TECHNOLOGY_LiMn,
300
301 .gpio_bat = TOSA_GPIO_BU_CHRG_ON,
302 .adc_bat = WM97XX_AUX_ID4,
303 .adc_bat_divider = 1266,
304
305 .gpio_temp = -1,
306 .adc_temp = -1,
307 .adc_temp_divider = -1,
308};
309
310static struct {
311 int gpio;
312 char *name;
313 bool output;
314 int value;
315} gpios[] = {
316 { TOSA_GPIO_CHARGE_OFF, "main charge off", 1, 1 },
317 { TOSA_GPIO_CHARGE_OFF_JC, "jacket charge off", 1, 1 },
318 { TOSA_GPIO_BAT_SW_ON, "battery switch", 1, 0 },
319 { TOSA_GPIO_BAT0_V_ON, "main battery", 1, 0 },
320 { TOSA_GPIO_BAT1_V_ON, "jacket battery", 1, 0 },
321 { TOSA_GPIO_BAT1_TH_ON, "main battery temp", 1, 0 },
322 { TOSA_GPIO_BAT0_TH_ON, "jacket battery temp", 1, 0 },
323 { TOSA_GPIO_BU_CHRG_ON, "backup battery", 1, 0 },
324 { TOSA_GPIO_BAT0_CRG, "main battery full", 0, 0 },
325 { TOSA_GPIO_BAT1_CRG, "jacket battery full", 0, 0 },
326 { TOSA_GPIO_BAT0_LOW, "main battery low", 0, 0 },
327 { TOSA_GPIO_BAT1_LOW, "jacket battery low", 0, 0 },
328 { TOSA_GPIO_JACKET_DETECT, "jacket detect", 0, 0 },
329};
330
331#ifdef CONFIG_PM
332static int tosa_bat_suspend(struct platform_device *dev, pm_message_t state)
333{
334 /* flush all pending status updates */
335 flush_scheduled_work();
336 return 0;
337}
338
339static int tosa_bat_resume(struct platform_device *dev)
340{
341 /* things may have changed while we were away */
342 schedule_work(&bat_work);
343 return 0;
344}
345#else
346#define tosa_bat_suspend NULL
347#define tosa_bat_resume NULL
348#endif
349
350static int __devinit tosa_bat_probe(struct platform_device *dev)
351{
352 int ret;
353 int i;
354
355 if (!machine_is_tosa())
356 return -ENODEV;
357
358 for (i = 0; i < ARRAY_SIZE(gpios); i++) {
359 ret = gpio_request(gpios[i].gpio, gpios[i].name);
360 if (ret) {
361 i--;
362 goto err_gpio;
363 }
364
365 if (gpios[i].output)
366 ret = gpio_direction_output(gpios[i].gpio,
367 gpios[i].value);
368 else
369 ret = gpio_direction_input(gpios[i].gpio);
370
371 if (ret)
372 goto err_gpio;
373 }
374
375 mutex_init(&tosa_bat_main.work_lock);
376 mutex_init(&tosa_bat_jacket.work_lock);
377
378 INIT_WORK(&bat_work, tosa_bat_work);
379
380 ret = power_supply_register(&dev->dev, &tosa_bat_main.psy);
381 if (ret)
382 goto err_psy_reg_main;
383 ret = power_supply_register(&dev->dev, &tosa_bat_jacket.psy);
384 if (ret)
385 goto err_psy_reg_jacket;
386 ret = power_supply_register(&dev->dev, &tosa_bat_bu.psy);
387 if (ret)
388 goto err_psy_reg_bu;
389
390 ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG),
391 tosa_bat_gpio_isr,
392 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
393 "main full", &tosa_bat_main);
394 if (ret)
395 goto err_req_main;
396
397 ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT1_CRG),
398 tosa_bat_gpio_isr,
399 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
400 "jacket full", &tosa_bat_jacket);
401 if (ret)
402 goto err_req_jacket;
403
404 ret = request_irq(gpio_to_irq(TOSA_GPIO_JACKET_DETECT),
405 tosa_bat_gpio_isr,
406 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
407 "jacket detect", &tosa_bat_jacket);
408 if (!ret) {
409 schedule_work(&bat_work);
410 return 0;
411 }
412
413 free_irq(gpio_to_irq(TOSA_GPIO_BAT1_CRG), &tosa_bat_jacket);
414err_req_jacket:
415 free_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG), &tosa_bat_main);
416err_req_main:
417 power_supply_unregister(&tosa_bat_bu.psy);
418err_psy_reg_bu:
419 power_supply_unregister(&tosa_bat_jacket.psy);
420err_psy_reg_jacket:
421 power_supply_unregister(&tosa_bat_main.psy);
422err_psy_reg_main:
423
424 /* see comment in tosa_bat_remove */
425 flush_scheduled_work();
426
427 i--;
428err_gpio:
429 for (; i >= 0; i--)
430 gpio_free(gpios[i].gpio);
431
432 return ret;
433}
434
435static int __devexit tosa_bat_remove(struct platform_device *dev)
436{
437 int i;
438
439 free_irq(gpio_to_irq(TOSA_GPIO_JACKET_DETECT), &tosa_bat_jacket);
440 free_irq(gpio_to_irq(TOSA_GPIO_BAT1_CRG), &tosa_bat_jacket);
441 free_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG), &tosa_bat_main);
442
443 power_supply_unregister(&tosa_bat_bu.psy);
444 power_supply_unregister(&tosa_bat_jacket.psy);
445 power_supply_unregister(&tosa_bat_main.psy);
446
447 /*
448 * now flush all pending work.
449 * we won't get any more schedules, since all
450 * sources (isr and external_power_changed)
451 * are unregistered now.
452 */
453 flush_scheduled_work();
454
455 for (i = ARRAY_SIZE(gpios) - 1; i >= 0; i--)
456 gpio_free(gpios[i].gpio);
457
458 return 0;
459}
460
461static struct platform_driver tosa_bat_driver = {
462 .driver.name = "wm97xx-battery",
463 .driver.owner = THIS_MODULE,
464 .probe = tosa_bat_probe,
465 .remove = __devexit_p(tosa_bat_remove),
466 .suspend = tosa_bat_suspend,
467 .resume = tosa_bat_resume,
468};
469
470static int __init tosa_bat_init(void)
471{
472 return platform_driver_register(&tosa_bat_driver);
473}
474
475static void __exit tosa_bat_exit(void)
476{
477 platform_driver_unregister(&tosa_bat_driver);
478}
479
480module_init(tosa_bat_init);
481module_exit(tosa_bat_exit);
482
483MODULE_LICENSE("GPL");
484MODULE_AUTHOR("Dmitry Baryshkov");
485MODULE_DESCRIPTION("Tosa battery driver");
486MODULE_ALIAS("platform:wm97xx-battery");
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
new file mode 100644
index 000000000000..a656128f1fdd
--- /dev/null
+++ b/drivers/regulator/Kconfig
@@ -0,0 +1,59 @@
1menu "Voltage and Current regulators"
2
3config REGULATOR
4 bool "Voltage and Current Regulator Support"
5 default n
6 help
7 Generic Voltage and Current Regulator support.
8
9 This framework is designed to provide a generic interface to voltage
10 and current regulators within the Linux kernel. It's intended to
11 provide voltage and current control to client or consumer drivers and
12 also provide status information to user space applications through a
13 sysfs interface.
14
15 The intention is to allow systems to dynamically control regulator
16 output in order to save power and prolong battery life. This applies
17 to both voltage regulators (where voltage output is controllable) and
18 current sinks (where current output is controllable).
19
20 This framework safely compiles out if not selected so that client
21 drivers can still be used in systems with no software controllable
22 regulators.
23
24 If unsure, say no.
25
26config REGULATOR_DEBUG
27 bool "Regulator debug support"
28 depends on REGULATOR
29 help
30 Say yes here to enable debugging support.
31
32config REGULATOR_FIXED_VOLTAGE
33 tristate
34 default n
35 select REGULATOR
36
37config REGULATOR_VIRTUAL_CONSUMER
38 tristate "Virtual regulator consumer support"
39 default n
40 select REGULATOR
41 help
42 This driver provides a virtual consumer for the voltage and
43 current regulator API which provides sysfs controls for
44 configuring the supplies requested. This is mainly useful
45 for test purposes.
46
47 If unsure, say no.
48
49config REGULATOR_BQ24022
50 tristate "TI bq24022 Dual Input 1-Cell Li-Ion Charger IC"
51 default n
52 select REGULATOR
53 help
54 This driver controls a TI bq24022 Charger attached via
55 GPIOs. The provided current regulator can enable/disable
56 charging select between 100 mA and 500 mA charging current
57 limit.
58
59endmenu
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
new file mode 100644
index 000000000000..ac2c64efe65c
--- /dev/null
+++ b/drivers/regulator/Makefile
@@ -0,0 +1,12 @@
1#
2# Makefile for regulator drivers.
3#
4
5
6obj-$(CONFIG_REGULATOR) += core.o
7obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
8obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
9
10obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
11
12ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c
new file mode 100644
index 000000000000..263699d6152d
--- /dev/null
+++ b/drivers/regulator/bq24022.c
@@ -0,0 +1,167 @@
1/*
2 * Support for TI bq24022 (bqTINY-II) Dual Input (USB/AC Adpater)
3 * 1-Cell Li-Ion Charger connected via GPIOs.
4 *
5 * Copyright (c) 2008 Philipp Zabel
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/err.h>
17#include <linux/gpio.h>
18#include <linux/regulator/bq24022.h>
19#include <linux/regulator/driver.h>
20
21static int bq24022_set_current_limit(struct regulator_dev *rdev,
22 int min_uA, int max_uA)
23{
24 struct platform_device *pdev = rdev_get_drvdata(rdev);
25 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
26
27 dev_dbg(&pdev->dev, "setting current limit to %s mA\n",
28 max_uA >= 500000 ? "500" : "100");
29
30 /* REVISIT: maybe return error if min_uA != 0 ? */
31 gpio_set_value(pdata->gpio_iset2, max_uA >= 500000);
32 return 0;
33}
34
35static int bq24022_get_current_limit(struct regulator_dev *rdev)
36{
37 struct platform_device *pdev = rdev_get_drvdata(rdev);
38 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
39
40 return gpio_get_value(pdata->gpio_iset2) ? 500000 : 100000;
41}
42
43static int bq24022_enable(struct regulator_dev *rdev)
44{
45 struct platform_device *pdev = rdev_get_drvdata(rdev);
46 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
47
48 dev_dbg(&pdev->dev, "enabling charger\n");
49
50 gpio_set_value(pdata->gpio_nce, 0);
51 return 0;
52}
53
54static int bq24022_disable(struct regulator_dev *rdev)
55{
56 struct platform_device *pdev = rdev_get_drvdata(rdev);
57 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
58
59 dev_dbg(&pdev->dev, "disabling charger\n");
60
61 gpio_set_value(pdata->gpio_nce, 1);
62 return 0;
63}
64
65static int bq24022_is_enabled(struct regulator_dev *rdev)
66{
67 struct platform_device *pdev = rdev_get_drvdata(rdev);
68 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
69
70 return !gpio_get_value(pdata->gpio_nce);
71}
72
73static struct regulator_ops bq24022_ops = {
74 .set_current_limit = bq24022_set_current_limit,
75 .get_current_limit = bq24022_get_current_limit,
76 .enable = bq24022_enable,
77 .disable = bq24022_disable,
78 .is_enabled = bq24022_is_enabled,
79};
80
81static struct regulator_desc bq24022_desc = {
82 .name = "bq24022",
83 .ops = &bq24022_ops,
84 .type = REGULATOR_CURRENT,
85};
86
87static int __init bq24022_probe(struct platform_device *pdev)
88{
89 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
90 struct regulator_dev *bq24022;
91 int ret;
92
93 if (!pdata || !pdata->gpio_nce || !pdata->gpio_iset2)
94 return -EINVAL;
95
96 ret = gpio_request(pdata->gpio_nce, "ncharge_en");
97 if (ret) {
98 dev_dbg(&pdev->dev, "couldn't request nCE GPIO: %d\n",
99 pdata->gpio_nce);
100 goto err_ce;
101 }
102 ret = gpio_request(pdata->gpio_iset2, "charge_mode");
103 if (ret) {
104 dev_dbg(&pdev->dev, "couldn't request ISET2 GPIO: %d\n",
105 pdata->gpio_iset2);
106 goto err_iset2;
107 }
108 ret = gpio_direction_output(pdata->gpio_iset2, 0);
109 ret = gpio_direction_output(pdata->gpio_nce, 1);
110
111 bq24022 = regulator_register(&bq24022_desc, pdev);
112 if (IS_ERR(bq24022)) {
113 dev_dbg(&pdev->dev, "couldn't register regulator\n");
114 ret = PTR_ERR(bq24022);
115 goto err_reg;
116 }
117 platform_set_drvdata(pdev, bq24022);
118 dev_dbg(&pdev->dev, "registered regulator\n");
119
120 return 0;
121err_reg:
122 gpio_free(pdata->gpio_iset2);
123err_iset2:
124 gpio_free(pdata->gpio_nce);
125err_ce:
126 return ret;
127}
128
129static int __devexit bq24022_remove(struct platform_device *pdev)
130{
131 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
132 struct regulator_dev *bq24022 = platform_get_drvdata(pdev);
133
134 regulator_unregister(bq24022);
135 gpio_free(pdata->gpio_iset2);
136 gpio_free(pdata->gpio_nce);
137
138 return 0;
139}
140
141static struct platform_driver bq24022_driver = {
142 .driver = {
143 .name = "bq24022",
144 },
145 .remove = __devexit_p(bq24022_remove),
146};
147
148static int __init bq24022_init(void)
149{
150 return platform_driver_probe(&bq24022_driver, bq24022_probe);
151}
152
153static void __exit bq24022_exit(void)
154{
155 platform_driver_unregister(&bq24022_driver);
156}
157
158/*
159 * make sure this is probed before gpio_vbus and pda_power,
160 * but after asic3 or other GPIO expander drivers.
161 */
162subsys_initcall(bq24022_init);
163module_exit(bq24022_exit);
164
165MODULE_AUTHOR("Philipp Zabel");
166MODULE_DESCRIPTION("TI bq24022 Li-Ion Charger driver");
167MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
new file mode 100644
index 000000000000..9c7986261568
--- /dev/null
+++ b/drivers/regulator/core.c
@@ -0,0 +1,1903 @@
1/*
2 * core.c -- Voltage/Current Regulator framework.
3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/device.h>
18#include <linux/err.h>
19#include <linux/mutex.h>
20#include <linux/suspend.h>
21#include <linux/regulator/consumer.h>
22#include <linux/regulator/driver.h>
23#include <linux/regulator/machine.h>
24
25#define REGULATOR_VERSION "0.5"
26
27static DEFINE_MUTEX(regulator_list_mutex);
28static LIST_HEAD(regulator_list);
29static LIST_HEAD(regulator_map_list);
30
31/**
32 * struct regulator_dev
33 *
34 * Voltage / Current regulator class device. One for each regulator.
35 */
36struct regulator_dev {
37 struct regulator_desc *desc;
38 int use_count;
39
40 /* lists we belong to */
41 struct list_head list; /* list of all regulators */
42 struct list_head slist; /* list of supplied regulators */
43
44 /* lists we own */
45 struct list_head consumer_list; /* consumers we supply */
46 struct list_head supply_list; /* regulators we supply */
47
48 struct blocking_notifier_head notifier;
49 struct mutex mutex; /* consumer lock */
50 struct module *owner;
51 struct device dev;
52 struct regulation_constraints *constraints;
53 struct regulator_dev *supply; /* for tree */
54
55 void *reg_data; /* regulator_dev data */
56};
57
58/**
59 * struct regulator_map
60 *
61 * Used to provide symbolic supply names to devices.
62 */
63struct regulator_map {
64 struct list_head list;
65 struct device *dev;
66 const char *supply;
67 const char *regulator;
68};
69
70static inline struct regulator_dev *to_rdev(struct device *d)
71{
72 return container_of(d, struct regulator_dev, dev);
73}
74
75/*
76 * struct regulator
77 *
78 * One for each consumer device.
79 */
80struct regulator {
81 struct device *dev;
82 struct list_head list;
83 int uA_load;
84 int min_uV;
85 int max_uV;
86 int enabled; /* client has called enabled */
87 char *supply_name;
88 struct device_attribute dev_attr;
89 struct regulator_dev *rdev;
90};
91
92static int _regulator_is_enabled(struct regulator_dev *rdev);
93static int _regulator_disable(struct regulator_dev *rdev);
94static int _regulator_get_voltage(struct regulator_dev *rdev);
95static int _regulator_get_current_limit(struct regulator_dev *rdev);
96static unsigned int _regulator_get_mode(struct regulator_dev *rdev);
97static void _notifier_call_chain(struct regulator_dev *rdev,
98 unsigned long event, void *data);
99
100/* gets the regulator for a given consumer device */
101static struct regulator *get_device_regulator(struct device *dev)
102{
103 struct regulator *regulator = NULL;
104 struct regulator_dev *rdev;
105
106 mutex_lock(&regulator_list_mutex);
107 list_for_each_entry(rdev, &regulator_list, list) {
108 mutex_lock(&rdev->mutex);
109 list_for_each_entry(regulator, &rdev->consumer_list, list) {
110 if (regulator->dev == dev) {
111 mutex_unlock(&rdev->mutex);
112 mutex_unlock(&regulator_list_mutex);
113 return regulator;
114 }
115 }
116 mutex_unlock(&rdev->mutex);
117 }
118 mutex_unlock(&regulator_list_mutex);
119 return NULL;
120}
121
122/* Platform voltage constraint check */
123static int regulator_check_voltage(struct regulator_dev *rdev,
124 int *min_uV, int *max_uV)
125{
126 BUG_ON(*min_uV > *max_uV);
127
128 if (!rdev->constraints) {
129 printk(KERN_ERR "%s: no constraints for %s\n", __func__,
130 rdev->desc->name);
131 return -ENODEV;
132 }
133 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
134 printk(KERN_ERR "%s: operation not allowed for %s\n",
135 __func__, rdev->desc->name);
136 return -EPERM;
137 }
138
139 if (*max_uV > rdev->constraints->max_uV)
140 *max_uV = rdev->constraints->max_uV;
141 if (*min_uV < rdev->constraints->min_uV)
142 *min_uV = rdev->constraints->min_uV;
143
144 if (*min_uV > *max_uV)
145 return -EINVAL;
146
147 return 0;
148}
149
150/* current constraint check */
151static int regulator_check_current_limit(struct regulator_dev *rdev,
152 int *min_uA, int *max_uA)
153{
154 BUG_ON(*min_uA > *max_uA);
155
156 if (!rdev->constraints) {
157 printk(KERN_ERR "%s: no constraints for %s\n", __func__,
158 rdev->desc->name);
159 return -ENODEV;
160 }
161 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_CURRENT)) {
162 printk(KERN_ERR "%s: operation not allowed for %s\n",
163 __func__, rdev->desc->name);
164 return -EPERM;
165 }
166
167 if (*max_uA > rdev->constraints->max_uA)
168 *max_uA = rdev->constraints->max_uA;
169 if (*min_uA < rdev->constraints->min_uA)
170 *min_uA = rdev->constraints->min_uA;
171
172 if (*min_uA > *max_uA)
173 return -EINVAL;
174
175 return 0;
176}
177
178/* operating mode constraint check */
179static int regulator_check_mode(struct regulator_dev *rdev, int mode)
180{
181 if (!rdev->constraints) {
182 printk(KERN_ERR "%s: no constraints for %s\n", __func__,
183 rdev->desc->name);
184 return -ENODEV;
185 }
186 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_MODE)) {
187 printk(KERN_ERR "%s: operation not allowed for %s\n",
188 __func__, rdev->desc->name);
189 return -EPERM;
190 }
191 if (!(rdev->constraints->valid_modes_mask & mode)) {
192 printk(KERN_ERR "%s: invalid mode %x for %s\n",
193 __func__, mode, rdev->desc->name);
194 return -EINVAL;
195 }
196 return 0;
197}
198
199/* dynamic regulator mode switching constraint check */
200static int regulator_check_drms(struct regulator_dev *rdev)
201{
202 if (!rdev->constraints) {
203 printk(KERN_ERR "%s: no constraints for %s\n", __func__,
204 rdev->desc->name);
205 return -ENODEV;
206 }
207 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_DRMS)) {
208 printk(KERN_ERR "%s: operation not allowed for %s\n",
209 __func__, rdev->desc->name);
210 return -EPERM;
211 }
212 return 0;
213}
214
215static ssize_t device_requested_uA_show(struct device *dev,
216 struct device_attribute *attr, char *buf)
217{
218 struct regulator *regulator;
219
220 regulator = get_device_regulator(dev);
221 if (regulator == NULL)
222 return 0;
223
224 return sprintf(buf, "%d\n", regulator->uA_load);
225}
226
227static ssize_t regulator_uV_show(struct device *dev,
228 struct device_attribute *attr, char *buf)
229{
230 struct regulator_dev *rdev = to_rdev(dev);
231 ssize_t ret;
232
233 mutex_lock(&rdev->mutex);
234 ret = sprintf(buf, "%d\n", _regulator_get_voltage(rdev));
235 mutex_unlock(&rdev->mutex);
236
237 return ret;
238}
239
240static ssize_t regulator_uA_show(struct device *dev,
241 struct device_attribute *attr, char *buf)
242{
243 struct regulator_dev *rdev = to_rdev(dev);
244
245 return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev));
246}
247
248static ssize_t regulator_opmode_show(struct device *dev,
249 struct device_attribute *attr, char *buf)
250{
251 struct regulator_dev *rdev = to_rdev(dev);
252 int mode = _regulator_get_mode(rdev);
253
254 switch (mode) {
255 case REGULATOR_MODE_FAST:
256 return sprintf(buf, "fast\n");
257 case REGULATOR_MODE_NORMAL:
258 return sprintf(buf, "normal\n");
259 case REGULATOR_MODE_IDLE:
260 return sprintf(buf, "idle\n");
261 case REGULATOR_MODE_STANDBY:
262 return sprintf(buf, "standby\n");
263 }
264 return sprintf(buf, "unknown\n");
265}
266
267static ssize_t regulator_state_show(struct device *dev,
268 struct device_attribute *attr, char *buf)
269{
270 struct regulator_dev *rdev = to_rdev(dev);
271 int state = _regulator_is_enabled(rdev);
272
273 if (state > 0)
274 return sprintf(buf, "enabled\n");
275 else if (state == 0)
276 return sprintf(buf, "disabled\n");
277 else
278 return sprintf(buf, "unknown\n");
279}
280
281static ssize_t regulator_min_uA_show(struct device *dev,
282 struct device_attribute *attr, char *buf)
283{
284 struct regulator_dev *rdev = to_rdev(dev);
285
286 if (!rdev->constraints)
287 return sprintf(buf, "constraint not defined\n");
288
289 return sprintf(buf, "%d\n", rdev->constraints->min_uA);
290}
291
292static ssize_t regulator_max_uA_show(struct device *dev,
293 struct device_attribute *attr, char *buf)
294{
295 struct regulator_dev *rdev = to_rdev(dev);
296
297 if (!rdev->constraints)
298 return sprintf(buf, "constraint not defined\n");
299
300 return sprintf(buf, "%d\n", rdev->constraints->max_uA);
301}
302
303static ssize_t regulator_min_uV_show(struct device *dev,
304 struct device_attribute *attr, char *buf)
305{
306 struct regulator_dev *rdev = to_rdev(dev);
307
308 if (!rdev->constraints)
309 return sprintf(buf, "constraint not defined\n");
310
311 return sprintf(buf, "%d\n", rdev->constraints->min_uV);
312}
313
314static ssize_t regulator_max_uV_show(struct device *dev,
315 struct device_attribute *attr, char *buf)
316{
317 struct regulator_dev *rdev = to_rdev(dev);
318
319 if (!rdev->constraints)
320 return sprintf(buf, "constraint not defined\n");
321
322 return sprintf(buf, "%d\n", rdev->constraints->max_uV);
323}
324
325static ssize_t regulator_total_uA_show(struct device *dev,
326 struct device_attribute *attr, char *buf)
327{
328 struct regulator_dev *rdev = to_rdev(dev);
329 struct regulator *regulator;
330 int uA = 0;
331
332 mutex_lock(&rdev->mutex);
333 list_for_each_entry(regulator, &rdev->consumer_list, list)
334 uA += regulator->uA_load;
335 mutex_unlock(&rdev->mutex);
336 return sprintf(buf, "%d\n", uA);
337}
338
339static ssize_t regulator_num_users_show(struct device *dev,
340 struct device_attribute *attr, char *buf)
341{
342 struct regulator_dev *rdev = to_rdev(dev);
343 return sprintf(buf, "%d\n", rdev->use_count);
344}
345
346static ssize_t regulator_type_show(struct device *dev,
347 struct device_attribute *attr, char *buf)
348{
349 struct regulator_dev *rdev = to_rdev(dev);
350
351 switch (rdev->desc->type) {
352 case REGULATOR_VOLTAGE:
353 return sprintf(buf, "voltage\n");
354 case REGULATOR_CURRENT:
355 return sprintf(buf, "current\n");
356 }
357 return sprintf(buf, "unknown\n");
358}
359
360static ssize_t regulator_suspend_mem_uV_show(struct device *dev,
361 struct device_attribute *attr, char *buf)
362{
363 struct regulator_dev *rdev = to_rdev(dev);
364
365 if (!rdev->constraints)
366 return sprintf(buf, "not defined\n");
367 return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV);
368}
369
370static ssize_t regulator_suspend_disk_uV_show(struct device *dev,
371 struct device_attribute *attr, char *buf)
372{
373 struct regulator_dev *rdev = to_rdev(dev);
374
375 if (!rdev->constraints)
376 return sprintf(buf, "not defined\n");
377 return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV);
378}
379
380static ssize_t regulator_suspend_standby_uV_show(struct device *dev,
381 struct device_attribute *attr, char *buf)
382{
383 struct regulator_dev *rdev = to_rdev(dev);
384
385 if (!rdev->constraints)
386 return sprintf(buf, "not defined\n");
387 return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV);
388}
389
390static ssize_t suspend_opmode_show(struct regulator_dev *rdev,
391 unsigned int mode, char *buf)
392{
393 switch (mode) {
394 case REGULATOR_MODE_FAST:
395 return sprintf(buf, "fast\n");
396 case REGULATOR_MODE_NORMAL:
397 return sprintf(buf, "normal\n");
398 case REGULATOR_MODE_IDLE:
399 return sprintf(buf, "idle\n");
400 case REGULATOR_MODE_STANDBY:
401 return sprintf(buf, "standby\n");
402 }
403 return sprintf(buf, "unknown\n");
404}
405
406static ssize_t regulator_suspend_mem_mode_show(struct device *dev,
407 struct device_attribute *attr, char *buf)
408{
409 struct regulator_dev *rdev = to_rdev(dev);
410
411 if (!rdev->constraints)
412 return sprintf(buf, "not defined\n");
413 return suspend_opmode_show(rdev,
414 rdev->constraints->state_mem.mode, buf);
415}
416
417static ssize_t regulator_suspend_disk_mode_show(struct device *dev,
418 struct device_attribute *attr, char *buf)
419{
420 struct regulator_dev *rdev = to_rdev(dev);
421
422 if (!rdev->constraints)
423 return sprintf(buf, "not defined\n");
424 return suspend_opmode_show(rdev,
425 rdev->constraints->state_disk.mode, buf);
426}
427
428static ssize_t regulator_suspend_standby_mode_show(struct device *dev,
429 struct device_attribute *attr, char *buf)
430{
431 struct regulator_dev *rdev = to_rdev(dev);
432
433 if (!rdev->constraints)
434 return sprintf(buf, "not defined\n");
435 return suspend_opmode_show(rdev,
436 rdev->constraints->state_standby.mode, buf);
437}
438
439static ssize_t regulator_suspend_mem_state_show(struct device *dev,
440 struct device_attribute *attr, char *buf)
441{
442 struct regulator_dev *rdev = to_rdev(dev);
443
444 if (!rdev->constraints)
445 return sprintf(buf, "not defined\n");
446
447 if (rdev->constraints->state_mem.enabled)
448 return sprintf(buf, "enabled\n");
449 else
450 return sprintf(buf, "disabled\n");
451}
452
453static ssize_t regulator_suspend_disk_state_show(struct device *dev,
454 struct device_attribute *attr, char *buf)
455{
456 struct regulator_dev *rdev = to_rdev(dev);
457
458 if (!rdev->constraints)
459 return sprintf(buf, "not defined\n");
460
461 if (rdev->constraints->state_disk.enabled)
462 return sprintf(buf, "enabled\n");
463 else
464 return sprintf(buf, "disabled\n");
465}
466
467static ssize_t regulator_suspend_standby_state_show(struct device *dev,
468 struct device_attribute *attr, char *buf)
469{
470 struct regulator_dev *rdev = to_rdev(dev);
471
472 if (!rdev->constraints)
473 return sprintf(buf, "not defined\n");
474
475 if (rdev->constraints->state_standby.enabled)
476 return sprintf(buf, "enabled\n");
477 else
478 return sprintf(buf, "disabled\n");
479}
480static struct device_attribute regulator_dev_attrs[] = {
481 __ATTR(microvolts, 0444, regulator_uV_show, NULL),
482 __ATTR(microamps, 0444, regulator_uA_show, NULL),
483 __ATTR(opmode, 0444, regulator_opmode_show, NULL),
484 __ATTR(state, 0444, regulator_state_show, NULL),
485 __ATTR(min_microvolts, 0444, regulator_min_uV_show, NULL),
486 __ATTR(min_microamps, 0444, regulator_min_uA_show, NULL),
487 __ATTR(max_microvolts, 0444, regulator_max_uV_show, NULL),
488 __ATTR(max_microamps, 0444, regulator_max_uA_show, NULL),
489 __ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL),
490 __ATTR(num_users, 0444, regulator_num_users_show, NULL),
491 __ATTR(type, 0444, regulator_type_show, NULL),
492 __ATTR(suspend_mem_microvolts, 0444,
493 regulator_suspend_mem_uV_show, NULL),
494 __ATTR(suspend_disk_microvolts, 0444,
495 regulator_suspend_disk_uV_show, NULL),
496 __ATTR(suspend_standby_microvolts, 0444,
497 regulator_suspend_standby_uV_show, NULL),
498 __ATTR(suspend_mem_mode, 0444,
499 regulator_suspend_mem_mode_show, NULL),
500 __ATTR(suspend_disk_mode, 0444,
501 regulator_suspend_disk_mode_show, NULL),
502 __ATTR(suspend_standby_mode, 0444,
503 regulator_suspend_standby_mode_show, NULL),
504 __ATTR(suspend_mem_state, 0444,
505 regulator_suspend_mem_state_show, NULL),
506 __ATTR(suspend_disk_state, 0444,
507 regulator_suspend_disk_state_show, NULL),
508 __ATTR(suspend_standby_state, 0444,
509 regulator_suspend_standby_state_show, NULL),
510 __ATTR_NULL,
511};
512
513static void regulator_dev_release(struct device *dev)
514{
515 struct regulator_dev *rdev = to_rdev(dev);
516 kfree(rdev);
517}
518
519static struct class regulator_class = {
520 .name = "regulator",
521 .dev_release = regulator_dev_release,
522 .dev_attrs = regulator_dev_attrs,
523};
524
525/* Calculate the new optimum regulator operating mode based on the new total
526 * consumer load. All locks held by caller */
527static void drms_uA_update(struct regulator_dev *rdev)
528{
529 struct regulator *sibling;
530 int current_uA = 0, output_uV, input_uV, err;
531 unsigned int mode;
532
533 err = regulator_check_drms(rdev);
534 if (err < 0 || !rdev->desc->ops->get_optimum_mode ||
535 !rdev->desc->ops->get_voltage || !rdev->desc->ops->set_mode);
536 return;
537
538 /* get output voltage */
539 output_uV = rdev->desc->ops->get_voltage(rdev);
540 if (output_uV <= 0)
541 return;
542
543 /* get input voltage */
544 if (rdev->supply && rdev->supply->desc->ops->get_voltage)
545 input_uV = rdev->supply->desc->ops->get_voltage(rdev->supply);
546 else
547 input_uV = rdev->constraints->input_uV;
548 if (input_uV <= 0)
549 return;
550
551 /* calc total requested load */
552 list_for_each_entry(sibling, &rdev->consumer_list, list)
553 current_uA += sibling->uA_load;
554
555 /* now get the optimum mode for our new total regulator load */
556 mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV,
557 output_uV, current_uA);
558
559 /* check the new mode is allowed */
560 err = regulator_check_mode(rdev, mode);
561 if (err == 0)
562 rdev->desc->ops->set_mode(rdev, mode);
563}
564
565static int suspend_set_state(struct regulator_dev *rdev,
566 struct regulator_state *rstate)
567{
568 int ret = 0;
569
570 /* enable & disable are mandatory for suspend control */
571 if (!rdev->desc->ops->set_suspend_enable ||
572 !rdev->desc->ops->set_suspend_disable)
573 return -EINVAL;
574
575 if (rstate->enabled)
576 ret = rdev->desc->ops->set_suspend_enable(rdev);
577 else
578 ret = rdev->desc->ops->set_suspend_disable(rdev);
579 if (ret < 0) {
580 printk(KERN_ERR "%s: failed to enabled/disable\n", __func__);
581 return ret;
582 }
583
584 if (rdev->desc->ops->set_suspend_voltage && rstate->uV > 0) {
585 ret = rdev->desc->ops->set_suspend_voltage(rdev, rstate->uV);
586 if (ret < 0) {
587 printk(KERN_ERR "%s: failed to set voltage\n",
588 __func__);
589 return ret;
590 }
591 }
592
593 if (rdev->desc->ops->set_suspend_mode && rstate->mode > 0) {
594 ret = rdev->desc->ops->set_suspend_mode(rdev, rstate->mode);
595 if (ret < 0) {
596 printk(KERN_ERR "%s: failed to set mode\n", __func__);
597 return ret;
598 }
599 }
600 return ret;
601}
602
603/* locks held by caller */
604static int suspend_prepare(struct regulator_dev *rdev, suspend_state_t state)
605{
606 if (!rdev->constraints)
607 return -EINVAL;
608
609 switch (state) {
610 case PM_SUSPEND_STANDBY:
611 return suspend_set_state(rdev,
612 &rdev->constraints->state_standby);
613 case PM_SUSPEND_MEM:
614 return suspend_set_state(rdev,
615 &rdev->constraints->state_mem);
616 case PM_SUSPEND_MAX:
617 return suspend_set_state(rdev,
618 &rdev->constraints->state_disk);
619 default:
620 return -EINVAL;
621 }
622}
623
624static void print_constraints(struct regulator_dev *rdev)
625{
626 struct regulation_constraints *constraints = rdev->constraints;
627 char buf[80];
628 int count;
629
630 if (rdev->desc->type == REGULATOR_VOLTAGE) {
631 if (constraints->min_uV == constraints->max_uV)
632 count = sprintf(buf, "%d mV ",
633 constraints->min_uV / 1000);
634 else
635 count = sprintf(buf, "%d <--> %d mV ",
636 constraints->min_uV / 1000,
637 constraints->max_uV / 1000);
638 } else {
639 if (constraints->min_uA == constraints->max_uA)
640 count = sprintf(buf, "%d mA ",
641 constraints->min_uA / 1000);
642 else
643 count = sprintf(buf, "%d <--> %d mA ",
644 constraints->min_uA / 1000,
645 constraints->max_uA / 1000);
646 }
647 if (constraints->valid_modes_mask & REGULATOR_MODE_FAST)
648 count += sprintf(buf + count, "fast ");
649 if (constraints->valid_modes_mask & REGULATOR_MODE_NORMAL)
650 count += sprintf(buf + count, "normal ");
651 if (constraints->valid_modes_mask & REGULATOR_MODE_IDLE)
652 count += sprintf(buf + count, "idle ");
653 if (constraints->valid_modes_mask & REGULATOR_MODE_STANDBY)
654 count += sprintf(buf + count, "standby");
655
656 printk(KERN_INFO "regulator: %s: %s\n", rdev->desc->name, buf);
657}
658
659#define REG_STR_SIZE 32
660
661static struct regulator *create_regulator(struct regulator_dev *rdev,
662 struct device *dev,
663 const char *supply_name)
664{
665 struct regulator *regulator;
666 char buf[REG_STR_SIZE];
667 int err, size;
668
669 regulator = kzalloc(sizeof(*regulator), GFP_KERNEL);
670 if (regulator == NULL)
671 return NULL;
672
673 mutex_lock(&rdev->mutex);
674 regulator->rdev = rdev;
675 list_add(&regulator->list, &rdev->consumer_list);
676
677 if (dev) {
678 /* create a 'requested_microamps_name' sysfs entry */
679 size = scnprintf(buf, REG_STR_SIZE, "microamps_requested_%s",
680 supply_name);
681 if (size >= REG_STR_SIZE)
682 goto overflow_err;
683
684 regulator->dev = dev;
685 regulator->dev_attr.attr.name = kstrdup(buf, GFP_KERNEL);
686 if (regulator->dev_attr.attr.name == NULL)
687 goto attr_name_err;
688
689 regulator->dev_attr.attr.owner = THIS_MODULE;
690 regulator->dev_attr.attr.mode = 0444;
691 regulator->dev_attr.show = device_requested_uA_show;
692 err = device_create_file(dev, &regulator->dev_attr);
693 if (err < 0) {
694 printk(KERN_WARNING "%s: could not add regulator_dev"
695 " load sysfs\n", __func__);
696 goto attr_name_err;
697 }
698
699 /* also add a link to the device sysfs entry */
700 size = scnprintf(buf, REG_STR_SIZE, "%s-%s",
701 dev->kobj.name, supply_name);
702 if (size >= REG_STR_SIZE)
703 goto attr_err;
704
705 regulator->supply_name = kstrdup(buf, GFP_KERNEL);
706 if (regulator->supply_name == NULL)
707 goto attr_err;
708
709 err = sysfs_create_link(&rdev->dev.kobj, &dev->kobj,
710 buf);
711 if (err) {
712 printk(KERN_WARNING
713 "%s: could not add device link %s err %d\n",
714 __func__, dev->kobj.name, err);
715 device_remove_file(dev, &regulator->dev_attr);
716 goto link_name_err;
717 }
718 }
719 mutex_unlock(&rdev->mutex);
720 return regulator;
721link_name_err:
722 kfree(regulator->supply_name);
723attr_err:
724 device_remove_file(regulator->dev, &regulator->dev_attr);
725attr_name_err:
726 kfree(regulator->dev_attr.attr.name);
727overflow_err:
728 list_del(&regulator->list);
729 kfree(regulator);
730 mutex_unlock(&rdev->mutex);
731 return NULL;
732}
733
734/**
735 * regulator_get - lookup and obtain a reference to a regulator.
736 * @dev: device for regulator "consumer"
737 * @id: Supply name or regulator ID.
738 *
739 * Returns a struct regulator corresponding to the regulator producer,
740 * or IS_ERR() condition containing errno. Use of supply names
741 * configured via regulator_set_device_supply() is strongly
742 * encouraged.
743 */
744struct regulator *regulator_get(struct device *dev, const char *id)
745{
746 struct regulator_dev *rdev;
747 struct regulator_map *map;
748 struct regulator *regulator = ERR_PTR(-ENODEV);
749 const char *supply = id;
750
751 if (id == NULL) {
752 printk(KERN_ERR "regulator: get() with no identifier\n");
753 return regulator;
754 }
755
756 mutex_lock(&regulator_list_mutex);
757
758 list_for_each_entry(map, &regulator_map_list, list) {
759 if (dev == map->dev &&
760 strcmp(map->supply, id) == 0) {
761 supply = map->regulator;
762 break;
763 }
764 }
765
766 list_for_each_entry(rdev, &regulator_list, list) {
767 if (strcmp(supply, rdev->desc->name) == 0 &&
768 try_module_get(rdev->owner))
769 goto found;
770 }
771 printk(KERN_ERR "regulator: Unable to get requested regulator: %s\n",
772 id);
773 mutex_unlock(&regulator_list_mutex);
774 return regulator;
775
776found:
777 regulator = create_regulator(rdev, dev, id);
778 if (regulator == NULL) {
779 regulator = ERR_PTR(-ENOMEM);
780 module_put(rdev->owner);
781 }
782
783 mutex_unlock(&regulator_list_mutex);
784 return regulator;
785}
786EXPORT_SYMBOL_GPL(regulator_get);
787
788/**
789 * regulator_put - "free" the regulator source
790 * @regulator: regulator source
791 *
792 * Note: drivers must ensure that all regulator_enable calls made on this
793 * regulator source are balanced by regulator_disable calls prior to calling
794 * this function.
795 */
796void regulator_put(struct regulator *regulator)
797{
798 struct regulator_dev *rdev;
799
800 if (regulator == NULL || IS_ERR(regulator))
801 return;
802
803 if (regulator->enabled) {
804 printk(KERN_WARNING "Releasing supply %s while enabled\n",
805 regulator->supply_name);
806 WARN_ON(regulator->enabled);
807 regulator_disable(regulator);
808 }
809
810 mutex_lock(&regulator_list_mutex);
811 rdev = regulator->rdev;
812
813 /* remove any sysfs entries */
814 if (regulator->dev) {
815 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
816 kfree(regulator->supply_name);
817 device_remove_file(regulator->dev, &regulator->dev_attr);
818 kfree(regulator->dev_attr.attr.name);
819 }
820 list_del(&regulator->list);
821 kfree(regulator);
822
823 module_put(rdev->owner);
824 mutex_unlock(&regulator_list_mutex);
825}
826EXPORT_SYMBOL_GPL(regulator_put);
827
828/* locks held by regulator_enable() */
829static int _regulator_enable(struct regulator_dev *rdev)
830{
831 int ret = -EINVAL;
832
833 if (!rdev->constraints) {
834 printk(KERN_ERR "%s: %s has no constraints\n",
835 __func__, rdev->desc->name);
836 return ret;
837 }
838
839 /* do we need to enable the supply regulator first */
840 if (rdev->supply) {
841 ret = _regulator_enable(rdev->supply);
842 if (ret < 0) {
843 printk(KERN_ERR "%s: failed to enable %s: %d\n",
844 __func__, rdev->desc->name, ret);
845 return ret;
846 }
847 }
848
849 /* check voltage and requested load before enabling */
850 if (rdev->desc->ops->enable) {
851
852 if (rdev->constraints &&
853 (rdev->constraints->valid_ops_mask &
854 REGULATOR_CHANGE_DRMS))
855 drms_uA_update(rdev);
856
857 ret = rdev->desc->ops->enable(rdev);
858 if (ret < 0) {
859 printk(KERN_ERR "%s: failed to enable %s: %d\n",
860 __func__, rdev->desc->name, ret);
861 return ret;
862 }
863 rdev->use_count++;
864 return ret;
865 }
866
867 return ret;
868}
869
870/**
871 * regulator_enable - enable regulator output
872 * @regulator: regulator source
873 *
874 * Enable the regulator output at the predefined voltage or current value.
875 * NOTE: the output value can be set by other drivers, boot loader or may be
876 * hardwired in the regulator.
877 * NOTE: calls to regulator_enable() must be balanced with calls to
878 * regulator_disable().
879 */
880int regulator_enable(struct regulator *regulator)
881{
882 int ret;
883
884 if (regulator->enabled) {
885 printk(KERN_CRIT "Regulator %s already enabled\n",
886 regulator->supply_name);
887 WARN_ON(regulator->enabled);
888 return 0;
889 }
890
891 mutex_lock(&regulator->rdev->mutex);
892 regulator->enabled = 1;
893 ret = _regulator_enable(regulator->rdev);
894 if (ret != 0)
895 regulator->enabled = 0;
896 mutex_unlock(&regulator->rdev->mutex);
897 return ret;
898}
899EXPORT_SYMBOL_GPL(regulator_enable);
900
901/* locks held by regulator_disable() */
902static int _regulator_disable(struct regulator_dev *rdev)
903{
904 int ret = 0;
905
906 /* are we the last user and permitted to disable ? */
907 if (rdev->use_count == 1 && !rdev->constraints->always_on) {
908
909 /* we are last user */
910 if (rdev->desc->ops->disable) {
911 ret = rdev->desc->ops->disable(rdev);
912 if (ret < 0) {
913 printk(KERN_ERR "%s: failed to disable %s\n",
914 __func__, rdev->desc->name);
915 return ret;
916 }
917 }
918
919 /* decrease our supplies ref count and disable if required */
920 if (rdev->supply)
921 _regulator_disable(rdev->supply);
922
923 rdev->use_count = 0;
924 } else if (rdev->use_count > 1) {
925
926 if (rdev->constraints &&
927 (rdev->constraints->valid_ops_mask &
928 REGULATOR_CHANGE_DRMS))
929 drms_uA_update(rdev);
930
931 rdev->use_count--;
932 }
933 return ret;
934}
935
936/**
937 * regulator_disable - disable regulator output
938 * @regulator: regulator source
939 *
940 * Disable the regulator output voltage or current.
941 * NOTE: this will only disable the regulator output if no other consumer
942 * devices have it enabled.
943 * NOTE: calls to regulator_enable() must be balanced with calls to
944 * regulator_disable().
945 */
946int regulator_disable(struct regulator *regulator)
947{
948 int ret;
949
950 if (!regulator->enabled) {
951 printk(KERN_ERR "%s: not in use by this consumer\n",
952 __func__);
953 return 0;
954 }
955
956 mutex_lock(&regulator->rdev->mutex);
957 regulator->enabled = 0;
958 regulator->uA_load = 0;
959 ret = _regulator_disable(regulator->rdev);
960 mutex_unlock(&regulator->rdev->mutex);
961 return ret;
962}
963EXPORT_SYMBOL_GPL(regulator_disable);
964
965/* locks held by regulator_force_disable() */
966static int _regulator_force_disable(struct regulator_dev *rdev)
967{
968 int ret = 0;
969
970 /* force disable */
971 if (rdev->desc->ops->disable) {
972 /* ah well, who wants to live forever... */
973 ret = rdev->desc->ops->disable(rdev);
974 if (ret < 0) {
975 printk(KERN_ERR "%s: failed to force disable %s\n",
976 __func__, rdev->desc->name);
977 return ret;
978 }
979 /* notify other consumers that power has been forced off */
980 _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE,
981 NULL);
982 }
983
984 /* decrease our supplies ref count and disable if required */
985 if (rdev->supply)
986 _regulator_disable(rdev->supply);
987
988 rdev->use_count = 0;
989 return ret;
990}
991
992/**
993 * regulator_force_disable - force disable regulator output
994 * @regulator: regulator source
995 *
996 * Forcibly disable the regulator output voltage or current.
997 * NOTE: this *will* disable the regulator output even if other consumer
998 * devices have it enabled. This should be used for situations when device
999 * damage will likely occur if the regulator is not disabled (e.g. over temp).
1000 */
1001int regulator_force_disable(struct regulator *regulator)
1002{
1003 int ret;
1004
1005 mutex_lock(&regulator->rdev->mutex);
1006 regulator->enabled = 0;
1007 regulator->uA_load = 0;
1008 ret = _regulator_force_disable(regulator->rdev);
1009 mutex_unlock(&regulator->rdev->mutex);
1010 return ret;
1011}
1012EXPORT_SYMBOL_GPL(regulator_force_disable);
1013
1014static int _regulator_is_enabled(struct regulator_dev *rdev)
1015{
1016 int ret;
1017
1018 mutex_lock(&rdev->mutex);
1019
1020 /* sanity check */
1021 if (!rdev->desc->ops->is_enabled) {
1022 ret = -EINVAL;
1023 goto out;
1024 }
1025
1026 ret = rdev->desc->ops->is_enabled(rdev);
1027out:
1028 mutex_unlock(&rdev->mutex);
1029 return ret;
1030}
1031
1032/**
1033 * regulator_is_enabled - is the regulator output enabled
1034 * @regulator: regulator source
1035 *
1036 * Returns zero for disabled otherwise return number of enable requests.
1037 */
1038int regulator_is_enabled(struct regulator *regulator)
1039{
1040 return _regulator_is_enabled(regulator->rdev);
1041}
1042EXPORT_SYMBOL_GPL(regulator_is_enabled);
1043
1044/**
1045 * regulator_set_voltage - set regulator output voltage
1046 * @regulator: regulator source
1047 * @min_uV: Minimum required voltage in uV
1048 * @max_uV: Maximum acceptable voltage in uV
1049 *
1050 * Sets a voltage regulator to the desired output voltage. This can be set
1051 * during any regulator state. IOW, regulator can be disabled or enabled.
1052 *
1053 * If the regulator is enabled then the voltage will change to the new value
1054 * immediately otherwise if the regulator is disabled the regulator will
1055 * output at the new voltage when enabled.
1056 *
1057 * NOTE: If the regulator is shared between several devices then the lowest
1058 * request voltage that meets the system constraints will be used.
1059 * NOTE: Regulator system constraints must be set for this regulator before
1060 * calling this function otherwise this call will fail.
1061 */
1062int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
1063{
1064 struct regulator_dev *rdev = regulator->rdev;
1065 int ret;
1066
1067 mutex_lock(&rdev->mutex);
1068
1069 /* sanity check */
1070 if (!rdev->desc->ops->set_voltage) {
1071 ret = -EINVAL;
1072 goto out;
1073 }
1074
1075 /* constraints check */
1076 ret = regulator_check_voltage(rdev, &min_uV, &max_uV);
1077 if (ret < 0)
1078 goto out;
1079 regulator->min_uV = min_uV;
1080 regulator->max_uV = max_uV;
1081 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV);
1082
1083out:
1084 mutex_unlock(&rdev->mutex);
1085 return ret;
1086}
1087EXPORT_SYMBOL_GPL(regulator_set_voltage);
1088
1089static int _regulator_get_voltage(struct regulator_dev *rdev)
1090{
1091 /* sanity check */
1092 if (rdev->desc->ops->get_voltage)
1093 return rdev->desc->ops->get_voltage(rdev);
1094 else
1095 return -EINVAL;
1096}
1097
1098/**
1099 * regulator_get_voltage - get regulator output voltage
1100 * @regulator: regulator source
1101 *
1102 * This returns the current regulator voltage in uV.
1103 *
1104 * NOTE: If the regulator is disabled it will return the voltage value. This
1105 * function should not be used to determine regulator state.
1106 */
1107int regulator_get_voltage(struct regulator *regulator)
1108{
1109 int ret;
1110
1111 mutex_lock(&regulator->rdev->mutex);
1112
1113 ret = _regulator_get_voltage(regulator->rdev);
1114
1115 mutex_unlock(&regulator->rdev->mutex);
1116
1117 return ret;
1118}
1119EXPORT_SYMBOL_GPL(regulator_get_voltage);
1120
1121/**
1122 * regulator_set_current_limit - set regulator output current limit
1123 * @regulator: regulator source
1124 * @min_uA: Minimuum supported current in uA
1125 * @max_uA: Maximum supported current in uA
1126 *
1127 * Sets current sink to the desired output current. This can be set during
1128 * any regulator state. IOW, regulator can be disabled or enabled.
1129 *
1130 * If the regulator is enabled then the current will change to the new value
1131 * immediately otherwise if the regulator is disabled the regulator will
1132 * output at the new current when enabled.
1133 *
1134 * NOTE: Regulator system constraints must be set for this regulator before
1135 * calling this function otherwise this call will fail.
1136 */
1137int regulator_set_current_limit(struct regulator *regulator,
1138 int min_uA, int max_uA)
1139{
1140 struct regulator_dev *rdev = regulator->rdev;
1141 int ret;
1142
1143 mutex_lock(&rdev->mutex);
1144
1145 /* sanity check */
1146 if (!rdev->desc->ops->set_current_limit) {
1147 ret = -EINVAL;
1148 goto out;
1149 }
1150
1151 /* constraints check */
1152 ret = regulator_check_current_limit(rdev, &min_uA, &max_uA);
1153 if (ret < 0)
1154 goto out;
1155
1156 ret = rdev->desc->ops->set_current_limit(rdev, min_uA, max_uA);
1157out:
1158 mutex_unlock(&rdev->mutex);
1159 return ret;
1160}
1161EXPORT_SYMBOL_GPL(regulator_set_current_limit);
1162
1163static int _regulator_get_current_limit(struct regulator_dev *rdev)
1164{
1165 int ret;
1166
1167 mutex_lock(&rdev->mutex);
1168
1169 /* sanity check */
1170 if (!rdev->desc->ops->get_current_limit) {
1171 ret = -EINVAL;
1172 goto out;
1173 }
1174
1175 ret = rdev->desc->ops->get_current_limit(rdev);
1176out:
1177 mutex_unlock(&rdev->mutex);
1178 return ret;
1179}
1180
1181/**
1182 * regulator_get_current_limit - get regulator output current
1183 * @regulator: regulator source
1184 *
1185 * This returns the current supplied by the specified current sink in uA.
1186 *
1187 * NOTE: If the regulator is disabled it will return the current value. This
1188 * function should not be used to determine regulator state.
1189 */
1190int regulator_get_current_limit(struct regulator *regulator)
1191{
1192 return _regulator_get_current_limit(regulator->rdev);
1193}
1194EXPORT_SYMBOL_GPL(regulator_get_current_limit);
1195
1196/**
1197 * regulator_set_mode - set regulator operating mode
1198 * @regulator: regulator source
1199 * @mode: operating mode - one of the REGULATOR_MODE constants
1200 *
1201 * Set regulator operating mode to increase regulator efficiency or improve
1202 * regulation performance.
1203 *
1204 * NOTE: Regulator system constraints must be set for this regulator before
1205 * calling this function otherwise this call will fail.
1206 */
1207int regulator_set_mode(struct regulator *regulator, unsigned int mode)
1208{
1209 struct regulator_dev *rdev = regulator->rdev;
1210 int ret;
1211
1212 mutex_lock(&rdev->mutex);
1213
1214 /* sanity check */
1215 if (!rdev->desc->ops->set_mode) {
1216 ret = -EINVAL;
1217 goto out;
1218 }
1219
1220 /* constraints check */
1221 ret = regulator_check_mode(rdev, mode);
1222 if (ret < 0)
1223 goto out;
1224
1225 ret = rdev->desc->ops->set_mode(rdev, mode);
1226out:
1227 mutex_unlock(&rdev->mutex);
1228 return ret;
1229}
1230EXPORT_SYMBOL_GPL(regulator_set_mode);
1231
1232static unsigned int _regulator_get_mode(struct regulator_dev *rdev)
1233{
1234 int ret;
1235
1236 mutex_lock(&rdev->mutex);
1237
1238 /* sanity check */
1239 if (!rdev->desc->ops->get_mode) {
1240 ret = -EINVAL;
1241 goto out;
1242 }
1243
1244 ret = rdev->desc->ops->get_mode(rdev);
1245out:
1246 mutex_unlock(&rdev->mutex);
1247 return ret;
1248}
1249
1250/**
1251 * regulator_get_mode - get regulator operating mode
1252 * @regulator: regulator source
1253 *
1254 * Get the current regulator operating mode.
1255 */
1256unsigned int regulator_get_mode(struct regulator *regulator)
1257{
1258 return _regulator_get_mode(regulator->rdev);
1259}
1260EXPORT_SYMBOL_GPL(regulator_get_mode);
1261
1262/**
1263 * regulator_set_optimum_mode - set regulator optimum operating mode
1264 * @regulator: regulator source
1265 * @uA_load: load current
1266 *
1267 * Notifies the regulator core of a new device load. This is then used by
1268 * DRMS (if enabled by constraints) to set the most efficient regulator
1269 * operating mode for the new regulator loading.
1270 *
1271 * Consumer devices notify their supply regulator of the maximum power
1272 * they will require (can be taken from device datasheet in the power
1273 * consumption tables) when they change operational status and hence power
1274 * state. Examples of operational state changes that can affect power
1275 * consumption are :-
1276 *
1277 * o Device is opened / closed.
1278 * o Device I/O is about to begin or has just finished.
1279 * o Device is idling in between work.
1280 *
1281 * This information is also exported via sysfs to userspace.
1282 *
1283 * DRMS will sum the total requested load on the regulator and change
1284 * to the most efficient operating mode if platform constraints allow.
1285 *
1286 * Returns the new regulator mode or error.
1287 */
1288int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
1289{
1290 struct regulator_dev *rdev = regulator->rdev;
1291 struct regulator *consumer;
1292 int ret, output_uV, input_uV, total_uA_load = 0;
1293 unsigned int mode;
1294
1295 mutex_lock(&rdev->mutex);
1296
1297 regulator->uA_load = uA_load;
1298 ret = regulator_check_drms(rdev);
1299 if (ret < 0)
1300 goto out;
1301 ret = -EINVAL;
1302
1303 /* sanity check */
1304 if (!rdev->desc->ops->get_optimum_mode)
1305 goto out;
1306
1307 /* get output voltage */
1308 output_uV = rdev->desc->ops->get_voltage(rdev);
1309 if (output_uV <= 0) {
1310 printk(KERN_ERR "%s: invalid output voltage found for %s\n",
1311 __func__, rdev->desc->name);
1312 goto out;
1313 }
1314
1315 /* get input voltage */
1316 if (rdev->supply && rdev->supply->desc->ops->get_voltage)
1317 input_uV = rdev->supply->desc->ops->get_voltage(rdev->supply);
1318 else
1319 input_uV = rdev->constraints->input_uV;
1320 if (input_uV <= 0) {
1321 printk(KERN_ERR "%s: invalid input voltage found for %s\n",
1322 __func__, rdev->desc->name);
1323 goto out;
1324 }
1325
1326 /* calc total requested load for this regulator */
1327 list_for_each_entry(consumer, &rdev->consumer_list, list)
1328 total_uA_load += consumer->uA_load;
1329
1330 mode = rdev->desc->ops->get_optimum_mode(rdev,
1331 input_uV, output_uV,
1332 total_uA_load);
1333 if (ret <= 0) {
1334 printk(KERN_ERR "%s: failed to get optimum mode for %s @"
1335 " %d uA %d -> %d uV\n", __func__, rdev->desc->name,
1336 total_uA_load, input_uV, output_uV);
1337 goto out;
1338 }
1339
1340 ret = rdev->desc->ops->set_mode(rdev, mode);
1341 if (ret <= 0) {
1342 printk(KERN_ERR "%s: failed to set optimum mode %x for %s\n",
1343 __func__, mode, rdev->desc->name);
1344 goto out;
1345 }
1346 ret = mode;
1347out:
1348 mutex_unlock(&rdev->mutex);
1349 return ret;
1350}
1351EXPORT_SYMBOL_GPL(regulator_set_optimum_mode);
1352
1353/**
1354 * regulator_register_notifier - register regulator event notifier
1355 * @regulator: regulator source
1356 * @notifier_block: notifier block
1357 *
1358 * Register notifier block to receive regulator events.
1359 */
1360int regulator_register_notifier(struct regulator *regulator,
1361 struct notifier_block *nb)
1362{
1363 return blocking_notifier_chain_register(&regulator->rdev->notifier,
1364 nb);
1365}
1366EXPORT_SYMBOL_GPL(regulator_register_notifier);
1367
1368/**
1369 * regulator_unregister_notifier - unregister regulator event notifier
1370 * @regulator: regulator source
1371 * @notifier_block: notifier block
1372 *
1373 * Unregister regulator event notifier block.
1374 */
1375int regulator_unregister_notifier(struct regulator *regulator,
1376 struct notifier_block *nb)
1377{
1378 return blocking_notifier_chain_unregister(&regulator->rdev->notifier,
1379 nb);
1380}
1381EXPORT_SYMBOL_GPL(regulator_unregister_notifier);
1382
1383/* notify regulator consumers and downstream regulator consumers */
1384static void _notifier_call_chain(struct regulator_dev *rdev,
1385 unsigned long event, void *data)
1386{
1387 struct regulator_dev *_rdev;
1388
1389 /* call rdev chain first */
1390 mutex_lock(&rdev->mutex);
1391 blocking_notifier_call_chain(&rdev->notifier, event, NULL);
1392 mutex_unlock(&rdev->mutex);
1393
1394 /* now notify regulator we supply */
1395 list_for_each_entry(_rdev, &rdev->supply_list, slist)
1396 _notifier_call_chain(_rdev, event, data);
1397}
1398
1399/**
1400 * regulator_bulk_get - get multiple regulator consumers
1401 *
1402 * @dev: Device to supply
1403 * @num_consumers: Number of consumers to register
1404 * @consumers: Configuration of consumers; clients are stored here.
1405 *
1406 * @return 0 on success, an errno on failure.
1407 *
1408 * This helper function allows drivers to get several regulator
1409 * consumers in one operation. If any of the regulators cannot be
1410 * acquired then any regulators that were allocated will be freed
1411 * before returning to the caller.
1412 */
1413int regulator_bulk_get(struct device *dev, int num_consumers,
1414 struct regulator_bulk_data *consumers)
1415{
1416 int i;
1417 int ret;
1418
1419 for (i = 0; i < num_consumers; i++)
1420 consumers[i].consumer = NULL;
1421
1422 for (i = 0; i < num_consumers; i++) {
1423 consumers[i].consumer = regulator_get(dev,
1424 consumers[i].supply);
1425 if (IS_ERR(consumers[i].consumer)) {
1426 dev_err(dev, "Failed to get supply '%s'\n",
1427 consumers[i].supply);
1428 ret = PTR_ERR(consumers[i].consumer);
1429 consumers[i].consumer = NULL;
1430 goto err;
1431 }
1432 }
1433
1434 return 0;
1435
1436err:
1437 for (i = 0; i < num_consumers && consumers[i].consumer; i++)
1438 regulator_put(consumers[i].consumer);
1439
1440 return ret;
1441}
1442EXPORT_SYMBOL_GPL(regulator_bulk_get);
1443
1444/**
1445 * regulator_bulk_enable - enable multiple regulator consumers
1446 *
1447 * @num_consumers: Number of consumers
1448 * @consumers: Consumer data; clients are stored here.
1449 * @return 0 on success, an errno on failure
1450 *
1451 * This convenience API allows consumers to enable multiple regulator
1452 * clients in a single API call. If any consumers cannot be enabled
1453 * then any others that were enabled will be disabled again prior to
1454 * return.
1455 */
1456int regulator_bulk_enable(int num_consumers,
1457 struct regulator_bulk_data *consumers)
1458{
1459 int i;
1460 int ret;
1461
1462 for (i = 0; i < num_consumers; i++) {
1463 ret = regulator_enable(consumers[i].consumer);
1464 if (ret != 0)
1465 goto err;
1466 }
1467
1468 return 0;
1469
1470err:
1471 printk(KERN_ERR "Failed to enable %s\n", consumers[i].supply);
1472 for (i = 0; i < num_consumers; i++)
1473 regulator_disable(consumers[i].consumer);
1474
1475 return ret;
1476}
1477EXPORT_SYMBOL_GPL(regulator_bulk_enable);
1478
1479/**
1480 * regulator_bulk_disable - disable multiple regulator consumers
1481 *
1482 * @num_consumers: Number of consumers
1483 * @consumers: Consumer data; clients are stored here.
1484 * @return 0 on success, an errno on failure
1485 *
1486 * This convenience API allows consumers to disable multiple regulator
1487 * clients in a single API call. If any consumers cannot be enabled
1488 * then any others that were disabled will be disabled again prior to
1489 * return.
1490 */
1491int regulator_bulk_disable(int num_consumers,
1492 struct regulator_bulk_data *consumers)
1493{
1494 int i;
1495 int ret;
1496
1497 for (i = 0; i < num_consumers; i++) {
1498 ret = regulator_disable(consumers[i].consumer);
1499 if (ret != 0)
1500 goto err;
1501 }
1502
1503 return 0;
1504
1505err:
1506 printk(KERN_ERR "Failed to disable %s\n", consumers[i].supply);
1507 for (i = 0; i < num_consumers; i++)
1508 regulator_enable(consumers[i].consumer);
1509
1510 return ret;
1511}
1512EXPORT_SYMBOL_GPL(regulator_bulk_disable);
1513
1514/**
1515 * regulator_bulk_free - free multiple regulator consumers
1516 *
1517 * @num_consumers: Number of consumers
1518 * @consumers: Consumer data; clients are stored here.
1519 *
1520 * This convenience API allows consumers to free multiple regulator
1521 * clients in a single API call.
1522 */
1523void regulator_bulk_free(int num_consumers,
1524 struct regulator_bulk_data *consumers)
1525{
1526 int i;
1527
1528 for (i = 0; i < num_consumers; i++) {
1529 regulator_put(consumers[i].consumer);
1530 consumers[i].consumer = NULL;
1531 }
1532}
1533EXPORT_SYMBOL_GPL(regulator_bulk_free);
1534
1535/**
1536 * regulator_notifier_call_chain - call regulator event notifier
1537 * @regulator: regulator source
1538 * @event: notifier block
1539 * @data:
1540 *
1541 * Called by regulator drivers to notify clients a regulator event has
1542 * occurred. We also notify regulator clients downstream.
1543 */
1544int regulator_notifier_call_chain(struct regulator_dev *rdev,
1545 unsigned long event, void *data)
1546{
1547 _notifier_call_chain(rdev, event, data);
1548 return NOTIFY_DONE;
1549
1550}
1551EXPORT_SYMBOL_GPL(regulator_notifier_call_chain);
1552
1553/**
1554 * regulator_register - register regulator
1555 * @regulator: regulator source
1556 * @reg_data: private regulator data
1557 *
1558 * Called by regulator drivers to register a regulator.
1559 * Returns 0 on success.
1560 */
1561struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1562 void *reg_data)
1563{
1564 static atomic_t regulator_no = ATOMIC_INIT(0);
1565 struct regulator_dev *rdev;
1566 int ret;
1567
1568 if (regulator_desc == NULL)
1569 return ERR_PTR(-EINVAL);
1570
1571 if (regulator_desc->name == NULL || regulator_desc->ops == NULL)
1572 return ERR_PTR(-EINVAL);
1573
1574 if (!regulator_desc->type == REGULATOR_VOLTAGE &&
1575 !regulator_desc->type == REGULATOR_CURRENT)
1576 return ERR_PTR(-EINVAL);
1577
1578 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL);
1579 if (rdev == NULL)
1580 return ERR_PTR(-ENOMEM);
1581
1582 mutex_lock(&regulator_list_mutex);
1583
1584 mutex_init(&rdev->mutex);
1585 rdev->reg_data = reg_data;
1586 rdev->owner = regulator_desc->owner;
1587 rdev->desc = regulator_desc;
1588 INIT_LIST_HEAD(&rdev->consumer_list);
1589 INIT_LIST_HEAD(&rdev->supply_list);
1590 INIT_LIST_HEAD(&rdev->list);
1591 INIT_LIST_HEAD(&rdev->slist);
1592 BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier);
1593
1594 rdev->dev.class = &regulator_class;
1595 device_initialize(&rdev->dev);
1596 snprintf(rdev->dev.bus_id, sizeof(rdev->dev.bus_id),
1597 "regulator_%ld_%s",
1598 (unsigned long)atomic_inc_return(&regulator_no) - 1,
1599 regulator_desc->name);
1600
1601 ret = device_add(&rdev->dev);
1602 if (ret == 0)
1603 list_add(&rdev->list, &regulator_list);
1604 else {
1605 kfree(rdev);
1606 rdev = ERR_PTR(ret);
1607 }
1608 mutex_unlock(&regulator_list_mutex);
1609 return rdev;
1610}
1611EXPORT_SYMBOL_GPL(regulator_register);
1612
1613/**
1614 * regulator_unregister - unregister regulator
1615 * @regulator: regulator source
1616 *
1617 * Called by regulator drivers to unregister a regulator.
1618 */
1619void regulator_unregister(struct regulator_dev *rdev)
1620{
1621 if (rdev == NULL)
1622 return;
1623
1624 mutex_lock(&regulator_list_mutex);
1625 list_del(&rdev->list);
1626 if (rdev->supply)
1627 sysfs_remove_link(&rdev->dev.kobj, "supply");
1628 device_unregister(&rdev->dev);
1629 mutex_unlock(&regulator_list_mutex);
1630}
1631EXPORT_SYMBOL_GPL(regulator_unregister);
1632
1633/**
1634 * regulator_set_supply - set regulator supply regulator
1635 * @regulator: regulator name
1636 * @supply: supply regulator name
1637 *
1638 * Called by platform initialisation code to set the supply regulator for this
1639 * regulator. This ensures that a regulators supply will also be enabled by the
1640 * core if it's child is enabled.
1641 */
1642int regulator_set_supply(const char *regulator, const char *supply)
1643{
1644 struct regulator_dev *rdev, *supply_rdev;
1645 int err;
1646
1647 if (regulator == NULL || supply == NULL)
1648 return -EINVAL;
1649
1650 mutex_lock(&regulator_list_mutex);
1651
1652 list_for_each_entry(rdev, &regulator_list, list) {
1653 if (!strcmp(rdev->desc->name, regulator))
1654 goto found_regulator;
1655 }
1656 mutex_unlock(&regulator_list_mutex);
1657 return -ENODEV;
1658
1659found_regulator:
1660 list_for_each_entry(supply_rdev, &regulator_list, list) {
1661 if (!strcmp(supply_rdev->desc->name, supply))
1662 goto found_supply;
1663 }
1664 mutex_unlock(&regulator_list_mutex);
1665 return -ENODEV;
1666
1667found_supply:
1668 err = sysfs_create_link(&rdev->dev.kobj, &supply_rdev->dev.kobj,
1669 "supply");
1670 if (err) {
1671 printk(KERN_ERR
1672 "%s: could not add device link %s err %d\n",
1673 __func__, supply_rdev->dev.kobj.name, err);
1674 goto out;
1675 }
1676 rdev->supply = supply_rdev;
1677 list_add(&rdev->slist, &supply_rdev->supply_list);
1678out:
1679 mutex_unlock(&regulator_list_mutex);
1680 return err;
1681}
1682EXPORT_SYMBOL_GPL(regulator_set_supply);
1683
1684/**
1685 * regulator_get_supply - get regulator supply regulator
1686 * @regulator: regulator name
1687 *
1688 * Returns the supply supply regulator name or NULL if no supply regulator
1689 * exists (i.e the regulator is supplied directly from USB, Line, Battery, etc)
1690 */
1691const char *regulator_get_supply(const char *regulator)
1692{
1693 struct regulator_dev *rdev;
1694
1695 if (regulator == NULL)
1696 return NULL;
1697
1698 mutex_lock(&regulator_list_mutex);
1699 list_for_each_entry(rdev, &regulator_list, list) {
1700 if (!strcmp(rdev->desc->name, regulator))
1701 goto found;
1702 }
1703 mutex_unlock(&regulator_list_mutex);
1704 return NULL;
1705
1706found:
1707 mutex_unlock(&regulator_list_mutex);
1708 if (rdev->supply)
1709 return rdev->supply->desc->name;
1710 else
1711 return NULL;
1712}
1713EXPORT_SYMBOL_GPL(regulator_get_supply);
1714
1715/**
1716 * regulator_set_machine_constraints - sets regulator constraints
1717 * @regulator: regulator source
1718 *
1719 * Allows platform initialisation code to define and constrain
1720 * regulator circuits e.g. valid voltage/current ranges, etc. NOTE:
1721 * Constraints *must* be set by platform code in order for some
1722 * regulator operations to proceed i.e. set_voltage, set_current_limit,
1723 * set_mode.
1724 */
1725int regulator_set_machine_constraints(const char *regulator_name,
1726 struct regulation_constraints *constraints)
1727{
1728 struct regulator_dev *rdev;
1729 int ret = 0;
1730
1731 if (regulator_name == NULL)
1732 return -EINVAL;
1733
1734 mutex_lock(&regulator_list_mutex);
1735
1736 list_for_each_entry(rdev, &regulator_list, list) {
1737 if (!strcmp(regulator_name, rdev->desc->name))
1738 goto found;
1739 }
1740 ret = -ENODEV;
1741 goto out;
1742
1743found:
1744 mutex_lock(&rdev->mutex);
1745 rdev->constraints = constraints;
1746
1747 /* do we need to apply the constraint voltage */
1748 if (rdev->constraints->apply_uV &&
1749 rdev->constraints->min_uV == rdev->constraints->max_uV &&
1750 rdev->desc->ops->set_voltage) {
1751 ret = rdev->desc->ops->set_voltage(rdev,
1752 rdev->constraints->min_uV, rdev->constraints->max_uV);
1753 if (ret < 0) {
1754 printk(KERN_ERR "%s: failed to apply %duV"
1755 " constraint\n", __func__,
1756 rdev->constraints->min_uV);
1757 rdev->constraints = NULL;
1758 goto out;
1759 }
1760 }
1761
1762 /* are we enabled at boot time by firmware / bootloader */
1763 if (rdev->constraints->boot_on)
1764 rdev->use_count = 1;
1765
1766 /* do we need to setup our suspend state */
1767 if (constraints->initial_state)
1768 ret = suspend_prepare(rdev, constraints->initial_state);
1769
1770 print_constraints(rdev);
1771 mutex_unlock(&rdev->mutex);
1772
1773out:
1774 mutex_unlock(&regulator_list_mutex);
1775 return ret;
1776}
1777EXPORT_SYMBOL_GPL(regulator_set_machine_constraints);
1778
1779
1780/**
1781 * regulator_set_device_supply: Bind a regulator to a symbolic supply
1782 * @regulator: regulator source
1783 * @dev: device the supply applies to
1784 * @supply: symbolic name for supply
1785 *
1786 * Allows platform initialisation code to map physical regulator
1787 * sources to symbolic names for supplies for use by devices. Devices
1788 * should use these symbolic names to request regulators, avoiding the
1789 * need to provide board-specific regulator names as platform data.
1790 */
1791int regulator_set_device_supply(const char *regulator, struct device *dev,
1792 const char *supply)
1793{
1794 struct regulator_map *node;
1795
1796 if (regulator == NULL || supply == NULL)
1797 return -EINVAL;
1798
1799 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
1800 if (node == NULL)
1801 return -ENOMEM;
1802
1803 node->regulator = regulator;
1804 node->dev = dev;
1805 node->supply = supply;
1806
1807 mutex_lock(&regulator_list_mutex);
1808 list_add(&node->list, &regulator_map_list);
1809 mutex_unlock(&regulator_list_mutex);
1810 return 0;
1811}
1812EXPORT_SYMBOL_GPL(regulator_set_device_supply);
1813
1814/**
1815 * regulator_suspend_prepare: prepare regulators for system wide suspend
1816 * @state: system suspend state
1817 *
1818 * Configure each regulator with it's suspend operating parameters for state.
1819 * This will usually be called by machine suspend code prior to supending.
1820 */
1821int regulator_suspend_prepare(suspend_state_t state)
1822{
1823 struct regulator_dev *rdev;
1824 int ret = 0;
1825
1826 /* ON is handled by regulator active state */
1827 if (state == PM_SUSPEND_ON)
1828 return -EINVAL;
1829
1830 mutex_lock(&regulator_list_mutex);
1831 list_for_each_entry(rdev, &regulator_list, list) {
1832
1833 mutex_lock(&rdev->mutex);
1834 ret = suspend_prepare(rdev, state);
1835 mutex_unlock(&rdev->mutex);
1836
1837 if (ret < 0) {
1838 printk(KERN_ERR "%s: failed to prepare %s\n",
1839 __func__, rdev->desc->name);
1840 goto out;
1841 }
1842 }
1843out:
1844 mutex_unlock(&regulator_list_mutex);
1845 return ret;
1846}
1847EXPORT_SYMBOL_GPL(regulator_suspend_prepare);
1848
1849/**
1850 * rdev_get_drvdata - get rdev regulator driver data
1851 * @regulator: regulator
1852 *
1853 * Get rdev regulator driver private data. This call can be used in the
1854 * regulator driver context.
1855 */
1856void *rdev_get_drvdata(struct regulator_dev *rdev)
1857{
1858 return rdev->reg_data;
1859}
1860EXPORT_SYMBOL_GPL(rdev_get_drvdata);
1861
1862/**
1863 * regulator_get_drvdata - get regulator driver data
1864 * @regulator: regulator
1865 *
1866 * Get regulator driver private data. This call can be used in the consumer
1867 * driver context when non API regulator specific functions need to be called.
1868 */
1869void *regulator_get_drvdata(struct regulator *regulator)
1870{
1871 return regulator->rdev->reg_data;
1872}
1873EXPORT_SYMBOL_GPL(regulator_get_drvdata);
1874
1875/**
1876 * regulator_set_drvdata - set regulator driver data
1877 * @regulator: regulator
1878 * @data: data
1879 */
1880void regulator_set_drvdata(struct regulator *regulator, void *data)
1881{
1882 regulator->rdev->reg_data = data;
1883}
1884EXPORT_SYMBOL_GPL(regulator_set_drvdata);
1885
1886/**
1887 * regulator_get_id - get regulator ID
1888 * @regulator: regulator
1889 */
1890int rdev_get_id(struct regulator_dev *rdev)
1891{
1892 return rdev->desc->id;
1893}
1894EXPORT_SYMBOL_GPL(rdev_get_id);
1895
1896static int __init regulator_init(void)
1897{
1898 printk(KERN_INFO "regulator: core version %s\n", REGULATOR_VERSION);
1899 return class_register(&regulator_class);
1900}
1901
1902/* init early to allow our consumers to complete system booting */
1903core_initcall(regulator_init);
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
new file mode 100644
index 000000000000..d31db3e14913
--- /dev/null
+++ b/drivers/regulator/fixed.c
@@ -0,0 +1,129 @@
1/*
2 * fixed.c
3 *
4 * Copyright 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This is useful for systems with mixed controllable and
14 * non-controllable regulators, as well as for allowing testing on
15 * systems with no controllable regulators.
16 */
17
18#include <linux/err.h>
19#include <linux/mutex.h>
20#include <linux/platform_device.h>
21#include <linux/regulator/driver.h>
22#include <linux/regulator/fixed.h>
23
24struct fixed_voltage_data {
25 struct regulator_desc desc;
26 struct regulator_dev *dev;
27 int microvolts;
28};
29
30static int fixed_voltage_is_enabled(struct regulator_dev *dev)
31{
32 return 1;
33}
34
35static int fixed_voltage_enable(struct regulator_dev *dev)
36{
37 return 0;
38}
39
40static int fixed_voltage_get_voltage(struct regulator_dev *dev)
41{
42 struct fixed_voltage_data *data = rdev_get_drvdata(dev);
43
44 return data->microvolts;
45}
46
47static struct regulator_ops fixed_voltage_ops = {
48 .is_enabled = fixed_voltage_is_enabled,
49 .enable = fixed_voltage_enable,
50 .get_voltage = fixed_voltage_get_voltage,
51};
52
53static int regulator_fixed_voltage_probe(struct platform_device *pdev)
54{
55 struct fixed_voltage_config *config = pdev->dev.platform_data;
56 struct fixed_voltage_data *drvdata;
57 int ret;
58
59 drvdata = kzalloc(sizeof(struct fixed_voltage_data), GFP_KERNEL);
60 if (drvdata == NULL) {
61 ret = -ENOMEM;
62 goto err;
63 }
64
65 drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
66 if (drvdata->desc.name == NULL) {
67 ret = -ENOMEM;
68 goto err;
69 }
70 drvdata->desc.type = REGULATOR_VOLTAGE;
71 drvdata->desc.owner = THIS_MODULE;
72 drvdata->desc.ops = &fixed_voltage_ops,
73
74 drvdata->microvolts = config->microvolts;
75
76 drvdata->dev = regulator_register(&drvdata->desc, drvdata);
77 if (IS_ERR(drvdata->dev)) {
78 ret = PTR_ERR(drvdata->dev);
79 goto err_name;
80 }
81
82 platform_set_drvdata(pdev, drvdata);
83
84 dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name,
85 drvdata->microvolts);
86
87 return 0;
88
89err_name:
90 kfree(drvdata->desc.name);
91err:
92 kfree(drvdata);
93 return ret;
94}
95
96static int regulator_fixed_voltage_remove(struct platform_device *pdev)
97{
98 struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
99
100 regulator_unregister(drvdata->dev);
101 kfree(drvdata->desc.name);
102 kfree(drvdata);
103
104 return 0;
105}
106
107static struct platform_driver regulator_fixed_voltage_driver = {
108 .probe = regulator_fixed_voltage_probe,
109 .remove = regulator_fixed_voltage_remove,
110 .driver = {
111 .name = "reg-fixed-voltage",
112 },
113};
114
115static int __init regulator_fixed_voltage_init(void)
116{
117 return platform_driver_register(&regulator_fixed_voltage_driver);
118}
119module_init(regulator_fixed_voltage_init);
120
121static void __exit regulator_fixed_voltage_exit(void)
122{
123 platform_driver_unregister(&regulator_fixed_voltage_driver);
124}
125module_exit(regulator_fixed_voltage_exit);
126
127MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
128MODULE_DESCRIPTION("Fixed voltage regulator");
129MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
new file mode 100644
index 000000000000..5ddb464b1c3f
--- /dev/null
+++ b/drivers/regulator/virtual.c
@@ -0,0 +1,345 @@
1/*
2 * reg-virtual-consumer.c
3 *
4 * Copyright 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 */
13
14#include <linux/err.h>
15#include <linux/mutex.h>
16#include <linux/platform_device.h>
17#include <linux/regulator/consumer.h>
18
19struct virtual_consumer_data {
20 struct mutex lock;
21 struct regulator *regulator;
22 int enabled;
23 int min_uV;
24 int max_uV;
25 int min_uA;
26 int max_uA;
27 unsigned int mode;
28};
29
30static void update_voltage_constraints(struct virtual_consumer_data *data)
31{
32 int ret;
33
34 if (data->min_uV && data->max_uV
35 && data->min_uV <= data->max_uV) {
36 ret = regulator_set_voltage(data->regulator,
37 data->min_uV, data->max_uV);
38 if (ret != 0) {
39 printk(KERN_ERR "regulator_set_voltage() failed: %d\n",
40 ret);
41 return;
42 }
43 }
44
45 if (data->min_uV && data->max_uV && !data->enabled) {
46 ret = regulator_enable(data->regulator);
47 if (ret == 0)
48 data->enabled = 1;
49 else
50 printk(KERN_ERR "regulator_enable() failed: %d\n",
51 ret);
52 }
53
54 if (!(data->min_uV && data->max_uV) && data->enabled) {
55 ret = regulator_disable(data->regulator);
56 if (ret == 0)
57 data->enabled = 0;
58 else
59 printk(KERN_ERR "regulator_disable() failed: %d\n",
60 ret);
61 }
62}
63
64static void update_current_limit_constraints(struct virtual_consumer_data
65 *data)
66{
67 int ret;
68
69 if (data->max_uA
70 && data->min_uA <= data->max_uA) {
71 ret = regulator_set_current_limit(data->regulator,
72 data->min_uA, data->max_uA);
73 if (ret != 0) {
74 pr_err("regulator_set_current_limit() failed: %d\n",
75 ret);
76 return;
77 }
78 }
79
80 if (data->max_uA && !data->enabled) {
81 ret = regulator_enable(data->regulator);
82 if (ret == 0)
83 data->enabled = 1;
84 else
85 printk(KERN_ERR "regulator_enable() failed: %d\n",
86 ret);
87 }
88
89 if (!(data->min_uA && data->max_uA) && data->enabled) {
90 ret = regulator_disable(data->regulator);
91 if (ret == 0)
92 data->enabled = 0;
93 else
94 printk(KERN_ERR "regulator_disable() failed: %d\n",
95 ret);
96 }
97}
98
99static ssize_t show_min_uV(struct device *dev,
100 struct device_attribute *attr, char *buf)
101{
102 struct virtual_consumer_data *data = dev_get_drvdata(dev);
103 return sprintf(buf, "%d\n", data->min_uV);
104}
105
106static ssize_t set_min_uV(struct device *dev, struct device_attribute *attr,
107 const char *buf, size_t count)
108{
109 struct virtual_consumer_data *data = dev_get_drvdata(dev);
110 long val;
111
112 if (strict_strtol(buf, 10, &val) != 0)
113 return count;
114
115 mutex_lock(&data->lock);
116
117 data->min_uV = val;
118 update_voltage_constraints(data);
119
120 mutex_unlock(&data->lock);
121
122 return count;
123}
124
125static ssize_t show_max_uV(struct device *dev,
126 struct device_attribute *attr, char *buf)
127{
128 struct virtual_consumer_data *data = dev_get_drvdata(dev);
129 return sprintf(buf, "%d\n", data->max_uV);
130}
131
132static ssize_t set_max_uV(struct device *dev, struct device_attribute *attr,
133 const char *buf, size_t count)
134{
135 struct virtual_consumer_data *data = dev_get_drvdata(dev);
136 long val;
137
138 if (strict_strtol(buf, 10, &val) != 0)
139 return count;
140
141 mutex_lock(&data->lock);
142
143 data->max_uV = val;
144 update_voltage_constraints(data);
145
146 mutex_unlock(&data->lock);
147
148 return count;
149}
150
151static ssize_t show_min_uA(struct device *dev,
152 struct device_attribute *attr, char *buf)
153{
154 struct virtual_consumer_data *data = dev_get_drvdata(dev);
155 return sprintf(buf, "%d\n", data->min_uA);
156}
157
158static ssize_t set_min_uA(struct device *dev, struct device_attribute *attr,
159 const char *buf, size_t count)
160{
161 struct virtual_consumer_data *data = dev_get_drvdata(dev);
162 long val;
163
164 if (strict_strtol(buf, 10, &val) != 0)
165 return count;
166
167 mutex_lock(&data->lock);
168
169 data->min_uA = val;
170 update_current_limit_constraints(data);
171
172 mutex_unlock(&data->lock);
173
174 return count;
175}
176
177static ssize_t show_max_uA(struct device *dev,
178 struct device_attribute *attr, char *buf)
179{
180 struct virtual_consumer_data *data = dev_get_drvdata(dev);
181 return sprintf(buf, "%d\n", data->max_uA);
182}
183
184static ssize_t set_max_uA(struct device *dev, struct device_attribute *attr,
185 const char *buf, size_t count)
186{
187 struct virtual_consumer_data *data = dev_get_drvdata(dev);
188 long val;
189
190 if (strict_strtol(buf, 10, &val) != 0)
191 return count;
192
193 mutex_lock(&data->lock);
194
195 data->max_uA = val;
196 update_current_limit_constraints(data);
197
198 mutex_unlock(&data->lock);
199
200 return count;
201}
202
203static ssize_t show_mode(struct device *dev,
204 struct device_attribute *attr, char *buf)
205{
206 struct virtual_consumer_data *data = dev_get_drvdata(dev);
207
208 switch (data->mode) {
209 case REGULATOR_MODE_FAST:
210 return sprintf(buf, "fast\n");
211 case REGULATOR_MODE_NORMAL:
212 return sprintf(buf, "normal\n");
213 case REGULATOR_MODE_IDLE:
214 return sprintf(buf, "idle\n");
215 case REGULATOR_MODE_STANDBY:
216 return sprintf(buf, "standby\n");
217 default:
218 return sprintf(buf, "unknown\n");
219 }
220}
221
222static ssize_t set_mode(struct device *dev, struct device_attribute *attr,
223 const char *buf, size_t count)
224{
225 struct virtual_consumer_data *data = dev_get_drvdata(dev);
226 unsigned int mode;
227 int ret;
228
229 if (strncmp(buf, "fast", strlen("fast")) == 0)
230 mode = REGULATOR_MODE_FAST;
231 else if (strncmp(buf, "normal", strlen("normal")) == 0)
232 mode = REGULATOR_MODE_NORMAL;
233 else if (strncmp(buf, "idle", strlen("idle")) == 0)
234 mode = REGULATOR_MODE_IDLE;
235 else if (strncmp(buf, "standby", strlen("standby")) == 0)
236 mode = REGULATOR_MODE_STANDBY;
237 else {
238 dev_err(dev, "Configuring invalid mode\n");
239 return count;
240 }
241
242 mutex_lock(&data->lock);
243 ret = regulator_set_mode(data->regulator, mode);
244 if (ret == 0)
245 data->mode = mode;
246 else
247 dev_err(dev, "Failed to configure mode: %d\n", ret);
248 mutex_unlock(&data->lock);
249
250 return count;
251}
252
253static DEVICE_ATTR(min_microvolts, 0666, show_min_uV, set_min_uV);
254static DEVICE_ATTR(max_microvolts, 0666, show_max_uV, set_max_uV);
255static DEVICE_ATTR(min_microamps, 0666, show_min_uA, set_min_uA);
256static DEVICE_ATTR(max_microamps, 0666, show_max_uA, set_max_uA);
257static DEVICE_ATTR(mode, 0666, show_mode, set_mode);
258
259struct device_attribute *attributes[] = {
260 &dev_attr_min_microvolts,
261 &dev_attr_max_microvolts,
262 &dev_attr_min_microamps,
263 &dev_attr_max_microamps,
264 &dev_attr_mode,
265};
266
267static int regulator_virtual_consumer_probe(struct platform_device *pdev)
268{
269 char *reg_id = pdev->dev.platform_data;
270 struct virtual_consumer_data *drvdata;
271 int ret, i;
272
273 drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL);
274 if (drvdata == NULL) {
275 ret = -ENOMEM;
276 goto err;
277 }
278
279 mutex_init(&drvdata->lock);
280
281 drvdata->regulator = regulator_get(&pdev->dev, reg_id);
282 if (IS_ERR(drvdata->regulator)) {
283 ret = PTR_ERR(drvdata->regulator);
284 goto err;
285 }
286
287 for (i = 0; i < ARRAY_SIZE(attributes); i++) {
288 ret = device_create_file(&pdev->dev, attributes[i]);
289 if (ret != 0)
290 goto err;
291 }
292
293 drvdata->mode = regulator_get_mode(drvdata->regulator);
294
295 platform_set_drvdata(pdev, drvdata);
296
297 return 0;
298
299err:
300 for (i = 0; i < ARRAY_SIZE(attributes); i++)
301 device_remove_file(&pdev->dev, attributes[i]);
302 kfree(drvdata);
303 return ret;
304}
305
306static int regulator_virtual_consumer_remove(struct platform_device *pdev)
307{
308 struct virtual_consumer_data *drvdata = platform_get_drvdata(pdev);
309 int i;
310
311 for (i = 0; i < ARRAY_SIZE(attributes); i++)
312 device_remove_file(&pdev->dev, attributes[i]);
313 if (drvdata->enabled)
314 regulator_disable(drvdata->regulator);
315 regulator_put(drvdata->regulator);
316
317 kfree(drvdata);
318
319 return 0;
320}
321
322static struct platform_driver regulator_virtual_consumer_driver = {
323 .probe = regulator_virtual_consumer_probe,
324 .remove = regulator_virtual_consumer_remove,
325 .driver = {
326 .name = "reg-virt-consumer",
327 },
328};
329
330
331static int __init regulator_virtual_consumer_init(void)
332{
333 return platform_driver_register(&regulator_virtual_consumer_driver);
334}
335module_init(regulator_virtual_consumer_init);
336
337static void __exit regulator_virtual_consumer_exit(void)
338{
339 platform_driver_unregister(&regulator_virtual_consumer_driver);
340}
341module_exit(regulator_virtual_consumer_exit);
342
343MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
344MODULE_DESCRIPTION("Virtual regulator consumer");
345MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index e5e7d7856454..8e08d51a0f05 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -375,7 +375,6 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
375 struct gendisk *disk = rq->rq_disk; 375 struct gendisk *disk = rq->rq_disk;
376 struct scsi_disk *sdkp; 376 struct scsi_disk *sdkp;
377 sector_t block = rq->sector; 377 sector_t block = rq->sector;
378 sector_t threshold;
379 unsigned int this_count = rq->nr_sectors; 378 unsigned int this_count = rq->nr_sectors;
380 unsigned int timeout = sdp->timeout; 379 unsigned int timeout = sdp->timeout;
381 int ret; 380 int ret;
@@ -423,21 +422,13 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
423 } 422 }
424 423
425 /* 424 /*
426 * Some SD card readers can't handle multi-sector accesses which touch 425 * Some devices (some sdcards for one) don't like it if the
427 * the last one or two hardware sectors. Split accesses as needed. 426 * last sector gets read in a larger then 1 sector read.
428 */ 427 */
429 threshold = get_capacity(disk) - SD_LAST_BUGGY_SECTORS * 428 if (unlikely(sdp->last_sector_bug &&
430 (sdp->sector_size / 512); 429 rq->nr_sectors > sdp->sector_size / 512 &&
431 430 block + this_count == get_capacity(disk)))
432 if (unlikely(sdp->last_sector_bug && block + this_count > threshold)) { 431 this_count -= sdp->sector_size / 512;
433 if (block < threshold) {
434 /* Access up to the threshold but not beyond */
435 this_count = threshold - block;
436 } else {
437 /* Access only a single hardware sector */
438 this_count = sdp->sector_size / 512;
439 }
440 }
441 432
442 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n", 433 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n",
443 (unsigned long long)block)); 434 (unsigned long long)block));
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 95b9f06534d5..550b2f70a1f8 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -31,12 +31,6 @@
31 */ 31 */
32#define SD_BUF_SIZE 512 32#define SD_BUF_SIZE 512
33 33
34/*
35 * Number of sectors at the end of the device to avoid multi-sector
36 * accesses to in the case of last_sector_bug
37 */
38#define SD_LAST_BUGGY_SECTORS 8
39
40struct scsi_disk { 34struct scsi_disk {
41 struct scsi_driver *driver; /* always &sd_template */ 35 struct scsi_driver *driver; /* always &sd_template */
42 struct scsi_device *device; 36 struct scsi_device *device;
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 9d8543762a30..efcd44344fb1 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -817,7 +817,7 @@ static void bfin_serial_set_ldisc(struct uart_port *port)
817 if (line >= port->info->port.tty->driver->num) 817 if (line >= port->info->port.tty->driver->num)
818 return; 818 return;
819 819
820 switch (port->info->port.tty->ldisc.num) { 820 switch (port->info->port.tty->termios->c_line) {
821 case N_IRDA: 821 case N_IRDA:
822 val = UART_GET_GCTL(&bfin_serial_ports[line]); 822 val = UART_GET_GCTL(&bfin_serial_ports[line]);
823 val |= (IREN | RPOLC); 823 val |= (IREN | RPOLC);
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 8249ac490559..bf94a770bb44 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -234,7 +234,7 @@ unsigned long r_alt_ser_baudrate_shadow = 0;
234 234
235static struct e100_serial rs_table[] = { 235static struct e100_serial rs_table[] = {
236 { .baud = DEF_BAUD, 236 { .baud = DEF_BAUD,
237 .port = (unsigned char *)R_SERIAL0_CTRL, 237 .ioport = (unsigned char *)R_SERIAL0_CTRL,
238 .irq = 1U << 12, /* uses DMA 6 and 7 */ 238 .irq = 1U << 12, /* uses DMA 6 and 7 */
239 .oclrintradr = R_DMA_CH6_CLR_INTR, 239 .oclrintradr = R_DMA_CH6_CLR_INTR,
240 .ofirstadr = R_DMA_CH6_FIRST, 240 .ofirstadr = R_DMA_CH6_FIRST,
@@ -288,7 +288,7 @@ static struct e100_serial rs_table[] = {
288}, /* ttyS0 */ 288}, /* ttyS0 */
289#ifndef CONFIG_SVINTO_SIM 289#ifndef CONFIG_SVINTO_SIM
290 { .baud = DEF_BAUD, 290 { .baud = DEF_BAUD,
291 .port = (unsigned char *)R_SERIAL1_CTRL, 291 .ioport = (unsigned char *)R_SERIAL1_CTRL,
292 .irq = 1U << 16, /* uses DMA 8 and 9 */ 292 .irq = 1U << 16, /* uses DMA 8 and 9 */
293 .oclrintradr = R_DMA_CH8_CLR_INTR, 293 .oclrintradr = R_DMA_CH8_CLR_INTR,
294 .ofirstadr = R_DMA_CH8_FIRST, 294 .ofirstadr = R_DMA_CH8_FIRST,
@@ -344,7 +344,7 @@ static struct e100_serial rs_table[] = {
344}, /* ttyS1 */ 344}, /* ttyS1 */
345 345
346 { .baud = DEF_BAUD, 346 { .baud = DEF_BAUD,
347 .port = (unsigned char *)R_SERIAL2_CTRL, 347 .ioport = (unsigned char *)R_SERIAL2_CTRL,
348 .irq = 1U << 4, /* uses DMA 2 and 3 */ 348 .irq = 1U << 4, /* uses DMA 2 and 3 */
349 .oclrintradr = R_DMA_CH2_CLR_INTR, 349 .oclrintradr = R_DMA_CH2_CLR_INTR,
350 .ofirstadr = R_DMA_CH2_FIRST, 350 .ofirstadr = R_DMA_CH2_FIRST,
@@ -398,7 +398,7 @@ static struct e100_serial rs_table[] = {
398 }, /* ttyS2 */ 398 }, /* ttyS2 */
399 399
400 { .baud = DEF_BAUD, 400 { .baud = DEF_BAUD,
401 .port = (unsigned char *)R_SERIAL3_CTRL, 401 .ioport = (unsigned char *)R_SERIAL3_CTRL,
402 .irq = 1U << 8, /* uses DMA 4 and 5 */ 402 .irq = 1U << 8, /* uses DMA 4 and 5 */
403 .oclrintradr = R_DMA_CH4_CLR_INTR, 403 .oclrintradr = R_DMA_CH4_CLR_INTR,
404 .ofirstadr = R_DMA_CH4_FIRST, 404 .ofirstadr = R_DMA_CH4_FIRST,
@@ -939,7 +939,7 @@ static const struct control_pins e100_modem_pins[NR_PORTS] =
939/* Output */ 939/* Output */
940#define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK) 940#define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK)
941/* Input */ 941/* Input */
942#define E100_CTS_GET(info) ((info)->port[REG_STATUS] & E100_CTS_MASK) 942#define E100_CTS_GET(info) ((info)->ioport[REG_STATUS] & E100_CTS_MASK)
943 943
944/* These are typically PA or PB and 0 means 0V, 1 means 3.3V */ 944/* These are typically PA or PB and 0 means 0V, 1 means 3.3V */
945/* Is an output */ 945/* Is an output */
@@ -1092,7 +1092,7 @@ e100_rts(struct e100_serial *info, int set)
1092 local_irq_save(flags); 1092 local_irq_save(flags);
1093 info->rx_ctrl &= ~E100_RTS_MASK; 1093 info->rx_ctrl &= ~E100_RTS_MASK;
1094 info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */ 1094 info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */
1095 info->port[REG_REC_CTRL] = info->rx_ctrl; 1095 info->ioport[REG_REC_CTRL] = info->rx_ctrl;
1096 local_irq_restore(flags); 1096 local_irq_restore(flags);
1097#ifdef SERIAL_DEBUG_IO 1097#ifdef SERIAL_DEBUG_IO
1098 printk("ser%i rts %i\n", info->line, set); 1098 printk("ser%i rts %i\n", info->line, set);
@@ -1142,7 +1142,7 @@ e100_disable_rx(struct e100_serial *info)
1142{ 1142{
1143#ifndef CONFIG_SVINTO_SIM 1143#ifndef CONFIG_SVINTO_SIM
1144 /* disable the receiver */ 1144 /* disable the receiver */
1145 info->port[REG_REC_CTRL] = 1145 info->ioport[REG_REC_CTRL] =
1146 (info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); 1146 (info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
1147#endif 1147#endif
1148} 1148}
@@ -1152,7 +1152,7 @@ e100_enable_rx(struct e100_serial *info)
1152{ 1152{
1153#ifndef CONFIG_SVINTO_SIM 1153#ifndef CONFIG_SVINTO_SIM
1154 /* enable the receiver */ 1154 /* enable the receiver */
1155 info->port[REG_REC_CTRL] = 1155 info->ioport[REG_REC_CTRL] =
1156 (info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); 1156 (info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable));
1157#endif 1157#endif
1158} 1158}
@@ -1490,7 +1490,7 @@ rs_stop(struct tty_struct *tty)
1490 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 1490 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
1491 } 1491 }
1492 1492
1493 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 1493 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
1494 local_irq_restore(flags); 1494 local_irq_restore(flags);
1495 } 1495 }
1496} 1496}
@@ -1513,7 +1513,7 @@ rs_start(struct tty_struct *tty)
1513 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 1513 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
1514 } 1514 }
1515 1515
1516 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 1516 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
1517 if (!info->uses_dma_out && 1517 if (!info->uses_dma_out &&
1518 info->xmit.head != info->xmit.tail && info->xmit.buf) 1518 info->xmit.head != info->xmit.tail && info->xmit.buf)
1519 e100_enable_serial_tx_ready_irq(info); 1519 e100_enable_serial_tx_ready_irq(info);
@@ -1888,7 +1888,7 @@ static void receive_chars_dma(struct e100_serial *info)
1888 handle_all_descr_data(info); 1888 handle_all_descr_data(info);
1889 1889
1890 /* Read the status register to detect errors */ 1890 /* Read the status register to detect errors */
1891 rstat = info->port[REG_STATUS]; 1891 rstat = info->ioport[REG_STATUS];
1892 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { 1892 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
1893 DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat)); 1893 DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat));
1894 } 1894 }
@@ -1897,7 +1897,7 @@ static void receive_chars_dma(struct e100_serial *info)
1897 /* If we got an error, we must reset it by reading the 1897 /* If we got an error, we must reset it by reading the
1898 * data_in field 1898 * data_in field
1899 */ 1899 */
1900 unsigned char data = info->port[REG_DATA]; 1900 unsigned char data = info->ioport[REG_DATA];
1901 1901
1902 PROCSTAT(ser_stat[info->line].errors_cnt++); 1902 PROCSTAT(ser_stat[info->line].errors_cnt++);
1903 DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n", 1903 DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n",
@@ -2077,7 +2077,7 @@ static int force_eop_if_needed(struct e100_serial *info)
2077 /* We check data_avail bit to determine if data has 2077 /* We check data_avail bit to determine if data has
2078 * arrived since last time 2078 * arrived since last time
2079 */ 2079 */
2080 unsigned char rstat = info->port[REG_STATUS]; 2080 unsigned char rstat = info->ioport[REG_STATUS];
2081 2081
2082 /* error or datavail? */ 2082 /* error or datavail? */
2083 if (rstat & SER_ERROR_MASK) { 2083 if (rstat & SER_ERROR_MASK) {
@@ -2096,7 +2096,7 @@ static int force_eop_if_needed(struct e100_serial *info)
2096 TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n", 2096 TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n",
2097 rstat | (info->line << 8))); 2097 rstat | (info->line << 8)));
2098 /* Read data to clear status flags */ 2098 /* Read data to clear status flags */
2099 (void)info->port[REG_DATA]; 2099 (void)info->ioport[REG_DATA];
2100 2100
2101 info->forced_eop = 0; 2101 info->forced_eop = 0;
2102 START_FLUSH_FAST_TIMER(info, "magic"); 2102 START_FLUSH_FAST_TIMER(info, "magic");
@@ -2296,7 +2296,7 @@ struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2296 } 2296 }
2297 2297
2298 /* Read data and status at the same time */ 2298 /* Read data and status at the same time */
2299 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2299 data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]);
2300more_data: 2300more_data:
2301 if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) { 2301 if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) {
2302 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); 2302 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
@@ -2391,7 +2391,7 @@ more_data:
2391 2391
2392 2392
2393 info->icount.rx++; 2393 info->icount.rx++;
2394 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2394 data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]);
2395 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) { 2395 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
2396 DEBUG_LOG(info->line, "ser_rx %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read)); 2396 DEBUG_LOG(info->line, "ser_rx %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read));
2397 goto more_data; 2397 goto more_data;
@@ -2413,7 +2413,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2413 return handle_ser_rx_interrupt_no_dma(info); 2413 return handle_ser_rx_interrupt_no_dma(info);
2414 } 2414 }
2415 /* DMA is used */ 2415 /* DMA is used */
2416 rstat = info->port[REG_STATUS]; 2416 rstat = info->ioport[REG_STATUS];
2417 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { 2417 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) {
2418 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); 2418 DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0));
2419 } 2419 }
@@ -2426,7 +2426,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2426 /* If we got an error, we must reset it by reading the 2426 /* If we got an error, we must reset it by reading the
2427 * data_in field 2427 * data_in field
2428 */ 2428 */
2429 data = info->port[REG_DATA]; 2429 data = info->ioport[REG_DATA];
2430 DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data)); 2430 DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data));
2431 DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat)); 2431 DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat));
2432 if (!data && (rstat & SER_FRAMING_ERR_MASK)) { 2432 if (!data && (rstat & SER_FRAMING_ERR_MASK)) {
@@ -2528,10 +2528,10 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2528 unsigned char rstat; 2528 unsigned char rstat;
2529 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char)); 2529 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char));
2530 local_irq_save(flags); 2530 local_irq_save(flags);
2531 rstat = info->port[REG_STATUS]; 2531 rstat = info->ioport[REG_STATUS];
2532 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2532 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2533 2533
2534 info->port[REG_TR_DATA] = info->x_char; 2534 info->ioport[REG_TR_DATA] = info->x_char;
2535 info->icount.tx++; 2535 info->icount.tx++;
2536 info->x_char = 0; 2536 info->x_char = 0;
2537 /* We must enable since it is disabled in ser_interrupt */ 2537 /* We must enable since it is disabled in ser_interrupt */
@@ -2545,7 +2545,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2545 /* We only use normal tx interrupt when sending x_char */ 2545 /* We only use normal tx interrupt when sending x_char */
2546 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0)); 2546 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0));
2547 local_irq_save(flags); 2547 local_irq_save(flags);
2548 rstat = info->port[REG_STATUS]; 2548 rstat = info->ioport[REG_STATUS];
2549 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2549 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2550 e100_disable_serial_tx_ready_irq(info); 2550 e100_disable_serial_tx_ready_irq(info);
2551 if (info->port.tty->stopped) 2551 if (info->port.tty->stopped)
@@ -2573,7 +2573,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2573 DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail])); 2573 DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail]));
2574 /* Send a byte, rs485 timing is critical so turn of ints */ 2574 /* Send a byte, rs485 timing is critical so turn of ints */
2575 local_irq_save(flags); 2575 local_irq_save(flags);
2576 info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail]; 2576 info->ioport[REG_TR_DATA] = info->xmit.buf[info->xmit.tail];
2577 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1); 2577 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1);
2578 info->icount.tx++; 2578 info->icount.tx++;
2579 if (info->xmit.head == info->xmit.tail) { 2579 if (info->xmit.head == info->xmit.tail) {
@@ -2848,7 +2848,7 @@ startup(struct e100_serial * info)
2848 2848
2849 /* dummy read to reset any serial errors */ 2849 /* dummy read to reset any serial errors */
2850 2850
2851 (void)info->port[REG_DATA]; 2851 (void)info->ioport[REG_DATA];
2852 2852
2853 /* enable the interrupts */ 2853 /* enable the interrupts */
2854 if (info->uses_dma_out) 2854 if (info->uses_dma_out)
@@ -2897,7 +2897,7 @@ shutdown(struct e100_serial * info)
2897 /* shut down the transmitter and receiver */ 2897 /* shut down the transmitter and receiver */
2898 DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line)); 2898 DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line));
2899 e100_disable_rx(info); 2899 e100_disable_rx(info);
2900 info->port[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40); 2900 info->ioport[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40);
2901 2901
2902 /* disable interrupts, reset dma channels */ 2902 /* disable interrupts, reset dma channels */
2903 if (info->uses_dma_in) { 2903 if (info->uses_dma_in) {
@@ -2968,7 +2968,7 @@ change_speed(struct e100_serial *info)
2968 2968
2969 if (!info->port.tty || !info->port.tty->termios) 2969 if (!info->port.tty || !info->port.tty->termios)
2970 return; 2970 return;
2971 if (!info->port) 2971 if (!info->ioport)
2972 return; 2972 return;
2973 2973
2974 cflag = info->port.tty->termios->c_cflag; 2974 cflag = info->port.tty->termios->c_cflag;
@@ -3037,7 +3037,7 @@ change_speed(struct e100_serial *info)
3037 3037
3038 info->baud = cflag_to_baud(cflag); 3038 info->baud = cflag_to_baud(cflag);
3039#ifndef CONFIG_SVINTO_SIM 3039#ifndef CONFIG_SVINTO_SIM
3040 info->port[REG_BAUD] = cflag_to_etrax_baud(cflag); 3040 info->ioport[REG_BAUD] = cflag_to_etrax_baud(cflag);
3041#endif /* CONFIG_SVINTO_SIM */ 3041#endif /* CONFIG_SVINTO_SIM */
3042 } 3042 }
3043 3043
@@ -3097,8 +3097,8 @@ change_speed(struct e100_serial *info)
3097 3097
3098 /* actually write the control regs to the hardware */ 3098 /* actually write the control regs to the hardware */
3099 3099
3100 info->port[REG_TR_CTRL] = info->tx_ctrl; 3100 info->ioport[REG_TR_CTRL] = info->tx_ctrl;
3101 info->port[REG_REC_CTRL] = info->rx_ctrl; 3101 info->ioport[REG_REC_CTRL] = info->rx_ctrl;
3102 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty)); 3102 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty));
3103 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable); 3103 xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
3104 if (info->port.tty->termios->c_iflag & IXON ) { 3104 if (info->port.tty->termios->c_iflag & IXON ) {
@@ -3107,7 +3107,7 @@ change_speed(struct e100_serial *info)
3107 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); 3107 xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
3108 } 3108 }
3109 3109
3110 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 3110 *((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
3111 local_irq_restore(flags); 3111 local_irq_restore(flags);
3112#endif /* !CONFIG_SVINTO_SIM */ 3112#endif /* !CONFIG_SVINTO_SIM */
3113 3113
@@ -3156,7 +3156,7 @@ static int rs_raw_write(struct tty_struct *tty,
3156#ifdef SERIAL_DEBUG_DATA 3156#ifdef SERIAL_DEBUG_DATA
3157 if (info->line == SERIAL_DEBUG_LINE) 3157 if (info->line == SERIAL_DEBUG_LINE)
3158 printk("rs_raw_write (%d), status %d\n", 3158 printk("rs_raw_write (%d), status %d\n",
3159 count, info->port[REG_STATUS]); 3159 count, info->ioport[REG_STATUS]);
3160#endif 3160#endif
3161 3161
3162#ifdef CONFIG_SVINTO_SIM 3162#ifdef CONFIG_SVINTO_SIM
@@ -3427,7 +3427,7 @@ get_serial_info(struct e100_serial * info,
3427 memset(&tmp, 0, sizeof(tmp)); 3427 memset(&tmp, 0, sizeof(tmp));
3428 tmp.type = info->type; 3428 tmp.type = info->type;
3429 tmp.line = info->line; 3429 tmp.line = info->line;
3430 tmp.port = (int)info->port; 3430 tmp.port = (int)info->ioport;
3431 tmp.irq = info->irq; 3431 tmp.irq = info->irq;
3432 tmp.flags = info->flags; 3432 tmp.flags = info->flags;
3433 tmp.baud_base = info->baud_base; 3433 tmp.baud_base = info->baud_base;
@@ -3557,14 +3557,14 @@ char *get_control_state_str(int MLines, char *s)
3557} 3557}
3558#endif 3558#endif
3559 3559
3560static void 3560static int
3561rs_break(struct tty_struct *tty, int break_state) 3561rs_break(struct tty_struct *tty, int break_state)
3562{ 3562{
3563 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3563 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3564 unsigned long flags; 3564 unsigned long flags;
3565 3565
3566 if (!info->port) 3566 if (!info->ioport)
3567 return; 3567 return -EIO;
3568 3568
3569 local_irq_save(flags); 3569 local_irq_save(flags);
3570 if (break_state == -1) { 3570 if (break_state == -1) {
@@ -3575,8 +3575,9 @@ rs_break(struct tty_struct *tty, int break_state)
3575 /* Set bit 7 (txd) and 6 (tr_enable) */ 3575 /* Set bit 7 (txd) and 6 (tr_enable) */
3576 info->tx_ctrl |= (0x80 | 0x40); 3576 info->tx_ctrl |= (0x80 | 0x40);
3577 } 3577 }
3578 info->port[REG_TR_CTRL] = info->tx_ctrl; 3578 info->ioport[REG_TR_CTRL] = info->tx_ctrl;
3579 local_irq_restore(flags); 3579 local_irq_restore(flags);
3580 return 0;
3580} 3581}
3581 3582
3582static int 3583static int
@@ -4231,9 +4232,9 @@ static int line_info(char *buf, struct e100_serial *info)
4231 unsigned long tmp; 4232 unsigned long tmp;
4232 4233
4233 ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d", 4234 ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d",
4234 info->line, (unsigned long)info->port, info->irq); 4235 info->line, (unsigned long)info->ioport, info->irq);
4235 4236
4236 if (!info->port || (info->type == PORT_UNKNOWN)) { 4237 if (!info->ioport || (info->type == PORT_UNKNOWN)) {
4237 ret += sprintf(buf+ret, "\n"); 4238 ret += sprintf(buf+ret, "\n");
4238 return ret; 4239 return ret;
4239 } 4240 }
@@ -4281,7 +4282,7 @@ static int line_info(char *buf, struct e100_serial *info)
4281 } 4282 }
4282 4283
4283 { 4284 {
4284 unsigned char rstat = info->port[REG_STATUS]; 4285 unsigned char rstat = info->ioport[REG_STATUS];
4285 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) 4286 if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) )
4286 ret += sprintf(buf+ret, " xoff_detect:1"); 4287 ret += sprintf(buf+ret, " xoff_detect:1");
4287 } 4288 }
@@ -4502,7 +4503,7 @@ rs_init(void)
4502 4503
4503 if (info->enabled) { 4504 if (info->enabled) {
4504 printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n", 4505 printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n",
4505 serial_driver->name, info->line, (unsigned int)info->port); 4506 serial_driver->name, info->line, (unsigned int)info->ioport);
4506 } 4507 }
4507 } 4508 }
4508#ifdef CONFIG_ETRAX_FAST_TIMER 4509#ifdef CONFIG_ETRAX_FAST_TIMER
diff --git a/drivers/serial/crisv10.h b/drivers/serial/crisv10.h
index ccd0f32b7372..e3c5c8c3c09b 100644
--- a/drivers/serial/crisv10.h
+++ b/drivers/serial/crisv10.h
@@ -36,8 +36,9 @@ struct etrax_recv_buffer {
36}; 36};
37 37
38struct e100_serial { 38struct e100_serial {
39 struct tty_port port;
39 int baud; 40 int baud;
40 volatile u8 *port; /* R_SERIALx_CTRL */ 41 volatile u8 *ioport; /* R_SERIALx_CTRL */
41 u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */ 42 u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */
42 43
43 /* Output registers */ 44 /* Output registers */
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index cd728df6a01a..8a0749e34ca3 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -451,19 +451,21 @@ SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
451SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) 451SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
452SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 452SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
453#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ 453#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
454 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
455 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 454 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
456 defined(CONFIG_CPU_SUBTYPE_SH7785) 455 defined(CONFIG_CPU_SUBTYPE_SH7785)
456SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
457SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) 457SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
458SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) 458SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
459SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) 459SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
460SCIF_FNS(SCLSR, 0, 0, 0x28, 16) 460SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
461#if defined(CONFIG_CPU_SUBTYPE_SH7763) 461#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
462/* SH7763 SCIF2 */
463SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) 462SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
464SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) 463SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16)
465SCIF_FNS(SCLSR2, 0, 0, 0x24, 16) 464SCIF_FNS(SCLSR2, 0, 0, 0x24, 16)
466#endif /* CONFIG_CPU_SUBTYPE_SH7763 */ 465SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
466SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
467SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
468SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
467#else 469#else
468SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 470SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
469#if defined(CONFIG_CPU_SUBTYPE_SH7722) 471#if defined(CONFIG_CPU_SUBTYPE_SH7722)
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 617efb1640b1..be97789fa5fd 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -24,13 +24,12 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/maple.h> 25#include <linux/maple.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/delay.h>
27#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
28#include <asm/dma.h> 29#include <asm/dma.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/mach/dma.h> 31#include <mach/dma.h>
31#include <asm/mach/sysasic.h> 32#include <mach/sysasic.h>
32#include <asm/mach/maple.h>
33#include <linux/delay.h>
34 33
35MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin"); 34MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin");
36MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); 35MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
@@ -46,14 +45,15 @@ static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);
46static LIST_HEAD(maple_waitq); 45static LIST_HEAD(maple_waitq);
47static LIST_HEAD(maple_sentq); 46static LIST_HEAD(maple_sentq);
48 47
49static DEFINE_MUTEX(maple_list_lock); 48/* mutex to protect queue of waiting packets */
49static DEFINE_MUTEX(maple_wlist_lock);
50 50
51static struct maple_driver maple_dummy_driver; 51static struct maple_driver maple_dummy_driver;
52static struct device maple_bus; 52static struct device maple_bus;
53static int subdevice_map[MAPLE_PORTS]; 53static int subdevice_map[MAPLE_PORTS];
54static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; 54static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
55static unsigned long maple_pnp_time; 55static unsigned long maple_pnp_time;
56static int started, scanning, liststatus, fullscan; 56static int started, scanning, fullscan;
57static struct kmem_cache *maple_queue_cache; 57static struct kmem_cache *maple_queue_cache;
58 58
59struct maple_device_specify { 59struct maple_device_specify {
@@ -129,35 +129,124 @@ static void maple_release_device(struct device *dev)
129 kfree(mdev); 129 kfree(mdev);
130} 130}
131 131
132/** 132/*
133 * maple_add_packet - add a single instruction to the queue 133 * maple_add_packet - add a single instruction to the queue
134 * @mq: instruction to add to waiting queue 134 * @mdev - maple device
135 * @function - function on device being queried
136 * @command - maple command to add
137 * @length - length of command string (in 32 bit words)
138 * @data - remainder of command string
135 */ 139 */
136void maple_add_packet(struct mapleq *mq) 140int maple_add_packet(struct maple_device *mdev, u32 function, u32 command,
141 size_t length, void *data)
137{ 142{
138 mutex_lock(&maple_list_lock); 143 int locking, ret = 0;
139 list_add(&mq->list, &maple_waitq); 144 void *sendbuf = NULL;
140 mutex_unlock(&maple_list_lock); 145
146 mutex_lock(&maple_wlist_lock);
147 /* bounce if device already locked */
148 locking = mutex_is_locked(&mdev->mq->mutex);
149 if (locking) {
150 ret = -EBUSY;
151 goto out;
152 }
153
154 mutex_lock(&mdev->mq->mutex);
155
156 if (length) {
157 sendbuf = kmalloc(length * 4, GFP_KERNEL);
158 if (!sendbuf) {
159 mutex_unlock(&mdev->mq->mutex);
160 ret = -ENOMEM;
161 goto out;
162 }
163 ((__be32 *)sendbuf)[0] = cpu_to_be32(function);
164 }
165
166 mdev->mq->command = command;
167 mdev->mq->length = length;
168 if (length > 1)
169 memcpy(sendbuf + 4, data, (length - 1) * 4);
170 mdev->mq->sendbuf = sendbuf;
171
172 list_add(&mdev->mq->list, &maple_waitq);
173out:
174 mutex_unlock(&maple_wlist_lock);
175 return ret;
141} 176}
142EXPORT_SYMBOL_GPL(maple_add_packet); 177EXPORT_SYMBOL_GPL(maple_add_packet);
143 178
179/*
180 * maple_add_packet_sleeps - add a single instruction to the queue
181 * - waits for lock to be free
182 * @mdev - maple device
183 * @function - function on device being queried
184 * @command - maple command to add
185 * @length - length of command string (in 32 bit words)
186 * @data - remainder of command string
187 */
188int maple_add_packet_sleeps(struct maple_device *mdev, u32 function,
189 u32 command, size_t length, void *data)
190{
191 int locking, ret = 0;
192 void *sendbuf = NULL;
193
194 locking = mutex_lock_interruptible(&mdev->mq->mutex);
195 if (locking) {
196 ret = -EIO;
197 goto out;
198 }
199
200 if (length) {
201 sendbuf = kmalloc(length * 4, GFP_KERNEL);
202 if (!sendbuf) {
203 mutex_unlock(&mdev->mq->mutex);
204 ret = -ENOMEM;
205 goto out;
206 }
207 ((__be32 *)sendbuf)[0] = cpu_to_be32(function);
208 }
209
210 mdev->mq->command = command;
211 mdev->mq->length = length;
212 if (length > 1)
213 memcpy(sendbuf + 4, data, (length - 1) * 4);
214 mdev->mq->sendbuf = sendbuf;
215
216 mutex_lock(&maple_wlist_lock);
217 list_add(&mdev->mq->list, &maple_waitq);
218 mutex_unlock(&maple_wlist_lock);
219out:
220 return ret;
221}
222EXPORT_SYMBOL_GPL(maple_add_packet_sleeps);
223
144static struct mapleq *maple_allocq(struct maple_device *mdev) 224static struct mapleq *maple_allocq(struct maple_device *mdev)
145{ 225{
146 struct mapleq *mq; 226 struct mapleq *mq;
147 227
148 mq = kmalloc(sizeof(*mq), GFP_KERNEL); 228 mq = kmalloc(sizeof(*mq), GFP_KERNEL);
149 if (!mq) 229 if (!mq)
150 return NULL; 230 goto failed_nomem;
151 231
152 mq->dev = mdev; 232 mq->dev = mdev;
153 mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL); 233 mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
154 mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp); 234 mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
155 if (!mq->recvbuf) { 235 if (!mq->recvbuf)
156 kfree(mq); 236 goto failed_p2;
157 return NULL; 237 /*
158 } 238 * most devices do not need the mutex - but
239 * anything that injects block reads or writes
240 * will rely on it
241 */
242 mutex_init(&mq->mutex);
159 243
160 return mq; 244 return mq;
245
246failed_p2:
247 kfree(mq);
248failed_nomem:
249 return NULL;
161} 250}
162 251
163static struct maple_device *maple_alloc_dev(int port, int unit) 252static struct maple_device *maple_alloc_dev(int port, int unit)
@@ -178,7 +267,6 @@ static struct maple_device *maple_alloc_dev(int port, int unit)
178 } 267 }
179 mdev->dev.bus = &maple_bus_type; 268 mdev->dev.bus = &maple_bus_type;
180 mdev->dev.parent = &maple_bus; 269 mdev->dev.parent = &maple_bus;
181 mdev->function = 0;
182 return mdev; 270 return mdev;
183} 271}
184 272
@@ -216,7 +304,6 @@ static void maple_build_block(struct mapleq *mq)
216 *maple_sendptr++ = PHYSADDR(mq->recvbuf); 304 *maple_sendptr++ = PHYSADDR(mq->recvbuf);
217 *maple_sendptr++ = 305 *maple_sendptr++ =
218 mq->command | (to << 8) | (from << 16) | (len << 24); 306 mq->command | (to << 8) | (from << 16) | (len << 24);
219
220 while (len-- > 0) 307 while (len-- > 0)
221 *maple_sendptr++ = *lsendbuf++; 308 *maple_sendptr++ = *lsendbuf++;
222} 309}
@@ -224,22 +311,27 @@ static void maple_build_block(struct mapleq *mq)
224/* build up command queue */ 311/* build up command queue */
225static void maple_send(void) 312static void maple_send(void)
226{ 313{
227 int i; 314 int i, maple_packets = 0;
228 int maple_packets;
229 struct mapleq *mq, *nmq; 315 struct mapleq *mq, *nmq;
230 316
231 if (!list_empty(&maple_sentq)) 317 if (!list_empty(&maple_sentq))
232 return; 318 return;
233 if (list_empty(&maple_waitq) || !maple_dma_done()) 319 mutex_lock(&maple_wlist_lock);
320 if (list_empty(&maple_waitq) || !maple_dma_done()) {
321 mutex_unlock(&maple_wlist_lock);
234 return; 322 return;
235 maple_packets = 0; 323 }
236 maple_sendptr = maple_lastptr = maple_sendbuf; 324 mutex_unlock(&maple_wlist_lock);
325 maple_lastptr = maple_sendbuf;
326 maple_sendptr = maple_sendbuf;
327 mutex_lock(&maple_wlist_lock);
237 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) { 328 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) {
238 maple_build_block(mq); 329 maple_build_block(mq);
239 list_move(&mq->list, &maple_sentq); 330 list_move(&mq->list, &maple_sentq);
240 if (maple_packets++ > MAPLE_MAXPACKETS) 331 if (maple_packets++ > MAPLE_MAXPACKETS)
241 break; 332 break;
242 } 333 }
334 mutex_unlock(&maple_wlist_lock);
243 if (maple_packets > 0) { 335 if (maple_packets > 0) {
244 for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) 336 for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++)
245 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE, 337 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE,
@@ -247,7 +339,8 @@ static void maple_send(void)
247 } 339 }
248} 340}
249 341
250static int attach_matching_maple_driver(struct device_driver *driver, 342/* check if there is a driver registered likely to match this device */
343static int check_matching_maple_driver(struct device_driver *driver,
251 void *devptr) 344 void *devptr)
252{ 345{
253 struct maple_driver *maple_drv; 346 struct maple_driver *maple_drv;
@@ -255,12 +348,8 @@ static int attach_matching_maple_driver(struct device_driver *driver,
255 348
256 mdev = devptr; 349 mdev = devptr;
257 maple_drv = to_maple_driver(driver); 350 maple_drv = to_maple_driver(driver);
258 if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) { 351 if (mdev->devinfo.function & cpu_to_be32(maple_drv->function))
259 if (maple_drv->connect(mdev) == 0) { 352 return 1;
260 mdev->driver = maple_drv;
261 return 1;
262 }
263 }
264 return 0; 353 return 0;
265} 354}
266 355
@@ -268,11 +357,6 @@ static void maple_detach_driver(struct maple_device *mdev)
268{ 357{
269 if (!mdev) 358 if (!mdev)
270 return; 359 return;
271 if (mdev->driver) {
272 if (mdev->driver->disconnect)
273 mdev->driver->disconnect(mdev);
274 }
275 mdev->driver = NULL;
276 device_unregister(&mdev->dev); 360 device_unregister(&mdev->dev);
277 mdev = NULL; 361 mdev = NULL;
278} 362}
@@ -328,8 +412,8 @@ static void maple_attach_driver(struct maple_device *mdev)
328 mdev->port, mdev->unit, function); 412 mdev->port, mdev->unit, function);
329 413
330 matched = 414 matched =
331 bus_for_each_drv(&maple_bus_type, NULL, mdev, 415 bus_for_each_drv(&maple_bus_type, NULL, mdev,
332 attach_matching_maple_driver); 416 check_matching_maple_driver);
333 417
334 if (matched == 0) { 418 if (matched == 0) {
335 /* Driver does not exist yet */ 419 /* Driver does not exist yet */
@@ -373,45 +457,48 @@ static int detach_maple_device(struct device *device, void *portptr)
373 457
374static int setup_maple_commands(struct device *device, void *ignored) 458static int setup_maple_commands(struct device *device, void *ignored)
375{ 459{
460 int add;
376 struct maple_device *maple_dev = to_maple_dev(device); 461 struct maple_device *maple_dev = to_maple_dev(device);
377 462
378 if ((maple_dev->interval > 0) 463 if ((maple_dev->interval > 0)
379 && time_after(jiffies, maple_dev->when)) { 464 && time_after(jiffies, maple_dev->when)) {
380 maple_dev->when = jiffies + maple_dev->interval; 465 /* bounce if we cannot lock */
381 maple_dev->mq->command = MAPLE_COMMAND_GETCOND; 466 add = maple_add_packet(maple_dev,
382 maple_dev->mq->sendbuf = &maple_dev->function; 467 be32_to_cpu(maple_dev->devinfo.function),
383 maple_dev->mq->length = 1; 468 MAPLE_COMMAND_GETCOND, 1, NULL);
384 maple_add_packet(maple_dev->mq); 469 if (!add)
385 liststatus++; 470 maple_dev->when = jiffies + maple_dev->interval;
386 } else { 471 } else {
387 if (time_after(jiffies, maple_pnp_time)) { 472 if (time_after(jiffies, maple_pnp_time))
388 maple_dev->mq->command = MAPLE_COMMAND_DEVINFO; 473 /* This will also bounce */
389 maple_dev->mq->length = 0; 474 maple_add_packet(maple_dev, 0,
390 maple_add_packet(maple_dev->mq); 475 MAPLE_COMMAND_DEVINFO, 0, NULL);
391 liststatus++;
392 }
393 } 476 }
394
395 return 0; 477 return 0;
396} 478}
397 479
398/* VBLANK bottom half - implemented via workqueue */ 480/* VBLANK bottom half - implemented via workqueue */
399static void maple_vblank_handler(struct work_struct *work) 481static void maple_vblank_handler(struct work_struct *work)
400{ 482{
401 if (!maple_dma_done()) 483 if (!list_empty(&maple_sentq) || !maple_dma_done())
402 return;
403 if (!list_empty(&maple_sentq))
404 return; 484 return;
485
405 ctrl_outl(0, MAPLE_ENABLE); 486 ctrl_outl(0, MAPLE_ENABLE);
406 liststatus = 0; 487
407 bus_for_each_dev(&maple_bus_type, NULL, NULL, 488 bus_for_each_dev(&maple_bus_type, NULL, NULL,
408 setup_maple_commands); 489 setup_maple_commands);
490
409 if (time_after(jiffies, maple_pnp_time)) 491 if (time_after(jiffies, maple_pnp_time))
410 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL; 492 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL;
411 if (liststatus && list_empty(&maple_sentq)) { 493
412 INIT_LIST_HEAD(&maple_sentq); 494 mutex_lock(&maple_wlist_lock);
495 if (!list_empty(&maple_waitq) && list_empty(&maple_sentq)) {
496 mutex_unlock(&maple_wlist_lock);
413 maple_send(); 497 maple_send();
498 } else {
499 mutex_unlock(&maple_wlist_lock);
414 } 500 }
501
415 maplebus_dma_reset(); 502 maplebus_dma_reset();
416} 503}
417 504
@@ -422,8 +509,8 @@ static void maple_map_subunits(struct maple_device *mdev, int submask)
422 struct maple_device *mdev_add; 509 struct maple_device *mdev_add;
423 struct maple_device_specify ds; 510 struct maple_device_specify ds;
424 511
512 ds.port = mdev->port;
425 for (k = 0; k < 5; k++) { 513 for (k = 0; k < 5; k++) {
426 ds.port = mdev->port;
427 ds.unit = k + 1; 514 ds.unit = k + 1;
428 retval = 515 retval =
429 bus_for_each_dev(&maple_bus_type, NULL, &ds, 516 bus_for_each_dev(&maple_bus_type, NULL, &ds,
@@ -437,9 +524,9 @@ static void maple_map_subunits(struct maple_device *mdev, int submask)
437 mdev_add = maple_alloc_dev(mdev->port, k + 1); 524 mdev_add = maple_alloc_dev(mdev->port, k + 1);
438 if (!mdev_add) 525 if (!mdev_add)
439 return; 526 return;
440 mdev_add->mq->command = MAPLE_COMMAND_DEVINFO; 527 maple_add_packet(mdev_add, 0, MAPLE_COMMAND_DEVINFO,
441 mdev_add->mq->length = 0; 528 0, NULL);
442 maple_add_packet(mdev_add->mq); 529 /* mark that we are checking sub devices */
443 scanning = 1; 530 scanning = 1;
444 } 531 }
445 submask = submask >> 1; 532 submask = submask >> 1;
@@ -505,6 +592,28 @@ static void maple_response_devinfo(struct maple_device *mdev,
505 } 592 }
506} 593}
507 594
595static void maple_port_rescan(void)
596{
597 int i;
598 struct maple_device *mdev;
599
600 fullscan = 1;
601 for (i = 0; i < MAPLE_PORTS; i++) {
602 if (checked[i] == false) {
603 fullscan = 0;
604 mdev = baseunits[i];
605 /*
606 * test lock in case scan has failed
607 * but device is still locked
608 */
609 if (mutex_is_locked(&mdev->mq->mutex))
610 mutex_unlock(&mdev->mq->mutex);
611 maple_add_packet(mdev, 0, MAPLE_COMMAND_DEVINFO,
612 0, NULL);
613 }
614 }
615}
616
508/* maple dma end bottom half - implemented via workqueue */ 617/* maple dma end bottom half - implemented via workqueue */
509static void maple_dma_handler(struct work_struct *work) 618static void maple_dma_handler(struct work_struct *work)
510{ 619{
@@ -512,7 +621,6 @@ static void maple_dma_handler(struct work_struct *work)
512 struct maple_device *dev; 621 struct maple_device *dev;
513 char *recvbuf; 622 char *recvbuf;
514 enum maple_code code; 623 enum maple_code code;
515 int i;
516 624
517 if (!maple_dma_done()) 625 if (!maple_dma_done())
518 return; 626 return;
@@ -522,6 +630,10 @@ static void maple_dma_handler(struct work_struct *work)
522 recvbuf = mq->recvbuf; 630 recvbuf = mq->recvbuf;
523 code = recvbuf[0]; 631 code = recvbuf[0];
524 dev = mq->dev; 632 dev = mq->dev;
633 kfree(mq->sendbuf);
634 mutex_unlock(&mq->mutex);
635 list_del_init(&mq->list);
636
525 switch (code) { 637 switch (code) {
526 case MAPLE_RESPONSE_NONE: 638 case MAPLE_RESPONSE_NONE:
527 maple_response_none(dev, mq); 639 maple_response_none(dev, mq);
@@ -558,26 +670,16 @@ static void maple_dma_handler(struct work_struct *work)
558 break; 670 break;
559 } 671 }
560 } 672 }
561 INIT_LIST_HEAD(&maple_sentq); 673 /* if scanning is 1 then we have subdevices to check */
562 if (scanning == 1) { 674 if (scanning == 1) {
563 maple_send(); 675 maple_send();
564 scanning = 2; 676 scanning = 2;
565 } else 677 } else
566 scanning = 0; 678 scanning = 0;
567 679 /*check if we have actually tested all ports yet */
568 if (!fullscan) { 680 if (!fullscan)
569 fullscan = 1; 681 maple_port_rescan();
570 for (i = 0; i < MAPLE_PORTS; i++) { 682 /* mark that we have been through the first scan */
571 if (checked[i] == false) {
572 fullscan = 0;
573 dev = baseunits[i];
574 dev->mq->command =
575 MAPLE_COMMAND_DEVINFO;
576 dev->mq->length = 0;
577 maple_add_packet(dev->mq);
578 }
579 }
580 }
581 if (started == 0) 683 if (started == 0)
582 started = 1; 684 started = 1;
583 } 685 }
@@ -631,7 +733,7 @@ static int match_maple_bus_driver(struct device *devptr,
631 if (maple_dev->devinfo.function == 0xFFFFFFFF) 733 if (maple_dev->devinfo.function == 0xFFFFFFFF)
632 return 0; 734 return 0;
633 else if (maple_dev->devinfo.function & 735 else if (maple_dev->devinfo.function &
634 be32_to_cpu(maple_drv->function)) 736 cpu_to_be32(maple_drv->function))
635 return 1; 737 return 1;
636 return 0; 738 return 0;
637} 739}
@@ -713,6 +815,9 @@ static int __init maple_bus_init(void)
713 if (!maple_queue_cache) 815 if (!maple_queue_cache)
714 goto cleanup_bothirqs; 816 goto cleanup_bothirqs;
715 817
818 INIT_LIST_HEAD(&maple_waitq);
819 INIT_LIST_HEAD(&maple_sentq);
820
716 /* setup maple ports */ 821 /* setup maple ports */
717 for (i = 0; i < MAPLE_PORTS; i++) { 822 for (i = 0; i < MAPLE_PORTS; i++) {
718 checked[i] = false; 823 checked[i] = false;
@@ -723,9 +828,7 @@ static int __init maple_bus_init(void)
723 maple_free_dev(mdev[i]); 828 maple_free_dev(mdev[i]);
724 goto cleanup_cache; 829 goto cleanup_cache;
725 } 830 }
726 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO; 831 maple_add_packet(mdev[i], 0, MAPLE_COMMAND_DEVINFO, 0, NULL);
727 mdev[i]->mq->length = 0;
728 maple_add_packet(mdev[i]->mq);
729 subdevice_map[i] = 0; 832 subdevice_map[i] = 0;
730 } 833 }
731 834
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 0c7165660853..95190c619c10 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -184,7 +184,8 @@ static void atmel_spi_next_xfer(struct spi_master *master,
184{ 184{
185 struct atmel_spi *as = spi_master_get_devdata(master); 185 struct atmel_spi *as = spi_master_get_devdata(master);
186 struct spi_transfer *xfer; 186 struct spi_transfer *xfer;
187 u32 len, remaining, total; 187 u32 len, remaining;
188 u32 ieval;
188 dma_addr_t tx_dma, rx_dma; 189 dma_addr_t tx_dma, rx_dma;
189 190
190 if (!as->current_transfer) 191 if (!as->current_transfer)
@@ -197,6 +198,8 @@ static void atmel_spi_next_xfer(struct spi_master *master,
197 xfer = NULL; 198 xfer = NULL;
198 199
199 if (xfer) { 200 if (xfer) {
201 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
202
200 len = xfer->len; 203 len = xfer->len;
201 atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len); 204 atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
202 remaining = xfer->len - len; 205 remaining = xfer->len - len;
@@ -234,6 +237,8 @@ static void atmel_spi_next_xfer(struct spi_master *master,
234 as->next_transfer = xfer; 237 as->next_transfer = xfer;
235 238
236 if (xfer) { 239 if (xfer) {
240 u32 total;
241
237 total = len; 242 total = len;
238 atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len); 243 atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
239 as->next_remaining_bytes = total - len; 244 as->next_remaining_bytes = total - len;
@@ -250,9 +255,11 @@ static void atmel_spi_next_xfer(struct spi_master *master,
250 " next xfer %p: len %u tx %p/%08x rx %p/%08x\n", 255 " next xfer %p: len %u tx %p/%08x rx %p/%08x\n",
251 xfer, xfer->len, xfer->tx_buf, xfer->tx_dma, 256 xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
252 xfer->rx_buf, xfer->rx_dma); 257 xfer->rx_buf, xfer->rx_dma);
258 ieval = SPI_BIT(ENDRX) | SPI_BIT(OVRES);
253 } else { 259 } else {
254 spi_writel(as, RNCR, 0); 260 spi_writel(as, RNCR, 0);
255 spi_writel(as, TNCR, 0); 261 spi_writel(as, TNCR, 0);
262 ieval = SPI_BIT(RXBUFF) | SPI_BIT(ENDRX) | SPI_BIT(OVRES);
256 } 263 }
257 264
258 /* REVISIT: We're waiting for ENDRX before we start the next 265 /* REVISIT: We're waiting for ENDRX before we start the next
@@ -265,7 +272,7 @@ static void atmel_spi_next_xfer(struct spi_master *master,
265 * 272 *
266 * It should be doable, though. Just not now... 273 * It should be doable, though. Just not now...
267 */ 274 */
268 spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES)); 275 spi_writel(as, IER, ieval);
269 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); 276 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
270} 277}
271 278
@@ -396,7 +403,7 @@ atmel_spi_interrupt(int irq, void *dev_id)
396 403
397 ret = IRQ_HANDLED; 404 ret = IRQ_HANDLED;
398 405
399 spi_writel(as, IDR, (SPI_BIT(ENDTX) | SPI_BIT(ENDRX) 406 spi_writel(as, IDR, (SPI_BIT(RXBUFF) | SPI_BIT(ENDRX)
400 | SPI_BIT(OVRES))); 407 | SPI_BIT(OVRES)));
401 408
402 /* 409 /*
@@ -418,7 +425,7 @@ atmel_spi_interrupt(int irq, void *dev_id)
418 if (xfer->delay_usecs) 425 if (xfer->delay_usecs)
419 udelay(xfer->delay_usecs); 426 udelay(xfer->delay_usecs);
420 427
421 dev_warn(master->dev.parent, "fifo overrun (%u/%u remaining)\n", 428 dev_warn(master->dev.parent, "overrun (%u/%u remaining)\n",
422 spi_readl(as, TCR), spi_readl(as, RCR)); 429 spi_readl(as, TCR), spi_readl(as, RCR));
423 430
424 /* 431 /*
@@ -442,7 +449,7 @@ atmel_spi_interrupt(int irq, void *dev_id)
442 spi_readl(as, SR); 449 spi_readl(as, SR);
443 450
444 atmel_spi_msg_done(master, as, msg, -EIO, 0); 451 atmel_spi_msg_done(master, as, msg, -EIO, 0);
445 } else if (pending & SPI_BIT(ENDRX)) { 452 } else if (pending & (SPI_BIT(RXBUFF) | SPI_BIT(ENDRX))) {
446 ret = IRQ_HANDLED; 453 ret = IRQ_HANDLED;
447 454
448 spi_writel(as, IDR, pending); 455 spi_writel(as, IDR, pending);
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 1c643c9e1f15..21661c7959c8 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -236,6 +236,19 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev)
236 return IRQ_HANDLED; 236 return IRQ_HANDLED;
237} 237}
238 238
239static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw)
240{
241 /* for the moment, permanently enable the clock */
242
243 clk_enable(hw->clk);
244
245 /* program defaults into the registers */
246
247 writeb(0xff, hw->regs + S3C2410_SPPRE);
248 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN);
249 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON);
250}
251
239static int __init s3c24xx_spi_probe(struct platform_device *pdev) 252static int __init s3c24xx_spi_probe(struct platform_device *pdev)
240{ 253{
241 struct s3c2410_spi_info *pdata; 254 struct s3c2410_spi_info *pdata;
@@ -327,15 +340,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
327 goto err_no_clk; 340 goto err_no_clk;
328 } 341 }
329 342
330 /* for the moment, permanently enable the clock */ 343 s3c24xx_spi_initialsetup(hw);
331
332 clk_enable(hw->clk);
333
334 /* program defaults into the registers */
335
336 writeb(0xff, hw->regs + S3C2410_SPPRE);
337 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN);
338 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON);
339 344
340 /* setup any gpio we can */ 345 /* setup any gpio we can */
341 346
@@ -415,7 +420,7 @@ static int s3c24xx_spi_resume(struct platform_device *pdev)
415{ 420{
416 struct s3c24xx_spi *hw = platform_get_drvdata(pdev); 421 struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
417 422
418 clk_enable(hw->clk); 423 s3c24xx_spi_initialsetup(hw);
419 return 0; 424 return 0;
420} 425}
421 426
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 0ebc1bfd2514..a6b55297a7fb 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -118,7 +118,6 @@ obj-$(CONFIG_FB_PS3) += ps3fb.o
118obj-$(CONFIG_FB_SM501) += sm501fb.o 118obj-$(CONFIG_FB_SM501) += sm501fb.o
119obj-$(CONFIG_FB_XILINX) += xilinxfb.o 119obj-$(CONFIG_FB_XILINX) += xilinxfb.o
120obj-$(CONFIG_FB_SH_MOBILE_LCDC) += sh_mobile_lcdcfb.o 120obj-$(CONFIG_FB_SH_MOBILE_LCDC) += sh_mobile_lcdcfb.o
121obj-$(CONFIG_FB_SH7343VOU) += sh7343_voufb.o
122obj-$(CONFIG_FB_OMAP) += omap/ 121obj-$(CONFIG_FB_OMAP) += omap/
123obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o 122obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o
124obj-$(CONFIG_FB_CARMINE) += carminefb.o 123obj-$(CONFIG_FB_CARMINE) += carminefb.o
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index fbea2bd129c7..6fa0b9d5559a 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -18,7 +18,7 @@
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/backlight.h> 19#include <linux/backlight.h>
20 20
21#include <asm/cpu/dac.h> 21#include <cpu/dac.h>
22#include <asm/hp6xx.h> 22#include <asm/hp6xx.h>
23#include <asm/hd64461.h> 23#include <asm/hd64461.h>
24 24
diff --git a/drivers/video/console/.gitignore b/drivers/video/console/.gitignore
new file mode 100644
index 000000000000..0c258b45439c
--- /dev/null
+++ b/drivers/video/console/.gitignore
@@ -0,0 +1,2 @@
1# conmakehash generated file
2promcon_tbl.c
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 392a8be6aa76..e6467cf9f19f 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -27,7 +27,7 @@
27#include <asm/pgtable.h> 27#include <asm/pgtable.h>
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/hd64461.h> 29#include <asm/hd64461.h>
30#include <asm/cpu/dac.h> 30#include <cpu/dac.h>
31 31
32#define WIDTH 640 32#define WIDTH 640
33 33
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 54e82f35353d..c02136202792 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -2536,7 +2536,7 @@ module_param(fh, int, 0);
2536MODULE_PARM_DESC(fh, "Startup horizontal frequency, 0-999kHz, 1000-INF Hz"); 2536MODULE_PARM_DESC(fh, "Startup horizontal frequency, 0-999kHz, 1000-INF Hz");
2537module_param(fv, int, 0); 2537module_param(fv, int, 0);
2538MODULE_PARM_DESC(fv, "Startup vertical frequency, 0-INF Hz\n" 2538MODULE_PARM_DESC(fv, "Startup vertical frequency, 0-INF Hz\n"
2539"You should specify \"fv:max_monitor_vsync,fh:max_monitor_hsync,maxclk:max_monitor_dotclock\"\n"); 2539"You should specify \"fv:max_monitor_vsync,fh:max_monitor_hsync,maxclk:max_monitor_dotclock\"");
2540module_param(grayscale, int, 0); 2540module_param(grayscale, int, 0);
2541MODULE_PARM_DESC(grayscale, "Sets display into grayscale. Works perfectly with paletized videomode (4, 8bpp), some limitations apply to 16, 24 and 32bpp videomodes (default=nograyscale)"); 2541MODULE_PARM_DESC(grayscale, "Sets display into grayscale. Works perfectly with paletized videomode (4, 8bpp), some limitations apply to 16, 24 and 32bpp videomodes (default=nograyscale)");
2542module_param(cross4MB, int, 0); 2542module_param(cross4MB, int, 0);
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 8c863a7f654b..0a0fd48a8566 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -58,18 +58,18 @@
58 58
59#ifdef CONFIG_SH_DREAMCAST 59#ifdef CONFIG_SH_DREAMCAST
60#include <asm/machvec.h> 60#include <asm/machvec.h>
61#include <asm/mach/sysasic.h> 61#include <mach-dreamcast/mach/sysasic.h>
62#endif 62#endif
63 63
64#ifdef CONFIG_SH_DMA 64#ifdef CONFIG_SH_DMA
65#include <linux/pagemap.h> 65#include <linux/pagemap.h>
66#include <asm/mach/dma.h> 66#include <mach/dma.h>
67#include <asm/dma.h> 67#include <asm/dma.h>
68#endif 68#endif
69 69
70#ifdef CONFIG_SH_STORE_QUEUES 70#ifdef CONFIG_SH_STORE_QUEUES
71#include <linux/uaccess.h> 71#include <linux/uaccess.h>
72#include <asm/cpu/sq.h> 72#include <cpu/sq.h>
73#endif 73#endif
74 74
75#ifndef PCI_DEVICE_ID_NEC_NEON250 75#ifndef PCI_DEVICE_ID_NEC_NEON250
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c
index 2eb48c0df32c..ef7b0d67095e 100644
--- a/drivers/watchdog/ar7_wdt.c
+++ b/drivers/watchdog/ar7_wdt.c
@@ -69,7 +69,8 @@ struct ar7_wdt {
69 u32 prescale; 69 u32 prescale;
70}; 70};
71 71
72static struct semaphore open_semaphore; 72static unsigned long wdt_is_open;
73static spinlock_t wdt_lock;
73static unsigned expect_close; 74static unsigned expect_close;
74 75
75/* XXX currently fixed, allows max margin ~68.72 secs */ 76/* XXX currently fixed, allows max margin ~68.72 secs */
@@ -154,8 +155,10 @@ static void ar7_wdt_update_margin(int new_margin)
154 u32 change; 155 u32 change;
155 156
156 change = new_margin * (ar7_vbus_freq() / prescale_value); 157 change = new_margin * (ar7_vbus_freq() / prescale_value);
157 if (change < 1) change = 1; 158 if (change < 1)
158 if (change > 0xffff) change = 0xffff; 159 change = 1;
160 if (change > 0xffff)
161 change = 0xffff;
159 ar7_wdt_change(change); 162 ar7_wdt_change(change);
160 margin = change * prescale_value / ar7_vbus_freq(); 163 margin = change * prescale_value / ar7_vbus_freq();
161 printk(KERN_INFO DRVNAME 164 printk(KERN_INFO DRVNAME
@@ -179,7 +182,7 @@ static void ar7_wdt_disable_wdt(void)
179static int ar7_wdt_open(struct inode *inode, struct file *file) 182static int ar7_wdt_open(struct inode *inode, struct file *file)
180{ 183{
181 /* only allow one at a time */ 184 /* only allow one at a time */
182 if (down_trylock(&open_semaphore)) 185 if (test_and_set_bit(0, &wdt_is_open))
183 return -EBUSY; 186 return -EBUSY;
184 ar7_wdt_enable_wdt(); 187 ar7_wdt_enable_wdt();
185 expect_close = 0; 188 expect_close = 0;
@@ -195,9 +198,7 @@ static int ar7_wdt_release(struct inode *inode, struct file *file)
195 "will not disable the watchdog timer\n"); 198 "will not disable the watchdog timer\n");
196 else if (!nowayout) 199 else if (!nowayout)
197 ar7_wdt_disable_wdt(); 200 ar7_wdt_disable_wdt();
198 201 clear_bit(0, &wdt_is_open);
199 up(&open_semaphore);
200
201 return 0; 202 return 0;
202} 203}
203 204
@@ -222,7 +223,9 @@ static ssize_t ar7_wdt_write(struct file *file, const char *data,
222 if (len) { 223 if (len) {
223 size_t i; 224 size_t i;
224 225
226 spin_lock(&wdt_lock);
225 ar7_wdt_kick(1); 227 ar7_wdt_kick(1);
228 spin_unlock(&wdt_lock);
226 229
227 expect_close = 0; 230 expect_close = 0;
228 for (i = 0; i < len; ++i) { 231 for (i = 0; i < len; ++i) {
@@ -237,8 +240,8 @@ static ssize_t ar7_wdt_write(struct file *file, const char *data,
237 return len; 240 return len;
238} 241}
239 242
240static int ar7_wdt_ioctl(struct inode *inode, struct file *file, 243static long ar7_wdt_ioctl(struct file *file,
241 unsigned int cmd, unsigned long arg) 244 unsigned int cmd, unsigned long arg)
242{ 245{
243 static struct watchdog_info ident = { 246 static struct watchdog_info ident = {
244 .identity = LONGNAME, 247 .identity = LONGNAME,
@@ -269,8 +272,10 @@ static int ar7_wdt_ioctl(struct inode *inode, struct file *file,
269 if (new_margin < 1) 272 if (new_margin < 1)
270 return -EINVAL; 273 return -EINVAL;
271 274
275 spin_lock(&wdt_lock);
272 ar7_wdt_update_margin(new_margin); 276 ar7_wdt_update_margin(new_margin);
273 ar7_wdt_kick(1); 277 ar7_wdt_kick(1);
278 spin_unlock(&wdt_lock);
274 279
275 case WDIOC_GETTIMEOUT: 280 case WDIOC_GETTIMEOUT:
276 if (put_user(margin, (int *)arg)) 281 if (put_user(margin, (int *)arg))
@@ -282,7 +287,7 @@ static int ar7_wdt_ioctl(struct inode *inode, struct file *file,
282static const struct file_operations ar7_wdt_fops = { 287static const struct file_operations ar7_wdt_fops = {
283 .owner = THIS_MODULE, 288 .owner = THIS_MODULE,
284 .write = ar7_wdt_write, 289 .write = ar7_wdt_write,
285 .ioctl = ar7_wdt_ioctl, 290 .unlocked_ioctl = ar7_wdt_ioctl,
286 .open = ar7_wdt_open, 291 .open = ar7_wdt_open,
287 .release = ar7_wdt_release, 292 .release = ar7_wdt_release,
288}; 293};
@@ -297,6 +302,8 @@ static int __init ar7_wdt_init(void)
297{ 302{
298 int rc; 303 int rc;
299 304
305 spin_lock_init(&wdt_lock);
306
300 ar7_wdt_get_regs(); 307 ar7_wdt_get_regs();
301 308
302 if (!request_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt), 309 if (!request_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt),
@@ -312,8 +319,6 @@ static int __init ar7_wdt_init(void)
312 ar7_wdt_prescale(prescale_value); 319 ar7_wdt_prescale(prescale_value);
313 ar7_wdt_update_margin(margin); 320 ar7_wdt_update_margin(margin);
314 321
315 sema_init(&open_semaphore, 1);
316
317 rc = register_reboot_notifier(&ar7_wdt_notifier); 322 rc = register_reboot_notifier(&ar7_wdt_notifier);
318 if (rc) { 323 if (rc) {
319 printk(KERN_ERR DRVNAME 324 printk(KERN_ERR DRVNAME
diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c
index 445b7e812112..51bfd5721833 100644
--- a/drivers/watchdog/it8712f_wdt.c
+++ b/drivers/watchdog/it8712f_wdt.c
@@ -30,9 +30,8 @@
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33 33#include <linux/uaccess.h>
34#include <asm/uaccess.h> 34#include <linux/io.h>
35#include <asm/io.h>
36 35
37#define NAME "it8712f_wdt" 36#define NAME "it8712f_wdt"
38 37
@@ -50,7 +49,7 @@ static int nowayout = WATCHDOG_NOWAYOUT;
50module_param(nowayout, int, 0); 49module_param(nowayout, int, 0);
51MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); 50MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
52 51
53static struct semaphore it8712f_wdt_sem; 52static unsigned long wdt_open;
54static unsigned expect_close; 53static unsigned expect_close;
55static spinlock_t io_lock; 54static spinlock_t io_lock;
56static unsigned char revision; 55static unsigned char revision;
@@ -86,22 +85,19 @@ static unsigned short address;
86#define WDT_OUT_PWROK 0x10 85#define WDT_OUT_PWROK 0x10
87#define WDT_OUT_KRST 0x40 86#define WDT_OUT_KRST 0x40
88 87
89static int 88static int superio_inb(int reg)
90superio_inb(int reg)
91{ 89{
92 outb(reg, REG); 90 outb(reg, REG);
93 return inb(VAL); 91 return inb(VAL);
94} 92}
95 93
96static void 94static void superio_outb(int val, int reg)
97superio_outb(int val, int reg)
98{ 95{
99 outb(reg, REG); 96 outb(reg, REG);
100 outb(val, VAL); 97 outb(val, VAL);
101} 98}
102 99
103static int 100static int superio_inw(int reg)
104superio_inw(int reg)
105{ 101{
106 int val; 102 int val;
107 outb(reg++, REG); 103 outb(reg++, REG);
@@ -111,15 +107,13 @@ superio_inw(int reg)
111 return val; 107 return val;
112} 108}
113 109
114static inline void 110static inline void superio_select(int ldn)
115superio_select(int ldn)
116{ 111{
117 outb(LDN, REG); 112 outb(LDN, REG);
118 outb(ldn, VAL); 113 outb(ldn, VAL);
119} 114}
120 115
121static inline void 116static inline void superio_enter(void)
122superio_enter(void)
123{ 117{
124 spin_lock(&io_lock); 118 spin_lock(&io_lock);
125 outb(0x87, REG); 119 outb(0x87, REG);
@@ -128,22 +122,19 @@ superio_enter(void)
128 outb(0x55, REG); 122 outb(0x55, REG);
129} 123}
130 124
131static inline void 125static inline void superio_exit(void)
132superio_exit(void)
133{ 126{
134 outb(0x02, REG); 127 outb(0x02, REG);
135 outb(0x02, VAL); 128 outb(0x02, VAL);
136 spin_unlock(&io_lock); 129 spin_unlock(&io_lock);
137} 130}
138 131
139static inline void 132static inline void it8712f_wdt_ping(void)
140it8712f_wdt_ping(void)
141{ 133{
142 inb(address); 134 inb(address);
143} 135}
144 136
145static void 137static void it8712f_wdt_update_margin(void)
146it8712f_wdt_update_margin(void)
147{ 138{
148 int config = WDT_OUT_KRST | WDT_OUT_PWROK; 139 int config = WDT_OUT_KRST | WDT_OUT_PWROK;
149 int units = margin; 140 int units = margin;
@@ -165,8 +156,7 @@ it8712f_wdt_update_margin(void)
165 superio_outb(units, WDT_TIMEOUT); 156 superio_outb(units, WDT_TIMEOUT);
166} 157}
167 158
168static int 159static int it8712f_wdt_get_status(void)
169it8712f_wdt_get_status(void)
170{ 160{
171 if (superio_inb(WDT_CONTROL) & 0x01) 161 if (superio_inb(WDT_CONTROL) & 0x01)
172 return WDIOF_CARDRESET; 162 return WDIOF_CARDRESET;
@@ -174,8 +164,7 @@ it8712f_wdt_get_status(void)
174 return 0; 164 return 0;
175} 165}
176 166
177static void 167static void it8712f_wdt_enable(void)
178it8712f_wdt_enable(void)
179{ 168{
180 printk(KERN_DEBUG NAME ": enabling watchdog timer\n"); 169 printk(KERN_DEBUG NAME ": enabling watchdog timer\n");
181 superio_enter(); 170 superio_enter();
@@ -190,8 +179,7 @@ it8712f_wdt_enable(void)
190 it8712f_wdt_ping(); 179 it8712f_wdt_ping();
191} 180}
192 181
193static void 182static void it8712f_wdt_disable(void)
194it8712f_wdt_disable(void)
195{ 183{
196 printk(KERN_DEBUG NAME ": disabling watchdog timer\n"); 184 printk(KERN_DEBUG NAME ": disabling watchdog timer\n");
197 185
@@ -207,8 +195,7 @@ it8712f_wdt_disable(void)
207 superio_exit(); 195 superio_exit();
208} 196}
209 197
210static int 198static int it8712f_wdt_notify(struct notifier_block *this,
211it8712f_wdt_notify(struct notifier_block *this,
212 unsigned long code, void *unused) 199 unsigned long code, void *unused)
213{ 200{
214 if (code == SYS_HALT || code == SYS_POWER_OFF) 201 if (code == SYS_HALT || code == SYS_POWER_OFF)
@@ -222,9 +209,8 @@ static struct notifier_block it8712f_wdt_notifier = {
222 .notifier_call = it8712f_wdt_notify, 209 .notifier_call = it8712f_wdt_notify,
223}; 210};
224 211
225static ssize_t 212static ssize_t it8712f_wdt_write(struct file *file, const char __user *data,
226it8712f_wdt_write(struct file *file, const char __user *data, 213 size_t len, loff_t *ppos)
227 size_t len, loff_t *ppos)
228{ 214{
229 /* check for a magic close character */ 215 /* check for a magic close character */
230 if (len) { 216 if (len) {
@@ -245,9 +231,8 @@ it8712f_wdt_write(struct file *file, const char __user *data,
245 return len; 231 return len;
246} 232}
247 233
248static int 234static long it8712f_wdt_ioctl(struct file *file, unsigned int cmd,
249it8712f_wdt_ioctl(struct inode *inode, struct file *file, 235 unsigned long arg)
250 unsigned int cmd, unsigned long arg)
251{ 236{
252 void __user *argp = (void __user *)arg; 237 void __user *argp = (void __user *)arg;
253 int __user *p = argp; 238 int __user *p = argp;
@@ -302,19 +287,16 @@ it8712f_wdt_ioctl(struct inode *inode, struct file *file,
302 } 287 }
303} 288}
304 289
305static int 290static int it8712f_wdt_open(struct inode *inode, struct file *file)
306it8712f_wdt_open(struct inode *inode, struct file *file)
307{ 291{
308 /* only allow one at a time */ 292 /* only allow one at a time */
309 if (down_trylock(&it8712f_wdt_sem)) 293 if (test_and_set_bit(0, &wdt_open))
310 return -EBUSY; 294 return -EBUSY;
311 it8712f_wdt_enable(); 295 it8712f_wdt_enable();
312
313 return nonseekable_open(inode, file); 296 return nonseekable_open(inode, file);
314} 297}
315 298
316static int 299static int it8712f_wdt_release(struct inode *inode, struct file *file)
317it8712f_wdt_release(struct inode *inode, struct file *file)
318{ 300{
319 if (expect_close != 42) { 301 if (expect_close != 42) {
320 printk(KERN_WARNING NAME 302 printk(KERN_WARNING NAME
@@ -324,7 +306,7 @@ it8712f_wdt_release(struct inode *inode, struct file *file)
324 it8712f_wdt_disable(); 306 it8712f_wdt_disable();
325 } 307 }
326 expect_close = 0; 308 expect_close = 0;
327 up(&it8712f_wdt_sem); 309 clear_bit(0, &wdt_open);
328 310
329 return 0; 311 return 0;
330} 312}
@@ -333,7 +315,7 @@ static const struct file_operations it8712f_wdt_fops = {
333 .owner = THIS_MODULE, 315 .owner = THIS_MODULE,
334 .llseek = no_llseek, 316 .llseek = no_llseek,
335 .write = it8712f_wdt_write, 317 .write = it8712f_wdt_write,
336 .ioctl = it8712f_wdt_ioctl, 318 .unlocked_ioctl = it8712f_wdt_ioctl,
337 .open = it8712f_wdt_open, 319 .open = it8712f_wdt_open,
338 .release = it8712f_wdt_release, 320 .release = it8712f_wdt_release,
339}; 321};
@@ -344,8 +326,7 @@ static struct miscdevice it8712f_wdt_miscdev = {
344 .fops = &it8712f_wdt_fops, 326 .fops = &it8712f_wdt_fops,
345}; 327};
346 328
347static int __init 329static int __init it8712f_wdt_find(unsigned short *address)
348it8712f_wdt_find(unsigned short *address)
349{ 330{
350 int err = -ENODEV; 331 int err = -ENODEV;
351 int chip_type; 332 int chip_type;
@@ -387,8 +368,7 @@ exit:
387 return err; 368 return err;
388} 369}
389 370
390static int __init 371static int __init it8712f_wdt_init(void)
391it8712f_wdt_init(void)
392{ 372{
393 int err = 0; 373 int err = 0;
394 374
@@ -404,8 +384,6 @@ it8712f_wdt_init(void)
404 384
405 it8712f_wdt_disable(); 385 it8712f_wdt_disable();
406 386
407 sema_init(&it8712f_wdt_sem, 1);
408
409 err = register_reboot_notifier(&it8712f_wdt_notifier); 387 err = register_reboot_notifier(&it8712f_wdt_notifier);
410 if (err) { 388 if (err) {
411 printk(KERN_ERR NAME ": unable to register reboot notifier\n"); 389 printk(KERN_ERR NAME ": unable to register reboot notifier\n");
@@ -430,8 +408,7 @@ out:
430 return err; 408 return err;
431} 409}
432 410
433static void __exit 411static void __exit it8712f_wdt_exit(void)
434it8712f_wdt_exit(void)
435{ 412{
436 misc_deregister(&it8712f_wdt_miscdev); 413 misc_deregister(&it8712f_wdt_miscdev);
437 unregister_reboot_notifier(&it8712f_wdt_notifier); 414 unregister_reboot_notifier(&it8712f_wdt_notifier);
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 98532c0e0689..97b4a2e8eb09 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -46,9 +46,8 @@
46#include <linux/platform_device.h> 46#include <linux/platform_device.h>
47#include <linux/interrupt.h> 47#include <linux/interrupt.h>
48#include <linux/clk.h> 48#include <linux/clk.h>
49 49#include <linux/uaccess.h>
50#include <asm/uaccess.h> 50#include <linux/io.h>
51#include <asm/io.h>
52 51
53#include <asm/arch/map.h> 52#include <asm/arch/map.h>
54 53
@@ -65,8 +64,8 @@
65static int nowayout = WATCHDOG_NOWAYOUT; 64static int nowayout = WATCHDOG_NOWAYOUT;
66static int tmr_margin = CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME; 65static int tmr_margin = CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME;
67static int tmr_atboot = CONFIG_S3C2410_WATCHDOG_ATBOOT; 66static int tmr_atboot = CONFIG_S3C2410_WATCHDOG_ATBOOT;
68static int soft_noboot = 0; 67static int soft_noboot;
69static int debug = 0; 68static int debug;
70 69
71module_param(tmr_margin, int, 0); 70module_param(tmr_margin, int, 0);
72module_param(tmr_atboot, int, 0); 71module_param(tmr_atboot, int, 0);
@@ -74,24 +73,23 @@ module_param(nowayout, int, 0);
74module_param(soft_noboot, int, 0); 73module_param(soft_noboot, int, 0);
75module_param(debug, int, 0); 74module_param(debug, int, 0);
76 75
77MODULE_PARM_DESC(tmr_margin, "Watchdog tmr_margin in seconds. default=" __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME) ")"); 76MODULE_PARM_DESC(tmr_margin, "Watchdog tmr_margin in seconds. default="
78 77 __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME) ")");
79MODULE_PARM_DESC(tmr_atboot, "Watchdog is started at boot time if set to 1, default=" __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT)); 78MODULE_PARM_DESC(tmr_atboot,
80 79 "Watchdog is started at boot time if set to 1, default="
81MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 80 __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT));
82 81MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
82 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
83MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)"); 83MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default depends on ONLY_TESTING)");
84
85MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)"); 84MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)");
86 85
87 86
88typedef enum close_state { 87typedef enum close_state {
89 CLOSE_STATE_NOT, 88 CLOSE_STATE_NOT,
90 CLOSE_STATE_ALLOW=0x4021 89 CLOSE_STATE_ALLOW = 0x4021
91} close_state_t; 90} close_state_t;
92 91
93static DECLARE_MUTEX(open_lock); 92static unsigned long open_lock;
94
95static struct device *wdt_dev; /* platform device attached to */ 93static struct device *wdt_dev; /* platform device attached to */
96static struct resource *wdt_mem; 94static struct resource *wdt_mem;
97static struct resource *wdt_irq; 95static struct resource *wdt_irq;
@@ -99,38 +97,58 @@ static struct clk *wdt_clock;
99static void __iomem *wdt_base; 97static void __iomem *wdt_base;
100static unsigned int wdt_count; 98static unsigned int wdt_count;
101static close_state_t allow_close; 99static close_state_t allow_close;
100static DEFINE_SPINLOCK(wdt_lock);
102 101
103/* watchdog control routines */ 102/* watchdog control routines */
104 103
105#define DBG(msg...) do { \ 104#define DBG(msg...) do { \
106 if (debug) \ 105 if (debug) \
107 printk(KERN_INFO msg); \ 106 printk(KERN_INFO msg); \
108 } while(0) 107 } while (0)
109 108
110/* functions */ 109/* functions */
111 110
112static int s3c2410wdt_keepalive(void) 111static void s3c2410wdt_keepalive(void)
113{ 112{
113 spin_lock(&wdt_lock);
114 writel(wdt_count, wdt_base + S3C2410_WTCNT); 114 writel(wdt_count, wdt_base + S3C2410_WTCNT);
115 return 0; 115 spin_unlock(&wdt_lock);
116} 116}
117 117
118static int s3c2410wdt_stop(void) 118static void __s3c2410wdt_stop(void)
119{ 119{
120 unsigned long wtcon; 120 unsigned long wtcon;
121 121
122 spin_lock(&wdt_lock);
122 wtcon = readl(wdt_base + S3C2410_WTCON); 123 wtcon = readl(wdt_base + S3C2410_WTCON);
123 wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN); 124 wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN);
124 writel(wtcon, wdt_base + S3C2410_WTCON); 125 writel(wtcon, wdt_base + S3C2410_WTCON);
126 spin_unlock(&wdt_lock);
127}
125 128
126 return 0; 129static void __s3c2410wdt_stop(void)
130{
131 unsigned long wtcon;
132
133 wtcon = readl(wdt_base + S3C2410_WTCON);
134 wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN);
135 writel(wtcon, wdt_base + S3C2410_WTCON);
136}
137
138static void s3c2410wdt_stop(void)
139{
140 spin_lock(&wdt_lock);
141 __s3c2410wdt_stop();
142 spin_unlock(&wdt_lock);
127} 143}
128 144
129static int s3c2410wdt_start(void) 145static void s3c2410wdt_start(void)
130{ 146{
131 unsigned long wtcon; 147 unsigned long wtcon;
132 148
133 s3c2410wdt_stop(); 149 spin_lock(&wdt_lock);
150
151 __s3c2410wdt_stop();
134 152
135 wtcon = readl(wdt_base + S3C2410_WTCON); 153 wtcon = readl(wdt_base + S3C2410_WTCON);
136 wtcon |= S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128; 154 wtcon |= S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128;
@@ -149,6 +167,7 @@ static int s3c2410wdt_start(void)
149 writel(wdt_count, wdt_base + S3C2410_WTDAT); 167 writel(wdt_count, wdt_base + S3C2410_WTDAT);
150 writel(wdt_count, wdt_base + S3C2410_WTCNT); 168 writel(wdt_count, wdt_base + S3C2410_WTCNT);
151 writel(wtcon, wdt_base + S3C2410_WTCON); 169 writel(wtcon, wdt_base + S3C2410_WTCON);
170 spin_unlock(&wdt_lock);
152 171
153 return 0; 172 return 0;
154} 173}
@@ -211,7 +230,7 @@ static int s3c2410wdt_set_heartbeat(int timeout)
211 230
212static int s3c2410wdt_open(struct inode *inode, struct file *file) 231static int s3c2410wdt_open(struct inode *inode, struct file *file)
213{ 232{
214 if(down_trylock(&open_lock)) 233 if (test_and_set_bit(0, &open_lock))
215 return -EBUSY; 234 return -EBUSY;
216 235
217 if (nowayout) 236 if (nowayout)
@@ -231,15 +250,14 @@ static int s3c2410wdt_release(struct inode *inode, struct file *file)
231 * Lock it in if it's a module and we set nowayout 250 * Lock it in if it's a module and we set nowayout
232 */ 251 */
233 252
234 if (allow_close == CLOSE_STATE_ALLOW) { 253 if (allow_close == CLOSE_STATE_ALLOW)
235 s3c2410wdt_stop(); 254 s3c2410wdt_stop();
236 } else { 255 else {
237 dev_err(wdt_dev, "Unexpected close, not stopping watchdog\n"); 256 dev_err(wdt_dev, "Unexpected close, not stopping watchdog\n");
238 s3c2410wdt_keepalive(); 257 s3c2410wdt_keepalive();
239 } 258 }
240
241 allow_close = CLOSE_STATE_NOT; 259 allow_close = CLOSE_STATE_NOT;
242 up(&open_lock); 260 clear_bit(0, &open_lock);
243 return 0; 261 return 0;
244} 262}
245 263
@@ -249,7 +267,7 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
249 /* 267 /*
250 * Refresh the timer. 268 * Refresh the timer.
251 */ 269 */
252 if(len) { 270 if (len) {
253 if (!nowayout) { 271 if (!nowayout) {
254 size_t i; 272 size_t i;
255 273
@@ -265,7 +283,6 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
265 allow_close = CLOSE_STATE_ALLOW; 283 allow_close = CLOSE_STATE_ALLOW;
266 } 284 }
267 } 285 }
268
269 s3c2410wdt_keepalive(); 286 s3c2410wdt_keepalive();
270 } 287 }
271 return len; 288 return len;
@@ -273,48 +290,41 @@ static ssize_t s3c2410wdt_write(struct file *file, const char __user *data,
273 290
274#define OPTIONS WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE 291#define OPTIONS WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE
275 292
276static struct watchdog_info s3c2410_wdt_ident = { 293static const struct watchdog_info s3c2410_wdt_ident = {
277 .options = OPTIONS, 294 .options = OPTIONS,
278 .firmware_version = 0, 295 .firmware_version = 0,
279 .identity = "S3C2410 Watchdog", 296 .identity = "S3C2410 Watchdog",
280}; 297};
281 298
282 299
283static int s3c2410wdt_ioctl(struct inode *inode, struct file *file, 300static long s3c2410wdt_ioctl(struct file *file, unsigned int cmd,
284 unsigned int cmd, unsigned long arg) 301 unsigned long arg)
285{ 302{
286 void __user *argp = (void __user *)arg; 303 void __user *argp = (void __user *)arg;
287 int __user *p = argp; 304 int __user *p = argp;
288 int new_margin; 305 int new_margin;
289 306
290 switch (cmd) { 307 switch (cmd) {
291 default: 308 default:
292 return -ENOTTY; 309 return -ENOTTY;
293 310 case WDIOC_GETSUPPORT:
294 case WDIOC_GETSUPPORT: 311 return copy_to_user(argp, &s3c2410_wdt_ident,
295 return copy_to_user(argp, &s3c2410_wdt_ident, 312 sizeof(s3c2410_wdt_ident)) ? -EFAULT : 0;
296 sizeof(s3c2410_wdt_ident)) ? -EFAULT : 0; 313 case WDIOC_GETSTATUS:
297 314 case WDIOC_GETBOOTSTATUS:
298 case WDIOC_GETSTATUS: 315 return put_user(0, p);
299 case WDIOC_GETBOOTSTATUS: 316 case WDIOC_KEEPALIVE:
300 return put_user(0, p); 317 s3c2410wdt_keepalive();
301 318 return 0;
302 case WDIOC_KEEPALIVE: 319 case WDIOC_SETTIMEOUT:
303 s3c2410wdt_keepalive(); 320 if (get_user(new_margin, p))
304 return 0; 321 return -EFAULT;
305 322 if (s3c2410wdt_set_heartbeat(new_margin))
306 case WDIOC_SETTIMEOUT: 323 return -EINVAL;
307 if (get_user(new_margin, p)) 324 s3c2410wdt_keepalive();
308 return -EFAULT; 325 return put_user(tmr_margin, p);
309 326 case WDIOC_GETTIMEOUT:
310 if (s3c2410wdt_set_heartbeat(new_margin)) 327 return put_user(tmr_margin, p);
311 return -EINVAL;
312
313 s3c2410wdt_keepalive();
314 return put_user(tmr_margin, p);
315
316 case WDIOC_GETTIMEOUT:
317 return put_user(tmr_margin, p);
318 } 328 }
319} 329}
320 330
@@ -324,7 +334,7 @@ static const struct file_operations s3c2410wdt_fops = {
324 .owner = THIS_MODULE, 334 .owner = THIS_MODULE,
325 .llseek = no_llseek, 335 .llseek = no_llseek,
326 .write = s3c2410wdt_write, 336 .write = s3c2410wdt_write,
327 .ioctl = s3c2410wdt_ioctl, 337 .unlocked_ioctl = s3c2410wdt_ioctl,
328 .open = s3c2410wdt_open, 338 .open = s3c2410wdt_open,
329 .release = s3c2410wdt_release, 339 .release = s3c2410wdt_release,
330}; 340};
@@ -411,14 +421,15 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
411 * not, try the default value */ 421 * not, try the default value */
412 422
413 if (s3c2410wdt_set_heartbeat(tmr_margin)) { 423 if (s3c2410wdt_set_heartbeat(tmr_margin)) {
414 started = s3c2410wdt_set_heartbeat(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); 424 started = s3c2410wdt_set_heartbeat(
425 CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
415 426
416 if (started == 0) { 427 if (started == 0)
417 dev_info(dev,"tmr_margin value out of range, default %d used\n", 428 dev_info(dev,
429 "tmr_margin value out of range, default %d used\n",
418 CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); 430 CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
419 } else { 431 else
420 dev_info(dev, "default timer value is out of range, cannot start\n"); 432 dev_info(dev, "default timer value is out of range, cannot start\n");
421 }
422 } 433 }
423 434
424 ret = misc_register(&s3c2410wdt_miscdev); 435 ret = misc_register(&s3c2410wdt_miscdev);
@@ -447,7 +458,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
447 (wtcon & S3C2410_WTCON_ENABLE) ? "" : "in", 458 (wtcon & S3C2410_WTCON_ENABLE) ? "" : "in",
448 (wtcon & S3C2410_WTCON_RSTEN) ? "" : "dis", 459 (wtcon & S3C2410_WTCON_RSTEN) ? "" : "dis",
449 (wtcon & S3C2410_WTCON_INTEN) ? "" : "en"); 460 (wtcon & S3C2410_WTCON_INTEN) ? "" : "en");
450 461
451 return 0; 462 return 0;
452 463
453 err_clk: 464 err_clk:
@@ -487,7 +498,7 @@ static int s3c2410wdt_remove(struct platform_device *dev)
487 498
488static void s3c2410wdt_shutdown(struct platform_device *dev) 499static void s3c2410wdt_shutdown(struct platform_device *dev)
489{ 500{
490 s3c2410wdt_stop(); 501 s3c2410wdt_stop();
491} 502}
492 503
493#ifdef CONFIG_PM 504#ifdef CONFIG_PM
@@ -540,7 +551,8 @@ static struct platform_driver s3c2410wdt_driver = {
540}; 551};
541 552
542 553
543static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n"; 554static char banner[] __initdata =
555 KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n";
544 556
545static int __init watchdog_init(void) 557static int __init watchdog_init(void)
546{ 558{
diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
index 35cddff7020f..621ebad56d86 100644
--- a/drivers/watchdog/sc1200wdt.c
+++ b/drivers/watchdog/sc1200wdt.c
@@ -15,14 +15,18 @@
15 * 15 *
16 * Changelog: 16 * Changelog:
17 * 20020220 Zwane Mwaikambo Code based on datasheet, no hardware. 17 * 20020220 Zwane Mwaikambo Code based on datasheet, no hardware.
18 * 20020221 Zwane Mwaikambo Cleanups as suggested by Jeff Garzik and Alan Cox. 18 * 20020221 Zwane Mwaikambo Cleanups as suggested by Jeff Garzik
19 * and Alan Cox.
19 * 20020222 Zwane Mwaikambo Added probing. 20 * 20020222 Zwane Mwaikambo Added probing.
20 * 20020225 Zwane Mwaikambo Added ISAPNP support. 21 * 20020225 Zwane Mwaikambo Added ISAPNP support.
21 * 20020412 Rob Radez Broke out start/stop functions 22 * 20020412 Rob Radez Broke out start/stop functions
22 * <rob@osinvestor.com> Return proper status instead of temperature warning 23 * <rob@osinvestor.com> Return proper status instead of
23 * Add WDIOC_GETBOOTSTATUS and WDIOC_SETOPTIONS ioctls 24 * temperature warning
25 * Add WDIOC_GETBOOTSTATUS and
26 * WDIOC_SETOPTIONS ioctls
24 * Fix CONFIG_WATCHDOG_NOWAYOUT 27 * Fix CONFIG_WATCHDOG_NOWAYOUT
25 * 20020530 Joel Becker Add Matt Domsch's nowayout module option 28 * 20020530 Joel Becker Add Matt Domsch's nowayout module
29 * option
26 * 20030116 Adam Belay Updated to the latest pnp code 30 * 20030116 Adam Belay Updated to the latest pnp code
27 * 31 *
28 */ 32 */
@@ -39,9 +43,8 @@
39#include <linux/pnp.h> 43#include <linux/pnp.h>
40#include <linux/fs.h> 44#include <linux/fs.h>
41#include <linux/semaphore.h> 45#include <linux/semaphore.h>
42 46#include <linux/io.h>
43#include <asm/io.h> 47#include <linux/uaccess.h>
44#include <asm/uaccess.h>
45 48
46#define SC1200_MODULE_VER "build 20020303" 49#define SC1200_MODULE_VER "build 20020303"
47#define SC1200_MODULE_NAME "sc1200wdt" 50#define SC1200_MODULE_NAME "sc1200wdt"
@@ -72,7 +75,7 @@ static char banner[] __initdata = KERN_INFO PFX SC1200_MODULE_VER;
72static int timeout = 1; 75static int timeout = 1;
73static int io = -1; 76static int io = -1;
74static int io_len = 2; /* for non plug and play */ 77static int io_len = 2; /* for non plug and play */
75static struct semaphore open_sem; 78static unsigned long open_flag;
76static char expect_close; 79static char expect_close;
77static DEFINE_SPINLOCK(sc1200wdt_lock); /* io port access serialisation */ 80static DEFINE_SPINLOCK(sc1200wdt_lock); /* io port access serialisation */
78 81
@@ -81,7 +84,8 @@ static int isapnp = 1;
81static struct pnp_dev *wdt_dev; 84static struct pnp_dev *wdt_dev;
82 85
83module_param(isapnp, int, 0); 86module_param(isapnp, int, 0);
84MODULE_PARM_DESC(isapnp, "When set to 0 driver ISA PnP support will be disabled"); 87MODULE_PARM_DESC(isapnp,
88 "When set to 0 driver ISA PnP support will be disabled");
85#endif 89#endif
86 90
87module_param(io, int, 0); 91module_param(io, int, 0);
@@ -91,26 +95,40 @@ MODULE_PARM_DESC(timeout, "range is 0-255 minutes, default is 1");
91 95
92static int nowayout = WATCHDOG_NOWAYOUT; 96static int nowayout = WATCHDOG_NOWAYOUT;
93module_param(nowayout, int, 0); 97module_param(nowayout, int, 0);
94MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 98MODULE_PARM_DESC(nowayout,
99 "Watchdog cannot be stopped once started (default="
100 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
95 101
96 102
97 103
98/* Read from Data Register */ 104/* Read from Data Register */
99static inline void sc1200wdt_read_data(unsigned char index, unsigned char *data) 105static inline void __sc1200wdt_read_data(unsigned char index,
106 unsigned char *data)
100{ 107{
101 spin_lock(&sc1200wdt_lock);
102 outb_p(index, PMIR); 108 outb_p(index, PMIR);
103 *data = inb(PMDR); 109 *data = inb(PMDR);
104 spin_unlock(&sc1200wdt_lock);
105} 110}
106 111
112static void sc1200wdt_read_data(unsigned char index, unsigned char *data)
113{
114 spin_lock(&sc1200wdt_lock);
115 __sc1200wdt_read_data(index, data);
116 spin_unlock(&sc1200wdt_lock);
117}
107 118
108/* Write to Data Register */ 119/* Write to Data Register */
109static inline void sc1200wdt_write_data(unsigned char index, unsigned char data) 120static inline void __sc1200wdt_write_data(unsigned char index,
121 unsigned char data)
110{ 122{
111 spin_lock(&sc1200wdt_lock);
112 outb_p(index, PMIR); 123 outb_p(index, PMIR);
113 outb(data, PMDR); 124 outb(data, PMDR);
125}
126
127static inline void sc1200wdt_write_data(unsigned char index,
128 unsigned char data)
129{
130 spin_lock(&sc1200wdt_lock);
131 __sc1200wdt_write_data(index, data);
114 spin_unlock(&sc1200wdt_lock); 132 spin_unlock(&sc1200wdt_lock);
115} 133}
116 134
@@ -118,22 +136,23 @@ static inline void sc1200wdt_write_data(unsigned char index, unsigned char data)
118static void sc1200wdt_start(void) 136static void sc1200wdt_start(void)
119{ 137{
120 unsigned char reg; 138 unsigned char reg;
139 spin_lock(&sc1200wdt_lock);
121 140
122 sc1200wdt_read_data(WDCF, &reg); 141 __sc1200wdt_read_data(WDCF, &reg);
123 /* assert WDO when any of the following interrupts are triggered too */ 142 /* assert WDO when any of the following interrupts are triggered too */
124 reg |= (KBC_IRQ | MSE_IRQ | UART1_IRQ | UART2_IRQ); 143 reg |= (KBC_IRQ | MSE_IRQ | UART1_IRQ | UART2_IRQ);
125 sc1200wdt_write_data(WDCF, reg); 144 __sc1200wdt_write_data(WDCF, reg);
126 /* set the timeout and get the ball rolling */ 145 /* set the timeout and get the ball rolling */
127 sc1200wdt_write_data(WDTO, timeout); 146 __sc1200wdt_write_data(WDTO, timeout);
128}
129 147
148 spin_unlock(&sc1200wdt_lock);
149}
130 150
131static void sc1200wdt_stop(void) 151static void sc1200wdt_stop(void)
132{ 152{
133 sc1200wdt_write_data(WDTO, 0); 153 sc1200wdt_write_data(WDTO, 0);
134} 154}
135 155
136
137/* This returns the status of the WDO signal, inactive high. */ 156/* This returns the status of the WDO signal, inactive high. */
138static inline int sc1200wdt_status(void) 157static inline int sc1200wdt_status(void)
139{ 158{
@@ -144,14 +163,13 @@ static inline int sc1200wdt_status(void)
144 * KEEPALIVEPING which is a bit of a kludge because there's nothing 163 * KEEPALIVEPING which is a bit of a kludge because there's nothing
145 * else for enabled/disabled status 164 * else for enabled/disabled status
146 */ 165 */
147 return (ret & 0x01) ? 0 : WDIOF_KEEPALIVEPING; /* bits 1 - 7 are undefined */ 166 return (ret & 0x01) ? 0 : WDIOF_KEEPALIVEPING;
148} 167}
149 168
150
151static int sc1200wdt_open(struct inode *inode, struct file *file) 169static int sc1200wdt_open(struct inode *inode, struct file *file)
152{ 170{
153 /* allow one at a time */ 171 /* allow one at a time */
154 if (down_trylock(&open_sem)) 172 if (test_and_set_bit(0, &open_flag))
155 return -EBUSY; 173 return -EBUSY;
156 174
157 if (timeout > MAX_TIMEOUT) 175 if (timeout > MAX_TIMEOUT)
@@ -164,71 +182,71 @@ static int sc1200wdt_open(struct inode *inode, struct file *file)
164} 182}
165 183
166 184
167static int sc1200wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 185static long sc1200wdt_ioctl(struct file *file, unsigned int cmd,
186 unsigned long arg)
168{ 187{
169 int new_timeout; 188 int new_timeout;
170 void __user *argp = (void __user *)arg; 189 void __user *argp = (void __user *)arg;
171 int __user *p = argp; 190 int __user *p = argp;
172 static struct watchdog_info ident = { 191 static const struct watchdog_info ident = {
173 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, 192 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
193 WDIOF_MAGICCLOSE,
174 .firmware_version = 0, 194 .firmware_version = 0,
175 .identity = "PC87307/PC97307", 195 .identity = "PC87307/PC97307",
176 }; 196 };
177 197
178 switch (cmd) { 198 switch (cmd) {
179 default:
180 return -ENOTTY;
181
182 case WDIOC_GETSUPPORT:
183 if (copy_to_user(argp, &ident, sizeof ident))
184 return -EFAULT;
185 return 0;
186
187 case WDIOC_GETSTATUS:
188 return put_user(sc1200wdt_status(), p);
189
190 case WDIOC_GETBOOTSTATUS:
191 return put_user(0, p);
192
193 case WDIOC_KEEPALIVE:
194 sc1200wdt_write_data(WDTO, timeout);
195 return 0;
196 199
197 case WDIOC_SETTIMEOUT: 200 case WDIOC_GETSUPPORT:
198 if (get_user(new_timeout, p)) 201 if (copy_to_user(argp, &ident, sizeof ident))
199 return -EFAULT; 202 return -EFAULT;
203 return 0;
200 204
201 /* the API states this is given in secs */ 205 case WDIOC_GETSTATUS:
202 new_timeout /= 60; 206 return put_user(sc1200wdt_status(), p);
203 if (new_timeout < 0 || new_timeout > MAX_TIMEOUT)
204 return -EINVAL;
205 207
206 timeout = new_timeout; 208 case WDIOC_GETBOOTSTATUS:
207 sc1200wdt_write_data(WDTO, timeout); 209 return put_user(0, p);
208 /* fall through and return the new timeout */
209 210
210 case WDIOC_GETTIMEOUT: 211 case WDIOC_KEEPALIVE:
211 return put_user(timeout * 60, p); 212 sc1200wdt_write_data(WDTO, timeout);
213 return 0;
214
215 case WDIOC_SETTIMEOUT:
216 if (get_user(new_timeout, p))
217 return -EFAULT;
218 /* the API states this is given in secs */
219 new_timeout /= 60;
220 if (new_timeout < 0 || new_timeout > MAX_TIMEOUT)
221 return -EINVAL;
222 timeout = new_timeout;
223 sc1200wdt_write_data(WDTO, timeout);
224 /* fall through and return the new timeout */
212 225
213 case WDIOC_SETOPTIONS: 226 case WDIOC_GETTIMEOUT:
214 { 227 return put_user(timeout * 60, p);
215 int options, retval = -EINVAL;
216 228
217 if (get_user(options, p)) 229 case WDIOC_SETOPTIONS:
218 return -EFAULT; 230 {
231 int options, retval = -EINVAL;
219 232
220 if (options & WDIOS_DISABLECARD) { 233 if (get_user(options, p))
221 sc1200wdt_stop(); 234 return -EFAULT;
222 retval = 0;
223 }
224 235
225 if (options & WDIOS_ENABLECARD) { 236 if (options & WDIOS_DISABLECARD) {
226 sc1200wdt_start(); 237 sc1200wdt_stop();
227 retval = 0; 238 retval = 0;
228 } 239 }
229 240
230 return retval; 241 if (options & WDIOS_ENABLECARD) {
242 sc1200wdt_start();
243 retval = 0;
231 } 244 }
245
246 return retval;
247 }
248 default:
249 return -ENOTTY;
232 } 250 }
233} 251}
234 252
@@ -240,16 +258,18 @@ static int sc1200wdt_release(struct inode *inode, struct file *file)
240 printk(KERN_INFO PFX "Watchdog disabled\n"); 258 printk(KERN_INFO PFX "Watchdog disabled\n");
241 } else { 259 } else {
242 sc1200wdt_write_data(WDTO, timeout); 260 sc1200wdt_write_data(WDTO, timeout);
243 printk(KERN_CRIT PFX "Unexpected close!, timeout = %d min(s)\n", timeout); 261 printk(KERN_CRIT PFX
262 "Unexpected close!, timeout = %d min(s)\n", timeout);
244 } 263 }
245 up(&open_sem); 264 clear_bit(0, &open_flag);
246 expect_close = 0; 265 expect_close = 0;
247 266
248 return 0; 267 return 0;
249} 268}
250 269
251 270
252static ssize_t sc1200wdt_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) 271static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
272 size_t len, loff_t *ppos)
253{ 273{
254 if (len) { 274 if (len) {
255 if (!nowayout) { 275 if (!nowayout) {
@@ -275,7 +295,8 @@ static ssize_t sc1200wdt_write(struct file *file, const char __user *data, size_
275} 295}
276 296
277 297
278static int sc1200wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused) 298static int sc1200wdt_notify_sys(struct notifier_block *this,
299 unsigned long code, void *unused)
279{ 300{
280 if (code == SYS_DOWN || code == SYS_HALT) 301 if (code == SYS_DOWN || code == SYS_HALT)
281 sc1200wdt_stop(); 302 sc1200wdt_stop();
@@ -284,23 +305,20 @@ static int sc1200wdt_notify_sys(struct notifier_block *this, unsigned long code,
284} 305}
285 306
286 307
287static struct notifier_block sc1200wdt_notifier = 308static struct notifier_block sc1200wdt_notifier = {
288{
289 .notifier_call = sc1200wdt_notify_sys, 309 .notifier_call = sc1200wdt_notify_sys,
290}; 310};
291 311
292static const struct file_operations sc1200wdt_fops = 312static const struct file_operations sc1200wdt_fops = {
293{
294 .owner = THIS_MODULE, 313 .owner = THIS_MODULE,
295 .llseek = no_llseek, 314 .llseek = no_llseek,
296 .write = sc1200wdt_write, 315 .write = sc1200wdt_write,
297 .ioctl = sc1200wdt_ioctl, 316 .unlocked_ioctl = sc1200wdt_ioctl,
298 .open = sc1200wdt_open, 317 .open = sc1200wdt_open,
299 .release = sc1200wdt_release, 318 .release = sc1200wdt_release,
300}; 319};
301 320
302static struct miscdevice sc1200wdt_miscdev = 321static struct miscdevice sc1200wdt_miscdev = {
303{
304 .minor = WATCHDOG_MINOR, 322 .minor = WATCHDOG_MINOR,
305 .name = "watchdog", 323 .name = "watchdog",
306 .fops = &sc1200wdt_fops, 324 .fops = &sc1200wdt_fops,
@@ -312,14 +330,14 @@ static int __init sc1200wdt_probe(void)
312 /* The probe works by reading the PMC3 register's default value of 0x0e 330 /* The probe works by reading the PMC3 register's default value of 0x0e
313 * there is one caveat, if the device disables the parallel port or any 331 * there is one caveat, if the device disables the parallel port or any
314 * of the UARTs we won't be able to detect it. 332 * of the UARTs we won't be able to detect it.
315 * Nb. This could be done with accuracy by reading the SID registers, but 333 * NB. This could be done with accuracy by reading the SID registers,
316 * we don't have access to those io regions. 334 * but we don't have access to those io regions.
317 */ 335 */
318 336
319 unsigned char reg; 337 unsigned char reg;
320 338
321 sc1200wdt_read_data(PMC3, &reg); 339 sc1200wdt_read_data(PMC3, &reg);
322 reg &= 0x0f; /* we don't want the UART busy bits */ 340 reg &= 0x0f; /* we don't want the UART busy bits */
323 return (reg == 0x0e) ? 0 : -ENODEV; 341 return (reg == 0x0e) ? 0 : -ENODEV;
324} 342}
325 343
@@ -332,7 +350,8 @@ static struct pnp_device_id scl200wdt_pnp_devices[] = {
332 {.id = ""}, 350 {.id = ""},
333}; 351};
334 352
335static int scl200wdt_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) 353static int scl200wdt_pnp_probe(struct pnp_dev *dev,
354 const struct pnp_device_id *dev_id)
336{ 355{
337 /* this driver only supports one card at a time */ 356 /* this driver only supports one card at a time */
338 if (wdt_dev || !isapnp) 357 if (wdt_dev || !isapnp)
@@ -347,13 +366,14 @@ static int scl200wdt_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id
347 return -EBUSY; 366 return -EBUSY;
348 } 367 }
349 368
350 printk(KERN_INFO "scl200wdt: PnP device found at io port %#x/%d\n", io, io_len); 369 printk(KERN_INFO "scl200wdt: PnP device found at io port %#x/%d\n",
370 io, io_len);
351 return 0; 371 return 0;
352} 372}
353 373
354static void scl200wdt_pnp_remove(struct pnp_dev * dev) 374static void scl200wdt_pnp_remove(struct pnp_dev *dev)
355{ 375{
356 if (wdt_dev){ 376 if (wdt_dev) {
357 release_region(io, io_len); 377 release_region(io, io_len);
358 wdt_dev = NULL; 378 wdt_dev = NULL;
359 } 379 }
@@ -375,8 +395,6 @@ static int __init sc1200wdt_init(void)
375 395
376 printk("%s\n", banner); 396 printk("%s\n", banner);
377 397
378 sema_init(&open_sem, 1);
379
380#if defined CONFIG_PNP 398#if defined CONFIG_PNP
381 if (isapnp) { 399 if (isapnp) {
382 ret = pnp_register_driver(&scl200wdt_pnp_driver); 400 ret = pnp_register_driver(&scl200wdt_pnp_driver);
@@ -410,13 +428,16 @@ static int __init sc1200wdt_init(void)
410 428
411 ret = register_reboot_notifier(&sc1200wdt_notifier); 429 ret = register_reboot_notifier(&sc1200wdt_notifier);
412 if (ret) { 430 if (ret) {
413 printk(KERN_ERR PFX "Unable to register reboot notifier err = %d\n", ret); 431 printk(KERN_ERR PFX
432 "Unable to register reboot notifier err = %d\n", ret);
414 goto out_io; 433 goto out_io;
415 } 434 }
416 435
417 ret = misc_register(&sc1200wdt_miscdev); 436 ret = misc_register(&sc1200wdt_miscdev);
418 if (ret) { 437 if (ret) {
419 printk(KERN_ERR PFX "Unable to register miscdev on minor %d\n", WATCHDOG_MINOR); 438 printk(KERN_ERR PFX
439 "Unable to register miscdev on minor %d\n",
440 WATCHDOG_MINOR);
420 goto out_rbt; 441 goto out_rbt;
421 } 442 }
422 443
@@ -446,7 +467,7 @@ static void __exit sc1200wdt_exit(void)
446 unregister_reboot_notifier(&sc1200wdt_notifier); 467 unregister_reboot_notifier(&sc1200wdt_notifier);
447 468
448#if defined CONFIG_PNP 469#if defined CONFIG_PNP
449 if(isapnp) 470 if (isapnp)
450 pnp_unregister_driver(&scl200wdt_pnp_driver); 471 pnp_unregister_driver(&scl200wdt_pnp_driver);
451 else 472 else
452#endif 473#endif
diff --git a/drivers/watchdog/wdt.c b/drivers/watchdog/wdt.c
index 756fb15fdce7..53a6b18bcb9a 100644
--- a/drivers/watchdog/wdt.c
+++ b/drivers/watchdog/wdt.c
@@ -24,9 +24,10 @@
24 * Matt Crocker). 24 * Matt Crocker).
25 * Alan Cox : Added wdt= boot option 25 * Alan Cox : Added wdt= boot option
26 * Alan Cox : Cleaned up copy/user stuff 26 * Alan Cox : Cleaned up copy/user stuff
27 * Tim Hockin : Added insmod parameters, comment cleanup 27 * Tim Hockin : Added insmod parameters, comment
28 * Parameterized timeout 28 * cleanup, parameterized timeout
29 * Tigran Aivazian : Restructured wdt_init() to handle failures 29 * Tigran Aivazian : Restructured wdt_init() to handle
30 * failures
30 * Joel Becker : Added WDIOC_GET/SETTIMEOUT 31 * Joel Becker : Added WDIOC_GET/SETTIMEOUT
31 * Matt Domsch : Added nowayout module option 32 * Matt Domsch : Added nowayout module option
32 */ 33 */
@@ -42,9 +43,9 @@
42#include <linux/notifier.h> 43#include <linux/notifier.h>
43#include <linux/reboot.h> 44#include <linux/reboot.h>
44#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/io.h>
47#include <linux/uaccess.h>
45 48
46#include <asm/io.h>
47#include <asm/uaccess.h>
48#include <asm/system.h> 49#include <asm/system.h>
49#include "wd501p.h" 50#include "wd501p.h"
50 51
@@ -60,15 +61,19 @@ static char expect_close;
60static int heartbeat = WD_TIMO; 61static int heartbeat = WD_TIMO;
61static int wd_heartbeat; 62static int wd_heartbeat;
62module_param(heartbeat, int, 0); 63module_param(heartbeat, int, 0);
63MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WD_TIMO) ")"); 64MODULE_PARM_DESC(heartbeat,
65 "Watchdog heartbeat in seconds. (0 < heartbeat < 65536, default="
66 __MODULE_STRING(WD_TIMO) ")");
64 67
65static int nowayout = WATCHDOG_NOWAYOUT; 68static int nowayout = WATCHDOG_NOWAYOUT;
66module_param(nowayout, int, 0); 69module_param(nowayout, int, 0);
67MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 70MODULE_PARM_DESC(nowayout,
71 "Watchdog cannot be stopped once started (default="
72 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
68 73
69/* You must set these - there is no sane way to probe for this board. */ 74/* You must set these - there is no sane way to probe for this board. */
70static int io=0x240; 75static int io = 0x240;
71static int irq=11; 76static int irq = 11;
72 77
73static DEFINE_SPINLOCK(wdt_lock); 78static DEFINE_SPINLOCK(wdt_lock);
74 79
@@ -82,7 +87,8 @@ MODULE_PARM_DESC(irq, "WDT irq (default=11)");
82static int tachometer; 87static int tachometer;
83 88
84module_param(tachometer, int, 0); 89module_param(tachometer, int, 0);
85MODULE_PARM_DESC(tachometer, "WDT501-P Fan Tachometer support (0=disable, default=0)"); 90MODULE_PARM_DESC(tachometer,
91 "WDT501-P Fan Tachometer support (0=disable, default=0)");
86#endif /* CONFIG_WDT_501 */ 92#endif /* CONFIG_WDT_501 */
87 93
88/* 94/*
@@ -91,9 +97,9 @@ MODULE_PARM_DESC(tachometer, "WDT501-P Fan Tachometer support (0=disable, defaul
91 97
92static void wdt_ctr_mode(int ctr, int mode) 98static void wdt_ctr_mode(int ctr, int mode)
93{ 99{
94 ctr<<=6; 100 ctr <<= 6;
95 ctr|=0x30; 101 ctr |= 0x30;
96 ctr|=(mode<<1); 102 ctr |= (mode << 1);
97 outb_p(ctr, WDT_CR); 103 outb_p(ctr, WDT_CR);
98} 104}
99 105
@@ -114,12 +120,15 @@ static int wdt_start(void)
114 unsigned long flags; 120 unsigned long flags;
115 spin_lock_irqsave(&wdt_lock, flags); 121 spin_lock_irqsave(&wdt_lock, flags);
116 inb_p(WDT_DC); /* Disable watchdog */ 122 inb_p(WDT_DC); /* Disable watchdog */
117 wdt_ctr_mode(0,3); /* Program CTR0 for Mode 3: Square Wave Generator */ 123 wdt_ctr_mode(0, 3); /* Program CTR0 for Mode 3:
118 wdt_ctr_mode(1,2); /* Program CTR1 for Mode 2: Rate Generator */ 124 Square Wave Generator */
119 wdt_ctr_mode(2,0); /* Program CTR2 for Mode 0: Pulse on Terminal Count */ 125 wdt_ctr_mode(1, 2); /* Program CTR1 for Mode 2:
126 Rate Generator */
127 wdt_ctr_mode(2, 0); /* Program CTR2 for Mode 0:
128 Pulse on Terminal Count */
120 wdt_ctr_load(0, 8948); /* Count at 100Hz */ 129 wdt_ctr_load(0, 8948); /* Count at 100Hz */
121 wdt_ctr_load(1,wd_heartbeat); /* Heartbeat */ 130 wdt_ctr_load(1, wd_heartbeat); /* Heartbeat */
122 wdt_ctr_load(2,65535); /* Length of reset pulse */ 131 wdt_ctr_load(2, 65535); /* Length of reset pulse */
123 outb_p(0, WDT_DC); /* Enable watchdog */ 132 outb_p(0, WDT_DC); /* Enable watchdog */
124 spin_unlock_irqrestore(&wdt_lock, flags); 133 spin_unlock_irqrestore(&wdt_lock, flags);
125 return 0; 134 return 0;
@@ -131,13 +140,13 @@ static int wdt_start(void)
131 * Stop the watchdog driver. 140 * Stop the watchdog driver.
132 */ 141 */
133 142
134static int wdt_stop (void) 143static int wdt_stop(void)
135{ 144{
136 unsigned long flags; 145 unsigned long flags;
137 spin_lock_irqsave(&wdt_lock, flags); 146 spin_lock_irqsave(&wdt_lock, flags);
138 /* Turn the card off */ 147 /* Turn the card off */
139 inb_p(WDT_DC); /* Disable watchdog */ 148 inb_p(WDT_DC); /* Disable watchdog */
140 wdt_ctr_load(2,0); /* 0 length reset pulses now */ 149 wdt_ctr_load(2, 0); /* 0 length reset pulses now */
141 spin_unlock_irqrestore(&wdt_lock, flags); 150 spin_unlock_irqrestore(&wdt_lock, flags);
142 return 0; 151 return 0;
143} 152}
@@ -145,8 +154,8 @@ static int wdt_stop (void)
145/** 154/**
146 * wdt_ping: 155 * wdt_ping:
147 * 156 *
148 * Reload counter one with the watchdog heartbeat. We don't bother reloading 157 * Reload counter one with the watchdog heartbeat. We don't bother
149 * the cascade counter. 158 * reloading the cascade counter.
150 */ 159 */
151 160
152static int wdt_ping(void) 161static int wdt_ping(void)
@@ -155,8 +164,9 @@ static int wdt_ping(void)
155 spin_lock_irqsave(&wdt_lock, flags); 164 spin_lock_irqsave(&wdt_lock, flags);
156 /* Write a watchdog value */ 165 /* Write a watchdog value */
157 inb_p(WDT_DC); /* Disable watchdog */ 166 inb_p(WDT_DC); /* Disable watchdog */
158 wdt_ctr_mode(1,2); /* Re-Program CTR1 for Mode 2: Rate Generator */ 167 wdt_ctr_mode(1, 2); /* Re-Program CTR1 for Mode 2:
159 wdt_ctr_load(1,wd_heartbeat); /* Heartbeat */ 168 Rate Generator */
169 wdt_ctr_load(1, wd_heartbeat); /* Heartbeat */
160 outb_p(0, WDT_DC); /* Enable watchdog */ 170 outb_p(0, WDT_DC); /* Enable watchdog */
161 spin_unlock_irqrestore(&wdt_lock, flags); 171 spin_unlock_irqrestore(&wdt_lock, flags);
162 return 0; 172 return 0;
@@ -166,13 +176,14 @@ static int wdt_ping(void)
166 * wdt_set_heartbeat: 176 * wdt_set_heartbeat:
167 * @t: the new heartbeat value that needs to be set. 177 * @t: the new heartbeat value that needs to be set.
168 * 178 *
169 * Set a new heartbeat value for the watchdog device. If the heartbeat value is 179 * Set a new heartbeat value for the watchdog device. If the heartbeat
170 * incorrect we keep the old value and return -EINVAL. If successfull we 180 * value is incorrect we keep the old value and return -EINVAL. If
171 * return 0. 181 * successful we return 0.
172 */ 182 */
183
173static int wdt_set_heartbeat(int t) 184static int wdt_set_heartbeat(int t)
174{ 185{
175 if ((t < 1) || (t > 65535)) 186 if (t < 1 || t > 65535)
176 return -EINVAL; 187 return -EINVAL;
177 188
178 heartbeat = t; 189 heartbeat = t;
@@ -200,7 +211,7 @@ static int wdt_get_status(int *status)
200 new_status = inb_p(WDT_SR); 211 new_status = inb_p(WDT_SR);
201 spin_unlock_irqrestore(&wdt_lock, flags); 212 spin_unlock_irqrestore(&wdt_lock, flags);
202 213
203 *status=0; 214 *status = 0;
204 if (new_status & WDC_SR_ISOI0) 215 if (new_status & WDC_SR_ISOI0)
205 *status |= WDIOF_EXTERN1; 216 *status |= WDIOF_EXTERN1;
206 if (new_status & WDC_SR_ISII1) 217 if (new_status & WDC_SR_ISII1)
@@ -266,7 +277,7 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id)
266 277
267#ifdef CONFIG_WDT_501 278#ifdef CONFIG_WDT_501
268 if (!(status & WDC_SR_TGOOD)) 279 if (!(status & WDC_SR_TGOOD))
269 printk(KERN_CRIT "Overheat alarm.(%d)\n",inb_p(WDT_RT)); 280 printk(KERN_CRIT "Overheat alarm.(%d)\n", inb_p(WDT_RT));
270 if (!(status & WDC_SR_PSUOVER)) 281 if (!(status & WDC_SR_PSUOVER))
271 printk(KERN_CRIT "PSU over voltage.\n"); 282 printk(KERN_CRIT "PSU over voltage.\n");
272 if (!(status & WDC_SR_PSUUNDR)) 283 if (!(status & WDC_SR_PSUUNDR))
@@ -304,9 +315,10 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id)
304 * write of data will do, as we we don't define content meaning. 315 * write of data will do, as we we don't define content meaning.
305 */ 316 */
306 317
307static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 318static ssize_t wdt_write(struct file *file, const char __user *buf,
319 size_t count, loff_t *ppos)
308{ 320{
309 if(count) { 321 if (count) {
310 if (!nowayout) { 322 if (!nowayout) {
311 size_t i; 323 size_t i;
312 324
@@ -328,7 +340,6 @@ static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count
328 340
329/** 341/**
330 * wdt_ioctl: 342 * wdt_ioctl:
331 * @inode: inode of the device
332 * @file: file handle to the device 343 * @file: file handle to the device
333 * @cmd: watchdog command 344 * @cmd: watchdog command
334 * @arg: argument pointer 345 * @arg: argument pointer
@@ -338,8 +349,7 @@ static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count
338 * querying capabilities and current status. 349 * querying capabilities and current status.
339 */ 350 */
340 351
341static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 352static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
342 unsigned long arg)
343{ 353{
344 void __user *argp = (void __user *)arg; 354 void __user *argp = (void __user *)arg;
345 int __user *p = argp; 355 int __user *p = argp;
@@ -362,32 +372,28 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
362 ident.options |= WDIOF_FANFAULT; 372 ident.options |= WDIOF_FANFAULT;
363#endif /* CONFIG_WDT_501 */ 373#endif /* CONFIG_WDT_501 */
364 374
365 switch(cmd) 375 switch (cmd) {
366 { 376 default:
367 default: 377 return -ENOTTY;
368 return -ENOTTY; 378 case WDIOC_GETSUPPORT:
369 case WDIOC_GETSUPPORT: 379 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
370 return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0; 380 case WDIOC_GETSTATUS:
371 381 wdt_get_status(&status);
372 case WDIOC_GETSTATUS: 382 return put_user(status, p);
373 wdt_get_status(&status); 383 case WDIOC_GETBOOTSTATUS:
374 return put_user(status, p); 384 return put_user(0, p);
375 case WDIOC_GETBOOTSTATUS: 385 case WDIOC_KEEPALIVE:
376 return put_user(0, p); 386 wdt_ping();
377 case WDIOC_KEEPALIVE: 387 return 0;
378 wdt_ping(); 388 case WDIOC_SETTIMEOUT:
379 return 0; 389 if (get_user(new_heartbeat, p))
380 case WDIOC_SETTIMEOUT: 390 return -EFAULT;
381 if (get_user(new_heartbeat, p)) 391 if (wdt_set_heartbeat(new_heartbeat))
382 return -EFAULT; 392 return -EINVAL;
383 393 wdt_ping();
384 if (wdt_set_heartbeat(new_heartbeat)) 394 /* Fall */
385 return -EINVAL; 395 case WDIOC_GETTIMEOUT:
386 396 return put_user(heartbeat, p);
387 wdt_ping();
388 /* Fall */
389 case WDIOC_GETTIMEOUT:
390 return put_user(heartbeat, p);
391 } 397 }
392} 398}
393 399
@@ -405,7 +411,7 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
405 411
406static int wdt_open(struct inode *inode, struct file *file) 412static int wdt_open(struct inode *inode, struct file *file)
407{ 413{
408 if(test_and_set_bit(0, &wdt_is_open)) 414 if (test_and_set_bit(0, &wdt_is_open))
409 return -EBUSY; 415 return -EBUSY;
410 /* 416 /*
411 * Activate 417 * Activate
@@ -432,7 +438,8 @@ static int wdt_release(struct inode *inode, struct file *file)
432 wdt_stop(); 438 wdt_stop();
433 clear_bit(0, &wdt_is_open); 439 clear_bit(0, &wdt_is_open);
434 } else { 440 } else {
435 printk(KERN_CRIT "wdt: WDT device closed unexpectedly. WDT will not stop!\n"); 441 printk(KERN_CRIT
442 "wdt: WDT device closed unexpectedly. WDT will not stop!\n");
436 wdt_ping(); 443 wdt_ping();
437 } 444 }
438 expect_close = 0; 445 expect_close = 0;
@@ -451,14 +458,15 @@ static int wdt_release(struct inode *inode, struct file *file)
451 * farenheit. It was designed by an imperial measurement luddite. 458 * farenheit. It was designed by an imperial measurement luddite.
452 */ 459 */
453 460
454static ssize_t wdt_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) 461static ssize_t wdt_temp_read(struct file *file, char __user *buf,
462 size_t count, loff_t *ptr)
455{ 463{
456 int temperature; 464 int temperature;
457 465
458 if (wdt_get_temperature(&temperature)) 466 if (wdt_get_temperature(&temperature))
459 return -EFAULT; 467 return -EFAULT;
460 468
461 if (copy_to_user (buf, &temperature, 1)) 469 if (copy_to_user(buf, &temperature, 1))
462 return -EFAULT; 470 return -EFAULT;
463 471
464 return 1; 472 return 1;
@@ -506,10 +514,8 @@ static int wdt_temp_release(struct inode *inode, struct file *file)
506static int wdt_notify_sys(struct notifier_block *this, unsigned long code, 514static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
507 void *unused) 515 void *unused)
508{ 516{
509 if(code==SYS_DOWN || code==SYS_HALT) { 517 if (code == SYS_DOWN || code == SYS_HALT)
510 /* Turn the card off */
511 wdt_stop(); 518 wdt_stop();
512 }
513 return NOTIFY_DONE; 519 return NOTIFY_DONE;
514} 520}
515 521
@@ -522,7 +528,7 @@ static const struct file_operations wdt_fops = {
522 .owner = THIS_MODULE, 528 .owner = THIS_MODULE,
523 .llseek = no_llseek, 529 .llseek = no_llseek,
524 .write = wdt_write, 530 .write = wdt_write,
525 .ioctl = wdt_ioctl, 531 .unlocked_ioctl = wdt_ioctl,
526 .open = wdt_open, 532 .open = wdt_open,
527 .release = wdt_release, 533 .release = wdt_release,
528}; 534};
@@ -576,7 +582,7 @@ static void __exit wdt_exit(void)
576#endif /* CONFIG_WDT_501 */ 582#endif /* CONFIG_WDT_501 */
577 unregister_reboot_notifier(&wdt_notifier); 583 unregister_reboot_notifier(&wdt_notifier);
578 free_irq(irq, NULL); 584 free_irq(irq, NULL);
579 release_region(io,8); 585 release_region(io, 8);
580} 586}
581 587
582/** 588/**
@@ -591,44 +597,49 @@ static int __init wdt_init(void)
591{ 597{
592 int ret; 598 int ret;
593 599
594 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 600 /* Check that the heartbeat value is within it's range;
601 if not reset to the default */
595 if (wdt_set_heartbeat(heartbeat)) { 602 if (wdt_set_heartbeat(heartbeat)) {
596 wdt_set_heartbeat(WD_TIMO); 603 wdt_set_heartbeat(WD_TIMO);
597 printk(KERN_INFO "wdt: heartbeat value must be 0<heartbeat<65536, using %d\n", 604 printk(KERN_INFO "wdt: heartbeat value must be 0 < heartbeat < 65536, using %d\n",
598 WD_TIMO); 605 WD_TIMO);
599 } 606 }
600 607
601 if (!request_region(io, 8, "wdt501p")) { 608 if (!request_region(io, 8, "wdt501p")) {
602 printk(KERN_ERR "wdt: I/O address 0x%04x already in use\n", io); 609 printk(KERN_ERR
610 "wdt: I/O address 0x%04x already in use\n", io);
603 ret = -EBUSY; 611 ret = -EBUSY;
604 goto out; 612 goto out;
605 } 613 }
606 614
607 ret = request_irq(irq, wdt_interrupt, IRQF_DISABLED, "wdt501p", NULL); 615 ret = request_irq(irq, wdt_interrupt, IRQF_DISABLED, "wdt501p", NULL);
608 if(ret) { 616 if (ret) {
609 printk(KERN_ERR "wdt: IRQ %d is not free.\n", irq); 617 printk(KERN_ERR "wdt: IRQ %d is not free.\n", irq);
610 goto outreg; 618 goto outreg;
611 } 619 }
612 620
613 ret = register_reboot_notifier(&wdt_notifier); 621 ret = register_reboot_notifier(&wdt_notifier);
614 if(ret) { 622 if (ret) {
615 printk(KERN_ERR "wdt: cannot register reboot notifier (err=%d)\n", ret); 623 printk(KERN_ERR
624 "wdt: cannot register reboot notifier (err=%d)\n", ret);
616 goto outirq; 625 goto outirq;
617 } 626 }
618 627
619#ifdef CONFIG_WDT_501 628#ifdef CONFIG_WDT_501
620 ret = misc_register(&temp_miscdev); 629 ret = misc_register(&temp_miscdev);
621 if (ret) { 630 if (ret) {
622 printk(KERN_ERR "wdt: cannot register miscdev on minor=%d (err=%d)\n", 631 printk(KERN_ERR
623 TEMP_MINOR, ret); 632 "wdt: cannot register miscdev on minor=%d (err=%d)\n",
633 TEMP_MINOR, ret);
624 goto outrbt; 634 goto outrbt;
625 } 635 }
626#endif /* CONFIG_WDT_501 */ 636#endif /* CONFIG_WDT_501 */
627 637
628 ret = misc_register(&wdt_miscdev); 638 ret = misc_register(&wdt_miscdev);
629 if (ret) { 639 if (ret) {
630 printk(KERN_ERR "wdt: cannot register miscdev on minor=%d (err=%d)\n", 640 printk(KERN_ERR
631 WATCHDOG_MINOR, ret); 641 "wdt: cannot register miscdev on minor=%d (err=%d)\n",
642 WATCHDOG_MINOR, ret);
632 goto outmisc; 643 goto outmisc;
633 } 644 }
634 645
@@ -636,7 +647,8 @@ static int __init wdt_init(void)
636 printk(KERN_INFO "WDT500/501-P driver 0.10 at 0x%04x (Interrupt %d). heartbeat=%d sec (nowayout=%d)\n", 647 printk(KERN_INFO "WDT500/501-P driver 0.10 at 0x%04x (Interrupt %d). heartbeat=%d sec (nowayout=%d)\n",
637 io, irq, heartbeat, nowayout); 648 io, irq, heartbeat, nowayout);
638#ifdef CONFIG_WDT_501 649#ifdef CONFIG_WDT_501
639 printk(KERN_INFO "wdt: Fan Tachometer is %s\n", (tachometer ? "Enabled" : "Disabled")); 650 printk(KERN_INFO "wdt: Fan Tachometer is %s\n",
651 (tachometer ? "Enabled" : "Disabled"));
640#endif /* CONFIG_WDT_501 */ 652#endif /* CONFIG_WDT_501 */
641 653
642out: 654out:
@@ -651,7 +663,7 @@ outrbt:
651outirq: 663outirq:
652 free_irq(irq, NULL); 664 free_irq(irq, NULL);
653outreg: 665outreg:
654 release_region(io,8); 666 release_region(io, 8);
655 goto out; 667 goto out;
656} 668}
657 669
diff --git a/drivers/watchdog/wdt_pci.c b/drivers/watchdog/wdt_pci.c
index 1355608683e4..5d922fd6eafc 100644
--- a/drivers/watchdog/wdt_pci.c
+++ b/drivers/watchdog/wdt_pci.c
@@ -29,9 +29,11 @@
29 * JP Nollmann : Added support for PCI wdt501p 29 * JP Nollmann : Added support for PCI wdt501p
30 * Alan Cox : Split ISA and PCI cards into two drivers 30 * Alan Cox : Split ISA and PCI cards into two drivers
31 * Jeff Garzik : PCI cleanups 31 * Jeff Garzik : PCI cleanups
32 * Tigran Aivazian : Restructured wdtpci_init_one() to handle failures 32 * Tigran Aivazian : Restructured wdtpci_init_one() to handle
33 * failures
33 * Joel Becker : Added WDIOC_GET/SETTIMEOUT 34 * Joel Becker : Added WDIOC_GET/SETTIMEOUT
34 * Zwane Mwaikambo : Magic char closing, locking changes, cleanups 35 * Zwane Mwaikambo : Magic char closing, locking changes,
36 * cleanups
35 * Matt Domsch : nowayout module option 37 * Matt Domsch : nowayout module option
36 */ 38 */
37 39
@@ -42,14 +44,15 @@
42#include <linux/miscdevice.h> 44#include <linux/miscdevice.h>
43#include <linux/watchdog.h> 45#include <linux/watchdog.h>
44#include <linux/ioport.h> 46#include <linux/ioport.h>
47#include <linux/delay.h>
45#include <linux/notifier.h> 48#include <linux/notifier.h>
46#include <linux/reboot.h> 49#include <linux/reboot.h>
47#include <linux/init.h> 50#include <linux/init.h>
48#include <linux/fs.h> 51#include <linux/fs.h>
49#include <linux/pci.h> 52#include <linux/pci.h>
53#include <linux/io.h>
54#include <linux/uaccess.h>
50 55
51#include <asm/io.h>
52#include <asm/uaccess.h>
53#include <asm/system.h> 56#include <asm/system.h>
54 57
55#define WDT_IS_PCI 58#define WDT_IS_PCI
@@ -73,7 +76,7 @@
73/* We can only use 1 card due to the /dev/watchdog restriction */ 76/* We can only use 1 card due to the /dev/watchdog restriction */
74static int dev_count; 77static int dev_count;
75 78
76static struct semaphore open_sem; 79static unsigned long open_lock;
77static DEFINE_SPINLOCK(wdtpci_lock); 80static DEFINE_SPINLOCK(wdtpci_lock);
78static char expect_close; 81static char expect_close;
79 82
@@ -86,18 +89,23 @@ static int irq;
86static int heartbeat = WD_TIMO; 89static int heartbeat = WD_TIMO;
87static int wd_heartbeat; 90static int wd_heartbeat;
88module_param(heartbeat, int, 0); 91module_param(heartbeat, int, 0);
89MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WD_TIMO) ")"); 92MODULE_PARM_DESC(heartbeat,
93 "Watchdog heartbeat in seconds. (0<heartbeat<65536, default="
94 __MODULE_STRING(WD_TIMO) ")");
90 95
91static int nowayout = WATCHDOG_NOWAYOUT; 96static int nowayout = WATCHDOG_NOWAYOUT;
92module_param(nowayout, int, 0); 97module_param(nowayout, int, 0);
93MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 98MODULE_PARM_DESC(nowayout,
99 "Watchdog cannot be stopped once started (default="
100 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
94 101
95#ifdef CONFIG_WDT_501_PCI 102#ifdef CONFIG_WDT_501_PCI
96/* Support for the Fan Tachometer on the PCI-WDT501 */ 103/* Support for the Fan Tachometer on the PCI-WDT501 */
97static int tachometer; 104static int tachometer;
98 105
99module_param(tachometer, int, 0); 106module_param(tachometer, int, 0);
100MODULE_PARM_DESC(tachometer, "PCI-WDT501 Fan Tachometer support (0=disable, default=0)"); 107MODULE_PARM_DESC(tachometer,
108 "PCI-WDT501 Fan Tachometer support (0=disable, default=0)");
101#endif /* CONFIG_WDT_501_PCI */ 109#endif /* CONFIG_WDT_501_PCI */
102 110
103/* 111/*
@@ -106,16 +114,19 @@ MODULE_PARM_DESC(tachometer, "PCI-WDT501 Fan Tachometer support (0=disable, defa
106 114
107static void wdtpci_ctr_mode(int ctr, int mode) 115static void wdtpci_ctr_mode(int ctr, int mode)
108{ 116{
109 ctr<<=6; 117 ctr <<= 6;
110 ctr|=0x30; 118 ctr |= 0x30;
111 ctr|=(mode<<1); 119 ctr |= (mode << 1);
112 outb_p(ctr, WDT_CR); 120 outb(ctr, WDT_CR);
121 udelay(8);
113} 122}
114 123
115static void wdtpci_ctr_load(int ctr, int val) 124static void wdtpci_ctr_load(int ctr, int val)
116{ 125{
117 outb_p(val&0xFF, WDT_COUNT0+ctr); 126 outb(val & 0xFF, WDT_COUNT0 + ctr);
118 outb_p(val>>8, WDT_COUNT0+ctr); 127 udelay(8);
128 outb(val >> 8, WDT_COUNT0 + ctr);
129 udelay(8);
119} 130}
120 131
121/** 132/**
@@ -134,23 +145,35 @@ static int wdtpci_start(void)
134 * "pet" the watchdog, as Access says. 145 * "pet" the watchdog, as Access says.
135 * This resets the clock outputs. 146 * This resets the clock outputs.
136 */ 147 */
137 inb_p(WDT_DC); /* Disable watchdog */ 148 inb(WDT_DC); /* Disable watchdog */
138 wdtpci_ctr_mode(2,0); /* Program CTR2 for Mode 0: Pulse on Terminal Count */ 149 udelay(8);
139 outb_p(0, WDT_DC); /* Enable watchdog */ 150 wdtpci_ctr_mode(2, 0); /* Program CTR2 for Mode 0:
140 151 Pulse on Terminal Count */
141 inb_p(WDT_DC); /* Disable watchdog */ 152 outb(0, WDT_DC); /* Enable watchdog */
142 outb_p(0, WDT_CLOCK); /* 2.0833MHz clock */ 153 udelay(8);
143 inb_p(WDT_BUZZER); /* disable */ 154 inb(WDT_DC); /* Disable watchdog */
144 inb_p(WDT_OPTONOTRST); /* disable */ 155 udelay(8);
145 inb_p(WDT_OPTORST); /* disable */ 156 outb(0, WDT_CLOCK); /* 2.0833MHz clock */
146 inb_p(WDT_PROGOUT); /* disable */ 157 udelay(8);
147 wdtpci_ctr_mode(0,3); /* Program CTR0 for Mode 3: Square Wave Generator */ 158 inb(WDT_BUZZER); /* disable */
148 wdtpci_ctr_mode(1,2); /* Program CTR1 for Mode 2: Rate Generator */ 159 udelay(8);
149 wdtpci_ctr_mode(2,1); /* Program CTR2 for Mode 1: Retriggerable One-Shot */ 160 inb(WDT_OPTONOTRST); /* disable */
150 wdtpci_ctr_load(0,20833); /* count at 100Hz */ 161 udelay(8);
151 wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */ 162 inb(WDT_OPTORST); /* disable */
163 udelay(8);
164 inb(WDT_PROGOUT); /* disable */
165 udelay(8);
166 wdtpci_ctr_mode(0, 3); /* Program CTR0 for Mode 3:
167 Square Wave Generator */
168 wdtpci_ctr_mode(1, 2); /* Program CTR1 for Mode 2:
169 Rate Generator */
170 wdtpci_ctr_mode(2, 1); /* Program CTR2 for Mode 1:
171 Retriggerable One-Shot */
172 wdtpci_ctr_load(0, 20833); /* count at 100Hz */
173 wdtpci_ctr_load(1, wd_heartbeat);/* Heartbeat */
152 /* DO NOT LOAD CTR2 on PCI card! -- JPN */ 174 /* DO NOT LOAD CTR2 on PCI card! -- JPN */
153 outb_p(0, WDT_DC); /* Enable watchdog */ 175 outb(0, WDT_DC); /* Enable watchdog */
176 udelay(8);
154 177
155 spin_unlock_irqrestore(&wdtpci_lock, flags); 178 spin_unlock_irqrestore(&wdtpci_lock, flags);
156 return 0; 179 return 0;
@@ -162,14 +185,15 @@ static int wdtpci_start(void)
162 * Stop the watchdog driver. 185 * Stop the watchdog driver.
163 */ 186 */
164 187
165static int wdtpci_stop (void) 188static int wdtpci_stop(void)
166{ 189{
167 unsigned long flags; 190 unsigned long flags;
168 191
169 /* Turn the card off */ 192 /* Turn the card off */
170 spin_lock_irqsave(&wdtpci_lock, flags); 193 spin_lock_irqsave(&wdtpci_lock, flags);
171 inb_p(WDT_DC); /* Disable watchdog */ 194 inb(WDT_DC); /* Disable watchdog */
172 wdtpci_ctr_load(2,0); /* 0 length reset pulses now */ 195 udelay(8);
196 wdtpci_ctr_load(2, 0); /* 0 length reset pulses now */
173 spin_unlock_irqrestore(&wdtpci_lock, flags); 197 spin_unlock_irqrestore(&wdtpci_lock, flags);
174 return 0; 198 return 0;
175} 199}
@@ -177,20 +201,23 @@ static int wdtpci_stop (void)
177/** 201/**
178 * wdtpci_ping: 202 * wdtpci_ping:
179 * 203 *
180 * Reload counter one with the watchdog heartbeat. We don't bother reloading 204 * Reload counter one with the watchdog heartbeat. We don't bother
181 * the cascade counter. 205 * reloading the cascade counter.
182 */ 206 */
183 207
184static int wdtpci_ping(void) 208static int wdtpci_ping(void)
185{ 209{
186 unsigned long flags; 210 unsigned long flags;
187 211
188 /* Write a watchdog value */
189 spin_lock_irqsave(&wdtpci_lock, flags); 212 spin_lock_irqsave(&wdtpci_lock, flags);
190 inb_p(WDT_DC); /* Disable watchdog */ 213 /* Write a watchdog value */
191 wdtpci_ctr_mode(1,2); /* Re-Program CTR1 for Mode 2: Rate Generator */ 214 inb(WDT_DC); /* Disable watchdog */
192 wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */ 215 udelay(8);
193 outb_p(0, WDT_DC); /* Enable watchdog */ 216 wdtpci_ctr_mode(1, 2); /* Re-Program CTR1 for Mode 2:
217 Rate Generator */
218 wdtpci_ctr_load(1, wd_heartbeat);/* Heartbeat */
219 outb(0, WDT_DC); /* Enable watchdog */
220 udelay(8);
194 spin_unlock_irqrestore(&wdtpci_lock, flags); 221 spin_unlock_irqrestore(&wdtpci_lock, flags);
195 return 0; 222 return 0;
196} 223}
@@ -199,14 +226,14 @@ static int wdtpci_ping(void)
199 * wdtpci_set_heartbeat: 226 * wdtpci_set_heartbeat:
200 * @t: the new heartbeat value that needs to be set. 227 * @t: the new heartbeat value that needs to be set.
201 * 228 *
202 * Set a new heartbeat value for the watchdog device. If the heartbeat value is 229 * Set a new heartbeat value for the watchdog device. If the heartbeat
203 * incorrect we keep the old value and return -EINVAL. If successfull we 230 * value is incorrect we keep the old value and return -EINVAL.
204 * return 0. 231 * If successful we return 0.
205 */ 232 */
206static int wdtpci_set_heartbeat(int t) 233static int wdtpci_set_heartbeat(int t)
207{ 234{
208 /* Arbitrary, can't find the card's limits */ 235 /* Arbitrary, can't find the card's limits */
209 if ((t < 1) || (t > 65535)) 236 if (t < 1 || t > 65535)
210 return -EINVAL; 237 return -EINVAL;
211 238
212 heartbeat = t; 239 heartbeat = t;
@@ -227,9 +254,14 @@ static int wdtpci_set_heartbeat(int t)
227 254
228static int wdtpci_get_status(int *status) 255static int wdtpci_get_status(int *status)
229{ 256{
230 unsigned char new_status=inb_p(WDT_SR); 257 unsigned char new_status;
258 unsigned long flags;
259
260 spin_lock_irqsave(&wdtpci_lock, flags);
261 new_status = inb(WDT_SR);
262 spin_unlock_irqrestore(&wdtpci_lock, flags);
231 263
232 *status=0; 264 *status = 0;
233 if (new_status & WDC_SR_ISOI0) 265 if (new_status & WDC_SR_ISOI0)
234 *status |= WDIOF_EXTERN1; 266 *status |= WDIOF_EXTERN1;
235 if (new_status & WDC_SR_ISII1) 267 if (new_status & WDC_SR_ISII1)
@@ -259,8 +291,12 @@ static int wdtpci_get_status(int *status)
259 291
260static int wdtpci_get_temperature(int *temperature) 292static int wdtpci_get_temperature(int *temperature)
261{ 293{
262 unsigned short c=inb_p(WDT_RT); 294 unsigned short c;
263 295 unsigned long flags;
296 spin_lock_irqsave(&wdtpci_lock, flags);
297 c = inb(WDT_RT);
298 udelay(8);
299 spin_unlock_irqrestore(&wdtpci_lock, flags);
264 *temperature = (c * 11 / 15) + 7; 300 *temperature = (c * 11 / 15) + 7;
265 return 0; 301 return 0;
266} 302}
@@ -282,17 +318,25 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
282 * Read the status register see what is up and 318 * Read the status register see what is up and
283 * then printk it. 319 * then printk it.
284 */ 320 */
285 unsigned char status=inb_p(WDT_SR); 321 unsigned char status;
322
323 spin_lock(&wdtpci_lock);
324
325 status = inb(WDT_SR);
326 udelay(8);
286 327
287 printk(KERN_CRIT PFX "status %d\n", status); 328 printk(KERN_CRIT PFX "status %d\n", status);
288 329
289#ifdef CONFIG_WDT_501_PCI 330#ifdef CONFIG_WDT_501_PCI
290 if (!(status & WDC_SR_TGOOD)) 331 if (!(status & WDC_SR_TGOOD)) {
291 printk(KERN_CRIT PFX "Overheat alarm.(%d)\n",inb_p(WDT_RT)); 332 u8 alarm = inb(WDT_RT);
333 printk(KERN_CRIT PFX "Overheat alarm.(%d)\n", alarm);
334 udelay(8);
335 }
292 if (!(status & WDC_SR_PSUOVER)) 336 if (!(status & WDC_SR_PSUOVER))
293 printk(KERN_CRIT PFX "PSU over voltage.\n"); 337 printk(KERN_CRIT PFX "PSU over voltage.\n");
294 if (!(status & WDC_SR_PSUUNDR)) 338 if (!(status & WDC_SR_PSUUNDR))
295 printk(KERN_CRIT PFX "PSU under voltage.\n"); 339 printk(KERN_CRIT PFX "PSU under voltage.\n");
296 if (tachometer) { 340 if (tachometer) {
297 if (!(status & WDC_SR_FANGOOD)) 341 if (!(status & WDC_SR_FANGOOD))
298 printk(KERN_CRIT PFX "Possible fan fault.\n"); 342 printk(KERN_CRIT PFX "Possible fan fault.\n");
@@ -310,6 +354,7 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
310 printk(KERN_CRIT PFX "Reset in 5ms.\n"); 354 printk(KERN_CRIT PFX "Reset in 5ms.\n");
311#endif 355#endif
312 } 356 }
357 spin_unlock(&wdtpci_lock);
313 return IRQ_HANDLED; 358 return IRQ_HANDLED;
314} 359}
315 360
@@ -325,7 +370,8 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
325 * write of data will do, as we we don't define content meaning. 370 * write of data will do, as we we don't define content meaning.
326 */ 371 */
327 372
328static ssize_t wdtpci_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 373static ssize_t wdtpci_write(struct file *file, const char __user *buf,
374 size_t count, loff_t *ppos)
329{ 375{
330 if (count) { 376 if (count) {
331 if (!nowayout) { 377 if (!nowayout) {
@@ -335,7 +381,7 @@ static ssize_t wdtpci_write(struct file *file, const char __user *buf, size_t co
335 381
336 for (i = 0; i != count; i++) { 382 for (i = 0; i != count; i++) {
337 char c; 383 char c;
338 if(get_user(c, buf+i)) 384 if (get_user(c, buf+i))
339 return -EFAULT; 385 return -EFAULT;
340 if (c == 'V') 386 if (c == 'V')
341 expect_close = 42; 387 expect_close = 42;
@@ -343,13 +389,11 @@ static ssize_t wdtpci_write(struct file *file, const char __user *buf, size_t co
343 } 389 }
344 wdtpci_ping(); 390 wdtpci_ping();
345 } 391 }
346
347 return count; 392 return count;
348} 393}
349 394
350/** 395/**
351 * wdtpci_ioctl: 396 * wdtpci_ioctl:
352 * @inode: inode of the device
353 * @file: file handle to the device 397 * @file: file handle to the device
354 * @cmd: watchdog command 398 * @cmd: watchdog command
355 * @arg: argument pointer 399 * @arg: argument pointer
@@ -359,8 +403,8 @@ static ssize_t wdtpci_write(struct file *file, const char __user *buf, size_t co
359 * querying capabilities and current status. 403 * querying capabilities and current status.
360 */ 404 */
361 405
362static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 406static long wdtpci_ioctl(struct file *file, unsigned int cmd,
363 unsigned long arg) 407 unsigned long arg)
364{ 408{
365 int new_heartbeat; 409 int new_heartbeat;
366 int status; 410 int status;
@@ -383,33 +427,29 @@ static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd
383 ident.options |= WDIOF_FANFAULT; 427 ident.options |= WDIOF_FANFAULT;
384#endif /* CONFIG_WDT_501_PCI */ 428#endif /* CONFIG_WDT_501_PCI */
385 429
386 switch(cmd) 430 switch (cmd) {
387 { 431 default:
388 default: 432 return -ENOTTY;
389 return -ENOTTY; 433 case WDIOC_GETSUPPORT:
390 case WDIOC_GETSUPPORT: 434 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
391 return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0; 435 case WDIOC_GETSTATUS:
392 436 wdtpci_get_status(&status);
393 case WDIOC_GETSTATUS: 437 return put_user(status, p);
394 wdtpci_get_status(&status); 438 case WDIOC_GETBOOTSTATUS:
395 return put_user(status, p); 439 return put_user(0, p);
396 case WDIOC_GETBOOTSTATUS: 440 case WDIOC_KEEPALIVE:
397 return put_user(0, p); 441 wdtpci_ping();
398 case WDIOC_KEEPALIVE: 442 return 0;
399 wdtpci_ping(); 443 case WDIOC_SETTIMEOUT:
400 return 0; 444 if (get_user(new_heartbeat, p))
401 case WDIOC_SETTIMEOUT: 445 return -EFAULT;
402 if (get_user(new_heartbeat, p)) 446 if (wdtpci_set_heartbeat(new_heartbeat))
403 return -EFAULT; 447 return -EINVAL;
404 448 wdtpci_ping();
405 if (wdtpci_set_heartbeat(new_heartbeat)) 449 /* Fall */
406 return -EINVAL; 450 case WDIOC_GETTIMEOUT:
407 451 return put_user(heartbeat, p);
408 wdtpci_ping(); 452 }
409 /* Fall */
410 case WDIOC_GETTIMEOUT:
411 return put_user(heartbeat, p);
412 }
413} 453}
414 454
415/** 455/**
@@ -426,12 +466,11 @@ static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd
426 466
427static int wdtpci_open(struct inode *inode, struct file *file) 467static int wdtpci_open(struct inode *inode, struct file *file)
428{ 468{
429 if (down_trylock(&open_sem)) 469 if (test_and_set_bit(0, &open_lock))
430 return -EBUSY; 470 return -EBUSY;
431 471
432 if (nowayout) { 472 if (nowayout)
433 __module_get(THIS_MODULE); 473 __module_get(THIS_MODULE);
434 }
435 /* 474 /*
436 * Activate 475 * Activate
437 */ 476 */
@@ -460,7 +499,7 @@ static int wdtpci_release(struct inode *inode, struct file *file)
460 wdtpci_ping(); 499 wdtpci_ping();
461 } 500 }
462 expect_close = 0; 501 expect_close = 0;
463 up(&open_sem); 502 clear_bit(0, &open_lock);
464 return 0; 503 return 0;
465} 504}
466 505
@@ -476,14 +515,15 @@ static int wdtpci_release(struct inode *inode, struct file *file)
476 * fahrenheit. It was designed by an imperial measurement luddite. 515 * fahrenheit. It was designed by an imperial measurement luddite.
477 */ 516 */
478 517
479static ssize_t wdtpci_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) 518static ssize_t wdtpci_temp_read(struct file *file, char __user *buf,
519 size_t count, loff_t *ptr)
480{ 520{
481 int temperature; 521 int temperature;
482 522
483 if (wdtpci_get_temperature(&temperature)) 523 if (wdtpci_get_temperature(&temperature))
484 return -EFAULT; 524 return -EFAULT;
485 525
486 if (copy_to_user (buf, &temperature, 1)) 526 if (copy_to_user(buf, &temperature, 1))
487 return -EFAULT; 527 return -EFAULT;
488 528
489 return 1; 529 return 1;
@@ -529,12 +569,10 @@ static int wdtpci_temp_release(struct inode *inode, struct file *file)
529 */ 569 */
530 570
531static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code, 571static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code,
532 void *unused) 572 void *unused)
533{ 573{
534 if (code==SYS_DOWN || code==SYS_HALT) { 574 if (code == SYS_DOWN || code == SYS_HALT)
535 /* Turn the card off */
536 wdtpci_stop(); 575 wdtpci_stop();
537 }
538 return NOTIFY_DONE; 576 return NOTIFY_DONE;
539} 577}
540 578
@@ -547,7 +585,7 @@ static const struct file_operations wdtpci_fops = {
547 .owner = THIS_MODULE, 585 .owner = THIS_MODULE,
548 .llseek = no_llseek, 586 .llseek = no_llseek,
549 .write = wdtpci_write, 587 .write = wdtpci_write,
550 .ioctl = wdtpci_ioctl, 588 .unlocked_ioctl = wdtpci_ioctl,
551 .open = wdtpci_open, 589 .open = wdtpci_open,
552 .release = wdtpci_release, 590 .release = wdtpci_release,
553}; 591};
@@ -584,80 +622,85 @@ static struct notifier_block wdtpci_notifier = {
584}; 622};
585 623
586 624
587static int __devinit wdtpci_init_one (struct pci_dev *dev, 625static int __devinit wdtpci_init_one(struct pci_dev *dev,
588 const struct pci_device_id *ent) 626 const struct pci_device_id *ent)
589{ 627{
590 int ret = -EIO; 628 int ret = -EIO;
591 629
592 dev_count++; 630 dev_count++;
593 if (dev_count > 1) { 631 if (dev_count > 1) {
594 printk (KERN_ERR PFX "this driver only supports 1 device\n"); 632 printk(KERN_ERR PFX "This driver only supports one device\n");
595 return -ENODEV; 633 return -ENODEV;
596 } 634 }
597 635
598 if (pci_enable_device (dev)) { 636 if (pci_enable_device(dev)) {
599 printk (KERN_ERR PFX "Not possible to enable PCI Device\n"); 637 printk(KERN_ERR PFX "Not possible to enable PCI Device\n");
600 return -ENODEV; 638 return -ENODEV;
601 } 639 }
602 640
603 if (pci_resource_start (dev, 2) == 0x0000) { 641 if (pci_resource_start(dev, 2) == 0x0000) {
604 printk (KERN_ERR PFX "No I/O-Address for card detected\n"); 642 printk(KERN_ERR PFX "No I/O-Address for card detected\n");
605 ret = -ENODEV; 643 ret = -ENODEV;
606 goto out_pci; 644 goto out_pci;
607 } 645 }
608 646
609 sema_init(&open_sem, 1);
610
611 irq = dev->irq; 647 irq = dev->irq;
612 io = pci_resource_start (dev, 2); 648 io = pci_resource_start(dev, 2);
613 649
614 if (request_region (io, 16, "wdt_pci") == NULL) { 650 if (request_region(io, 16, "wdt_pci") == NULL) {
615 printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", io); 651 printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", io);
616 goto out_pci; 652 goto out_pci;
617 } 653 }
618 654
619 if (request_irq (irq, wdtpci_interrupt, IRQF_DISABLED | IRQF_SHARED, 655 if (request_irq(irq, wdtpci_interrupt, IRQF_DISABLED | IRQF_SHARED,
620 "wdt_pci", &wdtpci_miscdev)) { 656 "wdt_pci", &wdtpci_miscdev)) {
621 printk (KERN_ERR PFX "IRQ %d is not free\n", irq); 657 printk(KERN_ERR PFX "IRQ %d is not free\n", irq);
622 goto out_reg; 658 goto out_reg;
623 } 659 }
624 660
625 printk ("PCI-WDT500/501 (PCI-WDG-CSM) driver 0.10 at 0x%04x (Interrupt %d)\n", 661 printk(KERN_INFO
626 io, irq); 662 "PCI-WDT500/501 (PCI-WDG-CSM) driver 0.10 at 0x%04x (Interrupt %d)\n",
663 io, irq);
627 664
628 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 665 /* Check that the heartbeat value is within its range;
666 if not reset to the default */
629 if (wdtpci_set_heartbeat(heartbeat)) { 667 if (wdtpci_set_heartbeat(heartbeat)) {
630 wdtpci_set_heartbeat(WD_TIMO); 668 wdtpci_set_heartbeat(WD_TIMO);
631 printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n", 669 printk(KERN_INFO PFX
632 WD_TIMO); 670 "heartbeat value must be 0 < heartbeat < 65536, using %d\n",
671 WD_TIMO);
633 } 672 }
634 673
635 ret = register_reboot_notifier (&wdtpci_notifier); 674 ret = register_reboot_notifier(&wdtpci_notifier);
636 if (ret) { 675 if (ret) {
637 printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); 676 printk(KERN_ERR PFX
677 "cannot register reboot notifier (err=%d)\n", ret);
638 goto out_irq; 678 goto out_irq;
639 } 679 }
640 680
641#ifdef CONFIG_WDT_501_PCI 681#ifdef CONFIG_WDT_501_PCI
642 ret = misc_register (&temp_miscdev); 682 ret = misc_register(&temp_miscdev);
643 if (ret) { 683 if (ret) {
644 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 684 printk(KERN_ERR PFX
645 TEMP_MINOR, ret); 685 "cannot register miscdev on minor=%d (err=%d)\n",
686 TEMP_MINOR, ret);
646 goto out_rbt; 687 goto out_rbt;
647 } 688 }
648#endif /* CONFIG_WDT_501_PCI */ 689#endif /* CONFIG_WDT_501_PCI */
649 690
650 ret = misc_register (&wdtpci_miscdev); 691 ret = misc_register(&wdtpci_miscdev);
651 if (ret) { 692 if (ret) {
652 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 693 printk(KERN_ERR PFX
653 WATCHDOG_MINOR, ret); 694 "cannot register miscdev on minor=%d (err=%d)\n",
695 WATCHDOG_MINOR, ret);
654 goto out_misc; 696 goto out_misc;
655 } 697 }
656 698
657 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", 699 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
658 heartbeat, nowayout); 700 heartbeat, nowayout);
659#ifdef CONFIG_WDT_501_PCI 701#ifdef CONFIG_WDT_501_PCI
660 printk(KERN_INFO "wdt: Fan Tachometer is %s\n", (tachometer ? "Enabled" : "Disabled")); 702 printk(KERN_INFO "wdt: Fan Tachometer is %s\n",
703 (tachometer ? "Enabled" : "Disabled"));
661#endif /* CONFIG_WDT_501_PCI */ 704#endif /* CONFIG_WDT_501_PCI */
662 705
663 ret = 0; 706 ret = 0;
@@ -673,14 +716,14 @@ out_rbt:
673out_irq: 716out_irq:
674 free_irq(irq, &wdtpci_miscdev); 717 free_irq(irq, &wdtpci_miscdev);
675out_reg: 718out_reg:
676 release_region (io, 16); 719 release_region(io, 16);
677out_pci: 720out_pci:
678 pci_disable_device(dev); 721 pci_disable_device(dev);
679 goto out; 722 goto out;
680} 723}
681 724
682 725
683static void __devexit wdtpci_remove_one (struct pci_dev *pdev) 726static void __devexit wdtpci_remove_one(struct pci_dev *pdev)
684{ 727{
685 /* here we assume only one device will ever have 728 /* here we assume only one device will ever have
686 * been picked up and registered by probe function */ 729 * been picked up and registered by probe function */
@@ -728,7 +771,7 @@ static struct pci_driver wdtpci_driver = {
728 771
729static void __exit wdtpci_cleanup(void) 772static void __exit wdtpci_cleanup(void)
730{ 773{
731 pci_unregister_driver (&wdtpci_driver); 774 pci_unregister_driver(&wdtpci_driver);
732} 775}
733 776
734 777
@@ -742,7 +785,7 @@ static void __exit wdtpci_cleanup(void)
742 785
743static int __init wdtpci_init(void) 786static int __init wdtpci_init(void)
744{ 787{
745 return pci_register_driver (&wdtpci_driver); 788 return pci_register_driver(&wdtpci_driver);
746} 789}
747 790
748 791