linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: peterz@infradead.org, mingo@kernel.org
Cc: davem@davemloft.net, cw00.choi@samsung.com,
	dougthompson@xmission.com, bp@alien8.de, mchehab@osg.samsung.com,
	gregkh@linuxfoundation.org, pfg@sgi.com, jikos@kernel.org,
	hans.verkuil@cisco.com, awalls@md.metrocast.net,
	dledford@redhat.com, sean.hefty@intel.com, kys@microsoft.com,
	heiko.carstens@de.ibm.com, James.Bottomley@HansenPartnership.com,
	sumit.semwal@linaro.org, schwidefsky@de.ibm.com,
	linux-kernel@vger.kernel.org, dave@stgolabs.net,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH 11/12] scsi: Employ atomic_fetch_inc()
Date: Mon, 20 Jun 2016 13:06:03 -0700	[thread overview]
Message-ID: <1466453164-13185-12-git-send-email-dave@stgolabs.net> (raw)
In-Reply-To: <1466453164-13185-1-git-send-email-dave@stgolabs.net>

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@HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 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

  parent reply	other threads:[~2016-06-20 20:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 20:05 [PATCH -tip 00/12] locking/atomics: Add and use inc,dec calls for FETCH-OP flavors Davidlohr Bueso
2016-06-20 20:05 ` [PATCH 01/12] locking/atomic: Introduce inc/dec " Davidlohr Bueso
2016-06-21  7:28   ` Peter Zijlstra
2016-06-21 13:33   ` [PATCH v2 " Davidlohr Bueso
2016-06-21 16:36     ` Davidlohr Bueso
2016-06-23  9:09       ` Peter Zijlstra
2016-06-24 16:34         ` Davidlohr Bueso
2016-06-24 18:48           ` Peter Zijlstra
2016-06-28 21:56             ` [PATCH -v4 " Davidlohr Bueso
2016-07-07  8:33               ` [tip:locking/core] locking/atomic: Introduce inc/dec variants for the atomic_fetch_$op() API tip-bot for Davidlohr Bueso
2016-06-20 20:05 ` [PATCH 02/12] net/neighbour: Employ atomic_fetch_inc() Davidlohr Bueso
2016-06-20 20:05 ` [PATCH 03/12] PM,devfreq: " Davidlohr Bueso
2016-07-02  5:04   ` Chanwoo Choi
2016-06-20 20:05 ` [PATCH 04/12] EDAC: " Davidlohr Bueso
2016-06-21 13:59   ` Borislav Petkov
2016-06-20 20:05 ` [PATCH 05/12] tty/serial: " Davidlohr Bueso
2016-06-20 20:05 ` [PATCH 06/12] HID,wacom: " Davidlohr Bueso
2016-06-22  8:10   ` Jiri Kosina
2016-06-20 20:05 ` [PATCH 07/12] drivers/media: " Davidlohr Bueso
2016-07-13 16:07   ` Mauro Carvalho Chehab
2016-06-20 20:06 ` [PATCH 08/12] infiniband: " Davidlohr Bueso
2016-06-20 20:06 ` [PATCH 09/12] drivers/hv: " Davidlohr Bueso
2016-06-20 20:06 ` [PATCH 10/12] s390/scm_block: " Davidlohr Bueso
2016-06-20 20:06 ` Davidlohr Bueso [this message]
2016-06-20 20:06 ` [PATCH 12/12] dma-buf/fence: Employ atomic_fetch_add Davidlohr Bueso
2016-06-24 16:46 ` [PATCH -tip 00/12] locking/atomics: Add and use inc,dec calls for FETCH-OP flavors James Bottomley
2016-06-24 17:30   ` Davidlohr Bueso
2016-06-24 17:44     ` James Bottomley
2016-06-24 20:35       ` Davidlohr Bueso
2016-06-24 17:45     ` KY Srinivasan
2016-06-24 19:35       ` Davidlohr Bueso
2016-06-24 19:17   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466453164-13185-12-git-send-email-dave@stgolabs.net \
    --to=dave@stgolabs.net \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=awalls@md.metrocast.net \
    --cc=bp@alien8.de \
    --cc=cw00.choi@samsung.com \
    --cc=davem@davemloft.net \
    --cc=dbueso@suse.de \
    --cc=dledford@redhat.com \
    --cc=dougthompson@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hans.verkuil@cisco.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jikos@kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mchehab@osg.samsung.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pfg@sgi.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=sean.hefty@intel.com \
    --cc=sumit.semwal@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).