From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755425AbcFTUJQ (ORCPT ); Mon, 20 Jun 2016 16:09:16 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:51592 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755331AbcFTUIc (ORCPT ); Mon, 20 Jun 2016 16:08:32 -0400 From: Davidlohr Bueso 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" , Davidlohr Bueso Subject: [PATCH 11/12] scsi: Employ atomic_fetch_inc() Date: Mon, 20 Jun 2016 13:06:03 -0700 Message-Id: <1466453164-13185-12-git-send-email-dave@stgolabs.net> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1466453164-13185-1-git-send-email-dave@stgolabs.net> References: <1466453164-13185-1-git-send-email-dave@stgolabs.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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" Cc: "Martin K. Petersen" Signed-off-by: Davidlohr Bueso --- 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