pca9539: new i2c drvier
PATCH 1/1 pca9539: new i2c drvier
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
--- linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/pca9539.c
1969-12-31 18:00:00.000000000 -0600 +++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/pca9539.c 2005-06-03 15:15:02.000000000 -0500
@@ -0,0 +1,188 @@
+/*
+ pca9539.c - 16 port digital I/O with interrupt and reset
+
+ Copyright (C) 2005 Ben Gardner <[email protected]>
+
+ 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; version 2 of the License.
+*/
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sysfs.h>
+#include <linux/i2c-sensor.h>
+
+/* Addresses to scan */
+static unsigned short normal_i2c[] = { 0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; +
+/* Insmod parameters */
+SENSORS_INSMOD_1(pca9539);
+
+enum pca9539_cmd
+{
+ PCA9539_INPUT_0 = 0,
+ PCA9539_INPUT_1 = 1,
+ PCA9539_OUTPUT_0 = 2,
+ PCA9539_OUTPUT_1 = 3,
+ PCA9539_INVERT_0 = 4,
+ PCA9539_INVERT_1 = 5,
+ PCA9539_CONFIG_0 = 6,
+ PCA9539_CONFIG_1 = 7
+};
+
+static int pca9539_attach_adapter(struct i2c_adapter *adapter); +static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind);
+static int pca9539_detach_client(struct i2c_client *client); +
+/* This is the driver that will be inserted */
+static struct i2c_driver pca9539_driver = {
+ .owner = THIS_MODULE,
+ .name = "pca9539",
+ .flags = I2C_DF_NOTIFY,
+ .attach_adapter = pca9539_attach_adapter,
+ .detach_client = pca9539_detach_client,
+};
+
+struct pca9539_data {
+ struct i2c_client client;
+};
+
+/* following are the sysfs callback functions */
+static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
+ struct pca9539_data *data i2c_get_clientdata(to_i2c_client(dev));
+ return sprintf(buf, "%d\n",i2c_smbus_read_byte_data(&data->client, (u8)psa->index));
+}
+
+static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
+ struct pca9539_data *data i2c_get_clientdata(to_i2c_client(dev));
+ u8 val = simple_strtoul(buf, NULL, 0);
+ i2c_smbus_write_byte_data(&data->client, (u8)psa->index, val);
+ return count;
+}
+
+/* Define the device attributes */
+
+#define PCA9539_ENTRY_RO(name,enum_name) \
+ staticSENSOR_DEVICE_ATTR(name,S_IRUGO,pca9539_show,NULL,enum_name) +
+#define PCA9539_ENTRY_RW(name,enum_name) \
+ staticSENSOR_DEVICE_ATTR(name,S_IRUGO|S_IWUSR,pca9539_show,pca9539_store,enum_ name)
+
+PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0); +PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1); +PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0); +PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1); +PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0); +PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1); +PCA9539_ENTRY_RW(config0, PCA9539_CONFIG_0); +PCA9539_ENTRY_RW(config1, PCA9539_CONFIG_1);
+
+static struct attribute *pca9539_attributes[] = {
+ &sensor_dev_attr_input0.dev_attr.attr,
+ &sensor_dev_attr_input1.dev_attr.attr,
+ &sensor_dev_attr_output0.dev_attr.attr,
+ &sensor_dev_attr_output1.dev_attr.attr,
+ &sensor_dev_attr_invert0.dev_attr.attr,
+ &sensor_dev_attr_invert1.dev_attr.attr,
+ &sensor_dev_attr_config0.dev_attr.attr,
+ &sensor_dev_attr_config1.dev_attr.attr,
+ NULL
+};
+
+static struct attribute_group pca9539_defattr_group = {
+ .attrs = pca9539_attributes,
+};
+
+static int pca9539_attach_adapter(struct i2c_adapter *adapter) +{
+ return i2c_detect(adapter, &addr_data, pca9539_detect);
+}
+
+/* This function is called by i2c_detect */
+static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct i2c_client *new_client;
+ struct pca9539_data *data;
+ int err = 0;
+
+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE
+ | I2C_FUNC_SMBUS_WRITE_BYTE_DATA
+ | I2C_FUNC_SMBUS_READ_BYTE_DATA))
+ goto exit;
+
+ /* 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)))
{
+ err = -ENOMEM;
+ goto exit;
+ }
+ memset(data, 0, sizeof(struct pca9539_data));
+
+ new_client = &data->client;
+ i2c_set_clientdata(new_client, data);
+ new_client->addr = address;
+ new_client->adapter = adapter;
+ new_client->driver = &pca9539_driver;
+ new_client->flags = 0;
+
+ /* Detection: not sure how to do that...
+ * possibility: toggle the value read from invert0 and see if
input0
+ * changes polarity.
+ * However, if the inputs are changing, this won't work.
+ */
+ strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE);
+
+ /* Tell the I2C layer a new client has arrived */
+ if ((err = i2c_attach_client(new_client)))
+ goto exit_kfree;
+
+ /* Register sysfs hooks */
+ return sysfs_create_group(&new_client->dev.kobj,&pca9539_defattr_group);
+
+exit_kfree:
+ kfree(data);
+exit:
+ return err;
+}
+
+static int pca9539_detach_client(struct i2c_client *client) +{
+ int err;
+
+ if ((err = i2c_detach_client(client))) {
+ dev_err(&client->dev,
+ "Client deregistration failed, client not
detached.\n");
+ return err;
+ }
+
+ kfree(i2c_get_clientdata(client));
+ return 0;
+}
+
+static int __init pca9539_init(void)
+{
+ return i2c_add_driver(&pca9539_driver);
+}
+
+static void __exit pca9539_exit(void)
+{
+ i2c_del_driver(&pca9539_driver);
+}
+
+MODULE_AUTHOR("Ben Gardner <[email protected]>"); +MODULE_DESCRIPTION("PCA9539 driver"); +MODULE_LICENSE("GPL");
+
+module_init(pca9539_init);
+module_exit(pca9539_exit);
+
PATCH 1/1 pca9539: new i2c drvier (retry)
Please ignore the previous patch -- I had left out the Makefile and Kconfig changes.
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
--- linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/pca9539.c
1969-12-31 18:00:00.000000000 -0600 +++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/pca9539.c 2005-06-03 15:15:02.000000000 -0500
@@ -0,0 +1,188 @@
+/*
+ pca9539.c - 16 port digital I/O with interrupt and reset
+
+ Copyright (C) 2005 Ben Gardner <[email protected]>
+
+ 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; version 2 of the License.
+*/
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sysfs.h>
+#include <linux/i2c-sensor.h>
+
+/* Addresses to scan */
+static unsigned short normal_i2c[] = { 0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; +
+/* Insmod parameters */
+SENSORS_INSMOD_1(pca9539);
+
+enum pca9539_cmd
+{
+ PCA9539_INPUT_0 = 0,
+ PCA9539_INPUT_1 = 1,
+ PCA9539_OUTPUT_0 = 2,
+ PCA9539_OUTPUT_1 = 3,
+ PCA9539_INVERT_0 = 4,
+ PCA9539_INVERT_1 = 5,
+ PCA9539_CONFIG_0 = 6,
+ PCA9539_CONFIG_1 = 7
+};
+
+static int pca9539_attach_adapter(struct i2c_adapter *adapter); +static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind);
+static int pca9539_detach_client(struct i2c_client *client); +
+/* This is the driver that will be inserted */
+static struct i2c_driver pca9539_driver = {
+ .owner = THIS_MODULE,
+ .name = "pca9539",
+ .flags = I2C_DF_NOTIFY,
+ .attach_adapter = pca9539_attach_adapter,
+ .detach_client = pca9539_detach_client,
+};
+
+struct pca9539_data {
+ struct i2c_client client;
+};
+
+/* following are the sysfs callback functions */
+static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
+ struct pca9539_data *data i2c_get_clientdata(to_i2c_client(dev));
+ return sprintf(buf, "%d\n",i2c_smbus_read_byte_data(&data->client, (u8)psa->index));
+}
+
+static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
+ struct pca9539_data *data i2c_get_clientdata(to_i2c_client(dev));
+ u8 val = simple_strtoul(buf, NULL, 0);
+ i2c_smbus_write_byte_data(&data->client, (u8)psa->index, val);
+ return count;
+}
+
+/* Define the device attributes */
+
+#define PCA9539_ENTRY_RO(name,enum_name) \
+ staticSENSOR_DEVICE_ATTR(name,S_IRUGO,pca9539_show,NULL,enum_name) +
+#define PCA9539_ENTRY_RW(name,enum_name) \
+ staticSENSOR_DEVICE_ATTR(name,S_IRUGO|S_IWUSR,pca9539_show,pca9539_store,enum_ name)
+
+PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0); +PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1); +PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0); +PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1); +PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0); +PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1); +PCA9539_ENTRY_RW(config0, PCA9539_CONFIG_0); +PCA9539_ENTRY_RW(config1, PCA9539_CONFIG_1);
+
+static struct attribute *pca9539_attributes[] = {
+ &sensor_dev_attr_input0.dev_attr.attr,
+ &sensor_dev_attr_input1.dev_attr.attr,
+ &sensor_dev_attr_output0.dev_attr.attr,
+ &sensor_dev_attr_output1.dev_attr.attr,
+ &sensor_dev_attr_invert0.dev_attr.attr,
+ &sensor_dev_attr_invert1.dev_attr.attr,
+ &sensor_dev_attr_config0.dev_attr.attr,
+ &sensor_dev_attr_config1.dev_attr.attr,
+ NULL
+};
+
+static struct attribute_group pca9539_defattr_group = {
+ .attrs = pca9539_attributes,
+};
+
+static int pca9539_attach_adapter(struct i2c_adapter *adapter) +{
+ return i2c_detect(adapter, &addr_data, pca9539_detect);
+}
+
+/* This function is called by i2c_detect */
+static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct i2c_client *new_client;
+ struct pca9539_data *data;
+ int err = 0;
+
+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE
+ | I2C_FUNC_SMBUS_WRITE_BYTE_DATA
+ | I2C_FUNC_SMBUS_READ_BYTE_DATA))
+ goto exit;
+
+ /* 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)))
{
+ err = -ENOMEM;
+ goto exit;
+ }
+ memset(data, 0, sizeof(struct pca9539_data));
+
+ new_client = &data->client;
+ i2c_set_clientdata(new_client, data);
+ new_client->addr = address;
+ new_client->adapter = adapter;
+ new_client->driver = &pca9539_driver;
+ new_client->flags = 0;
+
+ /* Detection: not sure how to do that...
+ * possibility: toggle the value read from invert0 and see if
input0
+ * changes polarity.
+ * However, if the inputs are changing, this won't work.
+ */
+ strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE);
+
+ /* Tell the I2C layer a new client has arrived */
+ if ((err = i2c_attach_client(new_client)))
+ goto exit_kfree;
+
+ /* Register sysfs hooks */
+ return sysfs_create_group(&new_client->dev.kobj,&pca9539_defattr_group);
+
+exit_kfree:
+ kfree(data);
+exit:
+ return err;
+}
+
+static int pca9539_detach_client(struct i2c_client *client) +{
+ int err;
+
+ if ((err = i2c_detach_client(client))) {
+ dev_err(&client->dev,
+ "Client deregistration failed, client not
detached.\n");
+ return err;
+ }
+
+ kfree(i2c_get_clientdata(client));
+ return 0;
+}
+
+static int __init pca9539_init(void)
+{
+ return i2c_add_driver(&pca9539_driver);
+}
+
+static void __exit pca9539_exit(void)
+{
+ i2c_del_driver(&pca9539_driver);
+}
+
+MODULE_AUTHOR("Ben Gardner <[email protected]>"); +MODULE_DESCRIPTION("PCA9539 driver"); +MODULE_LICENSE("GPL");
+
+module_init(pca9539_init);
+module_exit(pca9539_exit);
+
--- linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/Makefile
2005-06-01 14:29:17.000000000 -0500 +++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/Makefile 2005-06-03 12:09:41.000000000 -0500
@@ -34,6 +34,7 @@
obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
obj-$(CONFIG_SENSORS_M41T00) += m41t00.o
obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
+obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
--- linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/Kconfig
2005-06-01 14:29:17.000000000 -0500 +++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/Kconfig 2005-06-03 12:09:22.000000000 -0500
@@ -498,4 +498,14 @@
This driver can also be built as a module. If so, the module will be called m41t00.
+config SENSORS_PCA9539
+ tristate "PCA9539 16-bit digital IO"
+ depends on I2C && EXPERIMENTAL
+ help
+ If you say yes here you get support for the PCA9539
+ low power digital I/O with 16 bit.
+
+ This driver can also be built as a module. If so, the module
+ will be called pca9539.
+
endmenu
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Quoted 7 lines · On Fri, Jun 03, 2005 at 04:29:28PM -0400, [email protected] wrote:
Please ignore the previous patch -- I had left out the
MakefileandKconfigchanges.This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
Quoted 6 lines
Signed-off-by Ben Gardner <[email protected]>---
linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/pca9539.c1969-12-31 18:00:00.000000000 -0600 +++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/pca9539.c 2005-06-03 15:15:02.000000000 -0500
Hm, the patch is line-wrapped. Care to try it again?
thanks,
greg k-h
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Sorry about that. I suspect that my MS Exchange server is wrapping lines when it processes mail heading out to the internet. You know, when it attaches that oh-so-useful disclaimer.
Anyway, here is attempt 3, as an attachment.
=
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
-------------- next part --------------
drivers/i2c/chips/pca9539.c +188 -0
@@ -0,0 +1,188 @@ +/* +pca9539.c - 16 port digital I/O with interrupt and reset ++ Copyright (C) 2005 Ben Gardner <[email protected]> + +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; version 2 of the License. +*/ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/i2c.h> +#include <linux/i2c-sysfs.h> +#include <linux/i2c-sensor.h> + +/* Addresses to scan */ +static unsigned short normal_i2c[] = {0x74 ,0x75 ,0x76 ,0x77 ,I2C_CLIENT_END }; +static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; + +/* Insmod parameters */ +SENSORS_INSMOD_1 (pca9539); + +enum pca9539_cmd +{ +PCA9539_INPUT_0 =0 , +PCA9539_INPUT_1 =1 , +PCA9539_OUTPUT_0 =2 , +PCA9539_OUTPUT_1 =3 , +PCA9539_INVERT_0 =4 , +PCA9539_INVERT_1 =5 , +PCA9539_CONFIG_0 =6 , +PCA9539_CONFIG_1 =7 +}; + +static int pca9539_attach_adapter (struct i2c_adapter *adapter); +static int pca9539_detect (struct i2c_adapter *adapter,int address,int kind); +static int pca9539_detach_client (struct i2c_client *client); + +/* This is the driver that will be inserted */ +static struct i2c_driver pca9539_driver = { + .owner =THIS_MODULE , + .name ="pca9539" , + .flags =I2C_DF_NOTIFY , + .attach_adapter = pca9539_attach_adapter, + .detach_client = pca9539_detach_client, +}; + +struct pca9539_data { +struct i2c_client client; +}; + +/* following are the sysfs callback functions */ +static ssize_t pca9539_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct sensor_device_attribute *psa =to_sensor_dev_attr (attr); +struct pca9539_data *data =i2c_get_clientdata (to_i2c_client (dev)); +return sprintf (buf,"%d\n" ,i2c_smbus_read_byte_data (&data->client, (u8 )psa->index)); +} + +static ssize_t pca9539_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct sensor_device_attribute *psa =to_sensor_dev_attr (attr); +struct pca9539_data *data =i2c_get_clientdata (to_i2c_client (dev)); +u8 val =simple_strtoul (buf,NULL ,0 ); +i2c_smbus_write_byte_data (&data->client, (u8 )psa->index, val); +return count; +} + +/* Define the device attributes */ + +#define PCA9539_ENTRY_RO (name,enum_name) \ + static SENSOR_DEVICE_ATTR(name,S_IRUGO,pca9539_show,NULL,enum_name) + +#define PCA9539_ENTRY_RW (name,enum_name) \ + static SENSOR_DEVICE_ATTR(name,S_IRUGO|S_IWUSR,pca9539_show,pca9539_store,enum_name) + +PCA9539_ENTRY_RO (input0,PCA9539_INPUT_0 ); +PCA9539_ENTRY_RO (input1,PCA9539_INPUT_1 ); +PCA9539_ENTRY_RW (output0,PCA9539_OUTPUT_0 ); +PCA9539_ENTRY_RW (output1,PCA9539_OUTPUT_1 ); +PCA9539_ENTRY_RW (invert0,PCA9539_INVERT_0 ); +PCA9539_ENTRY_RW (invert1,PCA9539_INVERT_1 ); +PCA9539_ENTRY_RW (config0,PCA9539_CONFIG_0 ); +PCA9539_ENTRY_RW (config1,PCA9539_CONFIG_1 ); + +static struct attribute *pca9539_attributes[] = { + &sensor_dev_attr_input0.dev_attr.attr, + &sensor_dev_attr_input1.dev_attr.attr, + &sensor_dev_attr_output0.dev_attr.attr, + &sensor_dev_attr_output1.dev_attr.attr, + &sensor_dev_attr_invert0.dev_attr.attr, + &sensor_dev_attr_invert1.dev_attr.attr, + &sensor_dev_attr_config0.dev_attr.attr, + &sensor_dev_attr_config1.dev_attr.attr, +NULL +}; + +static struct attribute_group pca9539_defattr_group = { + .attrs = pca9539_attributes, +}; + +static int pca9539_attach_adapter (struct i2c_adapter *adapter) +{ +return i2c_detect (adapter, &addr_data, pca9539_detect); +} + +/* This function is called by i2c_detect */ +static int pca9539_detect (struct i2c_adapter *adapter,int address,int kind) +{ +struct i2c_client *new_client; +struct pca9539_data *data; +int err =0 ; + +if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE + |I2C_FUNC_SMBUS_WRITE_BYTE_DATA + |I2C_FUNC_SMBUS_READ_BYTE_DATA )) + goto exit; + +/* 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 ))) { + err = -ENOMEM ; + goto exit; + } +memset (data,0 ,sizeof (struct pca9539_data )); + + new_client = &data->client; +i2c_set_clientdata (new_client, data); + new_client->addr = address; + new_client->adapter = adapter; + new_client->driver = &pca9539_driver; + new_client->flags =0 ; + +/* Detection: not sure how to do that... +* possibility: toggle the value read from invert0 and see if input0 +* changes polarity. +* However, if the inputs are changing, this won't work. +*/ +strlcpy (new_client->name,"pca9539" ,I2C_NAME_SIZE ); + +/* Tell the I2C layer a new client has arrived */ +if ((err =i2c_attach_client (new_client))) + goto exit_kfree; + +/* Register sysfs hooks */ +return sysfs_create_group (&new_client->dev.kobj, &pca9539_defattr_group); + +exit_kfree: +kfree (data); +exit: +return err; +} + +static int pca9539_detach_client (struct i2c_client *client) +{ +int err; + +if ((err =i2c_detach_client (client))) { +dev_err (&client->dev, +"Client deregistration failed, client not detached.\n" ); +return err; + } + +kfree (i2c_get_clientdata (client)); +return 0 ; +} + +static int __init pca9539_init (void ) +{ +return i2c_add_driver (&pca9539_driver); +} + +static void __exit pca9539_exit(void) +{ +i2c_del_driver (&pca9539_driver); +} + +MODULE_AUTHOR ("Ben Gardner <[email protected]>" ); +MODULE_DESCRIPTION ("PCA9539 driver" ); +MODULE_LICENSE ("GPL" ); + +module_init (pca9539_init); +module_exit (pca9539_exit); +
drivers/i2c/chips/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_SENSORS_MAX1619) += max1619.o obj-$(CONFIG_SENSORS_M41T00) += m41t00.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o +obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
drivers/i2c/chips/Kconfig +10 -0
@@ -498,4 +498,14 @@ This driver can also be built as a module. If so, the module will be called m41t00. +config SENSORS_PCA9539 + tristate "PCA9539 16-bit digital IO" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the PCA9539 + low power digital I/O with 16 bit. + + This driver can also be built as a module. If so, the module + will be called pca9539. + endmenu
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Hi Ben,
Quoted 4 lines
Anyway, here is attempt 3, as an attachment.
=>
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
And here are my comments about your code (which overall looks very good).
Review
Quoted 8 lines
(quoted diff) +8
-0+/* following are the sysfs callback functions */ +static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); + struct pca9539_data *data = i2c_get_clientdata(to_i2c_client(dev)); + return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(&data->client, (u8)psa->index)); +}
This can be made a lot more simple. You currently go from dev to client to data back to client. What about:
static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
struct i2c_client *client = to_i2c_client(dev);
return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client, (u8)psa->index));
}Same holds for pca9539_store(), obviously.
BTW, please split lines which are longer than 80 characters, as mentioned in Documentation/CodingStyle.
Review
Quoted 9 lines
(quoted diff) +9
-0+static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); + struct pca9539_data *data = i2c_get_clientdata(to_i2c_client(dev)); + u8 val = simple_strtoul(buf, NULL, 0); + i2c_smbus_write_byte_data(&data->client, (u8)psa->index, val); + return count; +}
You fail to check the validity of the new value. Wrapping it into an u8 is no good. It would be far better to actually check the value, and reject it if incorrect. Something in the lines of:
unsigned long val = simple_strtoul(buf, NULL, 0); if (val > 0xff) return -EINVAL;
This is what the similar pcf8574 driver does. You may even have it warn in the logs if you want.
Review
Quoted 3 lines
(quoted diff) +2
-0+ static SENSOR_DEVICE_ATTR(name,S_IRUGO,pca9539_show,NULL,enum_name) + static SENSOR_DEVICE_ATTR(name,S_IRUGO|S_IWUSR,pca9539_show,pca9539_store,enum_name)
Add one space after each comma please. Spaces are also welcome around "|". As a side note, "enum_name" is a bad name IMHO, I would go for "index" or "command" or whatever you like which expresses what this parameter is holding.
Review
Quoted 2 lines
(quoted diff) +2
-0+PCA9539_ENTRY_RW(config0, PCA9539_CONFIG_0); +PCA9539_ENTRY_RW(config1, PCA9539_CONFIG_1);
"config" isn't a very relevant name. It could mean about anything depending on the chip. What about "direction" instead?
Review
Quoted 4 lines
(quoted diff) +4
-0+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE + | I2C_FUNC_SMBUS_WRITE_BYTE_DATA + | I2C_FUNC_SMBUS_READ_BYTE_DATA)) + goto exit;
Not correct. You test for I2C_FUNC_SMBUS_BYTE but never actually use this SMBus command in your code. Additionally, I2C_FUNC_SMBUS_WRITE_BYTE_DATA | I2C_FUNC_SMBUS_READ_BYTE_DATA can be shorten into I2C_FUNC_SMBUS_BYTE_DATA.
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* Detection: not sure how to do that... + * possibility: toggle the value read from invert0 and see if input0 + * changes polarity. + * However, if the inputs are changing, this won't work. + */
No, detection code should not write anything to the chips.
One possible detection method is to check that input and output match (modulo the polarity inversion) for all pins configured as outputs. I have made something similar in sensors-detect for the PCA9556, which is basically the same chip as the PCA9539 with half the GPIO pins. The code there reads like:
return unless ($input & ~$config) = (($output ^ $invert) & ~$config);
Another possible check would be on the number of registers (or commands). The PCA9539 has 8 commands, so reading "register" 0x07 will return a value, while reading register "0x08" will return an error.
If you could add detection for your chip to sensors-detect once you're done with the driver, this would be appreciated.
Review
Quoted 2 lines
(quoted diff) +2
-0+ /* Register sysfs hooks */ + return sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group);
Negative, an error from sysfs_create_group() should not be returned by the detection function due to the current (broken) design of i2c_detect().
Quoted 7 lines
drivers/i2c/chips/Kconfig +1
-0@@ -498,4 +498,14 @@ This driver can also be built as a module. If so, the module will be called m41t00. +config SENSORS_PCA9539
drivers/i2c/chips/Kconfig line 511
Quoted 10 lines
drivers/i2c/chips/Kconfig +9
-0+ tristate "PCA9539 16-bit digital IO" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the PCA9539 + low power digital I/O with 16 bit. + + This driver can also be built as a module. If so, the module + will be called pca9539. + endmenu
I'd rather see this entry next to the PCF8574 one, as both chips are similar in their function.
Thanks,
Signature · 1 line
Jean Delvare
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Hi Ben,
With respect to the sysfs attributes/callbacks much better :-), it really cleans up the code using the new callbacks and initializing the sensor device attributes as an attribute group. It also saves me or others having to go through and try to clean things up later.
Thanks,
Yani
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Hi Jean,
Thanks for your feedback.
I've incorporated your suggestions, so the next pca9539 patch should be 'final'. ;)
Ben
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: Saturday, June 04, 2005 2:26 AM
To: Gardner, Ben
Cc: LM Sensors; Greg KH
Subject: Re: [lm-sensors] [PATCH 2.6.12-rc5-mm2] pca9539: new i2c drvier (retry 3 - attachment)
Hi Ben,
Quoted 4 lines
Anyway, here is attempt 3, as an attachment.
=>
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
And here are my comments about your code (which overall looks very good).
Review
Quoted 7 lines
(quoted diff) +7
-0+/* following are the sysfs callback functions */ static ssize_t +pca9539_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); + struct pca9539_data *data i2c_get_clientdata(to_i2c_client(dev)); + return sprintf(buf, "%d\n",
i2c_smbus_read_byte_data(&data->client,
Quoted 1 line
+(u8)psa->index)); }
This can be made a lot more simple. You currently go from dev to client to data back to client. What about:
static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
struct i2c_client *client = to_i2c_client(dev);
return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client,(u8)psa->index)); }
Same holds for pca9539_store(), obviously.
BTW, please split lines which are longer than 80 characters, as mentioned in Documentation/CodingStyle.
Quoted 1 line
+static
ssize_tpca9539_store(struct device *dev, struct
device_attribute *attr,
Review
Quoted 7 lines
(quoted diff) +7
-0+ const char *buf, size_t count) { + struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); + struct pca9539_data *data i2c_get_clientdata(to_i2c_client(dev)); + u8 val = simple_strtoul(buf, NULL, 0); + i2c_smbus_write_byte_data(&data->client, (u8)psa->index, val); + return count; +}
You fail to check the validity of the new value. Wrapping it into an u8 is no good. It would be far better to actually check the value, and reject it if incorrect. Something in the lines of:
unsigned long val = simple_strtoul(buf, NULL, 0); if (val > 0xff) return -EINVAL;
This is what the similar pcf8574 driver does. You may even have it warn in the logs if you want.
Review
Quoted 1 line
(quoted diff) +1
-0+ static
SENSOR_DEVICE_ATTR(name,S_IRUGO,pca9539_show,NULL,enum_name)
Review
Quoted 4 lines
(...)
(quoted diff) +3
-0+ static +SENSOR_DEVICE_ATTR(name,S_IRUGO|S_IWUSR,pca9539_show,pca9539_store,en +um_name)
Add one space after each comma please. Spaces are also welcome around "|". As a side note, "enum_name" is a bad name IMHO, I would go for "index" or "command" or whatever you like which expresses what this parameter is holding.
Review
Quoted 2 lines
(quoted diff) +2
-0+PCA9539_ENTRY_RW(config0, PCA9539_CONFIG_0); +PCA9539_ENTRY_RW(config1, PCA9539_CONFIG_1);
"config" isn't a very relevant name. It could mean about anything depending on the chip. What about "direction" instead?
Review
Quoted 4 lines
(quoted diff) +4
-0+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE + | I2C_FUNC_SMBUS_WRITE_BYTE_DATA + | I2C_FUNC_SMBUS_READ_BYTE_DATA)) + goto exit;
Not correct. You test for I2C_FUNC_SMBUS_BYTE but never actually use this SMBus command in your code. Additionally, I2C_FUNC_SMBUS_WRITE_BYTE_DATA | I2C_FUNC_SMBUS_READ_BYTE_DATA can be shorten into I2C_FUNC_SMBUS_BYTE_DATA.
Review
Quoted 2 lines
(quoted diff) +2
-0+ /* Detection: not sure how to do that... + * possibility: toggle the value read from invert0 and see if
input0
Review
Quoted 3 lines
(quoted diff) +3
-0+ * changes polarity. + * However, if the inputs are changing, this won't work. + */
No, detection code should not write anything to the chips.
One possible detection method is to check that input and output match (modulo the polarity inversion) for all pins configured as outputs. I have made something similar in sensors-detect for the PCA9556, which is basically the same chip as the PCA9539 with half the GPIO pins. The code there reads like:
return unless ($input & ~$config) = (($output ^ $invert) &
~$config);
Another possible check would be on the number of registers (or commands). The PCA9539 has 8 commands, so reading "register" 0x07 will return a value, while reading register "0x08" will return an error.
If you could add detection for your chip to sensors-detect once you're done with the driver, this would be appreciated.
Review
Quoted 3 lines
(quoted diff) +3
-0+ /* Register sysfs hooks */ + return sysfs_create_group(&new_client->dev.kobj, +&pca9539_defattr_group);
Negative, an error from sysfs_create_group() should not be returned by the detection function due to the current (broken) design of i2c_detect().
Quoted 1 line
--- linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/Kconfig
2005-06-01 14:29:17.000000000 -0500
Quoted 1 line
+++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/Kconfig
2005-06-03 12:09:22.000000000 -0500
Quoted 5 lines
(quoted diff) +1
-0@@ -498,4 +498,14 @@ This driver can also be built as a module. If so, the module will be called m41t00. +config SENSORS_PCA9539
Review line 511
Quoted 10 lines
(quoted diff) +9
-0+ tristate "PCA9539 16-bit digital IO" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the PCA9539 + low power digital I/O with 16 bit. + + This driver can also be built as a module. If so, the module + will be called pca9539. + endmenu
I'd rather see this entry next to the PCF8574 one, as both chips are similar in their function.
Thanks,
--
Jean Delvare
PATCH 1/1 pca9539: new i2c drvier (retry 4
In reply to [email protected]Greg,
Attached (due to email line-wrapping problems) is an updated patch for the PCA9539.
I think this one is now ready for inclusion.
Thanks,
Ben
=
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
Includes documentation.
-------------- next part --------------
drivers/i2c/chips/Kconfig +10 -0
@@ -440,6 +440,16 @@ This driver can also be built as a module. If so, the module will be called pcf8574. +config SENSORS_PCA9539 + tristate "PCA9539 16-bit digital IO" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the PCA9539 + low power digital I/O with 16 bit. + + This driver can also be built as a module. If so, the module + will be called pca9539. + config SENSORS_PCF8591 tristate "Philips PCF8591" depends on I2C && EXPERIMENTAL
drivers/i2c/chips/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_SENSORS_MAX1619) += max1619.o obj-$(CONFIG_SENSORS_M41T00) += m41t00.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o +obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
drivers/i2c/chips/pca9539.c +192 -0
192 lines not on this page · raw message
Documentation/i2c/chips/pca9539 +53 -0
53 lines not on this page · raw message
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Hi Ben,
Quoted 3 lines
Attached (due to email line-wrapping problems) is an updated patch for the PCA9539.
I think this one is now ready for inclusion.
I'm very sorry but it looks like I still have a few objections ;)
drivers/i2c/chips/Kconfig line 444
Quoted 8 lines
drivers/i2c/chips/Kconfig +2
-0@@ -440,6 +440,16 @@ This driver can also be built as a module. If so, the module will be called pcf8574. +config SENSORS_PCA9539 + tristate "PCA9539 16-bit digital IO"
"Philips PCA9539 16-bit digital I/O"
(BTW, is there something like analog bits?)
drivers/i2c/chips/Kconfig line 447
Quoted 3 lines
drivers/i2c/chips/Kconfig +3
-0+ depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the PCA9539
Philips PCA9539
drivers/i2c/chips/Kconfig line 448
Quoted 1 line
drivers/i2c/chips/Kconfig +1
-0+ low power digital I/O with 16 bit.
"with 16 bit" sounds really weird. "16-bit digital I/O" here again maybe?
drivers/i2c/chips/pca9539.c line 2
Quoted 5 lines
drivers/i2c/chips/pca9539.c +2
-0@@ -0,0 +1,192 @@ +/* +pca9539.c - 16 port digital I/O with interrupt and reset
s/ port/-bit/ for consistency.
drivers/i2c/chips/pca9539.c line 3
Quoted 1 line
drivers/i2c/chips/pca9539.c +1
-0+#include <linux/i2c-sysfs.h>
It has become linux/hwmon-sysfs.h a few hours ago ;)
drivers/i2c/chips/pca9539.c line 14
Quoted 11 lines
drivers/i2c/chips/pca9539.c +11
-0+enum pca9539_cmd +{ +PCA9539_INPUT_0 =0 , +PCA9539_INPUT_1 =1 , +PCA9539_OUTPUT_0 =2 , +PCA9539_OUTPUT_1 =3 , +PCA9539_INVERT_0 =4 , +PCA9539_INVERT_1 =5 , +PCA9539_DIRECTION_0 =6 , +PCA9539_DIRECTION_1 =7 +};
I think tab-aligned equal signs would improve readability. Also, it's considered good practice to leave a comma on the last line, so as to minimize possible further patches.
drivers/i2c/chips/pca9539.c
Quoted 4 lines
drivers/i2c/chips/pca9539.c +3
-0+return sprintf (buf,"%d\n" ,i2c_smbus_read_byte_data (client, + (u8 )psa->index)); +i2c_smbus_write_byte_data (client, (u8 )psa->index, (u8 )val);
These (u8) casts do not seem to be needed.
drivers/i2c/chips/pca9539.c
Quoted 2 lines
drivers/i2c/chips/pca9539.c +2
-0+/* Detection: the pcs9539 only has 8 registers (0-7). +A read of 7 should succeed, but a read of 8 should fail. */
s/pcs/pca/
drivers/i2c/chips/pca9539.c
Quoted 3 lines
drivers/i2c/chips/pca9539.c +3
-0+if ((i2c_smbus_read_byte_data (new_client,7 ) <0 ) && + (i2c_smbus_read_byte_data (new_client,8 ) >=0 )) + goto exit_kfree;
Shouldn't this be || rather than &&? Either condition is sufficient to discard the chip.
Documentation/i2c/chips/pca9539 line 4
Quoted 7 lines
Documentation/i2c/chips/pca9539 +4
-0@@ -0,0 +1,54 @@ +Kernel driver pca9539 +==========> + +Supported chips: + * Maxim pca9539
Isn't it really Philips? Also, we tend to use caps when designating the chips themselves.
Documentation/i2c/chips/pca9539 line 5
Quoted 1 line
Documentation/i2c/chips/pca9539 +1
-0+ Prefixes: 'pca9539'
No s, there's a single prefix.
Documentation/i2c/chips/pca9539 line 7
Quoted 2 lines
Documentation/i2c/chips/pca9539 +2
-0+ Addresses scanned: 0x74 - 0x77 + Datasheets:
No s, there's a single datasheet.
Documentation/i2c/chips/pca9539 line 13
Quoted 6 lines
Documentation/i2c/chips/pca9539 +6
-0+Module Parameters +----------------- + +None + +
You can skip that section altogether.
Documentation/i2c/chips/pca9539 line 17
Quoted 4 lines
Documentation/i2c/chips/pca9539 +4
-0+Description +----------- + +The Phillips PCA9539 is a 16 bit low power I/O device.
Single 'l' to Philips.
Documentation/i2c/chips/pca9539 line 18
Quoted 1 line
Documentation/i2c/chips/pca9539 +1
-0+name - reads 'pca9539'
This is a standard entry, do not bother documenting it here.
Documentation/i2c/chips/pca9539 line 19
Quoted 1 line
Documentation/i2c/chips/pca9539 +1
-0+The direction defaults to input only for all channels.
s/only//?
OK, I think that's all, and it should be alright next time :)
Thanks for your collaboration, I know how much work it is to go through these review & update cycles, but this is how we manage to get the best code and documentation into the kernel tree.
Signature · 1 line
Jean Delvare
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Jean,
Thanks for taking the time to review.
I made the changes you suggested and will repost as retry 5. For the description, I went with the wording in the datasheet: "16-bit I/O port"
Ben
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: Monday, June 06, 2005 2:37 PM
To: Gardner, Ben
Cc: Greg KH; LM Sensors
Subject: Re: [lm-sensors] [PATCH 2.6.12-rc5-mm2] pca9539: new i2c drvier (retry 4 - attachment)
Hi Ben,
Quoted 4 lines
Attached (due to email line-wrapping problems) is an updated patch for
the PCA9539.
I think this one is now ready for inclusion.
I'm very sorry but it looks like I still have a few objections ;)
Quoted 1 line
--- linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/Kconfig
2005-06-01 14:29:17.000000000 -0500
Quoted 1 line
+++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/Kconfig
2005-06-06 09:22:05.904153486 -0500
Review line 444
Quoted 6 lines
(quoted diff) +2
-0@@ -440,6 +440,16 @@ This driver can also be built as a module. If so, the module will be called pcf8574. +config SENSORS_PCA9539 + tristate "PCA9539 16-bit digital IO"
"Philips PCA9539 16-bit digital I/O"
(BTW, is there something like analog bits?)
Review line 447
Quoted 3 lines
(quoted diff) +3
-0+ depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the PCA9539
Philips PCA9539
Review line 448
Quoted 1 line
(quoted diff) +1
-0+ low power digital I/O with 16 bit.
"with 16 bit" sounds really weird. "16-bit digital I/O" here again maybe?
Review line 443
Quoted 1 line
(quoted diff) +0
-1--- linux-2.6.12-rc5-mm2-clean/drivers/i2c/chips/pca9539.c
1969-12-31 18:00:00.000000000 -0600
Review line 449
Quoted 1 line
(quoted diff) +1
-0+++ linux-2.6.12-rc5-mm2-pca9539/drivers/i2c/chips/pca9539.c
2005-06-06 09:21:15.000000000 -0500
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,192 @@ +/* + pca9539.c - 16 port digital I/O with interrupt and reset
s/ port/-bit/ for consistency.
Review line 3
Quoted 1 line
(quoted diff) +1
-0+#include <linux/i2c-sysfs.h>
It has become linux/hwmon-sysfs.h a few hours ago ;)
Review line 14
Quoted 11 lines
(quoted diff) +11
-0+enum pca9539_cmd +{ + PCA9539_INPUT_0 = 0, + PCA9539_INPUT_1 = 1, + PCA9539_OUTPUT_0 = 2, + PCA9539_OUTPUT_1 = 3, + PCA9539_INVERT_0 = 4, + PCA9539_INVERT_1 = 5, + PCA9539_DIRECTION_0 = 6, + PCA9539_DIRECTION_1 = 7 +};
I think tab-aligned equal signs would improve readability. Also, it's considered good practice to leave a comma on the last line, so as to minimize possible further patches.
Review line 16
Quoted 2 lines
(quoted diff) +2
-0+ return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client, +
(u8)psa->index));
Review
Quoted 2 lines
(quoted diff) +1
-0+ i2c_smbus_write_byte_data(client, (u8)psa->index, (u8)val);
These (u8) casts do not seem to be needed.
Review
Quoted 2 lines
(quoted diff) +2
-0+ /* Detection: the pcs9539 only has 8 registers (0-7). + A read of 7 should succeed, but a read of 8 should fail. */
s/pcs/pca/
Review
Quoted 3 lines
(quoted diff) +3
-0+ if ((i2c_smbus_read_byte_data(new_client, 7) < 0) && + (i2c_smbus_read_byte_data(new_client, 8) >= 0)) + goto exit_kfree;
Shouldn't this be || rather than &&? Either condition is sufficient to discard the chip.
Quoted 1 line
--- linux-2.6.12-rc5-mm2-clean/Documentation/i2c/chips/pca9539
1969-12-31 18:00:00.000000000 -0600
Quoted 1 line
+++ linux-2.6.12-rc5-mm2/Documentation/i2c/chips/pca9539
2005-06-06 09:36:49.167804115 -0500
Review line 4
Quoted 5 lines
(quoted diff) +4
-0@@ -0,0 +1,54 @@ +Kernel driver pca9539 +==========> + +Supported chips: + * Maxim pca9539
Isn't it really Philips? Also, we tend to use caps when designating the chips themselves.
Review line 5
Quoted 1 line
(quoted diff) +1
-0+ Prefixes: 'pca9539'
No s, there's a single prefix.
Review line 7
Quoted 2 lines
(quoted diff) +2
-0+ Addresses scanned: 0x74 - 0x77 + Datasheets:
No s, there's a single datasheet.
Review line 13
Quoted 6 lines
(quoted diff) +6
-0+Module Parameters +----------------- + +None + +
You can skip that section altogether.
Review line 17
Quoted 4 lines
(quoted diff) +4
-0+Description +----------- + +The Phillips PCA9539 is a 16 bit low power I/O device.
Single 'l' to Philips.
Review line 18
Quoted 1 line
(quoted diff) +1
-0+name - reads 'pca9539'
This is a standard entry, do not bother documenting it here.
Review line 19
Quoted 1 line
(quoted diff) +1
-0+The direction defaults to input only for all channels.
s/only//?
OK, I think that's all, and it should be alright next time :)
Thanks for your collaboration, I know how much work it is to go through these review & update cycles, but this is how we manage to get the best code and documentation into the kernel tree.
--
Jean Delvare
PATCH 1/1 pca9539: new i2c drvier (retry 5
In reply to [email protected]Greg,
Attached (due to email line-wrapping problems) is an updated patch for the Philips PCA9539.
I think this one is now ready for inclusion.
Thanks,
Ben
=
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
The patch includes documentation.
It depends on the patch that renames "i2c-sysfs.h" to "hwmon-sysfs.h"
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Quoted 5 lines · On Mon, Jun 06, 2005 at 04:32:52PM -0400, [email protected] wrote:
Greg,
Attached (due to email line-wrapping problems) is an updated patch for the Philips PCA9539.
I think this one is now ready for inclusion.
-ENOPATCH :(
And please don't attach base-64 patches, they are a pain.
If only everyone would just use a sane email client...
thanks,
greg k-h
PATCH 1/1 pca9539: new i2c driver (retry 7)
In reply to [email protected]Here's a retry using KMail as the email client.
=
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
The patch includes documentation.
It depends on the patch that renames "i2c-sysfs.h" to "hwmon-sysfs.h"
drivers/i2c/chips/Kconfig 2005-06-06 15:24:28.961183516 -0500 renamed from drivers/i2c/chips/Kconfig 2005-06-01 14:29:17.000000000 -0500 +0 -0
@@ -440,6 +440,16 @@
? ? This driver can also be built as a module. ?If so, the module ? ? will be called pcf8574.
?
+config SENSORS_PCA9539
+ tristate "Philips PCA9539 16-bit I/O port"
+ depends on I2C && EXPERIMENTAL
+ help
+ ? If you say yes here you get support for the Philips PCA9539
+ ? 16-bit I/O port.
+ ? ? ? ? ?
+ ? This driver can also be built as a module. ?If so, the module
+ ? will be called pca9539.
+
?config SENSORS_PCF8591
? tristate "Philips PCF8591"
? depends on I2C && EXPERIMENTAL
drivers/i2c/chips/Makefile 2005-06-03 12:09:41.000000000 -0500 renamed from drivers/i2c/chips/Makefile 2005-06-01 14:29:17.000000000 -0500 +0 -0
@@ -34,6 +34,7 @@
?obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
?obj-$(CONFIG_SENSORS_M41T00) += m41t00.o
?obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
+obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
?obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
?obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
?obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
drivers/i2c/chips/pca9539.c 2005-06-06 15:15:30.000000000 -0500 renamed from drivers/i2c/chips/pca9539.c 1969-12-31 18:00:00.000000000 -0600 +192 -0
192 lines not on this page · raw message
Documentation/i2c/chips/pca9539 2005-06-06 15:09:25.161264937 -0500 renamed from Documentation/i2c/chips/pca9539 1969-12-31 18:00:00.000000000 -0600 +46 -0
46 lines not on this page · raw message
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Lets try that again with the attachement, since I've had 0 luck sending inline.
=
Greg,
Attached (due to email line-wrapping problems) is an updated patch for the Philips PCA9539.
I think this one is now ready for inclusion.
Thanks,
Ben
=
This is a driver for the PCA9539, a 16 bit digital I/O chip. It uses the new i2c-sysfs interfaces.
The patch includes documentation.
It depends on the patch that renames "i2c-sysfs.h" to "hwmon-sysfs.h"
-------------- next part --------------
drivers/i2c/chips/Kconfig +10 -0
@@ -440,6 +440,16 @@ This driver can also be built as a module. If so, the module will be called pcf8574. +config SENSORS_PCA9539 + tristate "Philips PCA9539 16-bit I/O port" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the Philips PCA9539 + 16-bit I/O port. + + This driver can also be built as a module. If so, the module + will be called pca9539. + config SENSORS_PCF8591 tristate "Philips PCF8591" depends on I2C && EXPERIMENTAL
drivers/i2c/chips/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_SENSORS_MAX1619) += max1619.o obj-$(CONFIG_SENSORS_M41T00) += m41t00.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o +obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
drivers/i2c/chips/pca9539.c +192 -0
192 lines not on this page · raw message
Documentation/i2c/chips/pca9539 +46 -0
46 lines not on this page · raw message
PATCH 1/1 pca9539: new i2c drvier
In reply to [email protected]Quoted 3 lines · On Mon, Jun 06, 2005 at 07:15:31PM -0400, [email protected] wrote:
Lets try that again with the attachement, since I've had 0 luck sending inline.
Content-Type: text/plain;
name="pca9539.diff.txt"
Content-Transfer-Encoding: base64
Content-Description: pca9539.diff.txt
Content-Disposition: attachment;
filename="pca9539.diff.txt"base64 is nasty. I can't just pipe that email through patch that way...
thanks,
greg k-h
PATCH 1/1 pca9539: new i2c driver (retry 9
In reply to [email protected]Greg,
I (finally) figured out how to send an attachment that is NOT Base64 encoded. Patch should be happy with this email.
Thanks for your patience. =)
Ben
=
This is an i2c driver for the Philips PCA9539 (16 bit I/O port). It uses the new i2c-sysfs interfaces.
The patch includes documentation.
It depends on the patch that renames "i2c-sysfs.h" to "hwmon-sysfs.h"
-------------- next part --------------
drivers/i2c/chips/Kconfig +10 -0
@@ -440,6 +440,16 @@ This driver can also be built as a module. If so, the module will be called pcf8574. +config SENSORS_PCA9539 + tristate "Philips PCA9539 16-bit I/O port" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the Philips PCA9539 + 16-bit I/O port. + + This driver can also be built as a module. If so, the module + will be called pca9539. + config SENSORS_PCF8591 tristate "Philips PCF8591" depends on I2C && EXPERIMENTAL
drivers/i2c/chips/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_SENSORS_MAX1619) += max1619.o obj-$(CONFIG_SENSORS_M41T00) += m41t00.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o +obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
drivers/i2c/chips/pca9539.c +192 -0
192 lines not on this page · raw message
Documentation/i2c/chips/pca9539 +46 -0
46 lines not on this page · raw message
PATCH 1/1 pca9539: new i2c driver
In reply to [email protected]Quoted 3 lines
I (finally) figured out how to send an attachment that is NOT Base64 encoded. Patch should be happy with this email.
Thanks for your patience. =)
This one is fine with me, and applies just fine on top of my tree as well :)
Signature · 1 line
Jean Delvare