From a9a7c767e38f3e74efb8d30397b48cc37612c4de Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:36:05 -0400 Subject: [PATCH] staging: unisys: unify businst attributes into visorbus_main.c 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 Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/Makefile | 2 +- .../staging/unisys/visorbus/businst_attr.c | 103 ------------------ .../staging/unisys/visorbus/businst_attr.h | 40 ------- .../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 20d87daf5b00..e1b667db363c 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 b3fea9d93d5e..000000000000 --- 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// - * version - * devices - * --> /sys/devices/ - * --> /sys/devices/ - * drivers - * - * - * - * ... - * - * - * - * ... - * >> busses - * >> - * >> - * >> - * >> ... - * >> - * >> - * >> - * >> ... - * - * I considered adding bus instance properties under - * /sys/devices/. But I thought there may be existing - * notions that ONLY device sub-trees should live under - * /sys/devices/. 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 e9fb36a692cb..000000000000 --- 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 d717e35d5a1e..d178fcd76ec5 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -18,7 +18,7 @@ #include #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// + * version + * devices + * --> /sys/devices/ + * --> /sys/devices/ + * drivers + * + * + * + * ... + * + * + * + * ... + * >> busses + * >> + * >> + * >> + * >> ... + * >> + * >> + * >> + * >> ... + * + * I considered adding bus instance properties under + * /sys/devices/. But I thought there may be existing + * notions that ONLY device sub-trees should live under + * /sys/devices/. 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.45.2