Skip to contentSkip to conversation

staging: greybus: spilib: Remove the local unused

PATCH In review [email protected] 2 participants 3 messages Aug 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: greybus: spilib: Remove the local unused

From: Supreet Singh <[email protected]>

The return value of spi_new_device() is only used to check whether device creation succeeded. Remove the unnecessary local variable and check the return value directly.

---
 drivers/staging/greybus/spilib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/greybus/spilib.c +1 -3
index 39d5bf234c61..0e8711fdc429 100644
@@ -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;
 
@@ -480,8 +479,7 @@ static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs)
 	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))
 		return -EINVAL;
 
 	return 0;
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 24 lines · On Thu, Aug 20, 2026 at 04:02:35PM +0530, [email protected] wrote:

From: Supreet Singh <[email protected]>

The return value of spi_new_device() is only used to check whether device creation succeeded. Remove the unnecessary local variable and check the return value directly.

---
 drivers/staging/greybus/spilib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/greybus/spilib.c +0 -1
index 39d5bf234c61..0e8711fdc429 100644
@@ -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;
 

drivers/staging/greybus/spilib.c static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs) · line 483

Quoted 7 lines
drivers/staging/greybus/spilib.c +1 -2
@@ -480,8 +479,7 @@ static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs)
 	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))
 		return -EINVAL;

No, this change just makes the code harder to read.

Johan