Skip to content

Commit

Permalink
[PATCH] ipmi: style cleanups
Browse files Browse the repository at this point in the history
Clean up various style issues in the IPMI driver.  Should be no functional
changes.

Signed-off-by: Corey Minyard <minyard@acm.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Corey Minyard authored and Linus Torvalds committed Sep 7, 2005
1 parent 168524d commit e8b3361
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 128 deletions.
66 changes: 44 additions & 22 deletions drivers/char/ipmi/ipmi_bt_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,17 @@ static int bt_start_transaction(struct si_sm_data *bt,
{
unsigned int i;

if ((size < 2) || (size > IPMI_MAX_MSG_LENGTH)) return -1;
if ((size < 2) || (size > IPMI_MAX_MSG_LENGTH))
return -1;

if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED))
return -2;

if (bt_debug & BT_DEBUG_MSG) {
printk(KERN_WARNING "+++++++++++++++++++++++++++++++++++++\n");
printk(KERN_WARNING "BT: write seq=0x%02X:", bt->seq);
for (i = 0; i < size; i ++) printk (" %02x", data[i]);
for (i = 0; i < size; i ++)
printk (" %02x", data[i]);
printk("\n");
}
bt->write_data[0] = size + 1; /* all data plus seq byte */
Expand Down Expand Up @@ -208,15 +210,18 @@ static int bt_get_result(struct si_sm_data *bt,
} else {
data[0] = bt->read_data[1];
data[1] = bt->read_data[3];
if (length < msg_len) bt->truncated = 1;
if (length < msg_len)
bt->truncated = 1;
if (bt->truncated) { /* can be set in read_all_bytes() */
data[2] = IPMI_ERR_MSG_TRUNCATED;
msg_len = 3;
} else memcpy(data + 2, bt->read_data + 4, msg_len - 2);
} else
memcpy(data + 2, bt->read_data + 4, msg_len - 2);

if (bt_debug & BT_DEBUG_MSG) {
printk (KERN_WARNING "BT: res (raw)");
for (i = 0; i < msg_len; i++) printk(" %02x", data[i]);
for (i = 0; i < msg_len; i++)
printk(" %02x", data[i]);
printk ("\n");
}
}
Expand All @@ -229,8 +234,10 @@ static int bt_get_result(struct si_sm_data *bt,

static void reset_flags(struct si_sm_data *bt)
{
if (BT_STATUS & BT_H_BUSY) BT_CONTROL(BT_H_BUSY);
if (BT_STATUS & BT_B_BUSY) BT_CONTROL(BT_B_BUSY);
if (BT_STATUS & BT_H_BUSY)
BT_CONTROL(BT_H_BUSY);
if (BT_STATUS & BT_B_BUSY)
BT_CONTROL(BT_B_BUSY);
BT_CONTROL(BT_CLR_WR_PTR);
BT_CONTROL(BT_SMS_ATN);
#ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION
Expand All @@ -239,7 +246,8 @@ static void reset_flags(struct si_sm_data *bt)
BT_CONTROL(BT_H_BUSY);
BT_CONTROL(BT_B2H_ATN);
BT_CONTROL(BT_CLR_RD_PTR);
for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++) BMC2HOST;
for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++)
BMC2HOST;
BT_CONTROL(BT_H_BUSY);
}
#endif
Expand All @@ -256,7 +264,8 @@ static inline void write_all_bytes(struct si_sm_data *bt)
printk (" %02x", bt->write_data[i]);
printk ("\n");
}
for (i = 0; i < bt->write_count; i++) HOST2BMC(bt->write_data[i]);
for (i = 0; i < bt->write_count; i++)
HOST2BMC(bt->write_data[i]);
}

static inline int read_all_bytes(struct si_sm_data *bt)
Expand All @@ -276,7 +285,8 @@ static inline int read_all_bytes(struct si_sm_data *bt)
bt->truncated = 1;
return 1; /* let next XACTION START clean it up */
}
for (i = 1; i <= bt->read_count; i++) bt->read_data[i] = BMC2HOST;
for (i = 1; i <= bt->read_count; i++)
bt->read_data[i] = BMC2HOST;
bt->read_count++; /* account for the length byte */

if (bt_debug & BT_DEBUG_MSG) {
Expand All @@ -293,7 +303,8 @@ static inline int read_all_bytes(struct si_sm_data *bt)
((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8)))
return 1;

if (bt_debug & BT_DEBUG_MSG) printk(KERN_WARNING "BT: bad packet: "
if (bt_debug & BT_DEBUG_MSG)
printk(KERN_WARNING "BT: bad packet: "
"want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n",
bt->write_data[1], bt->write_data[2], bt->write_data[3],
bt->read_data[1], bt->read_data[2], bt->read_data[3]);
Expand Down Expand Up @@ -357,7 +368,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
time);
bt->last_state = bt->state;

if (bt->state == BT_STATE_HOSED) return SI_SM_HOSED;
if (bt->state == BT_STATE_HOSED)
return SI_SM_HOSED;

if (bt->state != BT_STATE_IDLE) { /* do timeout test */

Expand All @@ -369,7 +381,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
/* FIXME: bt_event is sometimes called with time > BT_NORMAL_TIMEOUT
(noticed in ipmi_smic_sm.c January 2004) */

if ((time <= 0) || (time >= BT_NORMAL_TIMEOUT)) time = 100;
if ((time <= 0) || (time >= BT_NORMAL_TIMEOUT))
time = 100;
bt->timeout -= time;
if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) {
error_recovery(bt, "timed out");
Expand All @@ -391,20 +404,23 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
BT_CONTROL(BT_H_BUSY);
break;
}
if (status & BT_B2H_ATN) break;
if (status & BT_B2H_ATN)
break;
bt->state = BT_STATE_WRITE_BYTES;
return SI_SM_CALL_WITHOUT_DELAY; /* for logging */

case BT_STATE_WRITE_BYTES:
if (status & (BT_B_BUSY | BT_H2B_ATN)) break;
if (status & (BT_B_BUSY | BT_H2B_ATN))
break;
BT_CONTROL(BT_CLR_WR_PTR);
write_all_bytes(bt);
BT_CONTROL(BT_H2B_ATN); /* clears too fast to catch? */
bt->state = BT_STATE_WRITE_CONSUME;
return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */

case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */
if (status & (BT_H2B_ATN | BT_B_BUSY)) break;
if (status & (BT_H2B_ATN | BT_B_BUSY))
break;
bt->state = BT_STATE_B2H_WAIT;
/* fall through with status */

Expand All @@ -413,15 +429,18 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */

case BT_STATE_B2H_WAIT:
if (!(status & BT_B2H_ATN)) break;
if (!(status & BT_B2H_ATN))
break;

/* Assume ordered, uncached writes: no need to wait */
if (!(status & BT_H_BUSY)) BT_CONTROL(BT_H_BUSY); /* set */
if (!(status & BT_H_BUSY))
BT_CONTROL(BT_H_BUSY); /* set */
BT_CONTROL(BT_B2H_ATN); /* clear it, ACK to the BMC */
BT_CONTROL(BT_CLR_RD_PTR); /* reset the queue */
i = read_all_bytes(bt);
BT_CONTROL(BT_H_BUSY); /* clear */
if (!i) break; /* Try this state again */
if (!i) /* Try this state again */
break;
bt->state = BT_STATE_READ_END;
return SI_SM_CALL_WITHOUT_DELAY; /* for logging */

Expand All @@ -434,7 +453,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)

#ifdef MAKE_THIS_TRUE_IF_NECESSARY

if (status & BT_H_BUSY) break;
if (status & BT_H_BUSY)
break;
#endif
bt->seq++;
bt->state = BT_STATE_IDLE;
Expand All @@ -457,7 +477,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
break;

case BT_STATE_RESET3:
if (bt->timeout > 0) return SI_SM_CALL_WITH_DELAY;
if (bt->timeout > 0)
return SI_SM_CALL_WITH_DELAY;
bt->state = BT_STATE_RESTART; /* printk in debug modes */
break;

Expand All @@ -483,7 +504,8 @@ static int bt_detect(struct si_sm_data *bt)
but that's what you get from reading a bogus address, so we
test that first. The calling routine uses negative logic. */

if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) return 1;
if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF))
return 1;
reset_flags(bt);
return 0;
}
Expand Down
46 changes: 23 additions & 23 deletions drivers/char/ipmi/ipmi_msghandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct seq_table
do { \
seq = ((msgid >> 26) & 0x3f); \
seqid = (msgid & 0x3fffff); \
} while(0)
} while (0)

#define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff)

Expand Down Expand Up @@ -326,7 +326,7 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
down_read(&interfaces_sem);
down_write(&smi_watchers_sem);
list_add(&(watcher->link), &smi_watchers);
for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
if (ipmi_interfaces[i] != NULL) {
watcher->new_smi(i);
}
Expand Down Expand Up @@ -496,9 +496,9 @@ static int intf_next_seq(ipmi_smi_t intf,
int rv = 0;
unsigned int i;

for (i=intf->curr_seq;
for (i = intf->curr_seq;
(i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq;
i=(i+1)%IPMI_IPMB_NUM_SEQ)
i = (i+1)%IPMI_IPMB_NUM_SEQ)
{
if (! intf->seq_table[i].inuse)
break;
Expand Down Expand Up @@ -733,7 +733,7 @@ static int ipmi_destroy_user_nolock(ipmi_user_t user)

/* Remove the user from the interfaces sequence table. */
spin_lock_irqsave(&(user->intf->seq_lock), flags);
for (i=0; i<IPMI_IPMB_NUM_SEQ; i++) {
for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
if (user->intf->seq_table[i].inuse
&& (user->intf->seq_table[i].recv_msg->user == user))
{
Expand Down Expand Up @@ -1370,7 +1370,7 @@ static inline int i_ipmi_request(ipmi_user_t user,
#ifdef DEBUG_MSGING
{
int m;
for (m=0; m<smi_msg->data_size; m++)
for (m = 0; m < smi_msg->data_size; m++)
printk(" %2.2x", smi_msg->data[m]);
printk("\n");
}
Expand Down Expand Up @@ -1467,7 +1467,7 @@ static int ipmb_file_read_proc(char *page, char **start, off_t off,
int i;
int rv= 0;

for (i=0; i<IPMI_MAX_CHANNELS; i++)
for (i = 0; i < IPMI_MAX_CHANNELS; i++)
rv += sprintf(out+rv, "%x ", intf->channels[i].address);
out[rv-1] = '\n'; /* Replace the final space with a newline */
out[rv] = '\0';
Expand Down Expand Up @@ -1766,12 +1766,12 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
rv = -ENOMEM;

down_write(&interfaces_sem);
for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
if (ipmi_interfaces[i] == NULL) {
new_intf->intf_num = i;
new_intf->version_major = version_major;
new_intf->version_minor = version_minor;
for (j=0; j<IPMI_MAX_CHANNELS; j++) {
for (j = 0; j < IPMI_MAX_CHANNELS; j++) {
new_intf->channels[j].address
= IPMI_BMC_SLAVE_ADDR;
new_intf->channels[j].lun = 2;
Expand All @@ -1783,7 +1783,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
new_intf->handlers = handlers;
new_intf->send_info = send_info;
spin_lock_init(&(new_intf->seq_lock));
for (j=0; j<IPMI_IPMB_NUM_SEQ; j++) {
for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) {
new_intf->seq_table[j].inuse = 0;
new_intf->seq_table[j].seqid = 0;
}
Expand Down Expand Up @@ -1891,7 +1891,7 @@ static void clean_up_interface_data(ipmi_smi_t intf)
free_recv_msg_list(&(intf->waiting_events));
free_cmd_rcvr_list(&(intf->cmd_rcvrs));

for (i=0; i<IPMI_IPMB_NUM_SEQ; i++) {
for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
if ((intf->seq_table[i].inuse)
&& (intf->seq_table[i].recv_msg))
{
Expand All @@ -1910,7 +1910,7 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
down_write(&interfaces_sem);
if (list_empty(&(intf->users)))
{
for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
if (ipmi_interfaces[i] == intf) {
remove_proc_entries(intf);
spin_lock_irqsave(&interfaces_lock, flags);
Expand Down Expand Up @@ -2074,7 +2074,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
{
int m;
printk("Invalid command:");
for (m=0; m<msg->data_size; m++)
for (m = 0; m < msg->data_size; m++)
printk(" %2.2x", msg->data[m]);
printk("\n");
}
Expand Down Expand Up @@ -2469,7 +2469,7 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
#ifdef DEBUG_MSGING
int m;
printk("Recv:");
for (m=0; m<msg->rsp_size; m++)
for (m = 0; m < msg->rsp_size; m++)
printk(" %2.2x", msg->rsp[m]);
printk("\n");
#endif
Expand Down Expand Up @@ -2703,7 +2703,7 @@ smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
{
int m;
printk("Resend: ");
for (m=0; m<smi_msg->data_size; m++)
for (m = 0; m < smi_msg->data_size; m++)
printk(" %2.2x", smi_msg->data[m]);
printk("\n");
}
Expand All @@ -2724,7 +2724,7 @@ ipmi_timeout_handler(long timeout_period)
INIT_LIST_HEAD(&timeouts);

spin_lock(&interfaces_lock);
for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
intf = ipmi_interfaces[i];
if (intf == NULL)
continue;
Expand All @@ -2749,7 +2749,7 @@ ipmi_timeout_handler(long timeout_period)
have timed out, putting them in the timeouts
list. */
spin_lock_irqsave(&(intf->seq_lock), flags);
for (j=0; j<IPMI_IPMB_NUM_SEQ; j++) {
for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) {
struct seq_table *ent = &(intf->seq_table[j]);
if (!ent->inuse)
continue;
Expand Down Expand Up @@ -2789,7 +2789,7 @@ ipmi_timeout_handler(long timeout_period)
spin_unlock(&intf->counter_lock);
smi_msg = smi_from_recv_msg(intf,
ent->recv_msg, j, ent->seqid);
if(!smi_msg)
if (! smi_msg)
continue;

spin_unlock_irqrestore(&(intf->seq_lock),flags);
Expand Down Expand Up @@ -2820,7 +2820,7 @@ static void ipmi_request_event(void)
int i;

spin_lock(&interfaces_lock);
for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
intf = ipmi_interfaces[i];
if (intf == NULL)
continue;
Expand Down Expand Up @@ -2982,7 +2982,7 @@ static void send_panic_events(char *str)
recv_msg.done = dummy_recv_done_handler;

/* For every registered interface, send the event. */
for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
intf = ipmi_interfaces[i];
if (intf == NULL)
continue;
Expand All @@ -3009,7 +3009,7 @@ static void send_panic_events(char *str)
if (!str)
return;

for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
char *p = str;
struct ipmi_ipmb_addr *ipmb;
int j;
Expand Down Expand Up @@ -3149,7 +3149,7 @@ static int panic_event(struct notifier_block *this,
has_paniced = 1;

/* For every registered interface, set it to run to completion. */
for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
intf = ipmi_interfaces[i];
if (intf == NULL)
continue;
Expand Down Expand Up @@ -3180,7 +3180,7 @@ static int ipmi_init_msghandler(void)
printk(KERN_INFO "ipmi message handler version "
IPMI_DRIVER_VERSION "\n");

for (i=0; i<MAX_IPMI_INTERFACES; i++) {
for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
ipmi_interfaces[i] = NULL;
}

Expand Down
Loading

0 comments on commit e8b3361

Please sign in to comment.