usb: chipidea: imx: simplify the usbmisc callers
authorPeter Chen <peter.chen@freescale.com>
Wed, 11 Feb 2015 04:44:44 +0000 (12:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2015 15:19:08 +0000 (16:19 +0100)
Move struct imx_usbmisc_data NULL pointer judgement from caller to
each API, it can simplify the caller.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/ci_hdrc_imx.c
drivers/usb/chipidea/usbmisc_imx.c

index 421651060f8dfcb4dbb16b73929fc05de5643fff..353989e5675beb2c5473d4e216a1ab0e7ba1d9ad 100644 (file)
@@ -149,13 +149,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
        if (ret)
                goto err_clk;
 
-       if (data->usbmisc_data) {
-               ret = imx_usbmisc_init(data->usbmisc_data);
-               if (ret) {
-                       dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n",
-                                       ret);
-                       goto err_clk;
-               }
+       ret = imx_usbmisc_init(data->usbmisc_data);
+       if (ret) {
+               dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", ret);
+               goto err_clk;
        }
 
        data->ci_pdev = ci_hdrc_add_device(&pdev->dev,
@@ -169,13 +166,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
                goto err_clk;
        }
 
-       if (data->usbmisc_data) {
-               ret = imx_usbmisc_init_post(data->usbmisc_data);
-               if (ret) {
-                       dev_err(&pdev->dev, "usbmisc post failed, ret=%d\n",
-                                       ret);
-                       goto disable_device;
-               }
+       ret = imx_usbmisc_init_post(data->usbmisc_data);
+       if (ret) {
+               dev_err(&pdev->dev, "usbmisc post failed, ret=%d\n", ret);
+               goto disable_device;
        }
 
        platform_set_drvdata(pdev, data);
index 93856027d6f4cd88db8ac80f6adbf0e91929f876..eb77e3285c8a59ee9e8749773a32f74867049551 100644 (file)
@@ -265,8 +265,12 @@ static const struct usbmisc_ops vf610_usbmisc_ops = {
 
 int imx_usbmisc_init(struct imx_usbmisc_data *data)
 {
-       struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
+       struct imx_usbmisc *usbmisc;
+
+       if (!data)
+               return 0;
 
+       usbmisc = dev_get_drvdata(data->dev);
        if (!usbmisc->ops->init)
                return 0;
        return usbmisc->ops->init(data);
@@ -275,8 +279,12 @@ EXPORT_SYMBOL_GPL(imx_usbmisc_init);
 
 int imx_usbmisc_init_post(struct imx_usbmisc_data *data)
 {
-       struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
+       struct imx_usbmisc *usbmisc;
+
+       if (!data)
+               return 0;
 
+       usbmisc = dev_get_drvdata(data->dev);
        if (!usbmisc->ops->post)
                return 0;
        return usbmisc->ops->post(data);