From ab88eb58c7a56ded2fd3ec4b9184075ff415cad3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 11 Dec 2014 17:10:59 -0500 Subject: [PATCH] greybus: interface_block: move sysfs files into the interface_block.c file No need to keep these out in sysfs.c, move them into the interface_block.c file so that we can see them easier, and remove some variable definitions by taking advantage of the attribute group macro. Reviewed-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/Makefile | 1 - drivers/staging/greybus/greybus.h | 1 - drivers/staging/greybus/interface_block.c | 32 ++++++++++++++++-- drivers/staging/greybus/sysfs.c | 56 ------------------------------- 4 files changed, 30 insertions(+), 60 deletions(-) delete mode 100644 drivers/staging/greybus/sysfs.c diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile index 41186b7..29aa4d6 100644 --- a/drivers/staging/greybus/Makefile +++ b/drivers/staging/greybus/Makefile @@ -1,5 +1,4 @@ greybus-y := core.o \ - sysfs.o \ debugfs.o \ ap.o \ manifest.o \ diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index 632b1cd..b32dd61 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -167,7 +167,6 @@ int gb_debugfs_init(void); void gb_debugfs_cleanup(void); extern struct bus_type greybus_bus_type; -extern const struct attribute_group *greybus_interface_block_groups[]; int gb_uart_device_init(struct gb_connection *connection); void gb_uart_device_exit(struct gb_connection *connection); diff --git a/drivers/staging/greybus/interface_block.c b/drivers/staging/greybus/interface_block.c index 7b18f48..3f173ae 100644 --- a/drivers/staging/greybus/interface_block.c +++ b/drivers/staging/greybus/interface_block.c @@ -1,5 +1,5 @@ /* - * Greybus modules + * Greybus interface block code * * Copyright 2014 Google Inc. * @@ -8,6 +8,34 @@ #include "greybus.h" +/* interface block sysfs attributes */ +#define gb_ib_attr(field, type) \ +static ssize_t field##_show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct gb_interface_block *gb_ib = to_gb_interface_block(dev); \ + return sprintf(buf, "%"#type"\n", gb_ib->field); \ +} \ +static DEVICE_ATTR_RO(field) + +gb_ib_attr(vendor, x); +gb_ib_attr(product, x); +gb_ib_attr(unique_id, llX); +gb_ib_attr(vendor_string, s); +gb_ib_attr(product_string, s); + +static struct attribute *interface_block_attrs[] = { + &dev_attr_vendor.attr, + &dev_attr_product.attr, + &dev_attr_unique_id.attr, + &dev_attr_vendor_string.attr, + &dev_attr_product_string.attr, + NULL, +}; +ATTRIBUTE_GROUPS(interface_block); + + /* XXX This could be per-host device */ static DEFINE_SPINLOCK(gb_modules_lock); @@ -101,7 +129,7 @@ static struct gb_interface_block *gb_ib_create(struct greybus_host_device *hd, gb_ib->dev.parent = hd->parent; gb_ib->dev.bus = &greybus_bus_type; gb_ib->dev.type = &greybus_interface_block_type; - gb_ib->dev.groups = greybus_interface_block_groups; + gb_ib->dev.groups = interface_block_groups; gb_ib->dev.dma_mask = hd->parent->dma_mask; device_initialize(&gb_ib->dev); dev_set_name(&gb_ib->dev, "%d", module_id); diff --git a/drivers/staging/greybus/sysfs.c b/drivers/staging/greybus/sysfs.c deleted file mode 100644 index ae44c89..0000000 --- a/drivers/staging/greybus/sysfs.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Greybus sysfs file functions - * - * Copyright 2014 Google Inc. - * - * Released under the GPLv2 only. - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include - -#include "greybus.h" -#include "kernel_ver.h" - -/* Module fields */ -#define gb_ib_attr(field, type) \ -static ssize_t field##_show(struct device *dev, \ - struct device_attribute *attr, \ - char *buf) \ -{ \ - struct gb_interface_block *gb_ib = to_gb_interface_block(dev); \ - return sprintf(buf, "%"#type"\n", gb_ib->field); \ -} \ -static DEVICE_ATTR_RO(field) - -gb_ib_attr(vendor, x); -gb_ib_attr(product, x); -gb_ib_attr(unique_id, llX); -gb_ib_attr(vendor_string, s); -gb_ib_attr(product_string, s); - -static struct attribute *interface_block_attrs[] = { - &dev_attr_vendor.attr, - &dev_attr_product.attr, - &dev_attr_unique_id.attr, - &dev_attr_vendor_string.attr, - &dev_attr_product_string.attr, - NULL, -}; - -static struct attribute_group interface_block_attr_grp = { - .attrs = interface_block_attrs, -}; - -const struct attribute_group *greybus_interface_block_groups[] = { - &interface_block_attr_grp, - NULL, -}; - -- 2.7.4