Skip to content

Commit

Permalink
usb: musb: kill global and static for multi instance
Browse files Browse the repository at this point in the history
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: Santhapuri, Damodar <damodar.santhapuri@ti.com>
Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Ajay Kumar Gupta authored and Felipe Balbi committed Sep 11, 2012
1 parent 65b3d52 commit 8d2421e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
22 changes: 7 additions & 15 deletions drivers/usb/musb/musb_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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");
}
}
Expand Down Expand Up @@ -2060,11 +2060,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
/* 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;
Expand All @@ -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);
Expand All @@ -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.
Expand All @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/usb/musb/musb_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,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
};

Expand Down
8 changes: 3 additions & 5 deletions drivers/usb/musb/musb_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -261,7 +259,7 @@ int __devinit musb_init_debugfs(struct musb *musb)
goto err1;
}

musb_debugfs_root = root;
musb->debugfs_root = root;

return 0;

Expand All @@ -274,5 +272,5 @@ int __devinit musb_init_debugfs(struct musb *musb)

void /* __init_or_exit */ musb_exit_debugfs(struct musb *musb)
{
debugfs_remove_recursive(musb_debugfs_root);
debugfs_remove_recursive(musb->debugfs_root);
}

0 comments on commit 8d2421e

Please sign in to comment.