Skip to contentSkip to conversation

s390: Initialize nr_devices count variable to -1

PATCH In review Aniroop Mathur 2 participants 2 messages Dec 28, 2014 – Dec 29, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390: Initialize nr_devices count variable to -1

From: Aniroop Mathur <[email protected]>

This patch initializes nr_device count variable to -1 to avoid extra subtraction operation performed everytime scm block device is set up.

---
 drivers/s390/block/scm_blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/block/scm_blk.c +2 -2
index 76bed17..ee2bd6f 100644
@@ -23,7 +23,7 @@ static int scm_major;
 static DEFINE_SPINLOCK(list_lock);
 static LIST_HEAD(inactive_requests);
 static unsigned int nr_requests = 64;
-static atomic_t nr_devices = ATOMIC_INIT(0);
+static atomic_t nr_devices = ATOMIC_INIT(-1);
 module_param(nr_requests, uint, S_IRUGO);
 MODULE_PARM_DESC(nr_requests, "Number of parallel requests.");
 
@@ -357,7 +357,7 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev)
 	int len, ret = -ENOMEM;
 	unsigned int devindex, nr_max_blk;
 
-	devindex = atomic_inc_return(&nr_devices) - 1;
+	devindex = atomic_inc_return(&nr_devices);
 	/* scma..scmz + scmaa..scmzz */
 	if (devindex > 701) {
 		ret = -ENODEV;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 24 lines · On Sun, 28 Dec 2014 21:42:53 +0530 Aniroop Mathur <[email protected]>…

From: Aniroop Mathur <[email protected]>

This patch initializes nr_device count variable to -1 to avoid extra subtraction operation performed everytime scm block device is set up.

---
 drivers/s390/block/scm_blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/block/scm_blk.c +1 -1
index 76bed17..ee2bd6f 100644
@@ -23,7 +23,7 @@ static int scm_major;
 static DEFINE_SPINLOCK(list_lock);
 static LIST_HEAD(inactive_requests);
 static unsigned int nr_requests = 64;
-static atomic_t nr_devices = ATOMIC_INIT(0);
+static atomic_t nr_devices = ATOMIC_INIT(-1);
 module_param(nr_requests, uint, S_IRUGO);
 MODULE_PARM_DESC(nr_requests, "Number of parallel requests.");
 

drivers/s390/block/scm_blk.c int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev) · line 363

Quoted 8 lines
drivers/s390/block/scm_blk.c +1 -1
@@ -357,7 +357,7 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev)
 	int len, ret = -ENOMEM;
 	unsigned int devindex, nr_max_blk;
 
-	devindex = atomic_inc_return(&nr_devices) - 1;
+	devindex = atomic_inc_return(&nr_devices);
 	/* scma..scmz + scmaa..scmzz */
 	if (devindex > 701) {
 		ret = -ENODEV;

This patch makes the code harder to read to avoid a single subtraction at device setup time. I prefer readability.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.