* [PATCH v2] net: rfkill: gpio: Add check for clk_enable()
@ 2024-11-07 22:20 Mingwei Zheng
2024-11-08 7:47 ` Johannes Berg
0 siblings, 1 reply; 3+ messages in thread
From: Mingwei Zheng @ 2024-11-07 22:20 UTC (permalink / raw)
To: johannes
Cc: linville, rklein, linux-wireless, linux-kernel, Mingwei Zheng,
Jiasheng Jiang
Add check for the return value of clk_enable() to catch the potential
error.
Fixes: 7176ba23f8b5 ("net: rfkill: add generic gpio rfkill driver")
Signed-off-by: Mingwei Zheng <zmw12306@gmail.com>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
Changelog:
v1 -> v2
1. Replace expection with error in commit msg.
---
net/rfkill/rfkill-gpio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index c268c2b011f4..a87bb99231a6 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -31,9 +31,13 @@ struct rfkill_gpio_data {
static int rfkill_gpio_set_power(void *data, bool blocked)
{
struct rfkill_gpio_data *rfkill = data;
+ int ret;
- if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
- clk_enable(rfkill->clk);
+ if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled) {
+ ret = clk_enable(rfkill->clk);
+ if (!ret)
+ return ret;
+ }
gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked);
gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: rfkill: gpio: Add check for clk_enable()
2024-11-07 22:20 [PATCH v2] net: rfkill: gpio: Add check for clk_enable() Mingwei Zheng
@ 2024-11-08 7:47 ` Johannes Berg
2024-11-08 19:39 ` Mingwei Zheng
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2024-11-08 7:47 UTC (permalink / raw)
To: Mingwei Zheng
Cc: linville, rklein, linux-wireless, linux-kernel, Jiasheng Jiang
On Thu, 2024-11-07 at 17:20 -0500, Mingwei Zheng wrote:
> Add check for the return value of clk_enable() to catch the potential
> error.
Wait ... is someone running an experiment again? ;-)
>
> diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
> index c268c2b011f4..a87bb99231a6 100644
> --- a/net/rfkill/rfkill-gpio.c
> +++ b/net/rfkill/rfkill-gpio.c
> @@ -31,9 +31,13 @@ struct rfkill_gpio_data {
> static int rfkill_gpio_set_power(void *data, bool blocked)
> {
> struct rfkill_gpio_data *rfkill = data;
> + int ret;
You could move that into the if.
> - if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
> - clk_enable(rfkill->clk);
> + if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled) {
> + ret = clk_enable(rfkill->clk);
> + if (!ret)
> + return ret;
> + }
>
but this is obviously wrong anyway.
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: rfkill: gpio: Add check for clk_enable()
2024-11-08 7:47 ` Johannes Berg
@ 2024-11-08 19:39 ` Mingwei Zheng
0 siblings, 0 replies; 3+ messages in thread
From: Mingwei Zheng @ 2024-11-08 19:39 UTC (permalink / raw)
To: Johannes Berg
Cc: linville, rklein, linux-wireless, linux-kernel, Jiasheng Jiang
On Fri, Nov 8, 2024 at 2:47 AM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> On Thu, 2024-11-07 at 17:20 -0500, Mingwei Zheng wrote:
> > Add check for the return value of clk_enable() to catch the potential
> > error.
>
> Wait ... is someone running an experiment again? ;-)
> >
> > diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
> > index c268c2b011f4..a87bb99231a6 100644
> > --- a/net/rfkill/rfkill-gpio.c
> > +++ b/net/rfkill/rfkill-gpio.c
> > @@ -31,9 +31,13 @@ struct rfkill_gpio_data {
> > static int rfkill_gpio_set_power(void *data, bool blocked)
> > {
> > struct rfkill_gpio_data *rfkill = data;
> > + int ret;
>
> You could move that into the if.
>
> > - if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
> > - clk_enable(rfkill->clk);
> > + if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled) {
> > + ret = clk_enable(rfkill->clk);
> > + if (!ret)
> > + return ret;
> > + }
> >
>
> but this is obviously wrong anyway.
>
> johannes
Thank you for your suggestion. I’ll make the corrections and send a v3 patch.
Best,
Mingwei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-08 19:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-07 22:20 [PATCH v2] net: rfkill: gpio: Add check for clk_enable() Mingwei Zheng
2024-11-08 7:47 ` Johannes Berg
2024-11-08 19:39 ` Mingwei Zheng
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®