Re: [PATCH 15/34] scsi: use atomic find_bit() API where appropriate

From: Bart Van Assche
Date: Sat Nov 18 2023 - 11:31:08 EST


On 11/18/23 07:50, Yury Norov wrote:
drivers/scsi/mpi3mr/mpi3mr_os.c | 21 ++++++---------------
drivers/scsi/qedi/qedi_main.c | 9 +--------
drivers/scsi/scsi_lib.c | 5 ++---
3 files changed, 9 insertions(+), 26 deletions(-)

One patch for each of the above source files please. mpi3mr and qedi are
both SCSI drivers. scsi_lib.c is a source file from the SCSI core.

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index cf3864f72093..4460a37f4864 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2499,9 +2499,8 @@ void scsi_evt_thread(struct work_struct *work)
sdev = container_of(work, struct scsi_device, event_work);
- for (evt_type = SDEV_EVT_FIRST; evt_type <= SDEV_EVT_LAST; evt_type++)
- if (test_and_clear_bit(evt_type, sdev->pending_events))
- sdev_evt_send_simple(sdev, evt_type, GFP_KERNEL);
+ for_each_test_and_clear_bit(evt_type, sdev->pending_events, SDEV_EVT_LAST)
+ sdev_evt_send_simple(sdev, evt_type, GFP_KERNEL);

Hmm ... the original code iterates over the range 1 .. SDEV_EVT_LAST
while the new code iterates over the range 0 .. SDEV_EVT_LAST - 1. Please fix this.

Thanks,

Bart.