* [PATCH] net: ethernet: stmmac: Convert timers to use
@ 2017-10-05 0:50 Kees Cook
2017-10-05 5:21 ` Giuseppe CAVALLARO
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2017-10-05 0:50 UTC (permalink / raw)
To: linux-kernel
Cc: Giuseppe Cavallaro, Alexandre Torgue, netdev, Thomas Gleixner
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: netdev@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
index 6a9c954492f2..8b50afcdb52d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
@@ -118,10 +118,9 @@ int tse_pcs_init(void __iomem *base, struct tse_pcs *pcs)
return ret;
}
-static void pcs_link_timer_callback(unsigned long data)
+static void pcs_link_timer_callback(struct tse_pcs *pcs)
{
u16 val = 0;
- struct tse_pcs *pcs = (struct tse_pcs *)data;
void __iomem *tse_pcs_base = pcs->tse_pcs_base;
void __iomem *sgmii_adapter_base = pcs->sgmii_adapter_base;
@@ -138,12 +137,11 @@ static void pcs_link_timer_callback(unsigned long data)
}
}
-static void auto_nego_timer_callback(unsigned long data)
+static void auto_nego_timer_callback(struct tse_pcs *pcs)
{
u16 val = 0;
u16 speed = 0;
u16 duplex = 0;
- struct tse_pcs *pcs = (struct tse_pcs *)data;
void __iomem *tse_pcs_base = pcs->tse_pcs_base;
void __iomem *sgmii_adapter_base = pcs->sgmii_adapter_base;
@@ -201,14 +199,14 @@ static void auto_nego_timer_callback(unsigned long data)
}
}
-static void aneg_link_timer_callback(unsigned long data)
+static void aneg_link_timer_callback(struct timer_list *t)
{
- struct tse_pcs *pcs = (struct tse_pcs *)data;
+ struct tse_pcs *pcs = from_timer(pcs, t, aneg_link_timer);
if (pcs->autoneg == AUTONEG_ENABLE)
- auto_nego_timer_callback(data);
+ auto_nego_timer_callback(pcs);
else if (pcs->autoneg == AUTONEG_DISABLE)
- pcs_link_timer_callback(data);
+ pcs_link_timer_callback(pcs);
}
void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
@@ -237,8 +235,8 @@ void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
tse_pcs_reset(tse_pcs_base, pcs);
- setup_timer(&pcs->aneg_link_timer,
- aneg_link_timer_callback, (unsigned long)pcs);
+ timer_setup(&pcs->aneg_link_timer, aneg_link_timer_callback,
+ 0);
mod_timer(&pcs->aneg_link_timer, jiffies +
msecs_to_jiffies(AUTONEGO_LINK_TIMER));
} else if (phy_dev->autoneg == AUTONEG_DISABLE) {
@@ -270,8 +268,8 @@ void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
tse_pcs_reset(tse_pcs_base, pcs);
- setup_timer(&pcs->aneg_link_timer,
- aneg_link_timer_callback, (unsigned long)pcs);
+ timer_setup(&pcs->aneg_link_timer, aneg_link_timer_callback,
+ 0);
mod_timer(&pcs->aneg_link_timer, jiffies +
msecs_to_jiffies(AUTONEGO_LINK_TIMER));
}
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: ethernet: stmmac: Convert timers to use
2017-10-05 0:50 [PATCH] net: ethernet: stmmac: Convert timers to use Kees Cook
@ 2017-10-05 5:21 ` Giuseppe CAVALLARO
0 siblings, 0 replies; 2+ messages in thread
From: Giuseppe CAVALLARO @ 2017-10-05 5:21 UTC (permalink / raw)
To: Kees Cook, linux-kernel; +Cc: Alexandre Torgue, netdev, Thomas Gleixner
On 10/5/2017 2:50 AM, Kees Cook wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly.
>
> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> Cc: Alexandre Torgue <alexandre.torgue@st.com>
> Cc: netdev@vger.kernel.org
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> ---
> This requires commit 686fef928bba ("timer: Prepare to change timer
> callback argument type") in v4.14-rc3, but should be otherwise
> stand-alone.
> ---
> drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
> index 6a9c954492f2..8b50afcdb52d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
> @@ -118,10 +118,9 @@ int tse_pcs_init(void __iomem *base, struct tse_pcs *pcs)
> return ret;
> }
>
> -static void pcs_link_timer_callback(unsigned long data)
> +static void pcs_link_timer_callback(struct tse_pcs *pcs)
> {
> u16 val = 0;
> - struct tse_pcs *pcs = (struct tse_pcs *)data;
> void __iomem *tse_pcs_base = pcs->tse_pcs_base;
> void __iomem *sgmii_adapter_base = pcs->sgmii_adapter_base;
>
> @@ -138,12 +137,11 @@ static void pcs_link_timer_callback(unsigned long data)
> }
> }
>
> -static void auto_nego_timer_callback(unsigned long data)
> +static void auto_nego_timer_callback(struct tse_pcs *pcs)
> {
> u16 val = 0;
> u16 speed = 0;
> u16 duplex = 0;
> - struct tse_pcs *pcs = (struct tse_pcs *)data;
> void __iomem *tse_pcs_base = pcs->tse_pcs_base;
> void __iomem *sgmii_adapter_base = pcs->sgmii_adapter_base;
>
> @@ -201,14 +199,14 @@ static void auto_nego_timer_callback(unsigned long data)
> }
> }
>
> -static void aneg_link_timer_callback(unsigned long data)
> +static void aneg_link_timer_callback(struct timer_list *t)
> {
> - struct tse_pcs *pcs = (struct tse_pcs *)data;
> + struct tse_pcs *pcs = from_timer(pcs, t, aneg_link_timer);
>
> if (pcs->autoneg == AUTONEG_ENABLE)
> - auto_nego_timer_callback(data);
> + auto_nego_timer_callback(pcs);
> else if (pcs->autoneg == AUTONEG_DISABLE)
> - pcs_link_timer_callback(data);
> + pcs_link_timer_callback(pcs);
> }
>
> void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
> @@ -237,8 +235,8 @@ void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
>
> tse_pcs_reset(tse_pcs_base, pcs);
>
> - setup_timer(&pcs->aneg_link_timer,
> - aneg_link_timer_callback, (unsigned long)pcs);
> + timer_setup(&pcs->aneg_link_timer, aneg_link_timer_callback,
> + 0);
> mod_timer(&pcs->aneg_link_timer, jiffies +
> msecs_to_jiffies(AUTONEGO_LINK_TIMER));
> } else if (phy_dev->autoneg == AUTONEG_DISABLE) {
> @@ -270,8 +268,8 @@ void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
>
> tse_pcs_reset(tse_pcs_base, pcs);
>
> - setup_timer(&pcs->aneg_link_timer,
> - aneg_link_timer_callback, (unsigned long)pcs);
> + timer_setup(&pcs->aneg_link_timer, aneg_link_timer_callback,
> + 0);
> mod_timer(&pcs->aneg_link_timer, jiffies +
> msecs_to_jiffies(AUTONEGO_LINK_TIMER));
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-05 5:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 0:50 [PATCH] net: ethernet: stmmac: Convert timers to use Kees Cook
2017-10-05 5:21 ` Giuseppe CAVALLARO
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.