* [PATCH] drivers/net: Fix potential incorrect call for udelay()
@ 2013-12-23 9:33 Libin
2013-12-23 11:26 ` One Thousand Gnomes
2013-12-24 3:22 ` tingwei liu
0 siblings, 2 replies; 3+ messages in thread
From: Libin @ 2013-12-23 9:33 UTC (permalink / raw)
To: davem, hsweeten, gregkh, tedheadster; +Cc: netdev, linux-kernel, dingtianhong
From: Li Bin <huawei.libin@huawei.com>
The variable delay_time as a module parameter can be set a value
exceeding the limit of the udelay function. This patch checks the
delay_time value to select mdelay() or udelay().
Signed-off-by: Li Bin <huawei.libin@huawei.com>
---
drivers/net/ethernet/8390/pcnet_cs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
index 46c5aad..29fe157 100644
--- a/drivers/net/ethernet/8390/pcnet_cs.c
+++ b/drivers/net/ethernet/8390/pcnet_cs.c
@@ -1284,8 +1284,12 @@ static void dma_block_output(struct net_device *dev, int count,
}
outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
- if (info->flags & DELAY_OUTPUT)
- udelay((long)delay_time);
+ if (info->flags & DELAY_OUTPUT) {
+ if (delay_time >= 1000)
+ mdelay((long)delay_time/1000);
+ else
+ udelay(delay_time);
+ }
ei_status.dmaing &= ~0x01;
}
--
1.8.2.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers/net: Fix potential incorrect call for udelay()
2013-12-23 9:33 [PATCH] drivers/net: Fix potential incorrect call for udelay() Libin
@ 2013-12-23 11:26 ` One Thousand Gnomes
2013-12-24 3:22 ` tingwei liu
1 sibling, 0 replies; 3+ messages in thread
From: One Thousand Gnomes @ 2013-12-23 11:26 UTC (permalink / raw)
To: Libin
Cc: davem, hsweeten, gregkh, tedheadster, netdev, linux-kernel,
dingtianhong
On Mon, 23 Dec 2013 17:33:44 +0800
Libin <huawei.libin@huawei.com> wrote:
> From: Li Bin <huawei.libin@huawei.com>
>
> The variable delay_time as a module parameter can be set a value
> exceeding the limit of the udelay function. This patch checks the
> delay_time value to select mdelay() or udelay().
>
> Signed-off-by: Li Bin <huawei.libin@huawei.com>
Nobody should need to set a delay time that long, so this seems a rather
surplus check.
Alan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers/net: Fix potential incorrect call for udelay()
2013-12-23 9:33 [PATCH] drivers/net: Fix potential incorrect call for udelay() Libin
2013-12-23 11:26 ` One Thousand Gnomes
@ 2013-12-24 3:22 ` tingwei liu
1 sibling, 0 replies; 3+ messages in thread
From: tingwei liu @ 2013-12-24 3:22 UTC (permalink / raw)
To: Libin
Cc: davem, hsweeten, gregkh, tedheadster, netdev, linux-kernel,
dingtianhong
On Mon, Dec 23, 2013 at 5:33 PM, Libin <huawei.libin@huawei.com> wrote:
>
> From: Li Bin <huawei.libin@huawei.com>
>
> The variable delay_time as a module parameter can be set a value
> exceeding the limit of the udelay function. This patch checks the
> delay_time value to select mdelay() or udelay().
>
> Signed-off-by: Li Bin <huawei.libin@huawei.com>
> ---
> drivers/net/ethernet/8390/pcnet_cs.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
> index 46c5aad..29fe157 100644
> --- a/drivers/net/ethernet/8390/pcnet_cs.c
> +++ b/drivers/net/ethernet/8390/pcnet_cs.c
> @@ -1284,8 +1284,12 @@ static void dma_block_output(struct net_device *dev, int count,
> }
>
> outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
> - if (info->flags & DELAY_OUTPUT)
> - udelay((long)delay_time);
> + if (info->flags & DELAY_OUTPUT) {
> + if (delay_time >= 1000)
> + mdelay((long)delay_time/1000);
Indeed use of mdelay is discouraged.
I prefer to limit delay_time less than 1000.
Tingwei
>
> + else
> + udelay(delay_time);
> + }
> ei_status.dmaing &= ~0x01;
> }
>
> --
> 1.8.2.2
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-24 3:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-23 9:33 [PATCH] drivers/net: Fix potential incorrect call for udelay() Libin
2013-12-23 11:26 ` One Thousand Gnomes
2013-12-24 3:22 ` tingwei liu
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).