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

Commit 806f6e6b authored by Jingoo Han's avatar Jingoo Han Committed by Greg Kroah-Hartman
Browse files

USB: ehci-orion: Use devm_*() functions



Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Acked-by: default avatarJason Cooper <jason@lakedaemon.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 63c9b9d3
Loading
Loading
Loading
Loading
+12 −31
Original line number Original line Diff line number Diff line
@@ -184,33 +184,23 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
	if (err)
	if (err)
		goto err1;
		goto err1;


	if (!request_mem_region(res->start, resource_size(res),
	regs = devm_ioremap_resource(&pdev->dev, res);
				ehci_orion_hc_driver.description)) {
	if (IS_ERR(regs)) {
		dev_dbg(&pdev->dev, "controller already in use\n");
		err = PTR_ERR(regs);
		err = -EBUSY;
		goto err1;
		goto err1;
	}
	}


	regs = ioremap(res->start, resource_size(res));
	if (regs == NULL) {
		dev_dbg(&pdev->dev, "error mapping memory\n");
		err = -EFAULT;
		goto err2;
	}

	/* Not all platforms can gate the clock, so it is not
	/* Not all platforms can gate the clock, so it is not
	   an error if the clock does not exists. */
	   an error if the clock does not exists. */
	clk = clk_get(&pdev->dev, NULL);
	clk = devm_clk_get(&pdev->dev, NULL);
	if (!IS_ERR(clk)) {
	if (!IS_ERR(clk))
		clk_prepare_enable(clk);
		clk_prepare_enable(clk);
		clk_put(clk);
	}


	hcd = usb_create_hcd(&ehci_orion_hc_driver,
	hcd = usb_create_hcd(&ehci_orion_hc_driver,
			&pdev->dev, dev_name(&pdev->dev));
			&pdev->dev, dev_name(&pdev->dev));
	if (!hcd) {
	if (!hcd) {
		err = -ENOMEM;
		err = -ENOMEM;
		goto err3;
		goto err2;
	}
	}


	hcd->rsrc_start = res->start;
	hcd->rsrc_start = res->start;
@@ -250,21 +240,16 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)


	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
	if (err)
	if (err)
		goto err4;
		goto err3;


	device_wakeup_enable(hcd->self.controller);
	device_wakeup_enable(hcd->self.controller);
	return 0;
	return 0;


err4:
	usb_put_hcd(hcd);
err3:
err3:
	if (!IS_ERR(clk)) {
	usb_put_hcd(hcd);
		clk_disable_unprepare(clk);
		clk_put(clk);
	}
	iounmap(regs);
err2:
err2:
	release_mem_region(res->start, resource_size(res));
	if (!IS_ERR(clk))
		clk_disable_unprepare(clk);
err1:
err1:
	dev_err(&pdev->dev, "init %s fail, %d\n",
	dev_err(&pdev->dev, "init %s fail, %d\n",
		dev_name(&pdev->dev), err);
		dev_name(&pdev->dev), err);
@@ -278,15 +263,11 @@ static int ehci_orion_drv_remove(struct platform_device *pdev)
	struct clk *clk;
	struct clk *clk;


	usb_remove_hcd(hcd);
	usb_remove_hcd(hcd);
	iounmap(hcd->regs);
	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
	usb_put_hcd(hcd);
	usb_put_hcd(hcd);


	clk = clk_get(&pdev->dev, NULL);
	clk = devm_clk_get(&pdev->dev, NULL);
	if (!IS_ERR(clk)) {
	if (!IS_ERR(clk))
		clk_disable_unprepare(clk);
		clk_disable_unprepare(clk);
		clk_put(clk);
	}
	return 0;
	return 0;
}
}