GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / ide / ide-sysfs.c
blob883ffacaf45ac4bbd67ca8fe1f9cf576149665ad
1 #include <linux/kernel.h>
2 #include <linux/ide.h>
4 char *ide_media_string(ide_drive_t *drive)
6 switch (drive->media) {
7 case ide_disk:
8 return "disk";
9 case ide_cdrom:
10 return "cdrom";
11 case ide_tape:
12 return "tape";
13 case ide_floppy:
14 return "floppy";
15 case ide_optical:
16 return "optical";
17 default:
18 return "UNKNOWN";
22 static ssize_t media_show(struct device *dev, struct device_attribute *attr,
23 char *buf)
25 ide_drive_t *drive = to_ide_device(dev);
26 return sprintf(buf, "%s\n", ide_media_string(drive));
29 static ssize_t drivename_show(struct device *dev, struct device_attribute *attr,
30 char *buf)
32 ide_drive_t *drive = to_ide_device(dev);
33 return sprintf(buf, "%s\n", drive->name);
36 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
37 char *buf)
39 ide_drive_t *drive = to_ide_device(dev);
40 return sprintf(buf, "ide:m-%s\n", ide_media_string(drive));
43 static ssize_t model_show(struct device *dev, struct device_attribute *attr,
44 char *buf)
46 ide_drive_t *drive = to_ide_device(dev);
47 return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_PROD]);
50 static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,
51 char *buf)
53 ide_drive_t *drive = to_ide_device(dev);
54 return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_FW_REV]);
57 static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
58 char *buf)
60 ide_drive_t *drive = to_ide_device(dev);
61 return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_SERNO]);
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
75 static ssize_t store_delete_devices(struct device *portdev,
76 struct device_attribute *attr,
77 const char *buf, size_t n)
79 ide_hwif_t *hwif = dev_get_drvdata(portdev);
81 if (strncmp(buf, "1", n))
82 return -EINVAL;
84 ide_port_unregister_devices(hwif);
86 return n;
89 static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices);
91 static ssize_t store_scan(struct device *portdev,
92 struct device_attribute *attr,
93 const char *buf, size_t n)
95 ide_hwif_t *hwif = dev_get_drvdata(portdev);
97 if (strncmp(buf, "1", n))
98 return -EINVAL;
100 ide_port_unregister_devices(hwif);
101 ide_port_scan(hwif);
103 return n;
106 static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
108 static struct device_attribute *ide_port_attrs[] = {
109 &dev_attr_delete_devices,
110 &dev_attr_scan,
111 NULL
114 int ide_sysfs_register_port(ide_hwif_t *hwif)
116 int i, uninitialized_var(rc);
118 for (i = 0; ide_port_attrs[i]; i++) {
119 rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
120 if (rc)
121 break;
124 return rc;