Commit f21a3a38 authored by Markus Lidel's avatar Markus Lidel Committed by Linus Torvalds

[PATCH] i2o: code beautifying and cleanup

- added KERN_* to printk where it was missing (original from Alan Cox)

- removed unused code which was commented out already (original from Alan
  Cox)

- make error messages more sane in i2o_block (original from Alan Cox)
Signed-off-by: default avatarMarkus Lidel <Markus.Lidel@shadowconnect.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c94cb2c1
This diff is collapsed.
......@@ -18,7 +18,6 @@
#include <linux/rwsem.h>
#include <linux/i2o.h>
/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */
unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
module_param_named(max_drivers, i2o_max_drivers, uint, 0);
......@@ -146,7 +145,7 @@ void i2o_driver_unregister(struct i2o_driver *drv)
struct i2o_device *i2o_dev;
list_for_each_entry(i2o_dev, &c->devices, list)
i2o_driver_notify_device_remove(drv, i2o_dev);
i2o_driver_notify_device_remove(drv, i2o_dev);
i2o_driver_notify_controller_remove(drv, c);
}
......@@ -246,14 +245,15 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m,
* Send notifications to all registered drivers that a new controller was
* added.
*/
void i2o_driver_notify_controller_add_all(struct i2o_controller *c) {
void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
{
int i;
struct i2o_driver *drv;
for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
for (i = 0; i < I2O_MAX_DRIVERS; i++) {
drv = i2o_drivers[i];
if(drv)
if (drv)
i2o_driver_notify_controller_add(drv, c);
}
}
......@@ -265,14 +265,15 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c) {
* Send notifications to all registered drivers that a controller was
* removed.
*/
void i2o_driver_notify_controller_remove_all(struct i2o_controller *c) {
void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
{
int i;
struct i2o_driver *drv;
for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
for (i = 0; i < I2O_MAX_DRIVERS; i++) {
drv = i2o_drivers[i];
if(drv)
if (drv)
i2o_driver_notify_controller_remove(drv, c);
}
}
......@@ -283,14 +284,15 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c) {
*
* Send notifications to all registered drivers that a device was added.
*/
void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev) {
void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
{
int i;
struct i2o_driver *drv;
for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
for (i = 0; i < I2O_MAX_DRIVERS; i++) {
drv = i2o_drivers[i];
if(drv)
if (drv)
i2o_driver_notify_device_add(drv, i2o_dev);
}
}
......@@ -301,14 +303,15 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev) {
*
* Send notifications to all registered drivers that a device was removed.
*/
void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev) {
void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev)
{
int i;
struct i2o_driver *drv;
for(i = 0; i < I2O_MAX_DRIVERS; i ++) {
for (i = 0; i < I2O_MAX_DRIVERS; i++) {
drv = i2o_drivers[i];
if(drv)
if (drv)
i2o_driver_notify_device_remove(drv, i2o_dev);
}
}
......
......@@ -420,7 +420,6 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
struct i2o_message *pmsg;
u32 pm;
printk(KERN_WARNING "FAIL");
/*
* FAILed message from controller
* We increment the error count and abort it
......@@ -538,12 +537,12 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
* Don't stick a supertrak100 into cache aggressive modes
*/
printk(KERN_ERR "\n/dev/%s error: %s", dev->gd->disk_name,
printk(KERN_ERR "/dev/%s error: %s", dev->gd->disk_name,
bsa_errors[readl(&msg->body[0]) & 0xffff]);
if (readl(&msg->body[0]) & 0x00ff0000)
printk(" - DDM attempted %d retries",
printk(KERN_ERR " - DDM attempted %d retries",
(readl(&msg->body[0]) >> 16) & 0x00ff);
printk(".\n");
printk(KERN_ERR ".\n");
req->errors++;
} else
req->errors = 0;
......@@ -563,7 +562,7 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
i2o_block_sglist_free(ireq);
i2o_block_request_free(ireq);
} else
printk(KERN_ERR "still remaining chunks\n");
printk(KERN_ERR "i2o_block: still remaining chunks\n");
return 1;
};
......@@ -573,174 +572,6 @@ static void i2o_block_event(struct i2o_event *evt)
printk(KERN_INFO "block-osm: event received\n");
};
#if 0
static int i2o_block_event(void *dummy)
{
unsigned int evt;
unsigned long flags;
struct i2o_block_device *dev;
int unit;
//The only event that has data is the SCSI_SMART event.
struct i2o_reply {
u32 header[4];
u32 evt_indicator;
u8 ASC;
u8 ASCQ;
u16 pad;
u8 data[16];
} *evt_local;
daemonize("i2oblock");
allow_signal(SIGKILL);
evt_running = 1;
while (1) {
if (down_interruptible(&i2ob_evt_sem)) {
evt_running = 0;
printk("exiting...");
break;
}
/*
* Keep another CPU/interrupt from overwriting the
* message while we're reading it
*
* We stuffed the unit in the TxContext and grab the event mask
* None of the BSA we care about events have EventData
*/
spin_lock_irqsave(&i2ob_evt_lock, flags);
evt_local = (struct i2o_reply *)evt_msg;
spin_unlock_irqrestore(&i2ob_evt_lock, flags);
unit = le32_to_cpu(evt_local->header[3]);
evt = le32_to_cpu(evt_local->evt_indicator);
dev = &i2o_blk_dev[unit];
switch (evt) {
/*
* New volume loaded on same TID, so we just re-install.
* The TID/controller don't change as it is the same
* I2O device. It's just new media that we have to
* rescan.
*/
case I2O_EVT_IND_BSA_VOLUME_LOAD:
{
i2ob_install_device(dev->i2o_device->iop,
dev->i2o_device, unit);
add_disk(dev->gendisk);
break;
}
/*
* No media, so set all parameters to 0 and set the media
* change flag. The I2O device is still valid, just doesn't
* have media, so we don't want to clear the controller or
* device pointer.
*/
case I2O_EVT_IND_BSA_VOLUME_UNLOAD:
{
struct gendisk *p = dev->gendisk;
blk_queue_max_sectors(dev->gendisk->queue, 0);
del_gendisk(p);
put_disk(p);
dev->gendisk = NULL;
dev->media_change_flag = 1;
break;
}
case I2O_EVT_IND_BSA_VOLUME_UNLOAD_REQ:
printk(KERN_WARNING
"%s: Attempt to eject locked media\n",
dev->i2o_device->dev_name);
break;
/*
* The capacity has changed and we are going to be
* updating the max_sectors and other information
* about this disk. We try a revalidate first. If
* the block device is in use, we don't want to
* do that as there may be I/Os bound for the disk
* at the moment. In that case we read the size
* from the device and update the information ourselves
* and the user can later force a partition table
* update through an ioctl.
*/
case I2O_EVT_IND_BSA_CAPACITY_CHANGE:
{
u64 size;
if (i2ob_query_device(dev, 0x0004, 0, &size, 8)
!= 0)
i2ob_query_device(dev, 0x0000, 4, &size,
8);
spin_lock_irqsave(dev->req_queue->queue_lock,
flags);
set_capacity(dev->gendisk, size >> 9);
spin_unlock_irqrestore(dev->req_queue->
queue_lock, flags);
break;
}
/*
* We got a SCSI SMART event, we just log the relevant
* information and let the user decide what they want
* to do with the information.
*/
case I2O_EVT_IND_BSA_SCSI_SMART:
{
char buf[16];
printk(KERN_INFO
"I2O Block: %s received a SCSI SMART Event\n",
dev->i2o_device->dev_name);
evt_local->data[16] = '\0';
sprintf(buf, "%s", &evt_local->data[0]);
printk(KERN_INFO " Disk Serial#:%s\n",
buf);
printk(KERN_INFO " ASC 0x%02x \n",
evt_local->ASC);
printk(KERN_INFO " ASCQ 0x%02x \n",
evt_local->ASCQ);
break;
}
/*
* Non event
*/
case 0:
break;
/*
* An event we didn't ask for. Call the card manufacturer
* and tell them to fix their firmware :)
*/
case 0x20:
/*
* If a promise card reports 0x20 event then the brown stuff
* hit the fan big time. The card seems to recover but loses
* the pending writes. Deeply ungood except for testing fsck
*/
if (dev->i2o_device->iop->promise)
panic
("I2O controller firmware failed. Reboot and force a filesystem check.\n");
default:
printk(KERN_INFO
"%s: Received event 0x%X we didn't register for\n"
KERN_INFO
" Blame the I2O card manufacturer 8)\n",
dev->i2o_device->dev_name, evt);
break;
}
};
complete_and_exit(&i2ob_thread_dead, 0);
return 0;
}
#endif
/*
* SCSI-CAM for ioctl geometry mapping
* Duplicated with SCSI - this should be moved into somewhere common
......
......@@ -74,96 +74,6 @@ struct i2o_cfg_info {
static struct i2o_cfg_info *open_files = NULL;
static ulong i2o_cfg_info_id = 0;
#if 0
/*
* This is the callback for any message we have posted. The message itself
* will be returned to the message pool when we return from the IRQ
*
* This runs in irq context so be short and sweet.
*/
static void i2o_cfg_reply(struct i2o_handler *h, struct i2o_controller *c,
struct i2o_message *m)
{
u32 *msg = (u32 *) m;
if (msg[0] & MSG_FAIL) {
u32 *preserved_msg = (u32 *) (c->msg_virt + msg[7]);
printk(KERN_ERR "i2o_config: IOP failed to process the msg.\n");
/* Release the preserved msg frame by resubmitting it as a NOP */
preserved_msg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
preserved_msg[1] = I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | 0;
preserved_msg[2] = 0;
i2o_post_message(c, msg[7]);
}
if (msg[4] >> 24) // ReqStatus != SUCCESS
i2o_report_status(KERN_INFO, "i2o_config", msg);
if (m->function == I2O_CMD_UTIL_EVT_REGISTER) {
struct i2o_cfg_info *inf;
for (inf = open_files; inf; inf = inf->next)
if (inf->q_id == i2o_cntxt_list_get(c, msg[3]))
break;
//
// If this is the case, it means that we're getting
// events for a file descriptor that's been close()'d
// w/o the user unregistering for events first.
// The code currently assumes that the user will
// take care of unregistering for events before closing
// a file.
//
// TODO:
// Should we track event registartion and deregister
// for events when a file is close()'d so this doesn't
// happen? That would get rid of the search through
// the linked list since file->private_data could point
// directly to the i2o_config_info data structure...but
// it would mean having all sorts of tables to track
// what each file is registered for...I think the
// current method is simpler. - DS
//
if (!inf)
return;
inf->event_q[inf->q_in].id.iop = c->unit;
inf->event_q[inf->q_in].id.tid = m->target_tid;
inf->event_q[inf->q_in].id.evt_mask = msg[4];
//
// Data size = msg size - reply header
//
inf->event_q[inf->q_in].data_size = (m->size - 5) * 4;
if (inf->event_q[inf->q_in].data_size)
memcpy(inf->event_q[inf->q_in].evt_data,
(unsigned char *)(msg + 5),
inf->event_q[inf->q_in].data_size);
spin_lock(&i2o_config_lock);
MODINC(inf->q_in, I2O_EVT_Q_LEN);
if (inf->q_len == I2O_EVT_Q_LEN) {
MODINC(inf->q_out, I2O_EVT_Q_LEN);
inf->q_lost++;
} else {
// Keep I2OEVTGET on another CPU from touching this
inf->q_len++;
}
spin_unlock(&i2o_config_lock);
// printk(KERN_INFO "File %p w/id %d has %d events\n",
// inf->fp, inf->q_id, inf->q_len);
kill_fasync(&inf->fasync, SIGIO, POLL_IN);
}
return;
}
#endif
/*
* Each of these describes an i2o message handler. They are
* multiplexed by the i2o_core code
......@@ -388,7 +298,7 @@ static int i2o_cfg_swdl(unsigned long arg)
writel(0xD0000000 | fragsize, &msg->body[3]);
writel(buffer.phys, &msg->body[4]);
// printk("i2o_config: swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
// printk(KERN_INFO "i2o_config: swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
status = i2o_msg_post_wait_mem(c, m, 60, &buffer);
if (status != -ETIMEDOUT)
......@@ -461,7 +371,7 @@ static int i2o_cfg_swul(unsigned long arg)
writel(0xD0000000 | fragsize, &msg->body[3]);
writel(buffer.phys, &msg->body[4]);
// printk("i2o_config: swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
// printk(KERN_INFO "i2o_config: swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
status = i2o_msg_post_wait_mem(c, m, 60, &buffer);
if (status != I2O_POST_WAIT_OK) {
......
......@@ -938,11 +938,6 @@ int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
seq_printf(seq, " ");
}
#if 0
if (c->i2oversion == 0x02)
seq_printf(seq, "%-d", dst->module_state);
#endif
seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
seq_printf(seq, "%-#8x", dst->module_id);
seq_printf(seq, "%-29s", chtostr(dst->module_name_version, 28));
......@@ -950,10 +945,6 @@ int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
seq_printf(seq, "%8d ", dst->module_size);
seq_printf(seq, "%8d ", dst->mpb_size);
seq_printf(seq, "0x%04x", dst->module_flags);
#if 0
if (c->i2oversion == 0x02)
seq_printf(seq, "%d", dst->notification_level);
#endif
seq_printf(seq, "\n");
}
......
......@@ -274,53 +274,6 @@ static const char *i2o_scsi_info(struct Scsi_Host *SChost)
return hostdata->iop->name;
}
#if 0
/**
* i2o_retry_run - retry on timeout
* @f: unused
*
* Retry congested frames. This actually needs pushing down into
* i2o core. We should only bother the OSM with this when we can't
* queue and retry the frame. Or perhaps we should call the OSM
* and its default handler should be this in the core, and this
* call a 2nd "I give up" handler in the OSM ?
*/
static void i2o_retry_run(unsigned long f)
{
int i;
unsigned long flags;
spin_lock_irqsave(&retry_lock, flags);
for (i = 0; i < retry_ct; i++)
i2o_post_message(retry_ctrl[i], virt_to_bus(retry[i]));
retry_ct = 0;
spin_unlock_irqrestore(&retry_lock, flags);
}
/**
* flush_pending - empty the retry queue
*
* Turn each of the pending commands into a NOP and post it back
* to the controller to clear it.
*/
static void flush_pending(void)
{
int i;
unsigned long flags;
spin_lock_irqsave(&retry_lock, flags);
for (i = 0; i < retry_ct; i++) {
retry[i][0] &= ~0xFFFFFF;
retry[i][0] |= I2O_CMD_UTIL_NOP << 24;
i2o_post_message(retry_ctrl[i], virt_to_bus(retry[i]));
}
retry_ct = 0;
spin_unlock_irqrestore(&retry_lock, flags);
}
#endif
/**
* i2o_scsi_reply - SCSI OSM message reply handler
* @c: controller issuing the reply
......@@ -353,27 +306,26 @@ static int i2o_scsi_reply(struct i2o_controller *c, u32 m,
pmsg = c->in_queue.virt + pm;
printk("IOP fail.\n");
printk("From %d To %d Cmd %d.\n",
printk(KERN_ERR "IOP fail.\n");
printk(KERN_ERR "From %d To %d Cmd %d.\n",
(msg->u.head[1] >> 12) & 0xFFF,
msg->u.head[1] & 0xFFF, msg->u.head[1] >> 24);
printk("Failure Code %d.\n", msg->body[0] >> 24);
printk(KERN_ERR "Failure Code %d.\n", msg->body[0] >> 24);
if (msg->body[0] & (1 << 16))
printk("Format error.\n");
printk(KERN_ERR "Format error.\n");
if (msg->body[0] & (1 << 17))
printk("Path error.\n");
printk(KERN_ERR "Path error.\n");
if (msg->body[0] & (1 << 18))
printk("Path State.\n");
printk(KERN_ERR "Path State.\n");
if (msg->body[0] & (1 << 18))
printk("Congestion.\n");
printk(KERN_ERR "Congestion.\n");
printk("Failing message is %p.\n", pmsg);
printk(KERN_DEBUG "Failing message is %p.\n", pmsg);
cmd = i2o_cntxt_list_get(c, readl(&pmsg->u.s.tcntxt));
if (!cmd)
return 1;
printk("Aborted %ld\n", cmd->serial_number);
cmd->result = DID_ERROR << 16;
cmd->scsi_done(cmd);
......@@ -416,10 +368,11 @@ static int i2o_scsi_reply(struct i2o_controller *c, u32 m,
int i;
printk(KERN_ERR "SCSI: underflow 0x%08X 0x%08X"
"\n", count, cmd->underflow);
printk("Cmd: ");
printk(KERN_DEBUG "Cmd: ");
for (i = 0; i < 15; i++)
printk("%02X ", cmd->cmnd[i]);
printk(".\n");
printk(KERN_DEBUG "%02X ",
cmd->cmnd[i]);
printk(KERN_DEBUG ".\n");
cmd->result = (DID_ERROR << 16);
}
break;
......@@ -517,8 +470,7 @@ void i2o_scsi_notify_controller_add(struct i2o_controller *c)
rc = scsi_add_host(i2o_shost->scsi_host, &c->device);
if (rc) {
printk(KERN_ERR "scsi-osm: Could not add SCSI "
"host\n");
printk(KERN_ERR "scsi-osm: Could not add SCSI " "host\n");
scsi_host_put(i2o_shost->scsi_host);
return;
}
......
......@@ -117,7 +117,7 @@ u32 i2o_msg_get_wait(struct i2o_controller *c, struct i2o_message **msg,
*
* Returns context id > 0 on success or 0 on failure.
*/
u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr)
u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
{
struct i2o_context_list_element *entry;
unsigned long flags;
......@@ -162,7 +162,7 @@ u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr)
*
* Returns context id on succes or 0 on failure.
*/
u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr)
u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr)
{
struct i2o_context_list_element *entry;
u32 context = 0;
......@@ -691,10 +691,11 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
res->flags = IORESOURCE_MEM;
res->start = 0;
res->end = 0;
printk("%s: requires private memory resources.\n", c->name);
printk(KERN_INFO "%s: requires private memory resources.\n",
c->name);
root = pci_find_parent_resource(c->pdev, res);
if (root == NULL)
printk("Can't find parent resource!\n");
printk(KERN_WARNING "Can't find parent resource!\n");
if (root && allocate_resource(root, res, sb->desired_mem_size, sb->desired_mem_size, sb->desired_mem_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */
NULL, NULL) >= 0) {
c->mem_alloc = 1;
......@@ -712,10 +713,11 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
res->flags = IORESOURCE_IO;
res->start = 0;
res->end = 0;
printk("%s: requires private memory resources.\n", c->name);
printk(KERN_INFO "%s: requires private memory resources.\n",
c->name);
root = pci_find_parent_resource(c->pdev, res);
if (root == NULL)
printk("Can't find parent resource!\n");
printk(KERN_WARNING "Can't find parent resource!\n");
if (root && allocate_resource(root, res, sb->desired_io_size, sb->desired_io_size, sb->desired_io_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */
NULL, NULL) >= 0) {
c->io_alloc = 1;
......
......@@ -138,13 +138,13 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
* If we know what card it is, set the size
* correctly. Code is taken from dpt_i2o.c
*/
if(pdev->device == 0xa501) {
if(pdev->subsystem_device >= 0xc032 &&
pdev->subsystem_device <= 0xc03b) {
if(c->base.len > 0x400000)
if (pdev->device == 0xa501) {
if (pdev->subsystem_device >= 0xc032 &&
pdev->subsystem_device <= 0xc03b) {
if (c->base.len > 0x400000)
c->base.len = 0x400000;
} else {
if(c->base.len > 0x100000)
if (c->base.len > 0x100000)
c->base.len = 0x100000;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment