[dahdi-commits] dahdi/linux.git branch "next" updated.

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Mon Sep 3 03:05:07 CDT 2018


branch "next" has been updated
       via  6667f1c8d8fadc29ef95dce4f8b025f38d3d3084 (commit)
       via  20328895a28831024baf7fcd9e7bce57ef7cf263 (commit)
       via  7ecdf370bc137dab124eab134781ca23aa2ab5b4 (commit)
       via  ea2d67414a2a543a113eebdbbb541ce648b90b74 (commit)
       via  14d8754e342dbd05ee775ef31488e9a8ae797d4c (commit)
       via  d3c9e434373f6eac20ee4ff827286d5e97960a9a (commit)
       via  9a4d2fce48c33ef2779f103605e688d3839a06a0 (commit)
       via  26597a5cac2930c191ae540c03c7406745c03e36 (commit)
       via  d4e232a776ee27eb04aed3cbd72a203118dbe9f1 (commit)
       via  52f2c1976989a61b96d2e60a65450d28ff17bca0 (commit)
      from  960472ed35e2c3e2fffb34042a3ff4481fcb99c2 (commit)

Summary of changes:
 .gitignore                          |    2 +
 drivers/dahdi/Kbuild                |    2 +-
 drivers/dahdi/dahdi-base.c          |   21 +++-----
 drivers/dahdi/dahdi-sysfs-chan.c    |   38 +++++++++++++
 drivers/dahdi/dahdi-sysfs.c         |  101 +++++++++++++++++++++++++++++------
 drivers/dahdi/dahdi_dummy.c         |    8 ++-
 drivers/dahdi/dahdi_dynamic.c       |   11 ++--
 drivers/dahdi/dahdi_dynamic_ethmf.c |   16 ++----
 drivers/dahdi/datamods/syncppp.c    |    9 ++--
 drivers/dahdi/voicebus/GpakApi.c    |    2 +
 drivers/dahdi/voicebus/voicebus.c   |   16 +++---
 drivers/dahdi/wctc4xxp/base.c       |   12 ++---
 drivers/dahdi/wcte12xp/base.c       |    9 ++--
 drivers/dahdi/wcte13xp-base.c       |    9 ++--
 drivers/dahdi/wcte43x-base.c        |    9 ++--
 drivers/dahdi/xpp/card_fxs.c        |    6 ++-
 drivers/dahdi/xpp/init_card_1_30    |    2 +-
 drivers/dahdi/xpp/init_card_6_30    |    4 --
 drivers/dahdi/xpp/xbus-core.c       |    1 -
 drivers/dahdi/xpp/xbus-pcm.c        |   11 ++--
 drivers/dahdi/xpp/xbus-sysfs.c      |   66 +++++++++++++++++++++++
 include/dahdi/kernel.h              |   35 ++++++++++++
 22 files changed, 287 insertions(+), 103 deletions(-)
 mode change 100644 => 100755 drivers/dahdi/xpp/init_card_6_30


- Log -----------------------------------------------------------------
commit 6667f1c8d8fadc29ef95dce4f8b025f38d3d3084
Author: Shaun Ruffell <sruffell at sruffell.net>
Date:   Fri Aug 10 00:13:52 2018 -0500

    DAHDI in kernel 4.15: Switch to new timer_setup interface.
    
    Upstream kernel 4.14, in commit (686fef928bba6b "timer: Prepare to change timer
    callback argument type") [1], introduced the timer_setup interface to replace
    the init_timer/setup_timer interfaces. The primary change is that the timer
    callback functions now follow the standard kernel pattern where the structure
    the callback sits in is passed to the callback instead of storing a pointer to
    an unassociated data type.
    
    The setup_timer functions were removed in upstream kernel v4.15, and therefore
    this change is needed in order to compile DAHDI for kernels >= 4.15.
    
    This change follows the same strategy that was done in the kernel to while the
    existing users of setup_timer were migrated to the new interface.
    
    [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=686fef928bba6b

diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index c6f95f0..38df9c4 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -10069,7 +10069,7 @@ static inline unsigned long msecs_processed(const struct core_timer *const ct)
 	return atomic_read(&ct->count) * DAHDI_MSECS_PER_CHUNK;
 }
 
-static void coretimer_func(unsigned long param)
+static void coretimer_func(TIMER_DATA_TYPE unused)
 {
 	unsigned long flags;
 	unsigned long ms_since_start;
@@ -10150,16 +10150,14 @@ static void coretimer_func(unsigned long param)
 
 static void coretimer_init(void)
 {
-	init_timer(&core_timer.timer);
-	core_timer.timer.function = coretimer_func;
+	timer_setup(&core_timer.timer, coretimer_func, 0);
 	ktime_get_ts(&core_timer.start_interval);
 	atomic_set(&core_timer.count, 0);
 	atomic_set(&core_timer.shutdown, 0);
 	core_timer.interval = max(msecs_to_jiffies(DAHDI_MSECS_PER_CHUNK), 1UL);
 	if (core_timer.interval < (HZ/250))
 		core_timer.interval = (HZ/250);
-	core_timer.timer.expires = jiffies + core_timer.interval;
-	add_timer(&core_timer.timer);
+	mod_timer(&core_timer.timer, jiffies + core_timer.interval);
 }
 
 static void coretimer_cleanup(void)
@@ -10455,7 +10453,7 @@ static const struct file_operations dahdi_chan_fops = {
 #ifdef CONFIG_DAHDI_WATCHDOG
 static struct timer_list watchdogtimer;
 
-static void watchdog_check(unsigned long ignored)
+static void watchdog_check(TIMER_DATA_TYPE ignored)
 {
 	unsigned long flags;
 	static int wdcheck=0;
@@ -10496,10 +10494,7 @@ static void watchdog_check(unsigned long ignored)
 
 static int __init watchdog_init(void)
 {
-	init_timer(&watchdogtimer);
-	watchdogtimer.expires = 0;
-	watchdogtimer.data =0;
-	watchdogtimer.function = watchdog_check;
+	timer_setup(&watchdogtimer, watchdog_check, 0);
 	/* Run every couple of jiffy or so */
 	mod_timer(&watchdogtimer, jiffies + 2);
 	return 0;
diff --git a/drivers/dahdi/dahdi_dummy.c b/drivers/dahdi/dahdi_dummy.c
index 5358f3d..b75c6a6 100644
--- a/drivers/dahdi/dahdi_dummy.c
+++ b/drivers/dahdi/dahdi_dummy.c
@@ -157,7 +157,7 @@ static unsigned long timespec_diff_ms(struct timespec *t0, struct timespec *t1)
 	return ms;
 }
 
-static void dahdi_dummy_timer(unsigned long param)
+static void dahdi_dummy_timer(struct timer_timer *unused)
 {
 	unsigned long ms_since_start;
 	struct timespec now;
@@ -258,12 +258,10 @@ int init_module(void)
 	hrtimer_start(&zaptimer, ktime_set(0, DAHDI_TIME_NS), HRTIMER_MODE_REL);
 	printk(KERN_INFO "dahdi_dummy: High Resolution Timer started, good to go\n");
 #else
-	init_timer(&timer);
-	timer.function = dahdi_dummy_timer;
+	timer_setup(&timer, dahdi_dummy_timer);
 	ztd->start_interval = current_kernel_time();
-	timer.expires = jiffies + JIFFIES_INTERVAL;
 	atomic_set(&shutdown, 0);
-	add_timer(&timer);
+	mod_timer(&timer, jiffies + JIFFIES_INTERVAL);
 #endif
 
 	if (debug)
diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c
index 7811f9d..b1df408 100644
--- a/drivers/dahdi/dahdi_dynamic.c
+++ b/drivers/dahdi/dahdi_dynamic.c
@@ -831,7 +831,7 @@ EXPORT_SYMBOL(dahdi_dynamic_unregister_driver);
 
 static struct timer_list alarmcheck;
 
-static void check_for_red_alarm(unsigned long ignored)
+static void check_for_red_alarm(TIMER_DATA_TYPE unused)
 {
 	int newalarm;
 	int alarmchanged = 0;
@@ -867,10 +867,7 @@ static const struct dahdi_dynamic_ops dahdi_dynamic_ops = {
 static int dahdi_dynamic_init(void)
 {
 	/* Start process to check for RED ALARM */
-	init_timer(&alarmcheck);
-	alarmcheck.expires = 0;
-	alarmcheck.data = 0;
-	alarmcheck.function = check_for_red_alarm;
+	timer_setup(&alarmcheck, check_for_red_alarm, 0);
 	/* Check once per second */
 	mod_timer(&alarmcheck, jiffies + 1 * HZ);
 #ifdef ENABLE_TASKLETS
diff --git a/drivers/dahdi/dahdi_dynamic_ethmf.c b/drivers/dahdi/dahdi_dynamic_ethmf.c
index dec368b..90e4e6d 100644
--- a/drivers/dahdi/dahdi_dynamic_ethmf.c
+++ b/drivers/dahdi/dahdi_dynamic_ethmf.c
@@ -681,16 +681,13 @@ static int ethmf_delay_dec(void)
  * Timer callback function to allow all spans to be added, prior to any of
  * them being used.
  */
-static void timer_callback(unsigned long param)
+static void timer_callback(TIMER_DATA_TYPE unused)
 {
 	if (ethmf_delay_dec()) {
-		if (!atomic_read(&timer_deleted)) {
-			timer.expires = jiffies + HZ;
-			add_timer(&timer);
-		}
+		if (!atomic_read(&timer_deleted))
+			mod_timer(&timer, jiffies + HZ);
 	} else {
 		printk(KERN_INFO "All TDMoE multiframe span groups are active.\n");
-		del_timer(&timer);
 	}
 }
 
@@ -764,11 +761,8 @@ static const struct file_operations ztdethmf_proc_fops = {
 
 static int __init ztdethmf_init(void)
 {
-	init_timer(&timer);
-	timer.expires = jiffies + HZ;
-	timer.function = &timer_callback;
-	if (!timer_pending(&timer))
-		add_timer(&timer);
+	timer_setup(&timer, timer_callback, 0);
+	mod_timer(&timer, jiffies + HZ);
 
 	dev_add_pack(&ztdethmf_ptype);
 	register_netdevice_notifier(&ztdethmf_nblock);
diff --git a/drivers/dahdi/datamods/syncppp.c b/drivers/dahdi/datamods/syncppp.c
index 1a59caf..0e79a23 100644
--- a/drivers/dahdi/datamods/syncppp.c
+++ b/drivers/dahdi/datamods/syncppp.c
@@ -148,7 +148,7 @@ static void sppp_lcp_open (struct sppp *sp);
 static void sppp_ipcp_open (struct sppp *sp);
 static int sppp_lcp_conf_parse_options (struct sppp *sp, struct lcp_header *h,
 	int len, u32 *magic);
-static void sppp_cp_timeout (unsigned long arg);
+static void sppp_cp_timeout (TIMER_DATA_TYPE timer);
 static char *sppp_lcp_type_name (u8 type);
 static char *sppp_ipcp_type_name (u8 type);
 static void sppp_print_bytes (u8 *p, u16 len);
@@ -189,12 +189,9 @@ static void sppp_set_timeout(struct sppp *p,int s)
 {
 	if (! (p->pp_flags & PP_TIMO)) 
 	{
-		init_timer(&p->pp_timer);
-		p->pp_timer.function=sppp_cp_timeout;
-		p->pp_timer.expires=jiffies+s*HZ;
-		p->pp_timer.data=(unsigned long)p;
 		p->pp_flags |= PP_TIMO;
-		add_timer(&p->pp_timer);
+		timer_setup(&p->pp_timer, sppp_cp_timeout, 0);
+		mod_timer(&p->pp_timer, jiffies + s*HZ);
 	}
 }
 
diff --git a/drivers/dahdi/voicebus/voicebus.c b/drivers/dahdi/voicebus/voicebus.c
index 7ee7763..fb8c60c 100644
--- a/drivers/dahdi/voicebus/voicebus.c
+++ b/drivers/dahdi/voicebus/voicebus.c
@@ -1000,6 +1000,7 @@ __vb_rx_demand_poll(struct voicebus *vb)
 		__vb_setctl(vb, 0x0010, 0x00000000);
 }
 
+#ifndef CONFIG_VOICEBUS_TIMER
 static void
 __vb_enable_interrupts(struct voicebus *vb)
 {
@@ -1008,6 +1009,7 @@ __vb_enable_interrupts(struct voicebus *vb)
 	else
 		__vb_setctl(vb, IER_CSR7, DEFAULT_NORMAL_INTERRUPTS);
 }
+#endif
 
 static void
 __vb_disable_interrupts(struct voicebus *vb)
@@ -1033,8 +1035,7 @@ static void start_packet_processing(struct voicebus *vb)
 	clear_bit(VOICEBUS_STOP, &vb->flags);
 	clear_bit(VOICEBUS_STOPPED, &vb->flags);
 #if defined(CONFIG_VOICEBUS_TIMER)
-	vb->timer.expires = jiffies + HZ/1000;
-	add_timer(&vb->timer);
+	mod_timer(&vb->timer, jiffies + HZ/1000);
 #else
 	/* Clear the interrupt status register. */
 	__vb_setctl(vb, SR_CSR5, 0xffffffff);
@@ -1746,18 +1747,17 @@ vb_isr(int irq, void *dev_id)
  * the timer.
  */
 static void
-vb_timer(unsigned long data)
+vb_timer(TIMER_DATA_TYPE timer)
 {
 	unsigned long start = jiffies;
-	struct voicebus *vb = (struct voicebus *)data;
+	struct voicebus *vb = from_timer(vb, timer, timer);
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
 	vb_isr(0, vb, 0);
 #else
 	vb_isr(0, vb);
 #endif
 	if (!test_bit(VOICEBUS_STOPPED, &vb->flags)) {
-		vb->timer.expires = start + HZ/1000;
-		add_timer(&vb->timer);
+		mod_timer(&vb->timer, start + HZ/1000);
 	}
 }
 #endif
@@ -1800,9 +1800,7 @@ __voicebus_init(struct voicebus *vb, const char *board_name,
 	INIT_LIST_HEAD(&vb->free_rx);
 
 #if defined(CONFIG_VOICEBUS_TIMER)
-	init_timer(&vb->timer);
-	vb->timer.function = vb_timer;
-	vb->timer.data = (unsigned long)vb;
+	timer_setup(&vb->timer, vb_timer, 0);
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
diff --git a/drivers/dahdi/wctc4xxp/base.c b/drivers/dahdi/wctc4xxp/base.c
index 0d76d6a..88d3865 100644
--- a/drivers/dahdi/wctc4xxp/base.c
+++ b/drivers/dahdi/wctc4xxp/base.c
@@ -3701,9 +3701,9 @@ wctc4xxp_send_commands(struct wcdte *wc, struct list_head *to_send)
 }
 
 static void
-wctc4xxp_watchdog(unsigned long data)
+wctc4xxp_watchdog(TIMER_DATA_TYPE timer)
 {
-	struct wcdte *wc = (struct wcdte *)data;
+	struct wcdte *wc = from_timer(wc, timer, watchdog);
 	struct tcb *cmd, *temp;
 	LIST_HEAD(cmds_to_retry);
 	const int MAX_RETRIES = 5;
@@ -4090,13 +4090,7 @@ wctc4xxp_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 			goto error_exit_swinit;
 	}
 
-#	if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
-	wc->watchdog.function = wctc4xxp_watchdog;
-	wc->watchdog.data = (unsigned long)wc;
-	init_timer(&wc->watchdog);
-#	else
-	setup_timer(&wc->watchdog, wctc4xxp_watchdog, (unsigned long)wc);
-#	endif
+	timer_setup(&wc->watchdog, wctc4xxp_watchdog, 0);
 
 	/* ------------------------------------------------------------------
 	 * Load the firmware and start the DTE.
diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c
index 2164e63..9932656 100644
--- a/drivers/dahdi/wcte12xp/base.c
+++ b/drivers/dahdi/wcte12xp/base.c
@@ -2766,10 +2766,10 @@ static void vpm_check_func(struct work_struct *work)
 	return;
 }
 
-static void te12xp_timer(unsigned long data)
+static void te12xp_timer(TIMER_DATA_TYPE timer)
 {
 	unsigned long flags;
-	struct t1 *wc = (struct t1 *)data;
+	struct t1 *wc = from_timer(wc, timer, timer);
 
 	if (unlikely(!test_bit(INITIALIZED, &wc->bit_flags)))
 		return;
@@ -2944,7 +2944,7 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi
 	spin_lock_init(&wc->reglock);
 	INIT_LIST_HEAD(&wc->active_cmds);
 	INIT_LIST_HEAD(&wc->pending_cmds);
-	setup_timer(&wc->timer, te12xp_timer, (unsigned long)wc);
+	timer_setup(&wc->timer, te12xp_timer, 0);
 
 #	if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
 	INIT_WORK(&wc->timer_work, timer_work_func, wc);
diff --git a/drivers/dahdi/wcte13xp-base.c b/drivers/dahdi/wcte13xp-base.c
index bb80f15..ef9b5cd 100644
--- a/drivers/dahdi/wcte13xp-base.c
+++ b/drivers/dahdi/wcte13xp-base.c
@@ -2382,9 +2382,9 @@ static void te13x_handle_interrupt(struct wcxb *xb, u32 pending)
 	}
 }
 
-static void te13xp_timer(unsigned long data)
+static void te13xp_timer(TIMER_DATA_TYPE timer)
 {
-	struct t13x *wc = (struct t13x *)data;
+	struct t13x *wc = from_timer(wc, timer, timer);
 
 	if (unlikely(!test_bit(INITIALIZED, &wc->bit_flags)))
 		return;
@@ -2583,7 +2583,7 @@ static int __devinit te13xp_init_one(struct pci_dev *pdev,
 	wc->ledstate = -1;
 	spin_lock_init(&wc->reglock);
 	mutex_init(&wc->lock);
-	setup_timer(&wc->timer, te13xp_timer, (unsigned long)wc);
+	timer_setup(&wc->timer, te13xp_timer, 0);
 
 #	if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
 	INIT_WORK(&wc->timer_work, timer_work_func, wc);
diff --git a/drivers/dahdi/wcte43x-base.c b/drivers/dahdi/wcte43x-base.c
index c9b7978..74018ea 100644
--- a/drivers/dahdi/wcte43x-base.c
+++ b/drivers/dahdi/wcte43x-base.c
@@ -3204,9 +3204,9 @@ static void t43x_handle_interrupt(struct wcxb *xb, u32 pending)
 		wc->intr_span = 0;
 }
 
-static void t43x_timer(unsigned long data)
+static void t43x_timer(TIMER_DATA_TYPE timer)
 {
-	struct t43x *wc = (struct t43x *)data;
+	struct t43x *wc = from_timer(wc, timer, timer);
 
 	if (!is_initialized(wc))
 		return;
@@ -3432,7 +3432,7 @@ static int __devinit t43x_init_one(struct pci_dev *pdev,
 		goto fail_exit;
 
 	mutex_init(&wc->lock);
-	setup_timer(&wc->timer, t43x_timer, (unsigned long)wc);
+	timer_setup(&wc->timer, t43x_timer, 0);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
 	INIT_WORK(&wc->timer_work, timer_work_func, wc);
diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
index 4281f1c..565d267 100644
--- a/drivers/dahdi/xpp/xbus-core.c
+++ b/drivers/dahdi/xpp/xbus-core.c
@@ -1612,7 +1612,6 @@ xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size,
 	transport_init(xbus, ops, max_send_size, transport_device, priv);
 	spin_lock_init(&xbus->lock);
 	init_waitqueue_head(&xbus->command_queue_empty);
-	init_timer(&xbus->command_timer);
 	atomic_set(&xbus->pcm_rx_counter, 0);
 	xbus->min_tx_sync = INT_MAX;
 	xbus->min_rx_sync = INT_MAX;
diff --git a/drivers/dahdi/xpp/xbus-pcm.c b/drivers/dahdi/xpp/xbus-pcm.c
index 32f04fa..37f9260 100644
--- a/drivers/dahdi/xpp/xbus-pcm.c
+++ b/drivers/dahdi/xpp/xbus-pcm.c
@@ -353,9 +353,9 @@ static void xpp_set_syncer(xbus_t *xbus, bool on)
 			 (syncer) ? syncer->busname : "NO-SYNC");
 }
 
-static void xbus_command_timer(unsigned long param)
+static void xbus_command_timer(TIMER_DATA_TYPE timer)
 {
-	xbus_t *xbus = (xbus_t *)param;
+	xbus_t *xbus = from_timer(xbus, timer, command_timer);
 	struct timeval now;
 
 	BUG_ON(!xbus);
@@ -371,10 +371,9 @@ void xbus_set_command_timer(xbus_t *xbus, bool on)
 	if (on) {
 		if (!timer_pending(&xbus->command_timer)) {
 			XBUS_DBG(SYNC, xbus, "add_timer\n");
-			xbus->command_timer.function = xbus_command_timer;
-			xbus->command_timer.data = (unsigned long)xbus;
-			xbus->command_timer.expires = jiffies + 1;
-			add_timer(&xbus->command_timer);
+			timer_setup(&xbus->command_timer,
+				xbus_command_timer, 0);
+			mod_timer(&xbus->command_timer, jiffies + 1);
 		}
 	} else if (timer_pending(&xbus->command_timer)) {
 		XBUS_DBG(SYNC, xbus, "del_timer\n");
diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h
index c946fa3..5431652 100644
--- a/include/dahdi/kernel.h
+++ b/include/dahdi/kernel.h
@@ -1404,6 +1404,33 @@ static inline short dahdi_txtone_nextsample(struct dahdi_chan *ss)
 /*! Maximum audio mask */
 #define DAHDI_FORMAT_AUDIO_MASK	((1 << 16) - 1)
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
+
+#ifndef TIMER_DATA_TYPE
+#define TIMER_DATA_TYPE unsigned long
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
+
+/**
+ * timer_setup - Added in 4.13.0.  We can make a direct translation to the
+ * setup_timer interface since DAHDI does not pass any flags to any of the
+ * timer_setup functions.
+ *
+ */
+static inline void
+timer_setup(struct timer_list *timer,
+	    void (*timer_callback)(TIMER_DATA_TYPE data),
+	    unsigned long flags)
+{
+	WARN_ON(flags != 0);
+	setup_timer(timer, timer_callback, (TIMER_DATA_TYPE)timer);
+}
+
+#define from_timer(var, callback_timer, timer_fieldname) \
+	container_of((struct timer_list *)(callback_timer), \
+		     typeof(*var), timer_fieldname)
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
 #define refcount_read atomic_read
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
@@ -1536,6 +1563,14 @@ static inline int strcasecmp(const char *s1, const char *s2)
 #endif /* 3.10.0 */
 #endif /* 3.16.0 */
 #endif /* 4.11.0 */
+#endif /* 4.13.0 */
+#else /* >= 4.15.0 */
+
+#ifndef TIMER_DATA_TYPE
+#define TIMER_DATA_TYPE struct timer_list *
+#endif
+
+#endif /* 4.15.0 */
 
 #ifndef DEFINE_SPINLOCK
 #define DEFINE_SPINLOCK(x)      spinlock_t x = SPIN_LOCK_UNLOCKED

commit 20328895a28831024baf7fcd9e7bce57ef7cf263
Author: Shaun Ruffell <sruffell at sruffell.net>
Date:   Thu Aug 9 22:27:40 2018 -0500

    Disable -Wformat-truncation and prevent potential string overflows.
    
    GCC 7.3.0 complained about the potential to overflow the fixed size span and
    channel names and descriptions. It also flagged potential truncations of the
    strings.
    
    The sprintf calls are now changed to snprintf to prevent the potential
    overflows, but the warning about truncations are now disabled globally.

diff --git a/drivers/dahdi/Kbuild b/drivers/dahdi/Kbuild
index ee2cd59..25a8d37 100644
--- a/drivers/dahdi/Kbuild
+++ b/drivers/dahdi/Kbuild
@@ -66,7 +66,7 @@ obj-m += dahdi_echocan_oslec.o
 obj-m += ../staging/echo/echo.o
 endif
 
-CFLAGS_MODULE += -I$(DAHDI_INCLUDE) -I$(src)
+CFLAGS_MODULE += -I$(DAHDI_INCLUDE) -I$(src) -Wno-format-truncation
 
 ifndef HOTPLUG_FIRMWARE
 ifneq (,$(filter y m,$(CONFIG_FW_LOADER)))
diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c
index 0a37e2a..7811f9d 100644
--- a/drivers/dahdi/dahdi_dynamic.c
+++ b/drivers/dahdi/dahdi_dynamic.c
@@ -638,8 +638,8 @@ static int _create_dynamic(struct dahdi_dynamic_span *dds)
 		DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CRC4 | DAHDI_CONFIG_NOTOPEN;
 	d->span.ops = &dynamic_ops;
 	for (x = 0; x < d->span.channels; x++) {
-		sprintf(d->chans[x]->name, "DYN/%s/%s/%d",
-			dds->driver, dds->addr, x+1);
+		snprintf(d->chans[x]->name, sizeof(d->chans[x]->name),
+			 "DYN/%s/%s/%d", dds->driver, dds->addr, x+1);
 		d->chans[x]->sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR |
 				      DAHDI_SIG_FXSLS | DAHDI_SIG_FXSKS |
 				      DAHDI_SIG_FXSGS | DAHDI_SIG_FXOLS |
diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c
index c327c5f..2164e63 100644
--- a/drivers/dahdi/wcte12xp/base.c
+++ b/drivers/dahdi/wcte12xp/base.c
@@ -2069,7 +2069,8 @@ static int t1_software_init(struct t1 *wc, enum linemode type)
 	t4_serial_setup(wc);
 	set_bit(DAHDI_FLAGBIT_RBS, &wc->span.flags);
 	for (x = 0; x < wc->span.channels; x++) {
-		sprintf(wc->chans[x]->name, "%s/%d", wc->span.name, x + 1);
+		snprintf(wc->chans[x]->name, sizeof(wc->chans[x]->name),
+			 "%s/%d", wc->span.name, x + 1);
 		t1_chan_set_sigcap(&wc->span, x);
 		wc->chans[x]->pvt = wc;
 		wc->chans[x]->chanpos = x + 1;
diff --git a/drivers/dahdi/wcte13xp-base.c b/drivers/dahdi/wcte13xp-base.c
index c5ebe9d..bb80f15 100644
--- a/drivers/dahdi/wcte13xp-base.c
+++ b/drivers/dahdi/wcte13xp-base.c
@@ -1805,7 +1805,8 @@ static int t13x_software_init(struct t13x *wc, enum linemode type)
 	t13x_serial_setup(wc);
 	set_bit(DAHDI_FLAGBIT_RBS, &wc->span.flags);
 	for (x = 0; x < wc->span.channels; x++) {
-		sprintf(wc->chans[x]->name, "%s/%d", wc->span.name, x + 1);
+		snprintf(wc->chans[x]->name, sizeof(wc->chans[x]->name),
+			 "%s/%d", wc->span.name, x + 1);
 		t13x_chan_set_sigcap(&wc->span, x);
 		wc->chans[x]->pvt = wc;
 		wc->chans[x]->chanpos = x + 1;
diff --git a/drivers/dahdi/wcte43x-base.c b/drivers/dahdi/wcte43x-base.c
index 3e6159b..c9b7978 100644
--- a/drivers/dahdi/wcte43x-base.c
+++ b/drivers/dahdi/wcte43x-base.c
@@ -2536,7 +2536,8 @@ t43x_init_one_span(struct t43x *wc, struct t43x_span *ts, enum linemode type)
 
 	set_bit(DAHDI_FLAGBIT_RBS, &ts->span.flags);
 	for (x = 0; x < ts->span.channels; x++) {
-		sprintf(ts->chans[x]->name, "%s/%d", ts->span.name, x + 1);
+		snprintf(ts->chans[x]->name, sizeof(ts->chans[x]->name),
+			 "%s/%d", ts->span.name, x + 1);
 		t43x_chan_set_sigcap(&ts->span, x);
 		ts->chans[x]->pvt = wc;
 		ts->chans[x]->chanpos = x + 1;

commit 7ecdf370bc137dab124eab134781ca23aa2ab5b4
Author: Shaun Ruffell <sruffell at sruffell.net>
Date:   Thu Aug 9 22:26:17 2018 -0500

    voicebus: Initialize stack buffer.
    
    Quiets the following (valid) warning from gcc 7.3.0:
    
    drivers/dahdi/voicebus/GpakApi.c:1648:22: warning: ‘MsgBuffer[1]’ may be used
       uninitialized in this function [-Wmaybe-uninitialized]
             MsgBuffer[1] |= DTMF_UPDATE_MASK;

diff --git a/drivers/dahdi/voicebus/GpakApi.c b/drivers/dahdi/voicebus/GpakApi.c
index d65732b..4ff5dcb 100644
--- a/drivers/dahdi/voicebus/GpakApi.c
+++ b/drivers/dahdi/voicebus/GpakApi.c
@@ -1636,6 +1636,8 @@ gpakWriteSysParmsStatus_t gpakWriteSystemParms(
     DSP_WORD MsgBuffer[MSG_BUFFER_SIZE];    /* message buffer */
     DSP_WORD DspStatus;                     /* DSP's reply status */
 
+    memset(MsgBuffer, 0, sizeof(MsgBuffer));
+
     /* Make sure the DSP Id is valid. */
     if (DspId >= MAX_DSP_CORES)
         return (WspInvalidDsp);

commit ea2d67414a2a543a113eebdbbb541ce648b90b74
Author: Shaun Ruffell <sruffell at sruffell.net>
Date:   Thu Aug 9 22:23:57 2018 -0500

    xpp: fxs: Do not increment boolean.
    
    This quiets the following warning from gcc 7.3.0:
    
      drivers/dahdi/xpp/card_fxs.c:1344:17: warning: increment of a boolean
      	expression [-Wbool-operation]

diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c
index 03fcc3a..ab5f5a8 100644
--- a/drivers/dahdi/xpp/card_fxs.c
+++ b/drivers/dahdi/xpp/card_fxs.c
@@ -1341,11 +1341,13 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd,
 		if (!vmwi_ioctl) {
 			static bool notified;
 
-			if (!notified++)
+			if (!notified) {
+				notified = true;
 				LINE_NOTICE(xpd, pos,
 					"Got DAHDI_VMWI notification "
 					"but vmwi_ioctl parameter is off. "
 					"Ignoring.\n");
+			}
 			return 0;
 		}
 		/* Digital inputs/outputs don't have VM leds */

commit 14d8754e342dbd05ee775ef31488e9a8ae797d4c
Author: Shaun Ruffell <sruffell at sruffell.net>
Date:   Thu Aug 9 09:56:21 2018 -0500

    Completely clear out conference buffers.
    
    This fixes an error and quiets the following warning pointed out by gcc 7.3.0:
    
      warning: ‘memset’ used with length equal to number of elements without
        multiplication by element size [-Wmemset-elt-size] memset(chan->conflast, 0,
        DAHDI_MAX_CHUNKSIZE);
    
    Previously only the first half of the conference buffers were cleared out.

diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index 618754d..c6f95f0 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -5709,9 +5709,9 @@ static int dahdi_ioctl_setconf(struct file *file, unsigned long data)
 	}
 	  /* if changing confs, clear last added info */
 	if (conf.confno != chan->confna) {
-		memset(chan->conflast, 0, DAHDI_MAX_CHUNKSIZE);
-		memset(chan->conflast1, 0, DAHDI_MAX_CHUNKSIZE);
-		memset(chan->conflast2, 0, DAHDI_MAX_CHUNKSIZE);
+		memset(chan->conflast, 0, sizeof(chan->conflast));
+		memset(chan->conflast1, 0, sizeof(chan->conflast1));
+		memset(chan->conflast2, 0, sizeof(chan->conflast2));
 	}
 	oldconf = chan->confna;  /* save old conference number */
 	chan->confna = conf.confno;   /* set conference number */

-----------------------------------------------------------------------


-- 
dahdi/linux.git



More information about the dahdi-commits mailing list