aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiroshi DOYU <Hiroshi.DOYU@nokia.com>2009-03-23 21:07:24 -0400
committerTony Lindgren <tony@atomide.com>2009-03-23 21:07:24 -0400
commitf48cca87703a4f4c372f1519e72e0fd6acb70d54 (patch)
tree98ab2c2be89b005b704b2890122154129779fb08
parent94fc58c6da019257680ae711c061cb403582a362 (diff)
omap mailbox: fix empty struct device for omap_mbox
Since "mbox->dev" doesn't exist and isn't created either at registration, this patch will create "struct device", which belongs to "omap-mailbox" class and set this pointer for the member of "struct omap_mbox". Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
-rw-r--r--arch/arm/plat-omap/include/mach/mailbox.h4
-rw-r--r--arch/arm/plat-omap/mailbox.c63
2 files changed, 33 insertions, 34 deletions
diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index 7cbed9332e16..577db6852f43 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -53,7 +53,7 @@ struct omap_mbox {
53 53
54 mbox_msg_t seq_snd, seq_rcv; 54 mbox_msg_t seq_snd, seq_rcv;
55 55
56 struct device dev; 56 struct device *dev;
57 57
58 struct omap_mbox *next; 58 struct omap_mbox *next;
59 void *priv; 59 void *priv;
@@ -67,7 +67,7 @@ void omap_mbox_init_seq(struct omap_mbox *);
67struct omap_mbox *omap_mbox_get(const char *); 67struct omap_mbox *omap_mbox_get(const char *);
68void omap_mbox_put(struct omap_mbox *); 68void omap_mbox_put(struct omap_mbox *);
69 69
70int omap_mbox_register(struct omap_mbox *); 70int omap_mbox_register(struct device *parent, struct omap_mbox *);
71int omap_mbox_unregister(struct omap_mbox *); 71int omap_mbox_unregister(struct omap_mbox *);
72 72
73#endif /* MAILBOX_H */ 73#endif /* MAILBOX_H */
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index b52ce053e6f2..75ede474d844 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * OMAP mailbox driver 2 * OMAP mailbox driver
3 * 3 *
4 * Copyright (C) 2006 Nokia Corporation. All rights reserved. 4 * Copyright (C) 2006-2009 Nokia Corporation. All rights reserved.
5 * 5 *
6 * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com> 6 * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
7 * Restructured by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
8 * 7 *
9 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 9 * modify it under the terms of the GNU General Public License
@@ -136,7 +135,7 @@ static void mbox_rx_work(struct work_struct *work)
136 unsigned long flags; 135 unsigned long flags;
137 136
138 if (mbox->rxq->callback == NULL) { 137 if (mbox->rxq->callback == NULL) {
139 sysfs_notify(&mbox->dev.kobj, NULL, "mbox"); 138 sysfs_notify(&mbox->dev->kobj, NULL, "mbox");
140 return; 139 return;
141 } 140 }
142 141
@@ -204,7 +203,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
204 /* no more messages in the fifo. clear IRQ source. */ 203 /* no more messages in the fifo. clear IRQ source. */
205 ack_mbox_irq(mbox, IRQ_RX); 204 ack_mbox_irq(mbox, IRQ_RX);
206 enable_mbox_irq(mbox, IRQ_RX); 205 enable_mbox_irq(mbox, IRQ_RX);
207 nomem: 206nomem:
208 schedule_work(&mbox->rxq->work); 207 schedule_work(&mbox->rxq->work);
209} 208}
210 209
@@ -286,7 +285,7 @@ static ssize_t mbox_show(struct class *class, char *buf)
286static CLASS_ATTR(mbox, S_IRUGO, mbox_show, NULL); 285static CLASS_ATTR(mbox, S_IRUGO, mbox_show, NULL);
287 286
288static struct class omap_mbox_class = { 287static struct class omap_mbox_class = {
289 .name = "omap_mbox", 288 .name = "omap-mailbox",
290}; 289};
291 290
292static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox, 291static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
@@ -333,21 +332,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
333 return ret; 332 return ret;
334 } 333 }
335 334
336 mbox->dev.class = &omap_mbox_class;
337 dev_set_name(&mbox->dev, "%s", mbox->name);
338 dev_set_drvdata(&mbox->dev, mbox);
339
340 ret = device_register(&mbox->dev);
341 if (unlikely(ret))
342 goto fail_device_reg;
343
344 ret = device_create_file(&mbox->dev, &dev_attr_mbox);
345 if (unlikely(ret)) {
346 printk(KERN_ERR
347 "device_create_file failed: %d\n", ret);
348 goto fail_create_mbox;
349 }
350
351 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_DISABLED, 335 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_DISABLED,
352 mbox->name, mbox); 336 mbox->name, mbox);
353 if (unlikely(ret)) { 337 if (unlikely(ret)) {
@@ -377,10 +361,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
377 fail_alloc_txq: 361 fail_alloc_txq:
378 free_irq(mbox->irq, mbox); 362 free_irq(mbox->irq, mbox);
379 fail_request_irq: 363 fail_request_irq:
380 device_remove_file(&mbox->dev, &dev_attr_mbox);
381 fail_create_mbox:
382 device_unregister(&mbox->dev);
383 fail_device_reg:
384 if (unlikely(mbox->ops->shutdown)) 364 if (unlikely(mbox->ops->shutdown))
385 mbox->ops->shutdown(mbox); 365 mbox->ops->shutdown(mbox);
386 366
@@ -393,8 +373,6 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
393 mbox_queue_free(mbox->rxq); 373 mbox_queue_free(mbox->rxq);
394 374
395 free_irq(mbox->irq, mbox); 375 free_irq(mbox->irq, mbox);
396 device_remove_file(&mbox->dev, &dev_attr_mbox);
397 class_unregister(&omap_mbox_class);
398 376
399 if (unlikely(mbox->ops->shutdown)) 377 if (unlikely(mbox->ops->shutdown))
400 mbox->ops->shutdown(mbox); 378 mbox->ops->shutdown(mbox);
@@ -440,7 +418,7 @@ void omap_mbox_put(struct omap_mbox *mbox)
440} 418}
441EXPORT_SYMBOL(omap_mbox_put); 419EXPORT_SYMBOL(omap_mbox_put);
442 420
443int omap_mbox_register(struct omap_mbox *mbox) 421int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
444{ 422{
445 int ret = 0; 423 int ret = 0;
446 struct omap_mbox **tmp; 424 struct omap_mbox **tmp;
@@ -450,14 +428,31 @@ int omap_mbox_register(struct omap_mbox *mbox)
450 if (mbox->next) 428 if (mbox->next)
451 return -EBUSY; 429 return -EBUSY;
452 430
431 mbox->dev = device_create(&omap_mbox_class,
432 parent, 0, mbox, "%s", mbox->name);
433 if (IS_ERR(mbox->dev))
434 return PTR_ERR(mbox->dev);
435
436 ret = device_create_file(mbox->dev, &dev_attr_mbox);
437 if (ret)
438 goto err_sysfs;
439
453 write_lock(&mboxes_lock); 440 write_lock(&mboxes_lock);
454 tmp = find_mboxes(mbox->name); 441 tmp = find_mboxes(mbox->name);
455 if (*tmp) 442 if (*tmp) {
456 ret = -EBUSY; 443 ret = -EBUSY;
457 else 444 write_unlock(&mboxes_lock);
458 *tmp = mbox; 445 goto err_find;
446 }
447 *tmp = mbox;
459 write_unlock(&mboxes_lock); 448 write_unlock(&mboxes_lock);
460 449
450 return 0;
451
452err_find:
453 device_remove_file(mbox->dev, &dev_attr_mbox);
454err_sysfs:
455 device_unregister(mbox->dev);
461 return ret; 456 return ret;
462} 457}
463EXPORT_SYMBOL(omap_mbox_register); 458EXPORT_SYMBOL(omap_mbox_register);
@@ -473,6 +468,8 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
473 *tmp = mbox->next; 468 *tmp = mbox->next;
474 mbox->next = NULL; 469 mbox->next = NULL;
475 write_unlock(&mboxes_lock); 470 write_unlock(&mboxes_lock);
471 device_remove_file(mbox->dev, &dev_attr_mbox);
472 device_unregister(mbox->dev);
476 return 0; 473 return 0;
477 } 474 }
478 tmp = &(*tmp)->next; 475 tmp = &(*tmp)->next;
@@ -501,4 +498,6 @@ static void __exit omap_mbox_class_exit(void)
501subsys_initcall(omap_mbox_class_init); 498subsys_initcall(omap_mbox_class_init);
502module_exit(omap_mbox_class_exit); 499module_exit(omap_mbox_class_exit);
503 500
504MODULE_LICENSE("GPL"); 501MODULE_LICENSE("GPL v2");
502MODULE_DESCRIPTION("omap mailbox: interrupt driven messaging");
503MODULE_AUTHOR("Toshihiro Kobayashi and Hiroshi DOYU");