diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-12-03 23:16:20 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:08 -0500 |
commit | a045171f875cd61f690981a78ab98fbd137c938b (patch) | |
tree | 322884aeee9d5f5413e9c874be9d0601fef61630 /drivers/misc | |
parent | d7b37889650bb316f5c4ad4b0569ba897120d70d (diff) |
kobject: convert ibmasm to use kref, not kobject
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>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/ibmasm/command.c | 12 | ||||
-rw-r--r-- | drivers/misc/ibmasm/ibmasm.h | 10 |
2 files changed, 9 insertions, 13 deletions
diff --git a/drivers/misc/ibmasm/command.c b/drivers/misc/ibmasm/command.c index 6497872df52..1a0e7978226 100644 --- a/drivers/misc/ibmasm/command.c +++ b/drivers/misc/ibmasm/command.c | |||
@@ -26,11 +26,6 @@ | |||
26 | #include "lowlevel.h" | 26 | #include "lowlevel.h" |
27 | 27 | ||
28 | static void exec_next_command(struct service_processor *sp); | 28 | static void exec_next_command(struct service_processor *sp); |
29 | static void free_command(struct kobject *kobj); | ||
30 | |||
31 | static struct kobj_type ibmasm_cmd_kobj_type = { | ||
32 | .release = free_command, | ||
33 | }; | ||
34 | 29 | ||
35 | static atomic_t command_count = ATOMIC_INIT(0); | 30 | static atomic_t command_count = ATOMIC_INIT(0); |
36 | 31 | ||
@@ -53,8 +48,7 @@ struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_s | |||
53 | } | 48 | } |
54 | cmd->buffer_size = buffer_size; | 49 | cmd->buffer_size = buffer_size; |
55 | 50 | ||
56 | kobject_init(&cmd->kobj); | 51 | kref_init(&cmd->kref); |
57 | cmd->kobj.ktype = &ibmasm_cmd_kobj_type; | ||
58 | cmd->lock = &sp->lock; | 52 | cmd->lock = &sp->lock; |
59 | 53 | ||
60 | cmd->status = IBMASM_CMD_PENDING; | 54 | cmd->status = IBMASM_CMD_PENDING; |
@@ -67,9 +61,9 @@ struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_s | |||
67 | return cmd; | 61 | return cmd; |
68 | } | 62 | } |
69 | 63 | ||
70 | static void free_command(struct kobject *kobj) | 64 | void ibmasm_free_command(struct kref *kref) |
71 | { | 65 | { |
72 | struct command *cmd = to_command(kobj); | 66 | struct command *cmd = to_command(kref); |
73 | 67 | ||
74 | list_del(&cmd->queue_node); | 68 | list_del(&cmd->queue_node); |
75 | atomic_dec(&command_count); | 69 | atomic_dec(&command_count); |
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h index de860bc6d3f..4d8a4e248b3 100644 --- a/drivers/misc/ibmasm/ibmasm.h +++ b/drivers/misc/ibmasm/ibmasm.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |
34 | #include <linux/kref.h> | ||
34 | #include <linux/device.h> | 35 | #include <linux/device.h> |
35 | #include <linux/input.h> | 36 | #include <linux/input.h> |
36 | 37 | ||
@@ -92,24 +93,25 @@ struct command { | |||
92 | unsigned char *buffer; | 93 | unsigned char *buffer; |
93 | size_t buffer_size; | 94 | size_t buffer_size; |
94 | int status; | 95 | int status; |
95 | struct kobject kobj; | 96 | struct kref kref; |
96 | spinlock_t *lock; | 97 | spinlock_t *lock; |
97 | }; | 98 | }; |
98 | #define to_command(c) container_of(c, struct command, kobj) | 99 | #define to_command(c) container_of(c, struct command, kref) |
99 | 100 | ||
101 | void ibmasm_free_command(struct kref *kref); | ||
100 | static inline void command_put(struct command *cmd) | 102 | static inline void command_put(struct command *cmd) |
101 | { | 103 | { |
102 | unsigned long flags; | 104 | unsigned long flags; |
103 | spinlock_t *lock = cmd->lock; | 105 | spinlock_t *lock = cmd->lock; |
104 | 106 | ||
105 | spin_lock_irqsave(lock, flags); | 107 | spin_lock_irqsave(lock, flags); |
106 | kobject_put(&cmd->kobj); | 108 | kref_put(&cmd->kref, ibmasm_free_command); |
107 | spin_unlock_irqrestore(lock, flags); | 109 | spin_unlock_irqrestore(lock, flags); |
108 | } | 110 | } |
109 | 111 | ||
110 | static inline void command_get(struct command *cmd) | 112 | static inline void command_get(struct command *cmd) |
111 | { | 113 | { |
112 | kobject_get(&cmd->kobj); | 114 | kref_get(&cmd->kref); |
113 | } | 115 | } |
114 | 116 | ||
115 | 117 | ||