command.c (b981d8b3f5e008ff10d993be633ad00564fc22cd) command.c (a045171f875cd61f690981a78ab98fbd137c938b)
1
2/*
3 * IBM ASM Service Processor Device Driver
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 12 unchanged lines hidden (view full) ---

21 * Author: Max Asb�ck <amax@us.ibm.com>
22 *
23 */
24
25#include "ibmasm.h"
26#include "lowlevel.h"
27
28static void exec_next_command(struct service_processor *sp);
1
2/*
3 * IBM ASM Service Processor Device Driver
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 12 unchanged lines hidden (view full) ---

21 * Author: Max Asb�ck <amax@us.ibm.com>
22 *
23 */
24
25#include "ibmasm.h"
26#include "lowlevel.h"
27
28static void exec_next_command(struct service_processor *sp);
29static void free_command(struct kobject *kobj);
30
29
31static struct kobj_type ibmasm_cmd_kobj_type = {
32 .release = free_command,
33};
34
35static atomic_t command_count = ATOMIC_INIT(0);
36
37struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_size)
38{
39 struct command *cmd;
40
41 if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE)
42 return NULL;

--- 5 unchanged lines hidden (view full) ---

48
49 cmd->buffer = kzalloc(buffer_size, GFP_KERNEL);
50 if (cmd->buffer == NULL) {
51 kfree(cmd);
52 return NULL;
53 }
54 cmd->buffer_size = buffer_size;
55
30static atomic_t command_count = ATOMIC_INIT(0);
31
32struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_size)
33{
34 struct command *cmd;
35
36 if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE)
37 return NULL;

--- 5 unchanged lines hidden (view full) ---

43
44 cmd->buffer = kzalloc(buffer_size, GFP_KERNEL);
45 if (cmd->buffer == NULL) {
46 kfree(cmd);
47 return NULL;
48 }
49 cmd->buffer_size = buffer_size;
50
56 kobject_init(&cmd->kobj);
57 cmd->kobj.ktype = &ibmasm_cmd_kobj_type;
51 kref_init(&cmd->kref);
58 cmd->lock = &sp->lock;
59
60 cmd->status = IBMASM_CMD_PENDING;
61 init_waitqueue_head(&cmd->wait);
62 INIT_LIST_HEAD(&cmd->queue_node);
63
64 atomic_inc(&command_count);
65 dbg("command count: %d\n", atomic_read(&command_count));
66
67 return cmd;
68}
69
52 cmd->lock = &sp->lock;
53
54 cmd->status = IBMASM_CMD_PENDING;
55 init_waitqueue_head(&cmd->wait);
56 INIT_LIST_HEAD(&cmd->queue_node);
57
58 atomic_inc(&command_count);
59 dbg("command count: %d\n", atomic_read(&command_count));
60
61 return cmd;
62}
63
70static void free_command(struct kobject *kobj)
64void ibmasm_free_command(struct kref *kref)
71{
65{
72 struct command *cmd = to_command(kobj);
66 struct command *cmd = to_command(kref);
73
74 list_del(&cmd->queue_node);
75 atomic_dec(&command_count);
76 dbg("command count: %d\n", atomic_read(&command_count));
77 kfree(cmd->buffer);
78 kfree(cmd);
79}
80

--- 111 unchanged lines hidden ---
67
68 list_del(&cmd->queue_node);
69 atomic_dec(&command_count);
70 dbg("command count: %d\n", atomic_read(&command_count));
71 kfree(cmd->buffer);
72 kfree(cmd);
73}
74

--- 111 unchanged lines hidden ---