[PATCH 11/12] scsi: Employ atomic_fetch_inc()
From: Davidlohr Bueso
Date: Mon Jun 20 2016 - 16:09:20 EST
Now that we have fetch_inc() we can stop using inc_return() - 1.
These are very similar to the existing OP-RETURN primitives we already
have, except they return the value of the atomic variable _before_
modification.
Cc: "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
Cc: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
---
drivers/scsi/fcoe/fcoe_sysfs.c | 4 ++--
drivers/scsi/scsi_lib.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index 045c4e11ee54..3d6833fbdea7 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -685,7 +685,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
if (!ctlr)
goto out;
- ctlr->id = atomic_inc_return(&ctlr_num) - 1;
+ ctlr->id = atomic_fetch_inc(&ctlr_num);
ctlr->f = f;
ctlr->mode = FIP_CONN_TYPE_FABRIC;
INIT_LIST_HEAD(&ctlr->fcfs);
@@ -902,7 +902,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
fcf->dev.parent = &ctlr->dev;
fcf->dev.bus = &fcoe_bus_type;
fcf->dev.type = &fcoe_fcf_device_type;
- fcf->id = atomic_inc_return(&fcf_num) - 1;
+ fcf->id = atomic_fetch_inc(&fcf_num);
fcf->state = FCOE_FCF_STATE_UNKNOWN;
fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c71344aebdbb..113ec916210d 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1322,7 +1322,7 @@ static inline int scsi_dev_queue_ready(struct request_queue *q,
{
unsigned int busy;
- busy = atomic_inc_return(&sdev->device_busy) - 1;
+ busy = atomic_fetch_inc(&sdev->device_busy);
if (atomic_read(&sdev->device_blocked)) {
if (busy)
goto out_dec;
@@ -1375,7 +1375,7 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost,
if (starget->can_queue <= 0)
return 1;
- busy = atomic_inc_return(&starget->target_busy) - 1;
+ busy = atomic_fetch_inc(&starget->target_busy);
if (atomic_read(&starget->target_blocked) > 0) {
if (busy)
goto starved;
@@ -1419,7 +1419,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
if (scsi_host_in_recovery(shost))
return 0;
- busy = atomic_inc_return(&shost->host_busy) - 1;
+ busy = atomic_fetch_inc(&shost->host_busy);
if (atomic_read(&shost->host_blocked) > 0) {
if (busy)
goto starved;
--
2.6.6