Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <zhangzekun11@huawei.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20240902123020.29267-3-zhangzekun11@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Zhang Zekun and committed by
Greg Kroah-Hartman
c146ede4 b2430136

+4 -14
+4 -14
drivers/usb/host/ohci-nxp.c
··· 51 51 52 52 static struct i2c_client *isp1301_i2c_client; 53 53 54 - static struct clk *usb_host_clk; 55 - 56 54 static void isp1301_configure_lpc32xx(void) 57 55 { 58 56 /* LPC32XX only supports DAT_SE0 USB mode */ ··· 153 155 struct resource *res; 154 156 int ret = 0, irq; 155 157 struct device_node *isp1301_node; 158 + struct clk *usb_host_clk; 156 159 157 160 if (pdev->dev.of_node) { 158 161 isp1301_node = of_parse_phandle(pdev->dev.of_node, ··· 179 180 } 180 181 181 182 /* Enable USB host clock */ 182 - usb_host_clk = devm_clk_get(&pdev->dev, NULL); 183 + usb_host_clk = devm_clk_get_enabled(&pdev->dev, NULL); 183 184 if (IS_ERR(usb_host_clk)) { 184 - dev_err(&pdev->dev, "failed to acquire USB OHCI clock\n"); 185 + dev_err(&pdev->dev, "failed to acquire and start USB OHCI clock\n"); 185 186 ret = PTR_ERR(usb_host_clk); 186 - goto fail_disable; 187 - } 188 - 189 - ret = clk_prepare_enable(usb_host_clk); 190 - if (ret < 0) { 191 - dev_err(&pdev->dev, "failed to start USB OHCI clock\n"); 192 187 goto fail_disable; 193 188 } 194 189 ··· 192 199 if (!hcd) { 193 200 dev_err(&pdev->dev, "Failed to allocate HC buffer\n"); 194 201 ret = -ENOMEM; 195 - goto fail_hcd; 202 + goto fail_disable; 196 203 } 197 204 198 205 hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); ··· 222 229 ohci_nxp_stop_hc(); 223 230 fail_resource: 224 231 usb_put_hcd(hcd); 225 - fail_hcd: 226 - clk_disable_unprepare(usb_host_clk); 227 232 fail_disable: 228 233 isp1301_i2c_client = NULL; 229 234 return ret; ··· 234 243 usb_remove_hcd(hcd); 235 244 ohci_nxp_stop_hc(); 236 245 usb_put_hcd(hcd); 237 - clk_disable_unprepare(usb_host_clk); 238 246 isp1301_i2c_client = NULL; 239 247 } 240 248