From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Subject: Re: [PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer Date: Wed, 19 Mar 2014 09:06:31 +0100 Message-ID: References: <1395201227.16346.1.camel@phoenix> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Mark Brown , Wenyou Yang , Fabrice Crohas , Illia Smyrnov , Atsushi Nemoto , Lars-Peter Clausen , linux-spi To: Axel Lin Return-path: In-Reply-To: <1395201227.16346.1.camel@phoenix> Sender: linux-spi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: On Wed, Mar 19, 2014 at 4:53 AM, Axel Lin wrote: > Reject transfer if both tx_buf and rx_buf are NULL for non-zero length transfer. > Add the checking in spi core so we can remove the same checking in various > drivers. Just wondering: are there any SPI slave drivers that implement dummy cycles this way? > Signed-off-by: Axel Lin > --- > drivers/spi/spi.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c > index 26b331d..0a29d2a 100644 > --- a/drivers/spi/spi.c > +++ b/drivers/spi/spi.c > @@ -1876,6 +1876,10 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) > if (xfer->len % w_size) > return -EINVAL; > > + /* non-zero length transfer must has tx_buf or rx_buf */ have > + if (xfer->len && !xfer->tx_buf && !xfer->rx_buf) > + return -EINVAL; > + Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- 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