Skip to content

Commit fb3fed7

Browse files
committed
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. Acked-by: David S. Miller <davem@davemloft.net> Cc: <linux-ide@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0017314 commit fb3fed7

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

‎drivers/ide/ide-sysfs.c‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,51 +25,68 @@ static ssize_t media_show(struct device *dev, struct device_attribute *attr,
2525
ide_drive_t *drive = to_ide_device(dev);
2626
return sprintf(buf, "%s\n", ide_media_string(drive));
2727
}
28+
static DEVICE_ATTR_RO(media);
2829

2930
static ssize_t drivename_show(struct device *dev, struct device_attribute *attr,
3031
char *buf)
3132
{
3233
ide_drive_t *drive = to_ide_device(dev);
3334
return sprintf(buf, "%s\n", drive->name);
3435
}
36+
static DEVICE_ATTR_RO(drivename);
3537

3638
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
3739
char *buf)
3840
{
3941
ide_drive_t *drive = to_ide_device(dev);
4042
return sprintf(buf, "ide:m-%s\n", ide_media_string(drive));
4143
}
44+
static DEVICE_ATTR_RO(modalias);
4245

4346
static ssize_t model_show(struct device *dev, struct device_attribute *attr,
4447
char *buf)
4548
{
4649
ide_drive_t *drive = to_ide_device(dev);
4750
return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_PROD]);
4851
}
52+
static DEVICE_ATTR_RO(model);
4953

5054
static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,
5155
char *buf)
5256
{
5357
ide_drive_t *drive = to_ide_device(dev);
5458
return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_FW_REV]);
5559
}
60+
static DEVICE_ATTR_RO(firmware);
5661

5762
static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
5863
char *buf)
5964
{
6065
ide_drive_t *drive = to_ide_device(dev);
6166
return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_SERNO]);
6267
}
68+
static DEVICE_ATTR(serial, 0400, serial_show, NULL);
69+
70+
static DEVICE_ATTR(unload_heads, 0644, ide_park_show, ide_park_store);
71+
72+
static struct attribute *ide_attrs[] = {
73+
&dev_attr_media.attr,
74+
&dev_attr_drivename.attr,
75+
&dev_attr_modalias.attr,
76+
&dev_attr_model.attr,
77+
&dev_attr_firmware.attr,
78+
&dev_attr_serial.attr,
79+
&dev_attr_unload_heads.attr,
80+
NULL,
81+
};
82+
83+
static const struct attribute_group ide_attr_group = {
84+
.attrs = ide_attrs,
85+
};
6386

64-
struct device_attribute ide_dev_attrs[] = {
65-
__ATTR_RO(media),
66-
__ATTR_RO(drivename),
67-
__ATTR_RO(modalias),
68-
__ATTR_RO(model),
69-
__ATTR_RO(firmware),
70-
__ATTR(serial, 0400, serial_show, NULL),
71-
__ATTR(unload_heads, 0644, ide_park_show, ide_park_store),
72-
__ATTR_NULL
87+
const struct attribute_group *ide_dev_groups[] = {
88+
&ide_attr_group,
89+
NULL,
7390
};
7491

7592
static ssize_t store_delete_devices(struct device *portdev,

‎drivers/ide/ide.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct bus_type ide_bus_type = {
158158
.probe = generic_ide_probe,
159159
.remove = generic_ide_remove,
160160
.shutdown = generic_ide_shutdown,
161-
.dev_attrs = ide_dev_attrs,
161+
.dev_groups = ide_dev_groups,
162162
.suspend = generic_ide_suspend,
163163
.resume = generic_ide_resume,
164164
};

‎include/linux/ide.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ static inline void ide_set_max_pio(ide_drive_t *drive)
15141514

15151515
char *ide_media_string(ide_drive_t *);
15161516

1517-
extern struct device_attribute ide_dev_attrs[];
1517+
extern const struct attribute_group *ide_dev_groups[];
15181518
extern struct bus_type ide_bus_type;
15191519
extern struct class *ide_port_class;
15201520

0 commit comments

Comments
 (0)