Skip to content

Commit c146ede

Browse files
Zhang Zekungregkh
authored andcommitted
usb: ohci-nxp: Use helper function devm_clk_get_enabled()
devm_clk_get() and clk_prepare_enable() can be replaced by helper function devm_clk_get_enabled(). Let's use devm_clk_get_enabled() to simplify code and avoid calling clk_disable_unprepare(). Signed-off-by: Zhang Zekun <[email protected]> Acked-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b243013 commit c146ede

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

drivers/usb/host/ohci-nxp.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ static struct hc_driver __read_mostly ohci_nxp_hc_driver;
5151

5252
static struct i2c_client *isp1301_i2c_client;
5353

54-
static struct clk *usb_host_clk;
55-
5654
static void isp1301_configure_lpc32xx(void)
5755
{
5856
/* LPC32XX only supports DAT_SE0 USB mode */
@@ -155,6 +153,7 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
155153
struct resource *res;
156154
int ret = 0, irq;
157155
struct device_node *isp1301_node;
156+
struct clk *usb_host_clk;
158157

159158
if (pdev->dev.of_node) {
160159
isp1301_node = of_parse_phandle(pdev->dev.of_node,
@@ -180,26 +179,20 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
180179
}
181180

182181
/* Enable USB host clock */
183-
usb_host_clk = devm_clk_get(&pdev->dev, NULL);
182+
usb_host_clk = devm_clk_get_enabled(&pdev->dev, NULL);
184183
if (IS_ERR(usb_host_clk)) {
185-
dev_err(&pdev->dev, "failed to acquire USB OHCI clock\n");
184+
dev_err(&pdev->dev, "failed to acquire and start USB OHCI clock\n");
186185
ret = PTR_ERR(usb_host_clk);
187186
goto fail_disable;
188187
}
189188

190-
ret = clk_prepare_enable(usb_host_clk);
191-
if (ret < 0) {
192-
dev_err(&pdev->dev, "failed to start USB OHCI clock\n");
193-
goto fail_disable;
194-
}
195-
196189
isp1301_configure();
197190

198191
hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
199192
if (!hcd) {
200193
dev_err(&pdev->dev, "Failed to allocate HC buffer\n");
201194
ret = -ENOMEM;
202-
goto fail_hcd;
195+
goto fail_disable;
203196
}
204197

205198
hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
@@ -229,8 +222,6 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
229222
ohci_nxp_stop_hc();
230223
fail_resource:
231224
usb_put_hcd(hcd);
232-
fail_hcd:
233-
clk_disable_unprepare(usb_host_clk);
234225
fail_disable:
235226
isp1301_i2c_client = NULL;
236227
return ret;
@@ -243,7 +234,6 @@ static void ohci_hcd_nxp_remove(struct platform_device *pdev)
243234
usb_remove_hcd(hcd);
244235
ohci_nxp_stop_hc();
245236
usb_put_hcd(hcd);
246-
clk_disable_unprepare(usb_host_clk);
247237
isp1301_i2c_client = NULL;
248238
}
249239

0 commit comments

Comments
 (0)