From: kaf24@firebug.cl.cam.ac.uk Date: Fri, 30 Jun 2006 08:43:08 +0000 (+0100) Subject: [BLK] back: Clean up sysfs-interfacing code to use VBD_SHOW macro where possible. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15912^2~26 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=33c0901c24649d7b8f660064738a2d24b2c97320;p=xen.git [BLK] back: Clean up sysfs-interfacing code to use VBD_SHOW macro where possible. Signed-off-by: Satoshi UCHIDA --- diff --git a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c index 406adf1000..f796c2f2c8 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -76,8 +76,6 @@ static void update_blkif_status(blkif_t *blkif) * sysfs interface for VBD I/O requests */ -#ifdef CONFIG_SYSFS - #define VBD_SHOW(name, format, args...) \ static ssize_t show_##name(struct device *_dev, \ struct device_attribute *attr, \ @@ -106,56 +104,39 @@ static struct attribute_group vbdstat_group = { .attrs = vbdstat_attrs, }; +VBD_SHOW(physical_device, "%x:%x\n", be->major, be->minor); +VBD_SHOW(mode, "%s\n", be->mode); + int xenvbd_sysfs_addif(struct xenbus_device *dev) { int error = 0; - error = sysfs_create_group(&dev->dev.kobj, - &vbdstat_group); - if (error) - goto fail; - - return 0; - -fail: - sysfs_remove_group(&dev->dev.kobj, - &vbdstat_group); - return error; -} - -void xenvbd_sysfs_delif(struct xenbus_device *dev) -{ - sysfs_remove_group(&dev->dev.kobj, - &vbdstat_group); -} + error = device_create_file(&dev->dev, &dev_attr_physical_device); + if (error) + goto fail1; -#else + error = device_create_file(&dev->dev, &dev_attr_mode); + if (error) + goto fail2; -#define xenvbd_sysfs_addif(dev) (0) -#define xenvbd_sysfs_delif(dev) ((void)0) + error = sysfs_create_group(&dev->dev.kobj, &vbdstat_group); + if (error) + goto fail3; -#endif /* CONFIG_SYSFS */ + return 0; -static ssize_t show_physical_device(struct device *_dev, - struct device_attribute *attr, char *buf) -{ - struct xenbus_device *dev = to_xenbus_device(_dev); - struct backend_info *be = dev->dev.driver_data; - return sprintf(buf, "%x:%x\n", be->major, be->minor); +fail3: sysfs_remove_group(&dev->dev.kobj, &vbdstat_group); +fail2: device_remove_file(&dev->dev, &dev_attr_mode); +fail1: device_remove_file(&dev->dev, &dev_attr_physical_device); + return error; } -DEVICE_ATTR(physical_device, S_IRUSR | S_IRGRP | S_IROTH, - show_physical_device, NULL); - -static ssize_t show_mode(struct device *_dev, struct device_attribute *attr, - char *buf) +void xenvbd_sysfs_delif(struct xenbus_device *dev) { - struct xenbus_device *dev = to_xenbus_device(_dev); - struct backend_info *be = dev->dev.driver_data; - return sprintf(buf, "%s\n", be->mode); + sysfs_remove_group(&dev->dev.kobj, &vbdstat_group); + device_remove_file(&dev->dev, &dev_attr_mode); + device_remove_file(&dev->dev, &dev_attr_physical_device); } -DEVICE_ATTR(mode, S_IRUSR | S_IRGRP | S_IROTH, show_mode, NULL); - static int blkback_remove(struct xenbus_device *dev) { @@ -176,8 +157,6 @@ static int blkback_remove(struct xenbus_device *dev) be->blkif = NULL; } - device_remove_file(&dev->dev, &dev_attr_physical_device); - device_remove_file(&dev->dev, &dev_attr_mode); xenvbd_sysfs_delif(dev); kfree(be); @@ -299,8 +278,6 @@ static void backend_changed(struct xenbus_watch *watch, return; } - device_create_file(&dev->dev, &dev_attr_physical_device); - device_create_file(&dev->dev, &dev_attr_mode); xenvbd_sysfs_addif(dev); /* We're potentially connected now */