1 #include <linux/kernel.h>
4 char *ide_media_string(ide_drive_t *drive)
6 switch (drive->media) {
22 static ssize_t media_show(struct device *dev, struct device_attribute *attr,
25 ide_drive_t *drive = to_ide_device(dev);
26 return sprintf(buf, "%s\n", ide_media_string(drive));
28 static DEVICE_ATTR_RO(media);
30 static ssize_t drivename_show(struct device *dev, struct device_attribute *attr,
33 ide_drive_t *drive = to_ide_device(dev);
34 return sprintf(buf, "%s\n", drive->name);
36 static DEVICE_ATTR_RO(drivename);
38 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
41 ide_drive_t *drive = to_ide_device(dev);
42 return sprintf(buf, "ide:m-%s\n", ide_media_string(drive));
44 static DEVICE_ATTR_RO(modalias);
46 static ssize_t model_show(struct device *dev, struct device_attribute *attr,
49 ide_drive_t *drive = to_ide_device(dev);
50 return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_PROD]);
52 static DEVICE_ATTR_RO(model);
54 static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,
57 ide_drive_t *drive = to_ide_device(dev);
58 return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_FW_REV]);
60 static DEVICE_ATTR_RO(firmware);
62 static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
65 ide_drive_t *drive = to_ide_device(dev);
66 return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_SERNO]);
68 static DEVICE_ATTR(serial, 0400, serial_show, NULL);
70 static DEVICE_ATTR(unload_heads, 0644, ide_park_show, ide_park_store);
72 static struct attribute *ide_attrs[] = {
74 &dev_attr_drivename.attr,
75 &dev_attr_modalias.attr,
77 &dev_attr_firmware.attr,
78 &dev_attr_serial.attr,
79 &dev_attr_unload_heads.attr,
83 static const struct attribute_group ide_attr_group = {
87 const struct attribute_group *ide_dev_groups[] = {
92 static ssize_t store_delete_devices(struct device *portdev,
93 struct device_attribute *attr,
94 const char *buf, size_t n)
96 ide_hwif_t *hwif = dev_get_drvdata(portdev);
98 if (strncmp(buf, "1", n))
101 ide_port_unregister_devices(hwif);
106 static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices);
108 static ssize_t store_scan(struct device *portdev,
109 struct device_attribute *attr,
110 const char *buf, size_t n)
112 ide_hwif_t *hwif = dev_get_drvdata(portdev);
114 if (strncmp(buf, "1", n))
117 ide_port_unregister_devices(hwif);
123 static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
125 static struct device_attribute *ide_port_attrs[] = {
126 &dev_attr_delete_devices,
131 int ide_sysfs_register_port(ide_hwif_t *hwif)
133 int i, uninitialized_var(rc);
135 for (i = 0; ide_port_attrs[i]; i++) {
136 rc = device_create_file(hwif->portdev, ide_port_attrs[i]);