coresight: etm4x: Two function calls less
PATCH 1/1 coresight: etm4x: Two function calls less
From: Markus Elfring <[email protected]>
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.
--- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +4 -9
@@ -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
Quoted 33 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 5 Jul 2019 19:33:26 +0200Avoid 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 <[email protected]>--- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +2
-5@@ -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 */
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c static ssize_t addr_range_store(struct device *dev, · line 1000
Quoted 9 lines
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +2
-4@@ -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
Quoted 6 lines
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +0
-1spin_unlock (&drvdata->spinlock);return size; --2.22.0