All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ravi Babu <ravibabu@ti.com>
To: linux-usb@vger.kernel.org
Cc: linux-omap@vger.kernel.org, balbi@ti.com,
	grant.likely@secretlab.ca, devicetree-discuss@lists.ozlabs.org,
	tony@atomide.com, ajayguptaj@gmail.com
Subject: [PATCH v8 04/13] usb: musb: kill global and static for multi instance
Date: Thu, 30 Aug 2012 16:20:16 +0530	[thread overview]
Message-ID: <1346323825-24385-5-git-send-email-ravibabu@ti.com> (raw)
In-Reply-To: <1346323825-24385-1-git-send-email-ravibabu@ti.com>

From: Ajay Kumar Gupta <ajay.gupta@ti.com>

Moved global variable "musb_debugfs_root" and static variable
"old_state" to 'struct musb' to help support multi instance of
musb controller as present on AM335x platform.

Also removed the global variable "orig_dma_mask" and filled the
dev->dma_mask with parent device's dma_mask.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri@ti.com>
Signed-off-by: Ravi Babu <ravibabu@ti.com>
---
 drivers/usb/musb/musb_core.c    |   22 +++++++---------------
 drivers/usb/musb/musb_core.h    |    4 ++++
 drivers/usb/musb/musb_debugfs.c |    8 +++-----
 3 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 7499fbb..44c8caa 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -100,6 +100,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/idr.h>
+#include <linux/dma-mapping.h>
 
 #include "musb_core.h"
 
@@ -1797,10 +1798,9 @@ static const struct attribute_group musb_attr_group = {
 static void musb_irq_work(struct work_struct *data)
 {
 	struct musb *musb = container_of(data, struct musb, irq_work);
-	static int old_state;
 
-	if (musb->xceiv->state != old_state) {
-		old_state = musb->xceiv->state;
+	if (musb->xceiv->state != musb->xceiv_old_state) {
+		musb->xceiv_old_state = musb->xceiv->state;
 		sysfs_notify(&musb->controller->kobj, NULL, "mode");
 	}
 }
@@ -2060,11 +2060,6 @@ fail0:
 /* all implementations (PCI bridge to FPGA, VLYNQ, etc) should just
  * bridge to a platform device; this driver then suffices.
  */
-
-#ifndef CONFIG_MUSB_PIO_ONLY
-static u64	*orig_dma_mask;
-#endif
-
 static int __devinit musb_probe(struct platform_device *pdev)
 {
 	struct device	*dev = &pdev->dev;
@@ -2083,10 +2078,6 @@ static int __devinit musb_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-#ifndef CONFIG_MUSB_PIO_ONLY
-	/* clobbered by use_dma=n */
-	orig_dma_mask = dev->dma_mask;
-#endif
 	status = musb_init_controller(dev, irq, base);
 	if (status < 0)
 		iounmap(base);
@@ -2096,7 +2087,8 @@ static int __devinit musb_probe(struct platform_device *pdev)
 
 static int __devexit musb_remove(struct platform_device *pdev)
 {
-	struct musb	*musb = dev_to_musb(&pdev->dev);
+	struct device	*dev = &pdev->dev;
+	struct musb	*musb = dev_to_musb(dev);
 	void __iomem	*ctrl_base = musb->ctrl_base;
 
 	/* this gets called on rmmod.
@@ -2109,9 +2101,9 @@ static int __devexit musb_remove(struct platform_device *pdev)
 
 	musb_free(musb);
 	iounmap(ctrl_base);
-	device_init_wakeup(&pdev->dev, 0);
+	device_init_wakeup(dev, 0);
 #ifndef CONFIG_MUSB_PIO_ONLY
-	pdev->dev.dma_mask = orig_dma_mask;
+	dma_set_mask(dev, *dev->parent->dma_mask);
 #endif
 	return 0;
 }
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index a69ffd6..c158aac 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -437,6 +437,10 @@ struct musb {
 #ifdef MUSB_CONFIG_PROC_FS
 	struct proc_dir_entry *proc_entry;
 #endif
+	int			xceiv_old_state;
+#ifdef CONFIG_DEBUG_FS
+	struct dentry		*debugfs_root;
+#endif
 };
 
 static inline struct musb *gadget_to_musb(struct usb_gadget *g)
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 40a37c9..1d6e8af 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -103,8 +103,6 @@ static const struct musb_register_map musb_regmap[] = {
 	{  }	/* Terminating Entry */
 };
 
-static struct dentry *musb_debugfs_root;
-
 static int musb_regdump_show(struct seq_file *s, void *unused)
 {
 	struct musb		*musb = s->private;
@@ -241,7 +239,7 @@ int __devinit musb_init_debugfs(struct musb *musb)
 	struct dentry		*file;
 	int			ret;
 
-	root = debugfs_create_dir("musb", NULL);
+	root = debugfs_create_dir(dev_name(musb->controller), NULL);
 	if (!root) {
 		ret = -ENOMEM;
 		goto err0;
@@ -261,7 +259,7 @@ int __devinit musb_init_debugfs(struct musb *musb)
 		goto err1;
 	}
 
-	musb_debugfs_root = root;
+	musb->debugfs_root = root;
 
 	return 0;
 
@@ -274,5 +272,5 @@ err0:
 
 void /* __init_or_exit */ musb_exit_debugfs(struct musb *musb)
 {
-	debugfs_remove_recursive(musb_debugfs_root);
+	debugfs_remove_recursive(musb->debugfs_root);
 }
-- 
1.7.0.4


  parent reply	other threads:[~2012-08-30 10:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-30 10:50 [PATCH v8 00/13] usb: musb: adding multi instance support Ravi Babu
2012-08-30 10:50 ` [PATCH v8 01/13] usb: musb: dsps: add phy control logic to glue Ravi Babu
2012-08-30 10:50 ` [PATCH v8 02/13] usb: musb: dsps: enable phy control for am335x Ravi Babu
2012-08-30 10:50 ` Ravi Babu [this message]
2012-08-30 10:50 ` [PATCH v8 07/13] usb: musb: dsps: add dt support Ravi Babu
2012-08-30 10:50 ` [PATCH v8 08/13] arm/dts: am33xx: Add dt data for usbss Ravi Babu
     [not found]   ` <1346323825-24385-9-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
2012-08-30 11:39     ` Sergei Shtylyov
     [not found]       ` <503F50FC.5040200-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
2012-08-31  9:54         ` Felipe Balbi
2012-08-31 10:01           ` B, Ravi
2012-08-31 10:11   ` ABRAHAM, KISHON VIJAY
2012-08-31 10:16     ` B, Ravi
     [not found] ` <1346323825-24385-1-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
2012-08-30 10:50   ` [PATCH v8 03/13] usb: musb: add musb_ida for multi instance support Ravi Babu
2012-08-30 10:50   ` [PATCH v8 05/13] usb: musb: am335x: add support for dual instance Ravi Babu
2012-08-30 10:50   ` [PATCH v8 06/13] usb: otg: nop: add support for multiple tranceiver Ravi Babu
2012-08-30 10:50   ` [PATCH v8 09/13] arm/dts: am33xx: add dt data for usb nop phy Ravi Babu
2012-08-30 10:50   ` [PATCH v8 10/13] usb: musb: dsps: remove explicit NOP device creation Ravi Babu
2012-08-30 10:50   ` [PATCH v8 11/13] usb: musb: dsps: get the PHY using phandle api Ravi Babu
2012-08-30 10:50 ` [PATCH v8 12/13] arm/dts: am33xx: add phy phandle to usbss Ravi Babu
2012-08-30 10:50 ` [PATCH v8 13/13] usb: otg: nop: add dt support Ravi Babu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346323825-24385-5-git-send-email-ravibabu@ti.com \
    --to=ravibabu@ti.com \
    --cc=ajayguptaj@gmail.com \
    --cc=balbi@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.