[PATCH can-next 08/10] can: gs_usb: gs_usb_receive_bulk_callback(): reduce scope of several variables
From: Marc Kleine-Budde
Date: Sat Oct 03 2026 - 18:56:28 EST
To improve readability of the code, reduce the scope of the variables txc,
cf and cfd and skb.
Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
drivers/net/can/usb/gs_usb.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 86f7cac093a1..190cd3701202 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -599,10 +599,6 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
struct net_device_stats *stats;
struct gs_host_frame *hf = urb->transfer_buffer;
unsigned int minimum_length, data_length;
- struct gs_tx_context *txc;
- struct can_frame *cf;
- struct canfd_frame *cfd;
- struct sk_buff *skb;
BUG_ON(!parent);
@@ -660,7 +656,11 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
}
if (hf->echo_id == GS_HOST_FRAME_ECHO_ID_RX) { /* normal rx */
+ struct sk_buff *skb;
+
if (hf->flags & GS_CAN_FLAG_FD) {
+ struct canfd_frame *cfd;
+
skb = alloc_canfd_skb(netdev, &cfd);
if (!skb)
goto check_overflow;
@@ -674,6 +674,8 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
memcpy(cfd->data, hf->canfd->data, data_length);
} else {
+ struct can_frame *cf;
+
skb = alloc_can_skb(netdev, &cf);
if (!skb)
goto check_overflow;
@@ -690,6 +692,9 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
gs_usb_rx_offload(dev, skb, hf);
} else { /* echo_id == hf->echo_id */
+ struct gs_tx_context *txc;
+ struct sk_buff *skb;
+
if (hf->echo_id >= GS_MAX_TX_URBS) {
netdev_err(netdev,
"Unexpected out of range echo id %u\n",
@@ -719,6 +724,9 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
check_overflow:
if (hf->flags & GS_CAN_FLAG_OVERFLOW) {
+ struct can_frame *cf;
+ struct sk_buff *skb;
+
stats->rx_over_errors++;
stats->rx_errors++;
--
2.53.0