netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Samuel Ortiz <samuel@sortiz.org>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Johannes Berg <johannes.berg@intel.com>,
	Ingo Molnar <mingo@kernel.org>,
	netdev@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/58] net/irda: Convert timers to use timer_setup()
Date: Fri, 2 Mar 2018 18:29:19 -0300	[thread overview]
Message-ID: <20180302212919.GJ3887@localhost.localdomain> (raw)
In-Reply-To: <1508200182-104605-10-git-send-email-keescook@chromium.org>

On Mon, Oct 16, 2017 at 05:28:53PM -0700, 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: Samuel Ortiz <samuel@sortiz.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: Johannes Berg <johannes.berg@intel.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  .../staging/irda/include/net/irda/irlmp_event.h    |  6 +--
>  drivers/staging/irda/include/net/irda/timer.h      | 11 ++---
>  drivers/staging/irda/net/af_irda.c                 |  7 ++-
>  drivers/staging/irda/net/ircomm/ircomm_tty.c       |  2 +-
>  .../staging/irda/net/ircomm/ircomm_tty_attach.c    |  8 ++--
>  drivers/staging/irda/net/irda_device.c             | 10 ++--
>  drivers/staging/irda/net/iriap.c                   | 10 ++--
>  drivers/staging/irda/net/irlan/irlan_client.c      |  6 +--
>  drivers/staging/irda/net/irlan/irlan_common.c      |  4 +-
>  drivers/staging/irda/net/irlap.c                   | 16 +++----
>  drivers/staging/irda/net/irlap_event.c             |  6 +--
>  drivers/staging/irda/net/irlmp.c                   |  8 ++--
>  drivers/staging/irda/net/irlmp_event.c             | 10 ++--
>  drivers/staging/irda/net/irttp.c                   | 11 ++---
>  drivers/staging/irda/net/timer.c                   | 54 +++++++++++-----------
>  15 files changed, 79 insertions(+), 90 deletions(-)
> 
> diff --git a/drivers/staging/irda/include/net/irda/irlmp_event.h b/drivers/staging/irda/include/net/irda/irlmp_event.h
> index 9e4ec17a7449..a1a082fe384e 100644
> --- a/drivers/staging/irda/include/net/irda/irlmp_event.h
> +++ b/drivers/staging/irda/include/net/irda/irlmp_event.h
> @@ -82,9 +82,9 @@ typedef enum {
>  extern const char *const irlmp_state[];
>  extern const char *const irlsap_state[];
>  
> -void irlmp_watchdog_timer_expired(void *data);
> -void irlmp_discovery_timer_expired(void *data);
> -void irlmp_idle_timer_expired(void *data);
> +void irlmp_watchdog_timer_expired(struct timer_list *t);
> +void irlmp_discovery_timer_expired(struct timer_list *t);
> +void irlmp_idle_timer_expired(struct timer_list *t);
>  
>  void irlmp_do_lap_event(struct lap_cb *self, IRLMP_EVENT event, 
>  			struct sk_buff *skb);
> diff --git a/drivers/staging/irda/include/net/irda/timer.h b/drivers/staging/irda/include/net/irda/timer.h
> index d784f242cf7b..a6635f0afae9 100644
> --- a/drivers/staging/irda/include/net/irda/timer.h
> +++ b/drivers/staging/irda/include/net/irda/timer.h
> @@ -72,14 +72,11 @@ struct lap_cb;
>  
>  #define WATCHDOG_TIMEOUT        (20*HZ)       /* 20 sec */
>  
> -typedef void (*TIMER_CALLBACK)(void *);
> -
> -static inline void irda_start_timer(struct timer_list *ptimer, int timeout, 
> -				    void* data, TIMER_CALLBACK callback)
> +static inline void irda_start_timer(struct timer_list *ptimer, int timeout,
> +				    void (*callback)(struct timer_list *))
>  {
> -	ptimer->function = (void (*)(unsigned long)) callback;
> -	ptimer->data = (unsigned long) data;
> -	
> +	ptimer->function = (TIMER_FUNC_TYPE) callback;
> +
>  	/* Set new value for timer (update or add timer).
>  	 * We use mod_timer() because it's more efficient and also
>  	 * safer with respect to race conditions - Jean II */
> diff --git a/drivers/staging/irda/net/af_irda.c b/drivers/staging/irda/net/af_irda.c
> index 23fa7c8b09a5..b82a47b9ef0b 100644
> --- a/drivers/staging/irda/net/af_irda.c
> +++ b/drivers/staging/irda/net/af_irda.c
> @@ -429,11 +429,11 @@ static void irda_selective_discovery_indication(discinfo_t *discovery,
>   * We were waiting for a node to be discovered, but nothing has come up
>   * so far. Wake up the user and tell him that we failed...
>   */
> -static void irda_discovery_timeout(u_long priv)
> +static void irda_discovery_timeout(struct timer_list *t)
>  {
>  	struct irda_sock *self;
>  
> -	self = (struct irda_sock *) priv;
> +	self = from_timer(self, t, watchdog);
>  	BUG_ON(self == NULL);
>  
>  	/* Nothing for the caller */
> @@ -2505,8 +2505,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
>  
>  			/* Set watchdog timer to expire in <val> ms. */
>  			self->errno = 0;
> -			setup_timer(&self->watchdog, irda_discovery_timeout,
> -					(unsigned long)self);
> +			timer_setup(&self->watchdog, irda_discovery_timeout, 0);
>  			mod_timer(&self->watchdog,
>  				  jiffies + msecs_to_jiffies(val));
>  
> diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty.c b/drivers/staging/irda/net/ircomm/ircomm_tty.c
> index ec157c3419b5..473abfaffe7b 100644
> --- a/drivers/staging/irda/net/ircomm/ircomm_tty.c
> +++ b/drivers/staging/irda/net/ircomm/ircomm_tty.c
> @@ -395,7 +395,7 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
>  		self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED;
>  
>  		/* Init some important stuff */
> -		init_timer(&self->watchdog_timer);
> +		timer_setup(&self->watchdog_timer, NULL, 0);
>  		spin_lock_init(&self->spinlock);
>  
>  		/*
> diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c b/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c
> index 0a411019c098..e2d5ce8ba0db 100644
> --- a/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c
> +++ b/drivers/staging/irda/net/ircomm/ircomm_tty_attach.c
> @@ -52,7 +52,7 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
>  					struct ias_value *value, void *priv);
>  static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
>  					    int timeout);
> -static void ircomm_tty_watchdog_timer_expired(void *data);
> +static void ircomm_tty_watchdog_timer_expired(struct timer_list *timer);
>  
>  static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
>  				 IRCOMM_TTY_EVENT event,
> @@ -587,7 +587,7 @@ static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
>  	IRDA_ASSERT(self != NULL, return;);
>  	IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
>  
> -	irda_start_timer(&self->watchdog_timer, timeout, (void *) self,
> +	irda_start_timer(&self->watchdog_timer, timeout,
>  			 ircomm_tty_watchdog_timer_expired);
>  }
>  
> @@ -597,9 +597,9 @@ static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
>   *    Called when the connect procedure have taken to much time.
>   *
>   */
> -static void ircomm_tty_watchdog_timer_expired(void *data)
> +static void ircomm_tty_watchdog_timer_expired(struct timer_list *t)
>  {
> -	struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) data;
> +	struct ircomm_tty_cb *self = from_timer(self, t, watchdog_timer);
>  
>  	IRDA_ASSERT(self != NULL, return;);
>  	IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
> diff --git a/drivers/staging/irda/net/irda_device.c b/drivers/staging/irda/net/irda_device.c
> index d33de8a8762a..682b4eea15e0 100644
> --- a/drivers/staging/irda/net/irda_device.c
> +++ b/drivers/staging/irda/net/irda_device.c
> @@ -57,7 +57,7 @@ static void __irda_task_delete(struct irda_task *task);
>  static hashbin_t *dongles;
>  static hashbin_t *tasks;
>  
> -static void irda_task_timer_expired(void *data);
> +static void irda_task_timer_expired(struct timer_list *timer);
>  
>  int __init irda_device_init(void)
>  {
> @@ -233,7 +233,7 @@ static int irda_task_kick(struct irda_task *task)
>  		}
>  		irda_task_delete(task);
>  	} else if (timeout > 0) {
> -		irda_start_timer(&task->timer, timeout, (void *)task,
> +		irda_start_timer(&task->timer, timeout,
>  				 irda_task_timer_expired);
>  		finished = FALSE;
>  	} else {
> @@ -251,11 +251,9 @@ static int irda_task_kick(struct irda_task *task)
>   *    Task time has expired. We now try to execute task (again), and restart
>   *    the timer if the task has not finished yet
>   */
> -static void irda_task_timer_expired(void *data)
> +static void irda_task_timer_expired(struct timer_list *t)
>  {
> -	struct irda_task *task;
> -
> -	task = data;
> +	struct irda_task *task = from_timer(task, t, timer);
>  
>  	irda_task_kick(task);
>  }
> diff --git a/drivers/staging/irda/net/iriap.c b/drivers/staging/irda/net/iriap.c
> index 1138eaf5c682..d64192e9db8b 100644
> --- a/drivers/staging/irda/net/iriap.c
> +++ b/drivers/staging/irda/net/iriap.c
> @@ -76,12 +76,12 @@ static void iriap_connect_confirm(void *instance, void *sap,
>  static int iriap_data_indication(void *instance, void *sap,
>  				 struct sk_buff *skb);
>  
> -static void iriap_watchdog_timer_expired(void *data);
> +static void iriap_watchdog_timer_expired(struct timer_list *t);
>  
>  static inline void iriap_start_watchdog_timer(struct iriap_cb *self,
>  					      int timeout)
>  {
> -	irda_start_timer(&self->watchdog_timer, timeout, self,
> +	irda_start_timer(&self->watchdog_timer, timeout,
>  			 iriap_watchdog_timer_expired);

I'm having build issues on current net-next:

  CC [M]  drivers/staging/irda/net/iriap.o
In file included from /home/mleitner/linux/include/net/irda/iriap.h:35:0,
                 from /home/mleitner/linux/drivers/staging/irda/net/iriap.c:44:
/home/mleitner/linux/include/net/irda/timer.h: In function ‘irda_start_timer’:
/home/mleitner/linux/include/net/irda/timer.h:80:19: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
  ptimer->function = (void (*)(unsigned long)) callback;
                   ^
/home/mleitner/linux/include/net/irda/timer.h:81:8: error: ‘struct timer_list’ has no member named ‘data’
  ptimer->data = (unsigned long) data;
        ^~
/home/mleitner/linux/drivers/staging/irda/net/iriap.c: In function ‘iriap_start_watchdog_timer’:
/home/mleitner/linux/drivers/staging/irda/net/iriap.c:84:2: error: too few arguments to function ‘irda_start_timer’
  irda_start_timer(&self->watchdog_timer, timeout,
  ^~~~~~~~~~~~~~~~
In file included from /home/mleitner/linux/include/net/irda/iriap.h:35:0,
                 from /home/mleitner/linux/drivers/staging/irda/net/iriap.c:44:
/home/mleitner/linux/include/net/irda/timer.h:77:20: note: declared here
 static inline void irda_start_timer(struct timer_list *ptimer, int timeout,
                    ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

Note how it is using the irda_start_timer definition from
include/net/irda/timer.h instead of
drivers/staging/irda/include/net/irda/timer.h which was patched in
this patch.

  Marcelo

  reply	other threads:[~2018-03-02 21:29 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17  0:28 [PATCH 00/58] networking: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:28 ` [PATCH 01/58] net/decnet: " Kees Cook
2017-10-17  0:28 ` [PATCH 02/58] net/lapb: " Kees Cook
2017-10-17  0:28 ` [PATCH 03/58] net/rose: " Kees Cook
2017-10-17  0:28 ` [PATCH 04/58] net/irda-usb: " Kees Cook
2017-10-17  0:28 ` [PATCH 05/58] net/irda/bfin_sir: " Kees Cook
2017-10-17  0:28 ` [PATCH 06/58] net/ti/tlan: " Kees Cook
2017-10-17  0:28 ` [PATCH 07/58] net/usb/usbnet: " Kees Cook
2017-10-17 10:30   ` Oliver Neukum
2017-10-17  0:28 ` [PATCH 08/58] net/wireless/ray_cs: " Kees Cook
2017-10-27  7:31   ` [08/58] " Kalle Valo
2017-10-17  0:28 ` [PATCH 09/58] net/irda: " Kees Cook
2018-03-02 21:29   ` Marcelo Ricardo Leitner [this message]
2018-03-02 22:30     ` Kees Cook
2018-03-02 23:08       ` Marcelo Ricardo Leitner
2017-10-17  0:28 ` [PATCH 10/58] isdn/hisax: " Kees Cook
2017-10-17  0:28 ` [PATCH 11/58] net/hamradio/6pack: " Kees Cook
2017-10-17  0:28 ` [PATCH 12/58] xfrm: " Kees Cook
2017-10-17  0:28 ` [PATCH 13/58] ethernet/broadcom: " Kees Cook
2017-10-17  0:28 ` [PATCH 14/58] net: tulip: de2104x: " Kees Cook
2017-10-17  0:28 ` [PATCH 15/58] pcmcia/electra_cf: " Kees Cook
2017-10-17  0:29 ` [PATCH 16/58] net: ethernet: stmmac: " Kees Cook
2017-10-17  0:29 ` [PATCH 17/58] net/cw1200: " Kees Cook
2017-10-17  0:29 ` [PATCH 18/58] net: vxge: " Kees Cook
2017-10-17  0:29 ` [PATCH 19/58] drivers/atm/suni: " Kees Cook
2017-10-17  0:29 ` [PATCH 20/58] atm: idt77252: " Kees Cook
2017-10-17  0:29 ` [PATCH 21/58] net: tulip: " Kees Cook
2017-10-17  0:29 ` [PATCH 22/58] net: can: " Kees Cook
2017-10-17  0:29 ` [PATCH 23/58] drivers/net/3com: " Kees Cook
2017-10-17  0:29 ` [PATCH 24/58] chelsio: " Kees Cook
2017-10-17  0:29 ` [PATCH 25/58] net: amd8111e: " Kees Cook
2017-10-17  0:29 ` [PATCH 26/58] bna: " Kees Cook
2017-10-17  0:29 ` [PATCH 27/58] net: dl2k: " Kees Cook
2017-10-17  0:29 ` [PATCH 28/58] net: ksz884x: " Kees Cook
2017-10-17  0:29 ` [PATCH 29/58] forcedeth: " Kees Cook
2017-10-17  0:29 ` [PATCH 30/58] mISDN: " Kees Cook
2017-10-17  0:29 ` [PATCH 31/58] isdn/gigaset: Use kzalloc instead of open-coded field zeroing Kees Cook
2017-10-19 20:46   ` Paul Bolle
2017-10-17  0:29 ` [PATCH 32/58] isdn/gigaset: Convert timers to use timer_setup() Kees Cook
2017-10-19 21:03   ` Paul Bolle
2017-10-19 21:20     ` Paul Bolle
2017-10-19 21:31       ` Thomas Gleixner
2017-10-19 21:51         ` Paul Bolle
2017-10-19 22:28           ` Thomas Gleixner
2017-10-19 23:31             ` Paul Bolle
2017-10-19 21:31       ` Kees Cook
2017-10-19 22:16         ` Paul Bolle
2017-10-17  0:29 ` [PATCH 33/58] net: sched: " Kees Cook
2017-10-17  0:29 ` [PATCH 34/58] netfilter: ipset: " Kees Cook
2017-10-17  0:29 ` [PATCH 35/58] inet/connection_sock: " Kees Cook
2017-10-17  0:29 ` [PATCH 36/58] inet: frags: " Kees Cook
2017-10-17  0:29 ` [PATCH 37/58] net/core: Collapse redundant sk_timer callback data assignments Kees Cook
2017-10-17  0:29 ` [PATCH 38/58] hdlc: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 39/58] appletalk: Remove unneeded synchronization Kees Cook
2017-10-17  0:29 ` [PATCH 40/58] drivers/net/appletalk: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 41/58] net/atm/mpc: Stop using open-coded timer .data field Kees Cook
2017-10-17  0:29 ` [PATCH 42/58] isdnloop: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 43/58] net: ethernet: apple: " Kees Cook
2017-10-17  0:29 ` [PATCH 44/58] net: ethernet: sun: " Kees Cook
2017-10-17 16:27   ` Shannon Nelson
2017-10-17  0:29 ` [PATCH 45/58] net: seeq: " Kees Cook
2017-10-17  0:29 ` [PATCH 46/58] hamradio/scc: " Kees Cook
2017-10-17  0:29 ` [PATCH 47/58] net/ethernet/sgi: " Kees Cook
     [not found] ` <1508200182-104605-1-git-send-email-keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-10-17  0:29   ` [PATCH 48/58] net: usb: " Kees Cook
2017-10-17  0:29 ` [PATCH 49/58] net: neterion: " Kees Cook
2017-10-17  0:29 ` [PATCH 50/58] net: hns: " Kees Cook
2017-10-17  0:29 ` [PATCH 51/58] ethernet/intel: " Kees Cook
2017-10-17  0:29 ` [PATCH 52/58] net/core: Convert sk_timer users " Kees Cook
2017-10-17  0:29 ` [PATCH 53/58] net: atm: Convert timers " Kees Cook
2017-10-17  0:29 ` [PATCH 54/58] net/xen-netback: " Kees Cook
2017-10-20 16:16   ` Wei Liu
2017-10-17  0:29 ` [PATCH 55/58] net: fs_enet: Remove unused timer Kees Cook
2017-10-17  0:29 ` [PATCH 56/58] um: net: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 57/58] ipv4: timewait: " Kees Cook
2017-10-17  0:29 ` [PATCH 58/58] sunrpc: " Kees Cook
2017-10-17 14:18 ` [PATCH 00/58] networking: " Kalle Valo
2017-10-17 19:47   ` Kees Cook
2017-10-18  5:44     ` Kalle Valo
2017-10-18 19:45       ` Kees Cook
2017-10-18 11:42 ` David Miller
2017-10-18 19:42   ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180302212919.GJ3887@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=davem@davemloft.net \
    --cc=johannes.berg@intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=samuel@sortiz.org \
    --cc=stephen@networkplumber.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).