linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add possibility to define bits-per-word property.
@ 2017-02-16 13:39 Adrian Fiergolski
       [not found] ` <20170216133910.18278-1-adrian.fiergolski-vJEk5272eHo@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Fiergolski @ 2017-02-16 13:39 UTC (permalink / raw)
  To: linux-spi; +Cc: broonie, linux-kernel, Adrian Fiergolski

Signed-off-by: Adrian Fiergolski <adrian.fiergolski@cern.ch>
---
 drivers/spi/spi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0239b45..d2267e9 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1549,6 +1549,17 @@ of_register_spi_device(struct spi_master *master, struct device_node *nc)
 	}
 	spi->max_speed_hz = value;
 
+	/* Device bits-per-word */
+	if( ! of_property_read_u32(nc, "spi-bits-per-word", &value) ){
+	  if( value > 32 )
+	    dev_warn(&master->dev,
+		     "bits-per-word %d not supported\n",
+		     value);
+	  else
+	    spi->bits_per_word = value;
+	}
+
+
 	/* Store a pointer to the node in the device structure */
 	of_node_get(nc);
 	spi->dev.of_node = nc;
@@ -1626,6 +1637,13 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data)
 
 			spi->max_speed_hz = sb->connection_speed;
 
+			if(sb->data_bit_length > 32)
+				    dev_warn(&master->dev,
+					     "bits-per-word %d not supported\n",
+					     sb->data_bit_length);
+			else
+			  spi->bits_per_word = sb->data_bit_length;
+
 			if (sb->clock_phase == ACPI_SPI_SECOND_PHASE)
 				spi->mode |= SPI_CPHA;
 			if (sb->clock_polarity == ACPI_SPI_START_HIGH)
--
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add possibility to define bits-per-word property.
       [not found] ` <20170216133910.18278-1-adrian.fiergolski-vJEk5272eHo@public.gmane.org>
@ 2017-02-17 10:06   ` Miguel Ojeda
  2017-02-17 10:11   ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2017-02-17 10:06 UTC (permalink / raw)
  To: Adrian Fiergolski
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	linux-kernel

Hi Adrian,

Please review the style to match the kernel's (and the rest of the
code in the file). See an example below and
https://github.com/torvalds/linux/blob/master/Documentation/process/coding-style.rst

(I have no idea regarding the functional changes on this patch, I just
noticed the email coming from CERN and therefore I replied :-)

Cheers,
Miguel

On Thu, Feb 16, 2017 at 2:39 PM, Adrian Fiergolski
<adrian.fiergolski-vJEk5272eHo@public.gmane.org> wrote:
>
> Signed-off-by: Adrian Fiergolski <adrian.fiergolski-vJEk5272eHo@public.gmane.org>
> ---
>  drivers/spi/spi.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 0239b45..d2267e9 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1549,6 +1549,17 @@ of_register_spi_device(struct spi_master *master, struct device_node *nc)
>         }
>         spi->max_speed_hz = value;
>
> +       /* Device bits-per-word */
> +       if( ! of_property_read_u32(nc, "spi-bits-per-word", &value) ){

e.g.

 if (!of_property_read_u32(nc, "spi-bits-per-word", &value)) {

>
> +         if( value > 32 )
> +           dev_warn(&master->dev,
> +                    "bits-per-word %d not supported\n",
> +                    value);
> +         else
> +           spi->bits_per_word = value;
> +       }
> +
> +
>         /* Store a pointer to the node in the device structure */
>         of_node_get(nc);
>         spi->dev.of_node = nc;
> @@ -1626,6 +1637,13 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data)
>
>                         spi->max_speed_hz = sb->connection_speed;
>
> +                       if(sb->data_bit_length > 32)
> +                                   dev_warn(&master->dev,
> +                                            "bits-per-word %d not supported\n",
> +                                            sb->data_bit_length);
> +                       else
> +                         spi->bits_per_word = sb->data_bit_length;
> +
>                         if (sb->clock_phase == ACPI_SPI_SECOND_PHASE)
>                                 spi->mode |= SPI_CPHA;
>                         if (sb->clock_polarity == ACPI_SPI_START_HIGH)
> --
> 2.9.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add possibility to define bits-per-word property.
       [not found] ` <20170216133910.18278-1-adrian.fiergolski-vJEk5272eHo@public.gmane.org>
  2017-02-17 10:06   ` Miguel Ojeda
@ 2017-02-17 10:11   ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2017-02-17 10:11 UTC (permalink / raw)
  To: Adrian Fiergolski
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 681 bytes --]

On Thu, Feb 16, 2017 at 02:39:10PM +0100, Adrian Fiergolski wrote:
> Signed-off-by: Adrian Fiergolski <adrian.fiergolski-vJEk5272eHo@public.gmane.org>
> ---
>  drivers/spi/spi.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

Why would this property be useful?  You're also adding a new binding
with no binding documentation, binding documentation is mandatory for
all new bindings.

Please submit patches using subject lines reflecting the style for the
subsystem.  This makes it easier for people to identify relevant
patches.  Look at what existing commits in the area you're changing are
doing and make sure your subject lines visually resemble what they're
doing.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-17 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 13:39 [PATCH] Add possibility to define bits-per-word property Adrian Fiergolski
     [not found] ` <20170216133910.18278-1-adrian.fiergolski-vJEk5272eHo@public.gmane.org>
2017-02-17 10:06   ` Miguel Ojeda
2017-02-17 10:11   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).