aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/aoe
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-05-21 16:08:01 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:36 -0500
commitedfaa7c36574f1bf09c65ad602412db9da5f96bf (patch)
treed591b80ff9229e4845e41d68e2f4c5aadb017027 /drivers/block/aoe
parent09f82ea92822a7bbb7e816508abbda47ed54a77f (diff)
Driver core: convert block from raw kobjects to core devices
This moves the block devices to /sys/class/block. It will create a flat list of all block devices, with the disks and partitions in one directory. For compatibility /sys/block is created and contains symlinks to the disks. /sys/class/block |-- sda -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda |-- sda1 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1 |-- sda10 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10 |-- sda5 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5 |-- sda6 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6 |-- sda7 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7 |-- sda8 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8 |-- sda9 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9 `-- sr0 -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0 /sys/block/ |-- sda -> ../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda `-- sr0 -> ../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0 Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/block/aoe')
-rw-r--r--drivers/block/aoe/aoeblk.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index ad00b3d94711..826d12381e21 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -15,8 +15,10 @@
15 15
16static struct kmem_cache *buf_pool_cache; 16static struct kmem_cache *buf_pool_cache;
17 17
18static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) 18static ssize_t aoedisk_show_state(struct device *dev,
19 struct device_attribute *attr, char *page)
19{ 20{
21 struct gendisk *disk = dev_to_disk(dev);
20 struct aoedev *d = disk->private_data; 22 struct aoedev *d = disk->private_data;
21 23
22 return snprintf(page, PAGE_SIZE, 24 return snprintf(page, PAGE_SIZE,
@@ -26,50 +28,47 @@ static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
26 (d->nopen && !(d->flags & DEVFL_UP)) ? ",closewait" : ""); 28 (d->nopen && !(d->flags & DEVFL_UP)) ? ",closewait" : "");
27 /* I'd rather see nopen exported so we can ditch closewait */ 29 /* I'd rather see nopen exported so we can ditch closewait */
28} 30}
29static ssize_t aoedisk_show_mac(struct gendisk * disk, char *page) 31static ssize_t aoedisk_show_mac(struct device *dev,
32 struct device_attribute *attr, char *page)
30{ 33{
34 struct gendisk *disk = dev_to_disk(dev);
31 struct aoedev *d = disk->private_data; 35 struct aoedev *d = disk->private_data;
32 36
33 return snprintf(page, PAGE_SIZE, "%012llx\n", 37 return snprintf(page, PAGE_SIZE, "%012llx\n",
34 (unsigned long long)mac_addr(d->addr)); 38 (unsigned long long)mac_addr(d->addr));
35} 39}
36static ssize_t aoedisk_show_netif(struct gendisk * disk, char *page) 40static ssize_t aoedisk_show_netif(struct device *dev,
41 struct device_attribute *attr, char *page)
37{ 42{
43 struct gendisk *disk = dev_to_disk(dev);
38 struct aoedev *d = disk->private_data; 44 struct aoedev *d = disk->private_data;
39 45
40 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name); 46 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name);
41} 47}
42/* firmware version */ 48/* firmware version */
43static ssize_t aoedisk_show_fwver(struct gendisk * disk, char *page) 49static ssize_t aoedisk_show_fwver(struct device *dev,
50 struct device_attribute *attr, char *page)
44{ 51{
52 struct gendisk *disk = dev_to_disk(dev);
45 struct aoedev *d = disk->private_data; 53 struct aoedev *d = disk->private_data;
46 54
47 return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver); 55 return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver);
48} 56}
49 57
50static struct disk_attribute disk_attr_state = { 58static DEVICE_ATTR(state, S_IRUGO, aoedisk_show_state, NULL);
51 .attr = {.name = "state", .mode = S_IRUGO }, 59static DEVICE_ATTR(mac, S_IRUGO, aoedisk_show_mac, NULL);
52 .show = aoedisk_show_state 60static DEVICE_ATTR(netif, S_IRUGO, aoedisk_show_netif, NULL);
53}; 61static struct device_attribute dev_attr_firmware_version = {
54static struct disk_attribute disk_attr_mac = { 62 .attr = { .name = "firmware-version", .mode = S_IRUGO, .owner = THIS_MODULE },
55 .attr = {.name = "mac", .mode = S_IRUGO }, 63 .show = aoedisk_show_fwver,
56 .show = aoedisk_show_mac
57};
58static struct disk_attribute disk_attr_netif = {
59 .attr = {.name = "netif", .mode = S_IRUGO },
60 .show = aoedisk_show_netif
61};
62static struct disk_attribute disk_attr_fwver = {
63 .attr = {.name = "firmware-version", .mode = S_IRUGO },
64 .show = aoedisk_show_fwver
65}; 64};
66 65
67static struct attribute *aoe_attrs[] = { 66static struct attribute *aoe_attrs[] = {
68 &disk_attr_state.attr, 67 &dev_attr_state.attr,
69 &disk_attr_mac.attr, 68 &dev_attr_mac.attr,
70 &disk_attr_netif.attr, 69 &dev_attr_netif.attr,
71 &disk_attr_fwver.attr, 70 &dev_attr_firmware_version.attr,
72 NULL 71 NULL,
73}; 72};
74 73
75static const struct attribute_group attr_group = { 74static const struct attribute_group attr_group = {
@@ -79,12 +78,12 @@ static const struct attribute_group attr_group = {
79static int 78static int
80aoedisk_add_sysfs(struct aoedev *d) 79aoedisk_add_sysfs(struct aoedev *d)
81{ 80{
82 return sysfs_create_group(&d->gd->kobj, &attr_group); 81 return sysfs_create_group(&d->gd->dev.kobj, &attr_group);
83} 82}
84void 83void
85aoedisk_rm_sysfs(struct aoedev *d) 84aoedisk_rm_sysfs(struct aoedev *d)
86{ 85{
87 sysfs_remove_group(&d->gd->kobj, &attr_group); 86 sysfs_remove_group(&d->gd->dev.kobj, &attr_group);
88} 87}
89 88
90static int 89static int