[PATCH 2/2] staging/fbtft: use spi_setup instead of direct call to master->setup

Stefan Bruens stefan.bruens at rwth-aachen.de
Mon Aug 31 23:28:05 UTC 2015


On Monday 24 August 2015 01:24:59 Noralf Trønnes wrote:
> Den 24.08.2015 00:24, skrev Stefan Brüns:
> > Avoid a crash, as master->setup may be NULL (e.g. xilinx controller).
> > Even if master->setup is set, spi_setup does several compatibility/
> > sanity checks which should not be skipped (fixes problems with
> > displays/controllers needing emulation for bits_per_word = 9).
> > 
> > Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
> > ---
> > 
> >   drivers/staging/fbtft/fb_watterott.c | 4 ++--
> >   drivers/staging/fbtft/fbtft-core.c   | 4 ++--
> >   drivers/staging/fbtft/flexfb.c       | 4 ++--
> >   3 files changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/staging/fbtft/fbtft-core.c
> > b/drivers/staging/fbtft/fbtft-core.c index 9cc8141..ba08da3 100644
> > --- a/drivers/staging/fbtft/fbtft-core.c
> > +++ b/drivers/staging/fbtft/fbtft-core.c
> > @@ -1434,12 +1434,12 @@ int fbtft_probe_common(struct fbtft_display
> > *display,> 
> >   	/* 9-bit SPI setup */
> >   	if (par->spi && display->buswidth == 9) {
> >   	
> >   		par->spi->bits_per_word = 9;
> > 
> > -		ret = par->spi->master->setup(par->spi);
> > +		ret = spi_setup(par->spi);
> 
> You could also check against master->bits_per_word_mask to verify that
> 9-bit is supported before setting bits_per_word=9 and then drop
> spi_setup() altogether. And if bits_per_word_mask is not set, assume
> 9-bit is not supported.

IMHO, this is a bad idea. A controller supporting more than 32 bpw can
not set the bpw mask, as the mask is limited to 32 bits. Thus it has to
check the bpw in its own setup function, and may or may not reject 9 bpw.

Why should one penalize any controllers having an unset bpw mask, which
is a completely valid configuration?

BTW, the SPI core patch needed for this to work is in the 4.3 pull request.

Kind regards,

Stefan

-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034     mobile: +49 151 50412019
work: +49 2405 49936-424


More information about the devel mailing list