lkml.org 
[lkml]   [2023]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
From
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

\
 
 \ /
  Last update: 2023-03-26 23:35    [W:0.035 / U:2.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site