aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-01-22 16:45:38 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-02-07 13:37:11 -0500
commit2943ecf2ed32632473c06f1975db47a7aa98c10f (patch)
tree94bbae37d42f3e03fd8fc4a86767f5815a1318fb
parent873733188a019acdb7fa253011cbdc0a8afd97f3 (diff)
Driver core: convert SPI code to use struct device
Converts from using struct "class_device" to "struct device" making everything show up properly in /sys/devices/ with symlinks from the /sys/class directory. Cc: <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/spi/pxa2xx_spi.c2
-rw-r--r--drivers/spi/spi.c32
-rw-r--r--drivers/spi/spi_bitbang.c6
-rw-r--r--drivers/spi/spi_butterfly.c4
-rw-r--r--include/linux/spi/spi.h10
5 files changed, 27 insertions, 27 deletions
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 8b41f9cc2560..dccdc50b0296 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1234,7 +1234,7 @@ static int init_queue(struct driver_data *drv_data)
1234 1234
1235 INIT_WORK(&drv_data->pump_messages, pump_messages); 1235 INIT_WORK(&drv_data->pump_messages, pump_messages);
1236 drv_data->workqueue = create_singlethread_workqueue( 1236 drv_data->workqueue = create_singlethread_workqueue(
1237 drv_data->master->cdev.dev->bus_id); 1237 drv_data->master->dev.parent->bus_id);
1238 if (drv_data->workqueue == NULL) 1238 if (drv_data->workqueue == NULL)
1239 return -EBUSY; 1239 return -EBUSY;
1240 1240
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 6307428d2c94..35d8c01b42ac 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -193,7 +193,7 @@ struct spi_device *__init_or_module
193spi_new_device(struct spi_master *master, struct spi_board_info *chip) 193spi_new_device(struct spi_master *master, struct spi_board_info *chip)
194{ 194{
195 struct spi_device *proxy; 195 struct spi_device *proxy;
196 struct device *dev = master->cdev.dev; 196 struct device *dev = &master->dev;
197 int status; 197 int status;
198 198
199 /* NOTE: caller did any chip->bus_num checks necessary */ 199 /* NOTE: caller did any chip->bus_num checks necessary */
@@ -215,7 +215,7 @@ spi_new_device(struct spi_master *master, struct spi_board_info *chip)
215 proxy->modalias = chip->modalias; 215 proxy->modalias = chip->modalias;
216 216
217 snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id, 217 snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id,
218 "%s.%u", master->cdev.class_id, 218 "%s.%u", master->dev.bus_id,
219 chip->chip_select); 219 chip->chip_select);
220 proxy->dev.parent = dev; 220 proxy->dev.parent = dev;
221 proxy->dev.bus = &spi_bus_type; 221 proxy->dev.bus = &spi_bus_type;
@@ -290,7 +290,7 @@ static void __init_or_module
290scan_boardinfo(struct spi_master *master) 290scan_boardinfo(struct spi_master *master)
291{ 291{
292 struct boardinfo *bi; 292 struct boardinfo *bi;
293 struct device *dev = master->cdev.dev; 293 struct device *dev = master->dev.parent;
294 294
295 down(&board_lock); 295 down(&board_lock);
296 list_for_each_entry(bi, &board_list, list) { 296 list_for_each_entry(bi, &board_list, list) {
@@ -319,18 +319,18 @@ scan_boardinfo(struct spi_master *master)
319 319
320/*-------------------------------------------------------------------------*/ 320/*-------------------------------------------------------------------------*/
321 321
322static void spi_master_release(struct class_device *cdev) 322static void spi_master_release(struct device *dev)
323{ 323{
324 struct spi_master *master; 324 struct spi_master *master;
325 325
326 master = container_of(cdev, struct spi_master, cdev); 326 master = container_of(dev, struct spi_master, dev);
327 kfree(master); 327 kfree(master);
328} 328}
329 329
330static struct class spi_master_class = { 330static struct class spi_master_class = {
331 .name = "spi_master", 331 .name = "spi_master",
332 .owner = THIS_MODULE, 332 .owner = THIS_MODULE,
333 .release = spi_master_release, 333 .dev_release = spi_master_release,
334}; 334};
335 335
336 336
@@ -364,9 +364,9 @@ spi_alloc_master(struct device *dev, unsigned size)
364 if (!master) 364 if (!master)
365 return NULL; 365 return NULL;
366 366
367 class_device_initialize(&master->cdev); 367 device_initialize(&master->dev);
368 master->cdev.class = &spi_master_class; 368 master->dev.class = &spi_master_class;
369 master->cdev.dev = get_device(dev); 369 master->dev.parent = get_device(dev);
370 spi_master_set_devdata(master, &master[1]); 370 spi_master_set_devdata(master, &master[1]);
371 371
372 return master; 372 return master;
@@ -396,7 +396,7 @@ int __init_or_module
396spi_register_master(struct spi_master *master) 396spi_register_master(struct spi_master *master)
397{ 397{
398 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1); 398 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
399 struct device *dev = master->cdev.dev; 399 struct device *dev = master->dev.parent;
400 int status = -ENODEV; 400 int status = -ENODEV;
401 int dynamic = 0; 401 int dynamic = 0;
402 402
@@ -412,12 +412,12 @@ spi_register_master(struct spi_master *master)
412 /* register the device, then userspace will see it. 412 /* register the device, then userspace will see it.
413 * registration fails if the bus ID is in use. 413 * registration fails if the bus ID is in use.
414 */ 414 */
415 snprintf(master->cdev.class_id, sizeof master->cdev.class_id, 415 snprintf(master->dev.bus_id, sizeof master->dev.bus_id,
416 "spi%u", master->bus_num); 416 "spi%u", master->bus_num);
417 status = class_device_add(&master->cdev); 417 status = device_add(&master->dev);
418 if (status < 0) 418 if (status < 0)
419 goto done; 419 goto done;
420 dev_dbg(dev, "registered master %s%s\n", master->cdev.class_id, 420 dev_dbg(dev, "registered master %s%s\n", master->dev.bus_id,
421 dynamic ? " (dynamic)" : ""); 421 dynamic ? " (dynamic)" : "");
422 422
423 /* populate children from any spi device tables */ 423 /* populate children from any spi device tables */
@@ -449,8 +449,8 @@ void spi_unregister_master(struct spi_master *master)
449{ 449{
450 int dummy; 450 int dummy;
451 451
452 dummy = device_for_each_child(master->cdev.dev, NULL, __unregister); 452 dummy = device_for_each_child(&master->dev, NULL, __unregister);
453 class_device_unregister(&master->cdev); 453 device_unregister(&master->dev);
454} 454}
455EXPORT_SYMBOL_GPL(spi_unregister_master); 455EXPORT_SYMBOL_GPL(spi_unregister_master);
456 456
@@ -471,7 +471,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
471 471
472 down(&spi_master_class.sem); 472 down(&spi_master_class.sem);
473 list_for_each_entry(cdev, &spi_master_class.children, node) { 473 list_for_each_entry(cdev, &spi_master_class.children, node) {
474 m = container_of(cdev, struct spi_master, cdev); 474 m = container_of(cdev, struct spi_master, dev.kobj);
475 if (m->bus_num == bus_num) { 475 if (m->bus_num == bus_num) {
476 master = spi_master_get(m); 476 master = spi_master_get(m);
477 break; 477 break;
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 57289b61d0be..4638e6c83715 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -479,7 +479,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
479 /* this task is the only thing to touch the SPI bits */ 479 /* this task is the only thing to touch the SPI bits */
480 bitbang->busy = 0; 480 bitbang->busy = 0;
481 bitbang->workqueue = create_singlethread_workqueue( 481 bitbang->workqueue = create_singlethread_workqueue(
482 bitbang->master->cdev.dev->bus_id); 482 bitbang->master->dev.parent->bus_id);
483 if (bitbang->workqueue == NULL) { 483 if (bitbang->workqueue == NULL) {
484 status = -EBUSY; 484 status = -EBUSY;
485 goto err1; 485 goto err1;
@@ -513,14 +513,14 @@ int spi_bitbang_stop(struct spi_bitbang *bitbang)
513 while (!list_empty(&bitbang->queue) && limit--) { 513 while (!list_empty(&bitbang->queue) && limit--) {
514 spin_unlock_irq(&bitbang->lock); 514 spin_unlock_irq(&bitbang->lock);
515 515
516 dev_dbg(bitbang->master->cdev.dev, "wait for queue\n"); 516 dev_dbg(&bitbang->master->dev, "wait for queue\n");
517 msleep(10); 517 msleep(10);
518 518
519 spin_lock_irq(&bitbang->lock); 519 spin_lock_irq(&bitbang->lock);
520 } 520 }
521 spin_unlock_irq(&bitbang->lock); 521 spin_unlock_irq(&bitbang->lock);
522 if (!list_empty(&bitbang->queue)) { 522 if (!list_empty(&bitbang->queue)) {
523 dev_err(bitbang->master->cdev.dev, "queue didn't empty\n"); 523 dev_err(&bitbang->master->dev, "queue didn't empty\n");
524 return -EBUSY; 524 return -EBUSY;
525 } 525 }
526 526
diff --git a/drivers/spi/spi_butterfly.c b/drivers/spi/spi_butterfly.c
index 312987a03210..31b7970ae463 100644
--- a/drivers/spi/spi_butterfly.c
+++ b/drivers/spi/spi_butterfly.c
@@ -246,7 +246,7 @@ static void butterfly_attach(struct parport *p)
246 * and no way to be selective about what it binds to. 246 * and no way to be selective about what it binds to.
247 */ 247 */
248 248
249 /* FIXME where should master->cdev.dev come from? 249 /* FIXME where should master->dev.parent come from?
250 * e.g. /sys/bus/pnp0/00:0b, some PCI thing, etc 250 * e.g. /sys/bus/pnp0/00:0b, some PCI thing, etc
251 * setting up a platform device like this is an ugly kluge... 251 * setting up a platform device like this is an ugly kluge...
252 */ 252 */
@@ -386,7 +386,7 @@ static void butterfly_detach(struct parport *p)
386 butterfly = NULL; 386 butterfly = NULL;
387 387
388 /* stop() unregisters child devices too */ 388 /* stop() unregisters child devices too */
389 pdev = to_platform_device(pp->bitbang.master->cdev.dev); 389 pdev = to_platform_device(pp->bitbang.master->dev.parent);
390 status = spi_bitbang_stop(&pp->bitbang); 390 status = spi_bitbang_stop(&pp->bitbang);
391 391
392 /* turn off VCC */ 392 /* turn off VCC */
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 176f6e36dbfa..8c2edd82a073 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -170,7 +170,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
170 * message's completion function when the transaction completes. 170 * message's completion function when the transaction completes.
171 */ 171 */
172struct spi_master { 172struct spi_master {
173 struct class_device cdev; 173 struct device dev;
174 174
175 /* other than negative (== assign one dynamically), bus_num is fully 175 /* other than negative (== assign one dynamically), bus_num is fully
176 * board-specific. usually that simplifies to being SOC-specific. 176 * board-specific. usually that simplifies to being SOC-specific.
@@ -216,17 +216,17 @@ struct spi_master {
216 216
217static inline void *spi_master_get_devdata(struct spi_master *master) 217static inline void *spi_master_get_devdata(struct spi_master *master)
218{ 218{
219 return class_get_devdata(&master->cdev); 219 return dev_get_drvdata(&master->dev);
220} 220}
221 221
222static inline void spi_master_set_devdata(struct spi_master *master, void *data) 222static inline void spi_master_set_devdata(struct spi_master *master, void *data)
223{ 223{
224 class_set_devdata(&master->cdev, data); 224 dev_set_drvdata(&master->dev, data);
225} 225}
226 226
227static inline struct spi_master *spi_master_get(struct spi_master *master) 227static inline struct spi_master *spi_master_get(struct spi_master *master)
228{ 228{
229 if (!master || !class_device_get(&master->cdev)) 229 if (!master || !get_device(&master->dev))
230 return NULL; 230 return NULL;
231 return master; 231 return master;
232} 232}
@@ -234,7 +234,7 @@ static inline struct spi_master *spi_master_get(struct spi_master *master)
234static inline void spi_master_put(struct spi_master *master) 234static inline void spi_master_put(struct spi_master *master)
235{ 235{
236 if (master) 236 if (master)
237 class_device_put(&master->cdev); 237 put_device(&master->dev);
238} 238}
239 239
240 240