* [PATCH] hwmon: ibmaem: match return type of wait_for_completion_timeout
@ 2025-06-12 18:43 Qiushi Wu
2025-06-12 20:57 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Qiushi Wu @ 2025-06-12 18:43 UTC (permalink / raw)
To: linux-kernel; +Cc: jdelvare, linux, linux-hwmon, zohar, qiushi.wu, Qiushi Wu
Return type of wait_for_completion_timeout is unsigned long not int.
Check its return value inline instead of introducing a throw-away
variable.
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Qiushi Wu <qiushi@linux.ibm.com>
---
drivers/hwmon/ibmaem.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 157e232aace0..e52e937a396c 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -383,8 +383,7 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
aem_send_message(ipmi);
- res = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT);
- if (!res) {
+ if (!wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT)) {
res = -ETIMEDOUT;
goto out;
}
@@ -491,7 +490,6 @@ static void aem_delete(struct aem_data *data)
/* Retrieve version and module handle for an AEM1 instance */
static int aem_find_aem1_count(struct aem_ipmi_data *data)
{
- int res;
struct aem_find_firmware_req ff_req;
struct aem_find_firmware_resp ff_resp;
@@ -508,8 +506,7 @@ static int aem_find_aem1_count(struct aem_ipmi_data *data)
aem_send_message(data);
- res = wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT);
- if (!res)
+ if (!wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT))
return -ETIMEDOUT;
if (data->rx_result || data->rx_msg_len != sizeof(ff_resp) ||
@@ -632,7 +629,6 @@ static int aem_find_aem2(struct aem_ipmi_data *data,
struct aem_find_instance_resp *fi_resp,
int instance_num)
{
- int res;
struct aem_find_instance_req fi_req;
fi_req.id = system_x_id;
@@ -648,8 +644,7 @@ static int aem_find_aem2(struct aem_ipmi_data *data,
aem_send_message(data);
- res = wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT);
- if (!res)
+ if (!wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT))
return -ETIMEDOUT;
if (data->rx_result || data->rx_msg_len != sizeof(*fi_resp) ||
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: ibmaem: match return type of wait_for_completion_timeout
2025-06-12 18:43 [PATCH] hwmon: ibmaem: match return type of wait_for_completion_timeout Qiushi Wu
@ 2025-06-12 20:57 ` Guenter Roeck
2025-06-13 18:00 ` Qiushi Wu
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2025-06-12 20:57 UTC (permalink / raw)
To: Qiushi Wu, linux-kernel; +Cc: jdelvare, linux-hwmon, zohar, qiushi.wu
On 6/12/25 11:43, Qiushi Wu wrote:
> Return type of wait_for_completion_timeout is unsigned long not int.
> Check its return value inline instead of introducing a throw-away
> variable.
>
> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
> Signed-off-by: Qiushi Wu <qiushi@linux.ibm.com>
> ---
> drivers/hwmon/ibmaem.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
> index 157e232aace0..e52e937a396c 100644
> --- a/drivers/hwmon/ibmaem.c
> +++ b/drivers/hwmon/ibmaem.c
> @@ -383,8 +383,7 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
>
> aem_send_message(ipmi);
>
> - res = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT);
> - if (!res) {
> + if (!wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT)) {
> res = -ETIMEDOUT;
> goto out;
If you want to clean up the code:
return -ETIMEDOUT;
Also drop the second goto and return directly, drop res and the out: label
entirely, and return 0; at the end. That goto is really pointless.
Guenter
> }
> @@ -491,7 +490,6 @@ static void aem_delete(struct aem_data *data)
> /* Retrieve version and module handle for an AEM1 instance */
> static int aem_find_aem1_count(struct aem_ipmi_data *data)
> {
> - int res;
> struct aem_find_firmware_req ff_req;
> struct aem_find_firmware_resp ff_resp;
>
> @@ -508,8 +506,7 @@ static int aem_find_aem1_count(struct aem_ipmi_data *data)
>
> aem_send_message(data);
>
> - res = wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT);
> - if (!res)
> + if (!wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT))
> return -ETIMEDOUT;
>
> if (data->rx_result || data->rx_msg_len != sizeof(ff_resp) ||
> @@ -632,7 +629,6 @@ static int aem_find_aem2(struct aem_ipmi_data *data,
> struct aem_find_instance_resp *fi_resp,
> int instance_num)
> {
> - int res;
> struct aem_find_instance_req fi_req;
>
> fi_req.id = system_x_id;
> @@ -648,8 +644,7 @@ static int aem_find_aem2(struct aem_ipmi_data *data,
>
> aem_send_message(data);
>
> - res = wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT);
> - if (!res)
> + if (!wait_for_completion_timeout(&data->read_complete, IPMI_TIMEOUT))
> return -ETIMEDOUT;
>
> if (data->rx_result || data->rx_msg_len != sizeof(*fi_resp) ||
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: ibmaem: match return type of wait_for_completion_timeout
2025-06-12 20:57 ` Guenter Roeck
@ 2025-06-13 18:00 ` Qiushi Wu
0 siblings, 0 replies; 3+ messages in thread
From: Qiushi Wu @ 2025-06-13 18:00 UTC (permalink / raw)
To: Guenter Roeck, linux-kernel; +Cc: jdelvare, linux-hwmon, zohar, qiushi.wu
On 6/12/25 16:57, Guenter Roeck wrote:
> On 6/12/25 11:43, Qiushi Wu wrote:
>> Return type of wait_for_completion_timeout is unsigned long not int.
>> Check its return value inline instead of introducing a throw-away
>> variable.
>>
>> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
>> Signed-off-by: Qiushi Wu <qiushi@linux.ibm.com>
>> ---
>> drivers/hwmon/ibmaem.c | 11 +++--------
>> 1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
>> index 157e232aace0..e52e937a396c 100644
>> --- a/drivers/hwmon/ibmaem.c
>> +++ b/drivers/hwmon/ibmaem.c
>> @@ -383,8 +383,7 @@ static int aem_read_sensor(struct aem_data *data,
>> u8 elt, u8 reg,
>> aem_send_message(ipmi);
>> - res = wait_for_completion_timeout(&ipmi->read_complete,
>> IPMI_TIMEOUT);
>> - if (!res) {
>> + if (!wait_for_completion_timeout(&ipmi->read_complete,
>> IPMI_TIMEOUT)) {
>> res = -ETIMEDOUT;
>> goto out;
>
> If you want to clean up the code:
>
> return -ETIMEDOUT;
>
> Also drop the second goto and return directly, drop res and the out:
> label
> entirely, and return 0; at the end. That goto is really pointless.
>
> Guenter
>
Thanks for your feedback. I’ll clean up that and resubmit it as v2.
Sincerely,
Qiushi
>> }
>> @@ -491,7 +490,6 @@ static void aem_delete(struct aem_data *data)
>> /* Retrieve version and module handle for an AEM1 instance */
>> static int aem_find_aem1_count(struct aem_ipmi_data *data)
>> {
>> - int res;
>> struct aem_find_firmware_req ff_req;
>> struct aem_find_firmware_resp ff_resp;
>> @@ -508,8 +506,7 @@ static int aem_find_aem1_count(struct
>> aem_ipmi_data *data)
>> aem_send_message(data);
>> - res = wait_for_completion_timeout(&data->read_complete,
>> IPMI_TIMEOUT);
>> - if (!res)
>> + if (!wait_for_completion_timeout(&data->read_complete,
>> IPMI_TIMEOUT))
>> return -ETIMEDOUT;
>> if (data->rx_result || data->rx_msg_len != sizeof(ff_resp) ||
>> @@ -632,7 +629,6 @@ static int aem_find_aem2(struct aem_ipmi_data *data,
>> struct aem_find_instance_resp *fi_resp,
>> int instance_num)
>> {
>> - int res;
>> struct aem_find_instance_req fi_req;
>> fi_req.id = system_x_id;
>> @@ -648,8 +644,7 @@ static int aem_find_aem2(struct aem_ipmi_data *data,
>> aem_send_message(data);
>> - res = wait_for_completion_timeout(&data->read_complete,
>> IPMI_TIMEOUT);
>> - if (!res)
>> + if (!wait_for_completion_timeout(&data->read_complete,
>> IPMI_TIMEOUT))
>> return -ETIMEDOUT;
>> if (data->rx_result || data->rx_msg_len != sizeof(*fi_resp) ||
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-13 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-12 18:43 [PATCH] hwmon: ibmaem: match return type of wait_for_completion_timeout Qiushi Wu
2025-06-12 20:57 ` Guenter Roeck
2025-06-13 18:00 ` Qiushi Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®