Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bus-osm.c
Go to the documentation of this file.
1 /*
2  * Bus Adapter OSM
3  *
4  * Copyright (C) 2005 Markus Lidel <[email protected]>
5  *
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.
10  *
11  * Fixes/additions:
12  * Markus Lidel <[email protected]>
13  * initial version.
14  */
15 
16 #include <linux/module.h>
17 #include <linux/i2o.h>
18 
19 #define OSM_NAME "bus-osm"
20 #define OSM_VERSION "1.317"
21 #define OSM_DESCRIPTION "I2O Bus Adapter OSM"
22 
23 static struct i2o_driver i2o_bus_driver;
24 
25 /* Bus OSM class handling definition */
26 static struct i2o_class_id i2o_bus_class_id[] = {
29 };
30 
40 static int i2o_bus_scan(struct i2o_device *dev)
41 {
42  struct i2o_message *msg;
43 
45  if (IS_ERR(msg))
46  return -ETIMEDOUT;
47 
49  msg->u.head[1] =
50  cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.
51  tid);
52 
53  return i2o_msg_post_wait(dev->iop, msg, 60);
54 };
55 
65 static ssize_t i2o_bus_store_scan(struct device *d,
66  struct device_attribute *attr,
67  const char *buf, size_t count)
68 {
69  struct i2o_device *i2o_dev = to_i2o_device(d);
70  int rc;
71 
72  if ((rc = i2o_bus_scan(i2o_dev)))
73  osm_warn("bus scan failed %d\n", rc);
74 
75  return count;
76 }
77 
78 /* Bus Adapter OSM device attributes */
79 static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
80 
90 static int i2o_bus_probe(struct device *dev)
91 {
92  struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
93  int rc;
94 
95  rc = device_create_file(dev, &dev_attr_scan);
96  if (rc)
97  goto err_out;
98 
99  osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
100 
101  return 0;
102 
103 err_out:
104  put_device(dev);
105  return rc;
106 };
107 
114 static int i2o_bus_remove(struct device *dev)
115 {
116  struct i2o_device *i2o_dev = to_i2o_device(dev);
117 
118  device_remove_file(dev, &dev_attr_scan);
119 
120  put_device(dev);
121 
122  osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid);
123 
124  return 0;
125 };
126 
127 /* Bus Adapter OSM driver struct */
128 static struct i2o_driver i2o_bus_driver = {
129  .name = OSM_NAME,
130  .classes = i2o_bus_class_id,
131  .driver = {
132  .probe = i2o_bus_probe,
133  .remove = i2o_bus_remove,
134  },
135 };
136 
144 static int __init i2o_bus_init(void)
145 {
146  int rc;
147 
149 
150  /* Register Bus Adapter OSM into I2O core */
151  rc = i2o_driver_register(&i2o_bus_driver);
152  if (rc) {
153  osm_err("Could not register Bus Adapter OSM\n");
154  return rc;
155  }
156 
157  return 0;
158 };
159 
165 static void __exit i2o_bus_exit(void)
166 {
167  i2o_driver_unregister(&i2o_bus_driver);
168 };
169 
170 MODULE_AUTHOR("Markus Lidel <[email protected]>");
171 MODULE_LICENSE("GPL");
174 
175 module_init(i2o_bus_init);
176 module_exit(i2o_bus_exit);