aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorSoren Brinkmann <soren.brinkmann@xilinx.com>2013-10-17 17:08:05 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-19 22:47:37 -0400
commitc03cae1791407f4f4f9bc6b0354ecaeb50df787f (patch)
tree694af24bc92d91ea9ff08247351eb82b1182e009 /drivers/tty
parent991fc259361eb812ebf6c4527343d60ab4b2e1a6 (diff)
tty: xuartps: Use devm_kzalloc
Use the device managed interface for memory allocation, simplifying error paths. Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/xilinx_uartps.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 103ba8826d06..8c0745951605 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -949,27 +949,26 @@ static int xuartps_probe(struct platform_device *pdev)
949 struct resource *res, *res2; 949 struct resource *res, *res2;
950 struct xuartps *xuartps_data; 950 struct xuartps *xuartps_data;
951 951
952 xuartps_data = kzalloc(sizeof(*xuartps_data), GFP_KERNEL); 952 xuartps_data = devm_kzalloc(&pdev->dev, sizeof(*xuartps_data),
953 GFP_KERNEL);
953 if (!xuartps_data) 954 if (!xuartps_data)
954 return -ENOMEM; 955 return -ENOMEM;
955 956
956 xuartps_data->aperclk = devm_clk_get(&pdev->dev, "aper_clk"); 957 xuartps_data->aperclk = devm_clk_get(&pdev->dev, "aper_clk");
957 if (IS_ERR(xuartps_data->aperclk)) { 958 if (IS_ERR(xuartps_data->aperclk)) {
958 dev_err(&pdev->dev, "aper_clk clock not found.\n"); 959 dev_err(&pdev->dev, "aper_clk clock not found.\n");
959 rc = PTR_ERR(xuartps_data->aperclk); 960 return PTR_ERR(xuartps_data->aperclk);
960 goto err_out_free;
961 } 961 }
962 xuartps_data->refclk = devm_clk_get(&pdev->dev, "ref_clk"); 962 xuartps_data->refclk = devm_clk_get(&pdev->dev, "ref_clk");
963 if (IS_ERR(xuartps_data->refclk)) { 963 if (IS_ERR(xuartps_data->refclk)) {
964 dev_err(&pdev->dev, "ref_clk clock not found.\n"); 964 dev_err(&pdev->dev, "ref_clk clock not found.\n");
965 rc = PTR_ERR(xuartps_data->refclk); 965 return PTR_ERR(xuartps_data->refclk);
966 goto err_out_free;
967 } 966 }
968 967
969 rc = clk_prepare_enable(xuartps_data->aperclk); 968 rc = clk_prepare_enable(xuartps_data->aperclk);
970 if (rc) { 969 if (rc) {
971 dev_err(&pdev->dev, "Unable to enable APER clock.\n"); 970 dev_err(&pdev->dev, "Unable to enable APER clock.\n");
972 goto err_out_free; 971 return rc;
973 } 972 }
974 rc = clk_prepare_enable(xuartps_data->refclk); 973 rc = clk_prepare_enable(xuartps_data->refclk);
975 if (rc) { 974 if (rc) {
@@ -1020,8 +1019,6 @@ err_out_clk_disable:
1020 clk_disable_unprepare(xuartps_data->refclk); 1019 clk_disable_unprepare(xuartps_data->refclk);
1021err_out_clk_dis_aper: 1020err_out_clk_dis_aper:
1022 clk_disable_unprepare(xuartps_data->aperclk); 1021 clk_disable_unprepare(xuartps_data->aperclk);
1023err_out_free:
1024 kfree(xuartps_data);
1025 1022
1026 return rc; 1023 return rc;
1027} 1024}
@@ -1043,7 +1040,6 @@ static int xuartps_remove(struct platform_device *pdev)
1043 port->mapbase = 0; 1040 port->mapbase = 0;
1044 clk_disable_unprepare(xuartps_data->refclk); 1041 clk_disable_unprepare(xuartps_data->refclk);
1045 clk_disable_unprepare(xuartps_data->aperclk); 1042 clk_disable_unprepare(xuartps_data->aperclk);
1046 kfree(xuartps_data);
1047 return rc; 1043 return rc;
1048} 1044}
1049 1045