[PATCH 028/141] staging: unisys: unify businst attributes into visorbus_main.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Prarit Bhargava <prarit@xxxxxxxxxx>

The code in businst_attr.[ch] only creates sysfs files and is called
only in visorbus_main.c.  This code should be unified into
visorbus_main.c.  There are some functions that have been made static.

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>
Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx>
---
 drivers/staging/unisys/visorbus/Makefile        |   2 +-
 drivers/staging/unisys/visorbus/businst_attr.c  | 103 ------------------------
 drivers/staging/unisys/visorbus/businst_attr.h  |  40 ---------
 drivers/staging/unisys/visorbus/visorbus_main.c |  97 +++++++++++++++++++++-
 4 files changed, 97 insertions(+), 145 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorbus/businst_attr.c
 delete mode 100644 drivers/staging/unisys/visorbus/businst_attr.h

diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index 20d87da..e1b667d 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 
-visorbus-y := visorbus_main.o devmajorminor_attr.o businst_attr.o channel_attr.o
+visorbus-y := visorbus_main.o devmajorminor_attr.o channel_attr.o
 visorbus-y	+= visorchannel_funcs.o
 
 ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorbus/businst_attr.c b/drivers/staging/unisys/visorbus/businst_attr.c
deleted file mode 100644
index b3fea9d..0000000
--- a/drivers/staging/unisys/visorbus/businst_attr.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* businst_attr.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*   This is actually something they forgot to put in the kernel.
- *   struct bus_type in the kernel SHOULD have a "busses" member, which
- *   should be treated similarly to the "devices" and "drivers" members.
- *   There SHOULD be:
- *   - a "businst_attribute" analogous to the existing "bus_attribute"
- *   - a "businst_create_file" and "businst_remove_file" analogous to the
- *     existing "bus_create_file" and "bus_remove_file".
- *   That's what I created businst.c and businst.h to do.
- *
- *   We want to add the "busses" sub-tree in sysfs, where we will house the
- *   names and properties of each bus instance:
- *
- *       /sys/bus/<bustypename>/
- *           version
- *           devices
- *               <devname1> --> /sys/devices/<businstancename><devname1>
- *               <devname2> --> /sys/devices/<businstancename><devname2>
- *           drivers
- *               <driverinstancename1>
- *                   <driverinstance1property1>
- *                   <driverinstance1property2>
- *                   ...
- *               <driverinstancename2>
- *                   <driverinstance2property1>
- *                   <driverinstance2property2>
- *                   ...
- *   >>      busses
- *   >>          <businstancename1>
- *   >>              <businstance1property1>
- *   >>              <businstance1property2>
- *   >>              ...
- *   >>          <businstancename2>
- *   >>              <businstance2property1>
- *   >>              <businstance2property2>
- *   >>              ...
- *
- *   I considered adding bus instance properties under
- *   /sys/devices/<businstancename>.  But I thought there may be existing
- *   notions that ONLY device sub-trees should live under
- *   /sys/devices/<businstancename>.  So I stayed out of there.
- *
- */
-
-#include "businst_attr.h"
-
-#define to_businst_attr(_attr) \
-	container_of(_attr, struct businst_attribute, attr)
-#define to_visorbus_devdata(obj) \
-	container_of(obj, struct visorbus_devdata, kobj)
-#define CURRENT_FILE_PC VISOR_BUS_PC_businst_attr_c
-
-ssize_t businst_attr_show(struct kobject *kobj, struct attribute *attr,
-			  char *buf)
-{
-	struct businst_attribute *businst_attr = to_businst_attr(attr);
-	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
-	ssize_t ret = 0;
-
-	if (businst_attr->show)
-		ret = businst_attr->show(bus, buf);
-	return ret;
-}
-
-ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr,
-			   const char *buf, size_t count)
-{
-	struct businst_attribute *businst_attr = to_businst_attr(attr);
-	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
-	ssize_t ret = 0;
-
-	if (businst_attr->store)
-		ret = businst_attr->store(bus, buf, count);
-	return ret;
-}
-
-int businst_create_file(struct visorbus_devdata *bus,
-			struct businst_attribute *attr)
-{
-	return sysfs_create_file(&bus->kobj, &attr->attr);
-}
-
-void businst_remove_file(struct visorbus_devdata *bus,
-			 struct businst_attribute *attr)
-{
-	sysfs_remove_file(&bus->kobj, &attr->attr);
-}
diff --git a/drivers/staging/unisys/visorbus/businst_attr.h b/drivers/staging/unisys/visorbus/businst_attr.h
deleted file mode 100644
index e9fb36a..0000000
--- a/drivers/staging/unisys/visorbus/businst_attr.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* businst_attr.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __BUSINST_H__
-#define __BUSINST_H__
-
-#include "visorbus_private.h"	/* just to get visorbus_devdata declaration */
-#include "timskmod.h"
-
-struct businst_attribute {
-	struct attribute attr;
-	 ssize_t (*show)(struct visorbus_devdata*, char *buf);
-	 ssize_t (*store)(struct visorbus_devdata*, const char *buf,
-			  size_t count);
-};
-
-ssize_t businst_attr_show(struct kobject *kobj,
-			  struct attribute *attr, char *buf);
-ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr,
-			   const char *buf, size_t count);
-int businst_create_file(struct visorbus_devdata *bus,
-			struct businst_attribute *attr);
-void businst_remove_file(struct visorbus_devdata *bus,
-			 struct businst_attribute *attr);
-
-#endif
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index d717e35..d178fcd 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -18,7 +18,7 @@
 #include <linux/uuid.h>
 
 #include "visorbus_private.h"
-#include "businst_attr.h"
+#include "timskmod.h"
 #include "channel_attr.h"
 #include "devmajorminor_attr.h"
 #include "periodic_work.h"
@@ -200,6 +200,101 @@ visorbus_release_device(struct device *xdev)
 	kfree(dev);
 }
 
+/*   This is actually something they forgot to put in the kernel.
+ *   struct bus_type in the kernel SHOULD have a "busses" member, which
+ *   should be treated similarly to the "devices" and "drivers" members.
+ *   There SHOULD be:
+ *   - a "businst_attribute" analogous to the existing "bus_attribute"
+ *   - a "businst_create_file" and "businst_remove_file" analogous to the
+ *     existing "bus_create_file" and "bus_remove_file".
+ *   That's what I created businst.c and businst.h to do.
+ *
+ *   We want to add the "busses" sub-tree in sysfs, where we will house the
+ *   names and properties of each bus instance:
+ *
+ *       /sys/bus/<bustypename>/
+ *           version
+ *           devices
+ *               <devname1> --> /sys/devices/<businstancename><devname1>
+ *               <devname2> --> /sys/devices/<businstancename><devname2>
+ *           drivers
+ *               <driverinstancename1>
+ *                   <driverinstance1property1>
+ *                   <driverinstance1property2>
+ *                   ...
+ *               <driverinstancename2>
+ *                   <driverinstance2property1>
+ *                   <driverinstance2property2>
+ *                   ...
+ *   >>      busses
+ *   >>          <businstancename1>
+ *   >>              <businstance1property1>
+ *   >>              <businstance1property2>
+ *   >>              ...
+ *   >>          <businstancename2>
+ *   >>              <businstance2property1>
+ *   >>              <businstance2property2>
+ *   >>              ...
+ *
+ *   I considered adding bus instance properties under
+ *   /sys/devices/<businstancename>.  But I thought there may be existing
+ *   notions that ONLY device sub-trees should live under
+ *   /sys/devices/<businstancename>.  So I stayed out of there.
+ *
+ */
+
+struct businst_attribute {
+	struct attribute attr;
+	 ssize_t (*show)(struct visorbus_devdata*, char *buf);
+	 ssize_t (*store)(struct visorbus_devdata*, const char *buf,
+			  size_t count);
+};
+
+#define to_businst_attr(_attr) \
+	container_of(_attr, struct businst_attribute, attr)
+#define to_visorbus_devdata(obj) \
+	container_of(obj, struct visorbus_devdata, kobj)
+
+static ssize_t
+businst_attr_show(struct kobject *kobj, struct attribute *attr,
+		  char *buf)
+{
+	struct businst_attribute *businst_attr = to_businst_attr(attr);
+	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
+	ssize_t ret = 0;
+
+	if (businst_attr->show)
+		ret = businst_attr->show(bus, buf);
+	return ret;
+}
+
+static ssize_t
+businst_attr_store(struct kobject *kobj, struct attribute *attr,
+		   const char *buf, size_t count)
+{
+	struct businst_attribute *businst_attr = to_businst_attr(attr);
+	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
+	ssize_t ret = 0;
+
+	if (businst_attr->store)
+		ret = businst_attr->store(bus, buf, count);
+	return ret;
+}
+
+static int
+businst_create_file(struct visorbus_devdata *bus,
+		    struct businst_attribute *attr)
+{
+	return sysfs_create_file(&bus->kobj, &attr->attr);
+}
+
+static void
+businst_remove_file(struct visorbus_devdata *bus,
+		    struct businst_attribute *attr)
+{
+	sysfs_remove_file(&bus->kobj, &attr->attr);
+}
+
 static const struct sysfs_ops businst_sysfs_ops = {
 	.show = businst_attr_show,
 	.store = businst_attr_store,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux