ieee1394: add preprocessor constant for invalid csr address
[linux-2.6/mini2440.git] / drivers / message / i2o / bus-osm.c
blobac06f10c54ec1416c1a9b75fdbde20e23051be22
1 /*
2 * Bus Adapter OSM
4 * Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
11 * Fixes/additions:
12 * Markus Lidel <Markus.Lidel@shadowconnect.com>
13 * initial version.
16 #include <linux/module.h>
17 #include <linux/i2o.h>
19 #define OSM_NAME "bus-osm"
20 #define OSM_VERSION "1.317"
21 #define OSM_DESCRIPTION "I2O Bus Adapter OSM"
23 static struct i2o_driver i2o_bus_driver;
25 /* Bus OSM class handling definition */
26 static struct i2o_class_id i2o_bus_class_id[] = {
27 {I2O_CLASS_BUS_ADAPTER},
28 {I2O_CLASS_END}
31 /**
32 * i2o_bus_scan - Scan the bus for new devices
33 * @dev: I2O device of the bus, which should be scanned
35 * Scans the bus dev for new / removed devices. After the scan a new LCT
36 * will be fetched automatically.
38 * Returns 0 on success or negative error code on failure.
40 static int i2o_bus_scan(struct i2o_device *dev)
42 struct i2o_message *msg;
44 msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
45 if (IS_ERR(msg))
46 return -ETIMEDOUT;
48 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
49 msg->u.head[1] =
50 cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.
51 tid);
53 return i2o_msg_post_wait(dev->iop, msg, 60);
56 /**
57 * i2o_bus_store_scan - Scan the I2O Bus Adapter
58 * @d: device which should be scanned
60 * Returns count.
62 static ssize_t i2o_bus_store_scan(struct device *d,
63 struct device_attribute *attr,
64 const char *buf, size_t count)
66 struct i2o_device *i2o_dev = to_i2o_device(d);
67 int rc;
69 if ((rc = i2o_bus_scan(i2o_dev)))
70 osm_warn("bus scan failed %d\n", rc);
72 return count;
75 /* Bus Adapter OSM device attributes */
76 static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
78 /**
79 * i2o_bus_probe - verify if dev is a I2O Bus Adapter device and install it
80 * @dev: device to verify if it is a I2O Bus Adapter device
82 * Because we want all Bus Adapters always return 0.
84 * Returns 0.
86 static int i2o_bus_probe(struct device *dev)
88 struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
90 device_create_file(dev, &dev_attr_scan);
92 osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
94 return 0;
97 /**
98 * i2o_bus_remove - remove the I2O Bus Adapter device from the system again
99 * @dev: I2O Bus Adapter device which should be removed
101 * Always returns 0.
103 static int i2o_bus_remove(struct device *dev)
105 struct i2o_device *i2o_dev = to_i2o_device(dev);
107 device_remove_file(dev, &dev_attr_scan);
109 put_device(dev);
111 osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid);
113 return 0;
116 /* Bus Adapter OSM driver struct */
117 static struct i2o_driver i2o_bus_driver = {
118 .name = OSM_NAME,
119 .classes = i2o_bus_class_id,
120 .driver = {
121 .probe = i2o_bus_probe,
122 .remove = i2o_bus_remove,
127 * i2o_bus_init - Bus Adapter OSM initialization function
129 * Only register the Bus Adapter OSM in the I2O core.
131 * Returns 0 on success or negative error code on failure.
133 static int __init i2o_bus_init(void)
135 int rc;
137 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
139 /* Register Bus Adapter OSM into I2O core */
140 rc = i2o_driver_register(&i2o_bus_driver);
141 if (rc) {
142 osm_err("Could not register Bus Adapter OSM\n");
143 return rc;
146 return 0;
150 * i2o_bus_exit - Bus Adapter OSM exit function
152 * Unregisters Bus Adapter OSM from I2O core.
154 static void __exit i2o_bus_exit(void)
156 i2o_driver_unregister(&i2o_bus_driver);
159 MODULE_AUTHOR("Markus Lidel <Markus.Lidel@shadowconnect.com>");
160 MODULE_LICENSE("GPL");
161 MODULE_DESCRIPTION(OSM_DESCRIPTION);
162 MODULE_VERSION(OSM_VERSION);
164 module_init(i2o_bus_init);
165 module_exit(i2o_bus_exit);