Skip to contentSkip to conversation

Fix -Wcast-function-type net drivers

PATCH In review Phong Tran 3 participants 10 messages Nov 24, 2019 – Nov 25, 2019

Subsystems (10)
lore
Share & tools
lore

Phong Tran

author
#0 lore raw

cover Fix -Wcast-function-type net drivers

This series is for fixing the compiler warning while enable -Wcast-function-type.

Almost is incompatible callback prototype in using tasklet. The void (*func)(unsigned long) instead of void (*func)(struct foo*).

Reported by: https://github.com/KSPP/linux/issues/20

Phong Tran (5):
drivers: net: hso: Fix -Wcast-function-type
drivers: net: usbnet: Fix -Wcast-function-type
drivers: net: b43legacy: Fix -Wcast-function-type
drivers: net: intel: Fix -Wcast-function-type
drivers: net: realtek: Fix -Wcast-function-type

 drivers/net/usb/hso.c                          |  5 +++--
 drivers/net/usb/usbnet.c                       |  8 +++++++-
 drivers/net/wireless/broadcom/b43legacy/main.c |  5 +++--
 drivers/net/wireless/intel/ipw2x00/ipw2100.c   |  7 ++++---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c   |  5 +++--
 drivers/net/wireless/intel/iwlegacy/3945-mac.c |  5 +++--
 drivers/net/wireless/intel/iwlegacy/4965-mac.c |  5 +++--
 drivers/net/wireless/realtek/rtlwifi/pci.c     | 10 ++++++----
 8 files changed, 32 insertions(+), 18 deletions(-)
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 1/5 drivers: net: hso: Fix -Wcast-function-type

correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20

---
 drivers/net/usb/hso.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/usb/hso.c +3 -2
index 74849da031fa..ca827802f291 100644
@@ -1214,8 +1214,9 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
  * This needs to be a tasklet otherwise we will
  * end up recursively calling this function.
  */
-static void hso_unthrottle_tasklet(struct hso_serial *serial)
+static void hso_unthrottle_tasklet(unsigned long data)
 {
+	struct hso_serial *serial = (struct hso_serial *)data;
 	unsigned long flags;
 
 	spin_lock_irqsave(&serial->serial_lock, flags);
@@ -1265,7 +1266,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
 		/* Force default termio settings */
 		_hso_serial_set_termios(tty, NULL);
 		tasklet_init(&serial->unthrottle_tasklet,
-			     (void (*)(unsigned long))hso_unthrottle_tasklet,
+			     hso_unthrottle_tasklet,
 			     (unsigned long)serial);
 		result = hso_start_serial_device(serial->parent, GFP_KERNEL);
 		if (result) {
Signature · 1 line
2.20.1
author
#2 lore raw

PATCH 2/5 drivers: net: usbnet: Fix -Wcast-function-type

In reply to Phong Tran

correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20

---
 drivers/net/usb/usbnet.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/usb/usbnet.c +7 -1
index dde05e2fdc3e..d10a5e6d0917 100644
@@ -1573,6 +1573,12 @@ static void usbnet_bh (struct timer_list *t)
 	}
 }
 
+static void usbnet_bh_tasklet (unsigned long data)
+{
+	struct timer_list *t = (struct timer_list *)data;
+	usbnet_bh(t);
+}
+
 
 /*-------------------------------------------------------------------------
  *
@@ -1700,7 +1706,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	skb_queue_head_init (&dev->txq);
 	skb_queue_head_init (&dev->done);
 	skb_queue_head_init(&dev->rxq_pause);
-	dev->bh.func = (void (*)(unsigned long))usbnet_bh;
+	dev->bh.func = usbnet_bh_tasklet;
 	dev->bh.data = (unsigned long)&dev->delay;
 	INIT_WORK (&dev->kevent, usbnet_deferred_kevent);
 	init_usb_anchor(&dev->deferred);
Signature · 1 line
2.20.1
author
#3 lore raw

PATCH 3/5 drivers: net: b43legacy: Fix -Wcast-function-type

In reply to Phong Tran

correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20

---
 drivers/net/wireless/broadcom/b43legacy/main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/b43legacy/main.c +3 -2
index 4325e91736eb..8b6b657c4b85 100644
@@ -1275,8 +1275,9 @@ static void handle_irq_ucode_debug(struct b43legacy_wldev *dev)
 }
 
 /* Interrupt handler bottom-half */
-static void b43legacy_interrupt_tasklet(struct b43legacy_wldev *dev)
+static void b43legacy_interrupt_tasklet(unsigned long data)
 {
+	struct b43legacy_wldev *dev = (struct b43legacy_wldev *)data;
 	u32 reason;
 	u32 dma_reason[ARRAY_SIZE(dev->dma_reason)];
 	u32 merged_dma_reason = 0;
@@ -3741,7 +3742,7 @@ static int b43legacy_one_core_attach(struct ssb_device *dev,
 	b43legacy_set_status(wldev, B43legacy_STAT_UNINIT);
 	wldev->bad_frames_preempt = modparam_bad_frames_preempt;
 	tasklet_init(&wldev->isr_tasklet,
-		     (void (*)(unsigned long))b43legacy_interrupt_tasklet,
+		     b43legacy_interrupt_tasklet,
 		     (unsigned long)wldev);
 	if (modparam_pio)
 		wldev->__using_pio = true;
Signature · 1 line
2.20.1
Tested-by on v1 3/5
#4 lore raw

Re: [PATCH 3/5] drivers: net: b43legacy: Fix -Wcast-function-type

Quoted 7 lines · Phong Tran

correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20

---
  drivers/net/wireless/broadcom/b43legacy/main.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

The subject should be "b43legacy: .....". Otherwise it is OK.

Larry

Quoted 26 lines
drivers/net/wireless/broadcom/b43legacy/main.c +3 -2
index 4325e91736eb..8b6b657c4b85 100644
@@ -1275,8 +1275,9 @@ static void handle_irq_ucode_debug(struct b43legacy_wldev *dev)
  }
 
  /* Interrupt handler bottom-half */
-static void b43legacy_interrupt_tasklet(struct b43legacy_wldev *dev)
+static void b43legacy_interrupt_tasklet(unsigned long data)
  {
+	struct b43legacy_wldev *dev = (struct b43legacy_wldev *)data;
  	u32 reason;
  	u32 dma_reason[ARRAY_SIZE(dev->dma_reason)];
  	u32 merged_dma_reason = 0;
@@ -3741,7 +3742,7 @@ static int b43legacy_one_core_attach(struct ssb_device *dev,
  	b43legacy_set_status(wldev, B43legacy_STAT_UNINIT);
  	wldev->bad_frames_preempt = modparam_bad_frames_preempt;
  	tasklet_init(&wldev->isr_tasklet,
-		     (void (*)(unsigned long))b43legacy_interrupt_tasklet,
+		     b43legacy_interrupt_tasklet,
  		     (unsigned long)wldev);
  	if (modparam_pio)
  		wldev->__using_pio = true;
author
#5 lore raw

PATCH 4/5 drivers: net: intel: Fix -Wcast-function-type

In reply to Phong Tran

correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20

---
 drivers/net/wireless/intel/ipw2x00/ipw2100.c   | 7 ++++---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c   | 5 +++--
 drivers/net/wireless/intel/iwlegacy/3945-mac.c | 5 +++--
 drivers/net/wireless/intel/iwlegacy/4965-mac.c | 5 +++--
 4 files changed, 13 insertions(+), 9 deletions(-)
drivers/net/wireless/intel/ipw2x00/ipw2100.c +4 -3
index 8dfbaff2d1fe..a162146a43a7 100644
@@ -3206,8 +3206,9 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
 	}
 }
 
-static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
+static void ipw2100_irq_tasklet(unsigned long data)
 {
+	struct ipw2100_priv *priv = (struct ipw2100_priv *)data;
 	struct net_device *dev = priv->net_dev;
 	unsigned long flags;
 	u32 inta, tmp;
@@ -6007,7 +6008,7 @@ static void ipw2100_rf_kill(struct work_struct *work)
 	spin_unlock_irqrestore(&priv->low_lock, flags);
 }
 
-static void ipw2100_irq_tasklet(struct ipw2100_priv *priv);
+static void ipw2100_irq_tasklet(unsigned long data);
 
 static const struct net_device_ops ipw2100_netdev_ops = {
 	.ndo_open		= ipw2100_open,
@@ -6137,7 +6138,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
 	INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill);
 	INIT_DELAYED_WORK(&priv->scan_event, ipw2100_scan_event);
 
-	tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
+	tasklet_init(&priv->irq_tasklet,
 		     ipw2100_irq_tasklet, (unsigned long)priv);
 
 	/* NOTE:  We do not start the deferred work for status checks yet */
drivers/net/wireless/intel/ipw2x00/ipw2200.c +3 -2
index ed0f06532d5e..ac5f797fb1ad 100644
@@ -1945,8 +1945,9 @@ static void notify_wx_assoc_event(struct ipw_priv *priv)
 	wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
 }
 
-static void ipw_irq_tasklet(struct ipw_priv *priv)
+static void ipw_irq_tasklet(unsigned long data)
 {
+	struct ipw_priv *priv = (struct ipw_priv *)data;
 	u32 inta, inta_mask, handled = 0;
 	unsigned long flags;
 	int rc = 0;
@@ -10680,7 +10681,7 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
 	INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate);
 #endif				/* CONFIG_IPW2200_QOS */
 
-	tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
+	tasklet_init(&priv->irq_tasklet,
 		     ipw_irq_tasklet, (unsigned long)priv);
 
 	return ret;
drivers/net/wireless/intel/iwlegacy/3945-mac.c +3 -2
index 4fbcc7fba3cc..e2e9c3e8fff5 100644
@@ -1376,8 +1376,9 @@ il3945_dump_nic_error_log(struct il_priv *il)
 }
 
 static void
-il3945_irq_tasklet(struct il_priv *il)
+il3945_irq_tasklet(unsigned long data)
 {
+	struct il_priv *il = (struct il_priv *)data;
 	u32 inta, handled = 0;
 	u32 inta_fh;
 	unsigned long flags;
@@ -3403,7 +3404,7 @@ il3945_setup_deferred_work(struct il_priv *il)
 	timer_setup(&il->watchdog, il_bg_watchdog, 0);
 
 	tasklet_init(&il->irq_tasklet,
-		     (void (*)(unsigned long))il3945_irq_tasklet,
+		     il3945_irq_tasklet,
 		     (unsigned long)il);
 }
 
drivers/net/wireless/intel/iwlegacy/4965-mac.c +3 -2
index ffb705b18fb1..5fe17039a337 100644
@@ -4344,8 +4344,9 @@ il4965_synchronize_irq(struct il_priv *il)
 }
 
 static void
-il4965_irq_tasklet(struct il_priv *il)
+il4965_irq_tasklet(unsigned long data)
 {
+	struct il_priv *il = (struct il_priv *)data;
 	u32 inta, handled = 0;
 	u32 inta_fh;
 	unsigned long flags;
@@ -6238,7 +6239,7 @@ il4965_setup_deferred_work(struct il_priv *il)
 	timer_setup(&il->watchdog, il_bg_watchdog, 0);
 
 	tasklet_init(&il->irq_tasklet,
-		     (void (*)(unsigned long))il4965_irq_tasklet,
+		     il4965_irq_tasklet,
 		     (unsigned long)il);
 }
 
Signature · 1 line
2.20.1
author
#6 lore raw

PATCH 5/5 drivers: net: realtek: Fix -Wcast-function-type

In reply to Phong Tran

correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20

---
 drivers/net/wireless/realtek/rtlwifi/pci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +6 -4
index f88d26535978..25335bd2873b 100644
@@ -1061,13 +1061,15 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
 	return ret;
 }
 
-static void _rtl_pci_irq_tasklet(struct ieee80211_hw *hw)
+static void _rtl_pci_irq_tasklet(unsigned long data)
 {
+	struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
 	_rtl_pci_tx_chk_waitq(hw);
 }
 
-static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
+static void _rtl_pci_prepare_bcn_tasklet(unsigned long data)
 {
+	struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -1193,10 +1195,10 @@ static void _rtl_pci_init_struct(struct ieee80211_hw *hw,
 
 	/*task */
 	tasklet_init(&rtlpriv->works.irq_tasklet,
-		     (void (*)(unsigned long))_rtl_pci_irq_tasklet,
+		     _rtl_pci_irq_tasklet,
 		     (unsigned long)hw);
 	tasklet_init(&rtlpriv->works.irq_prepare_bcn_tasklet,
-		     (void (*)(unsigned long))_rtl_pci_prepare_bcn_tasklet,
+		     _rtl_pci_prepare_bcn_tasklet,
 		     (unsigned long)hw);
 	INIT_WORK(&rtlpriv->works.lps_change_work,
 		  rtl_lps_change_work_callback);
Signature · 1 line
2.20.1
#7 lore raw
In reply to Phong Tran
Quoted 7 lines · Phong Tran

This series is for fixing the compiler warning while enable -Wcast-function-type.

Almost is incompatible callback prototype in using tasklet. The void (*func)(unsigned long) instead of void (*func)(struct foo*).

Reported by: https://github.com/KSPP/linux/issues/20

Hi Tran, thanks for the patches. Could you split the series into two - the wireless changes and the USB changes?

Those usually go via slightly different trees.

author
#8 lore raw
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · Phong Tran

This series is for fixing the compiler warning while enable -Wcast-function-type.

Almost is incompatible callback prototype in using tasklet. The void (*func)(unsigned long) instead of void (*func)(struct foo*).

Quoted 7 lines
Quoted 1 line

Reported by: https://github.com/KSPP/linux/issues/20

Hi Tran, thanks for the patches. Could you split the series into two - the wireless changes and the USB changes?

Those usually go via slightly different trees.

Sent in different series:

[wireless]
https://lore.kernel.org/lkml/[email protected]/

[USB]
https://lore.kernel.org/linux-usb/[email protected]/

Regards,
Phong.