MLK-14314-11 dma: pxp-v3: refine attributes create in probe()
authorFancy Fang <chen.fang@nxp.com>
Thu, 13 Apr 2017 10:49:57 +0000 (18:49 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:22:10 +0000 (15:22 -0500)
Extract the attributes creation from the pxp_probe()
to a seperate function call to make the probing process
more clear.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 85ab5476bf59a407037b43419b920b681b58b52d)

drivers/dma/pxp/pxp_dma_v3.c

index 373b308..78583cc 100644 (file)
@@ -5196,6 +5196,33 @@ static int pxp_init_interrupt(struct platform_device *pdev)
        return 0;
 }
 
+static int pxp_create_attrs(struct platform_device *pdev)
+{
+       int ret = 0;
+
+       if ((ret = device_create_file(&pdev->dev, &dev_attr_clk_off_timeout))) {
+               dev_err(&pdev->dev,
+                       "Unable to create file from clk_off_timeout\n");
+               return ret;
+       }
+
+       if ((ret = device_create_file(&pdev->dev, &dev_attr_block_size))) {
+               device_remove_file(&pdev->dev, &dev_attr_clk_off_timeout);
+
+               dev_err(&pdev->dev,
+                       "Unable to create file from block_size\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static void pxp_remove_attrs(struct platform_device *pdev)
+{
+       device_remove_file(&pdev->dev, &dev_attr_clk_off_timeout);
+       device_remove_file(&pdev->dev, &dev_attr_block_size);
+}
+
 #ifdef CONFIG_MXC_FPGA_M4_TEST
 static void pxp_config_m4(struct platform_device *pdev)
 {
@@ -5278,13 +5305,6 @@ static int pxp_probe(struct platform_device *pdev)
        if (err < 0)
                goto exit;
 
-       if (device_create_file(&pdev->dev, &dev_attr_clk_off_timeout)) {
-               dev_err(&pdev->dev,
-                       "Unable to create file from clk_off_timeout\n");
-               goto exit;
-       }
-
-       device_create_file(&pdev->dev, &dev_attr_block_size);
        pxp_clk_enable(pxp);
        pxp_soft_reset(pxp);
        if (pxp->devdata && pxp->devdata->pxp_data_path_config)
@@ -5312,6 +5332,10 @@ static int pxp_probe(struct platform_device *pdev)
                goto exit;
        }
 
+       err = pxp_create_attrs(pdev);
+       if (err)
+               goto exit;
+
 #ifdef CONFIG_MXC_FPGA_M4_TEST
        pxp_config_m4(pdev);
 #endif
@@ -5335,8 +5359,7 @@ static int pxp_remove(struct platform_device *pdev)
        del_timer_sync(&pxp->clk_timer);
        clk_disable_unprepare(pxp->ipg_clk);
        clk_disable_unprepare(pxp->axi_clk);
-       device_remove_file(&pdev->dev, &dev_attr_clk_off_timeout);
-       device_remove_file(&pdev->dev, &dev_attr_block_size);
+       pxp_remove_attrs(pdev);
        dma_async_device_unregister(&(pxp->pxp_dma.dma));
 
        return 0;