Blame view
drivers/ide/ide-sysfs.c
3.18 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
ebdab07da ide: move sysfs s... |
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#include <linux/kernel.h> #include <linux/ide.h> char *ide_media_string(ide_drive_t *drive) { switch (drive->media) { case ide_disk: return "disk"; case ide_cdrom: return "cdrom"; case ide_tape: return "tape"; case ide_floppy: return "floppy"; case ide_optical: return "optical"; default: return "UNKNOWN"; } } static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf) { ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s ", ide_media_string(drive)); } |
fb3fed792 ide: convert bus ... |
30 |
static DEVICE_ATTR_RO(media); |
ebdab07da ide: move sysfs s... |
31 32 33 34 35 36 37 38 |
static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf) { ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s ", drive->name); } |
fb3fed792 ide: convert bus ... |
39 |
static DEVICE_ATTR_RO(drivename); |
ebdab07da ide: move sysfs s... |
40 41 42 43 44 45 46 47 |
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "ide:m-%s ", ide_media_string(drive)); } |
fb3fed792 ide: convert bus ... |
48 |
static DEVICE_ATTR_RO(modalias); |
ebdab07da ide: move sysfs s... |
49 50 51 52 53 54 55 56 |
static ssize_t model_show(struct device *dev, struct device_attribute *attr, char *buf) { ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s ", (char *)&drive->id[ATA_ID_PROD]); } |
fb3fed792 ide: convert bus ... |
57 |
static DEVICE_ATTR_RO(model); |
ebdab07da ide: move sysfs s... |
58 59 60 61 62 63 64 65 |
static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, char *buf) { ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s ", (char *)&drive->id[ATA_ID_FW_REV]); } |
fb3fed792 ide: convert bus ... |
66 |
static DEVICE_ATTR_RO(firmware); |
ebdab07da ide: move sysfs s... |
67 68 69 70 71 72 73 74 |
static ssize_t serial_show(struct device *dev, struct device_attribute *attr, char *buf) { ide_drive_t *drive = to_ide_device(dev); return sprintf(buf, "%s ", (char *)&drive->id[ATA_ID_SERNO]); } |
fb3fed792 ide: convert bus ... |
75 |
static DEVICE_ATTR(serial, 0400, serial_show, NULL); |
ebdab07da ide: move sysfs s... |
76 |
|
fb3fed792 ide: convert bus ... |
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
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, }; const struct attribute_group *ide_dev_groups[] = { &ide_attr_group, NULL, |
ebdab07da ide: move sysfs s... |
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
}; static ssize_t store_delete_devices(struct device *portdev, struct device_attribute *attr, const char *buf, size_t n) { ide_hwif_t *hwif = dev_get_drvdata(portdev); if (strncmp(buf, "1", n)) return -EINVAL; ide_port_unregister_devices(hwif); return n; }; static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices); static ssize_t store_scan(struct device *portdev, struct device_attribute *attr, const char *buf, size_t n) { ide_hwif_t *hwif = dev_get_drvdata(portdev); if (strncmp(buf, "1", n)) return -EINVAL; ide_port_unregister_devices(hwif); ide_port_scan(hwif); return n; }; static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); static struct device_attribute *ide_port_attrs[] = { &dev_attr_delete_devices, &dev_attr_scan, NULL }; int ide_sysfs_register_port(ide_hwif_t *hwif) { |
3f649ab72 treewide: Remove ... |
140 |
int i, rc; |
ebdab07da ide: move sysfs s... |
141 142 143 144 145 146 147 148 149 |
for (i = 0; ide_port_attrs[i]; i++) { rc = device_create_file(hwif->portdev, ide_port_attrs[i]); if (rc) break; } return rc; } |