From: "Noralf Trønnes" <noralf@tronnes.org>
To: Stefan Wahren <stefan.wahren@i2se.com>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org,
Henri Chain <henri.chain@eleves.ec-nantes.fr>,
devel@driverdev.osuosl.org, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH RFC 2/2] staging: fbtft: fix 9-bit SPI support detection
Date: Tue, 25 Aug 2015 20:21:29 +0200 [thread overview]
Message-ID: <55DCB229.9010403@tronnes.org> (raw)
In-Reply-To: <1273684089.140410.1440524095600.JavaMail.open-xchange@oxbsltgw04.schlund.de>
Den 25.08.2015 19:34, skrev Stefan Wahren:
>> Noralf Trønnes <noralf@tronnes.org> hat am 25. August 2015 um 00:00
>> geschrieben:
>>
>>
>>
>> Den 24.08.2015 20:33, skrev Stefan Wahren:
>>> Since bits_per_word isn't usually checked during SPI setup the 9-bit
>>> support must be checked manually.
>>>
>>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>>> ---
>>> drivers/staging/fbtft/fbtft-core.c | 7 +++++++
>>> drivers/staging/fbtft/flexfb.c | 7 +++++++
>>> 2 files changed, 14 insertions(+)
>>>
>>> diff --git a/drivers/staging/fbtft/fbtft-core.c
>>> b/drivers/staging/fbtft/fbtft-core.c
>>> index 3638554..bd71487 100644
>>> --- a/drivers/staging/fbtft/fbtft-core.c
>>> +++ b/drivers/staging/fbtft/fbtft-core.c
>>> @@ -1438,6 +1438,13 @@ int fbtft_probe_common(struct fbtft_display *display,
>>> if (par->spi && display->buswidth == 9) {
>>> par->spi->bits_per_word = 9;
>>> ret = spi_setup(par->spi);
>>> + if (!ret) {
>>> + struct spi_master *ma = par->spi->master;
>>> +
>>> + if (!(ma->bits_per_word_mask & SPI_BPW_MASK(9)))
>>> + ret = -EINVAL;
>>> + }
>>> +
>>> if (ret) {
>> There's no point in calling spi_setup() when it doesn't check bits_per_word.
> If checking of bits_per_word is the only intention of the setup call, then i
> agree.
> But i'm not sure it is safe to remove the setup call complete.
>
> Couldn't this cause regressions since there is no common spi setup call for all
> drivers?
spi_add_device() calls spi_setup() for all spi devices so it's already done.
If spi_setup() did something with bits_per_word, then I agree that we should
call it in the 9-bit case. But this is not the case, and it's possible to
change bits_per_word per transfer later, so I can't see that this is needed.
>> Apparently this changed with the commit:
>> spi: convert drivers to use bits_per_word_mask.
>> This has not been detected earlier, because FBTFT was previously mostly
>> used on the Raspberry Pi which had a downstream SPI driver that did this
>> check.
>>
>> How about this:
>>
>> - par->spi->bits_per_word = 9;
>> - ret = par->spi->master->setup(par->spi);
>> + if (par->spi->master->bits_per_word_mask &
>> SPI_BPW_MASK(9)) {
>> + par->spi->bits_per_word = 9;
>> - if (ret) {
>> + } else {
>> dev_warn(&par->spi->dev,
>> "9-bit SPI not available, emulating
>> using 8-bit.\n");
>> - par->spi->bits_per_word = 8;
> I think this assignment should stay.
Not needed since we haven't changed the default set by spi_setup():
if (!spi->bits_per_word)
spi->bits_per_word = 8;
Callchain for DT registered spi devices:
spi_register_master->of_register_spi_devices->of_register_spi_device->
spi_add_device->spi_setup
prev parent reply other threads:[~2015-08-25 18:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 18:33 [PATCH RFC 0/2] staging: fbtft: fix 9-bit SPI support Stefan Wahren
2015-08-24 18:33 ` [PATCH RFC 1/2] staging: fbtft: replace master->setup() with spi_setup() Stefan Wahren
2015-08-24 18:33 ` [PATCH RFC 2/2] staging: fbtft: fix 9-bit SPI support detection Stefan Wahren
2015-08-24 22:00 ` Noralf Trønnes
2015-08-25 17:34 ` Stefan Wahren
2015-08-25 18:21 ` Noralf Trønnes [this message]
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=55DCB229.9010403@tronnes.org \
--to=noralf@tronnes.org \
--cc=broonie@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=henri.chain@eleves.ec-nantes.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=stefan.wahren@i2se.com \
--cc=thomas.petazzoni@free-electrons.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox