LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] s390: Initialize nr_devices count variable to -1
@ 2014-12-28 16:12 Aniroop Mathur
  2014-12-29  9:56 ` Martin Schwidefsky
  0 siblings, 1 reply; 2+ messages in thread
From: Aniroop Mathur @ 2014-12-28 16:12 UTC (permalink / raw)
  To: schwidefsky, heiko.carstens, linux390, linux-s390, linux-kernel
  Cc: aniroop.mathur, a.mathur

From: Aniroop Mathur <a.mathur@samsung.com>

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

Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
---
 drivers/s390/block/scm_blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c
index 76bed17..ee2bd6f 100644
--- a/drivers/s390/block/scm_blk.c
+++ b/drivers/s390/block/scm_blk.c
@@ -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;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] s390: Initialize nr_devices count variable to -1
  2014-12-28 16:12 [PATCH] s390: Initialize nr_devices count variable to -1 Aniroop Mathur
@ 2014-12-29  9:56 ` Martin Schwidefsky
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Schwidefsky @ 2014-12-29  9:56 UTC (permalink / raw)
  To: Aniroop Mathur
  Cc: heiko.carstens, linux390, linux-s390, linux-kernel, a.mathur

On Sun, 28 Dec 2014 21:42:53 +0530
Aniroop Mathur <aniroop.mathur@gmail.com> wrote:

> From: Aniroop Mathur <a.mathur@samsung.com>
> 
> This patch initializes nr_device count variable to -1 to avoid extra
> subtraction operation performed everytime scm block device is set up.
> 
> Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
> ---
>  drivers/s390/block/scm_blk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c
> index 76bed17..ee2bd6f 100644
> --- a/drivers/s390/block/scm_blk.c
> +++ b/drivers/s390/block/scm_blk.c
> @@ -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;

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

-- 
blue skies,
   Martin.

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-29  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-28 16:12 [PATCH] s390: Initialize nr_devices count variable to -1 Aniroop Mathur
2014-12-29  9:56 ` Martin Schwidefsky

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).