linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: ti: dflt: remove redundant unlikely
@ 2016-04-05 18:28 Suman Anna
  2016-04-05 21:30 ` Joe Perches
  2016-04-15 22:52 ` Stephen Boyd
  0 siblings, 2 replies; 4+ messages in thread
From: Suman Anna @ 2016-04-05 18:28 UTC (permalink / raw)
  To: Tero Kristo
  Cc: Mike Turquette, Stephen Boyd, linux-omap, linux-clk, linux-kernel,
	Suman Anna

Commit 7aba4f5201d1 ("clk: ti: dflt: fix enable_reg validity check")
fixed a validation check by using an IS_ERR() macro within the
existing unlikely expression, but IS_ERR() macro already has an
unlikely inside it, so get rid of the redundant unlikely macro
from the validation check.

Reported-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
---
 drivers/clk/ti/clkt_dflt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/ti/clkt_dflt.c b/drivers/clk/ti/clkt_dflt.c
index 1ddc288fce4e..c6ae563801d7 100644
--- a/drivers/clk/ti/clkt_dflt.c
+++ b/drivers/clk/ti/clkt_dflt.c
@@ -222,7 +222,7 @@ int omap2_dflt_clk_enable(struct clk_hw *hw)
 		}
 	}
 
-	if (unlikely(IS_ERR(clk->enable_reg))) {
+	if (IS_ERR(clk->enable_reg)) {
 		pr_err("%s: %s missing enable_reg\n", __func__,
 		       clk_hw_get_name(hw));
 		ret = -EINVAL;
-- 
2.7.4


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

* Re: [PATCH] clk: ti: dflt: remove redundant unlikely
  2016-04-05 18:28 [PATCH] clk: ti: dflt: remove redundant unlikely Suman Anna
@ 2016-04-05 21:30 ` Joe Perches
  2016-04-15 22:53   ` Stephen Boyd
  2016-04-15 22:52 ` Stephen Boyd
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2016-04-05 21:30 UTC (permalink / raw)
  To: Suman Anna, Tero Kristo, Andrew Morton
  Cc: Mike Turquette, Stephen Boyd, linux-omap, linux-clk, linux-kernel

On Tue, 2016-04-05 at 13:28 -0500, Suman Anna wrote:
> Commit 7aba4f5201d1 ("clk: ti: dflt: fix enable_reg validity check")
> fixed a validation check by using an IS_ERR() macro within the
> existing unlikely expression, but IS_ERR() macro already has an
> unlikely inside it, so get rid of the redundant unlikely macro
> from the validation check.
[]
> diff --git a/drivers/clk/ti/clkt_dflt.c b/drivers/clk/ti/clkt_dflt.c
[]
> @@ -222,7 +222,7 @@ int omap2_dflt_clk_enable(struct clk_hw *hw)
>  		}
>  	}
>  
> -	if (unlikely(IS_ERR(clk->enable_reg))) {
> +	if (IS_ERR(clk->enable_reg)) {
>  		pr_err("%s: %s missing enable_reg\n", __func__,
>  		       clk_hw_get_name(hw));
>  		ret = -EINVAL;

There are several of these:

$ git grep -n -E "likely.*\bIS_ERR\s*\(" *
drivers/clk/ti/clkt_dflt.c:225: if (unlikely(IS_ERR(clk->enable_reg))) {
drivers/md/dm-verity-fec.c:76:  if (unlikely(IS_ERR(res))) {
drivers/md/dm-verity-fec.c:168:                 if (unlikely(IS_ERR(par)))
drivers/md/dm-verity-fec.c:253:         if (unlikely(IS_ERR(bbuf))) {
drivers/net/ethernet/broadcom/bnxt/bnxt.c:1109:         if (unlikely(IS_ERR(skb)))
drivers/net/ethernet/hisilicon/hns/hns_enet.c:1010:     if (unlikely(!phy_dev) || IS_ERR(phy_dev))
drivers/net/ethernet/sun/ldmvsw.c:302:  if (unlikely(IS_ERR(vp))) {
drivers/scsi/bnx2fc/bnx2fc_fcoe.c:2547: if (likely(!IS_ERR(thread))) {
drivers/scsi/bnx2i/bnx2i_init.c:431:    if (likely(!IS_ERR(thread))) {
drivers/scsi/fcoe/fcoe.c:1263:  if (likely(!IS_ERR(thread))) {
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c:1500:               if (likely(!IS_ERR(pfmr))) {
drivers/thermal/intel_powerclamp.c:541:         if (likely(!IS_ERR(thread))) {
drivers/thermal/intel_powerclamp.c:591:         if (likely(!IS_ERR(thread))) {
drivers/tty/serial/serial_core.c:2682:  if (likely(!IS_ERR(tty_dev))) {
fs/gfs2/dir.c:854:      if (unlikely(dent == NULL || IS_ERR(dent))) {
fs/ntfs/inode.c:2724:   if (unlikely(err || IS_ERR(m))) {
fs/ntfs/lcnalloc.c:744: if (likely(page && !IS_ERR(page))) {
fs/ntfs/mft.c:85:       if (likely(!IS_ERR(page))) {
fs/ntfs/mft.c:168:      if (likely(!IS_ERR(m)))
fs/ntfs/mft.c:285:              if (likely(!IS_ERR(m))) {
fs/ntfs/mft.c:1311:     if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) {
fs/ntfs/mft.c:1742:     if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) {
fs/ntfs/mft.c:1784:             if (likely(!IS_ERR(rl2)))
fs/ntfs/namei.c:132:            if (likely(!IS_ERR(dent_inode))) {
fs/ntfs/runlist.c:968:  if (likely(!IS_ERR(old_rl)))
fs/ntfs/super.c:1492:   if (unlikely(IS_ERR(tmp_ino) || is_bad_inode(tmp_ino))) {
net/ipv6/addrconf.c:3212:               if (unlikely(IS_ERR(rt)))
net/kcm/kcmsock.c:1969: if (unlikely(IS_ERR(newfile))) {
net/openvswitch/datapath.c:1315:                if (likely(!IS_ERR(reply))) {
net/socket.c:399:       if (likely(!IS_ERR(newfile))) {

Maybe a new checkpatch test like:
---
 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3d9c34..25e81b9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5734,6 +5734,13 @@ sub process {
 			}
 		}
 
+# check for IS_ERR with likely
+
+		if ($line =~ /\b((?:un)?likely)\s*\(\s*\!?\s*IS_ERR\s*\(/) {
+			WARN("IS_ERR_IS_UNLIKELY",
+			     "Using $1 isn't recommended as IS_ERR already uses unlikely\n" . $herecurr);
+		}
+
 # check for semaphores initialized locked
 		if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
 			WARN("CONSIDER_COMPLETION",

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

* Re: [PATCH] clk: ti: dflt: remove redundant unlikely
  2016-04-05 18:28 [PATCH] clk: ti: dflt: remove redundant unlikely Suman Anna
  2016-04-05 21:30 ` Joe Perches
@ 2016-04-15 22:52 ` Stephen Boyd
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2016-04-15 22:52 UTC (permalink / raw)
  To: Suman Anna
  Cc: Tero Kristo, Mike Turquette, linux-omap, linux-clk, linux-kernel

On 04/05, Suman Anna wrote:
> Commit 7aba4f5201d1 ("clk: ti: dflt: fix enable_reg validity check")
> fixed a validation check by using an IS_ERR() macro within the
> existing unlikely expression, but IS_ERR() macro already has an
> unlikely inside it, so get rid of the redundant unlikely macro
> from the validation check.
> 
> Reported-by: Stephen Boyd <sboyd@codeaurora.org>
> Signed-off-by: Suman Anna <s-anna@ti.com>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH] clk: ti: dflt: remove redundant unlikely
  2016-04-05 21:30 ` Joe Perches
@ 2016-04-15 22:53   ` Stephen Boyd
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2016-04-15 22:53 UTC (permalink / raw)
  To: Joe Perches
  Cc: Suman Anna, Tero Kristo, Andrew Morton, Mike Turquette,
	linux-omap, linux-clk, linux-kernel

On 04/05, Joe Perches wrote:
> 
> There are several of these:
[...]
> 
> Maybe a new checkpatch test like:

Looks good to me.
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2016-04-15 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-05 18:28 [PATCH] clk: ti: dflt: remove redundant unlikely Suman Anna
2016-04-05 21:30 ` Joe Perches
2016-04-15 22:53   ` Stephen Boyd
2016-04-15 22:52 ` Stephen Boyd

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