linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: vt6655: replace spin_lock_irqsave with spin_lock
@ 2022-09-14  8:00 Nam Cao
  2022-09-14 18:55 ` Philipp Hortmann
  2022-09-15  8:45 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Nam Cao @ 2022-09-14  8:00 UTC (permalink / raw)
  To: forest, gregkh; +Cc: namcaov, philipp.g.hortmann, linux-kernel, linux-staging

In vt6655 driver, there is a single interrupt handler: vnt_interrupt(),
and it does not take the spinlock. The interrupt handler only schedules
a workqueue, and the spinlock is taken in this workqueue. Thus, there is
no need to use spin_lock_irqsave, as the spinlock is never taken by an
interrupt. Replace spin_lock_irqsave (and spin_unlock_irqsave) with
spin_lock (and spin_unlock).

Signed-off-by: Nam Cao <namcaov@gmail.com>
---
 drivers/staging/vt6655/card.c        |  5 ++--
 drivers/staging/vt6655/channel.c     |  6 ++---
 drivers/staging/vt6655/device_main.c | 38 +++++++++++-----------------
 3 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index c680925b9c92..3d2873874886 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -540,9 +540,8 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type)
 {
 	union vnt_phy_field_swap phy;
 	unsigned char byTxRate, byRsvTime;      /* For OFDM */
-	unsigned long flags;
 
-	spin_lock_irqsave(&priv->lock, flags);
+	spin_lock(&priv->lock);
 
 	/* Set to Page1 */
 	VT6655_MAC_SELECT_PAGE1(priv->port_offset);
@@ -645,7 +644,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type)
 	/* Set to Page0 */
 	VT6655_MAC_SELECT_PAGE0(priv->port_offset);
 
-	spin_unlock_irqrestore(&priv->lock, flags);
+	spin_unlock(&priv->lock);
 }
 
 void CARDvUpdateBasicTopRate(struct vnt_private *priv)
diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c
index 4122875ebcaa..160ed640875d 100644
--- a/drivers/staging/vt6655/channel.c
+++ b/drivers/staging/vt6655/channel.c
@@ -111,9 +111,7 @@ bool set_channel(struct vnt_private *priv, struct ieee80211_channel *ch)
 	bb_software_reset(priv);
 
 	if (priv->local_id > REV_ID_VT3253_B1) {
-		unsigned long flags;
-
-		spin_lock_irqsave(&priv->lock, flags);
+		spin_lock(&priv->lock);
 
 		/* set HW default power register */
 		VT6655_MAC_SELECT_PAGE1(priv->port_offset);
@@ -123,7 +121,7 @@ bool set_channel(struct vnt_private *priv, struct ieee80211_channel *ch)
 		iowrite8(priv->byCurPwr, priv->port_offset + MAC_REG_PWROFDM);
 		VT6655_MAC_SELECT_PAGE0(priv->port_offset);
 
-		spin_unlock_irqrestore(&priv->lock, flags);
+		spin_unlock(&priv->lock);
 	}
 
 	if (priv->byBBType == BB_TYPE_11B)
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 04d737012cef..ea9560996eda 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -260,7 +260,6 @@ static void vt6655_mac_dis_barker_preamble_md(void __iomem *iobase)
 
 static void device_init_registers(struct vnt_private *priv)
 {
-	unsigned long flags;
 	unsigned int ii;
 	unsigned char byValue;
 	unsigned char byCCKPwrdBm = 0;
@@ -289,11 +288,11 @@ static void device_init_registers(struct vnt_private *priv)
 	/* Get Local ID */
 	priv->local_id = ioread8(priv->port_offset + MAC_REG_LOCALID);
 
-	spin_lock_irqsave(&priv->lock, flags);
+	spin_lock(&priv->lock);
 
 	SROMvReadAllContents(priv->port_offset, priv->abyEEPROM);
 
-	spin_unlock_irqrestore(&priv->lock, flags);
+	spin_unlock(&priv->lock);
 
 	/* Get Channel range */
 	priv->byMinChannel = 1;
@@ -1093,7 +1092,6 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 	int             max_count = 0;
 	u32 mib_counter;
 	u32 isr;
-	unsigned long flags;
 
 	isr = ioread32(priv->port_offset + MAC_REG_ISR);
 
@@ -1105,7 +1103,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 		return;
 	}
 
-	spin_lock_irqsave(&priv->lock, flags);
+	spin_lock(&priv->lock);
 
 	/* Read low level stats */
 	mib_counter = ioread32(priv->port_offset + MAC_REG_MIBCNTR);
@@ -1190,7 +1188,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 			break;
 	}
 
-	spin_unlock_irqrestore(&priv->lock, flags);
+	spin_unlock(&priv->lock);
 }
 
 static void vnt_interrupt_work(struct work_struct *work)
@@ -1220,9 +1218,8 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 	struct vnt_tx_desc *head_td;
 	u32 dma_idx;
-	unsigned long flags;
 
-	spin_lock_irqsave(&priv->lock, flags);
+	spin_lock(&priv->lock);
 
 	if (ieee80211_is_data(hdr->frame_control))
 		dma_idx = TYPE_AC0DMA;
@@ -1230,7 +1227,7 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 		dma_idx = TYPE_TXDMA0;
 
 	if (AVAIL_TD(priv, dma_idx) < 1) {
-		spin_unlock_irqrestore(&priv->lock, flags);
+		spin_unlock(&priv->lock);
 		ieee80211_stop_queues(priv->hw);
 		return -ENOMEM;
 	}
@@ -1246,11 +1243,11 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 
 	priv->apCurrTD[dma_idx] = head_td->next;
 
-	spin_unlock_irqrestore(&priv->lock, flags);
+	spin_unlock(&priv->lock);
 
 	vnt_generate_fifo_header(priv, dma_idx, head_td, skb);
 
-	spin_lock_irqsave(&priv->lock, flags);
+	spin_lock(&priv->lock);
 
 	priv->bPWBitOn = false;
 
@@ -1272,7 +1269,7 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 
 	priv->iTDUsed[dma_idx]++;
 
-	spin_unlock_irqrestore(&priv->lock, flags);
+	spin_unlock(&priv->lock);
 
 	return 0;
 }
@@ -1468,13 +1465,11 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw,
 	priv->current_aid = vif->cfg.aid;
 
 	if (changed & BSS_CHANGED_BSSID && conf->bssid) {
-		unsigned long flags;
-
-		spin_lock_irqsave(&priv->lock, flags);
+		spin_lock(&priv->lock);
 
 		vt6655_mac_write_bssid_addr(priv->port_offset, conf->bssid);
 
-		spin_unlock_irqrestore(&priv->lock, flags);
+		spin_unlock(&priv->lock);
 	}
 
 	if (changed & BSS_CHANGED_BASIC_RATES) {
@@ -1581,9 +1576,7 @@ static void vnt_configure(struct ieee80211_hw *hw,
 
 	if (changed_flags & FIF_ALLMULTI) {
 		if (*total_flags & FIF_ALLMULTI) {
-			unsigned long flags;
-
-			spin_lock_irqsave(&priv->lock, flags);
+			spin_lock(&priv->lock);
 
 			if (priv->mc_list_count > 2) {
 				VT6655_MAC_SELECT_PAGE1(priv->port_offset);
@@ -1603,7 +1596,7 @@ static void vnt_configure(struct ieee80211_hw *hw,
 				VT6655_MAC_SELECT_PAGE0(priv->port_offset);
 			}
 
-			spin_unlock_irqrestore(&priv->lock, flags);
+			spin_unlock(&priv->lock);
 
 			rx_mode |= RCR_MULTICAST | RCR_BROADCAST;
 		} else {
@@ -1830,13 +1823,12 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
 static int __maybe_unused vt6655_suspend(struct device *dev_d)
 {
 	struct vnt_private *priv = dev_get_drvdata(dev_d);
-	unsigned long flags;
 
-	spin_lock_irqsave(&priv->lock, flags);
+	spin_lock(&priv->lock);
 
 	MACbShutdown(priv);
 
-	spin_unlock_irqrestore(&priv->lock, flags);
+	spin_unlock(&priv->lock);
 
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-15 17:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  8:00 [PATCH] staging: vt6655: replace spin_lock_irqsave with spin_lock Nam Cao
2022-09-14 18:55 ` Philipp Hortmann
2022-09-15 17:10   ` Nam Cao
2022-09-15  8:45 ` Greg KH
2022-09-15 17:14   ` Nam Cao

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).