All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Barker <paul.barker@sancloud.com>
To: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Tom Rini <trini@konsulko.com>,
	Jagan Teki <jagan@amarulasolutions.com>
Cc: Paul Barker <paul.barker@sancloud.com>
Subject: [PATCH v4 1/6] spi: Implement spi_set_speed
Date: Wed,  5 Oct 2022 13:18:34 +0100	[thread overview]
Message-ID: <20221005121839.3938771-2-paul.barker@sancloud.com> (raw)
In-Reply-To: <20221005121839.3938771-1-paul.barker@sancloud.com>

This function is already defined in spi.h but no implementation of it
currently exists in the tree. The implementation is based on the static
function spi_set_speed_mode(). The function prototype is modified so
that an success or error condition can be returned to the caller.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
---
 drivers/spi/spi-uclass.c | 15 +++++++++++++++
 include/spi.h            |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index f2791c4b88ec..c929e7c1d0e9 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -130,6 +130,21 @@ void spi_release_bus(struct spi_slave *slave)
 	dm_spi_release_bus(slave->dev);
 }
 
+int spi_set_speed(struct spi_slave *slave, uint hz)
+{
+	struct dm_spi_ops *ops;
+	int ret;
+
+	ops = spi_get_ops(slave->dev->parent);
+	if (ops->set_speed)
+		ret = ops->set_speed(slave->dev->parent, hz);
+	else
+		ret = -EINVAL;
+	if (ret)
+		dev_err(slave->dev, "Cannot set speed (err=%d)\n", ret);
+	return ret;
+}
+
 int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
 	     const void *dout, void *din, unsigned long flags)
 {
diff --git a/include/spi.h b/include/spi.h
index 9a8c1fb260e6..de97ffb4c385 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -353,7 +353,7 @@ void spi_cs_deactivate(struct spi_slave *slave);
  * @slave:	The SPI slave
  * @hz:		The transfer speed
  */
-void spi_set_speed(struct spi_slave *slave, uint hz);
+int spi_set_speed(struct spi_slave *slave, uint hz);
 
 /**
  * Write 8 bits, then read 8 bits.
-- 
2.25.1


  reply	other threads:[~2022-10-05 12:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 12:18 [PATCH v4 0/6] Support UEFI SPI I/O protocol Paul Barker
2022-10-05 12:18 ` Paul Barker [this message]
2022-10-06  3:15   ` [PATCH v4 1/6] spi: Implement spi_set_speed Heinrich Schuchardt
2022-10-05 12:18 ` [PATCH v4 2/6] efi: Add string conversion helper Paul Barker
2022-10-06  3:26   ` Heinrich Schuchardt
2022-10-06  6:19   ` Ilias Apalodimas
2022-10-05 12:18 ` [PATCH v4 3/6] efi_loader: Add SPI I/O protocol support Paul Barker
2022-10-24 11:54   ` Ilias Apalodimas
2022-10-25 16:39     ` Paul Barker
2022-10-25 17:26       ` Tom Rini
2022-10-05 12:18 ` [PATCH v4 4/6] efi_selftest: Add tests for SPI " Paul Barker
2022-10-05 12:18 ` [PATCH v4 5/6] arm: dts: am335x-sancloud-bbe-lite: UEFI SPI export Paul Barker
2022-10-06  4:12   ` [U-Boot PATCH " Heinrich Schuchardt
2022-10-05 12:18 ` [PATCH v4 6/6] am335x_evm_defconfig: Enable Micron SPI flash support Paul Barker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221005121839.3938771-2-paul.barker@sancloud.com \
    --to=paul.barker@sancloud.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jagan@amarulasolutions.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.