* [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
@ 2023-01-11 2:07 XU pengfei
2023-01-11 3:29 ` Guenter Roeck
0 siblings, 1 reply; 4+ messages in thread
From: XU pengfei @ 2023-01-11 2:07 UTC (permalink / raw)
To: jdelvare, linux; +Cc: linux-hwmon, linux-kernel, XU pengfei
Pointer variables of void * type do not require type cast.
Signed-off-by: XU pengfei <xupengfei@nfschina.com>
---
drivers/hwmon/ibmpex.c | 2 +-
drivers/hwmon/powr1220.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index 1837cccd993c..db066b368918 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -546,7 +546,7 @@ static void ibmpex_bmc_gone(int iface)
static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
{
- struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
+ struct ibmpex_bmc_data *data = user_msg_data;
if (msg->msgid != data->tx_msgid) {
dev_err(data->bmc_device,
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;
if (channel >= chip_data->max_channels)
return 0;
--
2.18.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
2023-01-11 2:07 [PATCH 1/1] hwmon: remove unnecessary (void*) conversions XU pengfei
@ 2023-01-11 3:29 ` Guenter Roeck
2023-01-11 6:03 ` Ammar Faizi
0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2023-01-11 3:29 UTC (permalink / raw)
To: XU pengfei, jdelvare; +Cc: linux-hwmon, linux-kernel
On 1/10/23 18:07, XU pengfei wrote:
> Pointer variables of void * type do not require type cast.
>
One patch per driver, and include the driver name (ibmpex, powr1220)
in the subject.
Guenter
> Signed-off-by: XU pengfei <xupengfei@nfschina.com>
> ---
> drivers/hwmon/ibmpex.c | 2 +-
> drivers/hwmon/powr1220.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index 1837cccd993c..db066b368918 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -546,7 +546,7 @@ static void ibmpex_bmc_gone(int iface)
>
> static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
> {
> - struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
> + struct ibmpex_bmc_data *data = user_msg_data;
>
> if (msg->msgid != data->tx_msgid) {
> dev_err(data->bmc_device,
> 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;
>
> if (channel >= chip_data->max_channels)
> return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
2023-01-11 3:29 ` Guenter Roeck
@ 2023-01-11 6:03 ` Ammar Faizi
2023-01-11 6:09 ` Ammar Faizi
0 siblings, 1 reply; 4+ messages in thread
From: Ammar Faizi @ 2023-01-11 6:03 UTC (permalink / raw)
To: XU pengfei, Guenter Roeck
Cc: Linux Kernel Mailing List, Jean Delvare, linux-hwmon
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
--
Ammar Faizi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
2023-01-11 6:03 ` Ammar Faizi
@ 2023-01-11 6:09 ` Ammar Faizi
0 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2023-01-11 6:09 UTC (permalink / raw)
To: XU pengfei, Guenter Roeck
Cc: Linux Kernel Mailing List, Jean Delvare, linux-hwmon
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-11 6:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 2:07 [PATCH 1/1] hwmon: remove unnecessary (void*) conversions XU pengfei
2023-01-11 3:29 ` Guenter Roeck
2023-01-11 6:03 ` Ammar Faizi
2023-01-11 6:09 ` Ammar Faizi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).