WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [BLK] back: Clean up sysfs-interfacing co

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [BLK] back: Clean up sysfs-interfacing code to use VBD_SHOW macro where possible.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Jun 2006 15:40:42 +0000
Delivery-date: Fri, 30 Jun 2006 08:45:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 5fc6d83f43f78682a8e2543f4dce0a7cbd8e33b8
# Parent  85b092b4567d06b1aeffc87baae6fdb4bec51387
[BLK] back: Clean up sysfs-interfacing code to use VBD_SHOW macro where 
possible.
Signed-off-by: Satoshi UCHIDA <s-uchida@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c |   67 +++++++---------------
 1 files changed, 22 insertions(+), 45 deletions(-)

diff -r 85b092b4567d -r 5fc6d83f43f7 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Fri Jun 30 09:25:42 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Fri Jun 30 09:43:08 
2006 +0100
@@ -75,8 +75,6 @@ static void update_blkif_status(blkif_t 
 /****************************************************************
  *  sysfs interface for VBD I/O requests
  */
-
-#ifdef CONFIG_SYSFS
 
 #define VBD_SHOW(name, format, args...)                                        
\
        static ssize_t show_##name(struct device *_dev,                 \
@@ -106,56 +104,39 @@ static struct attribute_group vbdstat_gr
        .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);
+       error = device_create_file(&dev->dev, &dev_attr_physical_device);
+       if (error)
+               goto fail1;
+
+       error = device_create_file(&dev->dev, &dev_attr_mode);
        if (error)
-               goto fail;
-       
+               goto fail2;
+
+       error = sysfs_create_group(&dev->dev.kobj, &vbdstat_group);
+       if (error)
+               goto fail3;
+
        return 0;
-       
-fail:
-       sysfs_remove_group(&dev->dev.kobj,
-                          &vbdstat_group);
+
+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;
 }
 
 void xenvbd_sysfs_delif(struct xenbus_device *dev)
 {
-       sysfs_remove_group(&dev->dev.kobj,
-                          &vbdstat_group);
-}
-
-#else
-
-#define xenvbd_sysfs_addif(dev) (0)
-#define xenvbd_sysfs_delif(dev) ((void)0)
-
-#endif /* CONFIG_SYSFS */
-
-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);
-}
-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)
-{
-       struct xenbus_device *dev = to_xenbus_device(_dev);
-       struct backend_info *be = dev->dev.driver_data;
-       return sprintf(buf, "%s\n", be->mode);
-}
-DEVICE_ATTR(mode, S_IRUSR | S_IRGRP | S_IROTH, show_mode, NULL);
-
+       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);
+}
 
 static int blkback_remove(struct xenbus_device *dev)
 {
@@ -176,8 +157,6 @@ static int blkback_remove(struct xenbus_
                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 xenbu
                        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 */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [BLK] back: Clean up sysfs-interfacing code to use VBD_SHOW macro where possible., Xen patchbot-unstable <=