* [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset
@ 2015-04-21 11:16 Michael Trimarchi
2015-04-21 21:35 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Michael Trimarchi @ 2015-04-21 11:16 UTC (permalink / raw)
To: Giuseppe Cavallaro; +Cc: Michael Trimarchi, Fabio Estevam, netdev
Reset delay values are expressed in microsecond but most of the
time the delay is more then 2ms and up to 100ms. Use udelay
is wrong for large sleep period. This function is not used
in interrupt context according to the documentation.
Cc: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
Changes v1 -> v2:
- remove unreleated changes
---
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index b735fa2..c843fbe 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -161,11 +161,11 @@ int stmmac_mdio_reset(struct mii_bus *bus)
if (!gpio_request(reset_gpio, "mdio-reset")) {
gpio_direction_output(reset_gpio, active_low ? 1 : 0);
- udelay(data->delays[0]);
- gpio_set_value(reset_gpio, active_low ? 0 : 1);
- udelay(data->delays[1]);
- gpio_set_value(reset_gpio, active_low ? 1 : 0);
- udelay(data->delays[2]);
+ msleep(max(1U, data->delays[0] / 1000));
+ gpio_set_value(reset_gpio, !active_low);
+ msleep(max(1U, data->delays[1] / 1000));
+ gpio_set_value(reset_gpio, active_low);
+ msleep(max(1U, data->delays[2] / 1000));
}
}
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset
2015-04-21 11:16 [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset Michael Trimarchi
@ 2015-04-21 21:35 ` David Miller
2015-04-21 23:13 ` Michael Trimarchi
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2015-04-21 21:35 UTC (permalink / raw)
To: michael; +Cc: peppe.cavallaro, festevam, netdev
From: Michael Trimarchi <michael@amarulasolutions.com>
Date: Tue, 21 Apr 2015 13:16:13 +0200
> - udelay(data->delays[0]);
...
> + msleep(max(1U, data->delays[0] / 1000));
That looks very ugly with that max() expression in there.
Please find some clean way to get rid of it if you want to
make this conversion.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset
2015-04-21 21:35 ` David Miller
@ 2015-04-21 23:13 ` Michael Trimarchi
2015-04-22 0:31 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Michael Trimarchi @ 2015-04-21 23:13 UTC (permalink / raw)
To: David Miller; +Cc: peppe.cavallaro, festevam, netdev
Hi
On Tue, Apr 21, 2015 at 05:35:40PM -0400, David Miller wrote:
> From: Michael Trimarchi <michael@amarulasolutions.com>
> Date: Tue, 21 Apr 2015 13:16:13 +0200
>
> > - udelay(data->delays[0]);
> ...
> > + msleep(max(1U, data->delays[0] / 1000));
>
> That looks very ugly with that max() expression in there.
>
Is fine for you a DIV_ROUND_UP?
> Please find some clean way to get rid of it if you want to
> make this conversion.
>
Agree, I will repost it
Michael
> Thanks.
--
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO - Founder Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
| [`as] http://www.amarulasolutions.com |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset
2015-04-21 23:13 ` Michael Trimarchi
@ 2015-04-22 0:31 ` David Miller
2015-04-22 0:55 ` Michael Trimarchi
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2015-04-22 0:31 UTC (permalink / raw)
To: michael; +Cc: peppe.cavallaro, festevam, netdev
From: Michael Trimarchi <michael@amarulasolutions.com>
Date: Wed, 22 Apr 2015 01:13:47 +0200
> Hi
>
> On Tue, Apr 21, 2015 at 05:35:40PM -0400, David Miller wrote:
>> From: Michael Trimarchi <michael@amarulasolutions.com>
>> Date: Tue, 21 Apr 2015 13:16:13 +0200
>>
>> > - udelay(data->delays[0]);
>> ...
>> > + msleep(max(1U, data->delays[0] / 1000));
>>
>> That looks very ugly with that max() expression in there.
>>
>
> Is fine for you a DIV_ROUND_UP?
Not inside of these simple msleep() calls, no.
How about adjusting the values either in the datastructure or
in local variables instead? That wasn't so hard to come up
with now, was it?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset
2015-04-22 0:31 ` David Miller
@ 2015-04-22 0:55 ` Michael Trimarchi
0 siblings, 0 replies; 5+ messages in thread
From: Michael Trimarchi @ 2015-04-22 0:55 UTC (permalink / raw)
To: David Miller; +Cc: peppe.cavallaro, festevam, netdev
Hi
On Tue, Apr 21, 2015 at 08:31:34PM -0400, David Miller wrote:
> From: Michael Trimarchi <michael@amarulasolutions.com>
> Date: Wed, 22 Apr 2015 01:13:47 +0200
>
> > Hi
> >
> > On Tue, Apr 21, 2015 at 05:35:40PM -0400, David Miller wrote:
> >> From: Michael Trimarchi <michael@amarulasolutions.com>
> >> Date: Tue, 21 Apr 2015 13:16:13 +0200
> >>
> >> > - udelay(data->delays[0]);
> >> ...
> >> > + msleep(max(1U, data->delays[0] / 1000));
> >>
> >> That looks very ugly with that max() expression in there.
> >>
> >
> > Is fine for you a DIV_ROUND_UP?
>
> Not inside of these simple msleep() calls, no.
>
> How about adjusting the values either in the datastructure or
> in local variables instead? That wasn't so hard to come up
> with now, was it?
Ok, it's easy no problem at all, I will post later today but I prefer
local variables and use DIV_ROUND_UP
Michael
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-04-22 0:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-21 11:16 [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset Michael Trimarchi
2015-04-21 21:35 ` David Miller
2015-04-21 23:13 ` Michael Trimarchi
2015-04-22 0:31 ` David Miller
2015-04-22 0:55 ` Michael Trimarchi
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).