diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-09-27 22:05:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-02 16:38:58 -0400 |
commit | aca70d19c8e56a871e9a68c9b6b940656666b56a (patch) | |
tree | 5cc7b9a6529503ed8484d2e75343d6bc7a3694d1 | |
parent | 2fd8e454189d580bcfc198fee60e51655945b986 (diff) |
serial: 8250_uniphier: flatten probe function
Currently, the DT-related settings are split out to
uniphier_of_serial_setup(), but it turned out to be not nice.
The next commit will add a DT property, but it will not fit in
the helper. Merge the helper into the probe function.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/8250/8250_uniphier.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c index d292654422b2..1028c02c5d83 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c | |||
@@ -155,36 +155,6 @@ static void uniphier_serial_dl_write(struct uart_8250_port *up, int value) | |||
155 | writel(value, up->port.membase + UNIPHIER_UART_DLR); | 155 | writel(value, up->port.membase + UNIPHIER_UART_DLR); |
156 | } | 156 | } |
157 | 157 | ||
158 | static int uniphier_of_serial_setup(struct device *dev, struct uart_port *port, | ||
159 | struct uniphier8250_priv *priv) | ||
160 | { | ||
161 | int ret; | ||
162 | u32 prop; | ||
163 | struct device_node *np = dev->of_node; | ||
164 | |||
165 | ret = of_alias_get_id(np, "serial"); | ||
166 | if (ret < 0) { | ||
167 | dev_err(dev, "failed to get alias id\n"); | ||
168 | return ret; | ||
169 | } | ||
170 | port->line = ret; | ||
171 | |||
172 | /* Get clk rate through clk driver */ | ||
173 | priv->clk = devm_clk_get(dev, NULL); | ||
174 | if (IS_ERR(priv->clk)) { | ||
175 | dev_err(dev, "failed to get clock\n"); | ||
176 | return PTR_ERR(priv->clk); | ||
177 | } | ||
178 | |||
179 | ret = clk_prepare_enable(priv->clk); | ||
180 | if (ret < 0) | ||
181 | return ret; | ||
182 | |||
183 | port->uartclk = clk_get_rate(priv->clk); | ||
184 | |||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | static int uniphier_uart_probe(struct platform_device *pdev) | 158 | static int uniphier_uart_probe(struct platform_device *pdev) |
189 | { | 159 | { |
190 | struct device *dev = &pdev->dev; | 160 | struct device *dev = &pdev->dev; |
@@ -217,9 +187,24 @@ static int uniphier_uart_probe(struct platform_device *pdev) | |||
217 | 187 | ||
218 | memset(&up, 0, sizeof(up)); | 188 | memset(&up, 0, sizeof(up)); |
219 | 189 | ||
220 | ret = uniphier_of_serial_setup(dev, &up.port, priv); | 190 | ret = of_alias_get_id(dev->of_node, "serial"); |
221 | if (ret < 0) | 191 | if (ret < 0) { |
192 | dev_err(dev, "failed to get alias id\n"); | ||
222 | return ret; | 193 | return ret; |
194 | } | ||
195 | up.port.line = ret; | ||
196 | |||
197 | priv->clk = devm_clk_get(dev, NULL); | ||
198 | if (IS_ERR(priv->clk)) { | ||
199 | dev_err(dev, "failed to get clock\n"); | ||
200 | return PTR_ERR(priv->clk); | ||
201 | } | ||
202 | |||
203 | ret = clk_prepare_enable(priv->clk); | ||
204 | if (ret) | ||
205 | return ret; | ||
206 | |||
207 | up.port.uartclk = clk_get_rate(priv->clk); | ||
223 | 208 | ||
224 | spin_lock_init(&priv->atomic_write_lock); | 209 | spin_lock_init(&priv->atomic_write_lock); |
225 | 210 | ||