Skip to contentSkip to conversation

b43: rfkill: use HI enabled bit for all devices

RFC PATCH New Rafał Miłecki 2 participants 5 messages Nov 17, 2010 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 b43: rfkill: use HI enabled bit for all devices

Devices which use LO enabled bit are covered by b43legacy

---
Is this alright to use inline for this? Is my WARN_ON OK?

---
 drivers/net/wireless/b43/main.c   |    2 ++
 drivers/net/wireless/b43/rfkill.c |   21 +++------------------
 drivers/net/wireless/b43/rfkill.h |    4 ++--
 3 files changed, 7 insertions(+), 20 deletions(-)
drivers/net/wireless/b43/main.c +2 -0
index fa48803..9b71bb1 100644
@@ -4527,6 +4527,8 @@ static int b43_op_start(struct ieee80211_hw *hw)
 		}
 	}
 
+	/* we don't expect older devices which need other RFKILL check */
+	B43_WARN_ON(dev->dev->id.revision < 3);
 	/* XXX: only do if device doesn't support rfkill irq */
 	wiphy_rfkill_start_polling(hw->wiphy);
 
drivers/net/wireless/b43/rfkill.c +3 -18
index 78016ae..012ed2f 100644
@@ -26,25 +26,10 @@
 
 
 /* Returns TRUE, if the radio is enabled in hardware. */
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
 {
-	if (dev->phy.rev >= 3 || dev->phy.type == B43_PHYTYPE_LP) {
-		if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
-		      & B43_MMIO_RADIO_HWENABLED_HI_MASK))
-			return 1;
-	} else {
-		/* To prevent CPU fault on PPC, do not read a register
-		 * unless the interface is started; however, on resume
-		 * for hibernation, this routine is entered early. When
-		 * that happens, unconditionally return TRUE.
-		 */
-		if (b43_status(dev) < B43_STAT_STARTED)
-			return 1;
-		if (b43_read16(dev, B43_MMIO_RADIO_HWENABLED_LO)
-		    & B43_MMIO_RADIO_HWENABLED_LO_MASK)
-			return 1;
-	}
-	return 0;
+	return !(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
+		& B43_MMIO_RADIO_HWENABLED_HI_MASK);
 }
 
 /* The poll callback for the hardware button. */
drivers/net/wireless/b43/rfkill.h +2 -2
index f046c3c..7aa8a5a 100644
@@ -4,8 +4,8 @@
 struct ieee80211_hw;
 struct b43_wldev;
 
-void b43_rfkill_poll(struct ieee80211_hw *hw);
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev);
 
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev);
+void b43_rfkill_poll(struct ieee80211_hw *hw);
 
 #endif /* B43_RFKILL_H_ */
Signature · 1 line
1.6.0.4
#1 lore raw

RFC PATCH 1/1 b43: rfkill: use HI enabled bit for all devices

Quoted 16 lines · Rafa? Mi?ecki

Devices which use LO enabled bit are covered by b43legacy

---
Is this alright to use inline for this? Is my WARN_ON OK?

---
 drivers/net/wireless/b43/main.c   |    2 ++
 drivers/net/wireless/b43/rfkill.c |   21 +++------------------
 drivers/net/wireless/b43/rfkill.h |    4 ++--
 3 files changed, 7 insertions(+), 20 deletions(-)
drivers/net/wireless/b43/main.c +0 -0
index fa48803..9b71bb1 100644

drivers/net/wireless/b43/main.c static int b43_op_start(struct ieee80211_hw *hw) · line 4531

Quoted 5 lines
drivers/net/wireless/b43/main.c +2 -0
@@ -4527,6 +4527,8 @@ static int b43_op_start(struct ieee80211_hw *hw)
 		}
 	}
 
+	/* we don't expect older devices which need other RFKILL check */
+	B43_WARN_ON(dev->dev->id.revision < 3);

Do we really need that check? The driver is full of assumptions that the core revision is >=5.
I also think this assertion is misplaced in the interface start handler. If you want it, do it in the rfkill check function. (for nondebug build it's a no-op)

drivers/net/wireless/b43/rfkill.c line 29

Quoted 13 lines
drivers/net/wireless/b43/main.c +0 -0
 	/* XXX: only do if device doesn't support rfkill irq */
 	wiphy_rfkill_start_polling(hw->wiphy);
 
drivers/net/wireless/b43/rfkill.c +1 -1
index 78016ae..012ed2f 100644
@@ -26,25 +26,10 @@
 
 
 /* Returns TRUE, if the radio is enabled in hardware. */
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev)

inline doesn't make sense here.

Quoted 11 lines
drivers/net/wireless/b43/rfkill.c +0 -10
 {
-	if (dev->phy.rev >= 3 || dev->phy.type == B43_PHYTYPE_LP) {
-		if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
-		      & B43_MMIO_RADIO_HWENABLED_HI_MASK))
-			return 1;
-	} else {
-		/* To prevent CPU fault on PPC, do not read a register
-		 * unless the interface is started; however, on resume
-		 * for hibernation, this routine is entered early. When
-		 * that happens, unconditionally return TRUE.
-		 */

drivers/net/wireless/b43/rfkill.c line 33

Quoted 10 lines
drivers/net/wireless/b43/rfkill.c +2 -7
-		if (b43_status(dev) < B43_STAT_STARTED)
-			return 1;
-		if (b43_read16(dev, B43_MMIO_RADIO_HWENABLED_LO)
-		    & B43_MMIO_RADIO_HWENABLED_LO_MASK)
-			return 1;
-	}
-	return 0;
+	return !(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
+		& B43_MMIO_RADIO_HWENABLED_HI_MASK);
 }

Getting rid of that old crap is a good idea. So ACK on this part.

Quoted 6 lines
drivers/net/wireless/b43/rfkill.c +0 -0
 /* The poll callback for the hardware button. */
drivers/net/wireless/b43/rfkill.h +0 -0
index f046c3c..7aa8a5a 100644

drivers/net/wireless/b43/rfkill.h line 11

Quoted 10 lines
drivers/net/wireless/b43/rfkill.h +2 -2
@@ -4,8 +4,8 @@
 struct ieee80211_hw;
 struct b43_wldev;
 
-void b43_rfkill_poll(struct ieee80211_hw *hw);
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev);
 
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev);
+void b43_rfkill_poll(struct ieee80211_hw *hw);
 
 #endif /* B43_RFKILL_H_ */

doesn't make sense.

Signature · 1 line
Greetings Michael.
#2 lore raw

RFC PATCH 1/1 b43: rfkill: use HI enabled bit for all devices

W dniu 17 listopada 2010 21:17 u?ytkownik Michael B?sch <[email protected]> napisa?:

Quoted 20 lines · Rafa? Mi?ecki
Quoted 19 lines

Devices which use LO enabled bit are covered by b43legacy

---
Is this alright to use inline for this? Is my WARN_ON OK?
---

?drivers/net/wireless/b43/main.c ? | ? ?2 ++
?drivers/net/wireless/b43/rfkill.c | ? 21 +++------------------
?drivers/net/wireless/b43/rfkill.h | ? ?4 ++--

?3 files changed, 7 insertions(+), 20 deletions(-)

drivers/net/wireless/b43/main.c +0 -0
index fa48803..9b71bb1 100644
@@ -4527,6 +4527,8 @@ static int b43_op_start(struct ieee80211_hw *hw)
 ? ? ? ? ? ? ? }
 ? ? ? }
 
Quoted 5 lines

drivers/net/wireless/b43/main.c static int b43_op_start(struct ieee80211_hw *hw) · line 4531

Quoted 2 lines
drivers/net/wireless/b43/main.c +2 -0
+ ? ? /* we don't expect older devices which need other RFKILL check */
+ ? ? B43_WARN_ON(dev->dev->id.revision < 3);

Do we really need that check? The driver is full of assumptions that the core revision is >=5.

Thanks for info, wasn't aware of that.

Quoted 14 lines

I also think this assertion is misplaced in the interface start handler. If you want it, do it in the rfkill check function. (for nondebug build it's a no-op)

Quoted 10 lines

? ? ? /* XXX: only do if device doesn't support rfkill irq */ ? ? ? wiphy_rfkill_start_polling(hw->wiphy);

drivers/net/wireless/b43/rfkill.c +0 -0
index 78016ae..012ed2f 100644
@@ -26,25 +26,10 @@
 
 
Quoted 5 lines

drivers/net/wireless/b43/rfkill.c line 29

Quoted 3 lines

?/* Returns TRUE, if the radio is enabled in hardware. */

drivers/net/wireless/b43/rfkill.c +1 -1
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev)

inline doesn't make sense here.

Err, tip for compiler for optimization? To avoid some JUMPs in generated ASM?

Quoted 36 lines
Quoted 13 lines

{
- ? ? if (dev->phy.rev >= 3 || dev->phy.type == B43_PHYTYPE_LP) {
- ? ? ? ? ? ? if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
- ? ? ? ? ? ? ? ? ? & B43_MMIO_RADIO_HWENABLED_HI_MASK))
- ? ? ? ? ? ? ? ? ? ? return 1;
- ? ? } else {
- ? ? ? ? ? ? /* To prevent CPU fault on PPC, do not read a register
- ? ? ? ? ? ? ?* unless the interface is started; however, on resume
- ? ? ? ? ? ? ?* for hibernation, this routine is entered early. When
- ? ? ? ? ? ? ?* that happens, unconditionally return TRUE.
- ? ? ? ? ? ? ?*/
- ? ? ? ? ? ? if (b43_status(dev) < B43_STAT_STARTED)
- ? ? ? ? ? ? ? ? ? ? return 1;

Quoted 8 lines

- ? ? ? ? ? ? if (b43_read16(dev, B43_MMIO_RADIO_HWENABLED_LO)
- ? ? ? ? ? ? ? ? & B43_MMIO_RADIO_HWENABLED_LO_MASK)
- ? ? ? ? ? ? ? ? ? ? return 1;
- ? ? }
- ? ? return 0;
+ ? ? return !(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
+ ? ? ? ? ? ? & B43_MMIO_RADIO_HWENABLED_HI_MASK); ?}

Getting rid of that old crap is a good idea. So ACK on this part.

Quoted 12 lines

/* The poll callback for the hardware button. */

drivers/net/wireless/b43/rfkill.h +1 -1
index f046c3c..7aa8a5a 100644
@@ -4,8 +4,8 @@
 ?struct ieee80211_hw;
 ?struct b43_wldev;
 
-void b43_rfkill_poll(struct ieee80211_hw *hw);
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev);
 
Quoted 6 lines
Quoted 4 lines
drivers/net/wireless/b43/rfkill.h +1 -1
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev);
+void b43_rfkill_poll(struct ieee80211_hw *hw);
 

?#endif /* B43_RFKILL_H_ */

doesn't make sense.

"inline" was added to match rfkill.c change. Order was changed to match rfkill.c order, but I guess we can live without that.

Signature · 1 line
Rafa?
#3 lore raw

RFC PATCH 1/1 b43: rfkill: use HI enabled bit for all devices

Quoted 7 lines · Rafa? Mi?ecki
Quoted 5 lines

drivers/net/wireless/b43/rfkill.c line 29

Quoted 3 lines

/* Returns TRUE, if the radio is enabled in hardware. */

drivers/net/wireless/b43/rfkill.c +1 -1
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev)

inline doesn't make sense here.

Err, tip for compiler for optimization? To avoid some JUMPs in generated ASM?

Inline doesn't really work that way. In this case it might generate an inline version for callers inside of rfkill.c and an always-out-of-line version for other callers.
If you really want it inline (Which I think isn't really necessary as this isn't a fastpath), you'll need to make it static inline and put it into rfkill.h

Signature · 1 line
Greetings Michael.
#4 lore raw

RFC PATCH 1/1 b43: rfkill: use HI enabled bit for all devices

W dniu 17 listopada 2010 21:29 u?ytkownik Michael B?sch <[email protected]> napisa?:

Quoted 7 lines · Rafa? Mi?ecki
Quoted 6 lines
Quoted 5 lines

drivers/net/wireless/b43/rfkill.c line 29

Quoted 3 lines

?/* Returns TRUE, if the radio is enabled in hardware. */

drivers/net/wireless/b43/rfkill.c +1 -1
-bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
+inline bool b43_is_hw_radio_enabled(struct b43_wldev *dev)

inline doesn't make sense here.

Quoted 8 lines
Quoted 1 line

Err, tip for compiler for optimization? To avoid some JUMPs in generated ASM?

Inline doesn't really work that way. In this case it might generate an inline version for callers inside of rfkill.c and an always-out-of-line version for other callers.
If you really want it inline (Which I think isn't really necessary as this isn't a fastpath), you'll need to make it static inline and put it into rfkill.h

Huh, I got no idea inline works differently for local calls and calls from other files. That's tricky.

Thanks, I'll send V2.

Signature · 1 line
Rafa?