Messages in this thread |  | | Date | Tue, 1 Sep 2026 17:01:28 +0530 | | From | Supreet Singh <> | | Subject | Re: [PATCH v3] staging: greybus: spilib: Handle SPI device types with a switch statement |
| |
Understandable. Thanks for your time and review.
Thanks Supreet
On Tue, Sep 01, 2026 at 11:44:26AM +0200, Greg Kroah-Hartman wrote: > On Fri, Aug 07, 2026 at 12:45:42PM +0530, singh.supreet14@gmail.com wrote: > > From: Supreet Singh <singh.supreet14@gmail.com> > > > > Replace the if/else chain that selects the SPI device type with a switch > > statement. This makes the code easier to extend when additional device > > types are introduced and improves readability. > > But let's deal with that when it happens, you are adding more code here > than removing: > > > > > Signed-off-by: Supreet Singh <singh.supreet14@gmail.com> > > --- > > Changes in v3: > > - Fixed the memcpy indentation issue > > - Removed the extra blank line in the commit message > > > > drivers/staging/greybus/spilib.c | 13 +++++++++---- > > 1 file changed, 9 insertions(+), 4 deletions(-) > > So it's not really a benefit overall, right? > > > > > diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c > > index e4d1ae8308aa..39d5bf234c61 100644 > > --- a/drivers/staging/greybus/spilib.c > > +++ b/drivers/staging/greybus/spilib.c > > @@ -458,17 +458,22 @@ 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 > > + break; > > + default: > > return -EINVAL; > > + } > > thanks, > > greg k-h
|  |