Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f771164 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi
Browse files

usb: musb: remove hand-crafted id handling



This replaced the handcrafted id handling by the PLATFORM_DEVID_AUTO
value which should do the same thing.

This patch probably also fixes ux500 because I did not find the "musbid"
variable to remove. And we close a tiny-unlikely race window becuase the
old code gave the id back before device was destroyed in the remove
case.

[ balbi@ti.com : fixed up two failed hunks when applying patch ]

Cc: B, Ravi <ravibabu@ti.com>
Cc: Santhapuri, Damodar <damodar.santhapuri@ti.com>
Cc: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Cc: Bob Liu <lliubbo@gmail.com>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent b18d26f6
Loading
Loading
Loading
Loading
+2 −16
Original line number Diff line number Diff line
@@ -459,7 +459,6 @@ static int __devinit am35x_probe(struct platform_device *pdev)
	struct clk			*clk;

	int				ret = -ENOMEM;
	int				musbid;

	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
	if (!glue) {
@@ -467,18 +466,10 @@ static int __devinit am35x_probe(struct platform_device *pdev)
		goto err0;
	}

	/* get the musb id */
	musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
	if (musbid < 0) {
		dev_err(&pdev->dev, "failed to allocate musb id\n");
		ret = -ENOMEM;
		goto err1;
	}

	musb = platform_device_alloc("musb-hdrc", musbid);
	musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
	if (!musb) {
		dev_err(&pdev->dev, "failed to allocate musb device\n");
		goto err2;
		goto err1;
	}

	phy_clk = clk_get(&pdev->dev, "fck");
@@ -507,7 +498,6 @@ static int __devinit am35x_probe(struct platform_device *pdev)
		goto err6;
	}

	musb->id			= musbid;
	musb->dev.parent		= &pdev->dev;
	musb->dev.dma_mask		= &am35x_dmamask;
	musb->dev.coherent_dma_mask	= am35x_dmamask;
@@ -557,9 +547,6 @@ err4:
err3:
	platform_device_put(musb);

err2:
	musb_put_id(&pdev->dev, musbid);

err1:
	kfree(glue);

@@ -571,7 +558,6 @@ static int __devexit am35x_remove(struct platform_device *pdev)
{
	struct am35x_glue	*glue = platform_get_drvdata(pdev);

	musb_put_id(&pdev->dev, glue->musb->id);
	platform_device_unregister(glue->musb);
	clk_disable(glue->clk);
	clk_disable(glue->phy_clk);
+2 −16
Original line number Diff line number Diff line
@@ -455,7 +455,6 @@ static int __devinit bfin_probe(struct platform_device *pdev)
	struct bfin_glue		*glue;

	int				ret = -ENOMEM;
	int				musbid;

	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
	if (!glue) {
@@ -463,21 +462,12 @@ static int __devinit bfin_probe(struct platform_device *pdev)
		goto err0;
	}

	/* get the musb id */
	musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
	if (musbid < 0) {
		dev_err(&pdev->dev, "failed to allocate musb id\n");
		ret = -ENOMEM;
		goto err1;
	}

	musb = platform_device_alloc("musb-hdrc", musbid);
	musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
	if (!musb) {
		dev_err(&pdev->dev, "failed to allocate musb device\n");
		goto err2;
		goto err1;
	}

	musb->id			= musbid;
	musb->dev.parent		= &pdev->dev;
	musb->dev.dma_mask		= &bfin_dmamask;
	musb->dev.coherent_dma_mask	= bfin_dmamask;
@@ -513,9 +503,6 @@ static int __devinit bfin_probe(struct platform_device *pdev)
err3:
	platform_device_put(musb);

err2:
	musb_put_id(&pdev->dev, musbid);

err1:
	kfree(glue);

@@ -527,7 +514,6 @@ static int __devexit bfin_remove(struct platform_device *pdev)
{
	struct bfin_glue		*glue = platform_get_drvdata(pdev);

	musb_put_id(&pdev->dev, glue->musb->id);
	platform_device_unregister(glue->musb);
	kfree(glue);

+2 −16
Original line number Diff line number Diff line
@@ -480,7 +480,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
	struct clk			*clk;

	int				ret = -ENOMEM;
	int				musbid;

	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
	if (!glue) {
@@ -488,18 +487,10 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
		goto err0;
	}

	/* get the musb id */
	musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
	if (musbid < 0) {
		dev_err(&pdev->dev, "failed to allocate musb id\n");
		ret = -ENOMEM;
		goto err1;
	}

	musb = platform_device_alloc("musb-hdrc", musbid);
	musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
	if (!musb) {
		dev_err(&pdev->dev, "failed to allocate musb device\n");
		goto err2;
		goto err1;
	}

	clk = clk_get(&pdev->dev, "usb20");
@@ -515,7 +506,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
		goto err4;
	}

	musb->id			= musbid;
	musb->dev.parent		= &pdev->dev;
	musb->dev.dma_mask		= &da8xx_dmamask;
	musb->dev.coherent_dma_mask	= da8xx_dmamask;
@@ -558,9 +548,6 @@ err4:
err3:
	platform_device_put(musb);

err2:
	musb_put_id(&pdev->dev, musbid);

err1:
	kfree(glue);

@@ -572,7 +559,6 @@ static int __devexit da8xx_remove(struct platform_device *pdev)
{
	struct da8xx_glue		*glue = platform_get_drvdata(pdev);

	musb_put_id(&pdev->dev, glue->musb->id);
	platform_device_unregister(glue->musb);
	clk_disable(glue->clk);
	clk_put(glue->clk);
+2 −16
Original line number Diff line number Diff line
@@ -512,7 +512,6 @@ static int __devinit davinci_probe(struct platform_device *pdev)
	struct clk			*clk;

	int				ret = -ENOMEM;
	int				musbid;

	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
	if (!glue) {
@@ -520,18 +519,10 @@ static int __devinit davinci_probe(struct platform_device *pdev)
		goto err0;
	}

	/* get the musb id */
	musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
	if (musbid < 0) {
		dev_err(&pdev->dev, "failed to allocate musb id\n");
		ret = -ENOMEM;
		goto err1;
	}

	musb = platform_device_alloc("musb-hdrc", musbid);
	musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
	if (!musb) {
		dev_err(&pdev->dev, "failed to allocate musb device\n");
		goto err2;
		goto err1;
	}

	clk = clk_get(&pdev->dev, "usb");
@@ -547,7 +538,6 @@ static int __devinit davinci_probe(struct platform_device *pdev)
		goto err4;
	}

	musb->id			= musbid;
	musb->dev.parent		= &pdev->dev;
	musb->dev.dma_mask		= &davinci_dmamask;
	musb->dev.coherent_dma_mask	= davinci_dmamask;
@@ -590,9 +580,6 @@ err4:
err3:
	platform_device_put(musb);

err2:
	musb_put_id(&pdev->dev, musbid);

err1:
	kfree(glue);

@@ -604,7 +591,6 @@ static int __devexit davinci_remove(struct platform_device *pdev)
{
	struct davinci_glue		*glue = platform_get_drvdata(pdev);

	musb_put_id(&pdev->dev, glue->musb->id);
	platform_device_unregister(glue->musb);
	clk_disable(glue->clk);
	clk_put(glue->clk);
+0 −30
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@

#define MUSB_DRIVER_NAME "musb-hdrc"
const char musb_driver_name[] = MUSB_DRIVER_NAME;
static DEFINE_IDA(musb_ida);

MODULE_DESCRIPTION(DRIVER_INFO);
MODULE_AUTHOR(DRIVER_AUTHOR);
@@ -133,35 +132,6 @@ static inline struct musb *dev_to_musb(struct device *dev)

/*-------------------------------------------------------------------------*/

int musb_get_id(struct device *dev, gfp_t gfp_mask)
{
	int ret;
	int id;

	ret = ida_pre_get(&musb_ida, gfp_mask);
	if (!ret) {
		dev_err(dev, "failed to reserve resource for id\n");
		return -ENOMEM;
	}

	ret = ida_get_new(&musb_ida, &id);
	if (ret < 0) {
		dev_err(dev, "failed to allocate a new id\n");
		return ret;
	}

	return id;
}
EXPORT_SYMBOL_GPL(musb_get_id);

void musb_put_id(struct device *dev, int id)
{

	dev_dbg(dev, "removing id %d\n", id);
	ida_remove(&musb_ida, id);
}
EXPORT_SYMBOL_GPL(musb_put_id);

#ifndef CONFIG_BLACKFIN
static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
{
Loading