diff options
author | Greg KH <greg@press.(none)> | 2005-10-18 11:29:14 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-18 11:29:14 -0700 |
commit | 3ff4d78b5ca6701ee5056bc177602bd8b571b760 (patch) | |
tree | 0dc21d2d05e8768a569c06a7217dcbac655bb210 /i2c | |
parent | 1ba0debc2902c1ccdaef8db09725f8eb47aad496 (diff) | |
download | patches-3ff4d78b5ca6701ee5056bc177602bd8b571b760.tar.gz |
lots of i2c patches.
created the bad/ directory for stuff that's not worth applying, but not bad
enough to throw away.
Diffstat (limited to 'i2c')
-rw-r--r-- | i2c/hwmon-missing-driver-class.patch | 41 | ||||
-rw-r--r-- | i2c/hwmon-smsc47b397-new-id.patch | 82 | ||||
-rw-r--r-- | i2c/i2c-owner-field-01-struct-pci-driver.patch | 217 | ||||
-rw-r--r-- | i2c/i2c-owner-field-02-struct-device-driver.patch | 108 | ||||
-rw-r--r-- | i2c/i2c-owner-field-03-i2c-keywest.patch | 41 | ||||
-rw-r--r-- | i2c/i2c-owner-field-04-i2c-core.patch | 47 | ||||
-rw-r--r-- | i2c/i2c-owner-field-05-i2c-isa.patch | 31 | ||||
-rw-r--r-- | i2c/i2c-x1205.patch | 827 | ||||
-rw-r--r-- | i2c/kzalloc-01-i2c-ixp.patch | 54 | ||||
-rw-r--r-- | i2c/kzalloc-02-hwmon.patch | 617 | ||||
-rw-r--r-- | i2c/kzalloc-03-i2c-other.patch | 399 | ||||
-rw-r--r-- | i2c/kzalloc-04-drop-useless-casts.patch | 43 | ||||
-rw-r--r-- | i2c/kzalloc-05-i2c-amd756-s4882.patch | 35 | ||||
-rw-r--r-- | i2c/kzalloc-06-i2c-documentation-update.patch | 78 |
14 files changed, 2620 insertions, 0 deletions
diff --git a/i2c/hwmon-missing-driver-class.patch b/i2c/hwmon-missing-driver-class.patch new file mode 100644 index 0000000000000..2fc9e626d9813 --- /dev/null +++ b/i2c/hwmon-missing-driver-class.patch @@ -0,0 +1,41 @@ +From khali@linux-fr.org Mon Oct 17 14:04:25 2005 +Date: Mon, 17 Oct 2005 23:02:42 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 07/14] hwmon: Missing class check in two hwmon drivers +Message-Id: <20051017230242.1b29cbd6.khali@linux-fr.org> +Content-Disposition: inline; filename=hwmon-missing-driver-class.patch + +The atxp1 and ds1621 drivers should make sure they do not probe +non-hwmon i2c adapters. + +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/hwmon/atxp1.c | 2 ++ + drivers/hwmon/ds1621.c | 2 ++ + 2 files changed, 4 insertions(+) + +--- gregkh-2.6.orig/drivers/hwmon/atxp1.c ++++ gregkh-2.6/drivers/hwmon/atxp1.c +@@ -253,6 +253,8 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IW + + 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); + }; + +--- gregkh-2.6.orig/drivers/hwmon/ds1621.c ++++ gregkh-2.6/drivers/hwmon/ds1621.c +@@ -180,6 +180,8 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | + + 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); + } + diff --git a/i2c/hwmon-smsc47b397-new-id.patch b/i2c/hwmon-smsc47b397-new-id.patch new file mode 100644 index 0000000000000..bb6512aa04557 --- /dev/null +++ b/i2c/hwmon-smsc47b397-new-id.patch @@ -0,0 +1,82 @@ +From khali@linux-fr.org Mon Oct 17 14:04:17 2005 +Date: Mon, 17 Oct 2005 23:01:45 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 06/14] hwmon: New device ID for the smsc47b397 driver +Message-Id: <20051017230145.4a7fdf44.khali@linux-fr.org> +Content-Disposition: inline; filename=hwmon-smsc47b397-new-id.patch + +From: "Mark M. Hoffman" <mhoffman@lightlink.com> + +This patch adds a new ID to the SMSC LPC47B397-NC hardware +monitoring driver - for a chip that is claimed to be 100% +compatible otherwise. + +Signed-off-by: Bryan Young (Utilitek Systems, Inc.) +Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + Documentation/hwmon/smsc47b397 | 8 ++++++-- + drivers/hwmon/smsc47b397.c | 7 ++++--- + 2 files changed, 10 insertions(+), 5 deletions(-) + +--- gregkh-2.6.orig/drivers/hwmon/smsc47b397.c ++++ gregkh-2.6/drivers/hwmon/smsc47b397.c +@@ -299,7 +299,7 @@ static int __init smsc47b397_find(unsign + superio_enter(); + id = superio_inb(SUPERIO_REG_DEVID); + +- if (id != 0x6f) { ++ if ((id != 0x6f) && (id != 0x81)) { + superio_exit(); + return -ENODEV; + } +@@ -310,8 +310,9 @@ static int __init smsc47b397_find(unsign + *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) + | superio_inb(SUPERIO_REG_BASE_LSB); + +- printk(KERN_INFO "smsc47b397: found SMSC LPC47B397-NC " +- "(base address 0x%04x, revision %u)\n", *addr, rev); ++ printk(KERN_INFO "smsc47b397: found SMSC %s " ++ "(base address 0x%04x, revision %u)\n", ++ id == 0x81 ? "SCH5307-NS" : "LPC47B397-NC", *addr, rev); + + superio_exit(); + return 0; +--- gregkh-2.6.orig/Documentation/hwmon/smsc47b397 ++++ gregkh-2.6/Documentation/hwmon/smsc47b397 +@@ -3,6 +3,7 @@ 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 +@@ -12,11 +13,14 @@ Authors: Mark M. Hoffman <mhoffman@light + + November 23, 2004 + +-The following specification describes the SMSC LPC47B397-NC sensor chip ++The following specification describes the SMSC LPC47B397-NC[1] 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 <mhoffman@lightlink.com>. + ++[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. +@@ -127,7 +131,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 ++The Device ID will read 0x6F (for SCH5307-NS, 0x81) + The Device Rev currently reads 0x01 + + Obtaining the HWM Base Address. diff --git a/i2c/i2c-owner-field-01-struct-pci-driver.patch b/i2c/i2c-owner-field-01-struct-pci-driver.patch new file mode 100644 index 0000000000000..5fea477214e47 --- /dev/null +++ b/i2c/i2c-owner-field-01-struct-pci-driver.patch @@ -0,0 +1,217 @@ +From khali@linux-fr.org Mon Oct 17 13:47:49 2005 +Date: Mon, 17 Oct 2005 22:47:48 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 01/14] Owner field additions to many i2c drivers, 1 of 5 +Message-Id: <20051017224748.75cdda3f.khali@linux-fr.org> +Content-Disposition: inline; filename=i2c-owner-field-01-struct-pci-driver.patch + +From: Laurent Riffard <laurent.riffard@free.fr> + +This patch updates .owner field for various struct pci_driver variables. + +Signed-off-by: Laurent Riffard <laurent.riffard@free.fr> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-ali1535.c | 1 + + drivers/i2c/busses/i2c-ali1563.c | 1 + + drivers/i2c/busses/i2c-ali15x3.c | 1 + + drivers/i2c/busses/i2c-amd756.c | 1 + + drivers/i2c/busses/i2c-amd8111.c | 1 + + drivers/i2c/busses/i2c-hydra.c | 1 + + drivers/i2c/busses/i2c-i801.c | 1 + + drivers/i2c/busses/i2c-i810.c | 1 + + drivers/i2c/busses/i2c-nforce2.c | 1 + + drivers/i2c/busses/i2c-piix4.c | 1 + + drivers/i2c/busses/i2c-prosavage.c | 1 + + drivers/i2c/busses/i2c-savage4.c | 1 + + drivers/i2c/busses/i2c-sis5595.c | 1 + + drivers/i2c/busses/i2c-sis630.c | 1 + + drivers/i2c/busses/i2c-sis96x.c | 1 + + drivers/i2c/busses/i2c-via.c | 1 + + drivers/i2c/busses/i2c-viapro.c | 1 + + drivers/i2c/busses/i2c-voodoo3.c | 1 + + 18 files changed, 18 insertions(+) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ali1535.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ali1535.c +@@ -513,6 +513,7 @@ static void __devexit ali1535_remove(str + } + + static struct pci_driver ali1535_driver = { ++ .owner = THIS_MODULE, + .name = "ali1535_smbus", + .id_table = ali1535_ids, + .probe = ali1535_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ali1563.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ali1563.c +@@ -408,6 +408,7 @@ static struct pci_device_id __devinitdat + MODULE_DEVICE_TABLE (pci, ali1563_id_table); + + static struct pci_driver ali1563_pci_driver = { ++ .owner = THIS_MODULE, + .name = "ali1563_smbus", + .id_table = ali1563_id_table, + .probe = ali1563_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ali15x3.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ali15x3.c +@@ -504,6 +504,7 @@ static void __devexit ali15x3_remove(str + } + + static struct pci_driver ali15x3_driver = { ++ .owner = THIS_MODULE, + .name = "ali15x3_smbus", + .id_table = ali15x3_ids, + .probe = ali15x3_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-amd756.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-amd756.c +@@ -401,6 +401,7 @@ static void __devexit amd756_remove(stru + } + + static struct pci_driver amd756_driver = { ++ .owner = THIS_MODULE, + .name = "amd756_smbus", + .id_table = amd756_ids, + .probe = amd756_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-amd8111.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-amd8111.c +@@ -392,6 +392,7 @@ static void __devexit amd8111_remove(str + } + + static struct pci_driver amd8111_driver = { ++ .owner = THIS_MODULE, + .name = "amd8111_smbus2", + .id_table = amd8111_ids, + .probe = amd8111_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-hydra.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-hydra.c +@@ -155,6 +155,7 @@ static void __devexit hydra_remove(struc + + + static struct pci_driver hydra_driver = { ++ .owner = THIS_MODULE, + .name = "hydra_smbus", + .id_table = hydra_ids, + .probe = hydra_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-i801.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-i801.c +@@ -568,6 +568,7 @@ static void __devexit i801_remove(struct + } + + static struct pci_driver i801_driver = { ++ .owner = THIS_MODULE, + .name = "i801_smbus", + .id_table = i801_ids, + .probe = i801_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-i810.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-i810.c +@@ -232,6 +232,7 @@ static void __devexit i810_remove(struct + } + + static struct pci_driver i810_driver = { ++ .owner = THIS_MODULE, + .name = "i810_smbus", + .id_table = i810_ids, + .probe = i810_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-nforce2.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-nforce2.c +@@ -356,6 +356,7 @@ static void __devexit nforce2_remove(str + } + + static struct pci_driver nforce2_driver = { ++ .owner = THIS_MODULE, + .name = "nForce2_smbus", + .id_table = nforce2_ids, + .probe = nforce2_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-piix4.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-piix4.c +@@ -462,6 +462,7 @@ static void __devexit piix4_remove(struc + } + + static struct pci_driver piix4_driver = { ++ .owner = THIS_MODULE, + .name = "piix4_smbus", + .id_table = piix4_ids, + .probe = piix4_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-prosavage.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-prosavage.c +@@ -308,6 +308,7 @@ static struct pci_device_id prosavage_pc + 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, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-savage4.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-savage4.c +@@ -179,6 +179,7 @@ static void __devexit savage4_remove(str + } + + static struct pci_driver savage4_driver = { ++ .owner = THIS_MODULE, + .name = "savage4_smbus", + .id_table = savage4_ids, + .probe = savage4_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-sis5595.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-sis5595.c +@@ -398,6 +398,7 @@ static void __devexit sis5595_remove(str + } + + static struct pci_driver sis5595_driver = { ++ .owner = THIS_MODULE, + .name = "sis5595_smbus", + .id_table = sis5595_ids, + .probe = sis5595_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-sis630.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-sis630.c +@@ -496,6 +496,7 @@ static void __devexit sis630_remove(stru + + + static struct pci_driver sis630_driver = { ++ .owner = THIS_MODULE, + .name = "sis630_smbus", + .id_table = sis630_ids, + .probe = sis630_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-sis96x.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-sis96x.c +@@ -329,6 +329,7 @@ static void __devexit sis96x_remove(stru + } + + static struct pci_driver sis96x_driver = { ++ .owner = THIS_MODULE, + .name = "sis96x_smbus", + .id_table = sis96x_ids, + .probe = sis96x_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-via.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-via.c +@@ -159,6 +159,7 @@ static void __devexit vt586b_remove(stru + + + static struct pci_driver vt586b_driver = { ++ .owner = THIS_MODULE, + .name = "vt586b_smbus", + .id_table = vt586b_ids, + .probe = vt586b_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c +@@ -439,6 +439,7 @@ static struct pci_device_id 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, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-voodoo3.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-voodoo3.c +@@ -225,6 +225,7 @@ static void __devexit voodoo3_remove(str + } + + static struct pci_driver voodoo3_driver = { ++ .owner = THIS_MODULE, + .name = "voodoo3_smbus", + .id_table = voodoo3_ids, + .probe = voodoo3_probe, diff --git a/i2c/i2c-owner-field-02-struct-device-driver.patch b/i2c/i2c-owner-field-02-struct-device-driver.patch new file mode 100644 index 0000000000000..050c7e264229f --- /dev/null +++ b/i2c/i2c-owner-field-02-struct-device-driver.patch @@ -0,0 +1,108 @@ +From khali@linux-fr.org Mon Oct 17 13:53:08 2005 +Date: Mon, 17 Oct 2005 22:51:37 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 02/14] Owner field additions to many i2c drivers, 2 of 5 +Message-Id: <20051017225137.75a0adfb.khali@linux-fr.org> +Content-Disposition: inline; filename=i2c-owner-field-02-struct-device-driver.patch + +From: Laurent Riffard <laurent.riffard@free.fr> + +This patch updates the .owner field for various struct xxxx_driver variables, +other than pci_driver. + +Signed-off-by: Laurent Riffard <laurent.riffard@free.fr> +Signed-off-by: Jean Delvare <khali@linux-fr> +Acked-by: Mark A. Greer <mgreer@mvista.com> +Acked-by: Ben Dooks <ben-linux@fluff.org> +Acked-by: Deepak Saxena <dsaxena@mvista.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-iop3xx.c | 1 + + drivers/i2c/busses/i2c-ixp2000.c | 1 + + drivers/i2c/busses/i2c-ixp4xx.c | 1 + + drivers/i2c/busses/i2c-mpc.c | 1 + + drivers/i2c/busses/i2c-mv64xxx.c | 1 + + drivers/i2c/busses/i2c-s3c2410.c | 2 ++ + drivers/i2c/chips/isp1301_omap.c | 1 + + 7 files changed, 8 insertions(+) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-iop3xx.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-iop3xx.c +@@ -525,6 +525,7 @@ out: + + + static struct device_driver iop3xx_i2c_driver = { ++ .owner = THIS_MODULE, + .name = "IOP3xx-I2C", + .bus = &platform_bus_type, + .probe = iop3xx_i2c_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ixp2000.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ixp2000.c +@@ -146,6 +146,7 @@ static int ixp2000_i2c_probe(struct devi + } + + static struct device_driver ixp2000_i2c_driver = { ++ .owner = THIS_MODULE, + .name = "IXP2000-I2C", + .bus = &platform_bus_type, + .probe = ixp2000_i2c_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ixp4xx.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ixp4xx.c +@@ -155,6 +155,7 @@ static int ixp4xx_i2c_probe(struct devic + } + + static struct device_driver ixp4xx_i2c_driver = { ++ .owner = THIS_MODULE, + .name = "IXP4XX-I2C", + .bus = &platform_bus_type, + .probe = ixp4xx_i2c_probe, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-mpc.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-mpc.c +@@ -361,6 +361,7 @@ static int fsl_i2c_remove(struct 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, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-mv64xxx.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-mv64xxx.c +@@ -570,6 +570,7 @@ 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, +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-s3c2410.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-s3c2410.c +@@ -898,6 +898,7 @@ static int s3c24xx_i2c_resume(struct 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, +@@ -906,6 +907,7 @@ static struct device_driver s3c2410_i2c_ + }; + + static struct device_driver s3c2440_i2c_driver = { ++ .owner = THIS_MODULE, + .name = "s3c2440-i2c", + .bus = &platform_bus_type, + .probe = s3c24xx_i2c_probe, +--- gregkh-2.6.orig/drivers/i2c/chips/isp1301_omap.c ++++ gregkh-2.6/drivers/i2c/chips/isp1301_omap.c +@@ -888,6 +888,7 @@ 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/i2c/i2c-owner-field-03-i2c-keywest.patch b/i2c/i2c-owner-field-03-i2c-keywest.patch new file mode 100644 index 0000000000000..38420c0e958bc --- /dev/null +++ b/i2c/i2c-owner-field-03-i2c-keywest.patch @@ -0,0 +1,41 @@ +From khali@linux-fr.org Mon Oct 17 13:53:17 2005 +Date: Mon, 17 Oct 2005 22:53:52 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 03/14] Owner field additions to many i2c drivers, 3 of 5 +Message-Id: <20051017225352.708f8c24.khali@linux-fr.org> +Content-Disposition: inline; filename=i2c-owner-field-03-i2c-keywest.patch + +From: Laurent Riffard <laurent.riffard@free.fr> + +This patch updates the .owner field for various struct xxxx_driver +variables which are available on PPC_MAC arch. + +This one was _not_ even compile-tested... + +Signed-off-by: Laurent Riffard <laurent.riffard@free.fr> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-keywest.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-keywest.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-keywest.c +@@ -716,6 +716,7 @@ static struct of_device_id i2c_keywest_m + + static struct macio_driver i2c_keywest_macio_driver = + { ++ .owner = THIS_MODULE, + .name = "i2c-keywest", + .match_table = i2c_keywest_match, + .probe = create_iface_macio, +@@ -724,6 +725,7 @@ static struct macio_driver i2c_keywest_m + + 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/i2c/i2c-owner-field-04-i2c-core.patch b/i2c/i2c-owner-field-04-i2c-core.patch new file mode 100644 index 0000000000000..d5cd934e49e60 --- /dev/null +++ b/i2c/i2c-owner-field-04-i2c-core.patch @@ -0,0 +1,47 @@ +From khali@linux-fr.org Mon Oct 17 13:58:30 2005 +Date: Mon, 17 Oct 2005 22:54:45 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 04/14] Owner field additions to many i2c drivers, 4 of 5 +Message-Id: <20051017225445.60bd4297.khali@linux-fr.org> +Content-Disposition: inline; filename=i2c-owner-field-04-i2c-core.patch + +From: Laurent Riffard <laurent.riffard@free.fr> + +This patch updates the .owner field for the i2c core struct xxxx_driver +variables. + +Signed-off-by: Laurent Riffard <laurent.riffard@free.fr> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/i2c-core.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- gregkh-2.6.orig/drivers/i2c/i2c-core.c ++++ gregkh-2.6/drivers/i2c/i2c-core.c +@@ -85,6 +85,7 @@ void i2c_adapter_dev_release(struct devi + } + + struct device_driver i2c_adapter_driver = { ++ .owner = THIS_MODULE, + .name = "i2c_adapter", + .bus = &i2c_bus_type, + .probe = i2c_device_probe, +@@ -98,6 +99,7 @@ static void i2c_adapter_class_dev_releas + } + + struct class i2c_adapter_class = { ++ .owner = THIS_MODULE, + .name = "i2c-adapter", + .release = &i2c_adapter_class_dev_release, + }; +@@ -291,6 +293,7 @@ int i2c_add_driver(struct i2c_driver *dr + 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; diff --git a/i2c/i2c-owner-field-05-i2c-isa.patch b/i2c/i2c-owner-field-05-i2c-isa.patch new file mode 100644 index 0000000000000..0c79bb6d0702a --- /dev/null +++ b/i2c/i2c-owner-field-05-i2c-isa.patch @@ -0,0 +1,31 @@ +From khali@linux-fr.org Mon Oct 17 13:58:47 2005 +Date: Mon, 17 Oct 2005 22:58:35 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 05/14] Owner field additions to many i2c drivers, 5 of 5 +Message-Id: <20051017225835.418f46f4.khali@linux-fr.org> +Content-Disposition: inline; filename=i2c-owner-field-05-i2c-isa.patch + +From: Laurent Riffard <laurent.riffard@free.fr> + +In function i2c_isa_add_driver, copied driver should inherit the owner +field as well as the name field. + +Signed-off-by: Laurent Riffard <laurent.riffard@free.fr> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-isa.c | 1 + + 1 file changed, 1 insertion(+) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-isa.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-isa.c +@@ -92,6 +92,7 @@ int i2c_isa_add_driver(struct i2c_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/i2c/i2c-x1205.patch b/i2c/i2c-x1205.patch new file mode 100644 index 0000000000000..325c20f1fa5bf --- /dev/null +++ b/i2c/i2c-x1205.patch @@ -0,0 +1,827 @@ +From khali@linux-fr.org Mon Oct 17 14:05:10 2005 +Date: Mon, 17 Oct 2005 23:04:42 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Cc: Alessandro Zummo <alessandro.zummo@towertech.it> +Subject: [PATCH 08/14] i2c: New Xicor X1205 RTC driver +Message-Id: <20051017230442.24010f03.khali@linux-fr.org> +Content-Disposition: inline; filename=i2c-x1205.patch + +From: Alessandro Zummo <alessandro.zummo@towertech.it> + +New driver for the Xicor X1205 RTC chip. + +Signed-off-by: Alessandro Zummo <alessandro.zummo@towertech.it> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + Documentation/i2c/chips/x1205 | 38 ++ + drivers/i2c/chips/Kconfig | 9 + drivers/i2c/chips/Makefile | 1 + drivers/i2c/chips/x1205.c | 698 ++++++++++++++++++++++++++++++++++++++++++ + include/linux/x1205.h | 31 + + 5 files changed, 777 insertions(+) + +--- gregkh-2.6.orig/drivers/i2c/chips/Kconfig ++++ gregkh-2.6/drivers/i2c/chips/Kconfig +@@ -126,4 +126,13 @@ 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 +--- gregkh-2.6.orig/drivers/i2c/chips/Makefile ++++ gregkh-2.6/drivers/i2c/chips/Makefile +@@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591 + 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 +--- /dev/null ++++ gregkh-2.6/drivers/i2c/chips/x1205.c +@@ -0,0 +1,698 @@ ++/* ++ * 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 <linux/module.h> ++#include <linux/init.h> ++#include <linux/slab.h> ++#include <linux/i2c.h> ++#include <linux/string.h> ++#include <linux/bcd.h> ++#include <linux/rtc.h> ++#include <linux/list.h> ++ ++#include <linux/x1205.h> ++ ++#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 <kas11@tampabay.rr.com>, " ++ "Alessandro Zummo <a.zummo@towertech.it>"); ++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); +--- /dev/null ++++ gregkh-2.6/include/linux/x1205.h +@@ -0,0 +1,31 @@ ++/* ++ * 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__ */ +--- /dev/null ++++ gregkh-2.6/Documentation/i2c/chips/x1205 +@@ -0,0 +1,38 @@ ++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 <kas11@tampabay.rr.com>, ++ Alessandro Zummo <a.zummo@towertech.it> ++ ++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/i2c/kzalloc-01-i2c-ixp.patch b/i2c/kzalloc-01-i2c-ixp.patch new file mode 100644 index 0000000000000..946eae6bc505d --- /dev/null +++ b/i2c/kzalloc-01-i2c-ixp.patch @@ -0,0 +1,54 @@ +From khali@linux-fr.org Mon Oct 17 14:10:53 2005 +Date: Mon, 17 Oct 2005 23:07:05 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Cc: Deepak Saxena <dsaxena@plexity.net> +Subject: [PATCH 09/14] i2c: kzalloc conversion, ixp bus drivers +Message-Id: <20051017230705.1aac3bf2.khali@linux-fr.org> +Content-Disposition: inline; filename=kzalloc-01-i2c-ixp.patch + +From: Deepak Saxena <dsaxena@plexity.net> + +Use kzalloc instead of kmalloc+memzero in the ixp2000 and ixp4xx +I2C bus drivers. + +Signed-off-by: Deepak Saxena <dsaxena@mvista.com> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-ixp2000.c | 3 +-- + drivers/i2c/busses/i2c-ixp4xx.c | 3 +-- + 2 files changed, 2 insertions(+), 4 deletions(-) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ixp2000.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ixp2000.c +@@ -106,11 +106,10 @@ static int ixp2000_i2c_probe(struct devi + 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 = +- kmalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); ++ kzalloc(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; +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ixp4xx.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ixp4xx.c +@@ -107,12 +107,11 @@ static int ixp4xx_i2c_probe(struct devic + 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 = +- kmalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); ++ kzalloc(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; + + /* diff --git a/i2c/kzalloc-02-hwmon.patch b/i2c/kzalloc-02-hwmon.patch new file mode 100644 index 0000000000000..743be3387fecf --- /dev/null +++ b/i2c/kzalloc-02-hwmon.patch @@ -0,0 +1,617 @@ +From khali@linux-fr.org Mon Oct 17 14:10:57 2005 +Date: Mon, 17 Oct 2005 23:08:32 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Cc: Deepak Saxena <dsaxena@plexity.net> +Subject: [PATCH 10/14] hwmon: kzalloc conversion +Message-Id: <20051017230832.6ef5a1b4.khali@linux-fr.org> +Content-Disposition: inline; filename=kzalloc-02-hwmon.patch + +From: Deepak Saxena <dsaxena@plexity.net> + +Use kzalloc instead of kmalloc+memset in all hardware monitoring +drivers. + +Signed-off-by: Deepak Saxena <dsaxena@plexity.net> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/hwmon/adm1021.c | 3 +-- + drivers/hwmon/adm1025.c | 3 +-- + drivers/hwmon/adm1026.c | 4 +--- + drivers/hwmon/adm1031.c | 3 +-- + drivers/hwmon/asb100.c | 11 ++++------- + drivers/hwmon/atxp1.c | 3 +-- + drivers/hwmon/ds1621.c | 3 +-- + drivers/hwmon/fscher.c | 3 +-- + drivers/hwmon/fscpos.c | 3 +-- + drivers/hwmon/gl518sm.c | 3 +-- + drivers/hwmon/gl520sm.c | 3 +-- + drivers/hwmon/it87.c | 3 +-- + drivers/hwmon/lm63.c | 3 +-- + drivers/hwmon/lm75.c | 3 +-- + drivers/hwmon/lm77.c | 3 +-- + drivers/hwmon/lm78.c | 3 +-- + drivers/hwmon/lm80.c | 3 +-- + drivers/hwmon/lm83.c | 3 +-- + drivers/hwmon/lm85.c | 3 +-- + drivers/hwmon/lm87.c | 3 +-- + drivers/hwmon/lm90.c | 3 +-- + drivers/hwmon/lm92.c | 3 +-- + drivers/hwmon/max1619.c | 3 +-- + drivers/hwmon/pc87360.c | 3 +-- + drivers/hwmon/sis5595.c | 3 +-- + drivers/hwmon/smsc47b397.c | 3 +-- + drivers/hwmon/smsc47m1.c | 3 +-- + drivers/hwmon/via686a.c | 3 +-- + drivers/hwmon/w83627ehf.c | 3 +-- + drivers/hwmon/w83627hf.c | 3 +-- + drivers/hwmon/w83781d.c | 10 +++------- + drivers/hwmon/w83792d.c | 6 ++---- + drivers/hwmon/w83l785ts.c | 4 +--- + 33 files changed, 39 insertions(+), 80 deletions(-) + +--- gregkh-2.6.orig/drivers/hwmon/adm1021.c ++++ gregkh-2.6/drivers/hwmon/adm1021.c +@@ -204,11 +204,10 @@ static int adm1021_detect(struct i2c_ada + client structure, even though we cannot fill it completely yet. + But it allows us to access adm1021_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/adm1025.c ++++ gregkh-2.6/drivers/hwmon/adm1025.c +@@ -331,11 +331,10 @@ static int adm1025_detect(struct i2c_ada + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ +--- gregkh-2.6.orig/drivers/hwmon/adm1026.c ++++ gregkh-2.6/drivers/hwmon/adm1026.c +@@ -1470,13 +1470,11 @@ int adm1026_detect(struct i2c_adapter *a + client structure, even though we cannot fill it completely yet. + But it allows us to access adm1026_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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; +--- gregkh-2.6.orig/drivers/hwmon/adm1031.c ++++ gregkh-2.6/drivers/hwmon/adm1031.c +@@ -740,11 +740,10 @@ static int adm1031_detect(struct i2c_ada + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/asb100.c ++++ gregkh-2.6/drivers/hwmon/asb100.c +@@ -629,19 +629,17 @@ static int asb100_detect_subclients(stru + int i, id, err; + struct asb100_data *data = i2c_get_clientdata(new_client); + +- data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); ++ data->lm75[0] = kzalloc(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] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); ++ data->lm75[1] = kzalloc(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); + +@@ -724,12 +722,11 @@ static int asb100_detect(struct i2c_adap + client structure, even though we cannot fill it completely yet. + But it allows us to access asb100_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct asb100_data), GFP_KERNEL))) { +- pr_debug("asb100.o: detect failed, kmalloc failed!\n"); ++ if (!(data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL))) { ++ pr_debug("asb100.o: detect failed, kzalloc failed!\n"); + err = -ENOMEM; + goto ERROR0; + } +- memset(data, 0, sizeof(struct asb100_data)); + + new_client = &data->client; + init_MUTEX(&data->lock); +--- gregkh-2.6.orig/drivers/hwmon/atxp1.c ++++ gregkh-2.6/drivers/hwmon/atxp1.c +@@ -268,12 +268,11 @@ static int atxp1_detect(struct i2c_adapt + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); + +--- gregkh-2.6.orig/drivers/hwmon/ds1621.c ++++ gregkh-2.6/drivers/hwmon/ds1621.c +@@ -202,11 +202,10 @@ int ds1621_detect(struct i2c_adapter *ad + /* 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 = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/fscher.c ++++ gregkh-2.6/drivers/hwmon/fscher.c +@@ -303,11 +303,10 @@ static int fscher_detect(struct i2c_adap + /* 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 = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ +--- gregkh-2.6.orig/drivers/hwmon/fscpos.c ++++ gregkh-2.6/drivers/hwmon/fscpos.c +@@ -453,11 +453,10 @@ int fscpos_detect(struct i2c_adapter *ad + * But it allows us to access fscpos_{read,write}_value. + */ + +- if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/gl518sm.c ++++ gregkh-2.6/drivers/hwmon/gl518sm.c +@@ -365,11 +365,10 @@ static int gl518_detect(struct i2c_adapt + client structure, even though we cannot fill it completely yet. + But it allows us to access gl518_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/gl520sm.c ++++ gregkh-2.6/drivers/hwmon/gl520sm.c +@@ -536,11 +536,10 @@ static int gl520_detect(struct i2c_adapt + client structure, even though we cannot fill it completely yet. + But it allows us to access gl520_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/it87.c ++++ gregkh-2.6/drivers/hwmon/it87.c +@@ -761,11 +761,10 @@ int it87_detect(struct i2c_adapter *adap + client structure, even though we cannot fill it completely yet. + But it allows us to access it87_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { + err = -ENOMEM; + goto ERROR1; + } +- memset(data, 0, sizeof(struct it87_data)); + + new_client = &data->client; + if (is_isa) +--- gregkh-2.6.orig/drivers/hwmon/lm63.c ++++ gregkh-2.6/drivers/hwmon/lm63.c +@@ -375,11 +375,10 @@ static int lm63_detect(struct i2c_adapte + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct lm63_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ +--- gregkh-2.6.orig/drivers/hwmon/lm75.c ++++ gregkh-2.6/drivers/hwmon/lm75.c +@@ -140,11 +140,10 @@ static int lm75_detect(struct i2c_adapte + /* 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 = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/lm77.c ++++ gregkh-2.6/drivers/hwmon/lm77.c +@@ -226,11 +226,10 @@ static int lm77_detect(struct i2c_adapte + /* 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 = kmalloc(sizeof(struct lm77_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/lm78.c ++++ gregkh-2.6/drivers/hwmon/lm78.c +@@ -540,11 +540,10 @@ int lm78_detect(struct i2c_adapter *adap + client structure, even though we cannot fill it completely yet. + But it allows us to access lm78_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL))) { + err = -ENOMEM; + goto ERROR1; + } +- memset(data, 0, sizeof(struct lm78_data)); + + new_client = &data->client; + if (is_isa) +--- gregkh-2.6.orig/drivers/hwmon/lm80.c ++++ gregkh-2.6/drivers/hwmon/lm80.c +@@ -407,11 +407,10 @@ int lm80_detect(struct i2c_adapter *adap + /* 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 = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/lm83.c ++++ gregkh-2.6/drivers/hwmon/lm83.c +@@ -230,11 +230,10 @@ static int lm83_detect(struct i2c_adapte + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ +--- gregkh-2.6.orig/drivers/hwmon/lm85.c ++++ gregkh-2.6/drivers/hwmon/lm85.c +@@ -1033,11 +1033,10 @@ int lm85_detect(struct i2c_adapter *adap + client structure, even though we cannot fill it completely yet. + But it allows us to access lm85_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/lm87.c ++++ gregkh-2.6/drivers/hwmon/lm87.c +@@ -554,11 +554,10 @@ static int lm87_detect(struct i2c_adapte + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ +--- gregkh-2.6.orig/drivers/hwmon/lm90.c ++++ gregkh-2.6/drivers/hwmon/lm90.c +@@ -370,11 +370,10 @@ static int lm90_detect(struct i2c_adapte + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ +--- gregkh-2.6.orig/drivers/hwmon/lm92.c ++++ gregkh-2.6/drivers/hwmon/lm92.c +@@ -300,11 +300,10 @@ static int lm92_detect(struct i2c_adapte + | I2C_FUNC_SMBUS_WORD_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct lm92_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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 */ +--- gregkh-2.6.orig/drivers/hwmon/max1619.c ++++ gregkh-2.6/drivers/hwmon/max1619.c +@@ -197,11 +197,10 @@ static int max1619_detect(struct i2c_ada + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct max1619_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ +--- gregkh-2.6.orig/drivers/hwmon/pc87360.c ++++ gregkh-2.6/drivers/hwmon/pc87360.c +@@ -754,9 +754,8 @@ static int pc87360_detect(struct i2c_ada + const char *name = "pc87360"; + int use_thermistors = 0; + +- if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/sis5595.c ++++ gregkh-2.6/drivers/hwmon/sis5595.c +@@ -518,11 +518,10 @@ static int sis5595_detect(struct i2c_ada + goto exit_release; + } + +- if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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; +--- gregkh-2.6.orig/drivers/hwmon/smsc47b397.c ++++ gregkh-2.6/drivers/hwmon/smsc47b397.c +@@ -244,11 +244,10 @@ static int smsc47b397_detect(struct i2c_ + return -EBUSY; + } + +- if (!(data = kmalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/smsc47m1.c ++++ gregkh-2.6/drivers/hwmon/smsc47m1.c +@@ -396,11 +396,10 @@ static int smsc47m1_detect(struct i2c_ad + return -EBUSY; + } + +- if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/via686a.c ++++ gregkh-2.6/drivers/hwmon/via686a.c +@@ -621,11 +621,10 @@ static int via686a_detect(struct i2c_ada + return -ENODEV; + } + +- if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/w83627ehf.c ++++ gregkh-2.6/drivers/hwmon/w83627ehf.c +@@ -681,11 +681,10 @@ static int w83627ehf_detect(struct i2c_a + goto exit; + } + +- if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/w83627hf.c ++++ gregkh-2.6/drivers/hwmon/w83627hf.c +@@ -1045,11 +1045,10 @@ static int w83627hf_detect(struct i2c_ad + client structure, even though we cannot fill it completely yet. + But it allows us to access w83627hf_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/w83781d.c ++++ gregkh-2.6/drivers/hwmon/w83781d.c +@@ -889,12 +889,11 @@ w83781d_detect_subclients(struct i2c_ada + const char *client_name = ""; + struct w83781d_data *data = i2c_get_clientdata(new_client); + +- data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); ++ data->lm75[0] = kzalloc(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); + +@@ -919,13 +918,11 @@ w83781d_detect_subclients(struct i2c_ada + } + + if (kind != w83783s) { +- +- data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); ++ data->lm75[1] = kzalloc(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) { +@@ -1064,11 +1061,10 @@ w83781d_detect(struct i2c_adapter *adapt + client structure, even though we cannot fill it completely yet. + But it allows us to access w83781d_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/w83792d.c ++++ gregkh-2.6/drivers/hwmon/w83792d.c +@@ -1086,11 +1086,10 @@ w83792d_create_subclient(struct i2c_adap + int err; + struct i2c_client *sub_client; + +- (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); ++ (*sub_cli) = sub_client = kzalloc(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; +@@ -1184,11 +1183,10 @@ w83792d_detect(struct i2c_adapter *adapt + client structure, even though we cannot fill it completely yet. + But it allows us to access w83792d_{read,write}_value. */ + +- if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/hwmon/w83l785ts.c ++++ gregkh-2.6/drivers/hwmon/w83l785ts.c +@@ -156,12 +156,10 @@ static int w83l785ts_detect(struct i2c_a + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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. */ diff --git a/i2c/kzalloc-03-i2c-other.patch b/i2c/kzalloc-03-i2c-other.patch new file mode 100644 index 0000000000000..dc7c05b118c0b --- /dev/null +++ b/i2c/kzalloc-03-i2c-other.patch @@ -0,0 +1,399 @@ +From khali@linux-fr.org Mon Oct 17 14:11:07 2005 +Date: Mon, 17 Oct 2005 23:09:43 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 11/14] i2c: kzalloc conversion, other drivers +Message-Id: <20051017230943.3d0085e1.khali@linux-fr.org> +Content-Disposition: inline; filename=kzalloc-03-i2c-other.patch + +From: Deepak Saxena <dsaxena@plexity.net> + +Use kzalloc instead of kmalloc+memset in all remaining i2c bus and +chip drivers. + +Signed-off-by: Deepak Saxena <dsaxena@plexity.net> +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-amd8111.c | 3 +-- + drivers/i2c/busses/i2c-ibm_iic.c | 3 +-- + drivers/i2c/busses/i2c-iop3xx.c | 6 ++---- + drivers/i2c/busses/i2c-keywest.c | 3 +-- + drivers/i2c/busses/i2c-mpc.c | 3 +-- + drivers/i2c/busses/i2c-mv64xxx.c | 5 +---- + drivers/i2c/busses/i2c-nforce2.c | 3 +-- + drivers/i2c/busses/i2c-parport.c | 5 ++--- + drivers/i2c/busses/i2c-pmac-smu.c | 3 +-- + drivers/i2c/busses/i2c-prosavage.c | 4 +--- + drivers/i2c/busses/scx200_acb.c | 3 +-- + drivers/i2c/chips/ds1337.c | 3 +-- + drivers/i2c/chips/ds1374.c | 3 +-- + drivers/i2c/chips/eeprom.c | 3 +-- + drivers/i2c/chips/m41t00.c | 3 +-- + drivers/i2c/chips/max6875.c | 6 ++---- + drivers/i2c/chips/pca9539.c | 3 +-- + drivers/i2c/chips/pcf8574.c | 3 +-- + drivers/i2c/chips/pcf8591.c | 3 +-- + drivers/i2c/chips/rtc8564.c | 3 +-- + drivers/i2c/chips/tps65010.c | 3 +-- + drivers/i2c/i2c-dev.c | 3 +-- + 22 files changed, 25 insertions(+), 52 deletions(-) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-amd8111.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-amd8111.c +@@ -344,10 +344,9 @@ static int __devinit amd8111_probe(struc + if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) + return -ENODEV; + +- smbus = kmalloc(sizeof(struct amd_smbus), GFP_KERNEL); ++ smbus = kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-ibm_iic.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-ibm_iic.c +@@ -672,13 +672,12 @@ static int __devinit iic_probe(struct oc + printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", + ocp->def->index); + +- if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){ ++ if (!(dev = kzalloc(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); + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-iop3xx.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-iop3xx.c +@@ -440,19 +440,17 @@ iop3xx_i2c_probe(struct device *dev) + struct i2c_adapter *new_adapter; + struct i2c_algo_iop3xx_data *adapter_data; + +- new_adapter = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); ++ new_adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); + if (!new_adapter) { + ret = -ENOMEM; + goto out; + } +- memset((void*)new_adapter, 0, sizeof(*new_adapter)); + +- adapter_data = kmalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); ++ adapter_data = kzalloc(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) { +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-keywest.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-keywest.c +@@ -535,13 +535,12 @@ create_iface(struct device_node *np, str + + tsize = sizeof(struct keywest_iface) + + (sizeof(struct keywest_chan) + 4) * nchan; +- iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL); ++ iface = (struct keywest_iface *) kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-mpc.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-mpc.c +@@ -296,10 +296,9 @@ static int fsl_i2c_probe(struct device * + + pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; + +- if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { ++ if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) { + return -ENOMEM; + } +- memset(i2c, 0, sizeof(*i2c)); + + i2c->irq = platform_get_irq(pdev, 0); + i2c->flags = pdata->device_flags; +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-mv64xxx.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-mv64xxx.c +@@ -500,13 +500,10 @@ mv64xxx_i2c_probe(struct device *dev) + if ((pd->id != 0) || !pdata) + return -ENODEV; + +- drv_data = kmalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); +- ++ drv_data = kzalloc(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; +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-nforce2.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-nforce2.c +@@ -313,10 +313,9 @@ static int __devinit nforce2_probe(struc + int res1, res2; + + /* we support 2 SMBus adapters */ +- if (!(smbuses = (void *)kmalloc(2*sizeof(struct nforce2_smbus), ++ if (!(smbuses = (void *)kzalloc(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 */ +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-parport.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-parport.c +@@ -155,12 +155,11 @@ static void i2c_parport_attach (struct p + { + struct i2c_par *adapter; + +- adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL); ++ adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL); + if (adapter == NULL) { +- printk(KERN_ERR "i2c-parport: Failed to kmalloc\n"); ++ printk(KERN_ERR "i2c-parport: Failed to kzalloc\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", +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-pmac-smu.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-pmac-smu.c +@@ -211,12 +211,11 @@ static int create_iface(struct device_no + } + busid = *reg; + +- iface = kmalloc(sizeof(struct smu_iface), GFP_KERNEL); ++ iface = kzalloc(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; + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-prosavage.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-prosavage.c +@@ -241,14 +241,12 @@ static int __devinit prosavage_probe(str + struct s_i2c_chip *chip; + struct s_i2c_bus *bus; + +- pci_set_drvdata(dev, kmalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); ++ pci_set_drvdata(dev, kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/busses/scx200_acb.c ++++ gregkh-2.6/drivers/i2c/busses/scx200_acb.c +@@ -442,14 +442,13 @@ static int __init scx200_acb_create(int + int rc = 0; + char description[64]; + +- iface = kmalloc(sizeof(*iface), GFP_KERNEL); ++ iface = kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/chips/ds1337.c ++++ gregkh-2.6/drivers/i2c/chips/ds1337.c +@@ -243,11 +243,10 @@ static int ds1337_detect(struct i2c_adap + I2C_FUNC_I2C)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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 +--- gregkh-2.6.orig/drivers/i2c/chips/ds1374.c ++++ gregkh-2.6/drivers/i2c/chips/ds1374.c +@@ -193,11 +193,10 @@ static int ds1374_probe(struct i2c_adapt + struct i2c_client *client; + int rc; + +- client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); ++ client = kzalloc(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->addr = addr; + client->adapter = adap; +--- gregkh-2.6.orig/drivers/i2c/chips/eeprom.c ++++ gregkh-2.6/drivers/i2c/chips/eeprom.c +@@ -171,11 +171,10 @@ int eeprom_detect(struct i2c_adapter *ad + | I2C_FUNC_SMBUS_BYTE)) + goto exit; + +- if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/chips/m41t00.c ++++ gregkh-2.6/drivers/i2c/chips/m41t00.c +@@ -174,11 +174,10 @@ m41t00_probe(struct i2c_adapter *adap, i + struct i2c_client *client; + int rc; + +- client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); ++ client = kzalloc(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->addr = addr; + client->adapter = adap; +--- gregkh-2.6.orig/drivers/i2c/chips/max6875.c ++++ gregkh-2.6/drivers/i2c/chips/max6875.c +@@ -179,16 +179,14 @@ static int max6875_detect(struct i2c_ada + if (address & 1) + return 0; + +- if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) ++ if (!(data = kzalloc(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 = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) { ++ if (!(fake_client = kzalloc(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; +--- gregkh-2.6.orig/drivers/i2c/chips/pca9539.c ++++ gregkh-2.6/drivers/i2c/chips/pca9539.c +@@ -122,11 +122,10 @@ static int pca9539_detect(struct i2c_ada + + /* 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 = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/chips/pcf8574.c ++++ gregkh-2.6/drivers/i2c/chips/pcf8574.c +@@ -127,11 +127,10 @@ int pcf8574_detect(struct i2c_adapter *a + + /* 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 = kmalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/chips/pcf8591.c ++++ gregkh-2.6/drivers/i2c/chips/pcf8591.c +@@ -178,11 +178,10 @@ int pcf8591_detect(struct i2c_adapter *a + + /* 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 = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { ++ if (!(data = kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/chips/rtc8564.c ++++ gregkh-2.6/drivers/i2c/chips/rtc8564.c +@@ -148,12 +148,11 @@ static int rtc8564_attach(struct i2c_ada + {addr, I2C_M_RD, 2, data} + }; + +- d = kmalloc(sizeof(struct rtc8564_data), GFP_KERNEL); ++ d = kzalloc(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); +--- gregkh-2.6.orig/drivers/i2c/chips/tps65010.c ++++ gregkh-2.6/drivers/i2c/chips/tps65010.c +@@ -500,11 +500,10 @@ tps65010_probe(struct i2c_adapter *bus, + return 0; + } + +- tps = kmalloc(sizeof *tps, GFP_KERNEL); ++ tps = kzalloc(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; +--- gregkh-2.6.orig/drivers/i2c/i2c-dev.c ++++ gregkh-2.6/drivers/i2c/i2c-dev.c +@@ -79,10 +79,9 @@ static struct i2c_dev *get_free_i2c_dev( + { + struct i2c_dev *i2c_dev; + +- i2c_dev = kmalloc(sizeof(*i2c_dev), GFP_KERNEL); ++ i2c_dev = kzalloc(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]) { diff --git a/i2c/kzalloc-04-drop-useless-casts.patch b/i2c/kzalloc-04-drop-useless-casts.patch new file mode 100644 index 0000000000000..42f54a2fe55df --- /dev/null +++ b/i2c/kzalloc-04-drop-useless-casts.patch @@ -0,0 +1,43 @@ +From khali@linux-fr.org Mon Oct 17 14:16:31 2005 +Date: Mon, 17 Oct 2005 23:12:36 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Cc: Jiri Slaby <lnx4us@gmail.com>, Deepak Saxena <dsaxena@plexity.net> +Subject: [PATCH 12/14] i2c: kzalloc cleanups, 1 of 2 +Message-Id: <20051017231236.111e196d.khali@linux-fr.org> +Content-Disposition: inline; filename=kzalloc-04-drop-useless-casts.patch + +Drop useless casts on kzalloc returned values, as suggested by +Jiri Slaby. + +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-keywest.c | 2 +- + drivers/i2c/busses/i2c-nforce2.c | 3 +-- + 2 files changed, 2 insertions(+), 3 deletions(-) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-keywest.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-keywest.c +@@ -535,7 +535,7 @@ create_iface(struct device_node *np, str + + tsize = sizeof(struct keywest_iface) + + (sizeof(struct keywest_chan) + 4) * nchan; +- iface = (struct keywest_iface *) kzalloc(tsize, GFP_KERNEL); ++ iface = kzalloc(tsize, GFP_KERNEL); + if (iface == NULL) { + printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); + pmac_low_i2c_unlock(np); +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-nforce2.c ++++ gregkh-2.6/drivers/i2c/busses/i2c-nforce2.c +@@ -313,8 +313,7 @@ static int __devinit nforce2_probe(struc + int res1, res2; + + /* we support 2 SMBus adapters */ +- if (!(smbuses = (void *)kzalloc(2*sizeof(struct nforce2_smbus), +- GFP_KERNEL))) ++ if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL))) + return -ENOMEM; + pci_set_drvdata(dev, smbuses); + diff --git a/i2c/kzalloc-05-i2c-amd756-s4882.patch b/i2c/kzalloc-05-i2c-amd756-s4882.patch new file mode 100644 index 0000000000000..e4d0ae5c0d2b1 --- /dev/null +++ b/i2c/kzalloc-05-i2c-amd756-s4882.patch @@ -0,0 +1,35 @@ +From khali@linux-fr.org Mon Oct 17 14:16:37 2005 +Date: Mon, 17 Oct 2005 23:14:31 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 13/14] i2c: kzalloc cleanups, 2 of 2 +Message-Id: <20051017231431.05f69953.khali@linux-fr.org> +Content-Disposition: inline; filename=kzalloc-05-i2c-amd756-s4882.patch + +Use kzalloc instead of kmalloc in the S4882 SMBus multiplexing driver. +I guess it's safer that way. + +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/i2c/busses/i2c-amd756-s4882.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- gregkh-2.6.orig/drivers/i2c/busses/i2c-amd756-s4882.c ++++ gregkh-2.6/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 = kmalloc(5 * sizeof(struct i2c_adapter), ++ if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), + GFP_KERNEL))) { + error = -ENOMEM; + goto ERROR1; + } +- if (!(s4882_algo = kmalloc(5 * sizeof(struct i2c_algorithm), ++ if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm), + GFP_KERNEL))) { + error = -ENOMEM; + goto ERROR2; diff --git a/i2c/kzalloc-06-i2c-documentation-update.patch b/i2c/kzalloc-06-i2c-documentation-update.patch new file mode 100644 index 0000000000000..360b0a37b7cdc --- /dev/null +++ b/i2c/kzalloc-06-i2c-documentation-update.patch @@ -0,0 +1,78 @@ +From khali@linux-fr.org Mon Oct 17 14:16:41 2005 +Date: Mon, 17 Oct 2005 23:16:25 +0200 +From: Jean Delvare <khali@linux-fr.org> +To: Greg KH <greg@kroah.com> +Subject: [PATCH 14/14] i2c: Documentation update +Message-Id: <20051017231625.6ea8183f.khali@linux-fr.org> +Content-Disposition: inline; filename=kzalloc-06-i2c-documentation-update.patch + +Update the i2c documentation: kzalloc should be used instead of +kmalloc. + +I also fixed a couple other things nearby in writing-clients, as several +past changes had never been reported there. + +Signed-off-by: Jean Delvare <khali@linux-fr.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + Documentation/i2c/porting-clients | 2 +- + Documentation/i2c/writing-clients | 16 +++++----------- + 2 files changed, 6 insertions(+), 12 deletions(-) + +--- gregkh-2.6.orig/Documentation/i2c/writing-clients ++++ gregkh-2.6/Documentation/i2c/writing-clients +@@ -55,6 +55,7 @@ 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. */ +@@ -307,22 +308,15 @@ For now, you can ignore the `flags' para + client structure, even though we cannot fill it completely yet. + But it allows us to access several i2c functions safely */ + +- /* 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))) { ++ if (!(data = kzalloc(sizeof(struct foo_data), GFP_KERNEL))) { + err = -ENOMEM; + goto ERROR0; + } + +- /* 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 = &data->client; ++ i2c_set_clientdata(new_client, data); + + new_client->addr = address; +- new_client->data = data; + new_client->adapter = adapter; + new_client->driver = &foo_driver; + new_client->flags = 0; +@@ -448,7 +442,7 @@ much simpler than the attachment code, f + release_region(client->addr,LM78_EXTENT); + /* HYBRID SENSORS CHIP ONLY END */ + +- kfree(client); /* Frees client data too, if allocated at the same time */ ++ kfree(data); + return 0; + } + +--- gregkh-2.6.orig/Documentation/i2c/porting-clients ++++ gregkh-2.6/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 memset to fill the client and data area with 0x00. ++ Use kzalloc instead of kmalloc. + 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. |