Commit a9a7c767 authored by Prarit Bhargava's avatar Prarit Bhargava Committed by Greg Kroah-Hartman

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: default avatarPrarit Bhargava <prarit@redhat.com>
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 98e50b8a
......@@ -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
......
/* 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);
}
/* 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
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment