Commit 2cda3623 authored by Tudor Ambarus's avatar Tudor Ambarus Committed by Mark Brown

spi: s3c64xx: introduce s3c64xx_spi_set_port_id()

Prepare driver to get rid of the of alias ID dependency. Split the
port_id logic into a dedicated method.
Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-9-tudor.ambarus@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e08433e0
...@@ -1200,6 +1200,27 @@ static inline const struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config( ...@@ -1200,6 +1200,27 @@ static inline const struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
return (const struct s3c64xx_spi_port_config *)platform_get_device_id(pdev)->driver_data; return (const struct s3c64xx_spi_port_config *)platform_get_device_id(pdev)->driver_data;
} }
static int s3c64xx_spi_set_port_id(struct platform_device *pdev,
struct s3c64xx_spi_driver_data *sdd)
{
int ret;
if (pdev->dev.of_node) {
ret = of_alias_get_id(pdev->dev.of_node, "spi");
if (ret < 0)
return dev_err_probe(&pdev->dev, ret,
"Failed to get alias id\n");
sdd->port_id = ret;
} else {
if (pdev->id < 0)
return dev_err_probe(&pdev->dev, -EINVAL,
"Negative platform ID is not allowed\n");
sdd->port_id = pdev->id;
}
return 0;
}
static void s3c64xx_spi_set_fifomask(struct s3c64xx_spi_driver_data *sdd) static void s3c64xx_spi_set_fifomask(struct s3c64xx_spi_driver_data *sdd)
{ {
const struct s3c64xx_spi_port_config *port_conf = sdd->port_conf; const struct s3c64xx_spi_port_config *port_conf = sdd->port_conf;
...@@ -1252,18 +1273,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1252,18 +1273,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
sdd->host = host; sdd->host = host;
sdd->cntrlr_info = sci; sdd->cntrlr_info = sci;
sdd->pdev = pdev; sdd->pdev = pdev;
if (pdev->dev.of_node) {
ret = of_alias_get_id(pdev->dev.of_node, "spi"); ret = s3c64xx_spi_set_port_id(pdev, sdd);
if (ret < 0) if (ret)
return dev_err_probe(&pdev->dev, ret, return ret;
"Failed to get alias id\n");
sdd->port_id = ret;
} else {
if (pdev->id < 0)
return dev_err_probe(&pdev->dev, -EINVAL,
"Negative platform ID is not allowed\n");
sdd->port_id = pdev->id;
}
if (sdd->port_conf->fifo_depth) if (sdd->port_conf->fifo_depth)
sdd->fifo_depth = sdd->port_conf->fifo_depth; sdd->fifo_depth = sdd->port_conf->fifo_depth;
......
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