diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-03-12 06:35:23 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-12 12:56:52 -0400 |
commit | f9f4cbde587335515acaaef9e23028fc0a616292 (patch) | |
tree | 8807db043d370dd11c26fd6ba7b865ec90bcc241 | |
parent | 78e39523b8c9721250b54b7fd930aeced56cf511 (diff) |
spi: efm32: Clean up non-DT paths
This is a DT-only driver, so remove all non-DT paths.
of_gpio_named_count() may fail, thus also add checking it's return value.
efm32_spi_probe_dt() never fails, make it return void.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi-efm32.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/spi/spi-efm32.c b/drivers/spi/spi-efm32.c index 7199d2fd2b0b..0512fedf1f13 100644 --- a/drivers/spi/spi-efm32.c +++ b/drivers/spi/spi-efm32.c | |||
@@ -287,16 +287,13 @@ static u32 efm32_spi_get_configured_location(struct efm32_spi_ddata *ddata) | |||
287 | return (reg & REG_ROUTE_LOCATION__MASK) >> __ffs(REG_ROUTE_LOCATION__MASK); | 287 | return (reg & REG_ROUTE_LOCATION__MASK) >> __ffs(REG_ROUTE_LOCATION__MASK); |
288 | } | 288 | } |
289 | 289 | ||
290 | static int efm32_spi_probe_dt(struct platform_device *pdev, | 290 | static void efm32_spi_probe_dt(struct platform_device *pdev, |
291 | struct spi_master *master, struct efm32_spi_ddata *ddata) | 291 | struct spi_master *master, struct efm32_spi_ddata *ddata) |
292 | { | 292 | { |
293 | struct device_node *np = pdev->dev.of_node; | 293 | struct device_node *np = pdev->dev.of_node; |
294 | u32 location; | 294 | u32 location; |
295 | int ret; | 295 | int ret; |
296 | 296 | ||
297 | if (!np) | ||
298 | return 1; | ||
299 | |||
300 | ret = of_property_read_u32(np, "location", &location); | 297 | ret = of_property_read_u32(np, "location", &location); |
301 | if (!ret) { | 298 | if (!ret) { |
302 | dev_dbg(&pdev->dev, "using location %u\n", location); | 299 | dev_dbg(&pdev->dev, "using location %u\n", location); |
@@ -308,7 +305,6 @@ static int efm32_spi_probe_dt(struct platform_device *pdev, | |||
308 | } | 305 | } |
309 | 306 | ||
310 | ddata->pdata.location = location; | 307 | ddata->pdata.location = location; |
311 | return 0; | ||
312 | } | 308 | } |
313 | 309 | ||
314 | static int efm32_spi_probe(struct platform_device *pdev) | 310 | static int efm32_spi_probe(struct platform_device *pdev) |
@@ -318,9 +314,14 @@ static int efm32_spi_probe(struct platform_device *pdev) | |||
318 | int ret; | 314 | int ret; |
319 | struct spi_master *master; | 315 | struct spi_master *master; |
320 | struct device_node *np = pdev->dev.of_node; | 316 | struct device_node *np = pdev->dev.of_node; |
321 | unsigned int num_cs, i; | 317 | int num_cs, i; |
318 | |||
319 | if (!np) | ||
320 | return -EINVAL; | ||
322 | 321 | ||
323 | num_cs = of_gpio_named_count(np, "cs-gpios"); | 322 | num_cs = of_gpio_named_count(np, "cs-gpios"); |
323 | if (num_cs < 0) | ||
324 | return num_cs; | ||
324 | 325 | ||
325 | master = spi_alloc_master(&pdev->dev, | 326 | master = spi_alloc_master(&pdev->dev, |
326 | sizeof(*ddata) + num_cs * sizeof(unsigned)); | 327 | sizeof(*ddata) + num_cs * sizeof(unsigned)); |
@@ -411,23 +412,7 @@ static int efm32_spi_probe(struct platform_device *pdev) | |||
411 | goto err; | 412 | goto err; |
412 | } | 413 | } |
413 | 414 | ||
414 | ret = efm32_spi_probe_dt(pdev, master, ddata); | 415 | efm32_spi_probe_dt(pdev, master, ddata); |
415 | if (ret > 0) { | ||
416 | /* not created by device tree */ | ||
417 | const struct efm32_spi_pdata *pdata = | ||
418 | dev_get_platdata(&pdev->dev); | ||
419 | |||
420 | if (pdata) | ||
421 | ddata->pdata = *pdata; | ||
422 | else | ||
423 | ddata->pdata.location = | ||
424 | efm32_spi_get_configured_location(ddata); | ||
425 | |||
426 | master->bus_num = pdev->id; | ||
427 | |||
428 | } else if (ret < 0) { | ||
429 | goto err_disable_clk; | ||
430 | } | ||
431 | 416 | ||
432 | efm32_spi_write32(ddata, 0, REG_IEN); | 417 | efm32_spi_write32(ddata, 0, REG_IEN); |
433 | efm32_spi_write32(ddata, REG_ROUTE_TXPEN | REG_ROUTE_RXPEN | | 418 | efm32_spi_write32(ddata, REG_ROUTE_TXPEN | REG_ROUTE_RXPEN | |