From af5cb7ea30889bfb9a751a906bcc732987fba6a0 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 28 Oct 2005 21:37:29 +0100 Subject: [PATCH] --- yaml --- r: 10662 b: refs/heads/master c: 19c1f3ca4272008a256cc153f3e3feb097799070 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/Documentation/hwmon/it87 | 8 +- trunk/Documentation/hwmon/lm90 | 47 +- trunk/Documentation/hwmon/smsc47b397 | 8 +- trunk/Documentation/hwmon/smsc47m1 | 7 - trunk/Documentation/hwmon/sysfs-interface | 3 - trunk/Documentation/hwmon/via686a | 17 +- trunk/Documentation/i2c/busses/i2c-i810 | 1 - trunk/Documentation/i2c/busses/i2c-viapro | 27 +- trunk/Documentation/i2c/chips/x1205 | 38 - trunk/Documentation/i2c/functionality | 7 +- trunk/Documentation/i2c/porting-clients | 2 +- trunk/Documentation/i2c/writing-clients | 27 +- trunk/MAINTAINERS | 6 - trunk/Makefile | 4 +- trunk/drivers/hwmon/adm1021.c | 5 +- trunk/drivers/hwmon/adm1025.c | 3 +- trunk/drivers/hwmon/adm1026.c | 22 +- trunk/drivers/hwmon/adm1031.c | 3 +- trunk/drivers/hwmon/adm9240.c | 429 +++++------ trunk/drivers/hwmon/asb100.c | 11 +- trunk/drivers/hwmon/atxp1.c | 5 +- trunk/drivers/hwmon/ds1621.c | 9 +- trunk/drivers/hwmon/fscher.c | 3 +- trunk/drivers/hwmon/fscpos.c | 5 +- trunk/drivers/hwmon/gl518sm.c | 3 +- trunk/drivers/hwmon/gl520sm.c | 3 +- trunk/drivers/hwmon/it87.c | 56 +- trunk/drivers/hwmon/lm63.c | 3 +- trunk/drivers/hwmon/lm75.c | 3 +- trunk/drivers/hwmon/lm77.c | 3 +- trunk/drivers/hwmon/lm78.c | 6 +- trunk/drivers/hwmon/lm80.c | 5 +- trunk/drivers/hwmon/lm83.c | 3 +- trunk/drivers/hwmon/lm85.c | 15 +- trunk/drivers/hwmon/lm87.c | 3 +- trunk/drivers/hwmon/lm90.c | 181 ++--- trunk/drivers/hwmon/lm92.c | 3 +- trunk/drivers/hwmon/max1619.c | 3 +- trunk/drivers/hwmon/pc87360.c | 3 +- trunk/drivers/hwmon/sis5595.c | 3 +- trunk/drivers/hwmon/smsc47b397.c | 10 +- trunk/drivers/hwmon/smsc47m1.c | 10 +- trunk/drivers/hwmon/via686a.c | 28 +- trunk/drivers/hwmon/w83627ehf.c | 16 +- trunk/drivers/hwmon/w83627hf.c | 32 +- trunk/drivers/hwmon/w83781d.c | 11 +- trunk/drivers/hwmon/w83792d.c | 7 +- trunk/drivers/hwmon/w83l785ts.c | 42 +- trunk/drivers/i2c/algos/i2c-algo-pca.c | 2 +- trunk/drivers/i2c/algos/i2c-algo-sibyte.c | 2 +- trunk/drivers/i2c/busses/Kconfig | 3 +- trunk/drivers/i2c/busses/i2c-ali1535.c | 7 +- trunk/drivers/i2c/busses/i2c-ali1563.c | 7 +- trunk/drivers/i2c/busses/i2c-ali15x3.c | 10 +- trunk/drivers/i2c/busses/i2c-amd756-s4882.c | 4 +- trunk/drivers/i2c/busses/i2c-amd756.c | 8 +- trunk/drivers/i2c/busses/i2c-amd8111.c | 16 +- trunk/drivers/i2c/busses/i2c-elektor.c | 138 ++-- trunk/drivers/i2c/busses/i2c-hydra.c | 1 - trunk/drivers/i2c/busses/i2c-i801.c | 61 +- trunk/drivers/i2c/busses/i2c-i810.c | 2 - trunk/drivers/i2c/busses/i2c-ibm_iic.c | 3 +- trunk/drivers/i2c/busses/i2c-iop3xx.c | 9 +- trunk/drivers/i2c/busses/i2c-isa.c | 1 - trunk/drivers/i2c/busses/i2c-ixp2000.c | 8 +- trunk/drivers/i2c/busses/i2c-ixp4xx.c | 8 +- trunk/drivers/i2c/busses/i2c-keywest.c | 5 +- trunk/drivers/i2c/busses/i2c-mpc.c | 4 +- trunk/drivers/i2c/busses/i2c-mv64xxx.c | 6 +- trunk/drivers/i2c/busses/i2c-nforce2.c | 16 +- trunk/drivers/i2c/busses/i2c-parport.c | 11 +- trunk/drivers/i2c/busses/i2c-piix4.c | 13 +- trunk/drivers/i2c/busses/i2c-pmac-smu.c | 3 +- trunk/drivers/i2c/busses/i2c-prosavage.c | 10 +- trunk/drivers/i2c/busses/i2c-s3c2410.c | 2 - trunk/drivers/i2c/busses/i2c-savage4.c | 1 - trunk/drivers/i2c/busses/i2c-sis5595.c | 10 +- trunk/drivers/i2c/busses/i2c-sis630.c | 9 +- trunk/drivers/i2c/busses/i2c-sis96x.c | 8 +- trunk/drivers/i2c/busses/i2c-via.c | 7 +- trunk/drivers/i2c/busses/i2c-viapro.c | 271 ++++--- trunk/drivers/i2c/busses/i2c-voodoo3.c | 1 - trunk/drivers/i2c/busses/scx200_acb.c | 3 +- trunk/drivers/i2c/chips/Kconfig | 9 - trunk/drivers/i2c/chips/Makefile | 1 - trunk/drivers/i2c/chips/ds1337.c | 3 +- trunk/drivers/i2c/chips/ds1374.c | 7 +- trunk/drivers/i2c/chips/eeprom.c | 9 +- trunk/drivers/i2c/chips/isp1301_omap.c | 1 - trunk/drivers/i2c/chips/m41t00.c | 4 +- trunk/drivers/i2c/chips/max6875.c | 6 +- trunk/drivers/i2c/chips/pca9539.c | 3 +- trunk/drivers/i2c/chips/pcf8574.c | 5 +- trunk/drivers/i2c/chips/pcf8591.c | 5 +- trunk/drivers/i2c/chips/rtc8564.c | 5 +- trunk/drivers/i2c/chips/tps65010.c | 3 +- trunk/drivers/i2c/chips/x1205.c | 698 ----------------- trunk/drivers/i2c/i2c-core.c | 194 +++-- trunk/drivers/i2c/i2c-dev.c | 17 +- trunk/drivers/mmc/wbsd.c | 119 ++- trunk/drivers/pcmcia/yenta_socket.c | 42 +- trunk/drivers/scsi/ahci.c | 30 +- trunk/drivers/scsi/libata-core.c | 123 +-- trunk/drivers/scsi/libata-scsi.c | 800 ++++---------------- trunk/drivers/scsi/libata.h | 3 +- trunk/drivers/scsi/pdc_adma.c | 34 +- trunk/drivers/scsi/sata_mv.c | 17 +- trunk/drivers/scsi/sata_promise.c | 4 - trunk/drivers/scsi/sata_qstor.c | 8 +- trunk/drivers/scsi/sata_sil24.c | 15 +- trunk/drivers/scsi/sata_sx4.c | 13 +- trunk/fs/ext3/super.c | 26 +- trunk/include/linux/i2c-algo-bit.h | 4 + trunk/include/linux/i2c-algo-pca.h | 2 + trunk/include/linux/i2c-algo-pcf.h | 4 + trunk/include/linux/i2c-dev.h | 2 + trunk/include/linux/i2c-id.h | 3 + trunk/include/linux/i2c.h | 38 +- trunk/include/linux/libata.h | 39 +- trunk/include/linux/mod_devicetable.h | 5 - trunk/include/linux/x1205.h | 31 - trunk/include/media/ovcamchip.h | 14 + trunk/include/scsi/scsi.h | 3 - trunk/scripts/mod/file2alias.c | 10 - 125 files changed, 1390 insertions(+), 2790 deletions(-) delete mode 100644 trunk/Documentation/i2c/chips/x1205 delete mode 100644 trunk/drivers/i2c/chips/x1205.c delete mode 100644 trunk/include/linux/x1205.h diff --git a/[refs] b/[refs] index 8e2030253299..ff66a39f6249 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5615ca7906aefbdc3318604c89db5931d0a25910 +refs/heads/master: 19c1f3ca4272008a256cc153f3e3feb097799070 diff --git a/trunk/Documentation/hwmon/it87 b/trunk/Documentation/hwmon/it87 index 7f42e441c645..0d0195040d88 100644 --- a/trunk/Documentation/hwmon/it87 +++ b/trunk/Documentation/hwmon/it87 @@ -4,18 +4,18 @@ Kernel driver it87 Supported chips: * IT8705F Prefix: 'it87' - Addresses scanned: from Super I/O config space (8 I/O ports) + Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) Datasheet: Publicly available at the ITE website http://www.ite.com.tw/ * IT8712F Prefix: 'it8712' Addresses scanned: I2C 0x28 - 0x2f - from Super I/O config space (8 I/O ports) + from Super I/O config space, or default ISA 0x290 (8 I/O ports) Datasheet: Publicly available at the ITE website http://www.ite.com.tw/ * SiS950 [clone of IT8705F] - Prefix: 'it87' - Addresses scanned: from Super I/O config space (8 I/O ports) + Prefix: 'sis950' + Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) Datasheet: No longer be available Author: Christophe Gauthron diff --git a/trunk/Documentation/hwmon/lm90 b/trunk/Documentation/hwmon/lm90 index 438cb24cee5b..2c4cf39471f4 100644 --- a/trunk/Documentation/hwmon/lm90 +++ b/trunk/Documentation/hwmon/lm90 @@ -24,14 +24,14 @@ Supported chips: http://www.national.com/pf/LM/LM86.html * Analog Devices ADM1032 Prefix: 'adm1032' - Addresses scanned: I2C 0x4c and 0x4d + Addresses scanned: I2C 0x4c Datasheet: Publicly available at the Analog Devices website - http://www.analog.com/en/prod/0,2877,ADM1032,00.html + http://products.analog.com/products/info.asp?product=ADM1032 * Analog Devices ADT7461 Prefix: 'adt7461' - Addresses scanned: I2C 0x4c and 0x4d + Addresses scanned: I2C 0x4c Datasheet: Publicly available at the Analog Devices website - http://www.analog.com/en/prod/0,2877,ADT7461,00.html + http://products.analog.com/products/info.asp?product=ADT7461 Note: Only if in ADM1032 compatibility mode * Maxim MAX6657 Prefix: 'max6657' @@ -71,8 +71,8 @@ increased resolution of the remote temperature measurement. The different chipsets of the family are not strictly identical, although very similar. This driver doesn't handle any specific feature for now, -with the exception of SMBus PEC. For reference, here comes a non-exhaustive -list of specific features: +but could if there ever was a need for it. For reference, here comes a +non-exhaustive list of specific features: LM90: * Filter and alert configuration register at 0xBF. @@ -91,7 +91,6 @@ ADM1032: * Conversion averaging. * Up to 64 conversions/s. * ALERT is triggered by open remote sensor. - * SMBus PEC support for Write Byte and Receive Byte transactions. ADT7461 * Extended temperature range (breaks compatibility) @@ -120,37 +119,3 @@ The lm90 driver will not update its values more frequently than every other second; reading them more often will do no harm, but will return 'old' values. -PEC Support ------------ - -The ADM1032 is the only chip of the family which supports PEC. It does -not support PEC on all transactions though, so some care must be taken. - -When reading a register value, the PEC byte is computed and sent by the -ADM1032 chip. However, in the case of a combined transaction (SMBus Read -Byte), the ADM1032 computes the CRC value over only the second half of -the message rather than its entirety, because it thinks the first half -of the message belongs to a different transaction. As a result, the CRC -value differs from what the SMBus master expects, and all reads fail. - -For this reason, the lm90 driver will enable PEC for the ADM1032 only if -the bus supports the SMBus Send Byte and Receive Byte transaction types. -These transactions will be used to read register values, instead of -SMBus Read Byte, and PEC will work properly. - -Additionally, the ADM1032 doesn't support SMBus Send Byte with PEC. -Instead, it will try to write the PEC value to the register (because the -SMBus Send Byte transaction with PEC is similar to a Write Byte transaction -without PEC), which is not what we want. Thus, PEC is explicitely disabled -on SMBus Send Byte transactions in the lm90 driver. - -PEC on byte data transactions represents a significant increase in bandwidth -usage (+33% for writes, +25% for reads) in normal conditions. With the need -to use two SMBus transaction for reads, this overhead jumps to +50%. Worse, -two transactions will typically mean twice as much delay waiting for -transaction completion, effectively doubling the register cache refresh time. -I guess reliability comes at a price, but it's quite expensive this time. - -So, as not everyone might enjoy the slowdown, PEC can be disabled through -sysfs. Just write 0 to the "pec" file and PEC will be disabled. Write 1 -to that file to enable PEC again. diff --git a/trunk/Documentation/hwmon/smsc47b397 b/trunk/Documentation/hwmon/smsc47b397 index 20682f15ae41..da9d80c96432 100644 --- a/trunk/Documentation/hwmon/smsc47b397 +++ b/trunk/Documentation/hwmon/smsc47b397 @@ -3,7 +3,6 @@ Kernel driver smsc47b397 Supported chips: * SMSC LPC47B397-NC - * SMSC SCH5307-NS Prefix: 'smsc47b397' Addresses scanned: none, address read from Super I/O config space Datasheet: In this file @@ -13,14 +12,11 @@ Authors: Mark M. Hoffman November 23, 2004 -The following specification describes the SMSC LPC47B397-NC[1] sensor chip +The following specification describes the SMSC LPC47B397-NC sensor chip (for which there is no public datasheet available). This document was provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected by Mark M. Hoffman . -[1] And SMSC SCH5307-NS, which has a different device ID but is otherwise -compatible. - * * * * * Methods for detecting the HP SIO and reading the thermal data on a dc7100. @@ -131,7 +127,7 @@ OUT DX,AL The registers of interest for identifying the SIO on the dc7100 are Device ID (0x20) and Device Rev (0x21). -The Device ID will read 0x6F (for SCH5307-NS, 0x81) +The Device ID will read 0X6F The Device Rev currently reads 0x01 Obtaining the HWM Base Address. diff --git a/trunk/Documentation/hwmon/smsc47m1 b/trunk/Documentation/hwmon/smsc47m1 index c15bbe68264e..34e6478c1425 100644 --- a/trunk/Documentation/hwmon/smsc47m1 +++ b/trunk/Documentation/hwmon/smsc47m1 @@ -12,10 +12,6 @@ Supported chips: http://www.smsc.com/main/datasheets/47m14x.pdf http://www.smsc.com/main/tools/discontinued/47m15x.pdf http://www.smsc.com/main/datasheets/47m192.pdf - * SMSC LPC47M997 - Addresses scanned: none, address read from Super I/O config space - Prefix: 'smsc47m1' - Datasheet: none Authors: Mark D. Studebaker , @@ -34,9 +30,6 @@ The 47M15x and 47M192 chips contain a full 'hardware monitoring block' in addition to the fan monitoring and control. The hardware monitoring block is not supported by the driver. -No documentation is available for the 47M997, but it has the same device -ID as the 47M15x and 47M192 chips and seems to be compatible. - Fan rotation speeds are reported in RPM (rotations per minute). An alarm is triggered if the rotation speed has dropped below a programmable limit. Fan readings can be divided by a programmable divider (1, 2, 4 or 8) to give diff --git a/trunk/Documentation/hwmon/sysfs-interface b/trunk/Documentation/hwmon/sysfs-interface index 764cdc5480e7..346400519d0d 100644 --- a/trunk/Documentation/hwmon/sysfs-interface +++ b/trunk/Documentation/hwmon/sysfs-interface @@ -272,6 +272,3 @@ beep_mask Bitmask for beep. eeprom Raw EEPROM data in binary form. Read only. - -pec Enable or disable PEC (SMBus only) - Read/Write diff --git a/trunk/Documentation/hwmon/via686a b/trunk/Documentation/hwmon/via686a index a936fb3824b2..b82014cb7c53 100644 --- a/trunk/Documentation/hwmon/via686a +++ b/trunk/Documentation/hwmon/via686a @@ -18,9 +18,8 @@ Authors: Module Parameters ----------------- -force_addr=0xaddr Set the I/O base address. Useful for boards that - don't set the address in the BIOS. Look for a BIOS - upgrade before resorting to this. Does not do a +force_addr=0xaddr Set the I/O base address. Useful for Asus A7V boards + that don't set the address in the BIOS. Does not do a PCI force; the via686a must still be present in lspci. Don't use this unless the driver complains that the base address is not set. @@ -64,15 +63,3 @@ miss once-only alarms. The driver only updates its values each 1.5 seconds; reading it more often will do no harm, but will return 'old' values. - -Known Issues ------------- - -This driver handles sensors integrated in some VIA south bridges. It is -possible that a motherboard maker used a VT82C686A/B chip as part of a -product design but was not interested in its hardware monitoring features, -in which case the sensor inputs will not be wired. This is the case of -the Asus K7V, A7V and A7V133 motherboards, to name only a few of them. -So, if you need the force_addr parameter, and end up with values which -don't seem to make any sense, don't look any further: your chip is simply -not wired for hardware monitoring. diff --git a/trunk/Documentation/i2c/busses/i2c-i810 b/trunk/Documentation/i2c/busses/i2c-i810 index 83c3b9743c3c..0544eb332887 100644 --- a/trunk/Documentation/i2c/busses/i2c-i810 +++ b/trunk/Documentation/i2c/busses/i2c-i810 @@ -2,7 +2,6 @@ Kernel driver i2c-i810 Supported adapters: * Intel 82810, 82810-DC100, 82810E, and 82815 (GMCH) - * Intel 82845G (GMCH) Authors: Frodo Looijaard , diff --git a/trunk/Documentation/i2c/busses/i2c-viapro b/trunk/Documentation/i2c/busses/i2c-viapro index 9363b8bd6109..702f5ac68c09 100644 --- a/trunk/Documentation/i2c/busses/i2c-viapro +++ b/trunk/Documentation/i2c/busses/i2c-viapro @@ -4,18 +4,17 @@ Supported adapters: * VIA Technologies, Inc. VT82C596A/B Datasheet: Sometimes available at the VIA website - * VIA Technologies, Inc. VT82C686A/B + * VIA Technologies, Inc. VT82C686A/B Datasheet: Sometimes available at the VIA website * VIA Technologies, Inc. VT8231, VT8233, VT8233A, VT8235, VT8237 Datasheet: available on request from Via Authors: - Frodo Looijaard , - Philip Edelbrock , - Kyösti Mälkki , - Mark D. Studebaker , - Jean Delvare + Frodo Looijaard , + Philip Edelbrock , + Kyösti Mälkki , + Mark D. Studebaker Module Parameters ----------------- @@ -29,22 +28,20 @@ Description ----------- i2c-viapro is a true SMBus host driver for motherboards with one of the -supported VIA south bridges. +supported VIA southbridges. Your lspci -n listing must show one of these : - device 1106:3050 (VT82C596A function 3) - device 1106:3051 (VT82C596B function 3) + device 1106:3050 (VT82C596 function 3) + device 1106:3051 (VT82C596 function 3) device 1106:3057 (VT82C686 function 4) device 1106:3074 (VT8233) device 1106:3147 (VT8233A) - device 1106:8235 (VT8231 function 4) - device 1106:3177 (VT8235) - device 1106:3227 (VT8237R) + device 1106:8235 (VT8231) + devide 1106:3177 (VT8235) + devide 1106:3227 (VT8237) If none of these show up, you should look in the BIOS for settings like enable ACPI / SMBus or even USB. -Except for the oldest chips (VT82C596A/B, VT82C686A and most probably -VT8231), this driver supports I2C block transactions. Such transactions -are mainly useful to read from and write to EEPROMs. + diff --git a/trunk/Documentation/i2c/chips/x1205 b/trunk/Documentation/i2c/chips/x1205 deleted file mode 100644 index 09407c991fe5..000000000000 --- a/trunk/Documentation/i2c/chips/x1205 +++ /dev/null @@ -1,38 +0,0 @@ -Kernel driver x1205 -=================== - -Supported chips: - * Xicor X1205 RTC - Prefix: 'x1205' - Addresses scanned: none - Datasheet: http://www.intersil.com/cda/deviceinfo/0,1477,X1205,00.html - -Authors: - Karen Spearel , - Alessandro Zummo - -Description ------------ - -This module aims to provide complete access to the Xicor X1205 RTC. -Recently Xicor has merged with Intersil, but the chip is -still sold under the Xicor brand. - -This chip is located at address 0x6f and uses a 2-byte register addressing. -Two bytes need to be written to read a single register, while most -other chips just require one and take the second one as the data -to be written. To prevent corrupting unknown chips, the user must -explicitely set the probe parameter. - -example: - -modprobe x1205 probe=0,0x6f - -The module supports one more option, hctosys, which is used to set the -software clock from the x1205. On systems where the x1205 is the -only hardware rtc, this parameter could be used to achieve a correct -date/time earlier in the system boot sequence. - -example: - -modprobe x1205 probe=0,0x6f hctosys=1 diff --git a/trunk/Documentation/i2c/functionality b/trunk/Documentation/i2c/functionality index 60cca249e452..41ffefbdc60c 100644 --- a/trunk/Documentation/i2c/functionality +++ b/trunk/Documentation/i2c/functionality @@ -17,10 +17,9 @@ For the most up-to-date list of functionality constants, please check I2C_FUNC_I2C Plain i2c-level commands (Pure SMBus adapters typically can not do these) I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions - I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_IGNORE_NAK, - I2C_M_REV_DIR_ADDR, I2C_M_NOSTART and - I2C_M_NO_RD_ACK flags (which modify the - I2C protocol!) + I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_REV_DIR_ADDR, + I2C_M_REV_DIR_ADDR and I2C_M_REV_DIR_NOSTART + flags (which modify the i2c protocol!) I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command diff --git a/trunk/Documentation/i2c/porting-clients b/trunk/Documentation/i2c/porting-clients index 184fac2377aa..4849dfd6961c 100644 --- a/trunk/Documentation/i2c/porting-clients +++ b/trunk/Documentation/i2c/porting-clients @@ -82,7 +82,7 @@ Technical changes: exit and exit_free. For i2c+isa drivers, labels should be named ERROR0, ERROR1 and ERROR2. Don't forget to properly set err before jumping to error labels. By the way, labels should be left-aligned. - Use kzalloc instead of kmalloc. + Use memset to fill the client and data area with 0x00. Use i2c_set_clientdata to set the client data (as opposed to a direct access to client->data). Use strlcpy instead of strcpy to copy the client name. diff --git a/trunk/Documentation/i2c/writing-clients b/trunk/Documentation/i2c/writing-clients index e94d9c6cc522..077275722a7c 100644 --- a/trunk/Documentation/i2c/writing-clients +++ b/trunk/Documentation/i2c/writing-clients @@ -33,8 +33,8 @@ static struct i2c_driver foo_driver = { .command = &foo_command /* may be NULL */ } -The name field must match the driver name, including the case. It must not -contain spaces, and may be up to 31 characters long. +The name can be chosen freely, and may be upto 40 characters long. Please +use something descriptive here. Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This means that your driver will be notified when new adapters are found. @@ -43,6 +43,9 @@ This is almost always what you want. All other fields are for call-back functions which will be explained below. +There use to be two additional fields in this structure, inc_use et dec_use, +for module usage count, but these fields were obsoleted and removed. + Extra client data ================= @@ -55,7 +58,6 @@ be very useful. An example structure is below. struct foo_data { - struct i2c_client client; struct semaphore lock; /* For ISA access in `sensors' drivers. */ int sysctl_id; /* To keep the /proc directory entry for `sensors' drivers. */ @@ -308,15 +310,22 @@ For now, you can ignore the `flags' parameter. It is there for future use. client structure, even though we cannot fill it completely yet. But it allows us to access several i2c functions safely */ - if (!(data = kzalloc(sizeof(struct foo_data), GFP_KERNEL))) { + /* Note that we reserve some space for foo_data too. If you don't + need it, remove it. We do it here to help to lessen memory + fragmentation. */ + if (! (new_client = kmalloc(sizeof(struct i2c_client) + + sizeof(struct foo_data), + GFP_KERNEL))) { err = -ENOMEM; goto ERROR0; } - new_client = &data->client; - i2c_set_clientdata(new_client, data); + /* This is tricky, but it will set the data to the right value. */ + client->data = new_client + 1; + data = (struct foo_data *) (client->data); new_client->addr = address; + new_client->data = data; new_client->adapter = adapter; new_client->driver = &foo_driver; new_client->flags = 0; @@ -442,7 +451,7 @@ much simpler than the attachment code, fortunately! release_region(client->addr,LM78_EXTENT); /* HYBRID SENSORS CHIP ONLY END */ - kfree(data); + kfree(client); /* Frees client data too, if allocated at the same time */ return 0; } @@ -567,12 +576,12 @@ SMBus communication extern s32 i2c_smbus_write_block_data(struct i2c_client * client, u8 command, u8 length, u8 *values); - extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, - u8 command, u8 *values); These ones were removed in Linux 2.6.10 because they had no users, but could be added back later if needed: + extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, + u8 command, u8 *values); extern s32 i2c_smbus_read_block_data(struct i2c_client * client, u8 command, u8 *values); extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index 3928dc7d6ea9..248b93b32fc4 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -2736,12 +2736,6 @@ P: Roger Luethi M: rl@hellgate.ch S: Maintained -VIAPRO SMBUS DRIVER -P: Jean Delvare -M: khali@linux-fr.org -L: lm-sensors@lm-sensors.org -S: Maintained - UCLINUX (AND M68KNOMMU) P: Greg Ungerer M: gerg@uclinux.org diff --git a/trunk/Makefile b/trunk/Makefile index 79601320ac3e..f1d121f23025 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -371,8 +371,8 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve # Files to ignore in find ... statements -RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o -export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git +RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg \) -prune -o +export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg # =========================================================================== # Rules shared between *config targets and build targets diff --git a/trunk/drivers/hwmon/adm1021.c b/trunk/drivers/hwmon/adm1021.c index 8102876c7c3f..e928cdb041cb 100644 --- a/trunk/drivers/hwmon/adm1021.c +++ b/trunk/drivers/hwmon/adm1021.c @@ -121,7 +121,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, static struct adm1021_data *adm1021_update_device(struct device *dev); /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ -static int read_only; +static int read_only = 0; /* This is the driver that will be inserted */ @@ -204,10 +204,11 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access adm1021_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { err = -ENOMEM; goto error0; } + memset(data, 0, sizeof(struct adm1021_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/adm1025.c b/trunk/drivers/hwmon/adm1025.c index 3ec12421694f..526b7ff179eb 100644 --- a/trunk/drivers/hwmon/adm1025.c +++ b/trunk/drivers/hwmon/adm1025.c @@ -331,10 +331,11 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct adm1025_data)); /* The common I2C client data is placed right before the ADM1025-specific data. */ diff --git a/trunk/drivers/hwmon/adm1026.c b/trunk/drivers/hwmon/adm1026.c index e0f56549d1d8..625158110fd4 100644 --- a/trunk/drivers/hwmon/adm1026.c +++ b/trunk/drivers/hwmon/adm1026.c @@ -315,7 +315,7 @@ static struct i2c_driver adm1026_driver = { .detach_client = adm1026_detach_client, }; -static int adm1026_attach_adapter(struct i2c_adapter *adapter) +int adm1026_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) { return 0; @@ -323,7 +323,7 @@ static int adm1026_attach_adapter(struct i2c_adapter *adapter) return i2c_probe(adapter, &addr_data, adm1026_detect); } -static int adm1026_detach_client(struct i2c_client *client) +int adm1026_detach_client(struct i2c_client *client) { struct adm1026_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->class_dev); @@ -332,7 +332,7 @@ static int adm1026_detach_client(struct i2c_client *client) return 0; } -static int adm1026_read_value(struct i2c_client *client, u8 reg) +int adm1026_read_value(struct i2c_client *client, u8 reg) { int res; @@ -346,7 +346,7 @@ static int adm1026_read_value(struct i2c_client *client, u8 reg) return res; } -static int adm1026_write_value(struct i2c_client *client, u8 reg, int value) +int adm1026_write_value(struct i2c_client *client, u8 reg, int value) { int res; @@ -360,7 +360,7 @@ static int adm1026_write_value(struct i2c_client *client, u8 reg, int value) return res; } -static void adm1026_init_client(struct i2c_client *client) +void adm1026_init_client(struct i2c_client *client) { int value, i; struct adm1026_data *data = i2c_get_clientdata(client); @@ -460,7 +460,7 @@ static void adm1026_init_client(struct i2c_client *client) } } -static void adm1026_print_gpio(struct i2c_client *client) +void adm1026_print_gpio(struct i2c_client *client) { struct adm1026_data *data = i2c_get_clientdata(client); int i; @@ -492,7 +492,7 @@ static void adm1026_print_gpio(struct i2c_client *client) } } -static void adm1026_fixup_gpio(struct i2c_client *client) +void adm1026_fixup_gpio(struct i2c_client *client) { struct adm1026_data *data = i2c_get_clientdata(client); int i; @@ -1452,8 +1452,8 @@ static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); -static int adm1026_detect(struct i2c_adapter *adapter, int address, - int kind) +int adm1026_detect(struct i2c_adapter *adapter, int address, + int kind) { int company, verstep; struct i2c_client *new_client; @@ -1470,11 +1470,13 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, client structure, even though we cannot fill it completely yet. But it allows us to access adm1026_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct adm1026_data)); + new_client = &data->client; i2c_set_clientdata(new_client, data); new_client->addr = address; diff --git a/trunk/drivers/hwmon/adm1031.c b/trunk/drivers/hwmon/adm1031.c index 7c545d5eee45..58338ed7c8a1 100644 --- a/trunk/drivers/hwmon/adm1031.c +++ b/trunk/drivers/hwmon/adm1031.c @@ -740,10 +740,11 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct adm1031_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/adm9240.c b/trunk/drivers/hwmon/adm9240.c index 11dc95f8a17e..bc7faef162f7 100644 --- a/trunk/drivers/hwmon/adm9240.c +++ b/trunk/drivers/hwmon/adm9240.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -70,7 +69,8 @@ I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); #define ADM9240_REG_INT(nr) (0x41 + (nr)) #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) #define ADM9240_REG_TEMP 0x27 -#define ADM9240_REG_TEMP_MAX(nr) (0x39 + (nr)) /* 0, 1 = high, hyst */ +#define ADM9240_REG_TEMP_HIGH 0x39 +#define ADM9240_REG_TEMP_HYST 0x3a #define ADM9240_REG_ANALOG_OUT 0x19 #define ADM9240_REG_CHASSIS_CLEAR 0x46 #define ADM9240_REG_VID_FAN_DIV 0x47 @@ -162,155 +162,177 @@ struct adm9240_data { u8 fan_min[2]; /* rw fan1_min */ u8 fan_div[2]; /* rw fan1_div, read-only accessor */ s16 temp; /* ro temp1_input, 9-bit sign-extended */ - s8 temp_max[2]; /* rw 0 -> temp_max, 1 -> temp_max_hyst */ + s8 temp_high; /* rw temp1_max */ + s8 temp_hyst; /* rw temp1_max_hyst */ u16 alarms; /* ro alarms */ u8 aout; /* rw aout_output */ u8 vid; /* ro vid */ u8 vrm; /* -- vrm set on startup, no accessor */ }; -/*** sysfs accessors ***/ - -/* temperature */ -static ssize_t show_temp(struct device *dev, struct device_attribute *dummy, - char *buf) +/* i2c byte read/write interface */ +static int adm9240_read_value(struct i2c_client *client, u8 reg) { - struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */ + return i2c_smbus_read_byte_data(client, reg); } -static ssize_t show_max(struct device *dev, struct device_attribute *devattr, - char *buf) +static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", data->temp_max[attr->index] * 1000); + return i2c_smbus_write_byte_data(client, reg, value); } -static ssize_t set_max(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_client *client = to_i2c_client(dev); - struct adm9240_data *data = i2c_get_clientdata(client); - long val = simple_strtol(buf, NULL, 10); - - down(&data->update_lock); - data->temp_max[attr->index] = TEMP_TO_REG(val); - i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), - data->temp_max[attr->index]); - up(&data->update_lock); - return count; -} +/*** sysfs accessors ***/ +/* temperature */ +#define show_temp(value, scale) \ +static ssize_t show_##value(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct adm9240_data *data = adm9240_update_device(dev); \ + return sprintf(buf, "%d\n", data->value * scale); \ +} +show_temp(temp_high, 1000); +show_temp(temp_hyst, 1000); +show_temp(temp, 500); /* 0.5'C per bit */ + +#define set_temp(value, reg) \ +static ssize_t set_##value(struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ + struct i2c_client *client = to_i2c_client(dev); \ + struct adm9240_data *data = adm9240_update_device(dev); \ + long temp = simple_strtoul(buf, NULL, 10); \ + \ + down(&data->update_lock); \ + data->value = TEMP_TO_REG(temp); \ + adm9240_write_value(client, reg, data->value); \ + up(&data->update_lock); \ + return count; \ +} + +set_temp(temp_high, ADM9240_REG_TEMP_HIGH); +set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); + +static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, + show_temp_high, set_temp_high); +static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, + show_temp_hyst, set_temp_hyst); static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, - show_max, set_max, 0); -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, - show_max, set_max, 1); /* voltage */ -static ssize_t show_in(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t show_in(struct device *dev, char *buf, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", IN_FROM_REG(data->in[attr->index], - attr->index)); + return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); } -static ssize_t show_in_min(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t show_in_min(struct device *dev, char *buf, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[attr->index], - attr->index)); + return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); } -static ssize_t show_in_max(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t show_in_max(struct device *dev, char *buf, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[attr->index], - attr->index)); + return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); } -static ssize_t set_in_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t set_in_min(struct device *dev, const char *buf, + size_t count, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct i2c_client *client = to_i2c_client(dev); struct adm9240_data *data = i2c_get_clientdata(client); unsigned long val = simple_strtoul(buf, NULL, 10); down(&data->update_lock); - data->in_min[attr->index] = IN_TO_REG(val, attr->index); - i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), - data->in_min[attr->index]); + data->in_min[nr] = IN_TO_REG(val, nr); + adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); up(&data->update_lock); return count; } -static ssize_t set_in_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t set_in_max(struct device *dev, const char *buf, + size_t count, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct i2c_client *client = to_i2c_client(dev); struct adm9240_data *data = i2c_get_clientdata(client); unsigned long val = simple_strtoul(buf, NULL, 10); down(&data->update_lock); - data->in_max[attr->index] = IN_TO_REG(val, attr->index); - i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), - data->in_max[attr->index]); + data->in_max[nr] = IN_TO_REG(val, nr); + adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); up(&data->update_lock); return count; } -#define vin(nr) \ -static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \ - show_in, NULL, nr); \ -static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, nr); \ -static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, nr); - -vin(0); -vin(1); -vin(2); -vin(3); -vin(4); -vin(5); +#define show_in_offset(offset) \ +static ssize_t show_in##offset(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + return show_in(dev, buf, offset); \ +} \ +static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ +static ssize_t show_in##offset##_min(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + return show_in_min(dev, buf, offset); \ +} \ +static ssize_t show_in##offset##_max(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + return show_in_max(dev, buf, offset); \ +} \ +static ssize_t \ +set_in##offset##_min(struct device *dev, \ + struct device_attribute *attr, const char *buf, \ + size_t count) \ +{ \ + return set_in_min(dev, buf, count, offset); \ +} \ +static ssize_t \ +set_in##offset##_max(struct device *dev, \ + struct device_attribute *attr, const char *buf, \ + size_t count) \ +{ \ + return set_in_max(dev, buf, count, offset); \ +} \ +static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ + show_in##offset##_min, set_in##offset##_min); \ +static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ + show_in##offset##_max, set_in##offset##_max); + +show_in_offset(0); +show_in_offset(1); +show_in_offset(2); +show_in_offset(3); +show_in_offset(4); +show_in_offset(5); /* fans */ -static ssize_t show_fan(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t show_fan(struct device *dev, char *buf, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], - 1 << data->fan_div[attr->index])); + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], + 1 << data->fan_div[nr])); } -static ssize_t show_fan_min(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[attr->index], - 1 << data->fan_div[attr->index])); + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], + 1 << data->fan_div[nr])); } -static ssize_t show_fan_div(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm9240_data *data = adm9240_update_device(dev); - return sprintf(buf, "%d\n", 1 << data->fan_div[attr->index]); + return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); } /* write new fan div, callers must hold data->update_lock */ @@ -319,16 +341,16 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, { u8 reg, old, shift = (nr + 2) * 2; - reg = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); + reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); old = (reg >> shift) & 3; reg &= ~(3 << shift); reg |= (fan_div << shift); - i2c_smbus_write_byte_data(client, ADM9240_REG_VID_FAN_DIV, reg); + adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); dev_dbg(&client->dev, "fan%d clock divider changed from %u " "to %u\n", nr + 1, 1 << old, 1 << fan_div); } -/* +/* * set fan speed low limit: * * - value is zero: disable fan speed low limit alarm @@ -339,15 +361,12 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, * - otherwise: select fan clock divider to suit fan speed low limit, * measurement code may adjust registers to ensure fan speed reading */ -static ssize_t set_fan_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t set_fan_min(struct device *dev, const char *buf, + size_t count, int nr) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct i2c_client *client = to_i2c_client(dev); struct adm9240_data *data = i2c_get_clientdata(client); unsigned long val = simple_strtoul(buf, NULL, 10); - int nr = attr->index; u8 new_div; down(&data->update_lock); @@ -387,27 +406,50 @@ static ssize_t set_fan_min(struct device *dev, data->fan_div[nr] = new_div; adm9240_write_fan_div(client, nr, new_div); } - i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), + adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), data->fan_min[nr]); up(&data->update_lock); return count; } -#define fan(nr) \ -static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \ - show_fan, NULL, nr - 1); \ -static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \ - show_fan_div, NULL, nr - 1); \ -static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, nr - 1); - -fan(1); -fan(2); +#define show_fan_offset(offset) \ +static ssize_t show_fan_##offset (struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ +return show_fan(dev, buf, offset - 1); \ +} \ +static ssize_t show_fan_##offset##_div (struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ +return show_fan_div(dev, buf, offset - 1); \ +} \ +static ssize_t show_fan_##offset##_min (struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ +return show_fan_min(dev, buf, offset - 1); \ +} \ +static ssize_t set_fan_##offset##_min (struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ +return set_fan_min(dev, buf, count, offset - 1); \ +} \ +static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ + show_fan_##offset, NULL); \ +static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ + show_fan_##offset##_div, NULL); \ +static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ + show_fan_##offset##_min, set_fan_##offset##_min); + +show_fan_offset(1); +show_fan_offset(2); /* alarms */ -static ssize_t show_alarms(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { struct adm9240_data *data = adm9240_update_device(dev); return sprintf(buf, "%u\n", data->alarms); @@ -415,8 +457,7 @@ static ssize_t show_alarms(struct device *dev, static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); /* vid */ -static ssize_t show_vid(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) { struct adm9240_data *data = adm9240_update_device(dev); return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); @@ -424,16 +465,13 @@ static ssize_t show_vid(struct device *dev, static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); /* analog output */ -static ssize_t show_aout(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) { struct adm9240_data *data = adm9240_update_device(dev); return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); } -static ssize_t set_aout(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); struct adm9240_data *data = i2c_get_clientdata(client); @@ -441,23 +479,20 @@ static ssize_t set_aout(struct device *dev, down(&data->update_lock); data->aout = AOUT_TO_REG(val); - i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); + adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); up(&data->update_lock); return count; } static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); /* chassis_clear */ -static ssize_t chassis_clear(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); unsigned long val = simple_strtol(buf, NULL, 10); if (val == 1) { - i2c_smbus_write_byte_data(client, - ADM9240_REG_CHASSIS_CLEAR, 0x80); + adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); } return count; @@ -478,10 +513,11 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct adm9240_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -497,7 +533,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) if (kind < 0) { /* verify chip: reg address should match i2c address */ - if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) + if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) != address) { dev_err(&adapter->dev, "detect fail: address match, " "0x%02x\n", address); @@ -505,8 +541,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) } /* check known chip manufacturer */ - man_id = i2c_smbus_read_byte_data(new_client, - ADM9240_REG_MAN_ID); + man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); + if (man_id == 0x23) { kind = adm9240; } else if (man_id == 0xda) { @@ -520,8 +556,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) } /* successful detect, print chip info */ - die_rev = i2c_smbus_read_byte_data(new_client, - ADM9240_REG_DIE_REV); + die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); dev_info(&adapter->dev, "found %s revision %u\n", man_id == 0x23 ? "ADM9240" : man_id == 0xda ? "DS1780" : "LM81", die_rev); @@ -553,59 +588,33 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) goto exit_detach; } - device_create_file(&new_client->dev, - &sensor_dev_attr_in0_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in0_min.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in0_max.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in1_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in1_min.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in1_max.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in2_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in2_min.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in2_max.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in3_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in3_min.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in3_max.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in4_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in4_min.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in4_max.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in5_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in5_min.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_in5_max.dev_attr); + device_create_file(&new_client->dev, &dev_attr_in0_input); + device_create_file(&new_client->dev, &dev_attr_in0_min); + device_create_file(&new_client->dev, &dev_attr_in0_max); + device_create_file(&new_client->dev, &dev_attr_in1_input); + device_create_file(&new_client->dev, &dev_attr_in1_min); + device_create_file(&new_client->dev, &dev_attr_in1_max); + device_create_file(&new_client->dev, &dev_attr_in2_input); + device_create_file(&new_client->dev, &dev_attr_in2_min); + device_create_file(&new_client->dev, &dev_attr_in2_max); + device_create_file(&new_client->dev, &dev_attr_in3_input); + device_create_file(&new_client->dev, &dev_attr_in3_min); + device_create_file(&new_client->dev, &dev_attr_in3_max); + device_create_file(&new_client->dev, &dev_attr_in4_input); + device_create_file(&new_client->dev, &dev_attr_in4_min); + device_create_file(&new_client->dev, &dev_attr_in4_max); + device_create_file(&new_client->dev, &dev_attr_in5_input); + device_create_file(&new_client->dev, &dev_attr_in5_min); + device_create_file(&new_client->dev, &dev_attr_in5_max); + device_create_file(&new_client->dev, &dev_attr_temp1_max); + device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); device_create_file(&new_client->dev, &dev_attr_temp1_input); - device_create_file(&new_client->dev, - &sensor_dev_attr_temp1_max.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_temp1_max_hyst.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_fan1_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_fan1_div.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_fan1_min.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_fan2_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_fan2_div.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_fan2_min.dev_attr); + device_create_file(&new_client->dev, &dev_attr_fan1_input); + device_create_file(&new_client->dev, &dev_attr_fan1_div); + device_create_file(&new_client->dev, &dev_attr_fan1_min); + device_create_file(&new_client->dev, &dev_attr_fan2_input); + device_create_file(&new_client->dev, &dev_attr_fan2_div); + device_create_file(&new_client->dev, &dev_attr_fan2_min); device_create_file(&new_client->dev, &dev_attr_alarms); device_create_file(&new_client->dev, &dev_attr_aout_output); device_create_file(&new_client->dev, &dev_attr_chassis_clear); @@ -645,8 +654,8 @@ static int adm9240_detach_client(struct i2c_client *client) static void adm9240_init_client(struct i2c_client *client) { struct adm9240_data *data = i2c_get_clientdata(client); - u8 conf = i2c_smbus_read_byte_data(client, ADM9240_REG_CONFIG); - u8 mode = i2c_smbus_read_byte_data(client, ADM9240_REG_TEMP_CONF) & 3; + u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); + u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; data->vrm = vid_which_vrm(); /* need this to report vid as mV */ @@ -663,22 +672,18 @@ static void adm9240_init_client(struct i2c_client *client) for (i = 0; i < 6; i++) { - i2c_smbus_write_byte_data(client, + adm9240_write_value(client, ADM9240_REG_IN_MIN(i), 0); - i2c_smbus_write_byte_data(client, + adm9240_write_value(client, ADM9240_REG_IN_MAX(i), 255); } - i2c_smbus_write_byte_data(client, - ADM9240_REG_FAN_MIN(0), 255); - i2c_smbus_write_byte_data(client, - ADM9240_REG_FAN_MIN(1), 255); - i2c_smbus_write_byte_data(client, - ADM9240_REG_TEMP_MAX(0), 127); - i2c_smbus_write_byte_data(client, - ADM9240_REG_TEMP_MAX(1), 127); + adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); + adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); + adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); + adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); /* start measurement cycle */ - i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1); + adm9240_write_value(client, ADM9240_REG_CONFIG, 1); dev_info(&client->dev, "cold start: config was 0x%02x " "mode %u\n", conf, mode); @@ -699,25 +704,25 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) for (i = 0; i < 6; i++) /* read voltages */ { - data->in[i] = i2c_smbus_read_byte_data(client, + data->in[i] = adm9240_read_value(client, ADM9240_REG_IN(i)); } - data->alarms = i2c_smbus_read_byte_data(client, + data->alarms = adm9240_read_value(client, ADM9240_REG_INT(0)) | - i2c_smbus_read_byte_data(client, + adm9240_read_value(client, ADM9240_REG_INT(1)) << 8; /* read temperature: assume temperature changes less than * 0.5'C per two measurement cycles thus ignore possible * but unlikely aliasing error on lsb reading. --Grant */ - data->temp = ((i2c_smbus_read_byte_data(client, + data->temp = ((adm9240_read_value(client, ADM9240_REG_TEMP) << 8) | - i2c_smbus_read_byte_data(client, + adm9240_read_value(client, ADM9240_REG_TEMP_CONF)) / 128; for (i = 0; i < 2; i++) /* read fans */ { - data->fan[i] = i2c_smbus_read_byte_data(client, + data->fan[i] = adm9240_read_value(client, ADM9240_REG_FAN(i)); /* adjust fan clock divider on overflow */ @@ -742,30 +747,30 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) for (i = 0; i < 6; i++) { - data->in_min[i] = i2c_smbus_read_byte_data(client, + data->in_min[i] = adm9240_read_value(client, ADM9240_REG_IN_MIN(i)); - data->in_max[i] = i2c_smbus_read_byte_data(client, + data->in_max[i] = adm9240_read_value(client, ADM9240_REG_IN_MAX(i)); } for (i = 0; i < 2; i++) { - data->fan_min[i] = i2c_smbus_read_byte_data(client, + data->fan_min[i] = adm9240_read_value(client, ADM9240_REG_FAN_MIN(i)); } - data->temp_max[0] = i2c_smbus_read_byte_data(client, - ADM9240_REG_TEMP_MAX(0)); - data->temp_max[1] = i2c_smbus_read_byte_data(client, - ADM9240_REG_TEMP_MAX(1)); + data->temp_high = adm9240_read_value(client, + ADM9240_REG_TEMP_HIGH); + data->temp_hyst = adm9240_read_value(client, + ADM9240_REG_TEMP_HYST); /* read fan divs and 5-bit VID */ - i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); + i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); data->fan_div[0] = (i >> 4) & 3; data->fan_div[1] = (i >> 6) & 3; data->vid = i & 0x0f; - data->vid |= (i2c_smbus_read_byte_data(client, + data->vid |= (adm9240_read_value(client, ADM9240_REG_VID4) & 1) << 4; /* read analog out */ - data->aout = i2c_smbus_read_byte_data(client, + data->aout = adm9240_read_value(client, ADM9240_REG_ANALOG_OUT); data->last_updated_config = jiffies; diff --git a/trunk/drivers/hwmon/asb100.c b/trunk/drivers/hwmon/asb100.c index 52c469722a65..8e34855a6274 100644 --- a/trunk/drivers/hwmon/asb100.c +++ b/trunk/drivers/hwmon/asb100.c @@ -629,17 +629,19 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, int i, id, err; struct asb100_data *data = i2c_get_clientdata(new_client); - data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (!(data->lm75[0])) { err = -ENOMEM; goto ERROR_SC_0; } + memset(data->lm75[0], 0x00, sizeof(struct i2c_client)); - data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (!(data->lm75[1])) { err = -ENOMEM; goto ERROR_SC_1; } + memset(data->lm75[1], 0x00, sizeof(struct i2c_client)); id = i2c_adapter_id(adapter); @@ -722,11 +724,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access asb100_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL))) { - pr_debug("asb100.o: detect failed, kzalloc failed!\n"); + if (!(data = kmalloc(sizeof(struct asb100_data), GFP_KERNEL))) { + pr_debug("asb100.o: detect failed, kmalloc failed!\n"); err = -ENOMEM; goto ERROR0; } + memset(data, 0, sizeof(struct asb100_data)); new_client = &data->client; init_MUTEX(&data->lock); diff --git a/trunk/drivers/hwmon/atxp1.c b/trunk/drivers/hwmon/atxp1.c index 53324f56404e..deb4d34c9539 100644 --- a/trunk/drivers/hwmon/atxp1.c +++ b/trunk/drivers/hwmon/atxp1.c @@ -253,8 +253,6 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); static int atxp1_attach_adapter(struct i2c_adapter *adapter) { - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; return i2c_probe(adapter, &addr_data, &atxp1_detect); }; @@ -268,11 +266,12 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct atxp1_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/ds1621.c b/trunk/drivers/hwmon/ds1621.c index 34f71b7c7f37..b0199e063d0e 100644 --- a/trunk/drivers/hwmon/ds1621.c +++ b/trunk/drivers/hwmon/ds1621.c @@ -180,14 +180,12 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max); static int ds1621_attach_adapter(struct i2c_adapter *adapter) { - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; return i2c_probe(adapter, &addr_data, ds1621_detect); } /* This function is called by i2c_probe */ -static int ds1621_detect(struct i2c_adapter *adapter, int address, - int kind) +int ds1621_detect(struct i2c_adapter *adapter, int address, + int kind) { int conf, temp; struct i2c_client *new_client; @@ -202,10 +200,11 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address, /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access ds1621_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct ds1621_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/fscher.c b/trunk/drivers/hwmon/fscher.c index a02e1c34c757..eef6061d786b 100644 --- a/trunk/drivers/hwmon/fscher.c +++ b/trunk/drivers/hwmon/fscher.c @@ -303,10 +303,11 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) /* OK. For now, we presume we have a valid client. We now create the * client structure, even though we cannot fill it completely yet. * But it allows us to access i2c_smbus_read_byte_data. */ - if (!(data = kzalloc(sizeof(struct fscher_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct fscher_data)); /* The common I2C client data is placed right before the * Hermes-specific data. */ diff --git a/trunk/drivers/hwmon/fscpos.c b/trunk/drivers/hwmon/fscpos.c index 64e4edc64f8d..5fc77a5fed07 100644 --- a/trunk/drivers/hwmon/fscpos.c +++ b/trunk/drivers/hwmon/fscpos.c @@ -438,7 +438,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter) return i2c_probe(adapter, &addr_data, fscpos_detect); } -static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) +int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) { struct i2c_client *new_client; struct fscpos_data *data; @@ -453,10 +453,11 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) * But it allows us to access fscpos_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct fscpos_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/gl518sm.c b/trunk/drivers/hwmon/gl518sm.c index 2f178dbe3d87..256b9323c84b 100644 --- a/trunk/drivers/hwmon/gl518sm.c +++ b/trunk/drivers/hwmon/gl518sm.c @@ -365,10 +365,11 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access gl518_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct gl518_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct gl518_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/gl520sm.c b/trunk/drivers/hwmon/gl520sm.c index c39ba1239426..12fd757066fc 100644 --- a/trunk/drivers/hwmon/gl520sm.c +++ b/trunk/drivers/hwmon/gl520sm.c @@ -536,10 +536,11 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access gl520_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct gl520_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/it87.c b/trunk/drivers/hwmon/it87.c index 6c41e25e670b..53cc2b6d6385 100644 --- a/trunk/drivers/hwmon/it87.c +++ b/trunk/drivers/hwmon/it87.c @@ -2,7 +2,7 @@ it87.c - Part of lm_sensors, Linux kernel modules for hardware monitoring. - Supports: IT8705F Super I/O chip w/LPC interface + Supports: IT8705F Super I/O chip w/LPC interface & SMBus IT8712F Super I/O chip w/LPC interface & SMBus Sis950 A clone of the IT8705F @@ -47,7 +47,7 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned short isa_address; +static unsigned short isa_address = 0x290; /* Insmod parameters */ I2C_CLIENT_INSMOD_2(it87, it8712); @@ -706,7 +706,7 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter) } /* SuperIO detection - will change isa_address if a chip is found */ -static int __init it87_find(unsigned short *address) +static int __init it87_find(int *address) { int err = -ENODEV; @@ -738,7 +738,7 @@ static int __init it87_find(unsigned short *address) } /* This function is called by i2c_probe */ -static int it87_detect(struct i2c_adapter *adapter, int address, int kind) +int it87_detect(struct i2c_adapter *adapter, int address, int kind) { int i; struct i2c_client *new_client; @@ -757,14 +757,42 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) goto ERROR0; - /* For now, we presume we have a valid client. We create the + /* Probe whether there is anything available on this address. Already + done for SMBus and Super-I/O clients */ + if (kind < 0) { + if (is_isa && !chip_type) { +#define REALLY_SLOW_IO + /* We need the timeouts for at least some IT87-like chips. But only + if we read 'undefined' registers. */ + i = inb_p(address + 1); + if (inb_p(address + 2) != i + || inb_p(address + 3) != i + || inb_p(address + 7) != i) { + err = -ENODEV; + goto ERROR1; + } +#undef REALLY_SLOW_IO + + /* Let's just hope nothing breaks here */ + i = inb_p(address + 5) & 0x7f; + outb_p(~i & 0x7f, address + 5); + if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) { + outb_p(i, address + 5); + err = -ENODEV; + goto ERROR1; + } + } + } + + /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access it87_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) { err = -ENOMEM; goto ERROR1; } + memset(data, 0, sizeof(struct it87_data)); new_client = &data->client; if (is_isa) @@ -1154,18 +1182,20 @@ static struct it87_data *it87_update_device(struct device *dev) static int __init sm_it87_init(void) { - int res; + int addr, res; + + if (!it87_find(&addr)) { + isa_address = addr; + } res = i2c_add_driver(&it87_driver); if (res) return res; - if (!it87_find(&isa_address)) { - res = i2c_isa_add_driver(&it87_isa_driver); - if (res) { - i2c_del_driver(&it87_driver); - return res; - } + res = i2c_isa_add_driver(&it87_isa_driver); + if (res) { + i2c_del_driver(&it87_driver); + return res; } return 0; diff --git a/trunk/drivers/hwmon/lm63.c b/trunk/drivers/hwmon/lm63.c index 954ec2497249..be5c7095ecbb 100644 --- a/trunk/drivers/hwmon/lm63.c +++ b/trunk/drivers/hwmon/lm63.c @@ -375,10 +375,11 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct lm63_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm63_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm63_data)); /* The common I2C client data is placed right before the LM63-specific data. */ diff --git a/trunk/drivers/hwmon/lm75.c b/trunk/drivers/hwmon/lm75.c index d70f4c8fc1e6..9a3ebdf583f4 100644 --- a/trunk/drivers/hwmon/lm75.c +++ b/trunk/drivers/hwmon/lm75.c @@ -127,10 +127,11 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access lm75_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm75_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/lm77.c b/trunk/drivers/hwmon/lm77.c index 9380fda7dcd1..866eab96a6f6 100644 --- a/trunk/drivers/hwmon/lm77.c +++ b/trunk/drivers/hwmon/lm77.c @@ -226,10 +226,11 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access lm77_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm77_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm77_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/lm78.c b/trunk/drivers/hwmon/lm78.c index bde0cda9477e..f6730dc3573b 100644 --- a/trunk/drivers/hwmon/lm78.c +++ b/trunk/drivers/hwmon/lm78.c @@ -480,7 +480,7 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) } /* This function is called by i2c_probe */ -static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) +int lm78_detect(struct i2c_adapter *adapter, int address, int kind) { int i, err; struct i2c_client *new_client; @@ -540,10 +540,11 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access lm78_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { err = -ENOMEM; goto ERROR1; } + memset(data, 0, sizeof(struct lm78_data)); new_client = &data->client; if (is_isa) @@ -725,6 +726,7 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) return i2c_smbus_write_byte_data(client, reg, value); } +/* Called when we have found a new LM78. It should set limits, etc. */ static void lm78_init_client(struct i2c_client *client) { u8 config = lm78_read_value(client, LM78_REG_CONFIG); diff --git a/trunk/drivers/hwmon/lm80.c b/trunk/drivers/hwmon/lm80.c index c359fdea211e..83af8b3a0cac 100644 --- a/trunk/drivers/hwmon/lm80.c +++ b/trunk/drivers/hwmon/lm80.c @@ -393,7 +393,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter) return i2c_probe(adapter, &addr_data, lm80_detect); } -static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) +int lm80_detect(struct i2c_adapter *adapter, int address, int kind) { int i, cur; struct i2c_client *new_client; @@ -407,10 +407,11 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access lm80_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm80_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/lm83.c b/trunk/drivers/hwmon/lm83.c index 9a70611a9f69..d74b2c20c719 100644 --- a/trunk/drivers/hwmon/lm83.c +++ b/trunk/drivers/hwmon/lm83.c @@ -230,10 +230,11 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct lm83_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm83_data)); /* The common I2C client data is placed right after the * LM83-specific data. */ diff --git a/trunk/drivers/hwmon/lm85.c b/trunk/drivers/hwmon/lm85.c index d1070ed2bee6..ab214df9624b 100644 --- a/trunk/drivers/hwmon/lm85.c +++ b/trunk/drivers/hwmon/lm85.c @@ -1007,14 +1007,14 @@ temp_auto(1); temp_auto(2); temp_auto(3); -static int lm85_attach_adapter(struct i2c_adapter *adapter) +int lm85_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; return i2c_probe(adapter, &addr_data, lm85_detect); } -static int lm85_detect(struct i2c_adapter *adapter, int address, +int lm85_detect(struct i2c_adapter *adapter, int address, int kind) { int company, verstep ; @@ -1033,10 +1033,11 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, client structure, even though we cannot fill it completely yet. But it allows us to access lm85_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) { err = -ENOMEM; goto ERROR0; } + memset(data, 0, sizeof(struct lm85_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -1235,7 +1236,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, return err; } -static int lm85_detach_client(struct i2c_client *client) +int lm85_detach_client(struct i2c_client *client) { struct lm85_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->class_dev); @@ -1245,7 +1246,7 @@ static int lm85_detach_client(struct i2c_client *client) } -static int lm85_read_value(struct i2c_client *client, u8 reg) +int lm85_read_value(struct i2c_client *client, u8 reg) { int res; @@ -1275,7 +1276,7 @@ static int lm85_read_value(struct i2c_client *client, u8 reg) return res ; } -static int lm85_write_value(struct i2c_client *client, u8 reg, int value) +int lm85_write_value(struct i2c_client *client, u8 reg, int value) { int res ; @@ -1304,7 +1305,7 @@ static int lm85_write_value(struct i2c_client *client, u8 reg, int value) return res ; } -static void lm85_init_client(struct i2c_client *client) +void lm85_init_client(struct i2c_client *client) { int value; struct lm85_data *data = i2c_get_clientdata(client); diff --git a/trunk/drivers/hwmon/lm87.c b/trunk/drivers/hwmon/lm87.c index eeec18177861..dca996de4c33 100644 --- a/trunk/drivers/hwmon/lm87.c +++ b/trunk/drivers/hwmon/lm87.c @@ -554,10 +554,11 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm87_data)); /* The common I2C client data is placed right before the LM87-specific data. */ diff --git a/trunk/drivers/hwmon/lm90.c b/trunk/drivers/hwmon/lm90.c index 83cf2e1b09f5..14de05fcd431 100644 --- a/trunk/drivers/hwmon/lm90.c +++ b/trunk/drivers/hwmon/lm90.c @@ -31,7 +31,7 @@ * Devices. That chip is similar to the LM90, with a few differences * that are not handled by this driver. Complete datasheet can be * obtained from Analog's website at: - * http://www.analog.com/en/prod/0,2877,ADM1032,00.html + * http://products.analog.com/products/info.asp?product=ADM1032 * Among others, it has a higher accuracy than the LM90, much like the * LM86 does. * @@ -49,7 +49,7 @@ * register values are decoded differently) it is ignored by this * driver. Complete datasheet can be obtained from Analog's website * at: - * http://www.analog.com/en/prod/0,2877,ADT7461,00.html + * http://products.analog.com/products/info.asp?product=ADT7461 * * Since the LM90 was the first chipset supported by this driver, most * comments will refer to this chipset, but are actually general and @@ -83,10 +83,10 @@ * Addresses to scan * Address is fully defined internally and cannot be changed except for * MAX6659. - * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658 - * have address 0x4c. - * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d. + * LM86, LM89, LM90, LM99, ADM1032, MAX6657 and MAX6658 have address 0x4c. + * LM89-1, and LM99-1 have address 0x4d. * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). + * ADT7461 always has address 0x4c. */ static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; @@ -345,74 +345,10 @@ static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); -/* pec used for ADM1032 only */ -static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - return sprintf(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC)); -} - -static ssize_t set_pec(struct device *dev, struct device_attribute *dummy, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - long val = simple_strtol(buf, NULL, 10); - - switch (val) { - case 0: - client->flags &= ~I2C_CLIENT_PEC; - break; - case 1: - client->flags |= I2C_CLIENT_PEC; - break; - default: - return -EINVAL; - } - - return count; -} - -static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec); - /* * Real code */ -/* The ADM1032 supports PEC but not on write byte transactions, so we need - to explicitely ask for a transaction without PEC. */ -static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) -{ - return i2c_smbus_xfer(client->adapter, client->addr, - client->flags & ~I2C_CLIENT_PEC, - I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); -} - -/* It is assumed that client->update_lock is held (unless we are in - detection or initialization steps). This matters when PEC is enabled, - because we don't want the address pointer to change between the write - byte and the read byte transactions. */ -static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value) -{ - int err; - - if (client->flags & I2C_CLIENT_PEC) { - err = adm1032_write_byte(client, reg); - if (err >= 0) - err = i2c_smbus_read_byte(client); - } else - err = i2c_smbus_read_byte_data(client, reg); - - if (err < 0) { - dev_warn(&client->dev, "Register %#02x read failed (%d)\n", - reg, err); - return err; - } - *value = err; - - return 0; -} - static int lm90_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) @@ -434,10 +370,11 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm90_data)); /* The common I2C client data is placed right before the LM90-specific data. */ @@ -466,22 +403,20 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) if (kind < 0) { /* detection and identification */ u8 man_id, chip_id, reg_config1, reg_convrate; - if (lm90_read_reg(new_client, LM90_REG_R_MAN_ID, - &man_id) < 0 - || lm90_read_reg(new_client, LM90_REG_R_CHIP_ID, - &chip_id) < 0 - || lm90_read_reg(new_client, LM90_REG_R_CONFIG1, - ®_config1) < 0 - || lm90_read_reg(new_client, LM90_REG_R_CONVRATE, - ®_convrate) < 0) - goto exit_free; + man_id = i2c_smbus_read_byte_data(new_client, + LM90_REG_R_MAN_ID); + chip_id = i2c_smbus_read_byte_data(new_client, + LM90_REG_R_CHIP_ID); + reg_config1 = i2c_smbus_read_byte_data(new_client, + LM90_REG_R_CONFIG1); + reg_convrate = i2c_smbus_read_byte_data(new_client, + LM90_REG_R_CONVRATE); if (man_id == 0x01) { /* National Semiconductor */ u8 reg_config2; - if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, - ®_config2) < 0) - goto exit_free; + reg_config2 = i2c_smbus_read_byte_data(new_client, + LM90_REG_R_CONFIG2); if ((reg_config1 & 0x2A) == 0x00 && (reg_config2 & 0xF8) == 0x00 @@ -500,12 +435,14 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) } } else if (man_id == 0x41) { /* Analog Devices */ - if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ + if (address == 0x4C + && (chip_id & 0xF0) == 0x40 /* ADM1032 */ && (reg_config1 & 0x3F) == 0x00 && reg_convrate <= 0x0A) { kind = adm1032; } else - if (chip_id == 0x51 /* ADT7461 */ + if (address == 0x4c + && chip_id == 0x51 /* ADT7461 */ && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ && reg_convrate <= 0x0A) { kind = adt7461; @@ -540,10 +477,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) name = "lm90"; } else if (kind == adm1032) { name = "adm1032"; - /* The ADM1032 supports PEC, but only if combined - transactions are not used. */ - if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) - new_client->flags |= I2C_CLIENT_PEC; } else if (kind == lm99) { name = "lm99"; } else if (kind == lm86) { @@ -596,9 +529,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) &sensor_dev_attr_temp2_crit_hyst.dev_attr); device_create_file(&new_client->dev, &dev_attr_alarms); - if (new_client->flags & I2C_CLIENT_PEC) - device_create_file(&new_client->dev, &dev_attr_pec); - return 0; exit_detach: @@ -618,10 +548,7 @@ static void lm90_init_client(struct i2c_client *client) */ i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, 5); /* 2 Hz */ - if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) { - dev_warn(&client->dev, "Initialization failed!\n"); - return; - } + config = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG1); if (config & 0x40) i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config & 0xBF); /* run */ @@ -649,15 +576,21 @@ static struct lm90_data *lm90_update_device(struct device *dev) down(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { - u8 oldh, newh, l; + u8 oldh, newh; dev_dbg(&client->dev, "Updating lm90 data.\n"); - lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP, &data->temp8[0]); - lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[1]); - lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH, &data->temp8[2]); - lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT, &data->temp8[3]); - lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[4]); - lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst); + data->temp8[0] = i2c_smbus_read_byte_data(client, + LM90_REG_R_LOCAL_TEMP); + data->temp8[1] = i2c_smbus_read_byte_data(client, + LM90_REG_R_LOCAL_LOW); + data->temp8[2] = i2c_smbus_read_byte_data(client, + LM90_REG_R_LOCAL_HIGH); + data->temp8[3] = i2c_smbus_read_byte_data(client, + LM90_REG_R_LOCAL_CRIT); + data->temp8[4] = i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_CRIT); + data->temp_hyst = i2c_smbus_read_byte_data(client, + LM90_REG_R_TCRIT_HYST); /* * There is a trick here. We have to read two registers to @@ -673,20 +606,36 @@ static struct lm90_data *lm90_update_device(struct device *dev) * then we have a valid reading. Else we have to read the low * byte again, and now we believe we have a correct reading. */ - if (lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &oldh) == 0 - && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0 - && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &newh) == 0 - && (newh == oldh - || lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0)) - data->temp11[0] = (newh << 8) | l; - - if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &newh) == 0 - && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, &l) == 0) - data->temp11[1] = (newh << 8) | l; - if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &newh) == 0 - && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0) - data->temp11[2] = (newh << 8) | l; - lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); + oldh = i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_TEMPH); + data->temp11[0] = i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_TEMPL); + newh = i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_TEMPH); + if (newh != oldh) { + data->temp11[0] = i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_TEMPL); +#ifdef DEBUG + oldh = i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_TEMPH); + /* oldh is actually newer */ + if (newh != oldh) + dev_warn(&client->dev, "Remote temperature may be " + "wrong.\n"); +#endif + } + data->temp11[0] |= (newh << 8); + + data->temp11[1] = (i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_LOWH) << 8) + + i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_LOWL); + data->temp11[2] = (i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_HIGHH) << 8) + + i2c_smbus_read_byte_data(client, + LM90_REG_R_REMOTE_HIGHL); + data->alarms = i2c_smbus_read_byte_data(client, + LM90_REG_R_STATUS); data->last_updated = jiffies; data->valid = 1; diff --git a/trunk/drivers/hwmon/lm92.c b/trunk/drivers/hwmon/lm92.c index 7a4b3701ed1a..647b7c7cd575 100644 --- a/trunk/drivers/hwmon/lm92.c +++ b/trunk/drivers/hwmon/lm92.c @@ -300,10 +300,11 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) | I2C_FUNC_SMBUS_WORD_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct lm92_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct lm92_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct lm92_data)); /* Fill in enough client fields so that we can read from the chip, which is required for identication */ diff --git a/trunk/drivers/hwmon/max1619.c b/trunk/drivers/hwmon/max1619.c index 6a82ffae1bfd..16bf71f3a04d 100644 --- a/trunk/drivers/hwmon/max1619.c +++ b/trunk/drivers/hwmon/max1619.c @@ -197,10 +197,11 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct max1619_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct max1619_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct max1619_data)); /* The common I2C client data is placed right before the MAX1619-specific data. */ diff --git a/trunk/drivers/hwmon/pc87360.c b/trunk/drivers/hwmon/pc87360.c index 17f745a23d04..cf2a35799c7c 100644 --- a/trunk/drivers/hwmon/pc87360.c +++ b/trunk/drivers/hwmon/pc87360.c @@ -754,8 +754,9 @@ static int pc87360_detect(struct i2c_adapter *adapter) const char *name = "pc87360"; int use_thermistors = 0; - if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) + if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) return -ENOMEM; + memset(data, 0x00, sizeof(struct pc87360_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/sis5595.c b/trunk/drivers/hwmon/sis5595.c index 9c6cadec1087..21aa9a41f62c 100644 --- a/trunk/drivers/hwmon/sis5595.c +++ b/trunk/drivers/hwmon/sis5595.c @@ -518,10 +518,11 @@ static int sis5595_detect(struct i2c_adapter *adapter) goto exit_release; } - if (!(data = kzalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { err = -ENOMEM; goto exit_release; } + memset(data, 0, sizeof(struct sis5595_data)); new_client = &data->client; new_client->addr = address; diff --git a/trunk/drivers/hwmon/smsc47b397.c b/trunk/drivers/hwmon/smsc47b397.c index 2a3e21b5b6b4..7fe71576dea4 100644 --- a/trunk/drivers/hwmon/smsc47b397.c +++ b/trunk/drivers/hwmon/smsc47b397.c @@ -244,10 +244,11 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) return -EBUSY; } - if (!(data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { err = -ENOMEM; goto error_release; } + memset(data, 0x00, sizeof(struct smsc47b397_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -298,7 +299,7 @@ static int __init smsc47b397_find(unsigned short *addr) superio_enter(); id = superio_inb(SUPERIO_REG_DEVID); - if ((id != 0x6f) && (id != 0x81)) { + if (id != 0x6f) { superio_exit(); return -ENODEV; } @@ -309,9 +310,8 @@ static int __init smsc47b397_find(unsigned short *addr) *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) | superio_inb(SUPERIO_REG_BASE_LSB); - printk(KERN_INFO "smsc47b397: found SMSC %s " - "(base address 0x%04x, revision %u)\n", - id == 0x81 ? "SCH5307-NS" : "LPC47B397-NC", *addr, rev); + printk(KERN_INFO "smsc47b397: found SMSC LPC47B397-NC " + "(base address 0x%04x, revision %u)\n", *addr, rev); superio_exit(); return 0; diff --git a/trunk/drivers/hwmon/smsc47m1.c b/trunk/drivers/hwmon/smsc47m1.c index 5905c1af88f2..c9cc683eba4a 100644 --- a/trunk/drivers/hwmon/smsc47m1.c +++ b/trunk/drivers/hwmon/smsc47m1.c @@ -3,7 +3,7 @@ for hardware monitoring Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, - LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips. + LPC47M15x and LPC47M192 Super-I/O chips. Copyright (C) 2002 Mark D. Studebaker Copyright (C) 2004 Jean Delvare @@ -356,8 +356,6 @@ static int __init smsc47m1_find(unsigned short *addr) * 0x5F) and LPC47B27x (device id 0x51) have fan control. * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" * can do much more besides (device id 0x60). - * The LPC47M997 is undocumented, but seems to be compatible with - * the LPC47M192, and has the same device id. */ if (val == 0x51) printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); @@ -366,8 +364,7 @@ static int __init smsc47m1_find(unsigned short *addr) else if (val == 0x5F) printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); else if (val == 0x60) - printk(KERN_INFO "smsc47m1: Found SMSC " - "LPC47M15x/LPC47M192/LPC47M997\n"); + printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); else { superio_exit(); return -ENODEV; @@ -399,10 +396,11 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) return -EBUSY; } - if (!(data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { err = -ENOMEM; goto error_release; } + memset(data, 0x00, sizeof(struct smsc47m1_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/hwmon/via686a.c b/trunk/drivers/hwmon/via686a.c index 6f696f897176..05ddc88e7dd2 100644 --- a/trunk/drivers/hwmon/via686a.c +++ b/trunk/drivers/hwmon/via686a.c @@ -44,7 +44,7 @@ /* If force_addr is set to anything different from 0, we forcibly enable the device at the given address. */ -static unsigned short force_addr; +static unsigned short force_addr = 0; module_param(force_addr, ushort, 0); MODULE_PARM_DESC(force_addr, "Initialize the base address of the sensors"); @@ -198,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) but the function is very linear in the useful range (0-80 deg C), so we'll just use linear interpolation for 10-bit readings.) So, tempLUT is the temp at via register values 0-255: */ -static const s16 tempLUT[] = +static const long tempLUT[] = { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, @@ -270,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val) } /* for 8-bit temperature hyst and over registers */ -#define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100) +#define TEMP_FROM_REG(val) (tempLUT[(val)] * 100) /* for 10-bit temperature readings */ static inline long TEMP_FROM_REG10(u16 val) @@ -589,8 +589,10 @@ static int via686a_detect(struct i2c_adapter *adapter) u16 val; /* 8231 requires multiple of 256, we enforce that on 686 as well */ - if (force_addr) { + if (force_addr) address = force_addr & 0xFF00; + + if (force_addr) { dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", address); if (PCIBIOS_SUCCESSFUL != @@ -601,17 +603,11 @@ static int via686a_detect(struct i2c_adapter *adapter) pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) return -ENODEV; if (!(val & 0x0001)) { - if (force_addr) { - dev_info(&adapter->dev, "enabling sensors\n"); - if (PCIBIOS_SUCCESSFUL != - pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, - val | 0x0001)) - return -ENODEV; - } else { - dev_warn(&adapter->dev, "sensors disabled - enable " - "with force_addr=0x%x\n", address); + dev_warn(&adapter->dev, "enabling sensors\n"); + if (PCIBIOS_SUCCESSFUL != + pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, + val | 0x0001)) return -ENODEV; - } } /* Reserve the ISA region */ @@ -621,10 +617,11 @@ static int via686a_detect(struct i2c_adapter *adapter) return -ENODEV; } - if (!(data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { err = -ENOMEM; goto exit_release; } + memset(data, 0, sizeof(struct via686a_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -711,6 +708,7 @@ static int via686a_detach_client(struct i2c_client *client) return 0; } +/* Called when we have found a new VIA686A. Set limits, etc. */ static void via686a_init_client(struct i2c_client *client) { u8 reg; diff --git a/trunk/drivers/hwmon/w83627ehf.c b/trunk/drivers/hwmon/w83627ehf.c index eee22a57e929..b60efe8f8b26 100644 --- a/trunk/drivers/hwmon/w83627ehf.c +++ b/trunk/drivers/hwmon/w83627ehf.c @@ -105,9 +105,7 @@ superio_exit(void) * ISA constants */ -#define REGION_ALIGNMENT ~7 -#define REGION_OFFSET 5 -#define REGION_LENGTH 2 +#define REGION_LENGTH 8 #define ADDR_REG_OFFSET 5 #define DATA_REG_OFFSET 6 @@ -675,16 +673,16 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) struct w83627ehf_data *data; int i, err = 0; - if (!request_region(address + REGION_OFFSET, REGION_LENGTH, - w83627ehf_driver.name)) { + if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { err = -EBUSY; goto exit; } - if (!(data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { err = -ENOMEM; goto exit_release; } + memset(data, 0, sizeof(struct w83627ehf_data)); client = &data->client; i2c_set_clientdata(client, data); @@ -764,7 +762,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) exit_free: kfree(data); exit_release: - release_region(address + REGION_OFFSET, REGION_LENGTH); + release_region(address, REGION_LENGTH); exit: return err; } @@ -778,7 +776,7 @@ static int w83627ehf_detach_client(struct i2c_client *client) if ((err = i2c_detach_client(client))) return err; - release_region(client->addr + REGION_OFFSET, REGION_LENGTH); + release_region(client->addr, REGION_LENGTH); kfree(data); return 0; @@ -809,7 +807,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr) superio_select(W83627EHF_LD_HWM); val = (superio_inb(SIO_REG_ADDR) << 8) | superio_inb(SIO_REG_ADDR + 1); - *addr = val & REGION_ALIGNMENT; + *addr = val & ~(REGION_LENGTH - 1); if (*addr == 0) { superio_exit(); return -ENODEV; diff --git a/trunk/drivers/hwmon/w83627hf.c b/trunk/drivers/hwmon/w83627hf.c index 70ef926c3bd8..3479dc5208e2 100644 --- a/trunk/drivers/hwmon/w83627hf.c +++ b/trunk/drivers/hwmon/w83627hf.c @@ -142,14 +142,10 @@ superio_exit(void) #define WINB_BASE_REG 0x60 /* Constants specified below */ -/* Alignment of the base address */ -#define WINB_ALIGNMENT ~7 +/* Length of ISA address segment */ +#define WINB_EXTENT 8 -/* Offset & size of I/O region we are interested in */ -#define WINB_REGION_OFFSET 5 -#define WINB_REGION_SIZE 2 - -/* Where are the sensors address/data registers relative to the base address */ +/* Where are the ISA address/data registers relative to the base address */ #define W83781D_ADDR_REG_OFFSET 5 #define W83781D_DATA_REG_OFFSET 6 @@ -201,6 +197,7 @@ superio_exit(void) #define W83627HF_REG_PWM1 0x5A #define W83627HF_REG_PWM2 0x5B +#define W83627HF_REG_PWMCLK12 0x5C #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ @@ -984,7 +981,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) superio_select(W83627HF_LD_HWM); val = (superio_inb(WINB_BASE_REG) << 8) | superio_inb(WINB_BASE_REG + 1); - *addr = val & WINB_ALIGNMENT; + *addr = val & ~(WINB_EXTENT - 1); if (*addr == 0 && force_addr == 0) { superio_exit(); return -ENODEV; @@ -1003,10 +1000,9 @@ static int w83627hf_detect(struct i2c_adapter *adapter) const char *client_name = ""; if(force_addr) - address = force_addr & WINB_ALIGNMENT; + address = force_addr & ~(WINB_EXTENT - 1); - if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, - w83627hf_driver.name)) { + if (!request_region(address, WINB_EXTENT, w83627hf_driver.name)) { err = -EBUSY; goto ERROR0; } @@ -1045,10 +1041,11 @@ static int w83627hf_detect(struct i2c_adapter *adapter) client structure, even though we cannot fill it completely yet. But it allows us to access w83627hf_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { err = -ENOMEM; goto ERROR1; } + memset(data, 0, sizeof(struct w83627hf_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -1151,7 +1148,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) ERROR2: kfree(data); ERROR1: - release_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE); + release_region(address, WINB_EXTENT); ERROR0: return err; } @@ -1166,7 +1163,7 @@ static int w83627hf_detach_client(struct i2c_client *client) if ((err = i2c_detach_client(client))) return err; - release_region(client->addr + WINB_REGION_OFFSET, WINB_REGION_SIZE); + release_region(client->addr, WINB_EXTENT); kfree(data); return 0; @@ -1278,6 +1275,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) return 0; } +/* Called when we have found a new W83781D. It should set limits, etc. */ static void w83627hf_init_client(struct i2c_client *client) { struct w83627hf_data *data = i2c_get_clientdata(client); @@ -1371,6 +1369,12 @@ static void w83627hf_init_client(struct i2c_client *client) } } + if (type == w83627hf) { + /* enable PWM2 control (can't hurt since PWM reg + should have been reset to 0xff) */ + w83627hf_write_value(client, W83627HF_REG_PWMCLK12, + 0x19); + } /* enable comparator mode for temp2 and temp3 so alarm indication will work correctly */ i = w83627hf_read_value(client, W83781D_REG_IRQ); diff --git a/trunk/drivers/hwmon/w83781d.c b/trunk/drivers/hwmon/w83781d.c index 9265f32122fa..4c43337ca780 100644 --- a/trunk/drivers/hwmon/w83781d.c +++ b/trunk/drivers/hwmon/w83781d.c @@ -889,11 +889,12 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, const char *client_name = ""; struct w83781d_data *data = i2c_get_clientdata(new_client); - data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (!(data->lm75[0])) { err = -ENOMEM; goto ERROR_SC_0; } + memset(data->lm75[0], 0x00, sizeof (struct i2c_client)); id = i2c_adapter_id(adapter); @@ -918,11 +919,13 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, } if (kind != w83783s) { - data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + + data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (!(data->lm75[1])) { err = -ENOMEM; goto ERROR_SC_1; } + memset(data->lm75[1], 0x0, sizeof(struct i2c_client)); if (force_subclients[0] == id && force_subclients[1] == address) { @@ -1061,10 +1064,11 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access w83781d_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { err = -ENOMEM; goto ERROR1; } + memset(data, 0, sizeof(struct w83781d_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -1447,6 +1451,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) return 0; } +/* Called when we have found a new W83781D. It should set limits, etc. */ static void w83781d_init_client(struct i2c_client *client) { diff --git a/trunk/drivers/hwmon/w83792d.c b/trunk/drivers/hwmon/w83792d.c index 4be59dbb78c4..ba0c28015f6a 100644 --- a/trunk/drivers/hwmon/w83792d.c +++ b/trunk/drivers/hwmon/w83792d.c @@ -1086,10 +1086,11 @@ w83792d_create_subclient(struct i2c_adapter *adapter, int err; struct i2c_client *sub_client; - (*sub_cli) = sub_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (!(sub_client)) { return -ENOMEM; } + memset(sub_client, 0x00, sizeof(struct i2c_client)); sub_client->addr = 0x48 + addr; i2c_set_clientdata(sub_client, NULL); sub_client->adapter = adapter; @@ -1183,10 +1184,11 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access w83792d_{read,write}_value. */ - if (!(data = kzalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { err = -ENOMEM; goto ERROR0; } + memset(data, 0, sizeof(struct w83792d_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -1427,6 +1429,7 @@ w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) return 0; } +/* Called when we have found a new W83792D. It should set limits, etc. */ static void w83792d_init_client(struct i2c_client *client) { diff --git a/trunk/drivers/hwmon/w83l785ts.c b/trunk/drivers/hwmon/w83l785ts.c index f495b6378668..133e34ab1d0a 100644 --- a/trunk/drivers/hwmon/w83l785ts.c +++ b/trunk/drivers/hwmon/w83l785ts.c @@ -37,7 +37,6 @@ #include #include #include -#include #include /* How many retries on register read error */ @@ -74,7 +73,7 @@ I2C_CLIENT_INSMOD_1(w83l785ts); * The W83L785TS-S uses signed 8-bit values. */ -#define TEMP_FROM_REG(val) ((val) * 1000) +#define TEMP_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000) /* * Functions declaration @@ -112,24 +111,27 @@ struct w83l785ts_data { unsigned long last_updated; /* in jiffies */ /* registers values */ - s8 temp[2]; /* 0: input - 1: critical limit */ + u8 temp, temp_over; }; /* * Sysfs stuff */ -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct w83l785ts_data *data = w83l785ts_update_device(dev); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1); +static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct w83l785ts_data *data = w83l785ts_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); +} + +static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); +static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL); /* * Real code @@ -156,10 +158,12 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kzalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct w83l785ts_data)); + /* The common I2C client data is placed right before the * W83L785TS-specific data. */ @@ -224,7 +228,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) init_MUTEX(&data->update_lock); /* Default values in case the first read fails (unlikely). */ - data->temp[1] = data->temp[0] = 0; + data->temp_over = data->temp = 0; /* Tell the I2C layer a new client has arrived. */ if ((err = i2c_attach_client(new_client))) @@ -242,10 +246,8 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) goto exit_detach; } - device_create_file(&new_client->dev, - &sensor_dev_attr_temp1_input.dev_attr); - device_create_file(&new_client->dev, - &sensor_dev_attr_temp1_max.dev_attr); + device_create_file(&new_client->dev, &dev_attr_temp1_input); + device_create_file(&new_client->dev, &dev_attr_temp1_max); return 0; @@ -303,10 +305,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { dev_dbg(&client->dev, "Updating w83l785ts data.\n"); - data->temp[0] = w83l785ts_read_value(client, - W83L785TS_REG_TEMP, data->temp[0]); - data->temp[1] = w83l785ts_read_value(client, - W83L785TS_REG_TEMP_OVER, data->temp[1]); + data->temp = w83l785ts_read_value(client, + W83L785TS_REG_TEMP, data->temp); + data->temp_over = w83l785ts_read_value(client, + W83L785TS_REG_TEMP_OVER, data->temp_over); data->last_updated = jiffies; data->valid = 1; diff --git a/trunk/drivers/i2c/algos/i2c-algo-pca.c b/trunk/drivers/i2c/algos/i2c-algo-pca.c index 82946acab4c7..beb10edfe9c1 100644 --- a/trunk/drivers/i2c/algos/i2c-algo-pca.c +++ b/trunk/drivers/i2c/algos/i2c-algo-pca.c @@ -34,7 +34,7 @@ #define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0) #define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0) -static int i2c_debug; +static int i2c_debug=0; #define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val) #define pca_inw(adap, reg) adap->read_byte(adap, reg) diff --git a/trunk/drivers/i2c/algos/i2c-algo-sibyte.c b/trunk/drivers/i2c/algos/i2c-algo-sibyte.c index 938848ae162d..8ed5ad12552f 100644 --- a/trunk/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/trunk/drivers/i2c/algos/i2c-algo-sibyte.c @@ -42,7 +42,7 @@ /* module parameters: */ -static int bit_scan; /* have a look at what's hanging 'round */ +static int bit_scan=0; /* have a look at what's hanging 'round */ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, diff --git a/trunk/drivers/i2c/busses/Kconfig b/trunk/drivers/i2c/busses/Kconfig index 4010fe92e72b..3badfec75b1c 100644 --- a/trunk/drivers/i2c/busses/Kconfig +++ b/trunk/drivers/i2c/busses/Kconfig @@ -135,12 +135,11 @@ config I2C_I810 help If you say yes to this option, support will be included for the Intel 810/815 family of mainboard I2C interfaces. Specifically, the - following versions of the chipset are supported: + following versions of the chipset is supported: i810AA i810AB i810E i815 - i845G This driver can also be built as a module. If so, the module will be called i2c-i810. diff --git a/trunk/drivers/i2c/busses/i2c-ali1535.c b/trunk/drivers/i2c/busses/i2c-ali1535.c index ba90f5140af6..f021acd2674e 100644 --- a/trunk/drivers/i2c/busses/i2c-ali1535.c +++ b/trunk/drivers/i2c/busses/i2c-ali1535.c @@ -134,7 +134,7 @@ /* -> Read = 1 */ #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ -static struct pci_driver ali1535_driver; + static unsigned short ali1535_smba; static DECLARE_MUTEX(i2c_ali1535_sem); @@ -162,8 +162,7 @@ static int ali1535_setup(struct pci_dev *dev) goto exit; } - if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, - ali1535_driver.name)) { + if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, "ali1535-smb")) { dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", ali1535_smba); goto exit; @@ -481,6 +480,7 @@ static struct i2c_adapter ali1535_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; static struct pci_device_id ali1535_ids[] = { @@ -513,7 +513,6 @@ static void __devexit ali1535_remove(struct pci_dev *dev) } static struct pci_driver ali1535_driver = { - .owner = THIS_MODULE, .name = "ali1535_smbus", .id_table = ali1535_ids, .probe = ali1535_probe, diff --git a/trunk/drivers/i2c/busses/i2c-ali1563.c b/trunk/drivers/i2c/busses/i2c-ali1563.c index f1a62d892425..86947504aea1 100644 --- a/trunk/drivers/i2c/busses/i2c-ali1563.c +++ b/trunk/drivers/i2c/busses/i2c-ali1563.c @@ -60,7 +60,6 @@ #define HST_CNTL2_SIZEMASK 0x38 -static struct pci_driver ali1563_pci_driver; static unsigned short ali1563_smba; static int ali1563_transaction(struct i2c_adapter * a, int size) @@ -351,8 +350,7 @@ static int __devinit ali1563_setup(struct pci_dev * dev) dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); goto Err; } - if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, - ali1563_pci_driver.name)) { + if (!request_region(ali1563_smba,ALI1563_SMB_IOSIZE,"i2c-ali1563")) { dev_warn(&dev->dev,"Could not allocate I/O space"); goto Err; } @@ -408,8 +406,7 @@ static struct pci_device_id __devinitdata ali1563_id_table[] = { MODULE_DEVICE_TABLE (pci, ali1563_id_table); static struct pci_driver ali1563_pci_driver = { - .owner = THIS_MODULE, - .name = "ali1563_smbus", + .name = "ali1563_i2c", .id_table = ali1563_id_table, .probe = ali1563_probe, .remove = __devexit_p(ali1563_remove), diff --git a/trunk/drivers/i2c/busses/i2c-ali15x3.c b/trunk/drivers/i2c/busses/i2c-ali15x3.c index 400b08ed4299..b3f50bff39a0 100644 --- a/trunk/drivers/i2c/busses/i2c-ali15x3.c +++ b/trunk/drivers/i2c/busses/i2c-ali15x3.c @@ -125,13 +125,12 @@ /* If force_addr is set to anything different from 0, we forcibly enable the device at the given address. */ -static u16 force_addr; +static u16 force_addr = 0; module_param(force_addr, ushort, 0); MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); -static struct pci_driver ali15x3_driver; -static unsigned short ali15x3_smba; +static unsigned short ali15x3_smba = 0; static int ali15x3_setup(struct pci_dev *ALI15X3_dev) { @@ -167,8 +166,7 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev) if(force_addr) ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); - if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, - ali15x3_driver.name)) { + if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb")) { dev_err(&ALI15X3_dev->dev, "ALI15X3_smb region 0x%x already in use!\n", ali15x3_smba); @@ -472,6 +470,7 @@ static struct i2c_adapter ali15x3_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; static struct pci_device_id ali15x3_ids[] = { @@ -504,7 +503,6 @@ static void __devexit ali15x3_remove(struct pci_dev *dev) } static struct pci_driver ali15x3_driver = { - .owner = THIS_MODULE, .name = "ali15x3_smbus", .id_table = ali15x3_ids, .probe = ali15x3_probe, diff --git a/trunk/drivers/i2c/busses/i2c-amd756-s4882.c b/trunk/drivers/i2c/busses/i2c-amd756-s4882.c index f51ab652300a..4e553e8c5cba 100644 --- a/trunk/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/trunk/drivers/i2c/busses/i2c-amd756-s4882.c @@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void) init_MUTEX(&amd756_lock); /* Define the 5 virtual adapters and algorithms structures */ - if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), + if (!(s4882_adapter = kmalloc(5 * sizeof(struct i2c_adapter), GFP_KERNEL))) { error = -ENOMEM; goto ERROR1; } - if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm), + if (!(s4882_algo = kmalloc(5 * sizeof(struct i2c_algorithm), GFP_KERNEL))) { error = -ENOMEM; goto ERROR2; diff --git a/trunk/drivers/i2c/busses/i2c-amd756.c b/trunk/drivers/i2c/busses/i2c-amd756.c index de035d137c3f..6ad0603384b8 100644 --- a/trunk/drivers/i2c/busses/i2c-amd756.c +++ b/trunk/drivers/i2c/busses/i2c-amd756.c @@ -85,8 +85,8 @@ #define AMD756_PROCESS_CALL 0x04 #define AMD756_BLOCK_DATA 0x05 -static struct pci_driver amd756_driver; -static unsigned short amd756_ioport; + +static unsigned short amd756_ioport = 0; /* SMBUS event = I/O 28-29 bit 11 @@ -303,6 +303,7 @@ struct i2c_adapter amd756_smbus = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 }; @@ -364,7 +365,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, amd756_ioport += SMB_ADDR_OFFSET; } - if (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) { + if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { dev_err(&pdev->dev, "SMB region 0x%x already in use!\n", amd756_ioport); return -ENODEV; @@ -401,7 +402,6 @@ static void __devexit amd756_remove(struct pci_dev *dev) } static struct pci_driver amd756_driver = { - .owner = THIS_MODULE, .name = "amd756_smbus", .id_table = amd756_ids, .probe = amd756_probe, diff --git a/trunk/drivers/i2c/busses/i2c-amd8111.c b/trunk/drivers/i2c/busses/i2c-amd8111.c index f3b79a68dbec..45ea24ba14d5 100644 --- a/trunk/drivers/i2c/busses/i2c-amd8111.c +++ b/trunk/drivers/i2c/busses/i2c-amd8111.c @@ -30,8 +30,6 @@ struct amd_smbus { int size; }; -static struct pci_driver amd8111_driver; - /* * AMD PCI control registers definitions. */ @@ -244,6 +242,7 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl break; case I2C_SMBUS_BLOCK_PROC_CALL: + protocol |= pec; len = min_t(u8, data->block[0], 31); amd_ec_write(smbus, AMD_SMB_CMD, command); amd_ec_write(smbus, AMD_SMB_BCNT, len); @@ -253,6 +252,13 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl read_write = I2C_SMBUS_READ; break; + case I2C_SMBUS_WORD_DATA_PEC: + case I2C_SMBUS_BLOCK_DATA_PEC: + case I2C_SMBUS_PROC_CALL_PEC: + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + dev_warn(&adap->dev, "Unexpected software PEC transaction %d\n.", size); + return -1; + default: dev_warn(&adap->dev, "Unsupported transaction %d\n", size); return -1; @@ -337,15 +343,16 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) return -ENODEV; - smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL); + smbus = kmalloc(sizeof(struct amd_smbus), GFP_KERNEL); if (!smbus) return -ENOMEM; + memset(smbus, 0, sizeof(struct amd_smbus)); smbus->dev = dev; smbus->base = pci_resource_start(dev, 0); smbus->size = pci_resource_len(dev, 0); - if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) + if (!request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0")) goto out_kfree; smbus->adapter.owner = THIS_MODULE; @@ -384,7 +391,6 @@ static void __devexit amd8111_remove(struct pci_dev *dev) } static struct pci_driver amd8111_driver = { - .owner = THIS_MODULE, .name = "amd8111_smbus2", .id_table = amd8111_ids, .probe = amd8111_probe, diff --git a/trunk/drivers/i2c/busses/i2c-elektor.c b/trunk/drivers/i2c/busses/i2c-elektor.c index 59f8308c2356..6930b660e508 100644 --- a/trunk/drivers/i2c/busses/i2c-elektor.c +++ b/trunk/drivers/i2c/busses/i2c-elektor.c @@ -22,7 +22,7 @@ /* With some changes from Kyösti Mälkki and even Frodo Looijaard */ -/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of +/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of for Alpha Processor Inc. UP-2000(+) boards */ #include @@ -46,14 +46,12 @@ #define DEFAULT_BASE 0x330 static int base; -static u8 __iomem *base_iomem; - static int irq; static int clock = 0x1c; static int own = 0x55; static int mmapped; -/* vdovikin: removed static struct i2c_pcf_isa gpi; code - +/* vdovikin: removed static struct i2c_pcf_isa gpi; code - this module in real supports only one device, due to missing arguments in some functions, called from the algo-pcf module. Sometimes it's need to be rewriten - but for now just remove this for simpler reading */ @@ -62,33 +60,40 @@ static wait_queue_head_t pcf_wait; static int pcf_pending; static spinlock_t lock; -static struct i2c_adapter pcf_isa_ops; - /* ----- local functions ---------------------------------------------- */ static void pcf_isa_setbyte(void *data, int ctl, int val) { - u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; + int address = ctl ? (base + 1) : base; /* enable irq if any specified for serial operation */ if (ctl && irq && (val & I2C_PCF_ESO)) { val |= I2C_PCF_ENI; } - pr_debug("%s: Write %p 0x%02X\n", pcf_isa_ops.name, address, val); - iowrite8(val, address); -#ifdef __alpha__ - /* API UP2000 needs some hardware fudging to make the write stick */ - iowrite8(val, address); -#endif + pr_debug("i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255); + + switch (mmapped) { + case 0: /* regular I/O */ + outb(val, address); + break; + case 2: /* double mapped I/O needed for UP2000 board, + I don't know why this... */ + writeb(val, (void *)address); + /* fall */ + case 1: /* memory mapped I/O */ + writeb(val, (void *)address); + break; + } } static int pcf_isa_getbyte(void *data, int ctl) { - u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; - int val = ioread8(address); + int address = ctl ? (base + 1) : base; + int val = mmapped ? readb((void *)address) : inb(address); + + pr_debug("i2c-elektor: Read 0x%X 0x%02X\n", address, val); - pr_debug("%s: Read %p 0x%02X\n", pcf_isa_ops.name, address, val); return (val); } @@ -144,40 +149,16 @@ static int pcf_isa_init(void) { spin_lock_init(&lock); if (!mmapped) { - if (!request_region(base, 2, pcf_isa_ops.name)) { - printk(KERN_ERR "%s: requested I/O region (%#x:2) is " - "in use\n", pcf_isa_ops.name, base); - return -ENODEV; - } - base_iomem = ioport_map(base, 2); - if (!base_iomem) { - printk(KERN_ERR "%s: remap of I/O region %#x failed\n", - pcf_isa_ops.name, base); - release_region(base, 2); - return -ENODEV; - } - } else { - if (!request_mem_region(base, 2, pcf_isa_ops.name)) { - printk(KERN_ERR "%s: requested memory region (%#x:2) " - "is in use\n", pcf_isa_ops.name, base); - return -ENODEV; - } - base_iomem = ioremap(base, 2); - if (base_iomem == NULL) { - printk(KERN_ERR "%s: remap of memory region %#x " - "failed\n", pcf_isa_ops.name, base); - release_mem_region(base, 2); + if (!request_region(base, 2, "i2c (isa bus adapter)")) { + printk(KERN_ERR + "i2c-elektor: requested I/O region (0x%X:2) " + "is in use.\n", base); return -ENODEV; } } - pr_debug("%s: registers %#x remapped to %p\n", pcf_isa_ops.name, base, - base_iomem); - if (irq > 0) { - if (request_irq(irq, pcf_isa_handler, 0, pcf_isa_ops.name, - NULL) < 0) { - printk(KERN_ERR "%s: Request irq%d failed\n", - pcf_isa_ops.name, irq); + if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", NULL) < 0) { + printk(KERN_ERR "i2c-elektor: Request irq%d failed\n", irq); irq = 0; } else enable_irq(irq); @@ -205,49 +186,47 @@ static struct i2c_adapter pcf_isa_ops = { .class = I2C_CLASS_HWMON, .id = I2C_HW_P_ELEK, .algo_data = &pcf_isa_data, - .name = "i2c-elektor", + .name = "PCF8584 ISA adapter", }; -static int __init i2c_pcfisa_init(void) +static int __init i2c_pcfisa_init(void) { #ifdef __alpha__ - /* check to see we have memory mapped PCF8584 connected to the + /* check to see we have memory mapped PCF8584 connected to the Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ if (base == 0) { struct pci_dev *cy693_dev; - - cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, + + cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, NULL); if (cy693_dev) { - unsigned char config; + char config; /* yeap, we've found cypress, let's check config */ if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { - - pr_debug("%s: found cy82c693, config " - "register 0x47 = 0x%02x\n", - pcf_isa_ops.name, config); + + pr_debug("i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config); /* UP2000 board has this register set to 0xe1, - but the most significant bit as seems can be + but the most significant bit as seems can be reset during the proper initialisation - sequence if guys from API decides to do that - (so, we can even enable Tsunami Pchip - window for the upper 1 Gb) */ + sequence if guys from API decides to do that + (so, we can even enable Tsunami Pchip + window for the upper 1 Gb) */ /* so just check for ROMCS at 0xe0000, - ROMCS enabled for writes + ROMCS enabled for writes and external XD Bus buffer in use. */ if ((config & 0x7f) == 0x61) { /* seems to be UP2000 like board */ base = 0xe0000; - mmapped = 1; - /* UP2000 drives ISA with + /* I don't know why we need to + write twice */ + mmapped = 2; + /* UP2000 drives ISA with 8.25 MHz (PCI/4) clock (this can be read from cypress) */ clock = I2C_PCF_CLK | I2C_PCF_TRNS90; - pr_info("%s: found API UP2000 like " - "board, will probe PCF8584 " - "later\n", pcf_isa_ops.name); + printk(KERN_INFO "i2c-elektor: found API UP2000 like board, will probe PCF8584 later.\n"); } } pci_dev_put(cy693_dev); @@ -257,11 +236,12 @@ static int __init i2c_pcfisa_init(void) /* sanity checks for mmapped I/O */ if (mmapped && base < 0xc8000) { - printk(KERN_ERR "%s: incorrect base address (%#x) specified " - "for mmapped I/O\n", pcf_isa_ops.name, base); + printk(KERN_ERR "i2c-elektor: incorrect base address (0x%0X) specified for mmapped I/O.\n", base); return -ENODEV; } + printk(KERN_INFO "i2c-elektor: i2c pcf8584-isa adapter driver\n"); + if (base == 0) { base = DEFAULT_BASE; } @@ -271,8 +251,8 @@ static int __init i2c_pcfisa_init(void) return -ENODEV; if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) goto fail; - - dev_info(&pcf_isa_ops.dev, "found device at %#x\n", base); + + printk(KERN_ERR "i2c-elektor: found device at %#x.\n", base); return 0; @@ -282,13 +262,8 @@ static int __init i2c_pcfisa_init(void) free_irq(irq, NULL); } - if (!mmapped) { - ioport_unmap(base_iomem); - release_region(base, 2); - } else { - iounmap(base_iomem); - release_mem_region(base, 2); - } + if (!mmapped) + release_region(base , 2); return -ENODEV; } @@ -301,13 +276,8 @@ static void i2c_pcfisa_exit(void) free_irq(irq, NULL); } - if (!mmapped) { - ioport_unmap(base_iomem); - release_region(base, 2); - } else { - iounmap(base_iomem); - release_mem_region(base, 2); - } + if (!mmapped) + release_region(base , 2); } MODULE_AUTHOR("Hans Berglund "); diff --git a/trunk/drivers/i2c/busses/i2c-hydra.c b/trunk/drivers/i2c/busses/i2c-hydra.c index 1b5354e24bf5..e0cb3b0f92fa 100644 --- a/trunk/drivers/i2c/busses/i2c-hydra.c +++ b/trunk/drivers/i2c/busses/i2c-hydra.c @@ -155,7 +155,6 @@ static void __devexit hydra_remove(struct pci_dev *dev) static struct pci_driver hydra_driver = { - .owner = THIS_MODULE, .name = "hydra_smbus", .id_table = hydra_ids, .probe = hydra_probe, diff --git a/trunk/drivers/i2c/busses/i2c-i801.c b/trunk/drivers/i2c/busses/i2c-i801.c index 4f63195069da..709beab76609 100644 --- a/trunk/drivers/i2c/busses/i2c-i801.c +++ b/trunk/drivers/i2c/busses/i2c-i801.c @@ -52,6 +52,10 @@ #include #include +#ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC +#define HAVE_PEC +#endif + /* I801 SMBus address offsets */ #define SMBHSTSTS (0 + i801_smba) #define SMBHSTCNT (2 + i801_smba) @@ -102,11 +106,10 @@ MODULE_PARM_DESC(force_addr, "EXTREMELY DANGEROUS!"); static int i801_transaction(void); -static int i801_block_transaction(union i2c_smbus_data *data, char read_write, - int command, int hwpec); +static int i801_block_transaction(union i2c_smbus_data *data, + char read_write, int command); static unsigned short i801_smba; -static struct pci_driver i801_driver; static struct pci_dev *I801_dev; static int isich4; @@ -140,7 +143,7 @@ static int i801_setup(struct pci_dev *dev) } } - if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) { + if (!request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus")) { dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", i801_smba); error_return = -EBUSY; @@ -249,7 +252,7 @@ static int i801_transaction(void) /* All-inclusive block transaction function */ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, - int command, int hwpec) + int command) { int i, len; int smbcmd; @@ -388,7 +391,8 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, goto END; } - if (hwpec) { +#ifdef HAVE_PEC + if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) { /* wait for INTR bit as advised by Intel */ timeout = 0; do { @@ -402,6 +406,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, } outb_p(temp, SMBHSTSTS); } +#endif result = 0; END: if (command == I2C_SMBUS_I2C_BLOCK_DATA) { @@ -416,13 +421,14 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data * data) { - int hwpec; + int hwpec = 0; int block = 0; int ret, xact = 0; - hwpec = isich4 && (flags & I2C_CLIENT_PEC) - && size != I2C_SMBUS_QUICK - && size != I2C_SMBUS_I2C_BLOCK_DATA; +#ifdef HAVE_PEC + if(isich4) + hwpec = (flags & I2C_CLIENT_PEC) != 0; +#endif switch (size) { case I2C_SMBUS_QUICK: @@ -457,6 +463,11 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, break; case I2C_SMBUS_BLOCK_DATA: case I2C_SMBUS_I2C_BLOCK_DATA: +#ifdef HAVE_PEC + case I2C_SMBUS_BLOCK_DATA_PEC: + if(hwpec && size == I2C_SMBUS_BLOCK_DATA) + size = I2C_SMBUS_BLOCK_DATA_PEC; +#endif outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(command, SMBHSTCMD); @@ -468,18 +479,27 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, return -1; } - if (hwpec) - outb_p(1, SMBAUXCTL); /* enable hardware PEC */ - +#ifdef HAVE_PEC + if(isich4 && hwpec) { + if(size != I2C_SMBUS_QUICK && + size != I2C_SMBUS_I2C_BLOCK_DATA) + outb_p(1, SMBAUXCTL); /* enable HW PEC */ + } +#endif if(block) - ret = i801_block_transaction(data, read_write, size, hwpec); + ret = i801_block_transaction(data, read_write, size); else { outb_p(xact | ENABLE_INT9, SMBHSTCNT); ret = i801_transaction(); } - if (hwpec) - outb_p(0, SMBAUXCTL); /* disable hardware PEC */ +#ifdef HAVE_PEC + if(isich4 && hwpec) { + if(size != I2C_SMBUS_QUICK && + size != I2C_SMBUS_I2C_BLOCK_DATA) + outb_p(0, SMBAUXCTL); + } +#endif if(block) return ret; @@ -506,7 +526,12 @@ static u32 i801_func(struct i2c_adapter *adapter) return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK - | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0); +#ifdef HAVE_PEC + | (isich4 ? I2C_FUNC_SMBUS_BLOCK_DATA_PEC | + I2C_FUNC_SMBUS_HWPEC_CALC + : 0) +#endif + ; } static struct i2c_algorithm smbus_algorithm = { @@ -518,6 +543,7 @@ static struct i2c_adapter i801_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; static struct pci_device_id i801_ids[] = { @@ -560,7 +586,6 @@ static void __devexit i801_remove(struct pci_dev *dev) } static struct pci_driver i801_driver = { - .owner = THIS_MODULE, .name = "i801_smbus", .id_table = i801_ids, .probe = i801_probe, diff --git a/trunk/drivers/i2c/busses/i2c-i810.c b/trunk/drivers/i2c/busses/i2c-i810.c index 52bc30593bd7..0ff7016e0629 100644 --- a/trunk/drivers/i2c/busses/i2c-i810.c +++ b/trunk/drivers/i2c/busses/i2c-i810.c @@ -32,7 +32,6 @@ i810AB 7123 i810E 7125 i815 1132 - i845G 2562 */ #include @@ -233,7 +232,6 @@ static void __devexit i810_remove(struct pci_dev *dev) } static struct pci_driver i810_driver = { - .owner = THIS_MODULE, .name = "i810_smbus", .id_table = i810_ids, .probe = i810_probe, diff --git a/trunk/drivers/i2c/busses/i2c-ibm_iic.c b/trunk/drivers/i2c/busses/i2c-ibm_iic.c index 1a587253d716..a3ed9590f028 100644 --- a/trunk/drivers/i2c/busses/i2c-ibm_iic.c +++ b/trunk/drivers/i2c/busses/i2c-ibm_iic.c @@ -672,12 +672,13 @@ static int __devinit iic_probe(struct ocp_device *ocp){ printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", ocp->def->index); - if (!(dev = kzalloc(sizeof(*dev), GFP_KERNEL))) { + if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){ printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n", ocp->def->index); return -ENOMEM; } + memset(dev, 0, sizeof(*dev)); dev->idx = ocp->def->index; ocp_set_drvdata(ocp, dev); diff --git a/trunk/drivers/i2c/busses/i2c-iop3xx.c b/trunk/drivers/i2c/busses/i2c-iop3xx.c index 9888fae1f37a..7bd9102db701 100644 --- a/trunk/drivers/i2c/busses/i2c-iop3xx.c +++ b/trunk/drivers/i2c/busses/i2c-iop3xx.c @@ -43,7 +43,7 @@ #include "i2c-iop3xx.h" /* global unit counter */ -static int i2c_id; +static int i2c_id = 0; static inline unsigned char iic_cook_addr(struct i2c_msg *msg) @@ -440,17 +440,19 @@ iop3xx_i2c_probe(struct device *dev) struct i2c_adapter *new_adapter; struct i2c_algo_iop3xx_data *adapter_data; - new_adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); + new_adapter = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); if (!new_adapter) { ret = -ENOMEM; goto out; } + memset((void*)new_adapter, 0, sizeof(*new_adapter)); - adapter_data = kzalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); + adapter_data = kmalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); if (!adapter_data) { ret = -ENOMEM; goto free_adapter; } + memset((void*)adapter_data, 0, sizeof(*adapter_data)); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -523,7 +525,6 @@ iop3xx_i2c_probe(struct device *dev) static struct device_driver iop3xx_i2c_driver = { - .owner = THIS_MODULE, .name = "IOP3xx-I2C", .bus = &platform_bus_type, .probe = iop3xx_i2c_probe, diff --git a/trunk/drivers/i2c/busses/i2c-isa.c b/trunk/drivers/i2c/busses/i2c-isa.c index 4fdc02411609..bdc6806dafae 100644 --- a/trunk/drivers/i2c/busses/i2c-isa.c +++ b/trunk/drivers/i2c/busses/i2c-isa.c @@ -92,7 +92,6 @@ int i2c_isa_add_driver(struct i2c_driver *driver) /* Add the driver to the list of i2c drivers in the driver core */ driver->driver.name = driver->name; - driver->driver.owner = driver->owner; driver->driver.bus = &i2c_bus_type; driver->driver.probe = i2c_isa_device_probe; driver->driver.remove = i2c_isa_device_remove; diff --git a/trunk/drivers/i2c/busses/i2c-ixp2000.c b/trunk/drivers/i2c/busses/i2c-ixp2000.c index 42016ee6ef13..1956af382cd8 100644 --- a/trunk/drivers/i2c/busses/i2c-ixp2000.c +++ b/trunk/drivers/i2c/busses/i2c-ixp2000.c @@ -36,8 +36,6 @@ #include /* Pick up IXP2000-specific bits */ #include -static struct device_driver ixp2000_i2c_driver; - static inline int ixp2000_scl_pin(void *data) { return ((struct ixp2000_i2c_pins*)data)->scl_pin; @@ -106,10 +104,11 @@ static int ixp2000_i2c_probe(struct device *dev) struct platform_device *plat_dev = to_platform_device(dev); struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; struct ixp2000_i2c_data *drv_data = - kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); + kmalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); if (!drv_data) return -ENOMEM; + memzero(drv_data, sizeof(*drv_data)); drv_data->gpio_pins = gpio; drv_data->algo_data.data = gpio; @@ -122,8 +121,6 @@ static int ixp2000_i2c_probe(struct device *dev) drv_data->algo_data.timeout = 100; drv_data->adapter.id = I2C_HW_B_IXP2000, - strlcpy(drv_data->adapter.name, ixp2000_i2c_driver.name, - I2C_NAME_SIZE); drv_data->adapter.algo_data = &drv_data->algo_data, drv_data->adapter.dev.parent = &plat_dev->dev; @@ -145,7 +142,6 @@ static int ixp2000_i2c_probe(struct device *dev) } static struct device_driver ixp2000_i2c_driver = { - .owner = THIS_MODULE, .name = "IXP2000-I2C", .bus = &platform_bus_type, .probe = ixp2000_i2c_probe, diff --git a/trunk/drivers/i2c/busses/i2c-ixp4xx.c b/trunk/drivers/i2c/busses/i2c-ixp4xx.c index 69303ab65e04..f6f5ca31fdba 100644 --- a/trunk/drivers/i2c/busses/i2c-ixp4xx.c +++ b/trunk/drivers/i2c/busses/i2c-ixp4xx.c @@ -35,8 +35,6 @@ #include /* Pick up IXP4xx-specific bits */ -static struct device_driver ixp4xx_i2c_driver; - static inline int ixp4xx_scl_pin(void *data) { return ((struct ixp4xx_i2c_pins*)data)->scl_pin; @@ -107,11 +105,12 @@ static int ixp4xx_i2c_probe(struct device *dev) struct platform_device *plat_dev = to_platform_device(dev); struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; struct ixp4xx_i2c_data *drv_data = - kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); + kmalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); if(!drv_data) return -ENOMEM; + memzero(drv_data, sizeof(struct ixp4xx_i2c_data)); drv_data->gpio_pins = gpio; /* @@ -130,8 +129,6 @@ static int ixp4xx_i2c_probe(struct device *dev) drv_data->algo_data.timeout = 100; drv_data->adapter.id = I2C_HW_B_IXP4XX; - strlcpy(drv_data->adapter.name, ixp4xx_i2c_driver.name, - I2C_NAME_SIZE); drv_data->adapter.algo_data = &drv_data->algo_data; drv_data->adapter.dev.parent = &plat_dev->dev; @@ -154,7 +151,6 @@ static int ixp4xx_i2c_probe(struct device *dev) } static struct device_driver ixp4xx_i2c_driver = { - .owner = THIS_MODULE, .name = "IXP4XX-I2C", .bus = &platform_bus_type, .probe = ixp4xx_i2c_probe, diff --git a/trunk/drivers/i2c/busses/i2c-keywest.c b/trunk/drivers/i2c/busses/i2c-keywest.c index d61f748278fc..eff5896ce865 100644 --- a/trunk/drivers/i2c/busses/i2c-keywest.c +++ b/trunk/drivers/i2c/busses/i2c-keywest.c @@ -535,12 +535,13 @@ create_iface(struct device_node *np, struct device *dev) tsize = sizeof(struct keywest_iface) + (sizeof(struct keywest_chan) + 4) * nchan; - iface = kzalloc(tsize, GFP_KERNEL); + iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL); if (iface == NULL) { printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); pmac_low_i2c_unlock(np); return -ENOMEM; } + memset(iface, 0, tsize); spin_lock_init(&iface->lock); init_completion(&iface->complete); iface->node = of_node_get(np); @@ -715,7 +716,6 @@ static struct of_device_id i2c_keywest_match[] = static struct macio_driver i2c_keywest_macio_driver = { - .owner = THIS_MODULE, .name = "i2c-keywest", .match_table = i2c_keywest_match, .probe = create_iface_macio, @@ -724,7 +724,6 @@ static struct macio_driver i2c_keywest_macio_driver = static struct of_platform_driver i2c_keywest_of_platform_driver = { - .owner = THIS_MODULE, .name = "i2c-keywest", .match_table = i2c_keywest_match, .probe = create_iface_of_platform, diff --git a/trunk/drivers/i2c/busses/i2c-mpc.c b/trunk/drivers/i2c/busses/i2c-mpc.c index 8491633005b8..f065583ddcf1 100644 --- a/trunk/drivers/i2c/busses/i2c-mpc.c +++ b/trunk/drivers/i2c/busses/i2c-mpc.c @@ -296,9 +296,10 @@ static int fsl_i2c_probe(struct device *device) pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; - if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) { + if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { return -ENOMEM; } + memset(i2c, 0, sizeof(*i2c)); i2c->irq = platform_get_irq(pdev, 0); i2c->flags = pdata->device_flags; @@ -360,7 +361,6 @@ static int fsl_i2c_remove(struct device *device) /* Structure for a device driver */ static struct device_driver fsl_i2c_driver = { - .owner = THIS_MODULE, .name = "fsl-i2c", .bus = &platform_bus_type, .probe = fsl_i2c_probe, diff --git a/trunk/drivers/i2c/busses/i2c-mv64xxx.c b/trunk/drivers/i2c/busses/i2c-mv64xxx.c index d0d2a6f1386e..99abca45fece 100644 --- a/trunk/drivers/i2c/busses/i2c-mv64xxx.c +++ b/trunk/drivers/i2c/busses/i2c-mv64xxx.c @@ -500,10 +500,13 @@ mv64xxx_i2c_probe(struct device *dev) if ((pd->id != 0) || !pdata) return -ENODEV; - drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); + drv_data = kmalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); + if (!drv_data) return -ENOMEM; + memset(drv_data, 0, sizeof(struct mv64xxx_i2c_data)); + if (mv64xxx_i2c_map_regs(pd, drv_data)) { rc = -ENODEV; goto exit_kfree; @@ -567,7 +570,6 @@ mv64xxx_i2c_remove(struct device *dev) } static struct device_driver mv64xxx_i2c_driver = { - .owner = THIS_MODULE, .name = MV64XXX_I2C_CTLR_NAME, .bus = &platform_bus_type, .probe = mv64xxx_i2c_probe, diff --git a/trunk/drivers/i2c/busses/i2c-nforce2.c b/trunk/drivers/i2c/busses/i2c-nforce2.c index fd26036e68a3..fe9c0f42a2b7 100644 --- a/trunk/drivers/i2c/busses/i2c-nforce2.c +++ b/trunk/drivers/i2c/busses/i2c-nforce2.c @@ -97,7 +97,6 @@ struct nforce2_smbus { #define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a #define NVIDIA_SMB_PRTCL_PEC 0x80 -static struct pci_driver nforce2_driver; static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, @@ -114,6 +113,7 @@ static struct i2c_adapter nforce2_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; /* Return -1 on error. See smbus.h for more information */ @@ -188,6 +188,13 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); return -1; + case I2C_SMBUS_WORD_DATA_PEC: + case I2C_SMBUS_BLOCK_DATA_PEC: + case I2C_SMBUS_PROC_CALL_PEC: + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + dev_err(&adap->dev, "Unexpected software PEC transaction %d\n.", size); + return -1; + default: dev_err(&adap->dev, "Unsupported transaction %d\n", size); return -1; @@ -278,7 +285,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int reg, smbus->base = iobase & 0xfffc; smbus->size = 8; - if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { + if (!request_region(smbus->base, smbus->size, "nForce2 SMBus")) { dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", smbus->base, smbus->base+smbus->size-1, name); return -1; @@ -306,8 +313,10 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_ int res1, res2; /* we support 2 SMBus adapters */ - if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL))) + if (!(smbuses = (void *)kmalloc(2*sizeof(struct nforce2_smbus), + GFP_KERNEL))) return -ENOMEM; + memset (smbuses, 0, 2*sizeof(struct nforce2_smbus)); pci_set_drvdata(dev, smbuses); /* SMBus adapter 1 */ @@ -347,7 +356,6 @@ static void __devexit nforce2_remove(struct pci_dev *dev) } static struct pci_driver nforce2_driver = { - .owner = THIS_MODULE, .name = "nForce2_smbus", .id_table = nforce2_ids, .probe = nforce2_probe, diff --git a/trunk/drivers/i2c/busses/i2c-parport.c b/trunk/drivers/i2c/busses/i2c-parport.c index 2854d858fc9b..71a2502fe069 100644 --- a/trunk/drivers/i2c/busses/i2c-parport.c +++ b/trunk/drivers/i2c/busses/i2c-parport.c @@ -155,11 +155,12 @@ static void i2c_parport_attach (struct parport *port) { struct i2c_par *adapter; - adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL); + adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL); if (adapter == NULL) { - printk(KERN_ERR "i2c-parport: Failed to kzalloc\n"); + printk(KERN_ERR "i2c-parport: Failed to kmalloc\n"); return; } + memset(adapter, 0x00, sizeof(struct i2c_par)); pr_debug("i2c-parport: attaching to %s\n", port->name); adapter->pdev = parport_register_device(port, "i2c-parport", @@ -231,7 +232,7 @@ static void i2c_parport_detach (struct parport *port) } } -static struct parport_driver i2c_parport_driver = { +static struct parport_driver i2c_driver = { .name = "i2c-parport", .attach = i2c_parport_attach, .detach = i2c_parport_detach, @@ -249,12 +250,12 @@ static int __init i2c_parport_init(void) type = 0; } - return parport_register_driver(&i2c_parport_driver); + return parport_register_driver(&i2c_driver); } static void __exit i2c_parport_exit(void) { - parport_unregister_driver(&i2c_parport_driver); + parport_unregister_driver(&i2c_driver); } MODULE_AUTHOR("Jean Delvare "); diff --git a/trunk/drivers/i2c/busses/i2c-piix4.c b/trunk/drivers/i2c/busses/i2c-piix4.c index 7d63eec423fe..6d48a4da7bed 100644 --- a/trunk/drivers/i2c/busses/i2c-piix4.c +++ b/trunk/drivers/i2c/busses/i2c-piix4.c @@ -90,13 +90,13 @@ struct sd { /* If force is set to anything different from 0, we forcibly enable the PIIX4. DANGEROUS! */ -static int force; +static int force = 0; module_param (force, int, 0); MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!"); /* If force_addr is set to anything different from 0, we forcibly enable the PIIX4 at the given address. VERY DANGEROUS! */ -static int force_addr; +static int force_addr = 0; module_param (force_addr, int, 0); MODULE_PARM_DESC(force_addr, "Forcibly enable the PIIX4 at the given address. " @@ -104,15 +104,14 @@ MODULE_PARM_DESC(force_addr, /* If fix_hstcfg is set to anything different from 0, we reset one of the registers to be a valid value. */ -static int fix_hstcfg; +static int fix_hstcfg = 0; module_param (fix_hstcfg, int, 0); MODULE_PARM_DESC(fix_hstcfg, "Fix config register. Needed on some boards (Force CPCI735)."); static int piix4_transaction(void); -static unsigned short piix4_smba; -static struct pci_driver piix4_driver; +static unsigned short piix4_smba = 0; static struct i2c_adapter piix4_adapter; static struct dmi_system_id __devinitdata piix4_dmi_table[] = { @@ -158,7 +157,7 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, } } - if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) { + if (!request_region(piix4_smba, SMBIOSIZE, "piix4-smbus")) { dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", piix4_smba); return -ENODEV; @@ -408,6 +407,7 @@ static struct i2c_adapter piix4_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; static struct pci_device_id piix4_ids[] = { @@ -462,7 +462,6 @@ static void __devexit piix4_remove(struct pci_dev *dev) } static struct pci_driver piix4_driver = { - .owner = THIS_MODULE, .name = "piix4_smbus", .id_table = piix4_ids, .probe = piix4_probe, diff --git a/trunk/drivers/i2c/busses/i2c-pmac-smu.c b/trunk/drivers/i2c/busses/i2c-pmac-smu.c index bfefe7f7a53d..8a9f5648a23d 100644 --- a/trunk/drivers/i2c/busses/i2c-pmac-smu.c +++ b/trunk/drivers/i2c/busses/i2c-pmac-smu.c @@ -211,11 +211,12 @@ static int create_iface(struct device_node *np, struct device *dev) } busid = *reg; - iface = kzalloc(sizeof(struct smu_iface), GFP_KERNEL); + iface = kmalloc(sizeof(struct smu_iface), GFP_KERNEL); if (iface == NULL) { printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n"); return -ENOMEM; } + memset(iface, 0, sizeof(struct smu_iface)); init_completion(&iface->complete); iface->busid = busid; diff --git a/trunk/drivers/i2c/busses/i2c-prosavage.c b/trunk/drivers/i2c/busses/i2c-prosavage.c index 42cb1d8ca659..83fd16d61ce5 100644 --- a/trunk/drivers/i2c/busses/i2c-prosavage.c +++ b/trunk/drivers/i2c/busses/i2c-prosavage.c @@ -83,6 +83,11 @@ struct s_i2c_chip { /* * i2c configuration */ +#ifndef I2C_HW_B_S3VIA +#define I2C_HW_B_S3VIA 0x18 /* S3VIA ProSavage adapter */ +#endif + +/* delays */ #define CYCLE_DELAY 10 #define TIMEOUT (HZ / 2) @@ -236,12 +241,14 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic struct s_i2c_chip *chip; struct s_i2c_bus *bus; - pci_set_drvdata(dev, kzalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); + pci_set_drvdata(dev, kmalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); chip = (struct s_i2c_chip *)pci_get_drvdata(dev); if (chip == NULL) { return -ENOMEM; } + memset(chip, 0, sizeof(struct s_i2c_chip)); + base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK; len = dev->resource[0].end - base + 1; chip->mmio = ioremap_nocache(base, len); @@ -301,7 +308,6 @@ static struct pci_device_id prosavage_pci_tbl[] = { MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl); static struct pci_driver prosavage_driver = { - .owner = THIS_MODULE, .name = "prosavage_smbus", .id_table = prosavage_pci_tbl, .probe = prosavage_probe, diff --git a/trunk/drivers/i2c/busses/i2c-s3c2410.c b/trunk/drivers/i2c/busses/i2c-s3c2410.c index 6ced28e90070..69fa282df2d5 100644 --- a/trunk/drivers/i2c/busses/i2c-s3c2410.c +++ b/trunk/drivers/i2c/busses/i2c-s3c2410.c @@ -896,7 +896,6 @@ static int s3c24xx_i2c_resume(struct device *dev) /* device driver for platform bus bits */ static struct device_driver s3c2410_i2c_driver = { - .owner = THIS_MODULE, .name = "s3c2410-i2c", .bus = &platform_bus_type, .probe = s3c24xx_i2c_probe, @@ -905,7 +904,6 @@ static struct device_driver s3c2410_i2c_driver = { }; static struct device_driver s3c2440_i2c_driver = { - .owner = THIS_MODULE, .name = "s3c2440-i2c", .bus = &platform_bus_type, .probe = s3c24xx_i2c_probe, diff --git a/trunk/drivers/i2c/busses/i2c-savage4.c b/trunk/drivers/i2c/busses/i2c-savage4.c index aebe87ba4033..0c8518298e4d 100644 --- a/trunk/drivers/i2c/busses/i2c-savage4.c +++ b/trunk/drivers/i2c/busses/i2c-savage4.c @@ -179,7 +179,6 @@ static void __devexit savage4_remove(struct pci_dev *dev) } static struct pci_driver savage4_driver = { - .owner = THIS_MODULE, .name = "savage4_smbus", .id_table = savage4_ids, .probe = savage4_probe, diff --git a/trunk/drivers/i2c/busses/i2c-sis5595.c b/trunk/drivers/i2c/busses/i2c-sis5595.c index 3ad27c3ba15b..080318d6f54b 100644 --- a/trunk/drivers/i2c/busses/i2c-sis5595.c +++ b/trunk/drivers/i2c/busses/i2c-sis5595.c @@ -123,12 +123,11 @@ static int blacklist[] = { /* If force_addr is set to anything different from 0, we forcibly enable the device at the given address. */ -static u16 force_addr; +static u16 force_addr = 0; module_param(force_addr, ushort, 0); MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); -static struct pci_driver sis5595_driver; -static unsigned short sis5595_base; +static unsigned short sis5595_base = 0; static u8 sis5595_read(u8 reg) { @@ -173,8 +172,7 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) /* NB: We grab just the two SMBus registers here, but this may still * interfere with ACPI :-( */ - if (!request_region(sis5595_base + SMB_INDEX, 2, - sis5595_driver.name)) { + if (!request_region(sis5595_base + SMB_INDEX, 2, "sis5595-smbus")) { dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1); return -ENODEV; @@ -366,6 +364,7 @@ static struct i2c_algorithm smbus_algorithm = { static struct i2c_adapter sis5595_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, + .name = "unset", .algo = &smbus_algorithm, }; @@ -398,7 +397,6 @@ static void __devexit sis5595_remove(struct pci_dev *dev) } static struct pci_driver sis5595_driver = { - .owner = THIS_MODULE, .name = "sis5595_smbus", .id_table = sis5595_ids, .probe = sis5595_probe, diff --git a/trunk/drivers/i2c/busses/i2c-sis630.c b/trunk/drivers/i2c/busses/i2c-sis630.c index 7f49e5fd3ff0..86f0f448fa0b 100644 --- a/trunk/drivers/i2c/busses/i2c-sis630.c +++ b/trunk/drivers/i2c/busses/i2c-sis630.c @@ -92,8 +92,6 @@ #define SIS630_PCALL 0x04 #define SIS630_BLOCK_DATA 0x05 -static struct pci_driver sis630_driver; - /* insmod parameters */ static int high_clock; static int force; @@ -103,7 +101,7 @@ module_param(force, bool, 0); MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!"); /* acpi base address */ -static unsigned short acpi_base; +static unsigned short acpi_base = 0; /* supported chips */ static int supported[] = { @@ -434,8 +432,7 @@ static int sis630_setup(struct pci_dev *sis630_dev) dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base); /* Everything is happy, let's grab the memory and set things up. */ - if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, - sis630_driver.name)) { + if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, "sis630-smbus")) { dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); goto exit; @@ -458,6 +455,7 @@ static struct i2c_algorithm smbus_algorithm = { static struct i2c_adapter sis630_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, + .name = "unset", .algo = &smbus_algorithm, }; @@ -496,7 +494,6 @@ static void __devexit sis630_remove(struct pci_dev *dev) static struct pci_driver sis630_driver = { - .owner = THIS_MODULE, .name = "sis630_smbus", .id_table = sis630_ids, .probe = sis630_probe, diff --git a/trunk/drivers/i2c/busses/i2c-sis96x.c b/trunk/drivers/i2c/busses/i2c-sis96x.c index 6a134c091324..ead2ff3cf60e 100644 --- a/trunk/drivers/i2c/busses/i2c-sis96x.c +++ b/trunk/drivers/i2c/busses/i2c-sis96x.c @@ -82,9 +82,8 @@ #define SIS96x_PROC_CALL 0x04 #define SIS96x_BLOCK_DATA 0x05 -static struct pci_driver sis96x_driver; static struct i2c_adapter sis96x_adapter; -static u16 sis96x_smbus_base; +static u16 sis96x_smbus_base = 0; static inline u8 sis96x_read(u8 reg) { @@ -258,6 +257,7 @@ static struct i2c_adapter sis96x_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; static struct pci_device_id sis96x_ids[] = { @@ -294,8 +294,7 @@ static int __devinit sis96x_probe(struct pci_dev *dev, sis96x_smbus_base); /* Everything is happy, let's grab the memory and set things up. */ - if (!request_region(sis96x_smbus_base, SMB_IOSIZE, - sis96x_driver.name)) { + if (!request_region(sis96x_smbus_base, SMB_IOSIZE, "sis96x-smbus")) { dev_err(&dev->dev, "SMBus registers 0x%04x-0x%04x " "already in use!\n", sis96x_smbus_base, sis96x_smbus_base + SMB_IOSIZE - 1); @@ -329,7 +328,6 @@ static void __devexit sis96x_remove(struct pci_dev *dev) } static struct pci_driver sis96x_driver = { - .owner = THIS_MODULE, .name = "sis96x_smbus", .id_table = sis96x_ids, .probe = sis96x_probe, diff --git a/trunk/drivers/i2c/busses/i2c-via.c b/trunk/drivers/i2c/busses/i2c-via.c index 544a38e64394..040b8abeabba 100644 --- a/trunk/drivers/i2c/busses/i2c-via.c +++ b/trunk/drivers/i2c/busses/i2c-via.c @@ -43,9 +43,9 @@ /* io-region reservation */ #define IOSPACE 0x06 +#define IOTEXT "via-i2c" -static struct pci_driver vt586b_driver; -static u16 pm_io_base; +static u16 pm_io_base = 0; /* It does not appear from the datasheet that the GPIO pins are @@ -130,7 +130,7 @@ static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_i pci_read_config_word(dev, base, &pm_io_base); pm_io_base &= (0xff << 8); - if (!request_region(I2C_DIR, IOSPACE, vt586b_driver.name)) { + if (!request_region(I2C_DIR, IOSPACE, IOTEXT)) { dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE); return -ENODEV; } @@ -159,7 +159,6 @@ static void __devexit vt586b_remove(struct pci_dev *dev) static struct pci_driver vt586b_driver = { - .owner = THIS_MODULE, .name = "vt586b_smbus", .id_table = vt586b_ids, .probe = vt586b_probe, diff --git a/trunk/drivers/i2c/busses/i2c-viapro.c b/trunk/drivers/i2c/busses/i2c-viapro.c index c9366b504833..99d209e0485a 100644 --- a/trunk/drivers/i2c/busses/i2c-viapro.c +++ b/trunk/drivers/i2c/busses/i2c-viapro.c @@ -1,10 +1,9 @@ /* i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware monitoring - Copyright (c) 1998 - 2002 Frodo Looijaard , + Copyright (c) 1998 - 2002 Frodo Looijaard , Philip Edelbrock , Kyösti Mälkki , Mark D. Studebaker - Copyright (C) 2005 Jean Delvare This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,19 +21,15 @@ */ /* - Supports the following VIA south bridges: - - Chip name PCI ID REV I2C block - VT82C596A 0x3050 no - VT82C596B 0x3051 no - VT82C686A 0x3057 0x30 no - VT82C686B 0x3057 0x40 yes - VT8231 0x8235 no? - VT8233 0x3074 yes - VT8233A 0x3147 yes? - VT8235 0x3177 yes - VT8237R 0x3227 yes - + Supports Via devices: + 82C596A/B (0x3050) + 82C596B (0x3051) + 82C686A/B + 8231 + 8233 + 8233A (0x3147 and 0x3177) + 8235 + 8237 Note: we assume there can only be one device, with one SMBus interface. */ @@ -43,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -50,37 +46,48 @@ static struct pci_dev *vt596_pdev; -#define SMBBA1 0x90 -#define SMBBA2 0x80 -#define SMBBA3 0xD0 +#define SMBBA1 0x90 +#define SMBBA2 0x80 +#define SMBBA3 0xD0 /* SMBus address offsets */ static unsigned short vt596_smba; #define SMBHSTSTS (vt596_smba + 0) +#define SMBHSLVSTS (vt596_smba + 1) #define SMBHSTCNT (vt596_smba + 2) #define SMBHSTCMD (vt596_smba + 3) #define SMBHSTADD (vt596_smba + 4) #define SMBHSTDAT0 (vt596_smba + 5) #define SMBHSTDAT1 (vt596_smba + 6) #define SMBBLKDAT (vt596_smba + 7) +#define SMBSLVCNT (vt596_smba + 8) +#define SMBSHDWCMD (vt596_smba + 9) +#define SMBSLVEVT (vt596_smba + 0xA) +#define SMBSLVDAT (vt596_smba + 0xC) /* PCI Address Constants */ /* SMBus data in configuration space can be found in two places, - We try to select the better one */ + We try to select the better one*/ + +static unsigned short smb_cf_hstcfg = 0xD2; -static unsigned short SMBHSTCFG = 0xD2; +#define SMBHSTCFG (smb_cf_hstcfg) +#define SMBSLVC (smb_cf_hstcfg + 1) +#define SMBSHDW1 (smb_cf_hstcfg + 2) +#define SMBSHDW2 (smb_cf_hstcfg + 3) +#define SMBREV (smb_cf_hstcfg + 4) /* Other settings */ #define MAX_TIMEOUT 500 +#define ENABLE_INT9 0 /* VT82C596 constants */ -#define VT596_QUICK 0x00 -#define VT596_BYTE 0x04 -#define VT596_BYTE_DATA 0x08 -#define VT596_WORD_DATA 0x0C -#define VT596_BLOCK_DATA 0x14 -#define VT596_I2C_BLOCK_DATA 0x34 +#define VT596_QUICK 0x00 +#define VT596_BYTE 0x04 +#define VT596_BYTE_DATA 0x08 +#define VT596_WORD_DATA 0x0C +#define VT596_BLOCK_DATA 0x14 /* If force is set to anything different from 0, we forcibly enable the @@ -98,65 +105,40 @@ MODULE_PARM_DESC(force_addr, "EXTREMELY DANGEROUS!"); -static struct pci_driver vt596_driver; static struct i2c_adapter vt596_adapter; -#define FEATURE_I2CBLOCK (1<<0) -static unsigned int vt596_features; - -#ifdef DEBUG -static void vt596_dump_regs(const char *msg, u8 size) -{ - dev_dbg(&vt596_adapter.dev, "%s: STS=%02x CNT=%02x CMD=%02x ADD=%02x " - "DAT=%02x,%02x\n", msg, inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), - inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), - inb_p(SMBHSTDAT1)); - - if (size == VT596_BLOCK_DATA - || size == VT596_I2C_BLOCK_DATA) { - int i; - - dev_dbg(&vt596_adapter.dev, "BLK="); - for (i = 0; i < I2C_SMBUS_BLOCK_MAX / 2; i++) - printk("%02x,", inb_p(SMBBLKDAT)); - printk("\n"); - dev_dbg(&vt596_adapter.dev, " "); - for (; i < I2C_SMBUS_BLOCK_MAX - 1; i++) - printk("%02x,", inb_p(SMBBLKDAT)); - printk("%02x\n", inb_p(SMBBLKDAT)); - } -} -#else -static inline void vt596_dump_regs(const char *msg, u8 size) { } -#endif - -/* Return -1 on error, 0 on success */ -static int vt596_transaction(u8 size) +/* Another internally used function */ +static int vt596_transaction(void) { int temp; int result = 0; int timeout = 0; - vt596_dump_regs("Transaction (pre)", size); + dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), + inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), + inb_p(SMBHSTDAT1)); /* Make sure the SMBus host is ready to start transmitting */ if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). " - "Resetting... ", temp); - + "Resetting...\n", temp); + outb_p(temp, SMBHSTSTS); if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { - printk("Failed! (0x%02x)\n", temp); + dev_dbg(&vt596_adapter.dev, "Failed! (0x%02x)\n", temp); + return -1; } else { - printk("Successful!\n"); + dev_dbg(&vt596_adapter.dev, "Successfull!\n"); } } - /* Start the transaction by setting bit 6 */ - outb_p(0x40 | (size & 0x3C), SMBHSTCNT); + /* start the transaction by setting bit 6 */ + outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); - /* We will always wait for a fraction of a second */ + /* We will always wait for a fraction of a second! + I don't know if VIA needs this, Intel did */ do { msleep(1); temp = inb_p(SMBHSTSTS); @@ -165,61 +147,77 @@ static int vt596_transaction(u8 size) /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { result = -1; - dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); + dev_dbg(&vt596_adapter.dev, "SMBus Timeout!\n"); } if (temp & 0x10) { result = -1; - dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n", - inb_p(SMBHSTCNT) & 0x3C); + dev_dbg(&vt596_adapter.dev, "Error: Failed bus transaction\n"); } if (temp & 0x08) { result = -1; - dev_err(&vt596_adapter.dev, "SMBus collision!\n"); + dev_info(&vt596_adapter.dev, "Bus collision! SMBus may be " + "locked until next hard\nreset. (sorry!)\n"); + /* Clock stops and slave is stuck in mid-transmission */ } if (temp & 0x04) { result = -1; - /* Quick commands are used to probe for chips, so - errors are expected, and we don't want to frighten the - user. */ - if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK) - dev_err(&vt596_adapter.dev, "Transaction error!\n"); + dev_dbg(&vt596_adapter.dev, "Error: no response!\n"); } - /* Resetting status register */ - if (temp & 0x1F) + if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { outb_p(temp, SMBHSTSTS); + if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { + dev_warn(&vt596_adapter.dev, "Failed reset at end " + "of transaction (%02x)\n", temp); + } + } - vt596_dump_regs("Transaction (post)", size); - + dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), + inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), + inb_p(SMBHSTDAT1)); + return result; } -/* Return -1 on error, 0 on success */ +/* Return -1 on error. */ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, - unsigned short flags, char read_write, u8 command, - int size, union i2c_smbus_data *data) + unsigned short flags, char read_write, u8 command, + int size, union i2c_smbus_data *data) { - int i; + int i, len; switch (size) { + case I2C_SMBUS_PROC_CALL: + dev_info(&vt596_adapter.dev, + "I2C_SMBUS_PROC_CALL not supported!\n"); + return -1; case I2C_SMBUS_QUICK: + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD); size = VT596_QUICK; break; case I2C_SMBUS_BYTE: + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD); if (read_write == I2C_SMBUS_WRITE) outb_p(command, SMBHSTCMD); size = VT596_BYTE; break; case I2C_SMBUS_BYTE_DATA: + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD); outb_p(command, SMBHSTCMD); if (read_write == I2C_SMBUS_WRITE) outb_p(data->byte, SMBHSTDAT0); size = VT596_BYTE_DATA; break; case I2C_SMBUS_WORD_DATA: + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD); outb_p(command, SMBHSTCMD); if (read_write == I2C_SMBUS_WRITE) { outb_p(data->word & 0xff, SMBHSTDAT0); @@ -227,33 +225,28 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, } size = VT596_WORD_DATA; break; - case I2C_SMBUS_I2C_BLOCK_DATA: - if (!(vt596_features & FEATURE_I2CBLOCK)) - goto exit_unsupported; - if (read_write == I2C_SMBUS_READ) - outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0); - /* Fall through */ case I2C_SMBUS_BLOCK_DATA: + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD); outb_p(command, SMBHSTCMD); if (read_write == I2C_SMBUS_WRITE) { - u8 len = data->block[0]; + len = data->block[0]; + if (len < 0) + len = 0; if (len > I2C_SMBUS_BLOCK_MAX) len = I2C_SMBUS_BLOCK_MAX; outb_p(len, SMBHSTDAT0); - inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ + i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ for (i = 1; i <= len; i++) outb_p(data->block[i], SMBBLKDAT); } - size = (size == I2C_SMBUS_I2C_BLOCK_DATA) ? - VT596_I2C_BLOCK_DATA : VT596_BLOCK_DATA; + size = VT596_BLOCK_DATA; break; - default: - goto exit_unsupported; } - outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD); + outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); - if (vt596_transaction(size)) /* Error in transaction */ + if (vt596_transaction()) /* Error in transaction */ return -1; if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) @@ -261,39 +254,35 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, switch (size) { case VT596_BYTE: + /* Where is the result put? I assume here it is in + * SMBHSTDAT0 but it might just as well be in the + * SMBHSTCMD. No clue in the docs + */ + data->byte = inb_p(SMBHSTDAT0); + break; case VT596_BYTE_DATA: data->byte = inb_p(SMBHSTDAT0); break; case VT596_WORD_DATA: data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); break; - case VT596_I2C_BLOCK_DATA: case VT596_BLOCK_DATA: data->block[0] = inb_p(SMBHSTDAT0); if (data->block[0] > I2C_SMBUS_BLOCK_MAX) data->block[0] = I2C_SMBUS_BLOCK_MAX; - inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ + i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ for (i = 1; i <= data->block[0]; i++) data->block[i] = inb_p(SMBBLKDAT); break; } return 0; - -exit_unsupported: - dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n", - size); - return -1; } static u32 vt596_func(struct i2c_adapter *adapter) { - u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | + return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA; - - if (vt596_features & FEATURE_I2CBLOCK) - func |= I2C_FUNC_SMBUS_I2C_BLOCK; - return func; } static struct i2c_algorithm smbus_algorithm = { @@ -305,6 +294,7 @@ static struct i2c_adapter vt596_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &smbus_algorithm, + .name = "unset", }; static int __devinit vt596_probe(struct pci_dev *pdev, @@ -312,7 +302,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, { unsigned char temp; int error = -ENODEV; - + /* Determine the address of the SMBus areas */ if (force_addr) { vt596_smba = force_addr & 0xfff0; @@ -321,12 +311,12 @@ static int __devinit vt596_probe(struct pci_dev *pdev, } if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) || - !(vt596_smba & 0x0001)) { + !(vt596_smba & 0x1)) { /* try 2nd address and config reg. for 596 */ if (id->device == PCI_DEVICE_ID_VIA_82C596_3 && !pci_read_config_word(pdev, SMBBA2, &vt596_smba) && - (vt596_smba & 0x0001)) { - SMBHSTCFG = 0x84; + (vt596_smba & 0x1)) { + smb_cf_hstcfg = 0x84; } else { /* no matches at all */ dev_err(&pdev->dev, "Cannot configure " @@ -343,10 +333,10 @@ static int __devinit vt596_probe(struct pci_dev *pdev, return -ENODEV; } -found: - if (!request_region(vt596_smba, 8, vt596_driver.name)) { + found: + if (!request_region(vt596_smba, 8, "viapro-smbus")) { dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n", - vt596_smba); + vt596_smba); return -ENODEV; } @@ -358,16 +348,16 @@ static int __devinit vt596_probe(struct pci_dev *pdev, pci_write_config_word(pdev, id->driver_data, vt596_smba); pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); dev_warn(&pdev->dev, "WARNING: SMBus interface set to new " - "address 0x%04x!\n", vt596_smba); - } else if (!(temp & 0x01)) { + "address 0x%04x!\n", vt596_smba); + } else if ((temp & 1) == 0) { if (force) { - /* NOTE: This assumes I/O space and other allocations - * WERE done by the Bios! Don't complain if your - * hardware does weird things after enabling this. - * :') Check for Bios updates before resorting to + /* NOTE: This assumes I/O space and other allocations + * WERE done by the Bios! Don't complain if your + * hardware does weird things after enabling this. + * :') Check for Bios updates before resorting to * this. */ - pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); + pci_write_config_byte(pdev, SMBHSTCFG, temp | 1); dev_info(&pdev->dev, "Enabling SMBus device\n"); } else { dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " @@ -377,28 +367,22 @@ static int __devinit vt596_probe(struct pci_dev *pdev, } } - dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); + if ((temp & 0x0E) == 8) + dev_dbg(&pdev->dev, "using Interrupt 9 for SMBus.\n"); + else if ((temp & 0x0E) == 0) + dev_dbg(&pdev->dev, "using Interrupt SMI# for SMBus.\n"); + else + dev_dbg(&pdev->dev, "Illegal Interrupt configuration " + "(or code out of date)!\n"); - switch (pdev->device) { - case PCI_DEVICE_ID_VIA_8237: - case PCI_DEVICE_ID_VIA_8235: - case PCI_DEVICE_ID_VIA_8233A: - case PCI_DEVICE_ID_VIA_8233_0: - vt596_features |= FEATURE_I2CBLOCK; - break; - case PCI_DEVICE_ID_VIA_82C686_4: - /* The VT82C686B (rev 0x40) does support I2C block - transactions, but the VT82C686A (rev 0x30) doesn't */ - if (!pci_read_config_byte(pdev, PCI_REVISION_ID, &temp) - && temp >= 0x40) - vt596_features |= FEATURE_I2CBLOCK; - break; - } + pci_read_config_byte(pdev, SMBREV, &temp); + dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp); + dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); vt596_adapter.dev.parent = &pdev->dev; snprintf(vt596_adapter.name, I2C_NAME_SIZE, - "SMBus Via Pro adapter at %04x", vt596_smba); - + "SMBus Via Pro adapter at %04x", vt596_smba); + vt596_pdev = pci_dev_get(pdev); if (i2c_add_adapter(&vt596_adapter)) { pci_dev_put(vt596_pdev); @@ -411,7 +395,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, */ return -ENODEV; -release_region: + release_region: release_region(vt596_smba, 8); return error; } @@ -436,10 +420,9 @@ static struct pci_device_id vt596_ids[] = { { 0, } }; -MODULE_DEVICE_TABLE(pci, vt596_ids); +MODULE_DEVICE_TABLE (pci, vt596_ids); static struct pci_driver vt596_driver = { - .owner = THIS_MODULE, .name = "vt596_smbus", .id_table = vt596_ids, .probe = vt596_probe, diff --git a/trunk/drivers/i2c/busses/i2c-voodoo3.c b/trunk/drivers/i2c/busses/i2c-voodoo3.c index 650c3ebde84c..b675773b0cc1 100644 --- a/trunk/drivers/i2c/busses/i2c-voodoo3.c +++ b/trunk/drivers/i2c/busses/i2c-voodoo3.c @@ -225,7 +225,6 @@ static void __devexit voodoo3_remove(struct pci_dev *dev) } static struct pci_driver voodoo3_driver = { - .owner = THIS_MODULE, .name = "voodoo3_smbus", .id_table = voodoo3_ids, .probe = voodoo3_probe, diff --git a/trunk/drivers/i2c/busses/scx200_acb.c b/trunk/drivers/i2c/busses/scx200_acb.c index d3478e084522..a1d580e05361 100644 --- a/trunk/drivers/i2c/busses/scx200_acb.c +++ b/trunk/drivers/i2c/busses/scx200_acb.c @@ -442,13 +442,14 @@ static int __init scx200_acb_create(int base, int index) int rc = 0; char description[64]; - iface = kzalloc(sizeof(*iface), GFP_KERNEL); + iface = kmalloc(sizeof(*iface), GFP_KERNEL); if (!iface) { printk(KERN_ERR NAME ": can't allocate memory\n"); rc = -ENOMEM; goto errout; } + memset(iface, 0, sizeof(*iface)); adapter = &iface->adapter; i2c_set_adapdata(adapter, iface); snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); diff --git a/trunk/drivers/i2c/chips/Kconfig b/trunk/drivers/i2c/chips/Kconfig index f9fae28f5612..6bd44a44cd28 100644 --- a/trunk/drivers/i2c/chips/Kconfig +++ b/trunk/drivers/i2c/chips/Kconfig @@ -126,13 +126,4 @@ config SENSORS_MAX6875 This driver can also be built as a module. If so, the module will be called max6875. -config RTC_X1205_I2C - tristate "Xicor X1205 RTC chip" - depends on I2C && EXPERIMENTAL - help - If you say yes here you get support for the Xicor X1205 RTC chip. - - This driver can also be built as a module. If so, the module - will be called x1205. - endmenu diff --git a/trunk/drivers/i2c/chips/Makefile b/trunk/drivers/i2c/chips/Makefile index 46178b57b1f1..a876dd42b860 100644 --- a/trunk/drivers/i2c/chips/Makefile +++ b/trunk/drivers/i2c/chips/Makefile @@ -13,7 +13,6 @@ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o obj-$(CONFIG_TPS65010) += tps65010.o -obj-$(CONFIG_RTC_X1205_I2C) += x1205.o ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) EXTRA_CFLAGS += -DDEBUG diff --git a/trunk/drivers/i2c/chips/ds1337.c b/trunk/drivers/i2c/chips/ds1337.c index 01b037007410..9d3175c03395 100644 --- a/trunk/drivers/i2c/chips/ds1337.c +++ b/trunk/drivers/i2c/chips/ds1337.c @@ -243,10 +243,11 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind) I2C_FUNC_I2C)) goto exit; - if (!(data = kzalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct ds1337_data)); INIT_LIST_HEAD(&data->list); /* The common I2C client data is placed right before the diff --git a/trunk/drivers/i2c/chips/ds1374.c b/trunk/drivers/i2c/chips/ds1374.c index da488b735abf..0936327a946d 100644 --- a/trunk/drivers/i2c/chips/ds1374.c +++ b/trunk/drivers/i2c/chips/ds1374.c @@ -167,8 +167,7 @@ static void ds1374_set_tlet(ulong arg) static ulong new_time; -static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, - (ulong) & new_time); +DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); int ds1374_set_rtc_time(ulong nowtime) { @@ -194,11 +193,13 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) struct i2c_client *client; int rc; - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (!client) return -ENOMEM; + memset(client, 0, sizeof(struct i2c_client)); strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); + client->flags = I2C_DF_NOTIFY; client->addr = addr; client->adapter = adap; client->driver = &ds1374_driver; diff --git a/trunk/drivers/i2c/chips/eeprom.c b/trunk/drivers/i2c/chips/eeprom.c index 4baf573fa04f..d58403a47908 100644 --- a/trunk/drivers/i2c/chips/eeprom.c +++ b/trunk/drivers/i2c/chips/eeprom.c @@ -88,8 +88,8 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_BLOCK_MAX) - if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_BLOCK_MAX) + for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_I2C_BLOCK_MAX) + if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_I2C_BLOCK_MAX) goto exit; } else { if (i2c_smbus_write_byte(client, slice << 5)) { @@ -155,7 +155,7 @@ static int eeprom_attach_adapter(struct i2c_adapter *adapter) } /* This function is called by i2c_probe */ -static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) +int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) { struct i2c_client *new_client; struct eeprom_data *data; @@ -171,10 +171,11 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | I2C_FUNC_SMBUS_BYTE)) goto exit; - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct eeprom_data)); new_client = &data->client; memset(data->data, 0xff, EEPROM_SIZE); diff --git a/trunk/drivers/i2c/chips/isp1301_omap.c b/trunk/drivers/i2c/chips/isp1301_omap.c index eaa4742e04fa..8ee56d4b3891 100644 --- a/trunk/drivers/i2c/chips/isp1301_omap.c +++ b/trunk/drivers/i2c/chips/isp1301_omap.c @@ -888,7 +888,6 @@ static int otg_remove(struct device *dev) } struct device_driver omap_otg_driver = { - .owner = THIS_MODULE, .name = "omap_otg", .bus = &platform_bus_type, .probe = otg_probe, diff --git a/trunk/drivers/i2c/chips/m41t00.c b/trunk/drivers/i2c/chips/m41t00.c index 3df309ae44a6..3f14528a52a9 100644 --- a/trunk/drivers/i2c/chips/m41t00.c +++ b/trunk/drivers/i2c/chips/m41t00.c @@ -174,11 +174,13 @@ m41t00_probe(struct i2c_adapter *adap, int addr, int kind) struct i2c_client *client; int rc; - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (!client) return -ENOMEM; + memset(client, 0, sizeof(struct i2c_client)); strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE); + client->flags = I2C_DF_NOTIFY; client->addr = addr; client->adapter = adap; client->driver = &m41t00_driver; diff --git a/trunk/drivers/i2c/chips/max6875.c b/trunk/drivers/i2c/chips/max6875.c index b376a006883c..9e1aeb69abf9 100644 --- a/trunk/drivers/i2c/chips/max6875.c +++ b/trunk/drivers/i2c/chips/max6875.c @@ -179,14 +179,16 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) if (address & 1) return 0; - if (!(data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL))) + if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) return -ENOMEM; + memset(data, 0, sizeof(struct max6875_data)); /* A fake client is created on the odd address */ - if (!(fake_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { + if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) { err = -ENOMEM; goto exit_kfree1; } + memset(fake_client, 0, sizeof(struct i2c_client)); /* Init real i2c_client */ real_client = &data->client; diff --git a/trunk/drivers/i2c/chips/pca9539.c b/trunk/drivers/i2c/chips/pca9539.c index 59a930346229..225577fdda4d 100644 --- a/trunk/drivers/i2c/chips/pca9539.c +++ b/trunk/drivers/i2c/chips/pca9539.c @@ -122,10 +122,11 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. */ - if (!(data = kzalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct pca9539_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/i2c/chips/pcf8574.c b/trunk/drivers/i2c/chips/pcf8574.c index c323c2de236c..6525743ff9fd 100644 --- a/trunk/drivers/i2c/chips/pcf8574.c +++ b/trunk/drivers/i2c/chips/pcf8574.c @@ -115,7 +115,7 @@ static int pcf8574_attach_adapter(struct i2c_adapter *adapter) } /* This function is called by i2c_probe */ -static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) +int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) { struct i2c_client *new_client; struct pcf8574_data *data; @@ -127,10 +127,11 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. */ - if (!(data = kzalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct pcf8574_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/i2c/chips/pcf8591.c b/trunk/drivers/i2c/chips/pcf8591.c index ce420a67560b..80f1df9a4500 100644 --- a/trunk/drivers/i2c/chips/pcf8591.c +++ b/trunk/drivers/i2c/chips/pcf8591.c @@ -166,7 +166,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter) } /* This function is called by i2c_probe */ -static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) +int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) { struct i2c_client *new_client; struct pcf8591_data *data; @@ -178,10 +178,11 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. */ - if (!(data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { + if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } + memset(data, 0, sizeof(struct pcf8591_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); diff --git a/trunk/drivers/i2c/chips/rtc8564.c b/trunk/drivers/i2c/chips/rtc8564.c index 916cdc1af23c..0b5385c892b1 100644 --- a/trunk/drivers/i2c/chips/rtc8564.c +++ b/trunk/drivers/i2c/chips/rtc8564.c @@ -148,16 +148,17 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind) {addr, I2C_M_RD, 2, data} }; - d = kzalloc(sizeof(struct rtc8564_data), GFP_KERNEL); + d = kmalloc(sizeof(struct rtc8564_data), GFP_KERNEL); if (!d) { ret = -ENOMEM; goto done; } + memset(d, 0, sizeof(struct rtc8564_data)); new_client = &d->client; strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); i2c_set_clientdata(new_client, d); - new_client->flags = I2C_CLIENT_ALLOW_USE; + new_client->flags = I2C_CLIENT_ALLOW_USE | I2C_DF_NOTIFY; new_client->addr = addr; new_client->adapter = adap; new_client->driver = &rtc8564_driver; diff --git a/trunk/drivers/i2c/chips/tps65010.c b/trunk/drivers/i2c/chips/tps65010.c index 280dd7a45db6..280e9638c0f8 100644 --- a/trunk/drivers/i2c/chips/tps65010.c +++ b/trunk/drivers/i2c/chips/tps65010.c @@ -500,10 +500,11 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) return 0; } - tps = kzalloc(sizeof *tps, GFP_KERNEL); + tps = kmalloc(sizeof *tps, GFP_KERNEL); if (!tps) return 0; + memset(tps, 0, sizeof *tps); init_MUTEX(&tps->lock); INIT_WORK(&tps->work, tps65010_work, tps); tps->irq = -1; diff --git a/trunk/drivers/i2c/chips/x1205.c b/trunk/drivers/i2c/chips/x1205.c deleted file mode 100644 index 7da366cdc18c..000000000000 --- a/trunk/drivers/i2c/chips/x1205.c +++ /dev/null @@ -1,698 +0,0 @@ -/* - * x1205.c - An i2c driver for the Xicor X1205 RTC - * Copyright 2004 Karen Spearel - * Copyright 2005 Alessandro Zummo - * - * please send all reports to: - * kas11 at tampabay dot rr dot com - * a dot zummo at towertech dot it - * - * based on the other drivers in this same directory. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define DRV_VERSION "0.9.9" - -/* Addresses to scan: none. This chip is located at - * 0x6f and uses a two bytes register addressing. - * Two bytes need to be written to read a single register, - * while most other chips just require one and take the second - * one as the data to be written. To prevent corrupting - * unknown chips, the user must explicitely set the probe parameter. - */ - -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -/* Insmod parameters */ -I2C_CLIENT_INSMOD; -I2C_CLIENT_MODULE_PARM(hctosys, - "Set the system time from the hardware clock upon initialization"); - -/* offsets into CCR area */ - -#define CCR_SEC 0 -#define CCR_MIN 1 -#define CCR_HOUR 2 -#define CCR_MDAY 3 -#define CCR_MONTH 4 -#define CCR_YEAR 5 -#define CCR_WDAY 6 -#define CCR_Y2K 7 - -#define X1205_REG_SR 0x3F /* status register */ -#define X1205_REG_Y2K 0x37 -#define X1205_REG_DW 0x36 -#define X1205_REG_YR 0x35 -#define X1205_REG_MO 0x34 -#define X1205_REG_DT 0x33 -#define X1205_REG_HR 0x32 -#define X1205_REG_MN 0x31 -#define X1205_REG_SC 0x30 -#define X1205_REG_DTR 0x13 -#define X1205_REG_ATR 0x12 -#define X1205_REG_INT 0x11 -#define X1205_REG_0 0x10 -#define X1205_REG_Y2K1 0x0F -#define X1205_REG_DWA1 0x0E -#define X1205_REG_YRA1 0x0D -#define X1205_REG_MOA1 0x0C -#define X1205_REG_DTA1 0x0B -#define X1205_REG_HRA1 0x0A -#define X1205_REG_MNA1 0x09 -#define X1205_REG_SCA1 0x08 -#define X1205_REG_Y2K0 0x07 -#define X1205_REG_DWA0 0x06 -#define X1205_REG_YRA0 0x05 -#define X1205_REG_MOA0 0x04 -#define X1205_REG_DTA0 0x03 -#define X1205_REG_HRA0 0x02 -#define X1205_REG_MNA0 0x01 -#define X1205_REG_SCA0 0x00 - -#define X1205_CCR_BASE 0x30 /* Base address of CCR */ -#define X1205_ALM0_BASE 0x00 /* Base address of ALARM0 */ - -#define X1205_SR_RTCF 0x01 /* Clock failure */ -#define X1205_SR_WEL 0x02 /* Write Enable Latch */ -#define X1205_SR_RWEL 0x04 /* Register Write Enable */ - -#define X1205_DTR_DTR0 0x01 -#define X1205_DTR_DTR1 0x02 -#define X1205_DTR_DTR2 0x04 - -#define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */ - -/* Prototypes */ -static int x1205_attach(struct i2c_adapter *adapter); -static int x1205_detach(struct i2c_client *client); -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind); -static int x1205_command(struct i2c_client *client, unsigned int cmd, - void *arg); - -static struct i2c_driver x1205_driver = { - .owner = THIS_MODULE, - .name = "x1205", - .flags = I2C_DF_NOTIFY, - .attach_adapter = &x1205_attach, - .detach_client = &x1205_detach, -}; - -struct x1205_data { - struct i2c_client client; - struct list_head list; - unsigned int epoch; -}; - -static const unsigned char days_in_mo[] = - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - -static LIST_HEAD(x1205_clients); - -/* Workaround until the I2C subsytem will allow to send - * commands to a specific client. This function will send the command - * to the first client. - */ -int x1205_do_command(unsigned int cmd, void *arg) -{ - struct list_head *walk; - struct list_head *tmp; - struct x1205_data *data; - - list_for_each_safe(walk, tmp, &x1205_clients) { - data = list_entry(walk, struct x1205_data, list); - return x1205_command(&data->client, cmd, arg); - } - - return -ENODEV; -} - -#define is_leap(year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) - -/* make sure the rtc_time values are in bounds */ -static int x1205_validate_tm(struct rtc_time *tm) -{ - int year = tm->tm_year + 1900; - - if ((tm->tm_year < 70) || (tm->tm_year > 255)) - return -EINVAL; - - if ((tm->tm_mon > 11) || (tm->tm_mday == 0)) - return -EINVAL; - - if (tm->tm_mday > days_in_mo[tm->tm_mon] - + ((tm->tm_mon == 1) && is_leap(year))) - return -EINVAL; - - if ((tm->tm_hour >= 24) || (tm->tm_min >= 60) || (tm->tm_sec >= 60)) - return -EINVAL; - - return 0; -} - -/* - * In the routines that deal directly with the x1205 hardware, we use - * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch - * Epoch is initialized as 2000. Time is set to UTC. - */ -static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, - u8 reg_base) -{ - unsigned char dt_addr[2] = { 0, reg_base }; - static unsigned char sr_addr[2] = { 0, X1205_REG_SR }; - - unsigned char buf[8], sr; - - struct i2c_msg msgs[] = { - { client->addr, 0, 2, sr_addr }, /* setup read ptr */ - { client->addr, I2C_M_RD, 1, &sr }, /* read status */ - { client->addr, 0, 2, dt_addr }, /* setup read ptr */ - { client->addr, I2C_M_RD, 8, buf }, /* read date */ - }; - - struct x1205_data *data = i2c_get_clientdata(client); - - /* read status register */ - if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); - return -EIO; - } - - /* check for battery failure */ - if (sr & X1205_SR_RTCF) { - dev_warn(&client->dev, - "Clock had a power failure, you must set the date.\n"); - return -EINVAL; - } - - /* read date registers */ - if ((i2c_transfer(client->adapter, &msgs[2], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); - return -EIO; - } - - dev_dbg(&client->dev, - "%s: raw read data - sec=%02x, min=%02x, hr=%02x, " - "mday=%02x, mon=%02x, year=%02x, wday=%02x, y2k=%02x\n", - __FUNCTION__, - buf[0], buf[1], buf[2], buf[3], - buf[4], buf[5], buf[6], buf[7]); - - tm->tm_sec = BCD2BIN(buf[CCR_SEC]); - tm->tm_min = BCD2BIN(buf[CCR_MIN]); - tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ - tm->tm_mday = BCD2BIN(buf[CCR_MDAY]); - tm->tm_mon = BCD2BIN(buf[CCR_MONTH]); - data->epoch = BCD2BIN(buf[CCR_Y2K]) * 100; - tm->tm_year = BCD2BIN(buf[CCR_YEAR]) + data->epoch - 1900; - tm->tm_wday = buf[CCR_WDAY]; - - dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " - "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, - tm->tm_sec, tm->tm_min, tm->tm_hour, - tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); - - return 0; -} - -static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, - int datetoo, u8 reg_base) -{ - int i, err, xfer; - - unsigned char buf[8]; - - static const unsigned char wel[3] = { 0, X1205_REG_SR, - X1205_SR_WEL }; - - static const unsigned char rwel[3] = { 0, X1205_REG_SR, - X1205_SR_WEL | X1205_SR_RWEL }; - - static const unsigned char diswe[3] = { 0, X1205_REG_SR, 0 }; - - struct x1205_data *data = i2c_get_clientdata(client); - - /* check if all values in the tm struct are correct */ - if ((err = x1205_validate_tm(tm)) < 0) - return err; - - dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " - "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, - tm->tm_sec, tm->tm_min, tm->tm_hour, - tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); - - buf[CCR_SEC] = BIN2BCD(tm->tm_sec); - buf[CCR_MIN] = BIN2BCD(tm->tm_min); - - /* set hour and 24hr bit */ - buf[CCR_HOUR] = BIN2BCD(tm->tm_hour) | X1205_HR_MIL; - - /* should we also set the date? */ - if (datetoo) { - buf[CCR_MDAY] = BIN2BCD(tm->tm_mday); - - /* month, 0 - 11 */ - buf[CCR_MONTH] = BIN2BCD(tm->tm_mon); - - /* year, since 1900 */ - buf[CCR_YEAR] = BIN2BCD(tm->tm_year + 1900 - data->epoch); - buf[CCR_WDAY] = tm->tm_wday & 0x07; - buf[CCR_Y2K] = BIN2BCD(data->epoch / 100); - } - - /* this sequence is required to unlock the chip */ - xfer = i2c_master_send(client, wel, 3); - if (xfer != 3) { - dev_err(&client->dev, "%s: wel - %d\n", __FUNCTION__, xfer); - return -EIO; - } - - xfer = i2c_master_send(client, rwel, 3); - if (xfer != 3) { - dev_err(&client->dev, "%s: rwel - %d\n", __FUNCTION__, xfer); - return -EIO; - } - - /* write register's data */ - for (i = 0; i < (datetoo ? 8 : 3); i++) { - unsigned char rdata[3] = { 0, reg_base + i, buf[i] }; - - xfer = i2c_master_send(client, rdata, 3); - if (xfer != 3) { - dev_err(&client->dev, - "%s: xfer=%d addr=%02x, data=%02x\n", - __FUNCTION__, - xfer, rdata[1], rdata[2]); - return -EIO; - } - }; - - /* disable further writes */ - xfer = i2c_master_send(client, diswe, 3); - if (xfer != 3) { - dev_err(&client->dev, "%s: diswe - %d\n", __FUNCTION__, xfer); - return -EIO; - } - - return 0; -} - -static int x1205_get_dtrim(struct i2c_client *client, int *trim) -{ - unsigned char dtr; - static unsigned char dtr_addr[2] = { 0, X1205_REG_DTR }; - - struct i2c_msg msgs[] = { - { client->addr, 0, 2, dtr_addr }, /* setup read ptr */ - { client->addr, I2C_M_RD, 1, &dtr }, /* read dtr */ - }; - - /* read dtr register */ - if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); - return -EIO; - } - - dev_dbg(&client->dev, "%s: raw dtr=%x\n", __FUNCTION__, dtr); - - *trim = 0; - - if (dtr & X1205_DTR_DTR0) - *trim += 20; - - if (dtr & X1205_DTR_DTR1) - *trim += 10; - - if (dtr & X1205_DTR_DTR2) - *trim = -*trim; - - return 0; -} - -static int x1205_get_atrim(struct i2c_client *client, int *trim) -{ - s8 atr; - static unsigned char atr_addr[2] = { 0, X1205_REG_ATR }; - - struct i2c_msg msgs[] = { - { client->addr, 0, 2, atr_addr }, /* setup read ptr */ - { client->addr, I2C_M_RD, 1, &atr }, /* read atr */ - }; - - /* read atr register */ - if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); - return -EIO; - } - - dev_dbg(&client->dev, "%s: raw atr=%x\n", __FUNCTION__, atr); - - /* atr is a two's complement value on 6 bits, - * perform sign extension. The formula is - * Catr = (atr * 0.25pF) + 11.00pF. - */ - if (atr & 0x20) - atr |= 0xC0; - - dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __FUNCTION__, atr, atr); - - *trim = (atr * 250) + 11000; - - dev_dbg(&client->dev, "%s: real=%d\n", __FUNCTION__, *trim); - - return 0; -} - -static int x1205_hctosys(struct i2c_client *client) -{ - int err; - - struct rtc_time tm; - struct timespec tv; - - err = x1205_command(client, X1205_CMD_GETDATETIME, &tm); - - if (err) { - dev_err(&client->dev, - "Unable to set the system clock\n"); - return err; - } - - /* IMPORTANT: the RTC only stores whole seconds. It is arbitrary - * whether it stores the most close value or the value with partial - * seconds truncated. However, it is important that we use it to store - * the truncated value. This is because otherwise it is necessary, - * in an rtc sync function, to read both xtime.tv_sec and - * xtime.tv_nsec. On some processors (i.e. ARM), an atomic read - * of >32bits is not possible. So storing the most close value would - * slow down the sync API. So here we have the truncated value and - * the best guess is to add 0.5s. - */ - - tv.tv_nsec = NSEC_PER_SEC >> 1; - - /* WARNING: this is not the C library 'mktime' call, it is a built in - * inline function from include/linux/time.h. It expects (requires) - * the month to be in the range 1-12 - */ - - tv.tv_sec = mktime(tm.tm_year + 1900, tm.tm_mon + 1, - tm.tm_mday, tm.tm_hour, - tm.tm_min, tm.tm_sec); - - do_settimeofday(&tv); - - dev_info(&client->dev, - "setting the system clock to %d-%d-%d %d:%d:%d\n", - tm.tm_year + 1900, tm.tm_mon + 1, - tm.tm_mday, tm.tm_hour, tm.tm_min, - tm.tm_sec); - - return 0; -} - -struct x1205_limit -{ - unsigned char reg; - unsigned char mask; - unsigned char min; - unsigned char max; -}; - -static int x1205_validate_client(struct i2c_client *client) -{ - int i, xfer; - - /* Probe array. We will read the register at the specified - * address and check if the given bits are zero. - */ - static const unsigned char probe_zero_pattern[] = { - /* register, mask */ - X1205_REG_SR, 0x18, - X1205_REG_DTR, 0xF8, - X1205_REG_ATR, 0xC0, - X1205_REG_INT, 0x18, - X1205_REG_0, 0xFF, - }; - - static const struct x1205_limit probe_limits_pattern[] = { - /* register, mask, min, max */ - { X1205_REG_Y2K, 0xFF, 19, 20 }, - { X1205_REG_DW, 0xFF, 0, 6 }, - { X1205_REG_YR, 0xFF, 0, 99 }, - { X1205_REG_MO, 0xFF, 0, 12 }, - { X1205_REG_DT, 0xFF, 0, 31 }, - { X1205_REG_HR, 0x7F, 0, 23 }, - { X1205_REG_MN, 0xFF, 0, 59 }, - { X1205_REG_SC, 0xFF, 0, 59 }, - { X1205_REG_Y2K1, 0xFF, 19, 20 }, - { X1205_REG_Y2K0, 0xFF, 19, 20 }, - }; - - /* check that registers have bits a 0 where expected */ - for (i = 0; i < ARRAY_SIZE(probe_zero_pattern); i += 2) { - unsigned char buf; - - unsigned char addr[2] = { 0, probe_zero_pattern[i] }; - - struct i2c_msg msgs[2] = { - { client->addr, 0, 2, addr }, - { client->addr, I2C_M_RD, 1, &buf }, - }; - - xfer = i2c_transfer(client->adapter, msgs, 2); - if (xfer != 2) { - dev_err(&client->adapter->dev, - "%s: could not read register %x\n", - __FUNCTION__, addr[1]); - - return -EIO; - } - - if ((buf & probe_zero_pattern[i+1]) != 0) { - dev_err(&client->adapter->dev, - "%s: register=%02x, zero pattern=%d, value=%x\n", - __FUNCTION__, addr[1], i, buf); - - return -ENODEV; - } - } - - /* check limits (only registers with bcd values) */ - for (i = 0; i < ARRAY_SIZE(probe_limits_pattern); i++) { - unsigned char reg, value; - - unsigned char addr[2] = { 0, probe_limits_pattern[i].reg }; - - struct i2c_msg msgs[2] = { - { client->addr, 0, 2, addr }, - { client->addr, I2C_M_RD, 1, ® }, - }; - - xfer = i2c_transfer(client->adapter, msgs, 2); - - if (xfer != 2) { - dev_err(&client->adapter->dev, - "%s: could not read register %x\n", - __FUNCTION__, addr[1]); - - return -EIO; - } - - value = BCD2BIN(reg & probe_limits_pattern[i].mask); - - if (value > probe_limits_pattern[i].max || - value < probe_limits_pattern[i].min) { - dev_dbg(&client->adapter->dev, - "%s: register=%x, lim pattern=%d, value=%d\n", - __FUNCTION__, addr[1], i, value); - - return -ENODEV; - } - } - - return 0; -} - -static int x1205_attach(struct i2c_adapter *adapter) -{ - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); - - return i2c_probe(adapter, &addr_data, x1205_probe); -} - -int x1205_direct_attach(int adapter_id, - struct i2c_client_address_data *address_data) -{ - int err; - struct i2c_adapter *adapter = i2c_get_adapter(adapter_id); - - if (adapter) { - err = i2c_probe(adapter, - address_data, x1205_probe); - - i2c_put_adapter(adapter); - - return err; - } - - return -ENODEV; -} - -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind) -{ - struct i2c_client *client; - struct x1205_data *data; - - int err = 0; - - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); - - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { - err = -ENODEV; - goto exit; - } - - if (!(data = kzalloc(sizeof(struct x1205_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - /* Initialize our structures */ - data->epoch = 2000; - - client = &data->client; - client->addr = address; - client->driver = &x1205_driver; - client->adapter = adapter; - - strlcpy(client->name, "x1205", I2C_NAME_SIZE); - - i2c_set_clientdata(client, data); - - /* Verify the chip is really an X1205 */ - if (kind < 0) { - if (x1205_validate_client(client) < 0) { - err = -ENODEV; - goto exit_kfree; - } - } - - /* Inform the i2c layer */ - if ((err = i2c_attach_client(client))) - goto exit_kfree; - - list_add(&data->list, &x1205_clients); - - dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - - /* If requested, set the system time */ - if (hctosys) - x1205_hctosys(client); - - return 0; - -exit_kfree: - kfree(data); - -exit: - return err; -} - -static int x1205_detach(struct i2c_client *client) -{ - int err; - struct x1205_data *data = i2c_get_clientdata(client); - - dev_dbg(&client->dev, "%s\n", __FUNCTION__); - - if ((err = i2c_detach_client(client))) - return err; - - list_del(&data->list); - - kfree(data); - - return 0; -} - -static int x1205_command(struct i2c_client *client, unsigned int cmd, - void *param) -{ - if (param == NULL) - return -EINVAL; - - if (!capable(CAP_SYS_TIME)) - return -EACCES; - - dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); - - switch (cmd) { - case X1205_CMD_GETDATETIME: - return x1205_get_datetime(client, param, X1205_CCR_BASE); - - case X1205_CMD_SETTIME: - return x1205_set_datetime(client, param, 0, - X1205_CCR_BASE); - - case X1205_CMD_SETDATETIME: - return x1205_set_datetime(client, param, 1, - X1205_CCR_BASE); - - case X1205_CMD_GETALARM: - return x1205_get_datetime(client, param, X1205_ALM0_BASE); - - case X1205_CMD_SETALARM: - return x1205_set_datetime(client, param, 1, - X1205_ALM0_BASE); - - case X1205_CMD_GETDTRIM: - return x1205_get_dtrim(client, param); - - case X1205_CMD_GETATRIM: - return x1205_get_atrim(client, param); - - default: - return -EINVAL; - } -} - -static int __init x1205_init(void) -{ - return i2c_add_driver(&x1205_driver); -} - -static void __exit x1205_exit(void) -{ - i2c_del_driver(&x1205_driver); -} - -MODULE_AUTHOR( - "Karen Spearel , " - "Alessandro Zummo "); -MODULE_DESCRIPTION("Xicor X1205 RTC driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - -EXPORT_SYMBOL_GPL(x1205_do_command); -EXPORT_SYMBOL_GPL(x1205_direct_attach); - -module_init(x1205_init); -module_exit(x1205_exit); diff --git a/trunk/drivers/i2c/i2c-core.c b/trunk/drivers/i2c/i2c-core.c index 02e335a04f09..45aa0e54e297 100644 --- a/trunk/drivers/i2c/i2c-core.c +++ b/trunk/drivers/i2c/i2c-core.c @@ -19,8 +19,7 @@ /* With some changes from Kyösti Mälkki . All SMBus-related things are written by Frodo Looijaard - SMBus 2.0 support by Mark Studebaker and - Jean Delvare */ + SMBus 2.0 support by Mark Studebaker */ #include #include @@ -86,7 +85,6 @@ void i2c_adapter_dev_release(struct device *dev) } struct device_driver i2c_adapter_driver = { - .owner = THIS_MODULE, .name = "i2c_adapter", .bus = &i2c_bus_type, .probe = i2c_device_probe, @@ -100,7 +98,6 @@ static void i2c_adapter_class_dev_release(struct class_device *dev) } struct class i2c_adapter_class = { - .owner = THIS_MODULE, .name = "i2c-adapter", .release = &i2c_adapter_class_dev_release, }; @@ -294,7 +291,6 @@ int i2c_add_driver(struct i2c_driver *driver) down(&core_lists); /* add the driver to the list of i2c drivers in the driver core */ - driver->driver.owner = driver->owner; driver->driver.name = driver->name; driver->driver.bus = &i2c_bus_type; driver->driver.probe = i2c_device_probe; @@ -710,6 +706,10 @@ int i2c_probe(struct i2c_adapter *adapter, int i, err; int adap_id = i2c_adapter_id(adapter); + /* Forget it if we can't probe using SMBUS_QUICK */ + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) + return -1; + /* Force entries are done first, and are not affected by ignore entries */ if (address_data->forces) { @@ -736,17 +736,6 @@ int i2c_probe(struct i2c_adapter *adapter, } } - /* Stop here if we can't use SMBUS_QUICK */ - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { - if (address_data->probe[0] == I2C_CLIENT_END - && address_data->normal_i2c[0] == I2C_CLIENT_END) - return 0; - - dev_warn(&adapter->dev, "SMBus Quick command not supported, " - "can't probe for chips\n"); - return -1; - } - /* Probe entries are done second, and are not affected by ignore entries either */ for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { @@ -831,44 +820,101 @@ crc8(u16 data) return (u8)(data >> 8); } -/* Incremental CRC8 over count bytes in the array pointed to by p */ -static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) +/* CRC over count bytes in the first array plus the bytes in the rest + array if it is non-null. rest[0] is the (length of rest) - 1 + and is included. */ +static u8 i2c_smbus_partial_pec(u8 crc, int count, u8 *first, u8 *rest) { int i; for(i = 0; i < count; i++) - crc = crc8((crc ^ p[i]) << 8); + crc = crc8((crc ^ first[i]) << 8); + if(rest != NULL) + for(i = 0; i <= rest[0]; i++) + crc = crc8((crc ^ rest[i]) << 8); return crc; } -/* Assume a 7-bit address, which is reasonable for SMBus */ -static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg) +static u8 i2c_smbus_pec(int count, u8 *first, u8 *rest) { - /* The address will be sent first */ - u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD); - pec = i2c_smbus_pec(pec, &addr, 1); - - /* The data buffer follows */ - return i2c_smbus_pec(pec, msg->buf, msg->len); + return i2c_smbus_partial_pec(0, count, first, rest); } -/* Used for write only transactions */ -static inline void i2c_smbus_add_pec(struct i2c_msg *msg) +/* Returns new "size" (transaction type) + Note that we convert byte to byte_data and byte_data to word_data + rather than invent new xxx_PEC transactions. */ +static int i2c_smbus_add_pec(u16 addr, u8 command, int size, + union i2c_smbus_data *data) { - msg->buf[msg->len] = i2c_smbus_msg_pec(0, msg); - msg->len++; + u8 buf[3]; + + buf[0] = addr << 1; + buf[1] = command; + switch(size) { + case I2C_SMBUS_BYTE: + data->byte = i2c_smbus_pec(2, buf, NULL); + size = I2C_SMBUS_BYTE_DATA; + break; + case I2C_SMBUS_BYTE_DATA: + buf[2] = data->byte; + data->word = buf[2] || + (i2c_smbus_pec(3, buf, NULL) << 8); + size = I2C_SMBUS_WORD_DATA; + break; + case I2C_SMBUS_WORD_DATA: + /* unsupported */ + break; + case I2C_SMBUS_BLOCK_DATA: + data->block[data->block[0] + 1] = + i2c_smbus_pec(2, buf, data->block); + size = I2C_SMBUS_BLOCK_DATA_PEC; + break; + } + return size; } -/* Return <0 on CRC error - If there was a write before this read (most cases) we need to take the - partial CRC from the write part into account. - Note that this function does modify the message (we need to decrease the - message length to hide the CRC byte from the caller). */ -static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg) +static int i2c_smbus_check_pec(u16 addr, u8 command, int size, u8 partial, + union i2c_smbus_data *data) { - u8 rpec = msg->buf[--msg->len]; - cpec = i2c_smbus_msg_pec(cpec, msg); + u8 buf[3], rpec, cpec; + buf[1] = command; + switch(size) { + case I2C_SMBUS_BYTE_DATA: + buf[0] = (addr << 1) | 1; + cpec = i2c_smbus_pec(2, buf, NULL); + rpec = data->byte; + break; + case I2C_SMBUS_WORD_DATA: + buf[0] = (addr << 1) | 1; + buf[2] = data->word & 0xff; + cpec = i2c_smbus_pec(3, buf, NULL); + rpec = data->word >> 8; + break; + case I2C_SMBUS_WORD_DATA_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_PROC_CALL_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_BLOCK_DATA_PEC: + buf[0] = (addr << 1); + buf[2] = (addr << 1) | 1; + cpec = i2c_smbus_pec(3, buf, data->block); + rpec = data->block[data->block[0] + 1]; + break; + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + buf[0] = (addr << 1) | 1; + rpec = i2c_smbus_partial_pec(partial, 1, + buf, data->block); + cpec = data->block[data->block[0] + 1]; + break; + default: + cpec = rpec = 0; + break; + } if (rpec != cpec) { pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", rpec, cpec); @@ -895,8 +941,9 @@ s32 i2c_smbus_read_byte(struct i2c_client *client) s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) { + union i2c_smbus_data data; /* only for PEC */ return i2c_smbus_xfer(client->adapter,client->addr,client->flags, - I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); + I2C_SMBUS_WRITE,value, I2C_SMBUS_BYTE,&data); } s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) @@ -979,14 +1026,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, need to use only one message; when reading, we need two. We initialize most things with sane defaults, to keep the code below somewhat simpler. */ - unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; - unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; + unsigned char msgbuf0[34]; + unsigned char msgbuf1[34]; int num = read_write == I2C_SMBUS_READ?2:1; struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, { addr, flags | I2C_M_RD, 0, msgbuf1 } }; int i; - u8 partial_pec = 0; msgbuf0[0] = command; switch(size) { @@ -1029,6 +1075,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, msgbuf0[2] = (data->word >> 8) & 0xff; break; case I2C_SMBUS_BLOCK_DATA: + case I2C_SMBUS_BLOCK_DATA_PEC: if (read_write == I2C_SMBUS_READ) { dev_err(&adapter->dev, "Block read not supported " "under I2C emulation!\n"); @@ -1041,20 +1088,23 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, data->block[0]); return -1; } - for (i = 1; i < msg[0].len; i++) + if(size == I2C_SMBUS_BLOCK_DATA_PEC) + (msg[0].len)++; + for (i = 1; i <= msg[0].len; i++) msgbuf0[i] = data->block[i-1]; } break; case I2C_SMBUS_BLOCK_PROC_CALL: + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: dev_dbg(&adapter->dev, "Block process call not supported " "under I2C emulation!\n"); return -1; case I2C_SMBUS_I2C_BLOCK_DATA: if (read_write == I2C_SMBUS_READ) { - msg[1].len = I2C_SMBUS_BLOCK_MAX; + msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; } else { msg[0].len = data->block[0] + 1; - if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { + if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) { dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " "invalid block write size (%d)\n", data->block[0]); @@ -1070,30 +1120,9 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, return -1; } - i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK - && size != I2C_SMBUS_I2C_BLOCK_DATA); - if (i) { - /* Compute PEC if first message is a write */ - if (!(msg[0].flags & I2C_M_RD)) { - if (num == 1) /* Write only */ - i2c_smbus_add_pec(&msg[0]); - else /* Write followed by read */ - partial_pec = i2c_smbus_msg_pec(0, &msg[0]); - } - /* Ask for PEC if last message is a read */ - if (msg[num-1].flags & I2C_M_RD) - msg[num-1].len++; - } - if (i2c_transfer(adapter, msg, num) < 0) return -1; - /* Check PEC if last message is a read */ - if (i && (msg[num-1].flags & I2C_M_RD)) { - if (i2c_smbus_check_pec(partial_pec, &msg[num-1]) < 0) - return -1; - } - if (read_write == I2C_SMBUS_READ) switch(size) { case I2C_SMBUS_BYTE: @@ -1108,8 +1137,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, break; case I2C_SMBUS_I2C_BLOCK_DATA: /* fixed at 32 for now */ - data->block[0] = I2C_SMBUS_BLOCK_MAX; - for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) + data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX; + for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++) data->block[i+1] = msgbuf1[i]; break; } @@ -1122,8 +1151,28 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, union i2c_smbus_data * data) { s32 res; + int swpec = 0; + u8 partial = 0; flags &= I2C_M_TEN | I2C_CLIENT_PEC; + if((flags & I2C_CLIENT_PEC) && + !(i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HWPEC_CALC))) { + swpec = 1; + if(read_write == I2C_SMBUS_READ && + size == I2C_SMBUS_BLOCK_DATA) + size = I2C_SMBUS_BLOCK_DATA_PEC; + else if(size == I2C_SMBUS_PROC_CALL) + size = I2C_SMBUS_PROC_CALL_PEC; + else if(size == I2C_SMBUS_BLOCK_PROC_CALL) { + i2c_smbus_add_pec(addr, command, + I2C_SMBUS_BLOCK_DATA, data); + partial = data->block[data->block[0] + 1]; + size = I2C_SMBUS_BLOCK_PROC_CALL_PEC; + } else if(read_write == I2C_SMBUS_WRITE && + size != I2C_SMBUS_QUICK && + size != I2C_SMBUS_I2C_BLOCK_DATA) + size = i2c_smbus_add_pec(addr, command, size, data); + } if (adapter->algo->smbus_xfer) { down(&adapter->bus_lock); @@ -1134,6 +1183,13 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, command,size,data); + if(res >= 0 && swpec && + size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA && + (read_write == I2C_SMBUS_READ || size == I2C_SMBUS_PROC_CALL_PEC || + size == I2C_SMBUS_BLOCK_PROC_CALL_PEC)) { + if(i2c_smbus_check_pec(addr, command, size, partial, data)) + return -1; + } return res; } diff --git a/trunk/drivers/i2c/i2c-dev.c b/trunk/drivers/i2c/i2c-dev.c index ea14c8f1c82b..aa7a4fadef64 100644 --- a/trunk/drivers/i2c/i2c-dev.c +++ b/trunk/drivers/i2c/i2c-dev.c @@ -26,11 +26,15 @@ /* The I2C_RDWR ioctl code is written by Kolja Waschk */ +/* The devfs code is contributed by Philipp Matthias Hahn + */ + #include #include #include #include #include +#include #include #include #include @@ -76,9 +80,10 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap) { struct i2c_dev *i2c_dev; - i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL); + i2c_dev = kmalloc(sizeof(*i2c_dev), GFP_KERNEL); if (!i2c_dev) return ERR_PTR(-ENOMEM); + memset(i2c_dev, 0x00, sizeof(*i2c_dev)); spin_lock(&i2c_dev_array_lock); if (i2c_dev_array[adap->nr]) { @@ -172,8 +177,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, int i,datasize,res; unsigned long funcs; - dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", - cmd, arg); + dev_dbg(&client->adapter->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", + iminor(inode),cmd, arg); switch ( cmd ) { case I2C_SLAVE: @@ -427,6 +432,8 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) if (IS_ERR(i2c_dev)) return PTR_ERR(i2c_dev); + devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), + S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", adap->name, i2c_dev->minor); @@ -459,6 +466,7 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) return -ENODEV; init_completion(&i2c_dev->released); + devfs_remove("i2c/%d", i2c_dev->minor); return_i2c_dev(i2c_dev); class_device_unregister(&i2c_dev->class_dev); wait_for_completion(&i2c_dev->released); @@ -514,6 +522,8 @@ static int __init i2c_dev_init(void) if (res) goto out_unreg_class; + devfs_mk_dir("i2c"); + return 0; out_unreg_class: @@ -529,6 +539,7 @@ static void __exit i2c_dev_exit(void) { i2c_del_driver(&i2cdev_driver); class_unregister(&i2c_dev_class); + devfs_remove("i2c"); unregister_chrdev(I2C_MAJOR,"i2c"); } diff --git a/trunk/drivers/mmc/wbsd.c b/trunk/drivers/mmc/wbsd.c index 25f7ce7b3bc0..3ace875decc4 100644 --- a/trunk/drivers/mmc/wbsd.c +++ b/trunk/drivers/mmc/wbsd.c @@ -1033,13 +1033,16 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) } else { - setup &= ~WBSD_DAT3_H; + if (setup & WBSD_DAT3_H) + { + setup &= ~WBSD_DAT3_H; - /* - * We cannot resume card detection immediatly - * because of capacitance and delays in the chip. - */ - mod_timer(&host->ignore_timer, jiffies + HZ/100); + /* + * We cannot resume card detection immediatly + * because of capacitance and delays in the chip. + */ + mod_timer(&host->ignore_timer, jiffies + HZ/100); + } } wbsd_write_index(host, WBSD_IDX_SETUP, setup); @@ -1461,8 +1464,10 @@ static int __devinit wbsd_scan(struct wbsd_host* host) { id = 0xFFFF; - outb(unlock_codes[j], config_ports[i]); - outb(unlock_codes[j], config_ports[i]); + host->config = config_ports[i]; + host->unlock_code = unlock_codes[j]; + + wbsd_unlock_config(host); outb(WBSD_CONF_ID_HI, config_ports[i]); id = inb(config_ports[i] + 1) << 8; @@ -1470,13 +1475,13 @@ static int __devinit wbsd_scan(struct wbsd_host* host) outb(WBSD_CONF_ID_LO, config_ports[i]); id |= inb(config_ports[i] + 1); + wbsd_lock_config(host); + for (k = 0;k < sizeof(valid_ids)/sizeof(int);k++) { if (id == valid_ids[k]) { host->chip_id = id; - host->config = config_ports[i]; - host->unlock_code = unlock_codes[i]; return 0; } @@ -1487,13 +1492,14 @@ static int __devinit wbsd_scan(struct wbsd_host* host) DBG("Unknown hardware (id %x) found at %x\n", id, config_ports[i]); } - - outb(LOCK_CODE, config_ports[i]); } release_region(config_ports[i], 2); } + host->config = 0; + host->unlock_code = 0; + return -ENODEV; } @@ -1699,8 +1705,10 @@ static void __devexit wbsd_release_resources(struct wbsd_host* host) * Configure the resources the chip should use. */ -static void __devinit wbsd_chip_config(struct wbsd_host* host) +static void wbsd_chip_config(struct wbsd_host* host) { + wbsd_unlock_config(host); + /* * Reset the chip. */ @@ -1733,16 +1741,20 @@ static void __devinit wbsd_chip_config(struct wbsd_host* host) */ wbsd_write_config(host, WBSD_CONF_ENABLE, 1); wbsd_write_config(host, WBSD_CONF_POWER, 0x20); + + wbsd_lock_config(host); } /* * Check that configured resources are correct. */ -static int __devinit wbsd_chip_validate(struct wbsd_host* host) +static int wbsd_chip_validate(struct wbsd_host* host) { int base, irq, dma; + wbsd_unlock_config(host); + /* * Select SD/MMC function. */ @@ -1758,6 +1770,8 @@ static int __devinit wbsd_chip_validate(struct wbsd_host* host) dma = wbsd_read_config(host, WBSD_CONF_DRQ); + wbsd_lock_config(host); + /* * Validate against given configuration. */ @@ -1771,6 +1785,20 @@ static int __devinit wbsd_chip_validate(struct wbsd_host* host) return 1; } +/* + * Powers down the SD function + */ + +static void wbsd_chip_poweroff(struct wbsd_host* host) +{ + wbsd_unlock_config(host); + + wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD); + wbsd_write_config(host, WBSD_CONF_ENABLE, 0); + + wbsd_lock_config(host); +} + /*****************************************************************************\ * * * Devices setup and shutdown * @@ -1844,7 +1872,11 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma, */ #ifdef CONFIG_PM if (host->config) + { + wbsd_unlock_config(host); wbsd_write_config(host, WBSD_CONF_PME, 0xA0); + wbsd_lock_config(host); + } #endif /* * Allow device to initialise itself properly. @@ -1885,16 +1917,11 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp) mmc_remove_host(mmc); + /* + * Power down the SD/MMC function. + */ if (!pnp) - { - /* - * Power down the SD/MMC function. - */ - wbsd_unlock_config(host); - wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD); - wbsd_write_config(host, WBSD_CONF_ENABLE, 0); - wbsd_lock_config(host); - } + wbsd_chip_poweroff(host); wbsd_release_resources(host); @@ -1955,23 +1982,59 @@ static void __devexit wbsd_pnp_remove(struct pnp_dev * dev) */ #ifdef CONFIG_PM + static int wbsd_suspend(struct device *dev, pm_message_t state) { - DBGF("Not yet supported\n"); + struct mmc_host *mmc = dev_get_drvdata(dev); + struct wbsd_host *host; + int ret; + + if (!mmc) + return 0; + + DBG("Suspending...\n"); + + ret = mmc_suspend_host(mmc, state); + if (!ret) + return ret; + + host = mmc_priv(mmc); + + wbsd_chip_poweroff(host); return 0; } static int wbsd_resume(struct device *dev) { - DBGF("Not yet supported\n"); + struct mmc_host *mmc = dev_get_drvdata(dev); + struct wbsd_host *host; - return 0; + if (!mmc) + return 0; + + DBG("Resuming...\n"); + + host = mmc_priv(mmc); + + wbsd_chip_config(host); + + /* + * Allow device to initialise itself properly. + */ + mdelay(5); + + wbsd_init_device(host); + + return mmc_resume_host(mmc); } -#else + +#else /* CONFIG_PM */ + #define wbsd_suspend NULL #define wbsd_resume NULL -#endif + +#endif /* CONFIG_PM */ static struct platform_device *wbsd_device; diff --git a/trunk/drivers/pcmcia/yenta_socket.c b/trunk/drivers/pcmcia/yenta_socket.c index ec6ab65f0872..db9f952f9e3c 100644 --- a/trunk/drivers/pcmcia/yenta_socket.c +++ b/trunk/drivers/pcmcia/yenta_socket.c @@ -151,40 +151,6 @@ static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) readb(socket->base + 0x800 + reg + 1); } -static ssize_t show_yenta_registers(struct device *yentadev, struct device_attribute *attr, char *buf) -{ - struct pci_dev *dev = to_pci_dev(yentadev); - struct yenta_socket *socket = pci_get_drvdata(dev); - int offset = 0, i; - - offset = snprintf(buf, PAGE_SIZE, "CB registers:"); - for (i = 0; i < 0x24; i += 4) { - unsigned val; - if (!(i & 15)) - offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i); - val = cb_readl(socket, i); - offset += snprintf(buf + offset, PAGE_SIZE - offset, " %08x", val); - } - - offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n\nExCA registers:"); - for (i = 0; i < 0x45; i++) { - unsigned char val; - if (!(i & 7)) { - if (i & 8) { - memcpy(buf + offset, " -", 2); - offset += 2; - } else - offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i); - } - val = exca_readb(socket, i); - offset += snprintf(buf + offset, PAGE_SIZE - offset, " %02x", val); - } - buf[offset++] = '\n'; - return offset; -} - -static DEVICE_ATTR(yenta_registers, S_IRUSR, show_yenta_registers, NULL); - /* * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend * on what kind of card is inserted.. @@ -799,9 +765,6 @@ static void yenta_close(struct pci_dev *dev) { struct yenta_socket *sock = pci_get_drvdata(dev); - /* Remove the register attributes */ - device_remove_file(&dev->dev, &dev_attr_yenta_registers); - /* we don't want a dying socket registered */ pcmcia_unregister_socket(&sock->socket); @@ -1175,11 +1138,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i /* Register it with the pcmcia layer.. */ ret = pcmcia_register_socket(&socket->socket); - if (ret == 0) { - /* Add the yenta register attributes */ - device_create_file(&dev->dev, &dev_attr_yenta_registers); + if (ret == 0) goto out; - } unmap: iounmap(socket->base); diff --git a/trunk/drivers/scsi/ahci.c b/trunk/drivers/scsi/ahci.c index cbab5868ffdf..fe8187d6f58b 100644 --- a/trunk/drivers/scsi/ahci.c +++ b/trunk/drivers/scsi/ahci.c @@ -314,15 +314,8 @@ static int ahci_port_start(struct ata_port *ap) return -ENOMEM; memset(pp, 0, sizeof(*pp)); - ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, &ap->pad_dma, GFP_KERNEL); - if (!ap->pad) { - kfree(pp); - return -ENOMEM; - } - mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL); if (!mem) { - dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); kfree(pp); return -ENOMEM; } @@ -398,7 +391,6 @@ static void ahci_port_stop(struct ata_port *ap) ap->private_data = NULL; dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, pp->cmd_slot, pp->cmd_slot_dma); - dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); kfree(pp); } @@ -484,23 +476,23 @@ static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) static void ahci_fill_sg(struct ata_queued_cmd *qc) { struct ahci_port_priv *pp = qc->ap->private_data; - struct scatterlist *sg; - struct ahci_sg *ahci_sg; + unsigned int i; VPRINTK("ENTER\n"); /* * Next, the S/G list. */ - ahci_sg = pp->cmd_tbl_sg; - ata_for_each_sg(sg, qc) { - dma_addr_t addr = sg_dma_address(sg); - u32 sg_len = sg_dma_len(sg); - - ahci_sg->addr = cpu_to_le32(addr & 0xffffffff); - ahci_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16); - ahci_sg->flags_size = cpu_to_le32(sg_len - 1); - ahci_sg++; + for (i = 0; i < qc->n_elem; i++) { + u32 sg_len; + dma_addr_t addr; + + addr = sg_dma_address(&qc->sg[i]); + sg_len = sg_dma_len(&qc->sg[i]); + + pp->cmd_tbl_sg[i].addr = cpu_to_le32(addr & 0xffffffff); + pp->cmd_tbl_sg[i].addr_hi = cpu_to_le32((addr >> 16) >> 16); + pp->cmd_tbl_sg[i].flags_size = cpu_to_le32(sg_len - 1); } } diff --git a/trunk/drivers/scsi/libata-core.c b/trunk/drivers/scsi/libata-core.c index 64f30bf59315..f53d7b8ac33f 100644 --- a/trunk/drivers/scsi/libata-core.c +++ b/trunk/drivers/scsi/libata-core.c @@ -2444,9 +2444,8 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) static void ata_sg_clean(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; - struct scatterlist *sg = qc->__sg; + struct scatterlist *sg = qc->sg; int dir = qc->dma_dir; - void *pad_buf = NULL; assert(qc->flags & ATA_QCFLAG_DMAMAP); assert(sg != NULL); @@ -2456,35 +2455,14 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) DPRINTK("unmapping %u sg elements\n", qc->n_elem); - /* if we padded the buffer out to 32-bit bound, and data - * xfer direction is from-device, we must copy from the - * pad buffer back into the supplied buffer - */ - if (qc->pad_len && !(qc->tf.flags & ATA_TFLAG_WRITE)) - pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); - - if (qc->flags & ATA_QCFLAG_SG) { + if (qc->flags & ATA_QCFLAG_SG) dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir); - /* restore last sg */ - sg[qc->orig_n_elem - 1].length += qc->pad_len; - if (pad_buf) { - struct scatterlist *psg = &qc->pad_sgent; - void *addr = kmap_atomic(psg->page, KM_IRQ0); - memcpy(addr + psg->offset, pad_buf, qc->pad_len); - kunmap_atomic(psg->page, KM_IRQ0); - } - } else { + else dma_unmap_single(ap->host_set->dev, sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), dir); - /* restore sg */ - sg->length += qc->pad_len; - if (pad_buf) - memcpy(qc->buf_virt + sg->length - qc->pad_len, - pad_buf, qc->pad_len); - } qc->flags &= ~ATA_QCFLAG_DMAMAP; - qc->__sg = NULL; + qc->sg = NULL; } /** @@ -2500,15 +2478,15 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) */ static void ata_fill_sg(struct ata_queued_cmd *qc) { + struct scatterlist *sg = qc->sg; struct ata_port *ap = qc->ap; - struct scatterlist *sg; - unsigned int idx; + unsigned int idx, nelem; - assert(qc->__sg != NULL); + assert(sg != NULL); assert(qc->n_elem > 0); idx = 0; - ata_for_each_sg(sg, qc) { + for (nelem = qc->n_elem; nelem; nelem--,sg++) { u32 addr, offset; u32 sg_len, len; @@ -2599,12 +2577,11 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) qc->flags |= ATA_QCFLAG_SINGLE; memset(&qc->sgent, 0, sizeof(qc->sgent)); - qc->__sg = &qc->sgent; + qc->sg = &qc->sgent; qc->n_elem = 1; - qc->orig_n_elem = 1; qc->buf_virt = buf; - sg = qc->__sg; + sg = qc->sg; sg->page = virt_to_page(buf); sg->offset = (unsigned long) buf & ~PAGE_MASK; sg->length = buflen; @@ -2628,9 +2605,8 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, unsigned int n_elem) { qc->flags |= ATA_QCFLAG_SG; - qc->__sg = sg; + qc->sg = sg; qc->n_elem = n_elem; - qc->orig_n_elem = n_elem; } /** @@ -2650,32 +2626,9 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; int dir = qc->dma_dir; - struct scatterlist *sg = qc->__sg; + struct scatterlist *sg = qc->sg; dma_addr_t dma_address; - /* we must lengthen transfers to end on a 32-bit boundary */ - qc->pad_len = sg->length & 3; - if (qc->pad_len) { - void *pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); - struct scatterlist *psg = &qc->pad_sgent; - - assert(qc->dev->class == ATA_DEV_ATAPI); - - memset(pad_buf, 0, ATA_DMA_PAD_SZ); - - if (qc->tf.flags & ATA_TFLAG_WRITE) - memcpy(pad_buf, qc->buf_virt + sg->length - qc->pad_len, - qc->pad_len); - - sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ); - sg_dma_len(psg) = ATA_DMA_PAD_SZ; - /* trim sg */ - sg->length -= qc->pad_len; - - DPRINTK("padding done, sg->length=%u pad_len=%u\n", - sg->length, qc->pad_len); - } - dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, sg->length, dir); if (dma_mapping_error(dma_address)) @@ -2707,47 +2660,12 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) static int ata_sg_setup(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; - struct scatterlist *sg = qc->__sg; - struct scatterlist *lsg = &sg[qc->n_elem - 1]; + struct scatterlist *sg = qc->sg; int n_elem, dir; VPRINTK("ENTER, ata%u\n", ap->id); assert(qc->flags & ATA_QCFLAG_SG); - /* we must lengthen transfers to end on a 32-bit boundary */ - qc->pad_len = lsg->length & 3; - if (qc->pad_len) { - void *pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); - struct scatterlist *psg = &qc->pad_sgent; - unsigned int offset; - - assert(qc->dev->class == ATA_DEV_ATAPI); - - memset(pad_buf, 0, ATA_DMA_PAD_SZ); - - /* - * psg->page/offset are used to copy to-be-written - * data in this function or read data in ata_sg_clean. - */ - offset = lsg->offset + lsg->length - qc->pad_len; - psg->page = nth_page(lsg->page, offset >> PAGE_SHIFT); - psg->offset = offset_in_page(offset); - - if (qc->tf.flags & ATA_TFLAG_WRITE) { - void *addr = kmap_atomic(psg->page, KM_IRQ0); - memcpy(pad_buf, addr + psg->offset, qc->pad_len); - kunmap_atomic(psg->page, KM_IRQ0); - } - - sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ); - sg_dma_len(psg) = ATA_DMA_PAD_SZ; - /* trim last sg */ - lsg->length -= qc->pad_len; - - DPRINTK("padding done, sg[%d].length=%u pad_len=%u\n", - qc->n_elem - 1, lsg->length, qc->pad_len); - } - dir = qc->dma_dir; n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir); if (n_elem < 1) @@ -3023,7 +2941,7 @@ static void ata_data_xfer(struct ata_port *ap, unsigned char *buf, static void ata_pio_sector(struct ata_queued_cmd *qc) { int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); - struct scatterlist *sg = qc->__sg; + struct scatterlist *sg = qc->sg; struct ata_port *ap = qc->ap; struct page *page; unsigned int offset; @@ -3073,7 +2991,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) { int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); - struct scatterlist *sg = qc->__sg; + struct scatterlist *sg = qc->sg; struct ata_port *ap = qc->ap; struct page *page; unsigned char *buf; @@ -3106,7 +3024,7 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) return; } - sg = &qc->__sg[qc->cursg]; + sg = &qc->sg[qc->cursg]; page = sg->page; offset = sg->offset + qc->cursg_ofs; @@ -3466,7 +3384,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, qc = ata_qc_new(ap); if (qc) { - qc->__sg = NULL; + qc->sg = NULL; qc->flags = 0; qc->scsicmd = NULL; qc->ap = ap; @@ -4153,12 +4071,6 @@ int ata_port_start (struct ata_port *ap) if (!ap->prd) return -ENOMEM; - ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, &ap->pad_dma, GFP_KERNEL); - if (!ap->pad) { - dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); - return -ENOMEM; - } - DPRINTK("prd alloc, virt %p, dma %llx\n", ap->prd, (unsigned long long) ap->prd_dma); return 0; @@ -4182,7 +4094,6 @@ void ata_port_stop (struct ata_port *ap) struct device *dev = ap->host_set->dev; dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); - dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); } void ata_host_stop (struct ata_host_set *host_set) diff --git a/trunk/drivers/scsi/libata-scsi.c b/trunk/drivers/scsi/libata-scsi.c index 69058510f43a..58858886d751 100644 --- a/trunk/drivers/scsi/libata-scsi.c +++ b/trunk/drivers/scsi/libata-scsi.c @@ -40,56 +40,14 @@ #include "scsi.h" #include #include -#include #include #include "libata.h" -#define SECTOR_SIZE 512 - typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); static struct ata_device * ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); -#define RW_RECOVERY_MPAGE 0x1 -#define RW_RECOVERY_MPAGE_LEN 12 -#define CACHE_MPAGE 0x8 -#define CACHE_MPAGE_LEN 20 -#define CONTROL_MPAGE 0xa -#define CONTROL_MPAGE_LEN 12 -#define ALL_MPAGES 0x3f -#define ALL_SUB_MPAGES 0xff - - -static const u8 def_rw_recovery_mpage[] = { - RW_RECOVERY_MPAGE, - RW_RECOVERY_MPAGE_LEN - 2, - (1 << 7) | /* AWRE, sat-r06 say it shall be 0 */ - (1 << 6), /* ARRE (auto read reallocation) */ - 0, /* read retry count */ - 0, 0, 0, 0, - 0, /* write retry count */ - 0, 0, 0 -}; - -static const u8 def_cache_mpage[CACHE_MPAGE_LEN] = { - CACHE_MPAGE, - CACHE_MPAGE_LEN - 2, - 0, /* contains WCE, needs to be 0 for logic */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* contains DRA, needs to be 0 for logic */ - 0, 0, 0, 0, 0, 0, 0 -}; - -static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = { - CONTROL_MPAGE, - CONTROL_MPAGE_LEN - 2, - 2, /* DSENSE=0, GLTSD=1 */ - 0, /* [QAM+QERR may be 1, see 05-359r1] */ - 0, 0, 0, 0, 0xff, 0xff, - 0, 30 /* extended self test time, see 05-359r1 */ -}; - static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) @@ -128,150 +86,6 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev, return 0; } -/** - * ata_cmd_ioctl - Handler for HDIO_DRIVE_CMD ioctl - * @dev: Device to whom we are issuing command - * @arg: User provided data for issuing command - * - * LOCKING: - * Defined by the SCSI layer. We don't really care. - * - * RETURNS: - * Zero on success, negative errno on error. - */ - -int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) -{ - int rc = 0; - u8 scsi_cmd[MAX_COMMAND_SIZE]; - u8 args[4], *argbuf = NULL; - int argsize = 0; - struct scsi_request *sreq; - - if (NULL == (void *)arg) - return -EINVAL; - - if (copy_from_user(args, arg, sizeof(args))) - return -EFAULT; - - sreq = scsi_allocate_request(scsidev, GFP_KERNEL); - if (!sreq) - return -EINTR; - - memset(scsi_cmd, 0, sizeof(scsi_cmd)); - - if (args[3]) { - argsize = SECTOR_SIZE * args[3]; - argbuf = kmalloc(argsize, GFP_KERNEL); - if (argbuf == NULL) { - rc = -ENOMEM; - goto error; - } - - scsi_cmd[1] = (4 << 1); /* PIO Data-in */ - scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, - block count in sector count field */ - sreq->sr_data_direction = DMA_FROM_DEVICE; - } else { - scsi_cmd[1] = (3 << 1); /* Non-data */ - /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ - sreq->sr_data_direction = DMA_NONE; - } - - scsi_cmd[0] = ATA_16; - - scsi_cmd[4] = args[2]; - if (args[0] == WIN_SMART) { /* hack -- ide driver does this too... */ - scsi_cmd[6] = args[3]; - scsi_cmd[8] = args[1]; - scsi_cmd[10] = 0x4f; - scsi_cmd[12] = 0xc2; - } else { - scsi_cmd[6] = args[1]; - } - scsi_cmd[14] = args[0]; - - /* Good values for timeout and retries? Values below - from scsi_ioctl_send_command() for default case... */ - scsi_wait_req(sreq, scsi_cmd, argbuf, argsize, (10*HZ), 5); - - if (sreq->sr_result) { - rc = -EIO; - goto error; - } - - /* Need code to retrieve data from check condition? */ - - if ((argbuf) - && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) - rc = -EFAULT; -error: - scsi_release_request(sreq); - - if (argbuf) - kfree(argbuf); - - return rc; -} - -/** - * ata_task_ioctl - Handler for HDIO_DRIVE_TASK ioctl - * @dev: Device to whom we are issuing command - * @arg: User provided data for issuing command - * - * LOCKING: - * Defined by the SCSI layer. We don't really care. - * - * RETURNS: - * Zero on success, negative errno on error. - */ -int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) -{ - int rc = 0; - u8 scsi_cmd[MAX_COMMAND_SIZE]; - u8 args[7]; - struct scsi_request *sreq; - - if (NULL == (void *)arg) - return -EINVAL; - - if (copy_from_user(args, arg, sizeof(args))) - return -EFAULT; - - memset(scsi_cmd, 0, sizeof(scsi_cmd)); - scsi_cmd[0] = ATA_16; - scsi_cmd[1] = (3 << 1); /* Non-data */ - /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ - scsi_cmd[4] = args[1]; - scsi_cmd[6] = args[2]; - scsi_cmd[8] = args[3]; - scsi_cmd[10] = args[4]; - scsi_cmd[12] = args[5]; - scsi_cmd[14] = args[0]; - - sreq = scsi_allocate_request(scsidev, GFP_KERNEL); - if (!sreq) { - rc = -EINTR; - goto error; - } - - sreq->sr_data_direction = DMA_NONE; - /* Good values for timeout and retries? Values below - from scsi_ioctl_send_command() for default case... */ - scsi_wait_req(sreq, scsi_cmd, NULL, 0, (10*HZ), 5); - - if (sreq->sr_result) { - rc = -EIO; - goto error; - } - - /* Need code to retrieve data from check condition? */ - -error: - scsi_release_request(sreq); - return rc; -} - int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) { struct ata_port *ap; @@ -301,16 +115,6 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) return -EINVAL; return 0; - case HDIO_DRIVE_CMD: - if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) - return -EACCES; - return ata_cmd_ioctl(scsidev, arg); - - case HDIO_DRIVE_TASK: - if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) - return -EACCES; - return ata_task_ioctl(scsidev, arg); - default: rc = -ENOTTY; break; @@ -354,10 +158,10 @@ struct ata_queued_cmd *ata_scsi_qc_new(struct ata_port *ap, qc->scsidone = done; if (cmd->use_sg) { - qc->__sg = (struct scatterlist *) cmd->request_buffer; + qc->sg = (struct scatterlist *) cmd->request_buffer; qc->n_elem = cmd->use_sg; } else { - qc->__sg = &qc->sgent; + qc->sg = &qc->sgent; qc->n_elem = 1; } } else { @@ -368,71 +172,24 @@ struct ata_queued_cmd *ata_scsi_qc_new(struct ata_port *ap, return qc; } -/** - * ata_dump_status - user friendly display of error info - * @id: id of the port in question - * @tf: ptr to filled out taskfile - * - * Decode and dump the ATA error/status registers for the user so - * that they have some idea what really happened at the non - * make-believe layer. - * - * LOCKING: - * inherited from caller - */ -void ata_dump_status(unsigned id, struct ata_taskfile *tf) -{ - u8 stat = tf->command, err = tf->feature; - - printk(KERN_WARNING "ata%u: status=0x%02x { ", id, stat); - if (stat & ATA_BUSY) { - printk("Busy }\n"); /* Data is not valid in this case */ - } else { - if (stat & 0x40) printk("DriveReady "); - if (stat & 0x20) printk("DeviceFault "); - if (stat & 0x10) printk("SeekComplete "); - if (stat & 0x08) printk("DataRequest "); - if (stat & 0x04) printk("CorrectedError "); - if (stat & 0x02) printk("Index "); - if (stat & 0x01) printk("Error "); - printk("}\n"); - - if (err) { - printk(KERN_WARNING "ata%u: error=0x%02x { ", id, err); - if (err & 0x04) printk("DriveStatusError "); - if (err & 0x80) { - if (err & 0x04) printk("BadCRC "); - else printk("Sector "); - } - if (err & 0x40) printk("UncorrectableError "); - if (err & 0x10) printk("SectorIdNotFound "); - if (err & 0x02) printk("TrackZeroNotFound "); - if (err & 0x01) printk("AddrMarkNotFound "); - printk("}\n"); - } - } -} - /** * ata_to_sense_error - convert ATA error to SCSI error + * @qc: Command that we are erroring out * @drv_stat: value contained in ATA status register - * @drv_err: value contained in ATA error register - * @sk: the sense key we'll fill out - * @asc: the additional sense code we'll fill out - * @ascq: the additional sense code qualifier we'll fill out * - * Converts an ATA error into a SCSI error. Fill out pointers to - * SK, ASC, and ASCQ bytes for later use in fixed or descriptor - * format sense blocks. + * Converts an ATA error into a SCSI error. While we are at it + * we decode and dump the ATA error for the user so that they + * have some idea what really happened at the non make-believe + * layer. * * LOCKING: * spin_lock_irqsave(host_set lock) */ -void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, - u8 *ascq) -{ - int i; +void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat) +{ + struct scsi_cmnd *cmd = qc->scsicmd; + u8 err = 0; /* Based on the 3ware driver translation table */ static unsigned char sense_table[][4] = { /* BBD|ECC|ID|MAR */ @@ -473,184 +230,96 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered {0xFF, 0xFF, 0xFF, 0xFF}, // END mark }; + int i = 0; /* * Is this an error we can process/parse */ - if (drv_stat & ATA_BUSY) { - drv_err = 0; /* Ignore the err bits, they're invalid */ - } - if (drv_err) { - /* Look for drv_err */ - for (i = 0; sense_table[i][0] != 0xFF; i++) { - /* Look for best matches first */ - if ((sense_table[i][0] & drv_err) == - sense_table[i][0]) { - *sk = sense_table[i][1]; - *asc = sense_table[i][2]; - *ascq = sense_table[i][3]; - goto translate_done; - } - } - /* No immediate match */ - printk(KERN_WARNING "ata%u: no sense translation for " - "error 0x%02x\n", id, drv_err); - } + if(drv_stat & ATA_ERR) + /* Read the err bits */ + err = ata_chk_err(qc->ap); - /* Fall back to interpreting status bits */ - for (i = 0; stat_table[i][0] != 0xFF; i++) { - if (stat_table[i][0] & drv_stat) { - *sk = stat_table[i][1]; - *asc = stat_table[i][2]; - *ascq = stat_table[i][3]; - goto translate_done; - } - } - /* No error? Undecoded? */ - printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", - id, drv_stat); + /* Display the ATA level error info */ - /* For our last chance pick, use medium read error because - * it's much more common than an ATA drive telling you a write - * has failed. - */ - *sk = MEDIUM_ERROR; - *asc = 0x11; /* "unrecovered read error" */ - *ascq = 0x04; /* "auto-reallocation failed" */ - - translate_done: - printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to " - "SCSI SK/ASC/ASCQ 0x%x/%02x/%02x\n", id, drv_stat, drv_err, - *sk, *asc, *ascq); - return; -} - -/* - * ata_gen_ata_desc_sense - Generate check condition sense block. - * @qc: Command that completed. - * - * This function is specific to the ATA descriptor format sense - * block specified for the ATA pass through commands. Regardless - * of whether the command errored or not, return a sense - * block. Copy all controller registers into the sense - * block. Clear sense key, ASC & ASCQ if there is no error. - * - * LOCKING: - * spin_lock_irqsave(host_set lock) - */ -void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) -{ - struct scsi_cmnd *cmd = qc->scsicmd; - struct ata_taskfile *tf = &qc->tf; - unsigned char *sb = cmd->sense_buffer; - unsigned char *desc = sb + 8; - - memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - - /* - * Read the controller registers. - */ - assert(NULL != qc->ap->ops->tf_read); - qc->ap->ops->tf_read(qc->ap, tf); - - /* - * Use ata_to_sense_error() to map status register bits - * onto sense key, asc & ascq. - */ - if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { - ata_to_sense_error(qc->ap->id, tf->command, tf->feature, - &sb[1], &sb[2], &sb[3]); - sb[1] &= 0x0f; + printk(KERN_WARNING "ata%u: status=0x%02x { ", qc->ap->id, drv_stat); + if(drv_stat & 0x80) + { + printk("Busy "); + err = 0; /* Data is not valid in this case */ } - - /* - * Sense data is current and format is descriptor. - */ - sb[0] = 0x72; - - desc[0] = 0x09; - - /* - * Set length of additional sense data. - * Since we only populate descriptor 0, the total - * length is the same (fixed) length as descriptor 0. - */ - desc[1] = sb[7] = 14; - - /* - * Copy registers into sense buffer. - */ - desc[2] = 0x00; - desc[3] = tf->feature; /* == error reg */ - desc[5] = tf->nsect; - desc[7] = tf->lbal; - desc[9] = tf->lbam; - desc[11] = tf->lbah; - desc[12] = tf->device; - desc[13] = tf->command; /* == status reg */ - - /* - * Fill in Extend bit, and the high order bytes - * if applicable. - */ - if (tf->flags & ATA_TFLAG_LBA48) { - desc[2] |= 0x01; - desc[4] = tf->hob_nsect; - desc[6] = tf->hob_lbal; - desc[8] = tf->hob_lbam; - desc[10] = tf->hob_lbah; + else { + if(drv_stat & 0x40) printk("DriveReady "); + if(drv_stat & 0x20) printk("DeviceFault "); + if(drv_stat & 0x10) printk("SeekComplete "); + if(drv_stat & 0x08) printk("DataRequest "); + if(drv_stat & 0x04) printk("CorrectedError "); + if(drv_stat & 0x02) printk("Index "); + if(drv_stat & 0x01) printk("Error "); } -} - -/** - * ata_gen_fixed_sense - generate a SCSI fixed sense block - * @qc: Command that we are erroring out - * - * Leverage ata_to_sense_error() to give us the codes. Fit our - * LBA in here if there's room. - * - * LOCKING: - * inherited from caller - */ -void ata_gen_fixed_sense(struct ata_queued_cmd *qc) -{ - struct scsi_cmnd *cmd = qc->scsicmd; - struct ata_taskfile *tf = &qc->tf; - unsigned char *sb = cmd->sense_buffer; - - memset(sb, 0, SCSI_SENSE_BUFFERSIZE); + printk("}\n"); + + if(err) + { + printk(KERN_WARNING "ata%u: error=0x%02x { ", qc->ap->id, err); + if(err & 0x04) printk("DriveStatusError "); + if(err & 0x80) + { + if(err & 0x04) + printk("BadCRC "); + else + printk("Sector "); + } + if(err & 0x40) printk("UncorrectableError "); + if(err & 0x10) printk("SectorIdNotFound "); + if(err & 0x02) printk("TrackZeroNotFound "); + if(err & 0x01) printk("AddrMarkNotFound "); + printk("}\n"); - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + /* Should we dump sector info here too ?? */ + } - /* - * Read the controller registers. - */ - assert(NULL != qc->ap->ops->tf_read); - qc->ap->ops->tf_read(qc->ap, tf); - /* - * Use ata_to_sense_error() to map status register bits - * onto sense key, asc & ascq. - */ - if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { - ata_to_sense_error(qc->ap->id, tf->command, tf->feature, - &sb[2], &sb[12], &sb[13]); - sb[2] &= 0x0f; + /* Look for err */ + while(sense_table[i][0] != 0xFF) + { + /* Look for best matches first */ + if((sense_table[i][0] & err) == sense_table[i][0]) + { + ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */, + sense_table[i][2] /* asc */, + sense_table[i][3] /* ascq */ ); + return; + } + i++; } + /* No immediate match */ + if(err) + printk(KERN_DEBUG "ata%u: no sense translation for 0x%02x\n", qc->ap->id, err); - sb[0] = 0x70; - sb[7] = 0x0a; + i = 0; + /* Fall back to interpreting status bits */ + while(stat_table[i][0] != 0xFF) + { + if(stat_table[i][0] & drv_stat) + { + ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */, + sense_table[i][2] /* asc */, + sense_table[i][3] /* ascq */ ); + return; + } + i++; + } + /* No error ?? */ + printk(KERN_ERR "ata%u: called with no error (%02X)!\n", qc->ap->id, drv_stat); + /* additional-sense-code[-qualifier] */ - if (tf->flags & ATA_TFLAG_LBA && !(tf->flags & ATA_TFLAG_LBA48)) { - /* A small (28b) LBA will fit in the 32b info field */ - sb[0] |= 0x80; /* set valid bit */ - sb[3] = tf->device & 0x0f; - sb[4] = tf->lbah; - sb[5] = tf->lbam; - sb[6] = tf->lbal; + if (cmd->sc_data_direction == DMA_FROM_DEVICE) { + ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0x11, 0x4); + /* "unrecovered read error" */ + } else { + ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0xc, 0x2); + /* "write error - auto-reallocation failed" */ } } @@ -693,16 +362,6 @@ int ata_scsi_slave_config(struct scsi_device *sdev) */ blk_queue_max_sectors(sdev->request_queue, 2048); } - - /* - * SATA DMA transfers must be multiples of 4 byte, so - * we need to pad ATAPI transfers using an extra sg. - * Decrement max hw segments accordingly. - */ - if (dev->class == ATA_DEV_ATAPI) { - request_queue_t *q = sdev->request_queue; - blk_queue_max_hw_segments(q, q->max_hw_segments - 1); - } } return 0; /* scsi layer doesn't check return value, sigh */ @@ -1212,36 +871,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) { struct scsi_cmnd *cmd = qc->scsicmd; - int need_sense = drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ); - - /* For ATA pass thru (SAT) commands, generate a sense block if - * user mandated it or if there's an error. Note that if we - * generate because the user forced us to, a check condition - * is generated and the ATA register values are returned - * whether the command completed successfully or not. If there - * was no error, SK, ASC and ASCQ will all be zero. - */ - if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && - ((cmd->cmnd[2] & 0x20) || need_sense)) { - ata_gen_ata_desc_sense(qc); - } else { - if (!need_sense) { - cmd->result = SAM_STAT_GOOD; - } else { - /* TODO: decide which descriptor format to use - * for 48b LBA devices and call that here - * instead of the fixed desc, which is only - * good for smaller LBA (and maybe CHS?) - * devices. - */ - ata_gen_fixed_sense(qc); - } - } - if (need_sense) { - /* The ata_gen_..._sense routines fill in tf */ - ata_dump_status(qc->ap->id, &qc->tf); - } + if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ))) + ata_to_sense_error(qc, drv_stat); + else + cmd->result = SAM_STAT_GOOD; qc->scsidone(cmd); @@ -1632,9 +1266,13 @@ static void ata_msense_push(u8 **ptr_io, const u8 *last, static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, const u8 *last) { - u8 page[CACHE_MPAGE_LEN]; + u8 page[] = { + 0x8, /* page code */ + 0x12, /* page length */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 zeroes */ + 0, 0, 0, 0, 0, 0, 0, 0 /* 8 zeroes */ + }; - memcpy(page, def_cache_mpage, sizeof(page)); if (ata_id_wcache_enabled(id)) page[2] |= (1 << 2); /* write cache enable */ if (!ata_id_rahead_enabled(id)) @@ -1658,9 +1296,15 @@ static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) { - ata_msense_push(ptr_io, last, def_control_mpage, - sizeof(def_control_mpage)); - return sizeof(def_control_mpage); + const u8 page[] = {0xa, 0xa, 6, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 30}; + + /* byte 2: set the descriptor format sense data bit (bit 2) + * since we need to support returning this format for SAT + * commands and any SCSI commands against a 48b LBA device. + */ + + ata_msense_push(ptr_io, last, page, sizeof(page)); + return sizeof(page); } /** @@ -1677,10 +1321,15 @@ static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) { + const u8 page[] = { + 0x1, /* page code */ + 0xa, /* page length */ + (1 << 7) | (1 << 6), /* note auto r/w reallocation */ + 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 9 zeroes */ + }; - ata_msense_push(ptr_io, last, def_rw_recovery_mpage, - sizeof(def_rw_recovery_mpage)); - return sizeof(def_rw_recovery_mpage); + ata_msense_push(ptr_io, last, page, sizeof(page)); + return sizeof(page); } /** @@ -1689,9 +1338,7 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. * @buflen: Response buffer length. * - * Simulate MODE SENSE commands. Assume this is invoked for direct - * access devices (e.g. disks) only. There should be no block - * descriptor for other device types. + * Simulate MODE SENSE commands. * * LOCKING: * spin_lock_irqsave(host_set lock) @@ -1701,22 +1348,15 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, unsigned int buflen) { u8 *scsicmd = args->cmd->cmnd, *p, *last; - const u8 sat_blk_desc[] = { - 0, 0, 0, 0, /* number of blocks: sat unspecified */ - 0, - 0, 0x2, 0x0 /* block length: 512 bytes */ - }; - u8 pg, spg; - unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; + unsigned int page_control, six_byte, output_len; VPRINTK("ENTER\n"); six_byte = (scsicmd[0] == MODE_SENSE); - ebd = !(scsicmd[1] & 0x8); /* dbd bit inverted == edb */ - /* - * LLBA bit in msense(10) ignored (compliant) - */ + /* we only support saved and current values (which we treat + * in the same manner) + */ page_control = scsicmd[2] >> 6; switch (page_control) { case 0: /* current */ @@ -1729,42 +1369,29 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, goto invalid_fld; } - if (six_byte) { - output_len = 4 + (ebd ? 8 : 0); - alloc_len = scsicmd[4]; - } else { - output_len = 8 + (ebd ? 8 : 0); - alloc_len = (scsicmd[7] << 8) + scsicmd[8]; - } - minlen = (alloc_len < buflen) ? alloc_len : buflen; + if (six_byte) + output_len = 4; + else + output_len = 8; p = rbuf + output_len; - last = rbuf + minlen - 1; + last = rbuf + buflen - 1; - pg = scsicmd[2] & 0x3f; - spg = scsicmd[3]; - /* - * No mode subpages supported (yet) but asking for _all_ - * subpages may be valid - */ - if (spg && (spg != ALL_SUB_MPAGES)) - goto invalid_fld; - - switch(pg) { - case RW_RECOVERY_MPAGE: + switch(scsicmd[2] & 0x3f) { + case 0x01: /* r/w error recovery */ output_len += ata_msense_rw_recovery(&p, last); break; - case CACHE_MPAGE: + case 0x08: /* caching */ output_len += ata_msense_caching(args->id, &p, last); break; - case CONTROL_MPAGE: { + case 0x0a: { /* control mode */ output_len += ata_msense_ctl_mode(&p, last); break; } - case ALL_MPAGES: + case 0x3f: /* all pages */ output_len += ata_msense_rw_recovery(&p, last); output_len += ata_msense_caching(args->id, &p, last); output_len += ata_msense_ctl_mode(&p, last); @@ -1774,31 +1401,15 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, goto invalid_fld; } - if (minlen < 1) - return 0; if (six_byte) { output_len--; rbuf[0] = output_len; - if (ebd) { - if (minlen > 3) - rbuf[3] = sizeof(sat_blk_desc); - if (minlen > 11) - memcpy(rbuf + 4, sat_blk_desc, - sizeof(sat_blk_desc)); - } } else { output_len -= 2; rbuf[0] = output_len >> 8; - if (minlen > 1) - rbuf[1] = output_len; - if (ebd) { - if (minlen > 7) - rbuf[7] = sizeof(sat_blk_desc); - if (minlen > 15) - memcpy(rbuf + 8, sat_blk_desc, - sizeof(sat_blk_desc)); - } + rbuf[1] = output_len; } + return 0; invalid_fld: @@ -2012,12 +1623,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ))) - /* FIXME: not quite right; we don't want the - * translation of taskfile registers into - * a sense descriptors, since that's only - * correct for ATA, not ATAPI - */ - ata_gen_ata_desc_sense(qc); + ata_to_sense_error(qc, drv_stat); else if (unlikely(drv_stat & ATA_ERR)) { DPRINTK("request check condition\n"); @@ -2176,143 +1782,6 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev) return dev; } -/* - * ata_scsi_map_proto - Map pass-thru protocol value to taskfile value. - * @byte1: Byte 1 from pass-thru CDB. - * - * RETURNS: - * ATA_PROT_UNKNOWN if mapping failed/unimplemented, protocol otherwise. - */ -static u8 -ata_scsi_map_proto(u8 byte1) -{ - switch((byte1 & 0x1e) >> 1) { - case 3: /* Non-data */ - return ATA_PROT_NODATA; - - case 6: /* DMA */ - return ATA_PROT_DMA; - - case 4: /* PIO Data-in */ - case 5: /* PIO Data-out */ - if (byte1 & 0xe0) { - return ATA_PROT_PIO_MULT; - } - return ATA_PROT_PIO; - - case 10: /* Device Reset */ - case 0: /* Hard Reset */ - case 1: /* SRST */ - case 2: /* Bus Idle */ - case 7: /* Packet */ - case 8: /* DMA Queued */ - case 9: /* Device Diagnostic */ - case 11: /* UDMA Data-in */ - case 12: /* UDMA Data-Out */ - case 13: /* FPDMA */ - default: /* Reserved */ - break; - } - - return ATA_PROT_UNKNOWN; -} - -/** - * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile - * @qc: command structure to be initialized - * @cmd: SCSI command to convert - * - * Handles either 12 or 16-byte versions of the CDB. - * - * RETURNS: - * Zero on success, non-zero on failure. - */ -static unsigned int -ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) -{ - struct ata_taskfile *tf = &(qc->tf); - struct scsi_cmnd *cmd = qc->scsicmd; - - if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) - return 1; - - /* - * 12 and 16 byte CDBs use different offsets to - * provide the various register values. - */ - if (scsicmd[0] == ATA_16) { - /* - * 16-byte CDB - may contain extended commands. - * - * If that is the case, copy the upper byte register values. - */ - if (scsicmd[1] & 0x01) { - tf->hob_feature = scsicmd[3]; - tf->hob_nsect = scsicmd[5]; - tf->hob_lbal = scsicmd[7]; - tf->hob_lbam = scsicmd[9]; - tf->hob_lbah = scsicmd[11]; - tf->flags |= ATA_TFLAG_LBA48; - } else - tf->flags &= ~ATA_TFLAG_LBA48; - - /* - * Always copy low byte, device and command registers. - */ - tf->feature = scsicmd[4]; - tf->nsect = scsicmd[6]; - tf->lbal = scsicmd[8]; - tf->lbam = scsicmd[10]; - tf->lbah = scsicmd[12]; - tf->device = scsicmd[13]; - tf->command = scsicmd[14]; - } else { - /* - * 12-byte CDB - incapable of extended commands. - */ - tf->flags &= ~ATA_TFLAG_LBA48; - - tf->feature = scsicmd[3]; - tf->nsect = scsicmd[4]; - tf->lbal = scsicmd[5]; - tf->lbam = scsicmd[6]; - tf->lbah = scsicmd[7]; - tf->device = scsicmd[8]; - tf->command = scsicmd[9]; - } - - /* - * Filter SET_FEATURES - XFER MODE command -- otherwise, - * SET_FEATURES - XFER MODE must be preceded/succeeded - * by an update to hardware-specific registers for each - * controller (i.e. the reason for ->set_piomode(), - * ->set_dmamode(), and ->post_set_mode() hooks). - */ - if ((tf->command == ATA_CMD_SET_FEATURES) - && (tf->feature == SETFEATURES_XFER)) - return 1; - - /* - * Set flags so that all registers will be written, - * and pass on write indication (used for PIO/DMA - * setup.) - */ - tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE); - - if (cmd->sc_data_direction == DMA_TO_DEVICE) - tf->flags |= ATA_TFLAG_WRITE; - - /* - * Set transfer length. - * - * TODO: find out if we need to do more here to - * cover scatter/gather case. - */ - qc->nsect = cmd->bufflen / ATA_SECT_SIZE; - - return 0; -} - /** * ata_get_xlat_func - check if SCSI to ATA translation is possible * @dev: ATA device @@ -2345,11 +1814,6 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) case VERIFY: case VERIFY_16: return ata_scsi_verify_xlat; - - case ATA_12: - case ATA_16: - return ata_scsi_pass_thru; - case START_STOP: return ata_scsi_start_stop_xlat; } @@ -2508,7 +1972,7 @@ void ata_scsi_simulate(u16 *id, ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); break; - /* mandatory commands we haven't implemented yet */ + /* mandantory commands we haven't implemented yet */ case REQUEST_SENSE: /* all other commands */ diff --git a/trunk/drivers/scsi/libata.h b/trunk/drivers/scsi/libata.h index 65c264b91136..3d60190584ba 100644 --- a/trunk/drivers/scsi/libata.h +++ b/trunk/drivers/scsi/libata.h @@ -50,14 +50,13 @@ extern void ata_dev_select(struct ata_port *ap, unsigned int device, unsigned int wait, unsigned int can_sleep); extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf); extern void swap_buf_le16(u16 *buf, unsigned int buf_words); -extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); -extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); /* libata-scsi.c */ extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, struct scsi_cmnd *cmd); extern void ata_scsi_scan_host(struct ata_port *ap); +extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat); extern int ata_scsi_error(struct Scsi_Host *host); extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, unsigned int buflen); diff --git a/trunk/drivers/scsi/pdc_adma.c b/trunk/drivers/scsi/pdc_adma.c index eebb3eb20255..9820f272f889 100644 --- a/trunk/drivers/scsi/pdc_adma.c +++ b/trunk/drivers/scsi/pdc_adma.c @@ -46,7 +46,7 @@ #include #define DRV_NAME "pdc_adma" -#define DRV_VERSION "0.03" +#define DRV_VERSION "0.01" /* macro to calculate base address for ATA regs */ #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) @@ -79,6 +79,7 @@ enum { aNIEN = (1 << 8), /* irq mask: 1==masked */ aGO = (1 << 7), /* packet trigger ("Go!") */ aRSTADM = (1 << 5), /* ADMA logic reset */ + aRSTA = (1 << 2), /* ATA hard reset */ aPIOMD4 = 0x0003, /* PIO mode 4 */ /* ADMA_STATUS register bits */ @@ -292,14 +293,14 @@ static void adma_eng_timeout(struct ata_port *ap) static int adma_fill_sg(struct ata_queued_cmd *qc) { - struct scatterlist *sg; + struct scatterlist *sg = qc->sg; struct ata_port *ap = qc->ap; struct adma_port_priv *pp = ap->private_data; u8 *buf = pp->pkt; - int i = (2 + buf[3]) * 8; + int nelem, i = (2 + buf[3]) * 8; u8 pFLAGS = pORD | ((qc->tf.flags & ATA_TFLAG_WRITE) ? pDIRO : 0); - ata_for_each_sg(sg, qc) { + for (nelem = 0; nelem < qc->n_elem; nelem++,sg++) { u32 addr; u32 len; @@ -311,7 +312,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc) *(__le32 *)(buf + i) = cpu_to_le32(len); i += 4; - if (ata_sg_is_last(sg, qc)) + if ((nelem + 1) == qc->n_elem) pFLAGS |= pEND; buf[i++] = pFLAGS; buf[i++] = qc->dev->dma_mode & 0xf; @@ -451,25 +452,24 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) struct adma_port_priv *pp; struct ata_queued_cmd *qc; void __iomem *chan = ADMA_REGS(mmio_base, port_no); - u8 drv_stat = 0, status = readb(chan + ADMA_STATUS); + u8 drv_stat, status = readb(chan + ADMA_STATUS); if (status == 0) continue; handled = 1; adma_enter_reg_mode(ap); - if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)) + if ((ap->flags & ATA_FLAG_PORT_DISABLED)) continue; pp = ap->private_data; if (!pp || pp->state != adma_state_pkt) continue; qc = ata_qc_from_tag(ap, ap->active_tag); - if (qc && (!(qc->tf.ctl & ATA_NIEN))) { - if ((status & (aPERR | aPSD | aUIRQ))) - drv_stat = ATA_ERR; - else if (pp->pkt[0] != cDONE) - drv_stat = ATA_ERR; - ata_qc_complete(qc, drv_stat); - } + drv_stat = 0; + if ((status & (aPERR | aPSD | aUIRQ))) + drv_stat = ATA_ERR; + else if (pp->pkt[0] != cDONE) + drv_stat = ATA_ERR; + ata_qc_complete(qc, drv_stat); } return handled; } @@ -561,15 +561,15 @@ static int adma_port_start(struct ata_port *ap) if ((pp->pkt_dma & 7) != 0) { printk("bad alignment for pp->pkt_dma: %08x\n", (u32)pp->pkt_dma); - dma_free_coherent(dev, ADMA_PKT_BYTES, - pp->pkt, pp->pkt_dma); - goto err_out_kfree; + goto err_out_kfree2; } memset(pp->pkt, 0, ADMA_PKT_BYTES); ap->private_data = pp; adma_reinit_engine(ap); return 0; +err_out_kfree2: + kfree(pp); err_out_kfree: kfree(pp); err_out: diff --git a/trunk/drivers/scsi/sata_mv.c b/trunk/drivers/scsi/sata_mv.c index 1d6d0c9e76f6..422e0b6f603a 100644 --- a/trunk/drivers/scsi/sata_mv.c +++ b/trunk/drivers/scsi/sata_mv.c @@ -785,24 +785,23 @@ static void mv_port_stop(struct ata_port *ap) static void mv_fill_sg(struct ata_queued_cmd *qc) { struct mv_port_priv *pp = qc->ap->private_data; - unsigned int i = 0; - struct scatterlist *sg; + unsigned int i; - ata_for_each_sg(sg, qc) { + for (i = 0; i < qc->n_elem; i++) { u32 sg_len; dma_addr_t addr; - addr = sg_dma_address(sg); - sg_len = sg_dma_len(sg); + addr = sg_dma_address(&qc->sg[i]); + sg_len = sg_dma_len(&qc->sg[i]); pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff); pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16); assert(0 == (sg_len & ~MV_DMA_BOUNDARY)); pp->sg_tbl[i].flags_size = cpu_to_le32(sg_len); - if (ata_sg_is_last(sg, qc)) - pp->sg_tbl[i].flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL); - - i++; + } + if (0 < qc->n_elem) { + pp->sg_tbl[qc->n_elem - 1].flags_size |= + cpu_to_le32(EPRD_FLAG_END_OF_TBL); } } diff --git a/trunk/drivers/scsi/sata_promise.c b/trunk/drivers/scsi/sata_promise.c index 63911f16b6ec..eee93b0016df 100644 --- a/trunk/drivers/scsi/sata_promise.c +++ b/trunk/drivers/scsi/sata_promise.c @@ -195,8 +195,6 @@ static struct ata_port_info pdc_port_info[] = { static struct pci_device_id pdc_ata_pci_tbl[] = { { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, board_2037x }, - { PCI_VENDOR_ID_PROMISE, 0x3570, PCI_ANY_ID, PCI_ANY_ID, 0, 0, - board_2037x }, { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, board_2037x }, { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, @@ -209,8 +207,6 @@ static struct pci_device_id pdc_ata_pci_tbl[] = { board_2037x }, { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, board_2037x }, - { PCI_VENDOR_ID_PROMISE, 0x3d73, PCI_ANY_ID, PCI_ANY_ID, 0, 0, - board_2037x }, { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, board_20319 }, diff --git a/trunk/drivers/scsi/sata_qstor.c b/trunk/drivers/scsi/sata_qstor.c index de3f266d67b3..250dafa6bc36 100644 --- a/trunk/drivers/scsi/sata_qstor.c +++ b/trunk/drivers/scsi/sata_qstor.c @@ -270,17 +270,16 @@ static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) static void qs_fill_sg(struct ata_queued_cmd *qc) { - struct scatterlist *sg; + struct scatterlist *sg = qc->sg; struct ata_port *ap = qc->ap; struct qs_port_priv *pp = ap->private_data; unsigned int nelem; u8 *prd = pp->pkt + QS_CPB_BYTES; - assert(qc->__sg != NULL); + assert(sg != NULL); assert(qc->n_elem > 0); - nelem = 0; - ata_for_each_sg(sg, qc) { + for (nelem = 0; nelem < qc->n_elem; nelem++,sg++) { u64 addr; u32 len; @@ -294,7 +293,6 @@ static void qs_fill_sg(struct ata_queued_cmd *qc) VPRINTK("PRD[%u] = (0x%llX, 0x%X)\n", nelem, (unsigned long long)addr, len); - nelem++; } } diff --git a/trunk/drivers/scsi/sata_sil24.c b/trunk/drivers/scsi/sata_sil24.c index e0d27a0fbad0..32d730bd5bb6 100644 --- a/trunk/drivers/scsi/sata_sil24.c +++ b/trunk/drivers/scsi/sata_sil24.c @@ -416,20 +416,15 @@ static void sil24_phy_reset(struct ata_port *ap) static inline void sil24_fill_sg(struct ata_queued_cmd *qc, struct sil24_cmd_block *cb) { + struct scatterlist *sg = qc->sg; struct sil24_sge *sge = cb->sge; - struct scatterlist *sg; - unsigned int idx = 0; + unsigned i; - ata_for_each_sg(sg, qc) { + for (i = 0; i < qc->n_elem; i++, sg++, sge++) { sge->addr = cpu_to_le64(sg_dma_address(sg)); sge->cnt = cpu_to_le32(sg_dma_len(sg)); - if (ata_sg_is_last(sg, qc)) - sge->flags = cpu_to_le32(SGE_TRM); - else - sge->flags = 0; - - sge++; - idx++; + sge->flags = 0; + sge->flags = i < qc->n_elem - 1 ? 0 : cpu_to_le32(SGE_TRM); } } diff --git a/trunk/drivers/scsi/sata_sx4.c b/trunk/drivers/scsi/sata_sx4.c index 8710d0f14f93..af08f4f650c1 100644 --- a/trunk/drivers/scsi/sata_sx4.c +++ b/trunk/drivers/scsi/sata_sx4.c @@ -449,14 +449,14 @@ static inline void pdc20621_host_pkt(struct ata_taskfile *tf, u8 *buf, static void pdc20621_dma_prep(struct ata_queued_cmd *qc) { - struct scatterlist *sg; + struct scatterlist *sg = qc->sg; struct ata_port *ap = qc->ap; struct pdc_port_priv *pp = ap->private_data; void __iomem *mmio = ap->host_set->mmio_base; struct pdc_host_priv *hpriv = ap->host_set->private_data; void __iomem *dimm_mmio = hpriv->dimm_mmio; unsigned int portno = ap->port_no; - unsigned int i, idx, total_len = 0, sgt_len; + unsigned int i, last, idx, total_len = 0, sgt_len; u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; assert(qc->flags & ATA_QCFLAG_DMAMAP); @@ -469,11 +469,12 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc) /* * Build S/G table */ + last = qc->n_elem; idx = 0; - ata_for_each_sg(sg, qc) { - buf[idx++] = cpu_to_le32(sg_dma_address(sg)); - buf[idx++] = cpu_to_le32(sg_dma_len(sg)); - total_len += sg_dma_len(sg); + for (i = 0; i < last; i++) { + buf[idx++] = cpu_to_le32(sg_dma_address(&sg[i])); + buf[idx++] = cpu_to_le32(sg_dma_len(&sg[i])); + total_len += sg_dma_len(&sg[i]); } buf[idx - 1] |= cpu_to_le32(ATA_PRD_EOT); sgt_len = idx * 4; diff --git a/trunk/fs/ext3/super.c b/trunk/fs/ext3/super.c index 097383c11154..9e24ceb019fe 100644 --- a/trunk/fs/ext3/super.c +++ b/trunk/fs/ext3/super.c @@ -510,11 +510,19 @@ static void ext3_clear_inode(struct inode *inode) kfree(rsv); } -static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb) +static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) { -#if defined(CONFIG_QUOTA) + struct super_block *sb = vfs->mnt_sb; struct ext3_sb_info *sbi = EXT3_SB(sb); + if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) + seq_puts(seq, ",data=journal"); + else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) + seq_puts(seq, ",data=ordered"); + else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) + seq_puts(seq, ",data=writeback"); + +#if defined(CONFIG_QUOTA) if (sbi->s_jquota_fmt) seq_printf(seq, ",jqfmt=%s", (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0"); @@ -531,20 +539,6 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) seq_puts(seq, ",grpquota"); #endif -} - -static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) -{ - struct super_block *sb = vfs->mnt_sb; - - if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) - seq_puts(seq, ",data=journal"); - else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) - seq_puts(seq, ",data=ordered"); - else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) - seq_puts(seq, ",data=writeback"); - - ext3_show_quota_options(seq, sb); return 0; } diff --git a/trunk/include/linux/i2c-algo-bit.h b/trunk/include/linux/i2c-algo-bit.h index c0e7fab28ce3..110904481238 100644 --- a/trunk/include/linux/i2c-algo-bit.h +++ b/trunk/include/linux/i2c-algo-bit.h @@ -21,6 +21,8 @@ /* With some changes from Kyösti Mälkki and even Frodo Looijaard */ +/* $Id: i2c-algo-bit.h,v 1.10 2003/01/21 08:08:16 kmalkki Exp $ */ + #ifndef _LINUX_I2C_ALGO_BIT_H #define _LINUX_I2C_ALGO_BIT_H @@ -44,6 +46,8 @@ struct i2c_algo_bit_data { int timeout; /* in jiffies */ }; +#define I2C_BIT_ADAP_MAX 16 + int i2c_bit_add_bus(struct i2c_adapter *); int i2c_bit_del_bus(struct i2c_adapter *); diff --git a/trunk/include/linux/i2c-algo-pca.h b/trunk/include/linux/i2c-algo-pca.h index 226693e0d88b..941b786c5732 100644 --- a/trunk/include/linux/i2c-algo-pca.h +++ b/trunk/include/linux/i2c-algo-pca.h @@ -9,6 +9,8 @@ struct i2c_algo_pca_data { int (*wait_for_interrupt) (struct i2c_algo_pca_data *adap); }; +#define I2C_PCA_ADAP_MAX 16 + int i2c_pca_add_bus(struct i2c_adapter *); int i2c_pca_del_bus(struct i2c_adapter *); diff --git a/trunk/include/linux/i2c-algo-pcf.h b/trunk/include/linux/i2c-algo-pcf.h index 18b0adf57a3d..2a508562255f 100644 --- a/trunk/include/linux/i2c-algo-pcf.h +++ b/trunk/include/linux/i2c-algo-pcf.h @@ -22,6 +22,8 @@ /* With some changes from Kyösti Mälkki and even Frodo Looijaard */ +/* $Id: i2c-algo-pcf.h,v 1.8 2003/01/21 08:08:16 kmalkki Exp $ */ + #ifndef _LINUX_I2C_ALGO_PCF_H #define _LINUX_I2C_ALGO_PCF_H @@ -39,6 +41,8 @@ struct i2c_algo_pcf_data { int timeout; }; +#define I2C_PCF_ADAP_MAX 16 + int i2c_pcf_add_bus(struct i2c_adapter *); int i2c_pcf_del_bus(struct i2c_adapter *); diff --git a/trunk/include/linux/i2c-dev.h b/trunk/include/linux/i2c-dev.h index 81c229a0fbca..541695679762 100644 --- a/trunk/include/linux/i2c-dev.h +++ b/trunk/include/linux/i2c-dev.h @@ -19,6 +19,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* $Id: i2c-dev.h,v 1.13 2003/01/21 08:08:16 kmalkki Exp $ */ + #ifndef _LINUX_I2C_DEV_H #define _LINUX_I2C_DEV_H diff --git a/trunk/include/linux/i2c-id.h b/trunk/include/linux/i2c-id.h index 1ce4b54caa21..44f30876a1c9 100644 --- a/trunk/include/linux/i2c-id.h +++ b/trunk/include/linux/i2c-id.h @@ -164,7 +164,10 @@ /* --- Bit algorithm adapters */ #define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ +#define I2C_HW_B_LPC 0x010001 /* Parallel port control reg. */ #define I2C_HW_B_SER 0x010002 /* Serial line interface */ +#define I2C_HW_B_ELV 0x010003 /* ELV Card */ +#define I2C_HW_B_VELLE 0x010004 /* Vellemann K8000 */ #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ #define I2C_HW_B_WNV 0x010006 /* Winnov Videums */ #define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */ diff --git a/trunk/include/linux/i2c.h b/trunk/include/linux/i2c.h index f88577ca3b3a..3d49a305bf88 100644 --- a/trunk/include/linux/i2c.h +++ b/trunk/include/linux/i2c.h @@ -23,13 +23,14 @@ /* With some changes from Kyösti Mälkki and Frodo Looijaard */ +/* $Id: i2c.h,v 1.68 2003/01/21 08:08:16 kmalkki Exp $ */ + #ifndef _LINUX_I2C_H #define _LINUX_I2C_H #include #include #include -#include #include /* for struct device */ #include @@ -93,10 +94,10 @@ extern s32 i2c_smbus_write_byte_data(struct i2c_client * client, extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); extern s32 i2c_smbus_write_word_data(struct i2c_client * client, u8 command, u16 value); +/* Returns the number of bytes transferred */ extern s32 i2c_smbus_write_block_data(struct i2c_client * client, u8 command, u8 length, u8 *values); -/* Returns the number of read bytes */ extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, u8 command, u8 *values); @@ -390,6 +391,10 @@ struct i2c_msg { #define I2C_FUNC_10BIT_ADDR 0x00000002 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ +#define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC 0x00000800 /* SMBus 2.0 */ +#define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */ +#define I2C_FUNC_SMBUS_PROC_CALL_PEC 0x00002000 /* SMBus 2.0 */ +#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_QUICK 0x00010000 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 @@ -405,6 +410,8 @@ struct i2c_msg { #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */ +#define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC 0x40000000 /* SMBus 2.0 */ +#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ I2C_FUNC_SMBUS_WRITE_BYTE) @@ -418,6 +425,17 @@ struct i2c_msg { I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) #define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \ I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2) +#define I2C_FUNC_SMBUS_BLOCK_DATA_PEC (I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \ + I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC) +#define I2C_FUNC_SMBUS_WORD_DATA_PEC (I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \ + I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC) + +#define I2C_FUNC_SMBUS_READ_BYTE_PEC I2C_FUNC_SMBUS_READ_BYTE_DATA +#define I2C_FUNC_SMBUS_WRITE_BYTE_PEC I2C_FUNC_SMBUS_WRITE_BYTE_DATA +#define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC I2C_FUNC_SMBUS_READ_WORD_DATA +#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC I2C_FUNC_SMBUS_WRITE_WORD_DATA +#define I2C_FUNC_SMBUS_BYTE_PEC I2C_FUNC_SMBUS_BYTE_DATA +#define I2C_FUNC_SMBUS_BYTE_DATA_PEC I2C_FUNC_SMBUS_WORD_DATA #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ I2C_FUNC_SMBUS_BYTE | \ @@ -425,17 +443,20 @@ struct i2c_msg { I2C_FUNC_SMBUS_WORD_DATA | \ I2C_FUNC_SMBUS_PROC_CALL | \ I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ + I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC | \ I2C_FUNC_SMBUS_I2C_BLOCK) /* * Data for SMBus Messages */ #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ +#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */ union i2c_smbus_data { __u8 byte; __u16 word; - __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ - /* and one more for user-space compatibility */ + __u8 block[I2C_SMBUS_BLOCK_MAX + 3]; /* block[0] is used for length */ + /* one more for read length in block process call */ + /* and one more for PEC */ }; /* smbus_access read or write markers */ @@ -452,6 +473,10 @@ union i2c_smbus_data { #define I2C_SMBUS_BLOCK_DATA 5 #define I2C_SMBUS_I2C_BLOCK_DATA 6 #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ +#define I2C_SMBUS_BLOCK_DATA_PEC 8 /* SMBus 2.0 */ +#define I2C_SMBUS_PROC_CALL_PEC 9 /* SMBus 2.0 */ +#define I2C_SMBUS_BLOCK_PROC_CALL_PEC 10 /* SMBus 2.0 */ +#define I2C_SMBUS_WORD_DATA_PEC 11 /* SMBus 2.0 */ /* ----- commands for the ioctl like i2c_command call: @@ -481,6 +506,11 @@ union i2c_smbus_data { #define I2C_SMBUS 0x0720 /* SMBus-level access */ +/* ... algo-bit.c recognizes */ +#define I2C_UDELAY 0x0705 /* set delay in microsecs between each */ + /* written byte (except address) */ +#define I2C_MDELAY 0x0706 /* millisec delay between written bytes */ + /* ----- I2C-DEV: char device interface stuff ------------------------- */ #define I2C_MAJOR 89 /* Device major number */ diff --git a/trunk/include/linux/libata.h b/trunk/include/linux/libata.h index 5f17203520cb..00a8a5738858 100644 --- a/trunk/include/linux/libata.h +++ b/trunk/include/linux/libata.h @@ -155,10 +155,6 @@ enum { ATA_SHIFT_UDMA = 0, ATA_SHIFT_MWDMA = 8, ATA_SHIFT_PIO = 11, - - /* size of buffer to pad xfers ending on unaligned boundaries */ - ATA_DMA_PAD_SZ = 4, - ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, /* Masks for port functions */ ATA_PORT_PRIMARY = (1 << 0), @@ -246,12 +242,9 @@ struct ata_queued_cmd { unsigned long flags; /* ATA_QCFLAG_xxx */ unsigned int tag; unsigned int n_elem; - unsigned int orig_n_elem; int dma_dir; - unsigned int pad_len; - unsigned int nsect; unsigned int cursect; @@ -262,11 +255,9 @@ struct ata_queued_cmd { unsigned int cursg_ofs; struct scatterlist sgent; - struct scatterlist pad_sgent; void *buf_virt; - /* DO NOT iterate over __sg manually, use ata_for_each_sg() */ - struct scatterlist *__sg; + struct scatterlist *sg; ata_qc_cb_t complete_fn; @@ -312,9 +303,6 @@ struct ata_port { struct ata_prd *prd; /* our SG list */ dma_addr_t prd_dma; /* and its DMA mapping */ - void *pad; /* array of DMA pad buffers */ - dma_addr_t pad_dma; - struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ u8 ctl; /* cache of ATA control register */ @@ -519,31 +507,6 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit #endif /* CONFIG_PCI */ -static inline int -ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) -{ - if (sg == &qc->pad_sgent) - return 1; - if (qc->pad_len) - return 0; - if (((sg - qc->__sg) + 1) == qc->n_elem) - return 1; - return 0; -} - -static inline struct scatterlist * -ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc) -{ - if (sg == &qc->pad_sgent) - return NULL; - if (++sg - qc->__sg < qc->n_elem) - return sg; - return qc->pad_len ? &qc->pad_sgent : NULL; -} - -#define ata_for_each_sg(sg, qc) \ - for (sg = qc->__sg; sg; sg = ata_qc_next_sg(sg, qc)) - static inline unsigned int ata_tag_valid(unsigned int tag) { return (tag < ATA_MAX_QUEUE) ? 1 : 0; diff --git a/trunk/include/linux/mod_devicetable.h b/trunk/include/linux/mod_devicetable.h index 7b08c11ec4cc..2f0299a448f6 100644 --- a/trunk/include/linux/mod_devicetable.h +++ b/trunk/include/linux/mod_devicetable.h @@ -244,9 +244,4 @@ struct pcmcia_device_id { #define PCMCIA_DEV_ID_MATCH_FAKE_CIS 0x0200 #define PCMCIA_DEV_ID_MATCH_ANONYMOUS 0x0400 -/* I2C */ -struct i2c_device_id { - __u16 id; -}; - #endif /* LINUX_MOD_DEVICETABLE_H */ diff --git a/trunk/include/linux/x1205.h b/trunk/include/linux/x1205.h deleted file mode 100644 index 64fd3af894a5..000000000000 --- a/trunk/include/linux/x1205.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * x1205.h - defines for drivers/i2c/chips/x1205.c - * Copyright 2004 Karen Spearel - * Copyright 2005 Alessandro Zummo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __LINUX_X1205_H__ -#define __LINUX_X1205_H__ - -/* commands */ - -#define X1205_CMD_GETDATETIME 0 -#define X1205_CMD_SETTIME 1 -#define X1205_CMD_SETDATETIME 2 -#define X1205_CMD_GETALARM 3 -#define X1205_CMD_SETALARM 4 -#define X1205_CMD_GETDTRIM 5 -#define X1205_CMD_SETDTRIM 6 -#define X1205_CMD_GETATRIM 7 -#define X1205_CMD_SETATRIM 8 - -extern int x1205_do_command(unsigned int cmd, void *arg); -extern int x1205_direct_attach(int adapter_id, - struct i2c_client_address_data *address_data); - -#endif /* __LINUX_X1205_H__ */ diff --git a/trunk/include/media/ovcamchip.h b/trunk/include/media/ovcamchip.h index 8138983adced..cb7c0aa96f22 100644 --- a/trunk/include/media/ovcamchip.h +++ b/trunk/include/media/ovcamchip.h @@ -17,6 +17,20 @@ #include #include +/* Remove these once they are officially defined */ +#ifndef I2C_DRIVERID_OVCAMCHIP + #define I2C_DRIVERID_OVCAMCHIP 0xf00f +#endif +#ifndef I2C_HW_SMBUS_OV511 + #define I2C_HW_SMBUS_OV511 0xfe +#endif +#ifndef I2C_HW_SMBUS_OV518 + #define I2C_HW_SMBUS_OV518 0xff +#endif +#ifndef I2C_HW_SMBUS_OVFX2 + #define I2C_HW_SMBUS_OVFX2 0xfd +#endif + /* --------------------------------- */ /* ENUMERATIONS */ /* --------------------------------- */ diff --git a/trunk/include/scsi/scsi.h b/trunk/include/scsi/scsi.h index 6cb1e2788d8b..b361172b576c 100644 --- a/trunk/include/scsi/scsi.h +++ b/trunk/include/scsi/scsi.h @@ -116,9 +116,6 @@ extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE]; /* values for service action in */ #define SAI_READ_CAPACITY_16 0x10 -/* Values for T10/04-262r7 */ -#define ATA_16 0x85 /* 16-byte pass-thru */ -#define ATA_12 0xa1 /* 12-byte pass-thru */ /* * SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft diff --git a/trunk/scripts/mod/file2alias.c b/trunk/scripts/mod/file2alias.c index e3d144a3f10b..f2ee673329a7 100644 --- a/trunk/scripts/mod/file2alias.c +++ b/trunk/scripts/mod/file2alias.c @@ -359,13 +359,6 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, return 1; } -static int do_i2c_entry(const char *filename, struct i2c_device_id *i2c, char *alias) -{ - strcpy(alias, "i2c:"); - ADD(alias, "id", 1, i2c->id); - return 1; -} - /* Ignore any prefix, eg. v850 prepends _ */ static inline int sym_is(const char *symbol, const char *name) { @@ -450,9 +443,6 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, else if (sym_is(symname, "__mod_vio_device_table")) do_table(symval, sym->st_size, sizeof(struct vio_device_id), do_vio_entry, mod); - else if (sym_is(symname, "__mod_i2c_device_table")) - do_table(symval, sym->st_size, sizeof(struct i2c_device_id), - do_i2c_entry, mod); }