Skip to content

Commit 5046449

Browse files
ptalari27broonie
authored andcommitted
spi: geni-qcom: Improve target mode allocation by using proper allocation functions
The current implementation always allocates a host controller and sets the target flag later when the "spi-slave" device tree property is present. This approach is suboptimal as it doesn't utilize the dedicated allocation functions designed for target mode. Use devm_spi_alloc_target() when "spi-slave" device tree property is present, otherwise use devm_spi_alloc_host(). This replaces the previous approach of always allocating a host controller and setting target flag later. Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Link: https://patch.msgid.link/20260204162854.1206323-2-praveen.talari@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4cc4ace commit 5046449

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/spi/spi-geni-qcom.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,11 @@ static int spi_geni_probe(struct platform_device *pdev)
10331033
if (IS_ERR(clk))
10341034
return PTR_ERR(clk);
10351035

1036-
spi = devm_spi_alloc_host(dev, sizeof(*mas));
1036+
if (device_property_read_bool(dev, "spi-slave"))
1037+
spi = devm_spi_alloc_target(dev, sizeof(*mas));
1038+
else
1039+
spi = devm_spi_alloc_host(dev, sizeof(*mas));
1040+
10371041
if (!spi)
10381042
return -ENOMEM;
10391043

@@ -1087,9 +1091,6 @@ static int spi_geni_probe(struct platform_device *pdev)
10871091
if (ret)
10881092
return ret;
10891093

1090-
if (device_property_read_bool(&pdev->dev, "spi-slave"))
1091-
spi->target = true;
1092-
10931094
/* Set the bus quota to a reasonable value for register access */
10941095
mas->se.icc_paths[GENI_TO_CORE].avg_bw = Bps_to_icc(CORE_2X_50_MHZ);
10951096
mas->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW;

0 commit comments

Comments
 (0)