kobject: convert ibmasm to use kref, not kobject
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 4 Dec 2007 04:16:20 +0000 (21:16 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Jan 2008 04:40:08 +0000 (20:40 -0800)
The IBM asm driver is using a kobject only for reference counting,
nothing else.  So switch it to use a kref instead, which is all that is
needed, and is much smaller.

Cc: Max Asböck <amax@us.ibm.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/misc/ibmasm/command.c
drivers/misc/ibmasm/ibmasm.h

index 6497872df524167e6121d6aca87b8ea2d58281e9..1a0e7978226a6b593e048e31ef00e4e40dd13d41 100644 (file)
 #include "lowlevel.h"
 
 static void exec_next_command(struct service_processor *sp);
-static void free_command(struct kobject *kobj);
-
-static struct kobj_type ibmasm_cmd_kobj_type = {
-       .release = free_command,
-};
 
 static atomic_t command_count = ATOMIC_INIT(0);
 
@@ -53,8 +48,7 @@ struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_s
        }
        cmd->buffer_size = buffer_size;
 
-       kobject_init(&cmd->kobj);
-       cmd->kobj.ktype = &ibmasm_cmd_kobj_type;
+       kref_init(&cmd->kref);
        cmd->lock = &sp->lock;
 
        cmd->status = IBMASM_CMD_PENDING;
@@ -67,9 +61,9 @@ struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_s
        return cmd;
 }
 
-static void free_command(struct kobject *kobj)
+void ibmasm_free_command(struct kref *kref)
 {
-       struct command *cmd = to_command(kobj);
+       struct command *cmd = to_command(kref);
 
        list_del(&cmd->queue_node);
        atomic_dec(&command_count);
index de860bc6d3f5eb51ea57e210e98e4446b606640d..4d8a4e248b345aec3a2ce128d425f60add73856a 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/kref.h>
 #include <linux/device.h>
 #include <linux/input.h>
 
@@ -92,24 +93,25 @@ struct command {
        unsigned char           *buffer;
        size_t                  buffer_size;
        int                     status;
-       struct kobject          kobj;
+       struct kref             kref;
        spinlock_t              *lock;
 };
-#define to_command(c) container_of(c, struct command, kobj)
+#define to_command(c) container_of(c, struct command, kref)
 
+void ibmasm_free_command(struct kref *kref);
 static inline void command_put(struct command *cmd)
 {
        unsigned long flags;
        spinlock_t *lock = cmd->lock;
 
        spin_lock_irqsave(lock, flags);
-       kobject_put(&cmd->kobj);
+       kref_put(&cmd->kref, ibmasm_free_command);
        spin_unlock_irqrestore(lock, flags);
 }
 
 static inline void command_get(struct command *cmd)
 {
-       kobject_get(&cmd->kobj);
+       kref_get(&cmd->kref);
 }