Unverified Commit 50464497 authored by Praveen Talari's avatar Praveen Talari Committed by Mark Brown
Browse files

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: default avatarPraveen Talari <praveen.talari@oss.qualcomm.com>
Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260204162854.1206323-2-praveen.talari@oss.qualcomm.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4cc4ace7
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1033,7 +1033,11 @@ static int spi_geni_probe(struct platform_device *pdev)
	if (IS_ERR(clk))
		return PTR_ERR(clk);

	if (device_property_read_bool(dev, "spi-slave"))
		spi = devm_spi_alloc_target(dev, sizeof(*mas));
	else
		spi = devm_spi_alloc_host(dev, sizeof(*mas));

	if (!spi)
		return -ENOMEM;

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

	if (device_property_read_bool(&pdev->dev, "spi-slave"))
		spi->target = true;

	/* Set the bus quota to a reasonable value for register access */
	mas->se.icc_paths[GENI_TO_CORE].avg_bw = Bps_to_icc(CORE_2X_50_MHZ);
	mas->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW;