Skip to contentSkip to conversation

hw/net/can: Remove redundant status bit setting in can_sja1000

PATCH In review SillyZ 3 participants 3 messages Sep 16, 2025 – Sep 17, 2025

lore
Share & tools
lore

SillyZ

author
#0 lore raw

PATCH 1/1 hw/net/can: Remove redundant status bit setting in can_sja1000

In PeliCAN mode reception, the RBS (Receive Buffer Status) bit is set twice at line 842 and 845 with identical operations:
s->status_pel |= 0x01;
s->status_pel |= (1 << 0);

Between these two operations, only interrupt_pel is modified and status_pel bit 4 is cleared, neither affecting bit 0. The second operation is redundant.

This cleanup aligns PeliCAN mode with BasicCAN mode, which correctly sets this bit only once (line 883).

---
 hw/net/can/can_sja1000.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/can/can_sja1000.c +0 -1
index 5b6ba9df6c..6b08e977a1 100644
@@ -842,7 +842,6 @@ ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames,
         s->status_pel |= 0x01; /* Set the Receive Buffer Status. DS-p23 */
         s->interrupt_pel |= 0x01;
         s->status_pel &= ~(1 << 4);
-        s->status_pel |= (1 << 0);
         can_sja_update_pel_irq(s);
     } else { /* BasicCAN mode */
 
Signature · 1 line
2.47.1.windows.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · SillyZ

In PeliCAN mode reception, the RBS (Receive Buffer Status) bit is set twice at line 842 and 845 with identical operations:
s->status_pel |= 0x01;
s->status_pel |= (1 << 0);

Between these two operations, only interrupt_pel is modified and status_pel bit 4 is cleared, neither affecting bit 0. The second operation is redundant.

This cleanup aligns PeliCAN mode with BasicCAN mode, which correctly sets this bit only once (line 883).

---
 hw/net/can/can_sja1000.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/can/can_sja1000.c +0 -0
index 5b6ba9df6c..6b08e977a1 100644

hw/net/can/can_sja1000.c ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames, · line 847

Quoted 7 lines
hw/net/can/can_sja1000.c +0 -1
@@ -842,7 +842,6 @@ ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames,
         s->status_pel |= 0x01; /* Set the Receive Buffer Status. DS-p23 */
         s->interrupt_pel |= 0x01;
         s->status_pel &= ~(1 << 4);
-        s->status_pel |= (1 << 0);
         can_sja_update_pel_irq(s);
     } else { /* BasicCAN mode */
 

thanks
-- PMM

Reviewed-by on v1 1/1
#2 lore raw
In reply to SillyZ
Quoted 5 lines · SillyZ

In PeliCAN mode reception, the RBS (Receive Buffer Status) bit is set twice at line 842 and 845 with identical operations:

   s->status_pel |= 0x01;
   s->status_pel |= (1 << 0);
Quoted 8 lines

Between these two operations, only interrupt_pel is modified and status_pel bit 4 is cleared, neither affecting bit 0. The second operation is redundant.

This cleanup aligns PeliCAN mode with BasicCAN mode, which correctly sets this bit only once (line 883).

And applied to the trivial-patches tree.

Thanks,

/mjt