Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 75721
b: refs/heads/master
c: a045171
h: refs/heads/master
i:
  75719: d261e83
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Jan 25, 2008
1 parent 4123318 commit 7109c0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d7b37889650bb316f5c4ad4b0569ba897120d70d
refs/heads/master: a045171f875cd61f690981a78ab98fbd137c938b
12 changes: 3 additions & 9 deletions trunk/drivers/misc/ibmasm/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
#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);

Expand All @@ -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;
Expand All @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions trunk/drivers/misc/ibmasm/ibmasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit 7109c0f

Please sign in to comment.