driver core bus cleanup to use dev_groups, round 2
Subsystems (9)
Greg Kroah-Hartman
maintainercover driver core bus cleanup to use dev_groups, round 2
Here is another series of patches to clean up the different bus code to not use 'dev_attr' and instead, use 'dev_groups' as dev_attr will be removed soon.
greg k-h
--- drivers/ide/ide-sysfs.c | 35 ++++++++++++++++++++++++++--------- drivers/ide/ide.c | 2 +- drivers/input/gameport/gameport.c | 17 ++++++++++------- drivers/ipack/ipack.c | 22 +++++++++++++++------- drivers/memstick/core/memstick.c | 18 +++++++++--------- drivers/message/i2o/core.h | 2 +- drivers/message/i2o/device.c | 32 +++++++++++++++++++++----------- drivers/message/i2o/driver.c | 2 +- drivers/misc/tifm_core.c | 10 ++++++---- drivers/spi/spi.c | 10 ++++++---- drivers/virtio/virtio.c | 27 +++++++++++++++++++-------- include/linux/ide.h | 2 +- 12 files changed, 116 insertions(+), 63 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/8 ide: convert bus code to use dev_groups
The dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the ide bus code to use the correct field.
---
David, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
drivers/ide/ide-sysfs.c | 35 ++++++++++++++++++++++++++--------- drivers/ide/ide.c | 2 +- include/linux/ide.h | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-)
drivers/ide/ide-sysfs.c +26 -9
@@ -25,6 +25,7 @@ static ssize_t media_show(struct device *dev, struct device_attribute *attr,ide_drive_t *drive =to_ide_device (dev);return sprintf (buf,"%s\n" ,ide_media_string (drive)); } +static DEVICE_ATTR_RO (media);static ssize_t drivename_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -32,6 +33,7 @@ static ssize_t drivename_show(struct device *dev, struct device_attribute *attr,ide_drive_t *drive =to_ide_device (dev);return sprintf (buf,"%s\n" , drive->name); } +static DEVICE_ATTR_RO (drivename);static ssize_t modalias_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -39,6 +41,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,ide_drive_t *drive =to_ide_device (dev);return sprintf (buf,"ide:m-%s\n" ,ide_media_string (drive)); } +static DEVICE_ATTR_RO (modalias);static ssize_t model_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -46,6 +49,7 @@ static ssize_t model_show(struct device *dev, struct device_attribute *attr,ide_drive_t *drive =to_ide_device (dev);return sprintf (buf,"%s\n" , (char *)&drive->id[ATA_ID_PROD ]); } +static DEVICE_ATTR_RO (model);static ssize_t firmware_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -53,6 +57,7 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,ide_drive_t *drive =to_ide_device (dev);return sprintf (buf,"%s\n" , (char *)&drive->id[ATA_ID_FW_REV ]); } +static DEVICE_ATTR_RO (firmware);static ssize_t serial_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -60,16 +65,28 @@ static ssize_t serial_show(struct device *dev, struct device_attribute *attr,ide_drive_t *drive =to_ide_device (dev);return sprintf (buf,"%s\n" , (char *)&drive->id[ATA_ID_SERNO ]); } +static DEVICE_ATTR(serial, 0400, serial_show, NULL); + +static DEVICE_ATTR(unload_heads, 0644, ide_park_show, ide_park_store); + +static struct attribute *ide_attrs[] = { + &dev_attr_media.attr, + &dev_attr_drivename.attr, + &dev_attr_modalias.attr, + &dev_attr_model.attr, + &dev_attr_firmware.attr, + &dev_attr_serial.attr, + &dev_attr_unload_heads.attr, +NULL , +}; + +static const struct attribute_group ide_attr_group = { + .attrs = ide_attrs, +}; -struct device_attribute ide_dev_attrs[] = { -__ATTR_RO (media), -__ATTR_RO (drivename), -__ATTR_RO (modalias), -__ATTR_RO (model), -__ATTR_RO (firmware), -__ATTR (serial,0400 , serial_show,NULL ), -__ATTR (unload_heads,0644 , ide_park_show, ide_park_store), - __ATTR_NULL +const struct attribute_group *ide_dev_groups[] = { + &ide_attr_group, +NULL , }; static ssize_t store_delete_devices(struct device *portdev,
drivers/ide/ide.c +1 -1
@@ -158,7 +158,7 @@ struct bus_type ide_bus_type = { .probe = generic_ide_probe, .remove = generic_ide_remove, .shutdown = generic_ide_shutdown, - .dev_attrs = ide_dev_attrs, + .dev_groups = ide_dev_groups, .suspend = generic_ide_suspend, .resume = generic_ide_resume, };
include/linux/ide.h +1 -1
@@ -1514,7 +1514,7 @@ static inline void ide_set_max_pio(ide_drive_t *drive)char *ide_media_string (ide_drive_t *); -extern struct device_attribute ide_dev_attrs[]; +extern const struct attribute_group *ide_dev_groups[];extern struct bus_type ide_bus_type;extern struct class *ide_port_class;
Signature · 1 line
1.8.4.6.g82e253f.dirty
Re: [PATCH 1/8] ide: convert bus code to use dev_groups
From: Greg Kroah-Hartman <[email protected]>
Date: Mon, 7 Oct 2013 18:27:35 -0700
Quoted 11 lines
The
dev_attrsfield of structbus_typeis going away soon,dev_groupsshould be used instead. This converts the ide bus code to use the correct field.Cc David S. Miller <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
David, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
Yep, please take it, that works for me:
Greg Kroah-Hartman
maintainerPATCH 2/8 ipack: convert bus code to use dev_groups
In reply to Greg Kroah-HartmanThe dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the ipack bus code to use the correct field.
---
Samuel and Jens, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
drivers/ipack/ipack.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/ipack/ipack.c +15 -7
@@ -180,20 +180,28 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,ipack_device_attr (id_format,"0x%hhu\n" ); -static struct device_attribute ipack_dev_attrs[] = { -__ATTR_RO (id), -__ATTR_RO (id_device), -__ATTR_RO (id_format), -__ATTR_RO (id_vendor), -__ATTR_RO (modalias), +static DEVICE_ATTR_RO (id); +static DEVICE_ATTR_RO (id_device); +static DEVICE_ATTR_RO (id_format); +static DEVICE_ATTR_RO (id_vendor); +static DEVICE_ATTR_RO (modalias); + +static struct attribute *ipack_attrs[] = { + &dev_attr_id.attr, + &dev_attr_id_device.attr, + &dev_attr_id_format.attr, + &dev_attr_id_vendor.attr, + &dev_attr_modalias.attr, +NULL , }; +ATTRIBUTE_GROUPS (ipack);static struct bus_type ipack_bus_type = { .name ="ipack" , .probe = ipack_bus_probe, .match = ipack_bus_match, .remove = ipack_bus_remove, - .dev_attrs = ipack_dev_attrs, + .dev_groups = ipack_groups, .uevent = ipack_uevent, };
Signature · 1 line
1.8.4.6.g82e253f.dirty
Re: [PATCH 2/8] ipack: convert bus code to use dev_groups
Quoted 8 lines · Greg Kroah-Hartman
The
dev_attrsfield of structbus_typeis going away soon,dev_groupsshould be used instead. This converts the ipack bus code to use the correct field.Cc Samuel Iglesias Gonsalvez <[email protected]>Cc Jens Taprogge <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
Samuel and Jens, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
OK, you can take it through your driver-core tree.
Quoted 33 lines
drivers/ipack/ipack.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)drivers/ipack/ipack.c +14
-6@@ -180,20 +180,28 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,ipack_device_attr (id_format,"0x%hhu\n" ); -static struct device_attribute ipack_dev_attrs[] = { -__ATTR_RO (id), -__ATTR_RO (id_device), -__ATTR_RO (id_format), -__ATTR_RO (id_vendor), -__ATTR_RO (modalias), +static DEVICE_ATTR_RO (id); +static DEVICE_ATTR_RO (id_device); +static DEVICE_ATTR_RO (id_format); +static DEVICE_ATTR_RO (id_vendor); +static DEVICE_ATTR_RO (modalias); + +static struct attribute *ipack_attrs[] = { + &dev_attr_id.attr, + &dev_attr_id_device.attr, + &dev_attr_id_format.attr, + &dev_attr_id_vendor.attr, + &dev_attr_modalias.attr, +NULL , }; +ATTRIBUTE_GROUPS (ipack);
drivers/ipack/ipack.c static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, · line 207
Quoted 10 lines
drivers/ipack/ipack.c +1
-1static struct bus_type ipack_bus_type = { .name ="ipack" , .probe = ipack_bus_probe, .match = ipack_bus_match, .remove = ipack_bus_remove, - .dev_attrs = ipack_dev_attrs, + .dev_groups = ipack_groups, .uevent = ipack_uevent, };
Thanks,
Sam
Greg Kroah-Hartman
maintainerPATCH 3/8 input: gameport: convert bus code to use dev_groups
In reply to Greg Kroah-HartmanThe dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the gameport bus code to use the correct field.
---
Dmitry, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
drivers/input/gameport/gameport.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/input/gameport/gameport.c +10 -7
@@ -422,14 +422,15 @@ static struct gameport *gameport_get_pending_child(struct gameport *parent)* Gameport port operations */ -static ssize_t gameport_show_description (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t gameport_description_show (struct device *dev,struct device_attribute *attr,char *buf) {struct gameport *gameport =to_gameport_port (dev);return sprintf (buf,"%s\n" , gameport->name); } +static DEVICE_ATTR(description, S_IRUGO, gameport_description_show, NULL); -static ssize_t gameport_rebind_driver (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) +static ssize_t drvctl_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct gameport *gameport =to_gameport_port (dev);struct device_driver *drv;
@@ -457,12 +458,14 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attributreturn error ? error : count; } +static DEVICE_ATTR_WO (drvctl); -static struct device_attribute gameport_device_attrs[] = { -__ATTR (description,S_IRUGO , gameport_show_description,NULL ), -__ATTR (drvctl,S_IWUSR ,NULL , gameport_rebind_driver), - __ATTR_NULL +static struct attribute *gameport_device_attrs[] = { + &dev_attr_description.attr, + &dev_attr_drvctl.attr, +NULL , }; +ATTRIBUTE_GROUPS (gameport_device);static void gameport_release_port (struct device *dev) {
@@ -750,7 +753,7 @@ static int gameport_bus_match(struct device *dev, struct device_driver *drv)static struct bus_type gameport_bus = { .name ="gameport" , - .dev_attrs = gameport_device_attrs, + .dev_groups = gameport_device_groups, .drv_groups = gameport_driver_groups, .match = gameport_bus_match, .probe = gameport_driver_probe,
Signature · 1 line
1.8.4.6.g82e253f.dirty
Greg Kroah-Hartman
maintainerPATCH 4/8 spi: convert bus code to use dev_groups
In reply to Greg Kroah-HartmanThe dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the spi bus code to use the correct field.
---
Mark, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
drivers/spi/spi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/spi/spi.c +6 -4
@@ -58,11 +58,13 @@ modalias_show(struct device *dev, struct device_attribute *a, char *buf)return sprintf (buf,"%s%s\n" ,SPI_MODULE_PREFIX , spi->modalias); } +static DEVICE_ATTR_RO (modalias); -static struct device_attribute spi_dev_attrs[] = { -__ATTR_RO (modalias), - __ATTR_NULL, +static struct attribute *spi_dev_attrs[] = { + &dev_attr_modalias.attr, +NULL , }; +ATTRIBUTE_GROUPS (spi_dev);/* modalias support makes "modprobe $MODALIAS" new-style hotplug work, * and the sysfs version makes coldplug work too.
@@ -229,7 +231,7 @@ static const struct dev_pm_ops spi_pm = {struct bus_type spi_bus_type = { .name ="spi" , - .dev_attrs = spi_dev_attrs, + .dev_groups = spi_dev_groups, .match = spi_match_device, .uevent = spi_uevent, .pm = &spi_pm,
Signature · 1 line
1.8.4.6.g82e253f.dirty
Re: [PATCH 4/8] spi: convert bus code to use dev_groups
Quoted 3 lines · Greg Kroah-Hartman
The
dev_attrsfield of structbus_typeis going away soon,dev_groupsshould be used instead. This converts the spi bus code to use the correct field.
Applied, thanks.
Greg Kroah-Hartman
maintainerPATCH 5/8 virtio: convert bus code to use dev_groups
In reply to Greg Kroah-HartmanThe dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the virtio bus code to use the correct field.
---
Rusty and Michael, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
drivers/virtio/virtio.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/virtio/virtio.c +19 -8
@@ -13,18 +13,24 @@ static ssize_t device_show(struct device *_d,struct virtio_device *dev =dev_to_virtio (_d);return sprintf (buf,"0x%04x\n" , dev->id.device); } +static DEVICE_ATTR_RO (device); +static ssize_t vendor_show (struct device *_d,struct device_attribute *attr,char *buf) {struct virtio_device *dev =dev_to_virtio (_d);return sprintf (buf,"0x%04x\n" , dev->id.vendor); } +static DEVICE_ATTR_RO (vendor); +static ssize_t status_show (struct device *_d,struct device_attribute *attr,char *buf) {struct virtio_device *dev =dev_to_virtio (_d);return sprintf (buf,"0x%08x\n" , dev->config->get_status (dev)); } +static DEVICE_ATTR_RO (status); +static ssize_t modalias_show (struct device *_d,struct device_attribute *attr,char *buf) {
@@ -32,6 +38,8 @@ static ssize_t modalias_show(struct device *_d,return sprintf (buf,"virtio:d%08Xv%08X\n" , dev->id.device, dev->id.vendor); } +static DEVICE_ATTR_RO (modalias); +static ssize_t features_show (struct device *_d,struct device_attribute *attr,char *buf) {
@@ -47,14 +55,17 @@ static ssize_t features_show(struct device *_d, len +=sprintf (buf+len,"\n" );return len; } -static struct device_attribute virtio_dev_attrs[] = { -__ATTR_RO (device), -__ATTR_RO (vendor), -__ATTR_RO (status), -__ATTR_RO (modalias), -__ATTR_RO (features), - __ATTR_NULL +static DEVICE_ATTR_RO (features); + +static struct attribute *virtio_dev_attrs[] = { + &dev_attr_device.attr, + &dev_attr_vendor.attr, + &dev_attr_status.attr, + &dev_attr_modalias.attr, + &dev_attr_features.attr, +NULL , }; +ATTRIBUTE_GROUPS (virtio_dev);static inline int virtio_id_match (const struct virtio_device *dev,const struct virtio_device_id *id)
@@ -165,7 +176,7 @@ static int virtio_dev_remove(struct device *_d)static struct bus_type virtio_bus = { .name ="virtio" , .match = virtio_dev_match, - .dev_attrs = virtio_dev_attrs, + .dev_groups = virtio_dev_groups, .uevent = virtio_uevent, .probe = virtio_dev_probe, .remove = virtio_dev_remove,
Signature · 1 line
1.8.4.6.g82e253f.dirty
Greg Kroah-Hartman
maintainerPATCH 6/8 tifm: convert bus code to use dev_groups
In reply to Greg Kroah-HartmanThe dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the tifm bus code to use the correct field.
---
Alex, I can take this through my driver-core tree if you don't want to take it through yours, just let me know what works best for you.
drivers/misc/tifm_core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/misc/tifm_core.c +6 -4
@@ -145,15 +145,17 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);return sprintf (buf,"%x" , sock->type); } +static DEVICE_ATTR_RO (type); -static struct device_attribute tifm_dev_attrs[] = { -__ATTR (type,S_IRUGO , type_show,NULL ), - __ATTR_NULL +static struct attribute *tifm_dev_attrs[] = { + &dev_attr_type.attr, +NULL , }; +ATTRIBUTE_GROUPS (tifm_dev);static struct bus_type tifm_bus_type = { .name ="tifm" , - .dev_attrs = tifm_dev_attrs, + .dev_groups = tifm_dev_groups, .match = tifm_bus_match, .uevent = tifm_uevent, .probe = tifm_device_probe,
Signature · 1 line
1.8.4.6.g82e253f.dirty
Greg Kroah-Hartman
maintainerPATCH 7/8 memstick: convert bus code to use dev_groups
In reply to Greg Kroah-HartmanThe dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the memstick bus code to use the correct field.
--- drivers/memstick/core/memstick.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/memstick/core/memstick.c +9 -9
@@ -153,24 +153,24 @@ static ssize_t name##_show(struct device *dev, struct device_attribute *attr, \ struct memstick_dev *card = container_of(dev, struct memstick_dev, \ dev); \return sprintf (buf, format, card->id.name); \ -} +} \ +static DEVICE_ATTR_RO (name);MEMSTICK_ATTR (type,"%02X" );MEMSTICK_ATTR (category,"%02X" );MEMSTICK_ATTR (class,"%02X" ); -#define MEMSTICK_ATTR_RO (name) __ATTR(name, S_IRUGO, name##_show, NULL) - -static struct device_attribute memstick_dev_attrs[] = { -MEMSTICK_ATTR_RO (type), -MEMSTICK_ATTR_RO (category), -MEMSTICK_ATTR_RO (class), - __ATTR_NULL +static struct attribute *memstick_dev_attrs[] = { + &dev_attr_type.attr, + &dev_attr_category.attr, + &dev_attr_class.attr, +NULL , }; +ATTRIBUTE_GROUPS (memstick_dev);static struct bus_type memstick_bus_type = { .name ="memstick" , - .dev_attrs = memstick_dev_attrs, + .dev_groups = memstick_dev_groups, .match = memstick_bus_match, .uevent = memstick_uevent, .probe = memstick_device_probe,
Signature · 1 line
1.8.4.6.g82e253f.dirty
Greg Kroah-Hartman
maintainerPATCH 8/8 i2o: convert bus code to use dev_groups
In reply to Greg Kroah-HartmanThe dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the i2o bus code to use the correct field.
--- drivers/message/i2o/core.h | 2 +- drivers/message/i2o/device.c | 32 +++++++++++++++++++++----------- drivers/message/i2o/driver.c | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-)
drivers/message/i2o/core.h +1 -1
@@ -33,7 +33,7 @@ extern int __init i2o_pci_init(void); extern void __exit i2o_pci_exit(void);/* device */ -extern struct device_attribute i2o_device_attrs[]; +extern const struct attribute_group *i2o_device_groups[];extern void i2o_device_remove (struct i2o_device *);extern int i2o_device_parse_lct (struct i2o_controller *);
drivers/message/i2o/device.c +21 -11
@@ -138,45 +138,55 @@ static void i2o_device_release(struct device *dev) }/** -* i2o_device_show_class_id - Displays class id of I2O device +* class_id_show - Displays class id of I2O device * @dev: device of which the class id should be displayed * @attr: pointer to device attribute * @buf: buffer into which the class id should be printed * * Returns the number of bytes which are printed into the buffer. */ -static ssize_t i2o_device_show_class_id (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t class_id_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct i2o_device *i2o_dev =to_i2o_device (dev);sprintf (buf,"0x%03x\n" , i2o_dev->lct_data.class_id);return strlen (buf) +1 ; } +static DEVICE_ATTR_RO (class_id);/** -* i2o_device_show_tid - Displays TID of I2O device +* tid_show - Displays TID of I2O device * @dev: device of which the TID should be displayed * @attr: pointer to device attribute * @buf: buffer into which the TID should be printed * * Returns the number of bytes which are printed into the buffer. */ -static ssize_t i2o_device_show_tid (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t tid_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct i2o_device *i2o_dev =to_i2o_device (dev);sprintf (buf,"0x%03x\n" , i2o_dev->lct_data.tid);return strlen (buf) +1 ; } +static DEVICE_ATTR_RO (tid);/* I2O device attributes */ -struct device_attribute i2o_device_attrs[] = { -__ATTR (class_id,S_IRUGO , i2o_device_show_class_id,NULL ), -__ATTR (tid,S_IRUGO , i2o_device_show_tid,NULL ), - __ATTR_NULL +static struct attribute *i2o_device_attrs[] = { + &dev_attr_class_id.attr, + &dev_attr_tid.attr, +NULL , +}; + +static const struct attribute_group i2o_device_group = { + .attrs = i2o_device_attrs, +}; + +const struct attribute_group *i2o_device_groups[] = { + &i2o_device_group, +NULL , };/**
drivers/message/i2o/driver.c +1 -1
@@ -62,7 +62,7 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv)struct bus_type i2o_bus_type = { .name ="i2o" , .match = i2o_bus_match, - .dev_attrs = i2o_device_attrs + .dev_groups = i2o_device_groups, };/**
Signature · 1 line
1.8.4.6.g82e253f.dirty