Commit 9e87545f authored by Markus Lidel's avatar Markus Lidel Committed by Linus Torvalds
Browse files

[PATCH] I2O: second code cleanup of sparse warnings and unneeded syncronization



Changes:
 - Added header "core.h" for i2o_core.ko internal definitions
 - More sparse fixes
 - Changed display of TID's in sysfs attributes from XXX to 0xXXX
 - Use the right functions for accessing I/O and normal memory
 - Removed error handling of SCSI device errors and let the SCSI layer
   take care of it
 - Added new device / removed device handling to SCSI-OSM
 - Make status access volatile
 - Cleaned up activation of I2O controller
 - Removed unnecessary wmb() and rmb() calls
 - Use own struct i2o_io for I/O memory instead of struct i2o_dma

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 b2aaee33
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
/*
 *	I2O core internal declarations
 *
 *	Copyright (C) 2005	Markus Lidel <Markus.Lidel@shadowconnect.com>
 *
 *	This program is free software; you can redistribute it and/or modify it
 *	under the terms of the GNU General Public License as published by the
 *	Free Software Foundation; either version 2 of the License, or (at your
 *	option) any later version.
 *
 *	Fixes/additions:
 *		Markus Lidel <Markus.Lidel@shadowconnect.com>
 *			initial version.
 */

/* Exec-OSM */
extern struct bus_type i2o_bus_type;

extern struct i2o_driver i2o_exec_driver;
extern int i2o_exec_lct_get(struct i2o_controller *);

extern int __init i2o_exec_init(void);
extern void __exit i2o_exec_exit(void);

/* driver */
extern int i2o_driver_dispatch(struct i2o_controller *, u32);

extern int __init i2o_driver_init(void);
extern void __exit i2o_driver_exit(void);

/* PCI */
extern int __init i2o_pci_init(void);
extern void __exit i2o_pci_exit(void);

/* device */
extern void i2o_device_remove(struct i2o_device *);
extern int i2o_device_parse_lct(struct i2o_controller *);

extern int i2o_device_init(void);
extern void i2o_device_exit(void);

/* IOP */
extern struct i2o_controller *i2o_iop_alloc(void);
extern void i2o_iop_free(struct i2o_controller *);

extern int i2o_iop_add(struct i2o_controller *);
extern void i2o_iop_remove(struct i2o_controller *);

/* control registers relative to c->base */
#define I2O_IRQ_STATUS	0x30
#define I2O_IRQ_MASK	0x34
#define I2O_IN_PORT	0x40
#define I2O_OUT_PORT	0x44

#define I2O_IRQ_OUTBOUND_POST	0x00000008
+0 −3
Original line number Diff line number Diff line
@@ -4,8 +4,6 @@
#include <linux/pci.h>
#include <linux/i2o.h>

extern struct i2o_driver **i2o_drivers;
extern unsigned int i2o_max_drivers;
static void i2o_report_util_cmd(u8 cmd);
static void i2o_report_exec_cmd(u8 cmd);
static void i2o_report_fail_status(u8 req_status, u32 * msg);
@@ -23,7 +21,6 @@ void i2o_report_status(const char *severity, const char *str,
	u8 cmd = (msg[1] >> 24) & 0xFF;
	u8 req_status = (msg[4] >> 24) & 0xFF;
	u16 detailed_status = msg[4] & 0xFFFF;
	//struct i2o_driver *h = i2o_drivers[msg[2] & (i2o_max_drivers-1)];

	if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
		return;		// No status in this reply
+13 −9
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@
#include <linux/module.h>
#include <linux/i2o.h>
#include <linux/delay.h>

/* Exec OSM functions */
extern struct bus_type i2o_bus_type;
#include "core.h"

/**
 *	i2o_device_issue_claim - claim or release a device
@@ -293,12 +291,12 @@ int i2o_device_parse_lct(struct i2o_controller *c)
	}

	if (lct->table_size * 4 > c->dlct.len) {
		memcpy_fromio(c->lct, c->dlct.virt, c->dlct.len);
		memcpy(c->lct, c->dlct.virt, c->dlct.len);
		up(&c->lct_lock);
		return -EAGAIN;
	}

	memcpy_fromio(c->lct, c->dlct.virt, lct->table_size * 4);
	memcpy(c->lct, c->dlct.virt, lct->table_size * 4);

	lct = c->lct;

@@ -353,7 +351,7 @@ static ssize_t i2o_device_class_show_class_id(struct class_device *cd,
{
	struct i2o_device *dev = to_i2o_device(cd->dev);

	sprintf(buf, "%03x\n", dev->lct_data.class_id);
	sprintf(buf, "0x%03x\n", dev->lct_data.class_id);
	return strlen(buf) + 1;
};

@@ -368,7 +366,7 @@ static ssize_t i2o_device_class_show_tid(struct class_device *cd, char *buf)
{
	struct i2o_device *dev = to_i2o_device(cd->dev);

	sprintf(buf, "%03x\n", dev->lct_data.tid);
	sprintf(buf, "0x%03x\n", dev->lct_data.tid);
	return strlen(buf) + 1;
};

@@ -490,7 +488,7 @@ static int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
	if (rc == -ETIMEDOUT)
		return rc;

	memcpy_fromio(reslist, res.virt, res.len);
	memcpy(reslist, res.virt, res.len);
	i2o_dma_free(dev, &res);

	/* Query failed */
@@ -532,17 +530,23 @@ int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
		       void *buf, int buflen)
{
	u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field };
	u8 resblk[8 + buflen];	/* 8 bytes for header */
	u8 *resblk;		/* 8 bytes for header */
	int size;

	if (field == -1)	/* whole group */
		opblk[4] = -1;

	resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC);
	if (!resblk)
		return -ENOMEM;

	size = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk,
			      sizeof(opblk), resblk, buflen + 8);

	memcpy(buf, resblk + 8, buflen);	/* cut off header */

	kfree(resblk);

	if (size > buflen)
		return buflen;

+10 −14
Original line number Diff line number Diff line
@@ -17,11 +17,12 @@
#include <linux/module.h>
#include <linux/rwsem.h>
#include <linux/i2o.h>
#include "core.h"

#define OSM_NAME	"i2o"

/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */
unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
static unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
module_param_named(max_drivers, i2o_max_drivers, uint, 0);
MODULE_PARM_DESC(max_drivers, "maximum number of OSM's to support");

@@ -179,15 +180,10 @@ void i2o_driver_unregister(struct i2o_driver *drv)
int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
{
	struct i2o_driver *drv;
	struct i2o_message __iomem *msg = i2o_msg_out_to_virt(c, m);
	u32 context;
	struct i2o_message *msg = i2o_msg_out_to_virt(c, m);
	u32 context = le32_to_cpu(msg->u.s.icntxt);
	unsigned long flags;

	if(unlikely(!msg))
		return -EIO;

	context = readl(&msg->u.s.icntxt);

	if (unlikely(context >= i2o_max_drivers)) {
		osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
			 context);
@@ -204,11 +200,11 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
		return -EIO;
	}

	if ((readl(&msg->u.head[1]) >> 24) == I2O_CMD_UTIL_EVT_REGISTER) {
	if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_UTIL_EVT_REGISTER) {
		struct i2o_device *dev, *tmp;
		struct i2o_event *evt;
		u16 size;
		u16 tid = readl(&msg->u.head[1]) & 0xfff;
		u16 tid = le32_to_cpu(msg->u.head[1]) & 0xfff;

		osm_debug("event received from device %d\n", tid);

@@ -216,16 +212,16 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
			return -EIO;

		/* cut of header from message size (in 32-bit words) */
		size = (readl(&msg->u.head[0]) >> 16) - 5;
		size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5;

		evt = kmalloc(size * 4 + sizeof(*evt), GFP_ATOMIC | __GFP_ZERO);
		if (!evt)
			return -ENOMEM;

		evt->size = size;
		evt->tcntxt = readl(&msg->u.s.tcntxt);
		evt->event_indicator = readl(&msg->body[0]);
		memcpy_fromio(&evt->tcntxt, &msg->u.s.tcntxt, size * 4);
		evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt);
		evt->event_indicator = le32_to_cpu(msg->body[0]);
		memcpy(&evt->tcntxt, &msg->u.s.tcntxt, size * 4);

		list_for_each_entry_safe(dev, tmp, &c->devices, list)
		    if (dev->lct_data.tid == tid) {
+12 −15
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/i2o.h>
#include <linux/delay.h>
#include "core.h"

#define OSM_NAME "exec-osm"

@@ -37,9 +38,6 @@ struct i2o_driver i2o_exec_driver;

static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind);

/* Module internal functions from other sources */
extern int i2o_device_parse_lct(struct i2o_controller *);

/* global wait list for POST WAIT */
static LIST_HEAD(i2o_exec_wait_list);

@@ -50,7 +48,7 @@ struct i2o_exec_wait {
	u32 tcntxt;		/* transaction context from reply */
	int complete;		/* 1 if reply received otherwise 0 */
	u32 m;			/* message id */
	struct i2o_message __iomem *msg;	/* pointer to the reply message */
	struct i2o_message *msg;	/* pointer to the reply message */
	struct list_head list;	/* node in global wait list */
};

@@ -162,7 +160,7 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long
	barrier();

	if (wait->complete) {
		rc = readl(&wait->msg->body[0]) >> 24;
		rc = le32_to_cpu(wait->msg->body[0]) >> 24;
		i2o_flush_reply(c, wait->m);
		i2o_exec_wait_free(wait);
	} else {
@@ -202,8 +200,7 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long
 *	message must also be given back to the controller.
 */
static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
				      struct i2o_message __iomem *msg,
				      u32 context)
				      struct i2o_message *msg, u32 context)
{
	struct i2o_exec_wait *wait, *tmp;
	unsigned long flags;
@@ -378,11 +375,11 @@ static void i2o_exec_lct_modified(struct i2o_controller *c)
 *	code on failure and if the reply should be flushed.
 */
static int i2o_exec_reply(struct i2o_controller *c, u32 m,
			  struct i2o_message __iomem *msg)
			  struct i2o_message *msg)
{
	u32 context;

	if (readl(&msg->u.head[0]) & MSG_FAIL) {
	if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) {
		/*
		 * If Fail bit is set we must take the transaction context of
		 * the preserved message to find the right request again.
@@ -390,7 +387,7 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
		struct i2o_message __iomem *pmsg;
		u32 pm;

		pm = readl(&msg->body[3]);
		pm = le32_to_cpu(msg->body[3]);

		pmsg = i2o_msg_in_to_virt(c, pm);

@@ -401,12 +398,12 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
		/* Release the preserved msg */
		i2o_msg_nop(c, pm);
	} else
		context = readl(&msg->u.s.tcntxt);
		context = le32_to_cpu(msg->u.s.tcntxt);

	if (context & 0x80000000)
		return i2o_msg_post_wait_complete(c, m, msg, context);

	if ((readl(&msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
	if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
		struct work_struct *work;

		pr_debug("%s: LCT notify received\n", c->name);
@@ -443,7 +440,7 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
static void i2o_exec_event(struct i2o_event *evt)
{
	if (likely(evt->i2o_dev))
		osm_info("Event received from device: %d\n",
		osm_debug("Event received from device: %d\n",
			  evt->i2o_dev->lct_data.tid);
	kfree(evt);
};
Loading