Skip to content

Commit 2cda362

Browse files
ambarusbroonie
authored andcommitted
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: Tudor Ambarus <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e08433e commit 2cda362

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

drivers/spi/spi-s3c64xx.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,27 @@ static inline const struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
12001200
return (const struct s3c64xx_spi_port_config *)platform_get_device_id(pdev)->driver_data;
12011201
}
12021202

1203+
static int s3c64xx_spi_set_port_id(struct platform_device *pdev,
1204+
struct s3c64xx_spi_driver_data *sdd)
1205+
{
1206+
int ret;
1207+
1208+
if (pdev->dev.of_node) {
1209+
ret = of_alias_get_id(pdev->dev.of_node, "spi");
1210+
if (ret < 0)
1211+
return dev_err_probe(&pdev->dev, ret,
1212+
"Failed to get alias id\n");
1213+
sdd->port_id = ret;
1214+
} else {
1215+
if (pdev->id < 0)
1216+
return dev_err_probe(&pdev->dev, -EINVAL,
1217+
"Negative platform ID is not allowed\n");
1218+
sdd->port_id = pdev->id;
1219+
}
1220+
1221+
return 0;
1222+
}
1223+
12031224
static void s3c64xx_spi_set_fifomask(struct s3c64xx_spi_driver_data *sdd)
12041225
{
12051226
const struct s3c64xx_spi_port_config *port_conf = sdd->port_conf;
@@ -1252,18 +1273,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
12521273
sdd->host = host;
12531274
sdd->cntrlr_info = sci;
12541275
sdd->pdev = pdev;
1255-
if (pdev->dev.of_node) {
1256-
ret = of_alias_get_id(pdev->dev.of_node, "spi");
1257-
if (ret < 0)
1258-
return dev_err_probe(&pdev->dev, ret,
1259-
"Failed to get alias id\n");
1260-
sdd->port_id = ret;
1261-
} else {
1262-
if (pdev->id < 0)
1263-
return dev_err_probe(&pdev->dev, -EINVAL,
1264-
"Negative platform ID is not allowed\n");
1265-
sdd->port_id = pdev->id;
1266-
}
1276+
1277+
ret = s3c64xx_spi_set_port_id(pdev, sdd);
1278+
if (ret)
1279+
return ret;
12671280

12681281
if (sdd->port_conf->fifo_depth)
12691282
sdd->fifo_depth = sdd->port_conf->fifo_depth;

0 commit comments

Comments
 (0)