Commit 5d785141 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

spi: fsl-lpspi: Clean up fsl_lpspi_probe

Use is_slave local variable to avoid calling of_property_read_bool() twice.
Remove redudant assignment for controller->bus_num, set it once is enough.
Move setting controller->bits_per_word_mask close to the code init other
controller fields.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a18656ea
...@@ -843,8 +843,10 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -843,8 +843,10 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
int i, ret, irq; int i, ret, irq;
u32 temp; u32 temp;
bool is_slave;
if (of_property_read_bool((&pdev->dev)->of_node, "spi-slave")) is_slave = of_property_read_bool((&pdev->dev)->of_node, "spi-slave");
if (is_slave)
controller = spi_alloc_slave(&pdev->dev, controller = spi_alloc_slave(&pdev->dev,
sizeof(struct fsl_lpspi_data)); sizeof(struct fsl_lpspi_data));
else else
...@@ -856,13 +858,9 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -856,13 +858,9 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, controller); platform_set_drvdata(pdev, controller);
controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
controller->bus_num = pdev->id;
fsl_lpspi = spi_controller_get_devdata(controller); fsl_lpspi = spi_controller_get_devdata(controller);
fsl_lpspi->dev = &pdev->dev; fsl_lpspi->dev = &pdev->dev;
fsl_lpspi->is_slave = of_property_read_bool((&pdev->dev)->of_node, fsl_lpspi->is_slave = is_slave;
"spi-slave");
if (!fsl_lpspi->is_slave) { if (!fsl_lpspi->is_slave) {
for (i = 0; i < controller->num_chipselect; i++) { for (i = 0; i < controller->num_chipselect; i++) {
...@@ -887,6 +885,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -887,6 +885,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
controller->prepare_message = fsl_lpspi_prepare_message; controller->prepare_message = fsl_lpspi_prepare_message;
} }
controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
controller->transfer_one = fsl_lpspi_transfer_one; controller->transfer_one = fsl_lpspi_transfer_one;
controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware; controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware;
controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware; controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment