drivers: (dynamic sysfs callbacks) update device attribute callbacks
Subsystems (6)
PATCH 1/1 drivers: (dynamic sysfs callbacks) update device attribute callbacks
Hi Greg,
I'm taking two steps here to try and mitigate the pain of a potential -mm merge.
I'm including a patch against 2.4.12-rc4-mm2 to fix the failed hunks when applying my 2.4.12-rc4 patch and update the callbacks in the new drivers that exist in -mm2.
In reply to this patch I'll include the latest perl script I'm using to update callbacks in code which can be used to update any old callbacks in a single file/source tree to the new callbacks. A warning along the lines of "warning: assignment from incompatible pointer type" when compiling is a good sign of an old callback that needs updating..
It is important to note that unlike before, updating the callbacks isn't just removing warnings/good practice. The new device_attribute * parameter was not added on the end of callback function's parameter list as the void * parameter was in previous device_attribute patches, but as the second parameter (mainly because of style and Russell did it that way). Thus if a device_attribute callback isn't updated it will very likely be broken...
If you can think of anything else I can do let me know to ease things let me know.
Yani
---char/tpm/tpm.c | 8 ++++----
char/tpm/tpm.h | 8 ++++---- i2c/chips/adm1025.c | 8 ++++---- i2c/chips/adm9240.c | 32 ++++++++++++++++---------------- i2c/chips/atxp1.c | 12 ++++++------ i2c/chips/w83627ehf.c | 18 +++++++++--------- input/serio/serio.c | 12 ++++++------ message/fusion/mptscsih.c | 2 +- message/fusion/mptscsih.h | 2 +- pci/pci-sysfs.c | 2 +- pcmcia/ds.c | 2 +- usb/core/sysfs.c | 2 +- 12 files changed, 54 insertions(+), 54 deletions(-)
---
drivers/char/tpm/tpm.c +4 -4
@@ -216,7 +216,7 @@ static const u8 pcrread[] = { 0, 0, 0, 0 /* PCR index */ }; -ssize_t tpm_show_pcrs (struct device *dev,char *buf) +ssize_t tpm_show_pcrs (struct device *dev,struct device_attribute *attr,char *buf) {u8 data[READ_PCR_RESULT_SIZE ];ssize_t len;
@@ -268,7 +268,7 @@ static const u8 readpubek[] = { 0, 0, 0, 124, /* TPM_ORD_ReadPubek */ }; -ssize_t tpm_show_pubek (struct device *dev,char *buf) +ssize_t tpm_show_pubek (struct device *dev,struct device_attribute *attr,char *buf) {u8 *data;ssize_t len;
@@ -349,7 +349,7 @@ static const u8 cap_manufacturer[] = { 0, 0, 1, 3 }; -ssize_t tpm_show_caps (struct device *dev,char *buf) +ssize_t tpm_show_caps (struct device *dev,struct device_attribute *attr,char *buf) {u8 data[sizeof (cap_manufacturer)];ssize_t len;
@@ -385,7 +385,7 @@ ssize_t tpm_show_caps(struct device *devEXPORT_SYMBOL_GPL (tpm_show_caps); -ssize_t tpm_store_cancel (struct device * dev,const char *buf, +ssize_t tpm_store_cancel (struct device * dev,struct device_attribute *attr,const char *buf,size_t count) {struct tpm_chip *chip =dev_get_drvdata (dev);
drivers/char/tpm/tpm.h +4 -4
@@ -35,10 +35,10 @@ enum tpm_addr { TPM_DATA = 0x4F }; -extern ssize_t tpm_show_pubek (struct device *,char *); -extern ssize_t tpm_show_pcrs (struct device *,char *); -extern ssize_t tpm_show_caps (struct device *,char *); -extern ssize_t tpm_store_cancel (struct device *,const char *,size_t ); +extern ssize_t tpm_show_pubek (struct device *,struct device_attribute *attr,char *); +extern ssize_t tpm_show_pcrs (struct device *,struct device_attribute *attr,char *); +extern ssize_t tpm_show_caps (struct device *,struct device_attribute *attr,char *); +extern ssize_t tpm_store_cancel (struct device *,struct device_attribute *attr,const char *,size_t );struct tpm_chip ;
drivers/i2c/chips/adm1025.c +4 -4
@@ -274,14 +274,14 @@ static DEVICE_ATTR(temp##offset##_max, Sset_temp (1 );set_temp (2 ); -static ssize_t show_alarms (struct device *dev,char *buf) +static ssize_t show_alarms (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1025_data *data =adm1025_update_device (dev);return sprintf (buf,"%u\n" , data->alarms); } static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); -static ssize_t show_vid (struct device *dev,char *buf) +static ssize_t show_vid (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1025_data *data =adm1025_update_device (dev);return sprintf (buf,"%u\n" ,vid_from_reg (data->vid, data->vrm));
@@ -290,12 +290,12 @@ static ssize_t show_vid(struct device *d static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); -static ssize_t show_vrm (struct device *dev,char *buf) +static ssize_t show_vrm (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1025_data *data =adm1025_update_device (dev);return sprintf (buf,"%u\n" , data->vrm); } -static ssize_t set_vrm (struct device *dev,const char *buf,size_t count) +static ssize_t set_vrm (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);struct adm1025_data *data =i2c_get_clientdata (client);
drivers/i2c/chips/adm9240.c +16 -16
@@ -185,7 +185,7 @@ static int adm9240_write_value(struct i2/* temperature */ #define show_temp (value, scale) \ -static ssize_t show_##value(struct device *dev, char *buf) \ +static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ { \ struct adm9240_data *data = adm9240_update_device(dev); \ return sprintf(buf, "%d\n", data->value * scale); \
@@ -195,7 +195,7 @@ show_temp(temp_hyst, 1000);show_temp (temp,500 );#define set_temp (value, reg) \ -static ssize_t set_##value(struct device *dev, const char *buf, \ +static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ size_t count) \ { \ struct i2c_client *client = to_i2c_client(dev); \
@@ -266,26 +266,26 @@ static ssize_t set_in_max(struct device }#define show_in_offset (offset) \ -static ssize_t show_in##offset(struct device *dev, char *buf) \ +static ssize_t show_in##offset(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_in(dev, buf, offset); \ } \ static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ -static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ +static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_in_min(dev, buf, offset); \ } \ -static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ +static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_in_max(dev, buf, offset); \ } \ static ssize_t \ -set_in##offset##_min(struct device *dev, const char *buf, size_t count) \ +set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ { \ return set_in_min(dev, buf, count, offset); \ } \ static ssize_t \ -set_in##offset##_max(struct device *dev, const char *buf, size_t count) \ +set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ { \ return set_in_max(dev, buf, count, offset); \ } \
@@ -401,19 +401,19 @@ static ssize_t set_fan_min(struct device }#define show_fan_offset (offset) \ -static ssize_t show_fan_##offset (struct device *dev, char *buf) \ +static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan(dev, buf, offset - 1); \ } \ -static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ +static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_div(dev, buf, offset - 1); \ } \ -static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ +static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_min(dev, buf, offset - 1); \ } \ -static ssize_t set_fan_##offset##_min (struct device *dev, \ +static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ const char *buf, size_t count) \ { \ return set_fan_min(dev, buf, count, offset - 1); \
@@ -429,7 +429,7 @@ show_fan_offset(1);show_fan_offset (2 );/* alarms */ -static ssize_t show_alarms (struct device *dev,char *buf) +static ssize_t show_alarms (struct device *dev,struct device_attribute *attr,char *buf) {struct adm9240_data *data =adm9240_update_device (dev);return sprintf (buf,"%u\n" , data->alarms);
@@ -437,7 +437,7 @@ static ssize_t show_alarms(struct device static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);/* vid */ -static ssize_t show_vid (struct device *dev,char *buf) +static ssize_t show_vid (struct device *dev,struct device_attribute *attr,char *buf) {struct adm9240_data *data =adm9240_update_device (dev);return sprintf (buf,"%d\n" ,vid_from_reg (data->vid, data->vrm));
@@ -445,13 +445,13 @@ static ssize_t show_vid(struct device *d static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);/* analog output */ -static ssize_t show_aout (struct device *dev,char *buf) +static ssize_t show_aout (struct device *dev,struct device_attribute *attr,char *buf) {struct adm9240_data *data =adm9240_update_device (dev);return sprintf (buf,"%d\n" ,AOUT_FROM_REG (data->aout)); } -static ssize_t set_aout (struct device *dev,const char *buf,size_t count) +static ssize_t set_aout (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);struct adm9240_data *data =i2c_get_clientdata (client);
@@ -466,7 +466,7 @@ static ssize_t set_aout(struct device *d static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);/* chassis_clear */ -static ssize_t chassis_clear (struct device *dev,const char *buf,size_t count) +static ssize_t chassis_clear (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);unsigned long val =simple_strtol (buf,NULL ,10 );
drivers/i2c/chips/atxp1.c +6 -6
@@ -99,7 +99,7 @@ static struct atxp1_data * atxp1_update_ }/* sys file functions for cpu0_vid */ -static ssize_t atxp1_showvcore (struct device *dev,char *buf) +static ssize_t atxp1_showvcore (struct device *dev,struct device_attribute *attr,char *buf) {int size;struct atxp1_data *data;
@@ -111,7 +111,7 @@ static ssize_t atxp1_showvcore(struct dereturn size; } -static ssize_t atxp1_storevcore (struct device *dev,const char * buf,size_t count) +static ssize_t atxp1_storevcore (struct device *dev,struct device_attribute *attr,const char * buf,size_t count) {struct atxp1_data *data;struct i2c_client *client;
@@ -169,7 +169,7 @@ static ssize_t atxp1_storevcore(struct d static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore);/* sys file functions for GPIO1 */ -static ssize_t atxp1_showgpio1 (struct device *dev,char *buf) +static ssize_t atxp1_showgpio1 (struct device *dev,struct device_attribute *attr,char *buf) {int size;struct atxp1_data *data;
@@ -181,7 +181,7 @@ static ssize_t atxp1_showgpio1(struct dereturn size; } -static ssize_t atxp1_storegpio1 (struct device *dev,const char * buf,size_t count) +static ssize_t atxp1_storegpio1 (struct device *dev,struct device_attribute *attr,const char * buf,size_t count) {struct atxp1_data *data;struct i2c_client *client;
@@ -211,7 +211,7 @@ static ssize_t atxp1_storegpio1(struct d static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1);/* sys file functions for GPIO2 */ -static ssize_t atxp1_showgpio2 (struct device *dev,char *buf) +static ssize_t atxp1_showgpio2 (struct device *dev,struct device_attribute *attr,char *buf) {int size;struct atxp1_data *data;
@@ -223,7 +223,7 @@ static ssize_t atxp1_showgpio2(struct dereturn size; } -static ssize_t atxp1_storegpio2 (struct device *dev,const char * buf,size_t count) +static ssize_t atxp1_storegpio2 (struct device *dev,struct device_attribute *attr,const char * buf,size_t count) {struct atxp1_data *data;struct i2c_client *client;
drivers/i2c/chips/w83627ehf.c +9 -9
@@ -486,7 +486,7 @@ store_fan_min(struct device *dev, const#define sysfs_fan_offset (offset) \ static ssize_t \ -show_reg_fan_##offset(struct device *dev, char *buf) \ +show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan(dev, buf, offset-1); \ } \
@@ -495,12 +495,12 @@ static DEVICE_ATTR(fan##offset##_input,#define sysfs_fan_min_offset (offset) \ static ssize_t \ -show_reg_fan##offset##_min(struct device *dev, char *buf) \ +show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_min(dev, buf, offset-1); \ } \ static ssize_t \ -store_reg_fan##offset##_min(struct device *dev, const char *buf, \ +store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ size_t count) \ { \ return store_fan_min(dev, buf, count, offset-1); \
@@ -511,7 +511,7 @@ static DEVICE_ATTR(fan##offset##_min, S_#define sysfs_fan_div_offset (offset) \ static ssize_t \ -show_reg_fan##offset##_div(struct device *dev, char *buf) \ +show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_div(dev, buf, offset - 1); \ } \
@@ -536,7 +536,7 @@ sysfs_fan_div_offset(5);#define show_temp1_reg (reg) \ static ssize_t \ -show_##reg(struct device *dev, char *buf) \ +show_##reg(struct device *dev, struct device_attribute *attr, char *buf) \ { \ struct w83627ehf_data *data = w83627ehf_update_device(dev); \ return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \
@@ -547,7 +547,7 @@ show_temp1_reg(temp1_max_hyst);#define store_temp1_reg (REG , reg) \ static ssize_t \ -store_temp1_##reg(struct device *dev, const char *buf, size_t count) \ +store_temp1_##reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ { \ struct i2c_client *client = to_i2c_client(dev); \ struct w83627ehf_data *data = i2c_get_clientdata(client); \
@@ -601,7 +601,7 @@ store_temp_reg(HYST, temp_max_hyst);#define sysfs_temp_offset (offset) \ static ssize_t \ -show_reg_temp##offset (struct device *dev, char *buf) \ +show_reg_temp##offset (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_temp(dev, buf, offset - 2); \ } \
@@ -610,12 +610,12 @@ static DEVICE_ATTR(temp##offset##_input,#define sysfs_temp_reg_offset (reg, offset) \ static ssize_t \ -show_reg_temp##offset##_##reg(struct device *dev, char *buf) \ +show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_temp_##reg(dev, buf, offset - 2); \ } \ static ssize_t \ -store_reg_temp##offset##_##reg(struct device *dev, const char *buf, \ +store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, const char *buf, \ size_t count) \ { \ return store_temp_##reg(dev, buf, count, offset - 2); \
drivers/input/serio/serio.c +6 -6
@@ -358,31 +358,31 @@ static int serio_thread(void *nothing)* Serio port operations */ -static ssize_t serio_show_description (struct device *dev,char *buf) +static ssize_t serio_show_description (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%s\n" , serio->name); } -static ssize_t serio_show_id_type (struct device *dev,char *buf) +static ssize_t serio_show_id_type (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.type); } -static ssize_t serio_show_id_proto (struct device *dev,char *buf) +static ssize_t serio_show_id_proto (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.proto); } -static ssize_t serio_show_id_id (struct device *dev,char *buf) +static ssize_t serio_show_id_id (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.id); } -static ssize_t serio_show_id_extra (struct device *dev,char *buf) +static ssize_t serio_show_id_extra (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.extra);
@@ -406,7 +406,7 @@ static struct attribute_group serio_id_a .attrs = serio_device_id_attrs, }; -static ssize_t serio_rebind_driver (struct device *dev,const char *buf,size_t count) +static ssize_t serio_rebind_driver (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct serio *serio =to_serio_port (dev);struct device_driver *drv;
drivers/message/fusion/mptscsih.c +1 -1
@@ -2352,7 +2352,7 @@ slave_configure_exit: }ssize_t -mptscsih_store_queue_depth (struct device *dev,const char *buf,size_t count) +mptscsih_store_queue_depth (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {int depth;struct scsi_device *sdev =to_scsi_device (dev);
drivers/message/fusion/mptscsih.h +1 -1
@@ -103,5 +103,5 @@ extern int mptscsih_taskmgmt_complete(MPextern int mptscsih_scandv_complete (MPT_ADAPTER *ioc,MPT_FRAME_HDR *mf,MPT_FRAME_HDR *r);extern int mptscsih_event_process (MPT_ADAPTER *ioc,EventNotificationReply_t *pEvReply);extern int mptscsih_ioc_reset (MPT_ADAPTER *ioc,int post_reset); -extern ssize_t mptscsih_store_queue_depth (struct device *dev,const char *buf,size_t count); +extern ssize_t mptscsih_store_queue_depth (struct device *dev,struct device_attribute *attr,const char *buf,size_t count);extern void mptscsih_timer_expired (unsigned long data);
drivers/pci/pci-sysfs.c +1 -1
@@ -76,7 +76,7 @@ resource_show(struct device * dev, strucreturn (str - buf); } -static ssize_t modalias_show (struct device *dev,char *buf) +static ssize_t modalias_show (struct device *dev,struct device_attribute *attr,char *buf) {struct pci_dev *pci_dev =to_pci_dev (dev);
drivers/pcmcia/ds.c +1 -1
@@ -848,7 +848,7 @@ pcmcia_device_stringattr(prod_id3, prod_pcmcia_device_stringattr (prod_id4, prod_id[3 ]); -static ssize_t pcmcia_store_allow_func_id_match (struct device * dev,const char * buf,size_t count) +static ssize_t pcmcia_store_allow_func_id_match (struct device * dev,struct device_attribute *attr,const char * buf,size_t count) {struct pcmcia_device *p_dev =to_pcmcia_dev (dev);if (!count)
drivers/usb/core/sysfs.c +1 -1
@@ -286,7 +286,7 @@ static ssize_t show_interface_string(str } static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); -static ssize_t show_modalias (struct device *dev,char *buf) +static ssize_t show_modalias (struct device *dev,struct device_attribute *attr,char *buf) {struct usb_interface *intf;struct usb_device *udev;
Ugh, forgot to sign it off, resubmitting.
Yani
Quoted 23 lines · Yani Ioannou
Hi Greg,
I'm taking two steps here to try and mitigate the pain of a potential -mm merge.
I'm including a patch against 2.4.12-rc4-mm2 to fix the failed hunks when applying my 2.4.12-rc4 patch and update the callbacks in the new drivers that exist in -mm2.
In reply to this patch I'll include the latest perl script I'm using to update callbacks in code which can be used to update any old callbacks in a single file/source tree to the new callbacks. A warning along the lines of "warning: assignment from incompatible pointer type" when compiling is a good sign of an old callback that needs updating..
It is important to note that unlike before, updating the callbacks isn't just removing warnings/good practice. The new
device_attribute* parameter was not added on the end of callback function's parameter list as the void * parameter was in previousdevice_attributepatches, but as the second parameter (mainly because of style and Russell did it that way). Thus if adevice_attributecallback isn't updated it will very likely be broken...
Quoted 4 lines
If you can think of anything else I can do let me know to ease things let me know.
Yani
char/tpm/tpm.c | 8 ++++---- char/tpm/tpm.h | 8 ++++---- i2c/chips/adm1025.c | 8 ++++---- i2c/chips/adm9240.c | 32 ++++++++++++++++---------------- i2c/chips/atxp1.c | 12 ++++++------ i2c/chips/w83627ehf.c | 18 +++++++++--------- input/serio/serio.c | 12 ++++++------ message/fusion/mptscsih.c | 2 +- message/fusion/mptscsih.h | 2 +- pci/pci-sysfs.c | 2 +- pcmcia/ds.c | 2 +- usb/core/sysfs.c | 2 +- 12 files changed, 54 insertions(+), 54 deletions(-)
---
drivers/char/tpm/tpm.c +4 -4
@@ -216,7 +216,7 @@ static const u8 pcrread[] = { 0, 0, 0, 0 /* PCR index */ }; -ssize_t tpm_show_pcrs (struct device *dev,char *buf) +ssize_t tpm_show_pcrs (struct device *dev,struct device_attribute *attr,char *buf) {u8 data[READ_PCR_RESULT_SIZE ];ssize_t len;
@@ -268,7 +268,7 @@ static const u8 readpubek[] = { 0, 0, 0, 124, /* TPM_ORD_ReadPubek */ }; -ssize_t tpm_show_pubek (struct device *dev,char *buf) +ssize_t tpm_show_pubek (struct device *dev,struct device_attribute *attr,char *buf) {u8 *data;ssize_t len;
@@ -349,7 +349,7 @@ static const u8 cap_manufacturer[] = { 0, 0, 1, 3 }; -ssize_t tpm_show_caps (struct device *dev,char *buf) +ssize_t tpm_show_caps (struct device *dev,struct device_attribute *attr,char *buf) {u8 data[sizeof (cap_manufacturer)];ssize_t len;
@@ -385,7 +385,7 @@ ssize_t tpm_show_caps(struct device *devEXPORT_SYMBOL_GPL (tpm_show_caps); -ssize_t tpm_store_cancel (struct device * dev,const char *buf, +ssize_t tpm_store_cancel (struct device * dev,struct device_attribute *attr,const char *buf,size_t count) {struct tpm_chip *chip =dev_get_drvdata (dev);
drivers/char/tpm/tpm.h +4 -4
@@ -35,10 +35,10 @@ enum tpm_addr { TPM_DATA = 0x4F }; -extern ssize_t tpm_show_pubek (struct device *,char *); -extern ssize_t tpm_show_pcrs (struct device *,char *); -extern ssize_t tpm_show_caps (struct device *,char *); -extern ssize_t tpm_store_cancel (struct device *,const char *,size_t ); +extern ssize_t tpm_show_pubek (struct device *,struct device_attribute *attr,char *); +extern ssize_t tpm_show_pcrs (struct device *,struct device_attribute *attr,char *); +extern ssize_t tpm_show_caps (struct device *,struct device_attribute *attr,char *); +extern ssize_t tpm_store_cancel (struct device *,struct device_attribute *attr,const char *,size_t );struct tpm_chip ;
drivers/i2c/chips/adm1025.c +4 -4
@@ -274,14 +274,14 @@ static DEVICE_ATTR(temp##offset##_max, Sset_temp (1 );set_temp (2 ); -static ssize_t show_alarms (struct device *dev,char *buf) +static ssize_t show_alarms (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1025_data *data =adm1025_update_device (dev);return sprintf (buf,"%u\n" , data->alarms); } static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); -static ssize_t show_vid (struct device *dev,char *buf) +static ssize_t show_vid (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1025_data *data =adm1025_update_device (dev);return sprintf (buf,"%u\n" ,vid_from_reg (data->vid, data->vrm));
@@ -290,12 +290,12 @@ static ssize_t show_vid(struct device *d static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); -static ssize_t show_vrm (struct device *dev,char *buf) +static ssize_t show_vrm (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1025_data *data =adm1025_update_device (dev);return sprintf (buf,"%u\n" , data->vrm); } -static ssize_t set_vrm (struct device *dev,const char *buf,size_t count) +static ssize_t set_vrm (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);struct adm1025_data *data =i2c_get_clientdata (client);
drivers/i2c/chips/adm9240.c +16 -16
@@ -185,7 +185,7 @@ static int adm9240_write_value(struct i2/* temperature */ #define show_temp (value, scale) \ -static ssize_t show_##value(struct device *dev, char *buf) \ +static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ { \ struct adm9240_data *data = adm9240_update_device(dev); \ return sprintf(buf, "%d\n", data->value * scale); \
@@ -195,7 +195,7 @@ show_temp(temp_hyst, 1000);show_temp (temp,500 );#define set_temp (value, reg) \ -static ssize_t set_##value(struct device *dev, const char *buf, \ +static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ size_t count) \ { \ struct i2c_client *client = to_i2c_client(dev); \
@@ -266,26 +266,26 @@ static ssize_t set_in_max(struct device }#define show_in_offset (offset) \ -static ssize_t show_in##offset(struct device *dev, char *buf) \ +static ssize_t show_in##offset(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_in(dev, buf, offset); \ } \ static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ -static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ +static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_in_min(dev, buf, offset); \ } \ -static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ +static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_in_max(dev, buf, offset); \ } \ static ssize_t \ -set_in##offset##_min(struct device *dev, const char *buf, size_t count) \ +set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ { \ return set_in_min(dev, buf, count, offset); \ } \ static ssize_t \ -set_in##offset##_max(struct device *dev, const char *buf, size_t count) \ +set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ { \ return set_in_max(dev, buf, count, offset); \ } \
@@ -401,19 +401,19 @@ static ssize_t set_fan_min(struct device }#define show_fan_offset (offset) \ -static ssize_t show_fan_##offset (struct device *dev, char *buf) \ +static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan(dev, buf, offset - 1); \ } \ -static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ +static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_div(dev, buf, offset - 1); \ } \ -static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ +static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_min(dev, buf, offset - 1); \ } \ -static ssize_t set_fan_##offset##_min (struct device *dev, \ +static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ const char *buf, size_t count) \ { \ return set_fan_min(dev, buf, count, offset - 1); \
@@ -429,7 +429,7 @@ show_fan_offset(1);show_fan_offset (2 );/* alarms */ -static ssize_t show_alarms (struct device *dev,char *buf) +static ssize_t show_alarms (struct device *dev,struct device_attribute *attr,char *buf) {struct adm9240_data *data =adm9240_update_device (dev);return sprintf (buf,"%u\n" , data->alarms);
@@ -437,7 +437,7 @@ static ssize_t show_alarms(struct device static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);/* vid */ -static ssize_t show_vid (struct device *dev,char *buf) +static ssize_t show_vid (struct device *dev,struct device_attribute *attr,char *buf) {struct adm9240_data *data =adm9240_update_device (dev);return sprintf (buf,"%d\n" ,vid_from_reg (data->vid, data->vrm));
@@ -445,13 +445,13 @@ static ssize_t show_vid(struct device *d static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);/* analog output */ -static ssize_t show_aout (struct device *dev,char *buf) +static ssize_t show_aout (struct device *dev,struct device_attribute *attr,char *buf) {struct adm9240_data *data =adm9240_update_device (dev);return sprintf (buf,"%d\n" ,AOUT_FROM_REG (data->aout)); } -static ssize_t set_aout (struct device *dev,const char *buf,size_t count) +static ssize_t set_aout (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);struct adm9240_data *data =i2c_get_clientdata (client);
@@ -466,7 +466,7 @@ static ssize_t set_aout(struct device *d static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);/* chassis_clear */ -static ssize_t chassis_clear (struct device *dev,const char *buf,size_t count) +static ssize_t chassis_clear (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);unsigned long val =simple_strtol (buf,NULL ,10 );
drivers/i2c/chips/atxp1.c +6 -6
@@ -99,7 +99,7 @@ static struct atxp1_data * atxp1_update_ }/* sys file functions for cpu0_vid */ -static ssize_t atxp1_showvcore (struct device *dev,char *buf) +static ssize_t atxp1_showvcore (struct device *dev,struct device_attribute *attr,char *buf) {int size;struct atxp1_data *data;
@@ -111,7 +111,7 @@ static ssize_t atxp1_showvcore(struct dereturn size; } -static ssize_t atxp1_storevcore (struct device *dev,const char * buf,size_t count) +static ssize_t atxp1_storevcore (struct device *dev,struct device_attribute *attr,const char * buf,size_t count) {struct atxp1_data *data;struct i2c_client *client;
@@ -169,7 +169,7 @@ static ssize_t atxp1_storevcore(struct d static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore);/* sys file functions for GPIO1 */ -static ssize_t atxp1_showgpio1 (struct device *dev,char *buf) +static ssize_t atxp1_showgpio1 (struct device *dev,struct device_attribute *attr,char *buf) {int size;struct atxp1_data *data;
@@ -181,7 +181,7 @@ static ssize_t atxp1_showgpio1(struct dereturn size; } -static ssize_t atxp1_storegpio1 (struct device *dev,const char * buf,size_t count) +static ssize_t atxp1_storegpio1 (struct device *dev,struct device_attribute *attr,const char * buf,size_t count) {struct atxp1_data *data;struct i2c_client *client;
@@ -211,7 +211,7 @@ static ssize_t atxp1_storegpio1(struct d static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1);/* sys file functions for GPIO2 */ -static ssize_t atxp1_showgpio2 (struct device *dev,char *buf) +static ssize_t atxp1_showgpio2 (struct device *dev,struct device_attribute *attr,char *buf) {int size;struct atxp1_data *data;
@@ -223,7 +223,7 @@ static ssize_t atxp1_showgpio2(struct dereturn size; } -static ssize_t atxp1_storegpio2 (struct device *dev,const char * buf,size_t count) +static ssize_t atxp1_storegpio2 (struct device *dev,struct device_attribute *attr,const char * buf,size_t count) {struct atxp1_data *data;struct i2c_client *client;
drivers/i2c/chips/w83627ehf.c +9 -9
@@ -486,7 +486,7 @@ store_fan_min(struct device *dev, const#define sysfs_fan_offset (offset) \ static ssize_t \ -show_reg_fan_##offset(struct device *dev, char *buf) \ +show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan(dev, buf, offset-1); \ } \
@@ -495,12 +495,12 @@ static DEVICE_ATTR(fan##offset##_input,#define sysfs_fan_min_offset (offset) \ static ssize_t \ -show_reg_fan##offset##_min(struct device *dev, char *buf) \ +show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_min(dev, buf, offset-1); \ } \ static ssize_t \ -store_reg_fan##offset##_min(struct device *dev, const char *buf, \ +store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ size_t count) \ { \ return store_fan_min(dev, buf, count, offset-1); \
@@ -511,7 +511,7 @@ static DEVICE_ATTR(fan##offset##_min, S_#define sysfs_fan_div_offset (offset) \ static ssize_t \ -show_reg_fan##offset##_div(struct device *dev, char *buf) \ +show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_fan_div(dev, buf, offset - 1); \ } \
@@ -536,7 +536,7 @@ sysfs_fan_div_offset(5);#define show_temp1_reg (reg) \ static ssize_t \ -show_##reg(struct device *dev, char *buf) \ +show_##reg(struct device *dev, struct device_attribute *attr, char *buf) \ { \ struct w83627ehf_data *data = w83627ehf_update_device(dev); \ return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \
@@ -547,7 +547,7 @@ show_temp1_reg(temp1_max_hyst);#define store_temp1_reg (REG , reg) \ static ssize_t \ -store_temp1_##reg(struct device *dev, const char *buf, size_t count) \ +store_temp1_##reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ { \ struct i2c_client *client = to_i2c_client(dev); \ struct w83627ehf_data *data = i2c_get_clientdata(client); \
@@ -601,7 +601,7 @@ store_temp_reg(HYST, temp_max_hyst);#define sysfs_temp_offset (offset) \ static ssize_t \ -show_reg_temp##offset (struct device *dev, char *buf) \ +show_reg_temp##offset (struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_temp(dev, buf, offset - 2); \ } \
@@ -610,12 +610,12 @@ static DEVICE_ATTR(temp##offset##_input,#define sysfs_temp_reg_offset (reg, offset) \ static ssize_t \ -show_reg_temp##offset##_##reg(struct device *dev, char *buf) \ +show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return show_temp_##reg(dev, buf, offset - 2); \ } \ static ssize_t \ -store_reg_temp##offset##_##reg(struct device *dev, const char *buf, \ +store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, const char *buf, \ size_t count) \ { \ return store_temp_##reg(dev, buf, count, offset - 2); \
drivers/input/serio/serio.c +6 -6
@@ -358,31 +358,31 @@ static int serio_thread(void *nothing)* Serio port operations */ -static ssize_t serio_show_description (struct device *dev,char *buf) +static ssize_t serio_show_description (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%s\n" , serio->name); } -static ssize_t serio_show_id_type (struct device *dev,char *buf) +static ssize_t serio_show_id_type (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.type); } -static ssize_t serio_show_id_proto (struct device *dev,char *buf) +static ssize_t serio_show_id_proto (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.proto); } -static ssize_t serio_show_id_id (struct device *dev,char *buf) +static ssize_t serio_show_id_id (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.id); } -static ssize_t serio_show_id_extra (struct device *dev,char *buf) +static ssize_t serio_show_id_extra (struct device *dev,struct device_attribute *attr,char *buf) {struct serio *serio =to_serio_port (dev);return sprintf (buf,"%02x\n" , serio->id.extra);
@@ -406,7 +406,7 @@ static struct attribute_group serio_id_a .attrs = serio_device_id_attrs, }; -static ssize_t serio_rebind_driver (struct device *dev,const char *buf,size_t count) +static ssize_t serio_rebind_driver (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct serio *serio =to_serio_port (dev);struct device_driver *drv;
drivers/message/fusion/mptscsih.c +1 -1
@@ -2352,7 +2352,7 @@ slave_configure_exit: }ssize_t -mptscsih_store_queue_depth (struct device *dev,const char *buf,size_t count) +mptscsih_store_queue_depth (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {int depth;struct scsi_device *sdev =to_scsi_device (dev);
drivers/message/fusion/mptscsih.h +1 -1
@@ -103,5 +103,5 @@ extern int mptscsih_taskmgmt_complete(MPextern int mptscsih_scandv_complete (MPT_ADAPTER *ioc,MPT_FRAME_HDR *mf,MPT_FRAME_HDR *r);extern int mptscsih_event_process (MPT_ADAPTER *ioc,EventNotificationReply_t *pEvReply);extern int mptscsih_ioc_reset (MPT_ADAPTER *ioc,int post_reset); -extern ssize_t mptscsih_store_queue_depth (struct device *dev,const char *buf,size_t count); +extern ssize_t mptscsih_store_queue_depth (struct device *dev,struct device_attribute *attr,const char *buf,size_t count);extern void mptscsih_timer_expired (unsigned long data);
drivers/pci/pci-sysfs.c +1 -1
@@ -76,7 +76,7 @@ resource_show(struct device * dev, strucreturn (str - buf); } -static ssize_t modalias_show (struct device *dev,char *buf) +static ssize_t modalias_show (struct device *dev,struct device_attribute *attr,char *buf) {struct pci_dev *pci_dev =to_pci_dev (dev);
drivers/pcmcia/ds.c +1 -1
@@ -848,7 +848,7 @@ pcmcia_device_stringattr(prod_id3, prod_pcmcia_device_stringattr (prod_id4, prod_id[3 ]); -static ssize_t pcmcia_store_allow_func_id_match (struct device * dev,const char * buf,size_t count) +static ssize_t pcmcia_store_allow_func_id_match (struct device * dev,struct device_attribute *attr,const char * buf,size_t count) {struct pcmcia_device *p_dev =to_pcmcia_dev (dev);if (!count)
drivers/usb/core/sysfs.c +1 -1
@@ -286,7 +286,7 @@ static ssize_t show_interface_string(str } static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); -static ssize_t show_modalias (struct device *dev,char *buf) +static ssize_t show_modalias (struct device *dev,struct device_attribute *attr,char *buf) {struct usb_interface *intf;struct usb_device *udev;
Here is the previously mentioned perl script. Its quite simplistic, and accepts the filename of a source file to update as a parameter, or uses stdin/stdout if no parameters are given. To update a whole tree using the below just use something like:
find linux-2.6.12-rc4 -type f -exec ./updatedyncallbackdevattr.pl {} \;
This script should catch every device_attribute callback, including multiline function signatures and embedded in macros. If it fails to catch something please let me know.
Thanks,
Yani
---
#!/usr/bin/perl
use strict;
my $infile=shift;
if(!defined $infile){
open(IN,"<&STDIN") or die "Could not open an input stream";
}else{
open(IN,"<$infile") or die "Could not open an input stream";
}my $subs = 0;
my $code = "";
while(<IN>){$code.=$_};
close(IN);
$code =~ s/(ssize_t[\s\\]+?[^(;]+?\(\s*?struct[\s\\]+?(?:device)[\s\\]*?\*[^,);]*?,)([\s\\]*?char[\s\\]*?\*[^,);]*?[\s\\]*?\))/$1
struct device_attribute *attr,$2/gs && $subs++;
$code =~ s/(ssize_t[\s\\]+?[^(;]+?\(\s*?struct[\s\\]+?(?:device)[\s\\]*?\*[^,);]*?,)([\s\\]*?const[\s\\]+?char[\s\\]*?\*[^,);]*?[\s\\]*?,[\s\\]*size_t[^,);]*?[\s\\]*\))/$1 struct device_attribute *attr,$2/gs && $subs++;
if($subs){
if(!defined $infile){
open(OUT,">&STDOUT") or die "Could not open an output stream";
}else{
open(OUT,">$infile") or die "Could not open an output stream";
}
$|;
print OUT $code;
close(OUT);
$infile && print STDOUT "$infile updated.\n";
}