From: "Satoshi Uchida" Subject: [PATCH][BLKBACK] Clean code by VBD_SHOW macro in xenbus.c Date: Fri, 30 Jun 2006 14:05:59 +0900 Message-ID: <000901c69c02$e0a07e80$4c87380a@ad.spf.cl.nec.co.jp> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_000A_01C69C4E.50882680" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_000A_01C69C4E.50882680 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This patch is cleaning code in xenbus.c by VBD_SHOW macro. VBD_SHOW macro can be applied show functions with corresponded to=20 'physical_devices' and 'mode' attributes. And corresponding 'device_create_file' and 'device_remove_file' function = can be inserted into 'xenvbd_sysfs_addif' and 'xenvbd_sysfs_delif functions' too. So, this patch transfer code based on above reasons. Thereby, code will be clear. Thanks, Satoshi UCHIDA ------=_NextPart_000_000A_01C69C4E.50882680 Content-Type: application/octet-stream; name="relocate_VBD_SHOW.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="relocate_VBD_SHOW.patch" # HG changeset patch # User Satoshi UCHIDA # Node ID a5bed4c2cfa4434db7fa92bc64e419d539791235 # Parent ef33b7a4b49dddfc5b03df9021580b77f135bc4f [BLKBACK]Simplfy and Clean program code by VBD_SHOW macro. VBD_SHOW can use for 'physical_device' and 'mode' attributes in = xenbus.c and so is applied at each location. And, move device_create_file and device_remove_file function into=20 xenvbd_sysfs_addif and xenvbd_sysfs_delif respectively. Signed-off-by: Satoshi UCHIDA diff -r ef33b7a4b49d -r a5bed4c2cfa4 = linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Jun 28 = 16:47:58 2006 +0900 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Jun 28 = 17:52:29 2006 +0900 @@ -115,50 +115,46 @@ static struct attribute_group vbdstat_gr .attrs =3D vbdstat_attrs, }; =20 + +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 =3D 0; =09 - error =3D sysfs_create_group(&dev->dev.kobj, - &vbdstat_group); + error =3D device_create_file(&dev->dev, &dev_attr_physical_device); if (error) - goto fail; + goto fail1; + + error =3D device_create_file(&dev->dev, &dev_attr_mode); + if (error) + goto fail2; + + error =3D sysfs_create_group(&dev->dev.kobj, &vbdstat_group); + if (error) + goto fail3; =09 return 0; =09 -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; } =20 void xenvbd_sysfs_delif(struct xenbus_device *dev) { - sysfs_remove_group(&dev->dev.kobj, - &vbdstat_group); + 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); } =20 #endif /* CONFIG_SYSFS */ - -static ssize_t show_physical_device(struct device *_dev, - struct device_attribute *attr, char *buf) -{ - struct xenbus_device *dev =3D to_xenbus_device(_dev); - struct backend_info *be =3D 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 =3D to_xenbus_device(_dev); - struct backend_info *be =3D dev->dev.driver_data; - return sprintf(buf, "%s\n", be->mode); -} -DEVICE_ATTR(mode, S_IRUSR | S_IRGRP | S_IROTH, show_mode, NULL); =20 =20 static int blkback_remove(struct xenbus_device *dev) @@ -179,8 +175,6 @@ static int blkback_remove(struct xenbus_ be->blkif =3D NULL; } =20 - device_remove_file(&dev->dev, &dev_attr_physical_device); - device_remove_file(&dev->dev, &dev_attr_mode); xenvbd_sysfs_delif(dev); =20 kfree(be); @@ -302,8 +296,6 @@ static void backend_changed(struct xenbu return; } =20 - device_create_file(&dev->dev, &dev_attr_physical_device); - device_create_file(&dev->dev, &dev_attr_mode); xenvbd_sysfs_addif(dev); =20 /* We're potentially connected now */ ------=_NextPart_000_000A_01C69C4E.50882680 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_NextPart_000_000A_01C69C4E.50882680--