aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2013-07-26 10:22:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-26 19:20:24 -0400
commit299a62575a63b19add8206642b340f1b54ec4faf (patch)
tree9ffe739f8fd236233f00546065ebed5b50da72e5
parentcf940ebe98e693aec2d10f9af2fb84eb55234e3c (diff)
serial8250-em: Convert to devm_* managed helpers
Replace kzalloc and clk_get by their managed counterparts to simplify error and cleanup paths. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/8250/8250_em.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c
index 916cc19fbbda..5f3bba12c159 100644
--- a/drivers/tty/serial/8250/8250_em.c
+++ b/drivers/tty/serial/8250/8250_em.c
@@ -95,25 +95,23 @@ static int serial8250_em_probe(struct platform_device *pdev)
95 struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 95 struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
96 struct serial8250_em_priv *priv; 96 struct serial8250_em_priv *priv;
97 struct uart_8250_port up; 97 struct uart_8250_port up;
98 int ret = -EINVAL; 98 int ret;
99 99
100 if (!regs || !irq) { 100 if (!regs || !irq) {
101 dev_err(&pdev->dev, "missing registers or irq\n"); 101 dev_err(&pdev->dev, "missing registers or irq\n");
102 goto err0; 102 return -EINVAL;
103 } 103 }
104 104
105 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 105 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
106 if (!priv) { 106 if (!priv) {
107 dev_err(&pdev->dev, "unable to allocate private data\n"); 107 dev_err(&pdev->dev, "unable to allocate private data\n");
108 ret = -ENOMEM; 108 return -ENOMEM;
109 goto err0;
110 } 109 }
111 110
112 priv->sclk = clk_get(&pdev->dev, "sclk"); 111 priv->sclk = devm_clk_get(&pdev->dev, "sclk");
113 if (IS_ERR(priv->sclk)) { 112 if (IS_ERR(priv->sclk)) {
114 dev_err(&pdev->dev, "unable to get clock\n"); 113 dev_err(&pdev->dev, "unable to get clock\n");
115 ret = PTR_ERR(priv->sclk); 114 return PTR_ERR(priv->sclk);
116 goto err1;
117 } 115 }
118 116
119 memset(&up, 0, sizeof(up)); 117 memset(&up, 0, sizeof(up));
@@ -136,20 +134,13 @@ static int serial8250_em_probe(struct platform_device *pdev)
136 ret = serial8250_register_8250_port(&up); 134 ret = serial8250_register_8250_port(&up);
137 if (ret < 0) { 135 if (ret < 0) {
138 dev_err(&pdev->dev, "unable to register 8250 port\n"); 136 dev_err(&pdev->dev, "unable to register 8250 port\n");
139 goto err2; 137 clk_disable(priv->sclk);
138 return ret;
140 } 139 }
141 140
142 priv->line = ret; 141 priv->line = ret;
143 platform_set_drvdata(pdev, priv); 142 platform_set_drvdata(pdev, priv);
144 return 0; 143 return 0;
145
146 err2:
147 clk_disable(priv->sclk);
148 clk_put(priv->sclk);
149 err1:
150 kfree(priv);
151 err0:
152 return ret;
153} 144}
154 145
155static int serial8250_em_remove(struct platform_device *pdev) 146static int serial8250_em_remove(struct platform_device *pdev)
@@ -158,8 +149,6 @@ static int serial8250_em_remove(struct platform_device *pdev)
158 149
159 serial8250_unregister_port(priv->line); 150 serial8250_unregister_port(priv->line);
160 clk_disable(priv->sclk); 151 clk_disable(priv->sclk);
161 clk_put(priv->sclk);
162 kfree(priv);
163 return 0; 152 return 0;
164} 153}
165 154