linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bhumika Goyal <bhumirks@gmail.com>
To: wsa@the-dreams.de, linux-i2c@vger.kernel.org
Cc: Bhumika Goyal <bhumirks@gmail.com>
Subject: [PATCH] Drivers: i2c: busses: Use max macro instead of ternary operator
Date: Sun, 11 Sep 2016 00:26:20 +0530	[thread overview]
Message-ID: <1473533780-15964-1-git-send-email-bhumirks@gmail.com> (raw)

Replace ternary operators with macro 'max' as it is shorter
and thus increases code readability. Macro max returns
the  maximum of the two compared values.
Done using coccinelle:

@@
type T;
T x;
T y;
@@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/i2c/busses/i2c-jz4780.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c
index cd98725..b6c6f90 100644
--- a/drivers/i2c/busses/i2c-jz4780.c
+++ b/drivers/i2c/busses/i2c-jz4780.c
@@ -133,10 +133,10 @@ static const char * const jz4780_i2c_abrt_src[] = {
 
 #define JZ4780_I2C_ENB_I2C		BIT(0)
 
-#define JZ4780_I2CSHCNT_ADJUST(n)	(((n) - 8) < 6 ? 6 : ((n) - 8))
-#define JZ4780_I2CSLCNT_ADJUST(n)	(((n) - 1) < 8 ? 8 : ((n) - 1))
-#define JZ4780_I2CFHCNT_ADJUST(n)	(((n) - 8) < 6 ? 6 : ((n) - 8))
-#define JZ4780_I2CFLCNT_ADJUST(n)	(((n) - 1) < 8 ? 8 : ((n) - 1))
+#define JZ4780_I2CSHCNT_ADJUST(n)	(max(6, (n) - 8))
+#define JZ4780_I2CSLCNT_ADJUST(n)	(max(8, (n) - 1))
+#define JZ4780_I2CFHCNT_ADJUST(n)	(max(6, (n) - 8))
+#define JZ4780_I2CFLCNT_ADJUST(n)	(max(8, (n) - 1))
 
 #define JZ4780_I2C_FIFO_LEN	16
 #define TX_LEVEL		3
-- 
1.9.1

             reply	other threads:[~2016-09-10 18:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-10 18:56 Bhumika Goyal [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-09-10 19:08 [PATCH] Drivers: i2c: busses: Use max macro instead of ternary operator Bhumika Goyal
2016-09-10 19:21 ` Joe Perches
2016-09-10 19:24   ` Bhumika Goyal

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=1473533780-15964-1-git-send-email-bhumirks@gmail.com \
    --to=bhumirks@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /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).