summaryrefslogtreecommitdiff
path: root/lib/kobject.c
AgeCommit message (Collapse)Author
2005-03-08[PATCH] kset: make ksets have a spinlock, and use that to lock their listsGreg Kroah-Hartman
Do this instead of using the rwsem of a subsys. Smaller, faster, and I'm trying to get rid of the rwsem in the subsys. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-03-08[PATCH] Kobject: remove some unneeded exportsArjan van de Ven
kobject_get_path and kobject_rename are only used by the sysfs core code and not aren't really driver-ish code. Remove the unused exports Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-11-18[PATCH] fix kobject varargs bugAndrew Morton
From: Gerd Knorr <kraxel@bytesex.org> It uses the varargs list twice in a illegal way. That doesn't harm on i386 by pure luck, but blows things up on amd64 machines. Using var args list twice without calling va_start twice is illegal. Signed-off-by: Gerd Knorr <kraxel@bytesex.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-11-08[PATCH] kobject: fix double kobject_put() in error path of kobject_add()Greg Kroah-Hartman
This fixes a problem introduced in the previous set of driver model changes that has been seen by a lot of people (most notibly the greater than 256 pty users, but others might also be hitting this without realizing it.) Also add a comment so we don't try to "fix" this again. Signed-off-by: Greg Kroah-Hartman <greg@kroah.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2004-11-03[PATCH] driver-model: kobject_add() error path reference counting fixTejun Heo
df_04_kobject_add_ref_fix.patch In kobject_add(), @kobj wasn't put'd properly on error path. This patch fixes it. Signed-off-by: Tejun Heo <tj@home-tj.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-10-20kobject: add CONFIG_DEBUG_KOBJECTGreg Kroah-Hartman
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-09-14kevent: standardize on the event typesGreg Kroah-Hartman
This prevents any potential typos from happening. Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-09-10Kobject Userspace Event NotificationGreg Kroah-Hartman
Implemetation of userspace events through a netlink socket. The kernel events layer provides the functionality to raise an event from a given kobject represented by its sysfs-path and a signal string to describe the type of event. Currently, kobject additions and removals are signalized to userspace by forking the /sbin/hotplug helper. This patch moves this special case of userspace-event out of the kobject core to the new kobject_uevent implementation. This makes it possible to send all hotplug messages also through the new netlink transport. Possible new users of the kernel userspace functionality are filesystem mount events (block device claim/release) or simple device state transitions (cpu overheating). To send an event, the user needs to pass the kobject, a optional sysfs-attribute and the signal string to the following function: kobject_uevent(const char *signal, struct kobject *kobj, struct attribute *attr) Example: kobject_uevent("overheating", &cpu->kobj, NULL); The message itself is sent over multicast netlink socket, which makes it possible for userspace to listen with multiple applications for the same messages. Signed-off-by: Robert Love <rml@novell.com> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-09-08[PATCH] ksyms: don't implement /sys/kernel/hotplug_seqnum if CONFIG_HOTPLUG ↵Greg Kroah-Hartman
is not enabled. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-09-08[PATCH] kobject: hotplug_seqnum is not 64 bits on all platforms, so fix it.Greg Kroah-Hartman
Thanks to Kay Sievers for pointing this out. Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-09-05kobject: fix build error if CONFIG_HOTPLUG is not enabled.Greg Kroah-Hartman
Thanks to Kay Sievers for pointing this out. Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-09-04kobject: adjust hotplug_seqnum increment to keep userspace and kernel agreeing.Greg Kroah-Hartman
2004-09-04[PATCH] export of SEQNUM to userspace (creates /sys/kernel)Kay Sievers
o /sys/kernel/hotplug_seqnum exports the current number o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and exported by include/linux/kobject.h o the source file ksysfs.c in kernel/ creates on init the sybsystem "/sys/kernel/" in sysfs Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-08-24kobject: convert struct kobject use kref.Greg Kroah-Hartman
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-08-24[PATCH] kobject: fix kobject_set_name comment.Dmitry Torokhov
Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-08-06[PATCH] KOBJECT: add kobject_get_pathRobert Love
Add a new kobject helper, kobject_get_path(), which is the greatest function ever. Signed-Off-By: Robert Love <rml@ximian.com> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-07-08[PATCH] Driver core: kset_find_obj should increment refcount of the found objectDmitry Torokhov
kset_find_obj should increment refcount of the found object so users of the function can safely use returned object Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-06-29sparse: get rid of more integer/pointer confusionLinus Torvalds
Use NULL, not 0, where appropriate.
2004-06-29[PATCH] Combined patch for remaining trivial sparse warnings in allnoconfig ↵Mika Kukkonen
build Well, one of these (fs/block_dev.c) is little non-trivial, but i felt throwing that away would be a shame (and I did add comments ;-). Also almost all of these have been submitted earlier through other channels, but have not been picked up (the only controversial is again the fs/block_dev.c patch, where Linus felt a better job would be done with __ffs(), but I could not convince myself that is does the same thing as original code). Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2004-05-13[PATCH] sysfs_rename_dir-cleanupManeesh Soni
o The following patch cleans up sysfs_rename_dir(). It now checks the return code of kobject_set_name() and propagates the error code to its callers. Because of this there are changes in the following two APIs. Both return int instead of void. int sysfs_rename_dir(struct kobject * kobj, const char *new_name) int kobject_rename(struct kobject * kobj, char *new_name)
2004-03-30[PATCH] kobject_set_name() doesn't allocate enough spaceLinda Xie
2004-02-26kobject: clean up kobject_get() convoluted logic.Greg Kroah-Hartman
2004-02-26kobject: fix kobject hotplug debug message to show more needed info.Greg Kroah-Hartman
2004-02-01[PATCH] Kobject: export some missing symbolsEugene Teo
2004-01-19[PATCH] Kobject: prevent oops in kset_find_obj() if kobject_name() is NULLGreg Kroah-Hartman
Thanks to Hollis Blanchard <hollisb@us.ibm.com> for pointing this out.
2004-01-19[PATCH] kobject: make kobject hotplug function publicDmitry Torokhov
make kobject hotplug mechanism public so that others may call it.
2003-12-10kobject: fix bug where a parent could be deleted before a child device.Greg Kroah-Hartman
2003-09-29[kobject] Fix memory leak in kobject_set_name().Patrick Mochel
If kobject_set_name() is called when the kobject already has a name that was dynamically allocated (too long for the static array), then we must free that memory. Noticed by Jon Corbet.
2003-09-24[kobject] export kset syms for module usePatrick Mochel
From John Rose <johnrose@austin.ibm.com> The patch below exposes some kset functions for use by modules. In the development of a PPC64 pci hotplug drv, we have found it necessary to use ksets of different types under a single subsystem. After discussing with GregKH, we agreed that this change makes this possible.
2003-09-02[kobject] Don't use kobject->k_name after it's been freed. Patrick Mochel
Bah, stupid mistake. After you call ->release(), you cannot touch the object.
2003-08-28[kobject] Support unlimited name lengths.Patrick Mochel
Add ->k_name pointer which points to the name for a kobject. By default, this points to ->name (the static name array). Users of kobjects may use the helper function kobject_set_name() (and are encouraged to do so in all cases). This function will determined whether or not the name is short enough to fit in ->name. If so, great. Otherwise, a dyanamic string is allocated and the name is stored there. ->k_name will point to that, and will be freed when the kobject is released. kobject_set_name() may take a format string, like: kobject_set_name(kobj,"%s%d",base_name,id); and will behave as expected (will put in ->name, unless it's too long, in which case a new string will be allocated and it will be stored in there).
2003-07-03[PATCH] kobject: add kobject_rename()Greg Kroah-Hartman
Based on a patch written by Dan Aloni <da-x@gmx.net>
2003-06-15[kobject] Add sequence number to kobject hotplug.Patrick Mochel
2003-06-10[kobject] Don't specially order objects in lists based on parent.Patrick Mochel
Previously, we would insert kobjects into their kset's lists at different locations based on if they had a parent or not - We kept an explicit depth-first list by placing devices directly before their parents. However, we don't need strict ordering. Assuming that a subordinate device is always added after its parent (true), then by adding them to the end of the list, then subordinate objects will always be farther down the list than their parent objects. We don't need to do anything special..
2003-06-04[kobject] Add warning + back trace if kobject_get() is called with 0 refcount.Patrick Mochel
2003-06-04[kobject] Remove kobj_lock and use lockless refcounting. Patrick Mochel
The only thing preventing this from happening earlier was the circular sysfs registration dependency - it would need to be initialized before it was registered, but needed to be registered before it was initialized. With kobjects gone from struct filesystem_type, the dependency no longer exists and we don't have to special-case the possibility that a kobject will be passed to kobject_get with a refcount == 0. Note that a kobject with a count of 0 in that function is still a bug, but one in the subsystem making the call. We should add a debugging hook to dump the stack if it does happen.
2003-06-03[kobject] Update Documentation and licenses. Patrick Mochel
- Make it very explicit that supplying an object desctructor is imperative if using the interface for object reference counting. - Add GPL statement to the source files. - Add GFL (http://www.fsf.org/licenses/fdl.html) statement to documentation.
2003-05-12Merge osdl.org:/home/mochel/src/kernel/devel/linux-2.5-virginPatrick Mochel
into osdl.org:/home/mochel/src/kernel/devel/linux-2.5-core
2003-04-28kobject: kobj_lock needs to be grabed using spinlock_irqGreg Kroah-Hartman
This is because some subsystems (cough, usb...) can grab a kobject from irq context. This lock can be completely removed once the sysfs_init() code is cleaned up. Patch originally by Andrew Morton.
2003-04-16kobject: Add better debugging for failed registrations.Patrick Mochel
From Steve Hemminger (shemminger@osdl.org)
2003-04-12[PATCH] kobject hotplug fixesAndrew Morton
- allocated storage `envp' was being leaked on an error path - kmalloc() returns void*, no need to cast it - don't return 0 from a void-returning function Greg has acked this patch.
2003-04-04kobject: cause /sbin/hotplug to be called when kobjects are added and removedGreg Kroah-Hartman
This only happens if a kobject belongs to a subsystem that has specified a set of hotplug operations. Based on work done by Kevin Fleming <kpfleming@cox.net>
2003-01-13kobject: export kset_find_obj.Patrick Mochel
From Louis Zhang.
2003-01-09kobject: make sure we remove kobject from list if kobject_add() failes.Patrick Mochel
Originally from Louis Zhang.
2003-01-09kobject.c fix compile when DEBUG is defined.Patrick Mochel
- From Greg k-h
2003-01-06add kset_find_obj() to search for object in a kset's list.Patrick Mochel
The operation is simple: - Take read lock for kset. - Iterate over kset->list. - Compare name to each kobject's name. - Return kobject if found.
2003-01-05kobjects: Remove kobject::subsys and subsystem::kobj.Patrick Mochel
The kobject core no longer references a subsystem directly through a kobject, instead using the kobject's dominant kset to reference the subsystem. The registrants of kobjects have been fixed up. To aid in this process, a few helpers were introdcuced: - kobj_set_kset_s(obj,subsys) - kset_set_kset_s(obj,subsys) - subsys_set_kset(obj,subsys) that set the kset ptr of embedded kobjects for objects that have different embedded types. See include/linux/kobject.h for more description and usage. struct subsystem::kobj is also removed, relying solely on a subsystem's embedded kset for hierarchy information. Since this requires modification of the subsystem declarations, a helper macro has been defined: decl_subsys(name,type) which initializes the name and ktype fields of the subsystem's embedded kset. All the subsystem declarations have been fixed up.
2003-01-05Introduce struct kset.Patrick Mochel
struct kset is what struct subsystem should have originally been called. It is a set of kobjects, and nothing more, with a much less confusing name than 'subsystem.' struct kset contains an embedded kobject, making it possible to represent it in the object hierarchy, and sysfs. This also provides a means for objects to easily express a list of subordinate objects. struct subsystem still exists, and contains an rwsem, which its subordinate ksets use to protect their lists. An arbitrary number of ksets may belong to a subsystem. A ksets specifies the subsystem it belongs to via its ->subsys field. struct subsystem also contains a default kset, which may be used without having to define a separate kset. The objects that defined subordinate subsystems (bus and class drivers) have been converted to use subordinate ksets instead. Note that the usage of ksets is flexible. - ksets may contain a list of objects of any type, not just kobjects. - The objects registered with a kset do not have to be registered. - ksets themselves do not have to be registered. One can be used by simply calling kset_init(). - ksets do not need a name if they are not registered. - Note however that locking must be done manually in these cases.
2003-01-04kobject: Introduce struct kobj_type. Patrick Mochel
This is the first step in morphing struct subsystem into something meaningful. A subsystem is defined simply as a list of kobjects of a certain type, which is far too generic. A subsystem should be representative of a large entity of code (i.e. a subsystem of the kernel), not just a simple list. This changeset: - Creates struct kobj_type, a descriptor of the type a kobject is embedded in. - Extracts the fields that are specific to a particular object type from struct subsystem and puts them in struct kobj_type, which are - the object's release method. - the sysfs operations for the object type. - the default attributes of the object type. - Adds ptr to struct kobject to point to its type descriptor. - Converts the existing subsystem definitions to define struct kobj_type. struct kobj_type's are not registered, as they do not have any explicit representation in the object hierarchy, nor do they have any fields that need runtime initialization. A kobject's ktype should be set when it is registered, like its subsystem. Note this obviates the need for defining a struct subsystem when an object type does not need to be kept in a global list.
2002-12-19kobjects: minor updatesPatrick Mochel
- check if subsystem is NULL during subsys_get(). - Don't increment parent's reference count before we check if we have a valid kobject during kobject_add() - Do kobject_add() in subsys_register(), instead of kobject_register(), since we've already done kobject_init().