From: Supreet Singh <singh.supreet14@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Viresh Kumar <vireshk@kernel.org>,
Rui Miguel Silva <rmfrfs@gmail.com>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: spilib: Handle SPI device types with a switch statement
Date: Wed, 5 Aug 2026 17:49:09 +0530 [thread overview]
Message-ID: <anMqPSOOg_EG2Lnf@dio> (raw)
In-Reply-To: <2026080508-stifle-qualm-3dd7@gregkh>
On Wed, Aug 05, 2026 at 01:28:47PM +0200, Greg Kroah-Hartman wrote:
> On Wed, Aug 05, 2026 at 04:49:57PM +0530, singh.supreet14@gmail.com wrote:
> > From: Supreet <singh.supreet14@gmail.com>
>
> We need a full name please.
>
>
> >
> > Replaced the if/else chain with switch statement. makes it easier to
> > extend support for additional device types.
> >
> > Remove the temporary spidev variable since it is only used to test the
> > return value of spi_new_device(). Call spi_new_device() directly in
> > the conditional instead.
> >
> > checkpatch was run, had no warnings and errors.
> >
> > Signed-off-by: Supreet <singh.supreet14@gmail.com>
> > ---
> > drivers/staging/greybus/spilib.c | 19 +++++++++++--------
> > 1 file changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c
> > index e4d1ae8308aa..53fc0c124754 100644
> > --- a/drivers/staging/greybus/spilib.c
> > +++ b/drivers/staging/greybus/spilib.c
> > @@ -444,7 +444,6 @@ static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs)
> > struct gb_spi_device_config_request request;
> > struct gb_spi_device_config_response response;
> > struct spi_board_info spi_board = { {0} };
> > - struct spi_device *spidev;
> > int ret;
> > u8 dev_type;
> >
> > @@ -458,25 +457,29 @@ static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs)
> >
> > dev_type = response.device_type;
> >
> > - if (dev_type == GB_SPI_SPI_DEV)
> > + switch (dev_type) {
> > + case GB_SPI_SPI_DEV:
> > strscpy(spi_board.modalias, "spidev",
> > sizeof(spi_board.modalias));
> > - else if (dev_type == GB_SPI_SPI_NOR)
> > + break;
> > + case GB_SPI_SPI_NOR:
> > strscpy(spi_board.modalias, "spi-nor",
> > sizeof(spi_board.modalias));
> > - else if (dev_type == GB_SPI_SPI_MODALIAS)
> > + break;
> > + case GB_SPI_SPI_MODALIAS:
> > memcpy(spi_board.modalias, response.name,
> > - sizeof(spi_board.modalias));
> > - else
> > + sizeof(spi_board.modalias));
> > + break;
> > + default:
> > return -EINVAL;
> > + }
> >
> > spi_board.mode = le16_to_cpu(response.mode);
> > spi_board.bus_num = ctlr->bus_num;
> > spi_board.chip_select = cs;
> > spi_board.max_speed_hz = le32_to_cpu(response.max_speed_hz);
> >
> > - spidev = spi_new_device(ctlr, &spi_board);
> > - if (!spidev)
> > + if (!spi_new_device(ctlr, &spi_board))
>
> Why was this change made? It's a different one than the switch
> statement, right?
>
> thanks,
>
> greg k-h
Hi Greg
Yes, you are right, the `spidev` change is independent of the switch
statement. My intention was to remove the temporary variable as it was
only used to check the return value of the `spi_new_device()`.
I will drop that change, and send a v2 focused only on the switch
statement. If appropriate I can send that cleanup as a separate patch.
Apologies for the last email, first time using mutt.
Thanks
Supreet Singh
next prev parent reply other threads:[~2026-08-05 12:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 11:19 [PATCH] staging: greybus: spilib: Handle SPI device types with a switch statement singh.supreet14
2026-08-05 11:28 ` Greg Kroah-Hartman
2026-08-05 12:19 ` Supreet Singh [this message]
2026-08-06 10:11 ` [PATCH v2] " singh.supreet14
2026-08-06 15:46 ` Dan Carpenter
2026-08-07 7:15 ` [PATCH v3] " singh.supreet14
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=anMqPSOOg_EG2Lnf@dio \
--to=singh.supreet14@gmail.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=rmfrfs@gmail.com \
--cc=vireshk@kernel.org \
/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