aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/driver.c
diff options
context:
space:
mode:
authorMarkus Lidel <Markus.Lidel@shadowconnect.com>2005-06-24 01:02:14 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:05:28 -0400
commitf88e119c4b824a5017456fa094950d0f4092d96c (patch)
tree7a0fea02c195732e299a576fd22fd439fbc38bdd /drivers/message/i2o/driver.c
parent61fbfa8129c1771061a0e9f47747854293081c5b (diff)
[PATCH] I2O: first code cleanup of spare warnings and unused functions
Changes: - Removed unnecessary checking of NULL before calling kfree() - Make some functions static - Changed pr_debug() into osm_debug() - Use i2o_msg_in_to_virt() for getting a pointer to the message frame - Cleaned up some comments - Changed some le32_to_cpu() into readl() where necessary - Make error messages of OSM's look the same - Cleaned up error handling in i2o_block_end_request() - Removed unused error handling of failed messages in Block-OSM, which are not allowed by the I2O spec - Corrected the blocksize detection in i2o_block - Added hrt and lct sysfs-attribute to controller - Call done() function in SCSI-OSM after freeing DMA buffers - Removed unneeded variable for message size calculation in i2o_scsi_queuecommand() - Make some changes to remove sparse warnings - Reordered some functions - Cleaned up controller initialization - Replaced some magic numbers by defines - Removed unnecessary dma_sync_single_for_cpu() call on coherent DMA - Removed some unused fields in i2o_controller and removed some unused functions Signed-off-by: Markus Lidel <Markus.Lidel@shadowconnect.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/message/i2o/driver.c')
-rw-r--r--drivers/message/i2o/driver.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index c71e68f70e7d..bebdd509b5d8 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -18,7 +18,7 @@
18#include <linux/rwsem.h> 18#include <linux/rwsem.h>
19#include <linux/i2o.h> 19#include <linux/i2o.h>
20 20
21#define OSM_NAME "core" 21#define OSM_NAME "i2o"
22 22
23/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */ 23/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */
24unsigned int i2o_max_drivers = I2O_MAX_DRIVERS; 24unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
@@ -78,17 +78,16 @@ int i2o_driver_register(struct i2o_driver *drv)
78 int rc = 0; 78 int rc = 0;
79 unsigned long flags; 79 unsigned long flags;
80 80
81 pr_debug("i2o: Register driver %s\n", drv->name); 81 osm_debug("Register driver %s\n", drv->name);
82 82
83 if (drv->event) { 83 if (drv->event) {
84 drv->event_queue = create_workqueue(drv->name); 84 drv->event_queue = create_workqueue(drv->name);
85 if (!drv->event_queue) { 85 if (!drv->event_queue) {
86 printk(KERN_ERR "i2o: Could not initialize event queue " 86 osm_err("Could not initialize event queue for driver "
87 "for driver %s\n", drv->name); 87 "%s\n", drv->name);
88 return -EFAULT; 88 return -EFAULT;
89 } 89 }
90 pr_debug("i2o: Event queue initialized for driver %s\n", 90 osm_debug("Event queue initialized for driver %s\n", drv->name);
91 drv->name);
92 } else 91 } else
93 drv->event_queue = NULL; 92 drv->event_queue = NULL;
94 93
@@ -99,8 +98,8 @@ int i2o_driver_register(struct i2o_driver *drv)
99 98
100 for (i = 0; i2o_drivers[i]; i++) 99 for (i = 0; i2o_drivers[i]; i++)
101 if (i >= i2o_max_drivers) { 100 if (i >= i2o_max_drivers) {
102 printk(KERN_ERR "i2o: too many drivers registered, " 101 osm_err("too many drivers registered, increase "
103 "increase max_drivers\n"); 102 "max_drivers\n");
104 spin_unlock_irqrestore(&i2o_drivers_lock, flags); 103 spin_unlock_irqrestore(&i2o_drivers_lock, flags);
105 return -EFAULT; 104 return -EFAULT;
106 } 105 }
@@ -110,8 +109,7 @@ int i2o_driver_register(struct i2o_driver *drv)
110 109
111 spin_unlock_irqrestore(&i2o_drivers_lock, flags); 110 spin_unlock_irqrestore(&i2o_drivers_lock, flags);
112 111
113 pr_debug("i2o: driver %s gets context id %d\n", drv->name, 112 osm_debug("driver %s gets context id %d\n", drv->name, drv->context);
114 drv->context);
115 113
116 list_for_each_entry(c, &i2o_controllers, list) { 114 list_for_each_entry(c, &i2o_controllers, list) {
117 struct i2o_device *i2o_dev; 115 struct i2o_device *i2o_dev;
@@ -141,7 +139,7 @@ void i2o_driver_unregister(struct i2o_driver *drv)
141 struct i2o_controller *c; 139 struct i2o_controller *c;
142 unsigned long flags; 140 unsigned long flags;
143 141
144 pr_debug("i2o: unregister driver %s\n", drv->name); 142 osm_debug("unregister driver %s\n", drv->name);
145 143
146 driver_unregister(&drv->driver); 144 driver_unregister(&drv->driver);
147 145
@@ -161,7 +159,7 @@ void i2o_driver_unregister(struct i2o_driver *drv)
161 if (drv->event_queue) { 159 if (drv->event_queue) {
162 destroy_workqueue(drv->event_queue); 160 destroy_workqueue(drv->event_queue);
163 drv->event_queue = NULL; 161 drv->event_queue = NULL;
164 pr_debug("i2o: event queue removed for %s\n", drv->name); 162 osm_debug("event queue removed for %s\n", drv->name);
165 } 163 }
166}; 164};
167 165
@@ -178,15 +176,15 @@ void i2o_driver_unregister(struct i2o_driver *drv)
178 * on success and if the message should be flushed afterwords. Returns 176 * on success and if the message should be flushed afterwords. Returns
179 * negative error code on failure (the message will be flushed too). 177 * negative error code on failure (the message will be flushed too).
180 */ 178 */
181int i2o_driver_dispatch(struct i2o_controller *c, u32 m, 179int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
182 struct i2o_message __iomem *msg)
183{ 180{
184 struct i2o_driver *drv; 181 struct i2o_driver *drv;
182 struct i2o_message __iomem *msg = i2o_msg_out_to_virt(c, m);
185 u32 context = readl(&msg->u.s.icntxt); 183 u32 context = readl(&msg->u.s.icntxt);
186 184
187 if (unlikely(context >= i2o_max_drivers)) { 185 if (unlikely(context >= i2o_max_drivers)) {
188 printk(KERN_WARNING "%s: Spurious reply to unknown driver " 186 osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
189 "%d\n", c->name, readl(&msg->u.s.icntxt)); 187 context);
190 return -EIO; 188 return -EIO;
191 } 189 }
192 190
@@ -195,7 +193,8 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m,
195 spin_unlock(&i2o_drivers_lock); 193 spin_unlock(&i2o_drivers_lock);
196 194
197 if (unlikely(!drv)) { 195 if (unlikely(!drv)) {
198 osm_warn("Spurious reply to unknown driver %d\n", context); 196 osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
197 context);
199 return -EIO; 198 return -EIO;
200 } 199 }
201 200
@@ -207,6 +206,9 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m,
207 206
208 osm_debug("event received from device %d\n", tid); 207 osm_debug("event received from device %d\n", tid);
209 208
209 if (!drv->event)
210 return -EIO;
211
210 /* cut of header from message size (in 32-bit words) */ 212 /* cut of header from message size (in 32-bit words) */
211 size = (readl(&msg->u.head[0]) >> 16) - 5; 213 size = (readl(&msg->u.head[0]) >> 16) - 5;
212 214
@@ -231,8 +233,8 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m,
231 } 233 }
232 234
233 if (unlikely(!drv->reply)) { 235 if (unlikely(!drv->reply)) {
234 pr_debug("%s: Reply to driver %s, but no reply function" 236 osm_debug("%s: Reply to driver %s, but no reply function"
235 " defined!\n", c->name, drv->name); 237 " defined!\n", c->name, drv->name);
236 return -EIO; 238 return -EIO;
237 } 239 }
238 240
@@ -333,11 +335,11 @@ int __init i2o_driver_init(void)
333 if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) || 335 if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) ||
334 ((i2o_max_drivers ^ (i2o_max_drivers - 1)) != 336 ((i2o_max_drivers ^ (i2o_max_drivers - 1)) !=
335 (2 * i2o_max_drivers - 1))) { 337 (2 * i2o_max_drivers - 1))) {
336 printk(KERN_WARNING "i2o: max_drivers set to %d, but must be " 338 osm_warn("max_drivers set to %d, but must be >=2 and <= 64 and "
337 ">=2 and <= 64 and a power of 2\n", i2o_max_drivers); 339 "a power of 2\n", i2o_max_drivers);
338 i2o_max_drivers = I2O_MAX_DRIVERS; 340 i2o_max_drivers = I2O_MAX_DRIVERS;
339 } 341 }
340 printk(KERN_INFO "i2o: max drivers = %d\n", i2o_max_drivers); 342 osm_info("max drivers = %d\n", i2o_max_drivers);
341 343
342 i2o_drivers = 344 i2o_drivers =
343 kmalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL); 345 kmalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL);