linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] coresight: etm4x: Two function calls less
@ 2019-07-05 17:39 Markus Elfring
  2019-07-08 16:16 ` Mathieu Poirier
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2019-07-05 17:39 UTC (permalink / raw)
  To: linux-arm-kernel, Alexander Shishkin, Mathieu Poirier, Suzuki K. Poulose
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 5 Jul 2019 19:33:26 +0200

Avoid an extra function call in two function implementations
by using a ternary operator instead of a conditional statement.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
index a0365e23678e..219c10eb752c 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
@@ -296,11 +296,8 @@ static ssize_t mode_store(struct device *dev,

 	spin_lock(&drvdata->spinlock);
 	config->mode = val & ETMv4_MODE_ALL;
-
-	if (config->mode & ETM_MODE_EXCLUDE)
-		etm4_set_mode_exclude(drvdata, true);
-	else
-		etm4_set_mode_exclude(drvdata, false);
+	etm4_set_mode_exclude(drvdata,
+			      config->mode & ETM_MODE_EXCLUDE ? true : false);

 	if (drvdata->instrp0 == true) {
 		/* start by clearing instruction P0 field */
@@ -999,10 +996,8 @@ static ssize_t addr_range_store(struct device *dev,
 	 * Program include or exclude control bits for vinst or vdata
 	 * whenever we change addr comparators to ETM_ADDR_TYPE_RANGE
 	 */
-	if (config->mode & ETM_MODE_EXCLUDE)
-		etm4_set_mode_exclude(drvdata, true);
-	else
-		etm4_set_mode_exclude(drvdata, false);
+	etm4_set_mode_exclude(drvdata,
+			      config->mode & ETM_MODE_EXCLUDE ? true : false);

 	spin_unlock(&drvdata->spinlock);
 	return size;
--
2.22.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] coresight: etm4x: Two function calls less
  2019-07-05 17:39 [PATCH] coresight: etm4x: Two function calls less Markus Elfring
@ 2019-07-08 16:16 ` Mathieu Poirier
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Poirier @ 2019-07-08 16:16 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Alexander Shishkin, kernel-janitors, LKML, linux-arm-kernel,
	Suzuki K. Poulose

On Fri, 5 Jul 2019 at 11:40, Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 5 Jul 2019 19:33:26 +0200
>
> Avoid an extra function call in two function implementations
> by using a ternary operator instead of a conditional statement.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> index a0365e23678e..219c10eb752c 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> @@ -296,11 +296,8 @@ static ssize_t mode_store(struct device *dev,
>
>         spin_lock(&drvdata->spinlock);
>         config->mode = val & ETMv4_MODE_ALL;
> -
> -       if (config->mode & ETM_MODE_EXCLUDE)
> -               etm4_set_mode_exclude(drvdata, true);
> -       else
> -               etm4_set_mode_exclude(drvdata, false);
> +       etm4_set_mode_exclude(drvdata,
> +                             config->mode & ETM_MODE_EXCLUDE ? true : false);
>
>         if (drvdata->instrp0 == true) {
>                 /* start by clearing instruction P0 field */
> @@ -999,10 +996,8 @@ static ssize_t addr_range_store(struct device *dev,
>          * Program include or exclude control bits for vinst or vdata
>          * whenever we change addr comparators to ETM_ADDR_TYPE_RANGE
>          */
> -       if (config->mode & ETM_MODE_EXCLUDE)
> -               etm4_set_mode_exclude(drvdata, true);
> -       else
> -               etm4_set_mode_exclude(drvdata, false);
> +       etm4_set_mode_exclude(drvdata,
> +                             config->mode & ETM_MODE_EXCLUDE ? true : false);

Looks good to me - I will add this to my next branch when we have a new 5.3-rc1.

Thanks,
Mathieu

>
>         spin_unlock(&drvdata->spinlock);
>         return size;
> --
> 2.22.0
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-07-08 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05 17:39 [PATCH] coresight: etm4x: Two function calls less Markus Elfring
2019-07-08 16:16 ` Mathieu Poirier

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