Skip to contentSkip to conversation

coresight: cti-sysfs: Mark coresight_cti_reg_store() as __maybe_unused

PATCH Applied Nathan Chancellor 3 participants 4 messages Sep 1, 2022 – Sep 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 coresight: cti-sysfs: Mark coresight_cti_reg_store() as __maybe_unused

When building without CONFIG_CORESIGHT_CTI_INTEGRATION_REGS, there is a warning about coresight_cti_reg_store() being unused in the file:

drivers/hwtracing/coresight/coresight-cti-sysfs.c:184:16: warning: 'coresight_cti_reg_store' defined but not used [-Wunused-function]
184 | static ssize_t coresight_cti_reg_store(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~

This is expected as coresight_cti_reg_store() is only used in the coresight_cti_reg_rw macro, which is only used in a block guarded by CONFIG_CORESIGHT_CTI_INTEGRATION_REGS. Mark coresight_cti_reg_store() as __maybe_unused to clearly indicate that the function may be unused depending on the configuration.

Fixes fbca79e55429 ("coresight: cti-sysfs: Re-use same functions for similar sysfs register accessors")
---
 drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-cti-sysfs.c +3 -3
index 478b8d38b744..6d59c815ecf5 100644
@@ -181,9 +181,9 @@ static ssize_t coresight_cti_reg_show(struct device *dev,
 }
 
 /* Write registers with power check only (no enable check). */
-static ssize_t coresight_cti_reg_store(struct device *dev,
-				       struct device_attribute *attr,
-				       const char *buf, size_t size)
+static __maybe_unused ssize_t coresight_cti_reg_store(struct device *dev,
+						      struct device_attribute *attr,
+						      const char *buf, size_t size)
 {
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);

base-commit: 0a98181f805058773961c5ab3172ecf1bf1ed0e1

Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Nathan Chancellor

When building without CONFIG_CORESIGHT_CTI_INTEGRATION_REGS, there is a warning about coresight_cti_reg_store() being unused in the file:

drivers/hwtracing/coresight/coresight-cti-sysfs.c:184:16: warning: 'coresight_cti_reg_store' defined but not used [-Wunused-function]
184 | static ssize_t coresight_cti_reg_store(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~

Quoted 5 lines

This is expected as coresight_cti_reg_store() is only used in the coresight_cti_reg_rw macro, which is only used in a block guarded by CONFIG_CORESIGHT_CTI_INTEGRATION_REGS. Mark coresight_cti_reg_store() as __maybe_unused to clearly indicate that the function may be unused depending on the configuration.

It would also be possible to fix this by wrapping the definitions in #ifdef CONFIG_CORESIGHT_CTI_INTEGRATION_REGS. That way the maybe_unused isn't needed and it's a bit cleaner.

Either way, thanks for the fix.

Quoted 25 lines
Fixes fbca79e55429 ("coresight: cti-sysfs: Re-use same functions for similar sysfs register accessors")
---
 drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-cti-sysfs.c +3 -3
index 478b8d38b744..6d59c815ecf5 100644
@@ -181,9 +181,9 @@ static ssize_t coresight_cti_reg_show(struct device *dev,
 }
 
 /* Write registers with power check only (no enable check). */
-static ssize_t coresight_cti_reg_store(struct device *dev,
-				       struct device_attribute *attr,
-				       const char *buf, size_t size)
+static __maybe_unused ssize_t coresight_cti_reg_store(struct device *dev,
+						      struct device_attribute *attr,
+						      const char *buf, size_t size)
 {
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);
Quoted 1 line

base-commit: 0a98181f805058773961c5ab3172ecf1bf1ed0e1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
Quoted 16 lines · James Clark
Quoted 7 lines · Nathan Chancellor

When building without CONFIG_CORESIGHT_CTI_INTEGRATION_REGS, there is a warning about coresight_cti_reg_store() being unused in the file:

drivers/hwtracing/coresight/coresight-cti-sysfs.c:184:16: warning: 'coresight_cti_reg_store' defined but not used [-Wunused-function]
184 | static ssize_t coresight_cti_reg_store(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~

Quoted 5 lines

This is expected as coresight_cti_reg_store() is only used in the coresight_cti_reg_rw macro, which is only used in a block guarded by CONFIG_CORESIGHT_CTI_INTEGRATION_REGS. Mark coresight_cti_reg_store() as __maybe_unused to clearly indicate that the function may be unused depending on the configuration.

Quoted 3 lines

It would also be possible to fix this by wrapping the definitions in #ifdef CONFIG_CORESIGHT_CTI_INTEGRATION_REGS. That way the maybe_unused isn't needed and it's a bit cleaner.

Right, I do not have a preference either. I only did this way first because most maintainers do not like ifdef's in .c files. I am happy to change the solution if you all prefer!

Quoted 3 lines

Either way, thanks for the fix.

Thanks for the review!

Cheers,
Nathan

Quoted 24 lines
Quoted 24 lines
Fixes fbca79e55429 ("coresight: cti-sysfs: Re-use same functions for similar sysfs register accessors")
---
 drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-cti-sysfs.c +3 -3
index 478b8d38b744..6d59c815ecf5 100644
@@ -181,9 +181,9 @@ static ssize_t coresight_cti_reg_show(struct device *dev,
 }
 
 /* Write registers with power check only (no enable check). */
-static ssize_t coresight_cti_reg_store(struct device *dev,
-				       struct device_attribute *attr,
-				       const char *buf, size_t size)
+static __maybe_unused ssize_t coresight_cti_reg_store(struct device *dev,
+						      struct device_attribute *attr,
+						      const char *buf, size_t size)
 {
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);
Quoted 1 line
Quoted 1 line

base-commit: 0a98181f805058773961c5ab3172ecf1bf1ed0e1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
In reply to Nathan Chancellor
Quoted 24 lines · Nathan Chancellor

When building without CONFIG_CORESIGHT_CTI_INTEGRATION_REGS, there is a warning about coresight_cti_reg_store() being unused in the file:

drivers/hwtracing/coresight/coresight-cti-sysfs.c:184:16: warning: 'coresight_cti_reg_store' defined but not used [-Wunused-function]
184 | static ssize_t coresight_cti_reg_store(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~

This is expected as coresight_cti_reg_store() is only used in the coresight_cti_reg_rw macro, which is only used in a block guarded by CONFIG_CORESIGHT_CTI_INTEGRATION_REGS. Mark coresight_cti_reg_store() as __maybe_unused to clearly indicate that the function may be unused depending on the configuration.

Fixes fbca79e55429 ("coresight: cti-sysfs: Re-use same functions for similar sysfs register accessors")
---
 drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-cti-sysfs.c +0 -0
index 478b8d38b744..6d59c815ecf5 100644

drivers/hwtracing/coresight/coresight-cti-sysfs.c static ssize_t coresight_cti_reg_show(struct device *dev, · line 187

Quoted 10 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +3 -3
@@ -181,9 +181,9 @@ static ssize_t coresight_cti_reg_show(struct device *dev,
 }
 
 /* Write registers with power check only (no enable check). */
-static ssize_t coresight_cti_reg_store(struct device *dev,
-				       struct device_attribute *attr,
-				       const char *buf, size_t size)
+static __maybe_unused ssize_t coresight_cti_reg_store(struct device *dev,
+						      struct device_attribute *attr,
+						      const char *buf, size_t size)
 {

Applied.

Thanks,
Mathieu

Quoted 7 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +0 -0
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);

base-commit: 0a98181f805058773961c5ab3172ecf1bf1ed0e1

Signature · 1 line
2.37.3

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel