aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/sccnxp.c
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2013-07-31 06:56:29 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-31 21:08:01 -0400
commite087ab74f3dd30105041e1c68db209f235b63042 (patch)
treeba3ba6f1460bea74f234b7b408e64192b917668c /drivers/tty/serial/sccnxp.c
parent3fc1eb5fe5318d3eff9938240c29cc6ce2d6ce4e (diff)
serial: sccnxp: Disable regulator on error
The patch disables the regulator in case of errors, if we have it. In addition, the patch adds support for deferred regulator probe and makes error path are a bit clean. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/sccnxp.c')
-rw-r--r--drivers/tty/serial/sccnxp.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index 98555179fe10..12a5c265f43a 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -787,10 +787,9 @@ static int sccnxp_probe(struct platform_device *pdev)
787 struct sccnxp_port *s; 787 struct sccnxp_port *s;
788 void __iomem *membase; 788 void __iomem *membase;
789 789
790 if (!res) { 790 membase = devm_ioremap_resource(&pdev->dev, res);
791 dev_err(&pdev->dev, "Missing memory resource data\n"); 791 if (IS_ERR(membase))
792 return -EADDRNOTAVAIL; 792 return PTR_ERR(membase);
793 }
794 793
795 s = devm_kzalloc(&pdev->dev, sizeof(struct sccnxp_port), GFP_KERNEL); 794 s = devm_kzalloc(&pdev->dev, sizeof(struct sccnxp_port), GFP_KERNEL);
796 if (!s) { 795 if (!s) {
@@ -885,10 +884,20 @@ static int sccnxp_probe(struct platform_device *pdev)
885 break; 884 break;
886 default: 885 default:
887 dev_err(&pdev->dev, "Unsupported chip type %i\n", chiptype); 886 dev_err(&pdev->dev, "Unsupported chip type %i\n", chiptype);
888 ret = -ENOTSUPP; 887 return -ENOTSUPP;
889 goto err_out;
890 } 888 }
891 889
890 s->regulator = devm_regulator_get(&pdev->dev, "vcc");
891 if (!IS_ERR(s->regulator)) {
892 ret = regulator_enable(s->regulator);
893 if (ret) {
894 dev_err(&pdev->dev,
895 "Failed to enable regulator: %i\n", ret);
896 return ret;
897 }
898 } else if (PTR_ERR(s->regulator) == -EPROBE_DEFER)
899 return -EPROBE_DEFER;
900
892 if (!pdata) { 901 if (!pdata) {
893 dev_warn(&pdev->dev, 902 dev_warn(&pdev->dev,
894 "No platform data supplied, using defaults\n"); 903 "No platform data supplied, using defaults\n");
@@ -919,22 +928,6 @@ static int sccnxp_probe(struct platform_device *pdev)
919 goto err_out; 928 goto err_out;
920 } 929 }
921 930
922 s->regulator = devm_regulator_get(&pdev->dev, "VCC");
923 if (!IS_ERR(s->regulator)) {
924 ret = regulator_enable(s->regulator);
925 if (ret) {
926 dev_err(&pdev->dev,
927 "Failed to enable regulator: %i\n", ret);
928 return ret;
929 }
930 }
931
932 membase = devm_ioremap_resource(&pdev->dev, res);
933 if (IS_ERR(membase)) {
934 ret = PTR_ERR(membase);
935 goto err_out;
936 }
937
938 s->uart.owner = THIS_MODULE; 931 s->uart.owner = THIS_MODULE;
939 s->uart.dev_name = "ttySC"; 932 s->uart.dev_name = "ttySC";
940 s->uart.major = SCCNXP_MAJOR; 933 s->uart.major = SCCNXP_MAJOR;
@@ -997,6 +990,9 @@ static int sccnxp_probe(struct platform_device *pdev)
997 } 990 }
998 991
999err_out: 992err_out:
993 if (!IS_ERR(s->regulator))
994 return regulator_disable(s->regulator);
995
1000 return ret; 996 return ret;
1001} 997}
1002 998