[PATCH 04/10] omap mailbox: fix empty struct device for omap_mbox

2009-01-16 Thread Hiroshi DOYU
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.d...@nokia.com
---

 arch/arm/plat-omap/include/mach/mailbox.h |4 +-
 arch/arm/plat-omap/mailbox.c  |   63 ++---
 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 7cbed93..577db68 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 {
 
mbox_msg_t  seq_snd, seq_rcv;
 
-   struct device   dev;
+   struct device   *dev;
 
struct omap_mbox*next;
void*priv;
@@ -67,7 +67,7 @@ void omap_mbox_init_seq(struct omap_mbox *);
 struct omap_mbox *omap_mbox_get(const char *);
 void omap_mbox_put(struct omap_mbox *);
 
-int omap_mbox_register(struct omap_mbox *);
+int omap_mbox_register(struct device *parent, struct omap_mbox *);
 int omap_mbox_unregister(struct omap_mbox *);
 
 #endif /* MAILBOX_H */
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index b52ce05..5e8cd65 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -1,10 +1,9 @@
 /*
  * OMAP mailbox driver
  *
- * Copyright (C) 2006 Nokia Corporation. All rights reserved.
+ * Copyright (C) 2006-2008 Nokia Corporation. All rights reserved.
  *
- * Contact: Toshihiro Kobayashi toshihiro.kobaya...@nokia.com
- * Restructured by Hiroshi DOYU hiroshi.d...@nokia.com
+ * Contact: Hiroshi DOYU hiroshi.d...@nokia.com
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -136,7 +135,7 @@ static void mbox_rx_work(struct work_struct *work)
unsigned long flags;
 
if (mbox-rxq-callback == NULL) {
-   sysfs_notify(mbox-dev.kobj, NULL, mbox);
+   sysfs_notify(mbox-dev-kobj, NULL, mbox);
return;
}
 
@@ -204,7 +203,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
/* no more messages in the fifo. clear IRQ source. */
ack_mbox_irq(mbox, IRQ_RX);
enable_mbox_irq(mbox, IRQ_RX);
-   nomem:
+nomem:
schedule_work(mbox-rxq-work);
 }
 
@@ -286,7 +285,7 @@ static ssize_t mbox_show(struct class *class, char *buf)
 static CLASS_ATTR(mbox, S_IRUGO, mbox_show, NULL);
 
 static struct class omap_mbox_class = {
-   .name = omap_mbox,
+   .name = omap-mailbox,
 };
 
 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
@@ -333,21 +332,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
return ret;
}
 
-   mbox-dev.class = omap_mbox_class;
-   dev_set_name(mbox-dev, %s, mbox-name);
-   dev_set_drvdata(mbox-dev, mbox);
-
-   ret = device_register(mbox-dev);
-   if (unlikely(ret))
-   goto fail_device_reg;
-
-   ret = device_create_file(mbox-dev, dev_attr_mbox);
-   if (unlikely(ret)) {
-   printk(KERN_ERR
-   device_create_file failed: %d\n, ret);
-   goto fail_create_mbox;
-   }
-
ret = request_irq(mbox-irq, mbox_interrupt, IRQF_DISABLED,
mbox-name, mbox);
if (unlikely(ret)) {
@@ -377,10 +361,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
  fail_alloc_txq:
free_irq(mbox-irq, mbox);
  fail_request_irq:
-   device_remove_file(mbox-dev, dev_attr_mbox);
- fail_create_mbox:
-   device_unregister(mbox-dev);
- fail_device_reg:
if (unlikely(mbox-ops-shutdown))
mbox-ops-shutdown(mbox);
 
@@ -393,8 +373,6 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
mbox_queue_free(mbox-rxq);
 
free_irq(mbox-irq, mbox);
-   device_remove_file(mbox-dev, dev_attr_mbox);
-   class_unregister(omap_mbox_class);
 
if (unlikely(mbox-ops-shutdown))
mbox-ops-shutdown(mbox);
@@ -440,7 +418,7 @@ void omap_mbox_put(struct omap_mbox *mbox)
 }
 EXPORT_SYMBOL(omap_mbox_put);
 
-int omap_mbox_register(struct omap_mbox *mbox)
+int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 {
int ret = 0;
struct omap_mbox **tmp;
@@ -450,14 +428,31 @@ int omap_mbox_register(struct omap_mbox *mbox)
if (mbox-next)
return -EBUSY;
 
+   mbox-dev = device_create(omap_mbox_class,
+ parent, 0, mbox, %s, mbox-name);
+   if (IS_ERR(mbox-dev))
+   return PTR_ERR(mbox-dev);
+
+   ret = device_create_file(mbox-dev, dev_attr_mbox);
+   if (ret)
+   goto err_sysfs;
+
write_lock(mboxes_lock);
tmp = find_mboxes(mbox-name);
-  

[PATCH 04/10] omap mailbox: fix empty struct device for omap_mbox

2008-11-25 Thread Hiroshi DOYU
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 [EMAIL PROTECTED]
---
 arch/arm/plat-omap/include/mach/mailbox.h |4 +-
 arch/arm/plat-omap/mailbox.c  |   63 ++---
 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 9d3994b..b81df6a 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 {
 
mbox_msg_t  seq_snd, seq_rcv;
 
-   struct device   dev;
+   struct device   *dev;
 
struct omap_mbox*next;
void*priv;
@@ -69,7 +69,7 @@ void omap_mbox_init_seq(struct omap_mbox *);
 struct omap_mbox *omap_mbox_get(const char *);
 void omap_mbox_put(struct omap_mbox *);
 
-int omap_mbox_register(struct omap_mbox *);
+int omap_mbox_register(struct device *parent, struct omap_mbox *);
 int omap_mbox_unregister(struct omap_mbox *);
 
 #endif /* MAILBOX_H */
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index b52ce05..5e8cd65 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -1,10 +1,9 @@
 /*
  * OMAP mailbox driver
  *
- * Copyright (C) 2006 Nokia Corporation. All rights reserved.
+ * Copyright (C) 2006-2008 Nokia Corporation. All rights reserved.
  *
- * Contact: Toshihiro Kobayashi [EMAIL PROTECTED]
- * Restructured by Hiroshi DOYU [EMAIL PROTECTED]
+ * Contact: Hiroshi DOYU [EMAIL PROTECTED]
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -136,7 +135,7 @@ static void mbox_rx_work(struct work_struct *work)
unsigned long flags;
 
if (mbox-rxq-callback == NULL) {
-   sysfs_notify(mbox-dev.kobj, NULL, mbox);
+   sysfs_notify(mbox-dev-kobj, NULL, mbox);
return;
}
 
@@ -204,7 +203,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
/* no more messages in the fifo. clear IRQ source. */
ack_mbox_irq(mbox, IRQ_RX);
enable_mbox_irq(mbox, IRQ_RX);
-   nomem:
+nomem:
schedule_work(mbox-rxq-work);
 }
 
@@ -286,7 +285,7 @@ static ssize_t mbox_show(struct class *class, char *buf)
 static CLASS_ATTR(mbox, S_IRUGO, mbox_show, NULL);
 
 static struct class omap_mbox_class = {
-   .name = omap_mbox,
+   .name = omap-mailbox,
 };
 
 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
@@ -333,21 +332,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
return ret;
}
 
-   mbox-dev.class = omap_mbox_class;
-   dev_set_name(mbox-dev, %s, mbox-name);
-   dev_set_drvdata(mbox-dev, mbox);
-
-   ret = device_register(mbox-dev);
-   if (unlikely(ret))
-   goto fail_device_reg;
-
-   ret = device_create_file(mbox-dev, dev_attr_mbox);
-   if (unlikely(ret)) {
-   printk(KERN_ERR
-   device_create_file failed: %d\n, ret);
-   goto fail_create_mbox;
-   }
-
ret = request_irq(mbox-irq, mbox_interrupt, IRQF_DISABLED,
mbox-name, mbox);
if (unlikely(ret)) {
@@ -377,10 +361,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
  fail_alloc_txq:
free_irq(mbox-irq, mbox);
  fail_request_irq:
-   device_remove_file(mbox-dev, dev_attr_mbox);
- fail_create_mbox:
-   device_unregister(mbox-dev);
- fail_device_reg:
if (unlikely(mbox-ops-shutdown))
mbox-ops-shutdown(mbox);
 
@@ -393,8 +373,6 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
mbox_queue_free(mbox-rxq);
 
free_irq(mbox-irq, mbox);
-   device_remove_file(mbox-dev, dev_attr_mbox);
-   class_unregister(omap_mbox_class);
 
if (unlikely(mbox-ops-shutdown))
mbox-ops-shutdown(mbox);
@@ -440,7 +418,7 @@ void omap_mbox_put(struct omap_mbox *mbox)
 }
 EXPORT_SYMBOL(omap_mbox_put);
 
-int omap_mbox_register(struct omap_mbox *mbox)
+int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 {
int ret = 0;
struct omap_mbox **tmp;
@@ -450,14 +428,31 @@ int omap_mbox_register(struct omap_mbox *mbox)
if (mbox-next)
return -EBUSY;
 
+   mbox-dev = device_create(omap_mbox_class,
+ parent, 0, mbox, %s, mbox-name);
+   if (IS_ERR(mbox-dev))
+   return PTR_ERR(mbox-dev);
+
+   ret = device_create_file(mbox-dev, dev_attr_mbox);
+   if (ret)
+   goto err_sysfs;
+
write_lock(mboxes_lock);
tmp = find_mboxes(mbox-name);
-   if (*tmp)
+   if