Commit dc8fea13 authored by Minghao Chi (CGEL ZTE)'s avatar Minghao Chi (CGEL ZTE) Committed by Mark Brown

spi: Use of_device_get_match_data()

Use of_device_get_match_data() to simplify the code.
Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarMinghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
Link: https://lore.kernel.org/r/20220303092131.2060044-1-chi.minghao@zte.com.cnSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 13262fc2
...@@ -671,7 +671,6 @@ static const struct of_device_id npcm_fiu_dt_ids[] = { ...@@ -671,7 +671,6 @@ static const struct of_device_id npcm_fiu_dt_ids[] = {
static int npcm_fiu_probe(struct platform_device *pdev) static int npcm_fiu_probe(struct platform_device *pdev)
{ {
const struct fiu_data *fiu_data_match; const struct fiu_data *fiu_data_match;
const struct of_device_id *match;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_controller *ctrl; struct spi_controller *ctrl;
struct npcm_fiu_spi *fiu; struct npcm_fiu_spi *fiu;
...@@ -685,13 +684,12 @@ static int npcm_fiu_probe(struct platform_device *pdev) ...@@ -685,13 +684,12 @@ static int npcm_fiu_probe(struct platform_device *pdev)
fiu = spi_controller_get_devdata(ctrl); fiu = spi_controller_get_devdata(ctrl);
match = of_match_device(npcm_fiu_dt_ids, dev); fiu_data_match = of_device_get_match_data(dev);
if (!match || !match->data) { if (!fiu_data_match) {
dev_err(dev, "No compatible OF match\n"); dev_err(dev, "No compatible OF match\n");
return -ENODEV; return -ENODEV;
} }
fiu_data_match = match->data;
id = of_alias_get_id(dev->of_node, "fiu"); id = of_alias_get_id(dev->of_node, "fiu");
if (id < 0 || id >= fiu_data_match->fiu_max) { if (id < 0 || id >= fiu_data_match->fiu_max) {
dev_err(dev, "Invalid platform device id: %d\n", id); dev_err(dev, "Invalid platform device id: %d\n", id);
......
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