[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dada9a9c-32fd-9d8c-b692-5efb8a94c20f@gnuweeb.org>
Date: Wed, 11 Jan 2023 13:09:35 +0700
From: Ammar Faizi <ammarfaizi2@...weeb.org>
To: XU pengfei <xupengfei@...china.com>,
Guenter Roeck <linux@...ck-us.net>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
On 1/11/23 1:03 PM, Ammar Faizi wrote:
> On 1/11/23 10:29 AM, Guenter Roeck wrote:
>> On 1/10/23 18:07, XU pengfei wrote:
>>> diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
>>> index f77dc6db31ac..501337ee5aa3 100644
>>> --- a/drivers/hwmon/powr1220.c
>>> +++ b/drivers/hwmon/powr1220.c
>>> @@ -174,7 +174,7 @@ static umode_t
>>> powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
>>> attr, int channel)
>>> {
>>> - struct powr1220_data *chip_data = (struct powr1220_data *)data;
>>> + struct powr1220_data *chip_data = data;
>
> This is wrong. That cast is needed to discard the "const".
>
> CC [M] drivers/hwmon/powr1220.o
> drivers/hwmon/powr1220.c: In function ‘powr1220_is_visible’:
> drivers/hwmon/powr1220.c:177:43: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
> 177 | struct powr1220_data *chip_data = data;
> | ^~~~
> cc1: all warnings being treated as errors
Anyway, powr1220_is_visible() doesn't write via that pointer, but
the local variable needs to be a const as well.
diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
index f77dc6db31ac..7cbbed5a6f5e 100644
--- a/drivers/hwmon/powr1220.c
+++ b/drivers/hwmon/powr1220.c
@@ -174,7 +174,7 @@ static umode_t
powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
attr, int channel)
{
- struct powr1220_data *chip_data = (struct powr1220_data *)data;
+ const struct powr1220_data *chip_data = data;
if (channel >= chip_data->max_channels)
return 0;
--
Ammar Faizi
Powered by blists - more mailing lists