2012-11-12 21:58:48

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 00/17] RTL8187SE driver cleanups

There are some bug fixes, cleanups and dead code removal for
drivers/staging/rtl8187se
----------------------------------------------------------------
Maxim Mikityanskiy (17):
Removed dead functions
Removed legacy rtl8225_rf_set_chan()
Removed empty functions and one-iteration loop
Fixed bugs in interrupt handler
Simplified function GetSupportedWirelessMode8185()
Fix oops when rmmoding
Removed unused module parameters and fixed module description
Removed dead code
Removed unused parameters of HwHSSIThreeWire()
Fixed typo in TransmitConfig
Removed non-existent function headers from r8180.h
Removed unused arrays in r8180_rtl8225z2.c
Use ARRAY_SIZE instead of in-code constants
Removed unneeded reads from EEPROM
Removed unused fields in r8180_priv
Fixed size of BEACON_INTERVAL register
Removed empty stub read_acadapter_file()

r8180.h | 28 ------
r8180_core.c | 436 ++++---------------------------------------------------------------------------------
r8180_rtl8225.h | 2 +-
r8180_rtl8225z2.c | 229 +++------------------------------------------
r8185b_init.c | 223 ++++++++++++-------------------------------
5 files changed, 91 insertions(+), 827 deletions(-)


2012-11-12 23:06:37

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 00/17] RTL8187SE driver cleanups

On Mon, Nov 12, 2012 at 04:37:31PM -0600, Larry Finger wrote:
> On 11/12/2012 03:58 PM, Maxim Mikityanskiy wrote:
> >There are some bug fixes, cleanups and dead code removal for
> >drivers/staging/rtl8187se
>
> There is a serious problems with your patches. The text in
> Documentation/SubmittingPatches says:
>
> "All changes to the Linux kernel occur in the form of patches, as
> generated by diff(1). When creating your patch, make sure to create it
> in "unified diff" format, as supplied by the '-u' argument to diff(1).
> Also, please use the '-p' argument which shows which C function each
> change is in - that makes the resultant diff a lot easier to read.
> Patches should be based in the root kernel source directory,
> not in any lower subdirectory."
>
> You satisfied the requirements for -u and -p, but you based then on
> the wrong directory. I can use sed to rewrite this version for
> testing, but please use the correct base in future versions.

Yeah, as-is, I can't take these, sorry. At the least, fix up the
Subject: and the diff level and please resend.

thanks,

greg k-h

2012-11-12 21:59:01

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 07/17] Removed unused module parameters and fixed module description


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/r8180_core.c b/r8180_core.c
index e04bb04..203e546 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -61,28 +61,18 @@ static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = {
}
};

-
static char ifname[IFNAMSIZ] = "wlan%d";
-static int hwseqnum = 0;
static int hwwep = 0;
-static int channels = 0x3fff;

MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl);
MODULE_AUTHOR("Andrea Merello <[email protected]>");
-MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 / RTL8185 WiFi cards");
-
+MODULE_DESCRIPTION("Linux driver for Realtek RTL8187SE WiFi cards");

module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR);
-module_param(hwseqnum, int, S_IRUGO|S_IWUSR);
module_param(hwwep, int, S_IRUGO|S_IWUSR);
-module_param(channels, int, S_IRUGO|S_IWUSR);

-MODULE_PARM_DESC(devname, " Net interface name, wlan%d=default");
-MODULE_PARM_DESC(hwseqnum, " Try to use hardware 802.11 header sequence numbers. Zero=default");
MODULE_PARM_DESC(hwwep, " Try to use hardware WEP support. Still broken and not available on all cards");
-MODULE_PARM_DESC(channels, " Channel bitmask for specific locales. NYI");
-

static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
--
1.7.10.4


2012-11-12 21:59:09

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 12/17] Removed unused arrays in r8180_rtl8225z2.c


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_rtl8225z2.c | 33 ---------------------------------
1 file changed, 33 deletions(-)

diff --git a/r8180_rtl8225z2.c b/r8180_rtl8225z2.c
index 315eece..eba9786 100644
--- a/r8180_rtl8225z2.c
+++ b/r8180_rtl8225z2.c
@@ -15,7 +15,6 @@

#include "ieee80211/dot11d.h"

-
static void write_rtl8225(struct net_device *dev, u8 adr, u16 data)
{
int i;
@@ -76,22 +75,6 @@ static void write_rtl8225(struct net_device *dev, u8 adr, u16 data)
rtl8185_rf_pins_enable(dev);
}

-static const u16 rtl8225bcd_rxgain[] = {
- 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
- 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
- 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
- 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
- 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
- 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
- 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
- 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
- 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
- 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
- 0x07aa, 0x07ab, 0x07ac, 0x07ad, 0x07b0, 0x07b1, 0x07b2, 0x07b3,
- 0x07b4, 0x07b5, 0x07b8, 0x07b9, 0x07ba, 0x07bb, 0x07bb
-
-};
-
static const u8 rtl8225_agc[] = {
0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e,
0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96,
@@ -117,10 +100,6 @@ static const u32 rtl8225_chan[] = {
0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x074A,
};

-static const u8 rtl8225z2_threshold[] = {
- 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd,
-};
-
static const u8 rtl8225z2_gain_bg[] = {
0x23, 0x15, 0xa5, /* -82-1dBm */
0x23, 0x15, 0xb5, /* -82-2dBm */
@@ -157,18 +136,6 @@ static const u16 rtl8225z2_rxgain[] = {

};

-static const u8 rtl8225z2_tx_power_ofdm[] = {
- 0x42, 0x00, 0x40, 0x00, 0x40
-};
-
-static const u8 rtl8225z2_tx_power_cck_ch14[] = {
- 0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u8 rtl8225z2_tx_power_cck[] = {
- 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04
-};
-
void rtl8225z2_set_gain(struct net_device *dev, short gain)
{
const u8 *rtl8225_gain;
--
1.7.10.4


2012-11-12 21:59:04

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 09/17] Removed unused parameters of HwHSSIThreeWire()


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_rtl8225.h | 2 +-
r8185b_init.c | 122 ++++++++++++-------------------------------------------
2 files changed, 27 insertions(+), 97 deletions(-)

diff --git a/r8180_rtl8225.h b/r8180_rtl8225.h
index 494ea86..89a9c07 100644
--- a/r8180_rtl8225.h
+++ b/r8180_rtl8225.h
@@ -23,7 +23,7 @@ void rtl8225z2_rf_init(struct net_device *dev);
void rtl8225z2_rf_set_chan(struct net_device *dev, short ch);
void rtl8225z2_rf_close(struct net_device *dev);

-void RF_WriteReg(struct net_device *dev, u8 offset, u32 data);
+void RF_WriteReg(struct net_device *dev, u8 offset, u16 data);
u32 RF_ReadReg(struct net_device *dev, u8 offset);

void rtl8180_set_mode(struct net_device *dev, int mode);
diff --git a/r8185b_init.c b/r8185b_init.c
index 0b5c34b..52e6802 100644
--- a/r8185b_init.c
+++ b/r8185b_init.c
@@ -207,13 +207,10 @@ void SetOutputEnableOfRfPins(struct net_device *dev)
write_nic_word(dev, RFPinsEnable, 0x1bff);
}

-static int HwHSSIThreeWire(struct net_device *dev,
- u8 *pDataBuf,
- u8 nDataBufBitCnt,
- int bSI,
- int bWrite)
+static bool HwHSSIThreeWire(struct net_device *dev,
+ u8 *pDataBuf,
+ bool write)
{
- int bResult = 1;
u8 TryCnt;
u8 u1bTmp;

@@ -228,77 +225,29 @@ static int HwHSSIThreeWire(struct net_device *dev,
if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) {
printk(KERN_ERR "rtl8187se: HwThreeWire(): CmdReg:"
" %#X RE|WE bits are not clear!!\n", u1bTmp);
- dump_stack();
- return 0;
+ return false;
}

/* RTL8187S HSSI Read/Write Function */
u1bTmp = read_nic_byte(dev, RF_SW_CONFIG);
-
- if (bSI)
- u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */
-
- else
- u1bTmp &= ~RF_SW_CFG_SI; /* reg08[1]=0 Parallel Interface(PI) */
-
-
+ u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */
write_nic_byte(dev, RF_SW_CONFIG, u1bTmp);

- if (bSI) {
- /* jong: HW SI read must set reg84[3]=0. */
- u1bTmp = read_nic_byte(dev, RFPinsSelect);
- u1bTmp &= ~BIT3;
- write_nic_byte(dev, RFPinsSelect, u1bTmp);
- }
+ /* jong: HW SI read must set reg84[3]=0. */
+ u1bTmp = read_nic_byte(dev, RFPinsSelect);
+ u1bTmp &= ~BIT3;
+ write_nic_byte(dev, RFPinsSelect, u1bTmp);
/* Fill up data buffer for write operation. */

- if (bWrite) {
- if (nDataBufBitCnt == 16) {
- write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
- } else if (nDataBufBitCnt == 64) {
- /* RTL8187S shouldn't enter this case */
- write_nic_dword(dev, SW_3W_DB0, *((u32 *)pDataBuf));
- write_nic_dword(dev, SW_3W_DB1, *((u32 *)(pDataBuf + 4)));
- } else {
- int idx;
- int ByteCnt = nDataBufBitCnt / 8;
- /* printk("%d\n",nDataBufBitCnt); */
- if ((nDataBufBitCnt % 8) != 0) {
- printk(KERN_ERR "rtl8187se: "
- "HwThreeWire(): nDataBufBitCnt(%d)"
- " should be multiple of 8!!!\n",
- nDataBufBitCnt);
- dump_stack();
- nDataBufBitCnt += 8;
- nDataBufBitCnt &= ~7;
- }
-
- if (nDataBufBitCnt > 64) {
- printk(KERN_ERR "rtl8187se: HwThreeWire():"
- " nDataBufBitCnt(%d) should <= 64!!!\n",
- nDataBufBitCnt);
- dump_stack();
- nDataBufBitCnt = 64;
- }
-
- for (idx = 0; idx < ByteCnt; idx++)
- write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx));
-
- }
- } else { /* read */
- if (bSI) {
- /* SI - reg274[3:0] : RF register's Address */
- write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
- } else {
- /* PI - reg274[15:12] : RF register's Address */
- write_nic_word(dev, SW_3W_DB0, (*((u16 *)pDataBuf)) << 12);
- }
- }
+ /* SI - reg274[3:0] : RF register's Address */
+ if (write)
+ write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
+ else
+ write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));

/* Set up command: WE or RE. */
- if (bWrite)
+ if (write)
write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_WE);
-
else
write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_RE);

@@ -306,7 +255,7 @@ static int HwHSSIThreeWire(struct net_device *dev,
/* Check if DONE is set. */
for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
u1bTmp = read_nic_byte(dev, SW_3W_CMD1);
- if ((u1bTmp & SW_3W_CMD1_DONE) != 0)
+ if (u1bTmp & SW_3W_CMD1_DONE)
break;

udelay(10);
@@ -315,45 +264,26 @@ static int HwHSSIThreeWire(struct net_device *dev,
write_nic_byte(dev, SW_3W_CMD1, 0);

/* Read back data for read operation. */
- if (bWrite == 0) {
- if (bSI) {
- /* Serial Interface : reg363_362[11:0] */
- *((u16 *)pDataBuf) = read_nic_word(dev, SI_DATA_READ) ;
- } else {
- /* Parallel Interface : reg361_360[11:0] */
- *((u16 *)pDataBuf) = read_nic_word(dev, PI_DATA_READ);
- }
-
+ if (!write) {
+ /* Serial Interface : reg363_362[11:0] */
+ *((u16 *)pDataBuf) = read_nic_word(dev, SI_DATA_READ);
*((u16 *)pDataBuf) &= 0x0FFF;
}

- return bResult;
+ return true;
}

-void RF_WriteReg(struct net_device *dev, u8 offset, u32 data)
+void RF_WriteReg(struct net_device *dev, u8 offset, u16 data)
{
- u32 data2Write;
- u8 len;
-
- /* Pure HW 3-wire. */
- data2Write = (data << 4) | (u32)(offset & 0x0f);
- len = 16;
-
- HwHSSIThreeWire(dev, (u8 *)(&data2Write), len, 1, 1);
+ u16 reg = (data << 4) | (offset & 0x0f);
+ HwHSSIThreeWire(dev, (u8 *)&reg, true);
}

u32 RF_ReadReg(struct net_device *dev, u8 offset)
{
- u32 data2Write;
- u8 wlen;
- u32 dataRead;
-
- data2Write = ((u32)(offset & 0x0f));
- wlen = 16;
- HwHSSIThreeWire(dev, (u8 *)(&data2Write), wlen, 1, 0);
- dataRead = data2Write;
-
- return dataRead;
+ u16 reg = offset & 0x0f;
+ HwHSSIThreeWire(dev, (u8 *)&reg, false);
+ return reg;
}


--
1.7.10.4


2012-11-12 21:59:11

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 13/17] Use ARRAY_SIZE instead of in-code constants


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_rtl8225z2.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/r8180_rtl8225z2.c b/r8180_rtl8225z2.c
index eba9786..c592f79 100644
--- a/r8180_rtl8225z2.c
+++ b/r8180_rtl8225z2.c
@@ -132,7 +132,7 @@ static const u16 rtl8225z2_rxgain[] = {
0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
- 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
+ 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb

};

@@ -431,8 +431,8 @@ void rtl8225z2_rf_init(struct net_device *dev)
struct r8180_priv *priv = ieee80211_priv(dev);
int i;
short channel = 1;
- u16 brsr;
- u32 data, addr;
+ u16 brsr;
+ u32 data;

priv->chan = channel;

@@ -473,8 +473,8 @@ void rtl8225z2_rf_init(struct net_device *dev)

write_rtl8225(dev, 0x0, 0x1b7);

- for (i = 0; i < 95; i++) {
- write_rtl8225(dev, 0x1, (u8)(i + 1));
+ for (i = 0; i < ARRAY_SIZE(rtl8225z2_rxgain); i++) {
+ write_rtl8225(dev, 0x1, i + 1);
write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]);
}

@@ -504,14 +504,12 @@ void rtl8225z2_rf_init(struct net_device *dev)

write_rtl8225(dev, 0x0, 0x2bf);

- for (i = 0; i < 128; i++) {
- data = rtl8225_agc[i];
-
- addr = i + 0x80; /* enable writing AGC table */
- write_phy_ofdm(dev, 0xb, data);
+ for (i = 0; i < ARRAY_SIZE(rtl8225_agc); i++) {
+ write_phy_ofdm(dev, 0xb, rtl8225_agc[i]);
mdelay(1);

- write_phy_ofdm(dev, 0xa, addr);
+ /* enable writing AGC table */
+ write_phy_ofdm(dev, 0xa, i + 0x80);
mdelay(1);
}

--
1.7.10.4


2012-11-12 21:58:55

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 04/17] Fixed bugs in interrupt handler


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/r8180_core.c b/r8180_core.c
index 53a645b..d903786 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -3787,7 +3787,7 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
priv->stats.txbkperr++;
priv->ieee80211->stats.tx_errors++;
rtl8180_tx_isr(dev, BK_PRIORITY, 1);
- rtl8180_try_wake_queue(dev, BE_PRIORITY);
+ rtl8180_try_wake_queue(dev, BK_PRIORITY);
}

if (inta & ISR_TBEDER) { /* corresponding to BE_PRIORITY */
@@ -3841,6 +3841,7 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
priv->link_detect.NumTxOkInPeriod++; /* YJ,add,080828 */
priv->stats.txnpokint++;
rtl8180_tx_isr(dev, NORM_PRIORITY, 0);
+ rtl8180_try_wake_queue(dev, NORM_PRIORITY);
}

if (inta & ISR_TLPDOK) { /* Low priority tx ok */
--
1.7.10.4


2012-11-12 21:58:54

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 03/17] Removed empty functions and one-iteration loop


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8185b_init.c | 210 ++++++++++++++++++++++++---------------------------------
1 file changed, 89 insertions(+), 121 deletions(-)

diff --git a/r8185b_init.c b/r8185b_init.c
index 9144957..1ab8513 100644
--- a/r8185b_init.c
+++ b/r8185b_init.c
@@ -217,118 +217,115 @@ static int HwHSSIThreeWire(struct net_device *dev,
u8 TryCnt;
u8 u1bTmp;

- do {
- /* Check if WE and RE are cleared. */
- for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
- u1bTmp = read_nic_byte(dev, SW_3W_CMD1);
- if ((u1bTmp & (SW_3W_CMD1_RE|SW_3W_CMD1_WE)) == 0)
- break;
+ /* Check if WE and RE are cleared. */
+ for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
+ u1bTmp = read_nic_byte(dev, SW_3W_CMD1);
+ if ((u1bTmp & (SW_3W_CMD1_RE|SW_3W_CMD1_WE)) == 0)
+ break;

- udelay(10);
- }
- if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) {
- printk(KERN_ERR "rtl8187se: HwThreeWire(): CmdReg:"
- " %#X RE|WE bits are not clear!!\n", u1bTmp);
- dump_stack();
- return 0;
- }
+ udelay(10);
+ }
+ if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) {
+ printk(KERN_ERR "rtl8187se: HwThreeWire(): CmdReg:"
+ " %#X RE|WE bits are not clear!!\n", u1bTmp);
+ dump_stack();
+ return 0;
+ }

- /* RTL8187S HSSI Read/Write Function */
- u1bTmp = read_nic_byte(dev, RF_SW_CONFIG);
+ /* RTL8187S HSSI Read/Write Function */
+ u1bTmp = read_nic_byte(dev, RF_SW_CONFIG);

- if (bSI)
- u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */
+ if (bSI)
+ u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */

- else
- u1bTmp &= ~RF_SW_CFG_SI; /* reg08[1]=0 Parallel Interface(PI) */
+ else
+ u1bTmp &= ~RF_SW_CFG_SI; /* reg08[1]=0 Parallel Interface(PI) */


- write_nic_byte(dev, RF_SW_CONFIG, u1bTmp);
+ write_nic_byte(dev, RF_SW_CONFIG, u1bTmp);

- if (bSI) {
- /* jong: HW SI read must set reg84[3]=0. */
- u1bTmp = read_nic_byte(dev, RFPinsSelect);
- u1bTmp &= ~BIT3;
- write_nic_byte(dev, RFPinsSelect, u1bTmp);
- }
- /* Fill up data buffer for write operation. */
-
- if (bWrite) {
- if (nDataBufBitCnt == 16) {
- write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
- } else if (nDataBufBitCnt == 64) {
- /* RTL8187S shouldn't enter this case */
- write_nic_dword(dev, SW_3W_DB0, *((u32 *)pDataBuf));
- write_nic_dword(dev, SW_3W_DB1, *((u32 *)(pDataBuf + 4)));
- } else {
- int idx;
- int ByteCnt = nDataBufBitCnt / 8;
- /* printk("%d\n",nDataBufBitCnt); */
- if ((nDataBufBitCnt % 8) != 0) {
- printk(KERN_ERR "rtl8187se: "
- "HwThreeWire(): nDataBufBitCnt(%d)"
- " should be multiple of 8!!!\n",
- nDataBufBitCnt);
- dump_stack();
- nDataBufBitCnt += 8;
- nDataBufBitCnt &= ~7;
- }
+ if (bSI) {
+ /* jong: HW SI read must set reg84[3]=0. */
+ u1bTmp = read_nic_byte(dev, RFPinsSelect);
+ u1bTmp &= ~BIT3;
+ write_nic_byte(dev, RFPinsSelect, u1bTmp);
+ }
+ /* Fill up data buffer for write operation. */
+
+ if (bWrite) {
+ if (nDataBufBitCnt == 16) {
+ write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
+ } else if (nDataBufBitCnt == 64) {
+ /* RTL8187S shouldn't enter this case */
+ write_nic_dword(dev, SW_3W_DB0, *((u32 *)pDataBuf));
+ write_nic_dword(dev, SW_3W_DB1, *((u32 *)(pDataBuf + 4)));
+ } else {
+ int idx;
+ int ByteCnt = nDataBufBitCnt / 8;
+ /* printk("%d\n",nDataBufBitCnt); */
+ if ((nDataBufBitCnt % 8) != 0) {
+ printk(KERN_ERR "rtl8187se: "
+ "HwThreeWire(): nDataBufBitCnt(%d)"
+ " should be multiple of 8!!!\n",
+ nDataBufBitCnt);
+ dump_stack();
+ nDataBufBitCnt += 8;
+ nDataBufBitCnt &= ~7;
+ }

- if (nDataBufBitCnt > 64) {
- printk(KERN_ERR "rtl8187se: HwThreeWire():"
- " nDataBufBitCnt(%d) should <= 64!!!\n",
- nDataBufBitCnt);
- dump_stack();
- nDataBufBitCnt = 64;
- }
+ if (nDataBufBitCnt > 64) {
+ printk(KERN_ERR "rtl8187se: HwThreeWire():"
+ " nDataBufBitCnt(%d) should <= 64!!!\n",
+ nDataBufBitCnt);
+ dump_stack();
+ nDataBufBitCnt = 64;
+ }

- for (idx = 0; idx < ByteCnt; idx++)
- write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx));
+ for (idx = 0; idx < ByteCnt; idx++)
+ write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx));

- }
- } else { /* read */
- if (bSI) {
- /* SI - reg274[3:0] : RF register's Address */
- write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
- } else {
- /* PI - reg274[15:12] : RF register's Address */
- write_nic_word(dev, SW_3W_DB0, (*((u16 *)pDataBuf)) << 12);
- }
}
+ } else { /* read */
+ if (bSI) {
+ /* SI - reg274[3:0] : RF register's Address */
+ write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
+ } else {
+ /* PI - reg274[15:12] : RF register's Address */
+ write_nic_word(dev, SW_3W_DB0, (*((u16 *)pDataBuf)) << 12);
+ }
+ }

- /* Set up command: WE or RE. */
- if (bWrite)
- write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_WE);
+ /* Set up command: WE or RE. */
+ if (bWrite)
+ write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_WE);

- else
- write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_RE);
+ else
+ write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_RE);


- /* Check if DONE is set. */
- for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
- u1bTmp = read_nic_byte(dev, SW_3W_CMD1);
- if ((u1bTmp & SW_3W_CMD1_DONE) != 0)
- break;
-
- udelay(10);
- }
+ /* Check if DONE is set. */
+ for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
+ u1bTmp = read_nic_byte(dev, SW_3W_CMD1);
+ if ((u1bTmp & SW_3W_CMD1_DONE) != 0)
+ break;

- write_nic_byte(dev, SW_3W_CMD1, 0);
+ udelay(10);
+ }

- /* Read back data for read operation. */
- if (bWrite == 0) {
- if (bSI) {
- /* Serial Interface : reg363_362[11:0] */
- *((u16 *)pDataBuf) = read_nic_word(dev, SI_DATA_READ) ;
- } else {
- /* Parallel Interface : reg361_360[11:0] */
- *((u16 *)pDataBuf) = read_nic_word(dev, PI_DATA_READ);
- }
+ write_nic_byte(dev, SW_3W_CMD1, 0);

- *((u16 *)pDataBuf) &= 0x0FFF;
+ /* Read back data for read operation. */
+ if (bWrite == 0) {
+ if (bSI) {
+ /* Serial Interface : reg363_362[11:0] */
+ *((u16 *)pDataBuf) = read_nic_word(dev, SI_DATA_READ) ;
+ } else {
+ /* Parallel Interface : reg361_360[11:0] */
+ *((u16 *)pDataBuf) = read_nic_word(dev, PI_DATA_READ);
}

- } while (0);
+ *((u16 *)pDataBuf) &= 0x0FFF;
+ }

return bResult;
}
@@ -1148,18 +1145,11 @@ void rtl8185b_irq_enable(struct net_device *dev)
write_nic_dword(dev, IMR, priv->IntrMask);
}

-void DrvIFIndicateDisassociation(struct net_device *dev, u16 reason)
-{
- /* nothing is needed after disassociation request. */
-}
-
void MgntDisconnectIBSS(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
u8 i;

- DrvIFIndicateDisassociation(dev, unspec_reason);
-
for (i = 0; i < 6 ; i++)
priv->ieee80211->current_network.bssid[i] = 0x55;

@@ -1190,8 +1180,6 @@ void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn)

if (memcmp(priv->ieee80211->current_network.bssid, asSta, 6) == 0) {
/* ShuChen TODO: change media status. */
- /* ShuChen TODO: What to do when disassociate. */
- DrvIFIndicateDisassociation(dev, unspec_reason);

for (i = 0; i < 6; i++)
priv->ieee80211->current_network.bssid[i] = 0x22;
@@ -1267,14 +1255,6 @@ bool SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState)
return bResult;
}

-void HalEnableRx8185Dummy(struct net_device *dev)
-{
-}
-
-void HalDisableRx8185Dummy(struct net_device *dev)
-{
-}
-
bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u32 ChangeSource)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -1359,18 +1339,6 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u
if (bActionAllowed) {
/* Config HW to the specified mode. */
SetRFPowerState(dev, StateToSet);
-
- /* Turn on RF. */
- if (StateToSet == eRfOn) {
- HalEnableRx8185Dummy(dev);
- if (bConnectBySSID) {
- /* by amy not supported */
- }
- }
- /* Turn off RF. */
- else if (StateToSet == eRfOff)
- HalDisableRx8185Dummy(dev);
-
}

/* Release RF spinlock */
--
1.7.10.4


2012-11-12 21:59:15

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 15/17] Removed unused fields in r8180_priv


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180.h | 10 ----------
r8180_core.c | 49 +++----------------------------------------------
r8185b_init.c | 6 ++----
3 files changed, 5 insertions(+), 60 deletions(-)

diff --git a/r8180.h b/r8180.h
index a819b01..1db8257 100644
--- a/r8180.h
+++ b/r8180.h
@@ -327,12 +327,8 @@ typedef struct r8180_priv
int irq;
struct ieee80211_device *ieee80211;

- short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
- short enable_gpio0;
- short hw_plcp_len;
short plcp_preamble_mode; // 0:auto 1:short 2:long

- spinlock_t irq_lock;
spinlock_t irq_th_lock;
spinlock_t tx_lock;
spinlock_t ps_lock;
@@ -350,7 +346,6 @@ typedef struct r8180_priv
u8 channel_plan; // it's the channel plan index
short up;
short crcmon; //if 1 allow bad crc frame reception in monitor mode
- short prism_hdr;

struct timer_list scan_timer;
/*short scanpending;
@@ -359,7 +354,6 @@ typedef struct r8180_priv
u8 active_probe;
//u8 active_scan_num;
struct semaphore wx_sem;
- struct semaphore rf_state;
short hw_wep;

short digphy;
@@ -489,7 +483,6 @@ typedef struct r8180_priv
RT_RF_POWER_STATE eRFPowerState;
u32 RfOffReason;
bool RFChangeInProgress;
- bool bInHctTest;
bool SetRFPowerStateInProgress;
u8 RFProgType;
bool bLeisurePs;
@@ -616,15 +609,12 @@ typedef struct r8180_priv
// struct workqueue_struct *workqueue;
struct work_struct reset_wq;
struct work_struct watch_dog_wq;
- struct work_struct tx_irq_wq;
short ack_tx_to_ieee;

u8 PowerProfile;
- u32 CSMethod;
u8 dma_poll_stop_mask;

//u8 RegThreeWireMode;
- u8 MWIEnable;
u16 ShortRetryLimit;
u16 LongRetryLimit;
u16 EarlyRxThreshold;
diff --git a/r8180_core.c b/r8180_core.c
index 70373e9..1202332 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -1437,14 +1437,9 @@ void rtl8180_rx(struct net_device *dev)
dev_kfree_skb_any(priv->rx_skb);
priv->stats.rxnolast++;
}
- /* support for prism header has been originally added by Christian */
- if (priv->prism_hdr && priv->ieee80211->iw_mode == IW_MODE_MONITOR) {
-
- } else {
- priv->rx_skb = dev_alloc_skb(len+2);
- if (!priv->rx_skb)
- goto drop;
- }
+ priv->rx_skb = dev_alloc_skb(len+2);
+ if (!priv->rx_skb)
+ goto drop;

priv->rx_skb_complete = 0;
priv->rx_skb->dev = dev;
@@ -1717,8 +1712,6 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
int remain;
int buflen;
int count;
- u16 duration;
- short ext;
struct buffer *buflist;
struct ieee80211_hdr_3addr *frag_hdr = (struct ieee80211_hdr_3addr *)txbuf;
u8 dest[ETH_ALEN];
@@ -1914,15 +1907,6 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,

*tail = *tail | ((rate&0xf) << 24);

- /* hw_plcp_len is not used for rtl8180 chip */
- /* FIXME */
- if (!priv->hw_plcp_len) {
- duration = rtl8180_len2duration(len, rate, &ext);
- *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16);
- if (ext)
- *(tail+1) = *(tail+1) | (1<<31); /* plcp length extension */
- }
-
if (morefrag)
*tail = (*tail) | (1<<17); /* more fragment */
if (!remain)
@@ -2219,7 +2203,6 @@ void rtl8180_wmm_param_update(struct work_struct *work)
}
}

-void rtl8180_tx_irq_wq(struct work_struct *work);
void rtl8180_restart_wq(struct work_struct *work);
/* void rtl8180_rq_tx_ack(struct work_struct *work); */
void rtl8180_watch_dog_wq(struct work_struct *work);
@@ -2408,7 +2391,6 @@ short rtl8180_init(struct net_device *dev)
priv->RFChangeInProgress = false;
priv->SetRFPowerStateInProgress = false;
priv->RFProgType = 0;
- priv->bInHctTest = false;

priv->irq_enabled = 0;

@@ -2432,14 +2414,12 @@ short rtl8180_init(struct net_device *dev)
priv->ieee80211->ps_is_queue_empty = rtl8180_is_tx_queue_empty;

priv->hw_wep = hwwep;
- priv->prism_hdr = 0;
priv->dev = dev;
priv->retry_rts = DEFAULT_RETRY_RTS;
priv->retry_data = DEFAULT_RETRY_DATA;
priv->RFChangeInProgress = false;
priv->SetRFPowerStateInProgress = false;
priv->RFProgType = 0;
- priv->bInHctTest = false;
priv->bInactivePs = true; /* false; */
priv->ieee80211->bInactivePs = priv->bInactivePs;
priv->bSwRfProcessing = false;
@@ -2522,15 +2502,12 @@ short rtl8180_init(struct net_device *dev)
priv->RegBModeGainStage = 1;

priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0;
- spin_lock_init(&priv->irq_lock);
spin_lock_init(&priv->irq_th_lock);
spin_lock_init(&priv->tx_lock);
spin_lock_init(&priv->ps_lock);
spin_lock_init(&priv->rf_ps_lock);
sema_init(&priv->wx_sem, 1);
- sema_init(&priv->rf_state, 1);
INIT_WORK(&priv->reset_wq, (void *)rtl8180_restart_wq);
- INIT_WORK(&priv->tx_irq_wq, (void *)rtl8180_tx_irq_wq);
INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,
(void *)rtl8180_hw_wakeup_wq);
INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,
@@ -2572,14 +2549,10 @@ short rtl8180_init(struct net_device *dev)
priv->ieee80211->stop_send_beacons = rtl8180_beacon_tx_disable;
priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;

- priv->MWIEnable = 0;
-
priv->ShortRetryLimit = 7;
priv->LongRetryLimit = 7;
priv->EarlyRxThreshold = 7;

- priv->CSMethod = (0x01 << 29);
-
priv->TransmitConfig = (1<<TCR_DurProcMode_OFFSET) |
(7<<TCR_MXDMA_OFFSET) |
(priv->ShortRetryLimit<<TCR_SRL_OFFSET) |
@@ -2605,14 +2578,10 @@ short rtl8180_init(struct net_device *dev)
priv->InitialGain = 6;

DMESG("MAC controller is a RTL8187SE b/g");
- priv->phy_ver = 2;

priv->ieee80211->modulation |= IEEE80211_OFDM_MODULATION;
priv->ieee80211->short_slot = 1;

- /* just for sync 85 */
- priv->enable_gpio0 = 0;
-
eeprom_93cx6_read(&eeprom, EEPROM_SW_REVD_OFFSET, &usValue);
DMESG("usValue is %#hx\n", usValue);
/* 3Read AntennaDiversity */
@@ -2639,9 +2608,6 @@ short rtl8180_init(struct net_device *dev)
/* 1: main, 2: aux. */
priv->bDefaultAntenna1 = priv->RegDefaultAntenna == 2;

- /* rtl8185 can calc plcp len in HW. */
- priv->hw_plcp_len = 1;
-
priv->plcp_preamble_mode = 2;
/* the eeprom type is stored in RCR register bit #6 */
if (RCR_9356SEL & read_nic_dword(dev, RCR))
@@ -3594,15 +3560,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri, short error)
spin_unlock_irqrestore(&priv->tx_lock, flag);
}

-void rtl8180_tx_irq_wq(struct work_struct *work)
-{
- struct delayed_work *dwork = to_delayed_work(work);
- struct ieee80211_device * ieee = (struct ieee80211_device *)
- container_of(dwork, struct ieee80211_device, watch_dog_wq);
- struct net_device *dev = ieee->dev;
-
- rtl8180_tx_isr(dev, MANAGE_PRIORITY, 0);
-}
irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
{
struct net_device *dev = (struct net_device *) netdev;
diff --git a/r8185b_init.c b/r8185b_init.c
index 52e6802..0b3ffd7 100644
--- a/r8185b_init.c
+++ b/r8185b_init.c
@@ -1230,11 +1230,9 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u
priv->RfOffReason = 0;
bActionAllowed = true;

- if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW && !priv->bInHctTest)
+ if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW)
bConnectBySSID = true;
-
- } else
- ;
+ }
break;

case eRfOff:
--
1.7.10.4


2012-11-12 23:31:13

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 15/17] Removed unused fields in r8180_priv

On 11/12/2012 03:58 PM, Maxim Mikityanskiy wrote:
> Signed-off-by: Maxim Mikityanskiy <[email protected]>
> ---
> r8180.h | 10 ----------
> r8180_core.c | 49 +++----------------------------------------------
> r8185b_init.c | 6 ++----
> 3 files changed, 5 insertions(+), 60 deletions(-)

This patch failed to apply, even after the directory level was fixed. A wiggle
run fixed it with no manual intervention, but there is some kind of problem. My
base system is the staging tree, with a pull today.

Larry


2012-11-13 17:19:01

by Maxim Mikityanskiy

[permalink] [raw]
Subject: Re: [PATCH 00/17] RTL8187SE driver cleanups

2012/11/13 Larry Finger <[email protected]>:
> On 11/12/2012 03:58 PM, Maxim Mikityanskiy wrote:
>>
>> There are some bug fixes, cleanups and dead code removal for
>> drivers/staging/rtl8187se
>
>
> There is a serious problems with your patches. The text in
> Documentation/SubmittingPatches says:
>
> "All changes to the Linux kernel occur in the form of patches, as
> generated by diff(1). When creating your patch, make sure to create it
> in "unified diff" format, as supplied by the '-u' argument to diff(1).
> Also, please use the '-p' argument which shows which C function each
> change is in - that makes the resultant diff a lot easier to read.
> Patches should be based in the root kernel source directory,
> not in any lower subdirectory."
>
> You satisfied the requirements for -u and -p, but you based then on the
> wrong directory. I can use sed to rewrite this version for testing, but
> please use the correct base in future versions.
>
> Larry
>
>

I'm sorry, I'll remake patches with correct base and resend them.
Really, you could use "cd drivers/staging/rtl8187se" instead of sed,
it might be easier for you.

2012-11-12 21:58:52

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 02/17] Removed legacy rtl8225_rf_set_chan()


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 41 --------------
r8180_rtl8225z2.c | 160 +----------------------------------------------------
2 files changed, 3 insertions(+), 198 deletions(-)

diff --git a/r8180_core.c b/r8180_core.c
index 29c44c9..53a645b 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -444,24 +444,6 @@ void buffer_free(struct net_device *dev, struct buffer **buffer, int len, short
*buffer = NULL;
}

-void print_buffer(u32 *buffer, int len)
-{
- int i;
- u8 *buf = (u8 *)buffer;
-
- printk("ASCII BUFFER DUMP (len: %x):\n", len);
-
- for (i = 0; i < len; i++)
- printk("%c", buf[i]);
-
- printk("\nBINARY BUFFER DUMP (len: %x):\n", len);
-
- for (i = 0; i < len; i++)
- printk("%02x", buf[i]);
-
- printk("\n");
-}
-
int get_curr_tx_free_desc(struct net_device *dev, int priority)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -2970,29 +2952,6 @@ void write_phy_cck(struct net_device *dev, u8 adr, u32 data)
rtl8185_write_phy(dev, adr, data | 0x10000);
}

-void rtl8185_set_rate(struct net_device *dev)
-{
- int i;
- u16 word;
- int basic_rate, min_rr_rate, max_rr_rate;
-
- basic_rate = ieeerate2rtlrate(240);
- min_rr_rate = ieeerate2rtlrate(60);
- max_rr_rate = ieeerate2rtlrate(240);
-
- write_nic_byte(dev, RESP_RATE,
- max_rr_rate<<MAX_RESP_RATE_SHIFT |
- min_rr_rate<<MIN_RESP_RATE_SHIFT);
-
- word = read_nic_word(dev, BRSR);
- word &= ~BRSR_MBR_8185;
-
- for (i = 0; i <= basic_rate; i++)
- word |= (1<<i);
-
- write_nic_word(dev, BRSR, word);
-}
-
/*
* This configures registers for beacon tx and enables it via
* rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might
diff --git a/r8180_rtl8225z2.c b/r8180_rtl8225z2.c
index a369a3d..315eece 100644
--- a/r8180_rtl8225z2.c
+++ b/r8180_rtl8225z2.c
@@ -111,118 +111,12 @@ static const u8 rtl8225_agc[] = {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
};

-static const u8 rtl8225_gain[] = {
- 0x23, 0x88, 0x7c, 0xa5, /* -82dBm */
- 0x23, 0x88, 0x7c, 0xb5, /* -82dBm */
- 0x23, 0x88, 0x7c, 0xc5, /* -82dBm */
- 0x33, 0x80, 0x79, 0xc5, /* -78dBm */
- 0x43, 0x78, 0x76, 0xc5, /* -74dBm */
- 0x53, 0x60, 0x73, 0xc5, /* -70dBm */
- 0x63, 0x58, 0x70, 0xc5, /* -66dBm */
-};
-
-static const u8 rtl8225_tx_gain_cck_ofdm[] = {
- 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0x7e
-};
-
-static const u8 rtl8225_tx_power_cck[] = {
- 0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02,
- 0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02,
- 0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02,
- 0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02,
- 0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03,
- 0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03
-};
-
-static const u8 rtl8225_tx_power_cck_ch14[] = {
- 0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00,
- 0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00,
- 0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00,
- 0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00,
- 0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u8 rtl8225_tx_power_ofdm[] = {
- 0x80, 0x90, 0xa2, 0xb5, 0xcb, 0xe4
-};
-
static const u32 rtl8225_chan[] = {
0,
0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380,
0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x074A,
};

-static void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- int GainIdx;
- int GainSetting;
- int i;
- u8 power;
- const u8 *cck_power_table;
- u8 max_cck_power_level;
- u8 max_ofdm_power_level;
- u8 min_ofdm_power_level;
- u8 cck_power_level = 0xff & priv->chtxpwr[ch];
- u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];
-
- max_cck_power_level = 35;
- max_ofdm_power_level = 35;
- min_ofdm_power_level = 0;
-
- if (cck_power_level > max_cck_power_level)
- cck_power_level = max_cck_power_level;
-
- GainIdx = cck_power_level % 6;
- GainSetting = cck_power_level / 6;
-
- if (ch == 14)
- cck_power_table = rtl8225_tx_power_cck_ch14;
- else
- cck_power_table = rtl8225_tx_power_cck;
-
- write_nic_byte(dev, TX_GAIN_CCK,
- rtl8225_tx_gain_cck_ofdm[GainSetting] >> 1);
-
- for (i = 0; i < 8; i++) {
- power = cck_power_table[GainIdx * 8 + i];
- write_phy_cck(dev, 0x44 + i, power);
- }
-
- /* FIXME Is this delay really needed ? */
- force_pci_posting(dev);
- mdelay(1);
-
- if (ofdm_power_level > (max_ofdm_power_level - min_ofdm_power_level))
- ofdm_power_level = max_ofdm_power_level;
- else
- ofdm_power_level += min_ofdm_power_level;
-
- if (ofdm_power_level > 35)
- ofdm_power_level = 35;
-
- GainIdx = ofdm_power_level % 6;
- GainSetting = ofdm_power_level / 6;
-
- rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
-
- write_phy_ofdm(dev, 2, 0x42);
- write_phy_ofdm(dev, 6, 0x00);
- write_phy_ofdm(dev, 8, 0x00);
-
- write_nic_byte(dev, TX_GAIN_OFDM,
- rtl8225_tx_gain_cck_ofdm[GainSetting] >> 1);
-
- power = rtl8225_tx_power_ofdm[GainIdx];
-
- write_phy_ofdm(dev, 5, power);
- write_phy_ofdm(dev, 7, power);
-
- force_pci_posting(dev);
- mdelay(1);
-}
-
static const u8 rtl8225z2_threshold[] = {
0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd,
};
@@ -263,15 +157,6 @@ static const u16 rtl8225z2_rxgain[] = {

};

-static const u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
- 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
- 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
- 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
- 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-};
-
static const u8 rtl8225z2_tx_power_ofdm[] = {
0x42, 0x00, 0x40, 0x00, 0x40
};
@@ -508,8 +393,7 @@ void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
if (cck_power_level > 35)
cck_power_level = 35;

- write_nic_byte(dev, CCK_TXAGC,
- (ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)cck_power_level]));
+ write_nic_byte(dev, CCK_TXAGC, cck_power_level);
force_pci_posting(dev);
mdelay(1);

@@ -524,8 +408,7 @@ void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
write_phy_ofdm(dev, 8, 0x40);
}

- write_nic_byte(dev, OFDM_TXAGC,
- ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)ofdm_power_level]);
+ write_nic_byte(dev, OFDM_TXAGC, ofdm_power_level);

if (ofdm_power_level <= 11) {
write_phy_ofdm(dev, 0x07, 0x5c);
@@ -576,43 +459,6 @@ static void rtl8225_host_pci_init(struct net_device *dev)
write_nic_word(dev, GP_ENABLE, 0xff & (~(1 << 6)));
}

-static void rtl8225_rf_set_chan(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
- ieee80211_is_54g(&priv->ieee80211->current_network)) ||
- priv->ieee80211->iw_mode == IW_MODE_MONITOR;
-
- rtl8225_SetTXPowerLevel(dev, ch);
-
- write_rtl8225(dev, 0x7, rtl8225_chan[ch]);
-
- force_pci_posting(dev);
- mdelay(10);
-
- if (gset) {
- write_nic_byte(dev, SIFS, 0x22);
- write_nic_byte(dev, DIFS, 0x14);
- } else {
- write_nic_byte(dev, SIFS, 0x44);
- write_nic_byte(dev, DIFS, 0x24);
- }
-
- if (priv->ieee80211->state == IEEE80211_LINKED &&
- ieee80211_is_shortslot(&priv->ieee80211->current_network))
- write_nic_byte(dev, SLOT, 0x9);
- else
- write_nic_byte(dev, SLOT, 0x14);
-
- if (gset) {
- write_nic_byte(dev, EIFS, 81);
- write_nic_byte(dev, CW_VAL, 0x73);
- } else {
- write_nic_byte(dev, EIFS, 81);
- write_nic_byte(dev, CW_VAL, 0xa5);
- }
-}
-
void rtl8225z2_rf_init(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -792,7 +638,7 @@ void rtl8225z2_rf_init(struct net_device *dev)
write_nic_dword(dev, 0x94, 0x15c00002);
rtl8185_rf_pins_enable(dev);

- rtl8225_rf_set_chan(dev, priv->chan);
+ rtl8225z2_rf_set_chan(dev, priv->chan);
}

void rtl8225z2_rf_set_mode(struct net_device *dev)
--
1.7.10.4


2012-11-13 17:26:07

by Maxim Mikityanskiy

[permalink] [raw]
Subject: Re: [PATCH 15/17] Removed unused fields in r8180_priv

2012/11/13 Larry Finger <[email protected]>:
> On 11/12/2012 03:58 PM, Maxim Mikityanskiy wrote:
>>
>> Signed-off-by: Maxim Mikityanskiy <[email protected]>
>> ---
>> r8180.h | 10 ----------
>> r8180_core.c | 49 +++----------------------------------------------
>> r8185b_init.c | 6 ++----
>> 3 files changed, 5 insertions(+), 60 deletions(-)
>
>
> This patch failed to apply, even after the directory level was fixed. A
> wiggle run fixed it with no manual intervention, but there is some kind of
> problem. My base system is the staging tree, with a pull today.
>
> Larry
>

Maybe, that's because I used linux-3.6.2 as base for my patches. I'll
resend patches that should apply cleanly to today's tree.

2012-11-12 21:58:51

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 01/17] Removed dead functions


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 185 -----------------------------------------------------
r8180_rtl8225z2.c | 16 -----
2 files changed, 201 deletions(-)

diff --git a/r8180_core.c b/r8180_core.c
index fd22b75..29c44c9 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -695,14 +695,6 @@ void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual)
return;
}

-void rtl8180_irq_enable(struct net_device *dev)
-{
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
- priv->irq_enabled = 1;
- write_nic_word(dev, INTA_MASK, priv->irq_mask);
-}
-
void rtl8180_irq_disable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -724,7 +716,6 @@ void rtl8180_set_mode(struct net_device *dev, int mode)
write_nic_byte(dev, EPROM_CMD, ecmd);
}

-void rtl8180_adapter_start(struct net_device *dev);
void rtl8180_beacon_tx_enable(struct net_device *dev);

void rtl8180_update_msr(struct net_device *dev)
@@ -771,57 +762,6 @@ void rtl8180_set_chan(struct net_device *dev, short ch)
priv->rf_set_chan(dev, priv->chan);
}

-void rtl8180_rx_enable(struct net_device *dev)
-{
- u8 cmd;
- u32 rxconf;
- /* for now we accept data, management & ctl frame*/
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
- rxconf = read_nic_dword(dev, RX_CONF);
- rxconf = rxconf & ~MAC_FILTER_MASK;
- rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
- if (dev->flags & IFF_PROMISC)
- DMESG("NIC in promisc mode");
-
- if (priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
- dev->flags & IFF_PROMISC) {
- rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
- } else {
- rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
- }
-
- if (priv->ieee80211->iw_mode == IW_MODE_MONITOR) {
- rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT);
- }
-
- if (priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
- rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
-
- rxconf = rxconf & ~RX_FIFO_THRESHOLD_MASK;
- rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE << RX_FIFO_THRESHOLD_SHIFT);
-
- rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
- rxconf = rxconf & ~MAX_RX_DMA_MASK;
- rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
-
- rxconf = rxconf | RCR_ONLYERLPKT;
-
- rxconf = rxconf & ~RCR_CS_MASK;
-
- write_nic_dword(dev, RX_CONF, rxconf);
-
- fix_rx_fifo(dev);
-
- cmd = read_nic_byte(dev, CMD);
- write_nic_byte(dev, CMD, cmd | (1<<CMD_RX_ENABLE_SHIFT));
-}
-
void set_nic_txring(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -855,60 +795,6 @@ void rtl8180_conttx_disable(struct net_device *dev)
write_nic_dword(dev, TX_CONF, txconf);
}

-void rtl8180_tx_enable(struct net_device *dev)
-{
- u8 cmd;
- u8 tx_agc_ctl;
- u8 byte;
- u32 txconf;
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
- txconf = read_nic_dword(dev, TX_CONF);
-
- byte = read_nic_byte(dev, CW_CONF);
- byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
- byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
- write_nic_byte(dev, CW_CONF, byte);
-
- tx_agc_ctl = read_nic_byte(dev, TX_AGC_CTL);
- tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
- tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
- tx_agc_ctl |= (1<<TX_AGC_CTL_FEEDBACK_ANT);
- write_nic_byte(dev, TX_AGC_CTL, tx_agc_ctl);
- write_nic_byte(dev, 0xec, 0x3f); /* Disable early TX */
-
- txconf = txconf & ~(1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
-
- txconf = txconf & ~TX_LOOPBACK_MASK;
- txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
- txconf = txconf & ~TCR_DPRETRY_MASK;
- txconf = txconf & ~TCR_RTSRETRY_MASK;
- txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT);
- txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT);
- txconf = txconf & ~(1<<TX_NOCRC_SHIFT);
-
- if (priv->hw_plcp_len)
- txconf = txconf & ~TCR_PLCP_LEN;
- else
- txconf = txconf | TCR_PLCP_LEN;
-
- txconf = txconf & ~TCR_MXDMA_MASK;
- txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
- txconf = txconf | TCR_CWMIN;
- txconf = txconf | TCR_DISCW;
-
- txconf = txconf | (1 << TX_NOICV_SHIFT);
-
- write_nic_dword(dev, TX_CONF, txconf);
-
- fix_tx_fifo(dev);
-
- cmd = read_nic_byte(dev, CMD);
- write_nic_byte(dev, CMD, cmd | (1<<CMD_TX_ENABLE_SHIFT));
-
- write_nic_dword(dev, TX_CONF, txconf);
-}
-
void rtl8180_beacon_tx_enable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -3107,77 +2993,6 @@ void rtl8185_set_rate(struct net_device *dev)
write_nic_word(dev, BRSR, word);
}

-void rtl8180_adapter_start(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-
- rtl8180_rtx_disable(dev);
- rtl8180_reset(dev);
-
- /* enable beacon timeout, beacon TX ok and err
- * LP tx ok and err, HP TX ok and err, NP TX ok and err,
- * RX ok and ERR, and GP timer
- */
- priv->irq_mask = 0x6fcf;
-
- priv->dma_poll_mask = 0;
-
- rtl8180_beacon_tx_disable(dev);
-
- rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
- write_nic_dword(dev, MAC0, ((u32 *)dev->dev_addr)[0]);
- write_nic_word(dev, MAC4, ((u32 *)dev->dev_addr)[1] & 0xffff);
- rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-
- rtl8180_update_msr(dev);
-
- /* These might be unnecessary since we do in rx_enable / tx_enable */
- fix_rx_fifo(dev);
- fix_tx_fifo(dev);
-
- rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
-
- /*
- * The following is very strange. seems to be that 1 means test mode,
- * but we need to acknowledges the nic when a packet is ready
- * although we set it to 0
- */
-
- write_nic_byte(dev,
- CONFIG2, read_nic_byte(dev, CONFIG2) & ~\
- (1<<CONFIG2_DMA_POLLING_MODE_SHIFT));
- /* ^the nic isn't in test mode */
- write_nic_byte(dev,
- CONFIG2, read_nic_byte(dev, CONFIG2)|(1<<4));
-
- rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-
- write_nic_dword(dev, INT_TIMEOUT, 0);
-
- write_nic_byte(dev, WPA_CONFIG, 0);
-
- rtl8180_no_hw_wep(dev);
-
- rtl8185_set_rate(dev);
- write_nic_byte(dev, RATE_FALLBACK, 0x81);
-
- write_nic_byte(dev, GP_ENABLE, read_nic_byte(dev, GP_ENABLE) & ~(1<<6));
-
- /* FIXME cfg 3 ClkRun enable - isn't it ReadOnly ? */
- rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
- write_nic_byte(dev, CONFIG3, read_nic_byte(dev, CONFIG3)
- | (1 << CONFIG3_CLKRUN_SHIFT));
- rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-
- priv->rf_init(dev);
-
- if (priv->rf_set_sens != NULL)
- priv->rf_set_sens(dev, priv->sens);
- rtl8180_irq_enable(dev);
-
- netif_start_queue(dev);
-}
-
/*
* This configures registers for beacon tx and enables it via
* rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might
diff --git a/r8180_rtl8225z2.c b/r8180_rtl8225z2.c
index d28c1d9..a369a3d 100644
--- a/r8180_rtl8225z2.c
+++ b/r8180_rtl8225z2.c
@@ -412,22 +412,6 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr)
return dataRead;
}

-short rtl8225_is_V_z2(struct net_device *dev)
-{
- short vz2 = 1;
-
- if (read_rtl8225(dev, 8) != 0x588)
- vz2 = 0;
- else /* reg 9 pg 1 = 24 */
- if (read_rtl8225(dev, 9) != 0x700)
- vz2 = 0;
-
- /* sw back to pg 0 */
- write_rtl8225(dev, 0, 0xb7);
-
- return vz2;
-}
-
void rtl8225z2_rf_close(struct net_device *dev)
{
RF_WriteReg(dev, 0x4, 0x1f);
--
1.7.10.4


2012-11-12 21:59:06

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 10/17] Fixed typo in TransmitConfig


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/r8180_core.c b/r8180_core.c
index ded5cd0..4e872d9 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -2581,11 +2581,10 @@ short rtl8180_init(struct net_device *dev)

priv->CSMethod = (0x01 << 29);

- priv->TransmitConfig = TCR_DurProcMode_OFFSET |
+ priv->TransmitConfig = (1<<TCR_DurProcMode_OFFSET) |
(7<<TCR_MXDMA_OFFSET) |
(priv->ShortRetryLimit<<TCR_SRL_OFFSET) |
- (priv->LongRetryLimit<<TCR_LRL_OFFSET) |
- (0 ? TCR_SAT : 0);
+ (priv->LongRetryLimit<<TCR_LRL_OFFSET);

priv->ReceiveConfig = RCR_AMF | RCR_ADF | RCR_ACF |
RCR_AB | RCR_AM | RCR_APM |
--
1.7.10.4


2012-11-12 21:59:02

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 08/17] Removed dead code


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 82 ----------------------------------------------------------
1 file changed, 82 deletions(-)

diff --git a/r8180_core.c b/r8180_core.c
index 203e546..ded5cd0 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -606,66 +606,6 @@ void fix_rx_fifo(struct net_device *dev)
set_nic_rxring(dev);
}

-unsigned char QUALITY_MAP[] = {
- 0x64, 0x64, 0x64, 0x63, 0x63, 0x62, 0x62, 0x61,
- 0x61, 0x60, 0x60, 0x5f, 0x5f, 0x5e, 0x5d, 0x5c,
- 0x5b, 0x5a, 0x59, 0x57, 0x56, 0x54, 0x52, 0x4f,
- 0x4c, 0x49, 0x45, 0x41, 0x3c, 0x37, 0x31, 0x29,
- 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x21, 0x21, 0x21, 0x21, 0x21, 0x20,
- 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e,
- 0x1d, 0x1d, 0x1c, 0x1c, 0x1b, 0x1a, 0x19, 0x19,
- 0x18, 0x17, 0x16, 0x15, 0x14, 0x12, 0x11, 0x0f,
- 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x01, 0x00
-};
-
-unsigned char STRENGTH_MAP[] = {
- 0x64, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e,
- 0x5d, 0x5c, 0x5b, 0x5a, 0x57, 0x54, 0x52, 0x50,
- 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x41, 0x3f,
- 0x3c, 0x3a, 0x37, 0x36, 0x36, 0x1c, 0x1c, 0x1b,
- 0x1b, 0x1a, 0x1a, 0x19, 0x19, 0x18, 0x18, 0x17,
- 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13,
- 0x13, 0x12, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0f,
- 0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b,
- 0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07,
- 0x07, 0x06, 0x06, 0x05, 0x04, 0x03, 0x02, 0x00
-};
-
-void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual)
-{
- u32 temp;
- u32 temp2;
- u32 q;
- u32 orig_qual;
- u8 _rssi;
-
- q = *qual;
- orig_qual = *qual;
- _rssi = 0; /* avoid gcc complains.. */
-
- if (q <= 0x4e) {
- temp = QUALITY_MAP[q];
- } else {
- if (q & 0x80)
- temp = 0x32;
- else
- temp = 1;
- }
-
- *qual = temp;
- temp2 = *rssi;
-
- if (_rssi < 0x64) {
- if (_rssi == 0)
- *rssi = 1;
- } else {
- *rssi = 0x64;
- }
-
- return;
-}
-
void rtl8180_irq_disable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -746,26 +686,6 @@ void set_nic_txring(struct net_device *dev)
write_nic_dword(dev, TX_BEACON_RING_ADDR, priv->txbeaconringdma);
}

-void rtl8180_conttx_enable(struct net_device *dev)
-{
- u32 txconf;
-
- txconf = read_nic_dword(dev, TX_CONF);
- txconf = txconf & ~TX_LOOPBACK_MASK;
- txconf = txconf | (TX_LOOPBACK_CONTINUE<<TX_LOOPBACK_SHIFT);
- write_nic_dword(dev, TX_CONF, txconf);
-}
-
-void rtl8180_conttx_disable(struct net_device *dev)
-{
- u32 txconf;
-
- txconf = read_nic_dword(dev, TX_CONF);
- txconf = txconf & ~TX_LOOPBACK_MASK;
- txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
- write_nic_dword(dev, TX_CONF, txconf);
-}
-
void rtl8180_beacon_tx_enable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -2136,8 +2056,6 @@ short rtl8180_is_tx_queue_empty(struct net_device *dev)
return 0;
return 1;
}
-/* FIXME FIXME 5msecs is random */
-#define HW_WAKE_DELAY 5

void rtl8180_hw_wakeup(struct net_device *dev)
{
--
1.7.10.4


2012-11-13 17:51:46

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 00/17] RTL8187SE driver cleanups

On 11/13/2012 11:18 AM, Maxim Mikityanskiy wrote:
>
> I'm sorry, I'll remake patches with correct base and resend them.
> Really, you could use "cd drivers/staging/rtl8187se" instead of sed,
> it might be easier for you.

Actually, that would be more trouble as I always use quilt to handle patches
like this, and having the patches directory in more than one place would be a
hassle.

Larry



2012-11-12 22:37:35

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 00/17] RTL8187SE driver cleanups

On 11/12/2012 03:58 PM, Maxim Mikityanskiy wrote:
> There are some bug fixes, cleanups and dead code removal for
> drivers/staging/rtl8187se

There is a serious problems with your patches. The text in
Documentation/SubmittingPatches says:

"All changes to the Linux kernel occur in the form of patches, as
generated by diff(1). When creating your patch, make sure to create it
in "unified diff" format, as supplied by the '-u' argument to diff(1).
Also, please use the '-p' argument which shows which C function each
change is in - that makes the resultant diff a lot easier to read.
Patches should be based in the root kernel source directory,
not in any lower subdirectory."

You satisfied the requirements for -u and -p, but you based then on the wrong
directory. I can use sed to rewrite this version for testing, but please use the
correct base in future versions.

Larry



2012-11-12 21:59:08

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 11/17] Removed non-existent function headers from r8180.h


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180.h | 13 -------------
1 file changed, 13 deletions(-)

diff --git a/r8180.h b/r8180.h
index 2682afb..db7974a 100644
--- a/r8180.h
+++ b/r8180.h
@@ -667,35 +667,22 @@ void write_nic_dword(struct net_device *dev, int x,u32 y);
void force_pci_posting(struct net_device *dev);

void rtl8180_rtx_disable(struct net_device *);
-void rtl8180_rx_enable(struct net_device *);
-void rtl8180_tx_enable(struct net_device *);
-void rtl8180_start_scanning(struct net_device *dev);
-void rtl8180_start_scanning_s(struct net_device *dev);
-void rtl8180_stop_scanning(struct net_device *dev);
-void rtl8180_disassociate(struct net_device *dev);
-//void fix_rx_fifo(struct net_device *dev);
void rtl8180_set_anaparam(struct net_device *dev,u32 a);
void rtl8185_set_anaparam2(struct net_device *dev,u32 a);
void rtl8180_set_hw_wep(struct net_device *dev);
void rtl8180_no_hw_wep(struct net_device *dev);
void rtl8180_update_msr(struct net_device *dev);
-//void rtl8180_BSS_create(struct net_device *dev);
void rtl8180_beacon_tx_disable(struct net_device *dev);
void rtl8180_beacon_rx_disable(struct net_device *dev);
-void rtl8180_conttx_enable(struct net_device *dev);
-void rtl8180_conttx_disable(struct net_device *dev);
int rtl8180_down(struct net_device *dev);
int rtl8180_up(struct net_device *dev);
void rtl8180_commit(struct net_device *dev);
void rtl8180_set_chan(struct net_device *dev,short ch);
-void rtl8180_set_master_essid(struct net_device *dev,char *essid);
-void rtl8180_update_beacon_security(struct net_device *dev);
void write_phy(struct net_device *dev, u8 adr, u8 data);
void write_phy_cck(struct net_device *dev, u8 adr, u32 data);
void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data);
void rtl8185_tx_antenna(struct net_device *dev, u8 ant);
void rtl8185_rf_pins_enable(struct net_device *dev);
-void IBSS_randomize_cell(struct net_device *dev);
void IPSEnter(struct net_device *dev);
void IPSLeave(struct net_device *dev);
int get_curr_tx_free_desc(struct net_device *dev, int priority);
--
1.7.10.4


2012-11-13 17:15:57

by Maxim Mikityanskiy

[permalink] [raw]
Subject: Re: [PATCH 00/17] RTL8187SE driver cleanups

2012/11/13 Larry Finger <[email protected]>:
> On 11/12/2012 03:58 PM, Maxim Mikityanskiy wrote:
>>
>> There are some bug fixes, cleanups and dead code removal for
>> drivers/staging/rtl8187se
>
>
> This comment applies to all 17 patches. The subject should be of the form
>
> [PATCH XX/17] staging: rtl8187se: blah-blah
>
> By using both staging and rtl8187se in the subject, it is a lot easier to
> search the git log.
>
> I expect there will be comments on others of the series.
>
> Larry
>
>

OK, I'll resend with correct subject.

2012-11-12 21:59:18

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 17/17] Removed empty stub read_acadapter_file()


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180.h | 1 -
r8180_core.c | 18 +-----------------
2 files changed, 1 insertion(+), 18 deletions(-)

diff --git a/r8180.h b/r8180.h
index 1db8257..70ea414 100644
--- a/r8180.h
+++ b/r8180.h
@@ -611,7 +611,6 @@ typedef struct r8180_priv
struct work_struct watch_dog_wq;
short ack_tx_to_ieee;

- u8 PowerProfile;
u8 dma_poll_stop_mask;

//u8 RegThreeWireMode;
diff --git a/r8180_core.c b/r8180_core.c
index 9e0621b..c60a618 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -2480,7 +2480,6 @@ short rtl8180_init(struct net_device *dev)
priv->NumTxOkTotal = 0;
priv->NumTxUnicast = 0;
priv->keepAliveLevel = DEFAULT_KEEP_ALIVE_LEVEL;
- priv->PowerProfile = POWER_PROFILE_AC;
priv->CurrRetryCnt = 0;
priv->LastRetryCnt = 0;
priv->LastTxokCnt = 0;
@@ -2927,8 +2926,6 @@ static void MgntLinkKeepAlive(struct r8180_priv *priv)
}
}

-static u8 read_acadapter_file(char *filename);
-
void rtl8180_watch_dog(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -2961,12 +2958,7 @@ void rtl8180_watch_dog(struct net_device *dev)
MgntLinkKeepAlive(priv);

/* YJ,add,080828,for LPS */
- if (priv->PowerProfile == POWER_PROFILE_BATTERY)
- priv->bLeisurePs = true;
- else if (priv->PowerProfile == POWER_PROFILE_AC) {
- LeisurePSLeave(priv);
- priv->bLeisurePs = false;
- }
+ LeisurePSLeave(priv);

if (priv->ieee80211->state == IEEE80211_LINKED) {
priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod;
@@ -3735,9 +3727,6 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work)
static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL};
static int readf_count = 0;

- if (readf_count % 10 == 0)
- priv->PowerProfile = read_acadapter_file("/proc/acpi/ac_adapter/AC0/state");
-
readf_count = (readf_count+1)%0xffff;
/* We should turn off LED before polling FF51[4]. */

@@ -3782,10 +3771,5 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work)
}
}

-static u8 read_acadapter_file(char *filename)
-{
- return 0;
-}
-
module_init(rtl8180_pci_module_init);
module_exit(rtl8180_pci_module_exit);
--
1.7.10.4


2012-11-12 21:58:59

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 06/17] Fix oops when rmmoding


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/r8180_core.c b/r8180_core.c
index d903786..e04bb04 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -323,7 +323,6 @@ void rtl8180_proc_remove_one(struct net_device *dev)
remove_proc_entry("stats-tx", priv->dir_dev);
remove_proc_entry("stats-rx", priv->dir_dev);
remove_proc_entry("registers", priv->dir_dev);
- remove_proc_entry(dev->name, rtl8180_proc);
priv->dir_dev = NULL;
}
}
--
1.7.10.4


2012-11-12 21:59:16

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 16/17] Fixed size of BEACON_INTERVAL register


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/r8180_core.c b/r8180_core.c
index 1202332..9e0621b 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -1984,10 +1984,10 @@ void rtl8180_link_change(struct net_device *dev)
write_nic_dword(dev, BSSID, ((u32 *)net->bssid)[0]);
write_nic_word(dev, BSSID+4, ((u16 *)net->bssid)[2]);

- beacon_interval = read_nic_dword(dev, BEACON_INTERVAL);
+ beacon_interval = read_nic_word(dev, BEACON_INTERVAL);
beacon_interval &= ~BEACON_INTERVAL_MASK;
beacon_interval |= net->beacon_interval;
- write_nic_dword(dev, BEACON_INTERVAL, beacon_interval);
+ write_nic_word(dev, BEACON_INTERVAL, beacon_interval);

rtl8180_set_mode(dev, EPROM_CMD_NORMAL);

--
1.7.10.4


2012-11-12 21:59:13

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 14/17] Removed unneeded reads from EEPROM


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8180.h | 4 ----
r8180_core.c | 36 +++++++++---------------------------
2 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/r8180.h b/r8180.h
index db7974a..a819b01 100644
--- a/r8180.h
+++ b/r8180.h
@@ -365,8 +365,6 @@ typedef struct r8180_priv
short digphy;
short antb;
short diversity;
- u8 cs_treshold;
- short rcr_csense;
u32 key0[4];
short (*rf_set_sens)(struct net_device *dev,short sens);
void (*rf_set_chan)(struct net_device *dev,short ch);
@@ -623,8 +621,6 @@ typedef struct r8180_priv

u8 PowerProfile;
u32 CSMethod;
- u8 cck_txpwr_base;
- u8 ofdm_txpwr_base;
u8 dma_poll_stop_mask;

//u8 RegThreeWireMode;
diff --git a/r8180_core.c b/r8180_core.c
index 4e872d9..70373e9 100644
--- a/r8180_core.c
+++ b/r8180_core.c
@@ -2376,8 +2376,7 @@ short rtl8180_init(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
u16 word;
- u16 version;
- u32 usValue;
+ u16 usValue;
u16 tmpu16;
int i, j;
struct eeprom_93cx6 eeprom;
@@ -2614,36 +2613,31 @@ short rtl8180_init(struct net_device *dev)
/* just for sync 85 */
priv->enable_gpio0 = 0;

- eeprom_93cx6_read(&eeprom, EEPROM_SW_REVD_OFFSET, &eeprom_val);
- usValue = eeprom_val;
- DMESG("usValue is 0x%x\n", usValue);
+ eeprom_93cx6_read(&eeprom, EEPROM_SW_REVD_OFFSET, &usValue);
+ DMESG("usValue is %#hx\n", usValue);
/* 3Read AntennaDiversity */

/* SW Antenna Diversity. */
- if ((usValue & EEPROM_SW_AD_MASK) != EEPROM_SW_AD_ENABLE)
- priv->EEPROMSwAntennaDiversity = false;
- else
- priv->EEPROMSwAntennaDiversity = true;
+ priv->EEPROMSwAntennaDiversity = (usValue & EEPROM_SW_AD_MASK) ==
+ EEPROM_SW_AD_ENABLE;

/* Default Antenna to use. */
- if ((usValue & EEPROM_DEF_ANT_MASK) != EEPROM_DEF_ANT_1)
- priv->EEPROMDefaultAntenna1 = false;
- else
- priv->EEPROMDefaultAntenna1 = true;
+ priv->EEPROMDefaultAntenna1 = (usValue & EEPROM_DEF_ANT_MASK) ==
+ EEPROM_DEF_ANT_1;

if (priv->RegSwAntennaDiversityMechanism == 0) /* Auto */
/* 0: default from EEPROM. */
priv->bSwAntennaDiverity = priv->EEPROMSwAntennaDiversity;
else
/* 1:disable antenna diversity, 2: enable antenna diversity. */
- priv->bSwAntennaDiverity = ((priv->RegSwAntennaDiversityMechanism == 1) ? false : true);
+ priv->bSwAntennaDiverity = priv->RegSwAntennaDiversityMechanism == 2;

if (priv->RegDefaultAntenna == 0)
/* 0: default from EEPROM. */
priv->bDefaultAntenna1 = priv->EEPROMDefaultAntenna1;
else
/* 1: main, 2: aux. */
- priv->bDefaultAntenna1 = ((priv->RegDefaultAntenna == 2) ? true : false);
+ priv->bDefaultAntenna1 = priv->RegDefaultAntenna == 2;

/* rtl8185 can calc plcp len in HW. */
priv->hw_plcp_len = 1;
@@ -2683,18 +2677,6 @@ short rtl8180_init(struct net_device *dev)
if ((tmpu16 & EEPROM_THERMAL_METER_ENABLE) >> 13)
priv->bTxPowerTrack = true;

- eeprom_93cx6_read(&eeprom, EPROM_TXPW_BASE, &word);
- priv->cck_txpwr_base = word & 0xf;
- priv->ofdm_txpwr_base = (word>>4) & 0xf;
-
- eeprom_93cx6_read(&eeprom, EPROM_VERSION, &version);
- DMESG("EEPROM version %x", version);
- priv->rcr_csense = 3;
-
- eeprom_93cx6_read(&eeprom, ENERGY_TRESHOLD, &eeprom_val);
- priv->cs_treshold = (eeprom_val & 0xff00) >> 8;
-
- eeprom_93cx6_read(&eeprom, RFCHIPID, &eeprom_val);
priv->rf_sleep = rtl8225z4_rf_sleep;
priv->rf_wakeup = rtl8225z4_rf_wakeup;
DMESGW("**PLEASE** REPORT SUCCESSFUL/UNSUCCESSFUL TO Realtek!");
--
1.7.10.4


2012-11-12 22:19:04

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 00/17] RTL8187SE driver cleanups

On 11/12/2012 03:58 PM, Maxim Mikityanskiy wrote:
> There are some bug fixes, cleanups and dead code removal for
> drivers/staging/rtl8187se

This comment applies to all 17 patches. The subject should be of the form

[PATCH XX/17] staging: rtl8187se: blah-blah

By using both staging and rtl8187se in the subject, it is a lot easier to search
the git log.

I expect there will be comments on others of the series.

Larry



2012-11-12 21:58:57

by Maxim Mikityanskiy

[permalink] [raw]
Subject: [PATCH 05/17] Simplified function GetSupportedWirelessMode8185()


Signed-off-by: Maxim Mikityanskiy <[email protected]>
---
r8185b_init.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/r8185b_init.c b/r8185b_init.c
index 1ab8513..0b5c34b 100644
--- a/r8185b_init.c
+++ b/r8185b_init.c
@@ -927,10 +927,7 @@ static void MacConfig_85BASIC(struct net_device *dev)

u8 GetSupportedWirelessMode8185(struct net_device *dev)
{
- u8 btSupportedWirelessMode = 0;
-
- btSupportedWirelessMode = (WIRELESS_MODE_B | WIRELESS_MODE_G);
- return btSupportedWirelessMode;
+ return WIRELESS_MODE_B | WIRELESS_MODE_G;
}

void ActUpdateChannelAccessSetting(struct net_device *dev,
--
1.7.10.4