diff mbox series

[48/68] hwmon: nzxt: constify pointers to hwmon_channel_info

Message ID 20230406203530.3012191-7-krzysztof.kozlowski@linaro.org (mailing list archive)
State Accepted
Headers show
Series hwmon: constify pointers to hwmon_channel_info | expand

Commit Message

Krzysztof Kozlowski April 6, 2023, 8:35 p.m. UTC
Statically allocated array of pointed to hwmon_channel_info can be made
const for safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/hwmon/nzxt-kraken2.c | 2 +-
 drivers/hwmon/nzxt-smart2.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Aleksandr Mezin April 8, 2023, 3:14 a.m. UTC | #1
On Thu, Apr 6, 2023 at 11:37 PM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
> -static const struct hwmon_channel_info *nzxt_smart2_channel_info[] = {
> +static const struct hwmon_channel_info * const nzxt_smart2_channel_info[] = {

In the rest of nzxt-smart2.c there are spaces only before "*", not on
both sides (and there are a few "*const" already). Would be nice to
keep it consistent. The same seems to be true for nzxt-kraken2.c
(although I'm not a maintainer)
Jonas Malaco April 8, 2023, 10:33 a.m. UTC | #2
On Sat, Apr 08, 2023 at 06:14:19AM +0300, Aleksandr Mezin wrote:
> On Thu, Apr 6, 2023 at 11:37 PM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
> > -static const struct hwmon_channel_info *nzxt_smart2_channel_info[] = {
> > +static const struct hwmon_channel_info * const nzxt_smart2_channel_info[] = {
> 
> In the rest of nzxt-smart2.c there are spaces only before "*", not on
> both sides (and there are a few "*const" already). Would be nice to
> keep it consistent. The same seems to be true for nzxt-kraken2.c
> (although I'm not a maintainer)

While I don't have a strong preference for either `* const` or `*const`,
it would be prefereable to use a single style in any given file.

As the kernel seems to favor the former style:

$ rg -F '*const ' | wc -l
2593
$ rg -F '* const ' | wc -l
15359

it would be better to change the other two locations in nzxt-kraken2.c
to also use `* const`.
diff mbox series

Patch

diff --git a/drivers/hwmon/nzxt-kraken2.c b/drivers/hwmon/nzxt-kraken2.c
index 89f7ea4f42d4..428c77b5fce5 100644
--- a/drivers/hwmon/nzxt-kraken2.c
+++ b/drivers/hwmon/nzxt-kraken2.c
@@ -86,7 +86,7 @@  static const struct hwmon_ops kraken2_hwmon_ops = {
 	.read_string = kraken2_read_string,
 };
 
-static const struct hwmon_channel_info *kraken2_info[] = {
+static const struct hwmon_channel_info * const kraken2_info[] = {
 	HWMON_CHANNEL_INFO(temp,
 			   HWMON_T_INPUT | HWMON_T_LABEL),
 	HWMON_CHANNEL_INFO(fan,
diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c
index e5edf8071f39..7aa586eb74be 100644
--- a/drivers/hwmon/nzxt-smart2.c
+++ b/drivers/hwmon/nzxt-smart2.c
@@ -663,7 +663,7 @@  static const struct hwmon_ops nzxt_smart2_hwmon_ops = {
 	.write = nzxt_smart2_hwmon_write,
 };
 
-static const struct hwmon_channel_info *nzxt_smart2_channel_info[] = {
+static const struct hwmon_channel_info * const nzxt_smart2_channel_info[] = {
 	HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_LABEL,
 			   HWMON_F_INPUT | HWMON_F_LABEL,
 			   HWMON_F_INPUT | HWMON_F_LABEL),