diff mbox

[U-Boot,v2] spi: ignore set speed and mode if not available

Message ID 1443961388-15585-1-git-send-email-thomas@wytron.com.tw
State Accepted, archived
Delegated to: Thomas Chou
Headers show

Commit Message

Thomas Chou Oct. 4, 2015, 12:23 p.m. UTC
Some cores, such as Altera SPI and QuadSPI, can not change
speed and mode at runtime. Ignore the operation which is
not available.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
Reviewed-by: Jagan Teki <jteki@openedev.com>
---
v2
  add comments as Simon sugggested.

 drivers/spi/spi-uclass.c | 7 ++-----
 include/spi.h            | 5 +++++
 2 files changed, 7 insertions(+), 5 deletions(-)

Comments

Simon Glass Oct. 4, 2015, 12:25 p.m. UTC | #1
On 4 October 2015 at 13:23, Thomas Chou <thomas@wytron.com.tw> wrote:
> Some cores, such as Altera SPI and QuadSPI, can not change
> speed and mode at runtime. Ignore the operation which is
> not available.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> Acked-by: Marek Vasut <marex@denx.de>
> Reviewed-by: Jagan Teki <jteki@openedev.com>
> ---
> v2
>   add comments as Simon sugggested.
>
>  drivers/spi/spi-uclass.c | 7 ++-----
>  include/spi.h            | 5 +++++
>  2 files changed, 7 insertions(+), 5 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index d666272..50e3553 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -21,13 +21,12 @@  DECLARE_GLOBAL_DATA_PTR;
 static int spi_set_speed_mode(struct udevice *bus, int speed, int mode)
 {
 	struct dm_spi_ops *ops;
-	int ret;
+	int ret = 0;
 
 	ops = spi_get_ops(bus);
+	/* missing get_speed() and set_mode() methods are OK */
 	if (ops->set_speed)
 		ret = ops->set_speed(bus, speed);
-	else
-		ret = -EINVAL;
 	if (ret) {
 		printf("Cannot set speed (err=%d)\n", ret);
 		return ret;
@@ -35,8 +34,6 @@  static int spi_set_speed_mode(struct udevice *bus, int speed, int mode)
 
 	if (ops->set_mode)
 		ret = ops->set_mode(bus, mode);
-	else
-		ret = -EINVAL;
 	if (ret) {
 		printf("Cannot set mode (err=%d)\n", ret);
 		return ret;
diff --git a/include/spi.h b/include/spi.h
index 51fdfd6..a418509 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -451,6 +451,9 @@  struct dm_spi_ops {
 	/**
 	 * Set transfer speed.
 	 * This sets a new speed to be applied for next spi_xfer().
+	 *
+	 * It is optional in the case where the hardware does not support it.
+	 *
 	 * @bus:	The SPI bus
 	 * @hz:		The transfer speed
 	 * @return 0 if OK, -ve on error
@@ -463,6 +466,8 @@  struct dm_spi_ops {
 	 * It is unclear if we want to set speed and mode together instead
 	 * of separately.
 	 *
+	 * It is optional in the case where the hardware does not support it.
+	 *
 	 * @bus:	The SPI bus
 	 * @mode:	Requested SPI mode (SPI_... flags)
 	 * @return 0 if OK, -ve on error