Re: [PATCH] isdn: use setup_timer

2017-03-24 Thread David Miller
From: Geliang Tang 
Date: Thu, 23 Mar 2017 21:15:57 +0800

> Use setup_timer() instead of init_timer() to simplify the code.
> 
> Signed-off-by: Geliang Tang 

Applied, thanks.

It would be really nice to get rid of all of the (void *) casts these
calls do.  In particular this turns off type checking for the timer
method, which is really rediculous and dangerous.


Re: [PATCH] isdn: use setup_timer

2017-03-24 Thread David Miller
From: Geliang Tang 
Date: Thu, 23 Mar 2017 21:15:57 +0800

> Use setup_timer() instead of init_timer() to simplify the code.
> 
> Signed-off-by: Geliang Tang 

Applied, thanks.

It would be really nice to get rid of all of the (void *) casts these
calls do.  In particular this turns off type checking for the timer
method, which is really rediculous and dangerous.


[PATCH] isdn: use setup_timer

2017-03-23 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/isdn/divert/isdn_divert.c   |  9 +++--
 drivers/isdn/hardware/eicon/divasi.c|  5 ++---
 drivers/isdn/hardware/mISDN/hfcmulti.c  | 10 --
 drivers/isdn/hardware/mISDN/hfcpci.c|  9 +++--
 drivers/isdn/hardware/mISDN/mISDNipac.c |  5 ++---
 drivers/isdn/hardware/mISDN/mISDNisar.c | 10 --
 drivers/isdn/hardware/mISDN/w6692.c |  5 ++---
 drivers/isdn/hisax/amd7930_fn.c |  4 +---
 drivers/isdn/hisax/arcofi.c |  4 +---
 drivers/isdn/hisax/diva.c   |  5 ++---
 drivers/isdn/hisax/elsa.c   |  4 +---
 drivers/isdn/hisax/fsm.c|  4 +---
 drivers/isdn/hisax/hfc4s8s_l1.c |  5 ++---
 drivers/isdn/hisax/hfc_2bds0.c  |  4 +---
 drivers/isdn/hisax/hfc_pci.c|  8 ++--
 drivers/isdn/hisax/hfc_sx.c |  8 ++--
 drivers/isdn/hisax/hfc_usb.c|  8 ++--
 drivers/isdn/hisax/hfcscard.c   |  4 +---
 drivers/isdn/hisax/icc.c|  4 +---
 drivers/isdn/hisax/ipacx.c  |  4 +---
 drivers/isdn/hisax/isac.c   |  4 +---
 drivers/isdn/hisax/isar.c   | 10 --
 drivers/isdn/hisax/isdnl3.c |  4 +---
 drivers/isdn/hisax/teleint.c|  4 +---
 drivers/isdn/hisax/w6692.c  |  5 ++---
 drivers/isdn/i4l/isdn_ppp.c |  5 ++---
 drivers/isdn/i4l/isdn_tty.c |  5 ++---
 drivers/isdn/mISDN/dsp_core.c   |  4 +---
 drivers/isdn/mISDN/fsm.c|  4 +---
 drivers/isdn/mISDN/l1oip_core.c |  4 +---
 30 files changed, 54 insertions(+), 114 deletions(-)

diff --git a/drivers/isdn/divert/isdn_divert.c 
b/drivers/isdn/divert/isdn_divert.c
index 50749a7..060d357 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -157,10 +157,8 @@ int cf_command(int drvid, int mode,
/* allocate mem for information struct */
if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
return (-ENOMEM); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire, (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own structure */
cs->ics.driver = drvid;
cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */
cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */
@@ -452,10 +450,9 @@ static int isdn_divert_icall(isdn_ctrl *ic)
return (0); /* no external deflection 
needed */
if (!(cs = kmalloc(sizeof(struct call_struc), 
GFP_ATOMIC)))
return (0); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire,
+   (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own 
structure */
 
cs->ics = *ic; /* copy incoming data */
if (!cs->ics.parm.setup.phone[0]) 
strcpy(cs->ics.parm.setup.phone, "0");
diff --git a/drivers/isdn/hardware/eicon/divasi.c 
b/drivers/isdn/hardware/eicon/divasi.c
index cb88090..c610495 100644
--- a/drivers/isdn/hardware/eicon/divasi.c
+++ b/drivers/isdn/hardware/eicon/divasi.c
@@ -300,9 +300,8 @@ static int um_idi_open_adapter(struct file *file, int 
adapter_nr)
p_os = (diva_um_idi_os_context_t *) diva_um_id_get_os_context(e);
init_waitqueue_head(_os->read_wait);
init_waitqueue_head(_os->close_wait);
-   init_timer(_os->diva_timer_id);
-   p_os->diva_timer_id.function = (void *) diva_um_timer_function;
-   p_os->diva_timer_id.data = (unsigned long) p_os;
+   setup_timer(_os->diva_timer_id, (void *)diva_um_timer_function,
+   (unsigned long)p_os);
p_os->aborted = 0;
p_os->adapter_nr = adapter_nr;
return (1);
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c 
b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 480c2d7..961c07e 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -3878,9 +3878,8 @@ hfcmulti_initmode(struct dchannel *dch)
if (hc->dnum[pt]) {
mode_hfcmulti(hc, dch->slot, dch->dev.D.protocol,
  -1, 0, -1, 0);
-   dch->timer.function = (void *) hfcmulti_dbusy_timer;
-   dch->timer.data = (long) dch;
-   init_timer(>timer);
+   setup_timer(>timer, (void *)hfcmulti_dbusy_timer,
+   (long)dch);
}
  

[PATCH] isdn: use setup_timer

2017-03-23 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/isdn/divert/isdn_divert.c   |  9 +++--
 drivers/isdn/hardware/eicon/divasi.c|  5 ++---
 drivers/isdn/hardware/mISDN/hfcmulti.c  | 10 --
 drivers/isdn/hardware/mISDN/hfcpci.c|  9 +++--
 drivers/isdn/hardware/mISDN/mISDNipac.c |  5 ++---
 drivers/isdn/hardware/mISDN/mISDNisar.c | 10 --
 drivers/isdn/hardware/mISDN/w6692.c |  5 ++---
 drivers/isdn/hisax/amd7930_fn.c |  4 +---
 drivers/isdn/hisax/arcofi.c |  4 +---
 drivers/isdn/hisax/diva.c   |  5 ++---
 drivers/isdn/hisax/elsa.c   |  4 +---
 drivers/isdn/hisax/fsm.c|  4 +---
 drivers/isdn/hisax/hfc4s8s_l1.c |  5 ++---
 drivers/isdn/hisax/hfc_2bds0.c  |  4 +---
 drivers/isdn/hisax/hfc_pci.c|  8 ++--
 drivers/isdn/hisax/hfc_sx.c |  8 ++--
 drivers/isdn/hisax/hfc_usb.c|  8 ++--
 drivers/isdn/hisax/hfcscard.c   |  4 +---
 drivers/isdn/hisax/icc.c|  4 +---
 drivers/isdn/hisax/ipacx.c  |  4 +---
 drivers/isdn/hisax/isac.c   |  4 +---
 drivers/isdn/hisax/isar.c   | 10 --
 drivers/isdn/hisax/isdnl3.c |  4 +---
 drivers/isdn/hisax/teleint.c|  4 +---
 drivers/isdn/hisax/w6692.c  |  5 ++---
 drivers/isdn/i4l/isdn_ppp.c |  5 ++---
 drivers/isdn/i4l/isdn_tty.c |  5 ++---
 drivers/isdn/mISDN/dsp_core.c   |  4 +---
 drivers/isdn/mISDN/fsm.c|  4 +---
 drivers/isdn/mISDN/l1oip_core.c |  4 +---
 30 files changed, 54 insertions(+), 114 deletions(-)

diff --git a/drivers/isdn/divert/isdn_divert.c 
b/drivers/isdn/divert/isdn_divert.c
index 50749a7..060d357 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -157,10 +157,8 @@ int cf_command(int drvid, int mode,
/* allocate mem for information struct */
if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
return (-ENOMEM); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire, (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own structure */
cs->ics.driver = drvid;
cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */
cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */
@@ -452,10 +450,9 @@ static int isdn_divert_icall(isdn_ctrl *ic)
return (0); /* no external deflection 
needed */
if (!(cs = kmalloc(sizeof(struct call_struc), 
GFP_ATOMIC)))
return (0); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire,
+   (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own 
structure */
 
cs->ics = *ic; /* copy incoming data */
if (!cs->ics.parm.setup.phone[0]) 
strcpy(cs->ics.parm.setup.phone, "0");
diff --git a/drivers/isdn/hardware/eicon/divasi.c 
b/drivers/isdn/hardware/eicon/divasi.c
index cb88090..c610495 100644
--- a/drivers/isdn/hardware/eicon/divasi.c
+++ b/drivers/isdn/hardware/eicon/divasi.c
@@ -300,9 +300,8 @@ static int um_idi_open_adapter(struct file *file, int 
adapter_nr)
p_os = (diva_um_idi_os_context_t *) diva_um_id_get_os_context(e);
init_waitqueue_head(_os->read_wait);
init_waitqueue_head(_os->close_wait);
-   init_timer(_os->diva_timer_id);
-   p_os->diva_timer_id.function = (void *) diva_um_timer_function;
-   p_os->diva_timer_id.data = (unsigned long) p_os;
+   setup_timer(_os->diva_timer_id, (void *)diva_um_timer_function,
+   (unsigned long)p_os);
p_os->aborted = 0;
p_os->adapter_nr = adapter_nr;
return (1);
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c 
b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 480c2d7..961c07e 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -3878,9 +3878,8 @@ hfcmulti_initmode(struct dchannel *dch)
if (hc->dnum[pt]) {
mode_hfcmulti(hc, dch->slot, dch->dev.D.protocol,
  -1, 0, -1, 0);
-   dch->timer.function = (void *) hfcmulti_dbusy_timer;
-   dch->timer.data = (long) dch;
-   init_timer(>timer);
+   setup_timer(>timer, (void *)hfcmulti_dbusy_timer,
+   (long)dch);
}
for (i = 1; i <= 31; 

[PATCH] isdn: Use setup_timer and mod_timer

2015-02-27 Thread Vaishali Thakkar
Use timer API functions setup_timer and mod_timer instead
of structure assignments as they are standard way to set
the timer and to update the expire field of an active timer
respectively.

This is done using Coccinelle and semantic patch used for
this is as follows:

// 
@@
expression x,y,z,a,b;
@@

-init_timer ();
+setup_timer (, y, z);
+mod_timer (, b);
-x.function = y;
-x.data = z;
-x.expires = b;
-add_timer();
// 

Signed-off-by: Vaishali Thakkar 
---
 drivers/isdn/pcbit/drv.c| 8 +++-
 drivers/isdn/pcbit/edss1.c  | 7 ++-
 drivers/isdn/pcbit/layer2.c | 8 +++-
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 4172e22..dc7df95 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -359,11 +359,9 @@ static int pcbit_xmit(int driver, int chnum, int ack, 
struct sk_buff *skb)
 */
 #ifdef BLOCK_TIMER
if (chan->block_timer.function == NULL) {
-   init_timer(>block_timer);
-   chan->block_timer.function =  _block_timer;
-   chan->block_timer.data = (long) chan;
-   chan->block_timer.expires = jiffies + 1 * HZ;
-   add_timer(>block_timer);
+   setup_timer(>block_timer, _block_timer,
+   (long)chan);
+   mod_timer(>block_timer, jiffies + 1 * HZ);
}
 #endif
return 0;
diff --git a/drivers/isdn/pcbit/edss1.c b/drivers/isdn/pcbit/edss1.c
index b2262ba..af524c7 100644
--- a/drivers/isdn/pcbit/edss1.c
+++ b/drivers/isdn/pcbit/edss1.c
@@ -298,11 +298,8 @@ void pcbit_fsm_event(struct pcbit_dev *dev, struct 
pcbit_chan *chan,
break;
 
if (tentry->init != 0xff) {
-   init_timer(>fsm_timer);
-   chan->fsm_timer.function = _fsm_timer;
-   chan->fsm_timer.data = (ulong) chan;
-   chan->fsm_timer.expires = jiffies + tentry->timeout * HZ;
-   add_timer(>fsm_timer);
+   setup_timer(>fsm_timer, _fsm_timer, (ulong)chan);
+   mod_timer(>fsm_timer, jiffies + tentry->timeout * HZ);
}
 
spin_unlock_irqrestore(>lock, flags);
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 46e1240..a136c72 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -645,11 +645,9 @@ pcbit_l2_error(struct pcbit_dev *dev)
 
dev->l2_state = L2_DOWN;
 
-   init_timer(>error_recover_timer);
-   dev->error_recover_timer.function = _l2_err_recover;
-   dev->error_recover_timer.data = (ulong) dev;
-   dev->error_recover_timer.expires = jiffies + ERRTIME;
-   add_timer(>error_recover_timer);
+   setup_timer(>error_recover_timer, _l2_err_recover,
+   (ulong)dev);
+   mod_timer(>error_recover_timer, jiffies + ERRTIME);
}
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] isdn: Use setup_timer and mod_timer

2015-02-27 Thread Vaishali Thakkar
Use timer API functions setup_timer and mod_timer instead
of structure assignments as they are standard way to set
the timer and to update the expire field of an active timer
respectively.

This is done using Coccinelle and semantic patch used for
this is as follows:

// smpl
@@
expression x,y,z,a,b;
@@

-init_timer (x);
+setup_timer (x, y, z);
+mod_timer (a, b);
-x.function = y;
-x.data = z;
-x.expires = b;
-add_timer(a);
// /smpl

Signed-off-by: Vaishali Thakkar vthakkar1...@gmail.com
---
 drivers/isdn/pcbit/drv.c| 8 +++-
 drivers/isdn/pcbit/edss1.c  | 7 ++-
 drivers/isdn/pcbit/layer2.c | 8 +++-
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 4172e22..dc7df95 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -359,11 +359,9 @@ static int pcbit_xmit(int driver, int chnum, int ack, 
struct sk_buff *skb)
 */
 #ifdef BLOCK_TIMER
if (chan-block_timer.function == NULL) {
-   init_timer(chan-block_timer);
-   chan-block_timer.function =  pcbit_block_timer;
-   chan-block_timer.data = (long) chan;
-   chan-block_timer.expires = jiffies + 1 * HZ;
-   add_timer(chan-block_timer);
+   setup_timer(chan-block_timer, pcbit_block_timer,
+   (long)chan);
+   mod_timer(chan-block_timer, jiffies + 1 * HZ);
}
 #endif
return 0;
diff --git a/drivers/isdn/pcbit/edss1.c b/drivers/isdn/pcbit/edss1.c
index b2262ba..af524c7 100644
--- a/drivers/isdn/pcbit/edss1.c
+++ b/drivers/isdn/pcbit/edss1.c
@@ -298,11 +298,8 @@ void pcbit_fsm_event(struct pcbit_dev *dev, struct 
pcbit_chan *chan,
break;
 
if (tentry-init != 0xff) {
-   init_timer(chan-fsm_timer);
-   chan-fsm_timer.function = pcbit_fsm_timer;
-   chan-fsm_timer.data = (ulong) chan;
-   chan-fsm_timer.expires = jiffies + tentry-timeout * HZ;
-   add_timer(chan-fsm_timer);
+   setup_timer(chan-fsm_timer, pcbit_fsm_timer, (ulong)chan);
+   mod_timer(chan-fsm_timer, jiffies + tentry-timeout * HZ);
}
 
spin_unlock_irqrestore(dev-lock, flags);
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 46e1240..a136c72 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -645,11 +645,9 @@ pcbit_l2_error(struct pcbit_dev *dev)
 
dev-l2_state = L2_DOWN;
 
-   init_timer(dev-error_recover_timer);
-   dev-error_recover_timer.function = pcbit_l2_err_recover;
-   dev-error_recover_timer.data = (ulong) dev;
-   dev-error_recover_timer.expires = jiffies + ERRTIME;
-   add_timer(dev-error_recover_timer);
+   setup_timer(dev-error_recover_timer, pcbit_l2_err_recover,
+   (ulong)dev);
+   mod_timer(dev-error_recover_timer, jiffies + ERRTIME);
}
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/