Skip to content

Commit

Permalink
remove "struct subsystem" as it is no longer needed
Browse files Browse the repository at this point in the history
We need to work on cleaning up the relationship between kobjects, ksets and
ktypes.  The removal of 'struct subsystem' is the first step of this,
especially as it is not really needed at all.

Thanks to Kay for fixing the bugs in this patch.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed May 3, 2007
1 parent 2609e7b commit 823bccf
Show file tree
Hide file tree
Showing 46 changed files with 231 additions and 292 deletions.
6 changes: 3 additions & 3 deletions arch/arm/mach-omap1/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];

static unsigned short enable_dyn_sleep = 1;

static ssize_t omap_pm_sleep_while_idle_show(struct subsystem * subsys, char *buf)
static ssize_t omap_pm_sleep_while_idle_show(struct kset *kset, char *buf)
{
return sprintf(buf, "%hu\n", enable_dyn_sleep);
}

static ssize_t omap_pm_sleep_while_idle_store(struct subsystem * subsys,
static ssize_t omap_pm_sleep_while_idle_store(struct kset *kset,
const char * buf,
size_t n)
{
Expand All @@ -100,7 +100,7 @@ static struct subsys_attribute sleep_while_idle_attr = {
.store = omap_pm_sleep_while_idle_store,
};

extern struct subsystem power_subsys;
extern struct kset power_subsys;
static void (*omap_sram_idle)(void) = NULL;
static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;

Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/kernel/vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <asm/iseries/hv_call_xm.h>
#include <asm/iseries/iommu.h>

extern struct subsystem devices_subsys; /* needed for vio_find_name() */
extern struct kset devices_subsys; /* needed for vio_find_name() */

static struct vio_dev vio_bus_device = { /* fake "parent" device */
.name = vio_bus_device.dev.bus_id,
Expand Down Expand Up @@ -427,7 +427,7 @@ static struct vio_dev *vio_find_name(const char *kobj_name)
{
struct kobject *found;

found = kset_find_obj(&devices_subsys.kset, kobj_name);
found = kset_find_obj(&devices_subsys, kobj_name);
if (!found)
return NULL;

Expand Down
8 changes: 4 additions & 4 deletions arch/powerpc/platforms/pseries/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

unsigned long rtas_poweron_auto; /* default and normal state is 0 */

static ssize_t auto_poweron_show(struct subsystem *subsys, char *buf)
static ssize_t auto_poweron_show(struct kset *kset, char *buf)
{
return sprintf(buf, "%lu\n", rtas_poweron_auto);
}

static ssize_t
auto_poweron_store(struct subsystem *subsys, const char *buf, size_t n)
auto_poweron_store(struct kset *kset, const char *buf, size_t n)
{
int ret;
unsigned long ups_restart;
Expand Down Expand Up @@ -72,12 +72,12 @@ static int __init pm_init(void)
{
int error = subsystem_register(&power_subsys);
if (!error)
error = sysfs_create_group(&power_subsys.kset.kobj,&attr_group);
error = sysfs_create_group(&power_subsys.kobj, &attr_group);
return error;
}
core_initcall(pm_init);
#else
extern struct subsystem power_subsys;
extern struct kset power_subsys;

static int __init apo_pm_init(void)
{
Expand Down
32 changes: 16 additions & 16 deletions arch/s390/kernel/ipl.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ EXPORT_SYMBOL_GPL(diag308);
/* SYSFS */

#define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
char *page) \
{ \
return sprintf(page, _format, _value); \
Expand All @@ -173,13 +173,13 @@ static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
__ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);

#define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
char *page) \
{ \
return sprintf(page, _fmt_out, \
(unsigned long long) _value); \
} \
static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
const char *buf, size_t len) \
{ \
unsigned long long value; \
Expand All @@ -194,12 +194,12 @@ static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
sys_##_prefix##_##_name##_store);

#define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
char *page) \
{ \
return sprintf(page, _fmt_out, _value); \
} \
static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
const char *buf, size_t len) \
{ \
if (sscanf(buf, _fmt_in, _value) != 1) \
Expand Down Expand Up @@ -272,14 +272,14 @@ void __init setup_ipl_info(void)
struct ipl_info ipl_info;
EXPORT_SYMBOL_GPL(ipl_info);

static ssize_t ipl_type_show(struct subsystem *subsys, char *page)
static ssize_t ipl_type_show(struct kset *kset, char *page)
{
return sprintf(page, "%s\n", ipl_type_str(ipl_info.type));
}

static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);

static ssize_t sys_ipl_device_show(struct subsystem *subsys, char *page)
static ssize_t sys_ipl_device_show(struct kset *kset, char *page)
{
struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;

Expand Down Expand Up @@ -371,7 +371,7 @@ static struct attribute_group ipl_fcp_attr_group = {

/* CCW ipl device attributes */

static ssize_t ipl_ccw_loadparm_show(struct subsystem *subsys, char *page)
static ssize_t ipl_ccw_loadparm_show(struct kset *kset, char *page)
{
char loadparm[LOADPARM_LEN + 1] = {};

Expand Down Expand Up @@ -469,15 +469,15 @@ static void reipl_get_ascii_loadparm(char *loadparm)
strstrip(loadparm);
}

static ssize_t reipl_ccw_loadparm_show(struct subsystem *subsys, char *page)
static ssize_t reipl_ccw_loadparm_show(struct kset *kset, char *page)
{
char buf[LOADPARM_LEN + 1];

reipl_get_ascii_loadparm(buf);
return sprintf(page, "%s\n", buf);
}

static ssize_t reipl_ccw_loadparm_store(struct subsystem *subsys,
static ssize_t reipl_ccw_loadparm_store(struct kset *kset,
const char *buf, size_t len)
{
int i, lp_len;
Expand Down Expand Up @@ -572,12 +572,12 @@ static int reipl_set_type(enum ipl_type type)
return 0;
}

static ssize_t reipl_type_show(struct subsystem *subsys, char *page)
static ssize_t reipl_type_show(struct kset *kset, char *page)
{
return sprintf(page, "%s\n", ipl_type_str(reipl_type));
}

static ssize_t reipl_type_store(struct subsystem *subsys, const char *buf,
static ssize_t reipl_type_store(struct kset *kset, const char *buf,
size_t len)
{
int rc = -EINVAL;
Expand Down Expand Up @@ -665,12 +665,12 @@ static int dump_set_type(enum dump_type type)
return 0;
}

static ssize_t dump_type_show(struct subsystem *subsys, char *page)
static ssize_t dump_type_show(struct kset *kset, char *page)
{
return sprintf(page, "%s\n", dump_type_str(dump_type));
}

static ssize_t dump_type_store(struct subsystem *subsys, const char *buf,
static ssize_t dump_type_store(struct kset *kset, const char *buf,
size_t len)
{
int rc = -EINVAL;
Expand All @@ -697,12 +697,12 @@ static decl_subsys(shutdown_actions, NULL, NULL);

/* on panic */

static ssize_t on_panic_show(struct subsystem *subsys, char *page)
static ssize_t on_panic_show(struct kset *kset, char *page)
{
return sprintf(page, "%s\n", shutdown_action_str(on_panic_action));
}

static ssize_t on_panic_store(struct subsystem *subsys, const char *buf,
static ssize_t on_panic_store(struct kset *kset, const char *buf,
size_t len)
{
if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0)
Expand Down
12 changes: 6 additions & 6 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/buffer_head.h>
#include <linux/mutex.h>

struct subsystem block_subsys;
struct kset block_subsys;
static DEFINE_MUTEX(block_subsys_lock);

/*
Expand Down Expand Up @@ -221,7 +221,7 @@ static void *part_start(struct seq_file *part, loff_t *pos)
loff_t l = *pos;

mutex_lock(&block_subsys_lock);
list_for_each(p, &block_subsys.kset.list)
list_for_each(p, &block_subsys.list)
if (!l--)
return list_entry(p, struct gendisk, kobj.entry);
return NULL;
Expand All @@ -231,7 +231,7 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
{
struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
++*pos;
return p==&block_subsys.kset.list ? NULL :
return p==&block_subsys.list ? NULL :
list_entry(p, struct gendisk, kobj.entry);
}

Expand All @@ -246,7 +246,7 @@ static int show_partition(struct seq_file *part, void *v)
int n;
char buf[BDEVNAME_SIZE];

if (&sgp->kobj.entry == block_subsys.kset.list.next)
if (&sgp->kobj.entry == block_subsys.list.next)
seq_puts(part, "major minor #blocks name\n\n");

/* Don't show non-partitionable removeable devices or empty devices */
Expand Down Expand Up @@ -565,7 +565,7 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos)
struct list_head *p;

mutex_lock(&block_subsys_lock);
list_for_each(p, &block_subsys.kset.list)
list_for_each(p, &block_subsys.list)
if (!k--)
return list_entry(p, struct gendisk, kobj.entry);
return NULL;
Expand All @@ -575,7 +575,7 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
{
struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
++*pos;
return p==&block_subsys.kset.list ? NULL :
return p==&block_subsys.list ? NULL :
list_entry(p, struct gendisk, kobj.entry);
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
extern char *make_class_name(const char *name, struct kobject *kobj);

extern void devres_release_all(struct device *dev);

extern struct kset devices_subsys;
16 changes: 8 additions & 8 deletions drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "power/power.h"

#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
#define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj)
#define to_bus(obj) container_of(obj, struct bus_type, subsys.kobj)

/*
* sysfs bindings for drivers
Expand Down Expand Up @@ -123,7 +123,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
{
int error;
if (get_bus(bus)) {
error = sysfs_create_file(&bus->subsys.kset.kobj, &attr->attr);
error = sysfs_create_file(&bus->subsys.kobj, &attr->attr);
put_bus(bus);
} else
error = -EINVAL;
Expand All @@ -133,7 +133,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
{
if (get_bus(bus)) {
sysfs_remove_file(&bus->subsys.kset.kobj, &attr->attr);
sysfs_remove_file(&bus->subsys.kobj, &attr->attr);
put_bus(bus);
}
}
Expand Down Expand Up @@ -397,7 +397,7 @@ static void device_remove_attrs(struct bus_type * bus, struct device * dev)
static int make_deprecated_bus_links(struct device *dev)
{
return sysfs_create_link(&dev->kobj,
&dev->bus->subsys.kset.kobj, "bus");
&dev->bus->subsys.kobj, "bus");
}

static void remove_deprecated_bus_links(struct device *dev)
Expand Down Expand Up @@ -431,7 +431,7 @@ int bus_add_device(struct device * dev)
if (error)
goto out_id;
error = sysfs_create_link(&dev->kobj,
&dev->bus->subsys.kset.kobj, "subsystem");
&dev->bus->subsys.kobj, "subsystem");
if (error)
goto out_subsys;
error = make_deprecated_bus_links(dev);
Expand Down Expand Up @@ -810,7 +810,7 @@ int bus_register(struct bus_type * bus)

BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);

retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name);
retval = kobject_set_name(&bus->subsys.kobj, "%s", bus->name);
if (retval)
goto out;

Expand All @@ -820,13 +820,13 @@ int bus_register(struct bus_type * bus)
goto out;

kobject_set_name(&bus->devices.kobj, "devices");
bus->devices.subsys = &bus->subsys;
bus->devices.kobj.parent = &bus->subsys.kobj;
retval = kset_register(&bus->devices);
if (retval)
goto bus_devices_fail;

kobject_set_name(&bus->drivers.kobj, "drivers");
bus->drivers.subsys = &bus->subsys;
bus->drivers.kobj.parent = &bus->subsys.kobj;
bus->drivers.ktype = &ktype_driver;
retval = kset_register(&bus->drivers);
if (retval)
Expand Down
18 changes: 8 additions & 10 deletions drivers/base/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
#include <linux/slab.h>
#include "base.h"

extern struct subsystem devices_subsys;

#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)
#define to_class(obj) container_of(obj, struct class, subsys.kobj)

static ssize_t
class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
Expand Down Expand Up @@ -80,7 +78,7 @@ int class_create_file(struct class * cls, const struct class_attribute * attr)
{
int error;
if (cls) {
error = sysfs_create_file(&cls->subsys.kset.kobj, &attr->attr);
error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
} else
error = -EINVAL;
return error;
Expand All @@ -89,7 +87,7 @@ int class_create_file(struct class * cls, const struct class_attribute * attr)
void class_remove_file(struct class * cls, const struct class_attribute * attr)
{
if (cls)
sysfs_remove_file(&cls->subsys.kset.kobj, &attr->attr);
sysfs_remove_file(&cls->subsys.kobj, &attr->attr);
}

static struct class *class_get(struct class *cls)
Expand Down Expand Up @@ -147,7 +145,7 @@ int class_register(struct class * cls)
INIT_LIST_HEAD(&cls->interfaces);
kset_init(&cls->class_dirs);
init_MUTEX(&cls->sem);
error = kobject_set_name(&cls->subsys.kset.kobj, "%s", cls->name);
error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
if (error)
return error;

Expand Down Expand Up @@ -611,15 +609,15 @@ int class_device_add(struct class_device *class_dev)
if (parent_class_dev)
class_dev->kobj.parent = &parent_class_dev->kobj;
else
class_dev->kobj.parent = &parent_class->subsys.kset.kobj;
class_dev->kobj.parent = &parent_class->subsys.kobj;

error = kobject_add(&class_dev->kobj);
if (error)
goto out2;

/* add the needed attributes to this device */
error = sysfs_create_link(&class_dev->kobj,
&parent_class->subsys.kset.kobj, "subsystem");
&parent_class->subsys.kobj, "subsystem");
if (error)
goto out3;
class_dev->uevent_attr.attr.name = "uevent";
Expand Down Expand Up @@ -917,8 +915,8 @@ int __init classes_init(void)
/* ick, this is ugly, the things we go through to keep from showing up
* in sysfs... */
subsystem_init(&class_obj_subsys);
if (!class_obj_subsys.kset.subsys)
class_obj_subsys.kset.subsys = &class_obj_subsys;
if (!class_obj_subsys.kobj.parent)
class_obj_subsys.kobj.parent = &class_obj_subsys.kobj;
return 0;
}

Expand Down
Loading

0 comments on commit 823bccf

Please sign in to comment.