forked from Minki/linux
spi: oc-tiny: Use of_property_read_u32 instead of open-coding it
Use of_property_read_u32 instead of of_get_property with return value checks and endianness conversion. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
6ff33f3902
commit
45a3e77108
@ -207,8 +207,7 @@ static int tiny_spi_of_probe(struct platform_device *pdev)
|
|||||||
struct tiny_spi *hw = platform_get_drvdata(pdev);
|
struct tiny_spi *hw = platform_get_drvdata(pdev);
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const __be32 *val;
|
u32 val;
|
||||||
int len;
|
|
||||||
|
|
||||||
if (!np)
|
if (!np)
|
||||||
return 0;
|
return 0;
|
||||||
@ -226,13 +225,10 @@ static int tiny_spi_of_probe(struct platform_device *pdev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
hw->bitbang.master->dev.of_node = pdev->dev.of_node;
|
hw->bitbang.master->dev.of_node = pdev->dev.of_node;
|
||||||
val = of_get_property(pdev->dev.of_node,
|
if (!of_property_read_u32(np, "clock-frequency", &val))
|
||||||
"clock-frequency", &len);
|
hw->freq = val;
|
||||||
if (val && len >= sizeof(__be32))
|
if (!of_property_read_u32(np, "baud-width", &val))
|
||||||
hw->freq = be32_to_cpup(val);
|
hw->baudwidth = val;
|
||||||
val = of_get_property(pdev->dev.of_node, "baud-width", &len);
|
|
||||||
if (val && len >= sizeof(__be32))
|
|
||||||
hw->baudwidth = be32_to_cpup(val);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else /* !CONFIG_OF */
|
#else /* !CONFIG_OF */
|
||||||
|
Loading…
Reference in New Issue
Block a user