Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3d42bf1 authored by Xenia Ragiadakou's avatar Xenia Ragiadakou Committed by Greg Kroah-Hartman
Browse files

staging: rtl8192u: fix read_nic_* functions



read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.

To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.

Some other fixes introduced in read_nic_*() functions are:

The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.

In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.

Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).

Signed-off-by: default avatarXenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c2ac90b9
Loading
Loading
Loading
Loading
+24 −16
Original line number Diff line number Diff line
@@ -22,13 +22,15 @@

void eprom_cs(struct net_device *dev, short bit)
{
	u8 cmdreg;

	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
	if (bit)
		write_nic_byte_E(dev, EPROM_CMD,
			       (1<<EPROM_CS_SHIFT) | \
			       read_nic_byte_E(dev, EPROM_CMD)); //enable EPROM
		/* enable EPROM */
		write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CS_BIT);
	else
		write_nic_byte_E(dev, EPROM_CMD, read_nic_byte_E(dev, EPROM_CMD)\
			       & ~(1<<EPROM_CS_SHIFT)); //disable EPROM
		/* disable EPROM */
		write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_CS_BIT);

	force_pci_posting(dev);
	udelay(EPROM_DELAY);
@@ -37,12 +39,15 @@ void eprom_cs(struct net_device *dev, short bit)

void eprom_ck_cycle(struct net_device *dev)
{
	write_nic_byte_E(dev, EPROM_CMD,
		       (1<<EPROM_CK_SHIFT) | read_nic_byte_E(dev,EPROM_CMD));
	u8 cmdreg;

	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
	write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CK_BIT);
	force_pci_posting(dev);
	udelay(EPROM_DELAY);
	write_nic_byte_E(dev, EPROM_CMD,
		       read_nic_byte_E(dev, EPROM_CMD) & ~(1<<EPROM_CK_SHIFT));

	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
	write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_CK_BIT);
	force_pci_posting(dev);
	udelay(EPROM_DELAY);
}
@@ -50,12 +55,13 @@ void eprom_ck_cycle(struct net_device *dev)

void eprom_w(struct net_device *dev,short bit)
{
	u8 cmdreg;

	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
	if (bit)
		write_nic_byte_E(dev, EPROM_CMD, (1<<EPROM_W_SHIFT) | \
			       read_nic_byte_E(dev,EPROM_CMD));
		write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_W_BIT);
	else
		write_nic_byte_E(dev, EPROM_CMD, read_nic_byte_E(dev,EPROM_CMD)\
			       & ~(1<<EPROM_W_SHIFT));
		write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_W_BIT);

	force_pci_posting(dev);
	udelay(EPROM_DELAY);
@@ -64,12 +70,14 @@ void eprom_w(struct net_device *dev,short bit)

short eprom_r(struct net_device *dev)
{
	short bit;
	u8 bit;

	bit=(read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT) );
	read_nic_byte_E(dev, EPROM_CMD, &bit);
	udelay(EPROM_DELAY);

	if (bit) return 1;
	if (bit & EPROM_R_BIT)
		return 1;

	return 0;
}

+4 −4
Original line number Diff line number Diff line
@@ -1205,10 +1205,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb);
u32 read_cam(struct net_device *dev, u8 addr);
void write_cam(struct net_device *dev, u8 addr, u32 data);

u8 read_nic_byte(struct net_device *dev, int x);
u8 read_nic_byte_E(struct net_device *dev, int x);
u32 read_nic_dword(struct net_device *dev, int x);
u16 read_nic_word(struct net_device *dev, int x) ;
int read_nic_byte(struct net_device *dev, int x, u8 *data);
int read_nic_byte_E(struct net_device *dev, int x, u8 *data);
int read_nic_dword(struct net_device *dev, int x, u32 *data);
int read_nic_word(struct net_device *dev, int x, u16 *data);
void write_nic_byte(struct net_device *dev, int x,u8 y);
void write_nic_byte_E(struct net_device *dev, int x,u8 y);
void write_nic_word(struct net_device *dev, int x,u16 y);
+75 −59
Original line number Diff line number Diff line
@@ -258,8 +258,11 @@ void write_cam(struct net_device *dev, u8 addr, u32 data)

u32 read_cam(struct net_device *dev, u8 addr)
{
	u32 data;

	write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff));
	return read_nic_dword(dev, 0xa8);
	read_nic_dword(dev, 0xa8, &data);
	return data;
}

void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
@@ -276,21 +279,22 @@ void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
		netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n", status);
}

u8 read_nic_byte_E(struct net_device *dev, int indx)
int read_nic_byte_E(struct net_device *dev, int indx, u8 *data)
{
	int status;
	u8 data;
	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
	struct usb_device *udev = priv->udev;

	status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
				 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
				 indx|0xfe00, 0, &data, 1, HZ / 2);
				 indx|0xfe00, 0, data, 1, HZ / 2);

	if (status < 0)
		netdev_err(dev, "read_nic_byte_E TimeOut! status: %d\n", status);
	if (status < 0) {
		netdev_err(dev, "%s failure status: %d\n", __func__, status);
		return status;
	}

	return data;
	return 0;
}
//as 92U has extend page from 4 to 16, so modify functions below.
void write_nic_byte(struct net_device *dev, int indx, u8 data)
@@ -349,28 +353,28 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data)



u8 read_nic_byte(struct net_device *dev, int indx)
int read_nic_byte(struct net_device *dev, int indx, u8 *data)
{
	u8 data;
	int status;
	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
	struct usb_device *udev = priv->udev;

	status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
				 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
				 (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 1, HZ / 2);
				 (indx&0xff)|0xff00, (indx>>8)&0x0f, data, 1, HZ / 2);

	if (status < 0)
		netdev_err(dev, "read_nic_byte TimeOut! status: %d\n", status);
	if (status < 0) {
		netdev_err(dev, "%s failure status: %d\n", __func__, status);
		return status;
	}

	return data;
	return 0;
}



u16 read_nic_word(struct net_device *dev, int indx)
int read_nic_word(struct net_device *dev, int indx, u16 *data)
{
	u16 data;
	int status;
	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
	struct usb_device *udev = priv->udev;
@@ -378,34 +382,36 @@ u16 read_nic_word(struct net_device *dev, int indx)
	status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
				 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
				 (indx&0xff)|0xff00, (indx>>8)&0x0f,
				 &data, 2, HZ / 2);
				 data, 2, HZ / 2);

	if (status < 0)
		netdev_err(dev, "read_nic_word TimeOut! status: %d\n", status);
	if (status < 0) {
		netdev_err(dev, "%s failure status: %d\n", __func__, status);
		return status;
	}

	return data;
	return 0;
}

u16 read_nic_word_E(struct net_device *dev, int indx)
int read_nic_word_E(struct net_device *dev, int indx, u16 *data)
{
	u16 data;
	int status;
	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
	struct usb_device *udev = priv->udev;

	status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
				 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
				 indx|0xfe00, 0, &data, 2, HZ / 2);
				 indx|0xfe00, 0, data, 2, HZ / 2);

	if (status < 0)
		netdev_err(dev, "read_nic_word TimeOut! status: %d\n", status);
	if (status < 0) {
		netdev_err(dev, "%s failure status: %d\n", __func__, status);
		return status;
	}

	return data;
	return 0;
}

u32 read_nic_dword(struct net_device *dev, int indx)
int read_nic_dword(struct net_device *dev, int indx, u32 *data)
{
	u32 data;
	int status;

	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
@@ -414,12 +420,14 @@ u32 read_nic_dword(struct net_device *dev, int indx)
	status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
				 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
				 (indx&0xff)|0xff00, (indx>>8)&0x0f,
				 &data, 4, HZ / 2);
				 data, 4, HZ / 2);

	if (status < 0)
		netdev_err(dev, "read_nic_dword TimeOut! status:%d\n", status);
	if (status < 0) {
		netdev_err(dev, "%s failure status: %d\n", __func__, status);
		return status;
	}

	return data;
	return 0;
}

/* u8 read_phy_cck(struct net_device *dev, u8 adr); */
@@ -465,30 +473,37 @@ static int proc_get_registers(struct seq_file *m, void *v)
{
	struct net_device *dev = m->private;
	int i, n, max = 0xff;
	u8 byte_rd;

	seq_puts(m, "\n####################page 0##################\n ");

	for (n = 0; n <= max;) {
		seq_printf(m, "\nD:  %2x > ", n);

		for (i = 0; i < 16 && n <= max; i++, n++)
			seq_printf(m, "%2x ", read_nic_byte(dev, 0x000|n));
		for (i = 0; i < 16 && n <= max; i++, n++) {
			read_nic_byte(dev, 0x000|n, &byte_rd);
			seq_printf(m, "%2x ", byte_rd);
		}
	}

	seq_puts(m, "\n####################page 1##################\n ");
	for (n = 0; n <= max;) {
		seq_printf(m, "\nD:  %2x > ", n);

		for (i = 0; i < 16 && n <= max; i++, n++)
			seq_printf(m, "%2x ", read_nic_byte(dev, 0x100|n));
		for (i = 0; i < 16 && n <= max; i++, n++) {
			read_nic_byte(dev, 0x100|n, &byte_rd);
			seq_printf(m, "%2x ", byte_rd);
		}
	}

	seq_puts(m, "\n####################page 3##################\n ");
	for (n = 0; n <= max;) {
		seq_printf(m, "\nD:  %2x > ", n);

		for (i = 0; i < 16 && n <= max; i++, n++)
			seq_printf(m, "%2x ", read_nic_byte(dev, 0x300|n));
		for (i = 0; i < 16 && n <= max; i++, n++) {
			read_nic_byte(dev, 0x300|n, &byte_rd);
			seq_printf(m, "%2x ", byte_rd);
		}
	}

	seq_putc(m, '\n');
@@ -683,11 +698,11 @@ void dump_eprom(struct net_device *dev)
void rtl8192_set_mode(struct net_device *dev, int mode)
{
	u8 ecmd;
	ecmd = read_nic_byte(dev, EPROM_CMD);
	read_nic_byte(dev, EPROM_CMD, &ecmd);
	ecmd = ecmd & ~EPROM_CMD_OPERATING_MODE_MASK;
	ecmd = ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT);
	ecmd = ecmd & ~(1<<EPROM_CS_SHIFT);
	ecmd = ecmd & ~(1<<EPROM_CK_SHIFT);
	ecmd = ecmd & ~EPROM_CS_BIT;
	ecmd = ecmd & ~EPROM_CK_BIT;
	write_nic_byte(dev, EPROM_CMD, ecmd);
}

@@ -697,7 +712,7 @@ void rtl8192_update_msr(struct net_device *dev)
	struct r8192_priv *priv = ieee80211_priv(dev);
	u8 msr;

	msr  = read_nic_byte(dev, MSR);
	read_nic_byte(dev, MSR, &msr);
	msr &= ~MSR_LINK_MASK;

	/* do not change in link_state != WLAN_LINK_ASSOCIATED.
@@ -810,7 +825,7 @@ void rtl8192_set_rxconf(struct net_device *dev)
	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
	u32 rxconf;

	rxconf = read_nic_dword(dev, RCR);
	read_nic_dword(dev, RCR, &rxconf);
	rxconf = rxconf & ~MAC_FILTER_MASK;
	rxconf = rxconf | RCR_AMF;
	rxconf = rxconf | RCR_ADF;
@@ -846,10 +861,6 @@ void rtl8192_set_rxconf(struct net_device *dev)
	rxconf = rxconf | RCR_ONLYERLPKT;

	write_nic_dword(dev, RCR, rxconf);

#ifdef DEBUG_RX
	DMESG("rxconf: %x %x", rxconf, read_nic_dword(dev, RCR));
#endif
}
//wait to be removed
void rtl8192_rx_enable(struct net_device *dev)
@@ -871,7 +882,7 @@ void rtl8192_rtx_disable(struct net_device *dev)
	struct sk_buff *skb;
	struct rtl8192_rx_info *info;

	cmd = read_nic_byte(dev, CMDR);
	read_nic_byte(dev, CMDR, &cmd);
	write_nic_byte(dev, CMDR, cmd & ~(CR_TE|CR_RE));
	force_pci_posting(dev);
	mdelay(10);
@@ -1352,7 +1363,7 @@ void rtl8192_beacon_stop(struct net_device *dev)
	u8 msr, msrm, msr2;
	struct r8192_priv *priv = ieee80211_priv(dev);

	msr  = read_nic_byte(dev, MSR);
	read_nic_byte(dev, MSR, &msr);
	msrm = msr & MSR_LINK_MASK;
	msr2 = msr & ~MSR_LINK_MASK;

@@ -2049,7 +2060,7 @@ void rtl8192_link_change(struct net_device *dev)
	/*update timing params*/
	if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) {
		u32 reg = 0;
		reg = read_nic_dword(dev, RCR);
		read_nic_dword(dev, RCR, &reg);
		if (priv->ieee80211->state == IEEE80211_LINKED)
			priv->ReceiveConfig = reg |= RCR_CBSSID;
		else
@@ -2544,7 +2555,7 @@ static void rtl8192_get_eeprom_size(struct net_device *dev)
	u16 curCR = 0;
	struct r8192_priv *priv = ieee80211_priv(dev);
	RT_TRACE(COMP_EPROM, "===========>%s()\n", __func__);
	curCR = read_nic_word_E(dev, EPROM_CMD);
	read_nic_word_E(dev, EPROM_CMD, &curCR);
	RT_TRACE(COMP_EPROM, "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR);
	//whether need I consider BIT5?
	priv->epromtype = (curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46;
@@ -2896,7 +2907,7 @@ void rtl8192_hwconfig(struct net_device *dev)
		ratr_value &= ~(RATE_ALL_OFDM_2SS);
	write_nic_dword(dev, RATR0, ratr_value);
	write_nic_byte(dev, UFWP, 1);
	regTmp = read_nic_byte(dev, 0x313);
	read_nic_byte(dev, 0x313, &regTmp);
	regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff);
	write_nic_dword(dev, RRSR, regRRSR);

@@ -2925,6 +2936,7 @@ bool rtl8192_adapter_start(struct net_device *dev)
	u32 dwRegRead = 0;
	bool init_status = true;
	u8 SECR_value = 0x0;
	u8 tmp;
	RT_TRACE(COMP_INIT, "====>%s()\n", __func__);
	priv->Rf_Mode = RF_OP_By_SW_3wire;
	//for ASIC power on sequence
@@ -2938,7 +2950,7 @@ bool rtl8192_adapter_start(struct net_device *dev)
	priv->pFirmware->firmware_status = FW_STATUS_0_INIT;
	//config CPUReset Register
	//Firmware Reset or not?
	dwRegRead = read_nic_dword(dev, CPU_GEN);
	read_nic_dword(dev, CPU_GEN, &dwRegRead);
	if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT)
		dwRegRead |= CPU_GEN_SYSTEM_RESET; //do nothing here?
	else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY)
@@ -2953,7 +2965,7 @@ bool rtl8192_adapter_start(struct net_device *dev)
	//Loopback mode or not
	priv->LoopbackMode = RTL819xU_NO_LOOPBACK;

	dwRegRead = read_nic_dword(dev, CPU_GEN);
	read_nic_dword(dev, CPU_GEN, &dwRegRead);
	if (priv->LoopbackMode == RTL819xU_NO_LOOPBACK)
		dwRegRead = ((dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET);
	else if (priv->LoopbackMode == RTL819xU_MAC_LOOPBACK)
@@ -2967,7 +2979,8 @@ bool rtl8192_adapter_start(struct net_device *dev)
	udelay(500);

	//xiong add for new bitfile:usb suspend reset pin set to 1. //do we need?
	write_nic_byte_E(dev, 0x5f, (read_nic_byte_E(dev, 0x5f)|0x20));
	read_nic_byte_E(dev, 0x5f, &tmp);
	write_nic_byte_E(dev, 0x5f, tmp|0x20);

	//Set Hardware
	rtl8192_hwconfig(dev);
@@ -3095,7 +3108,8 @@ bool rtl8192_adapter_start(struct net_device *dev)

	if (priv->ResetProgress == RESET_TYPE_NORESET) {
		//if D or C cut
		u8 tmpvalue = read_nic_byte(dev, 0x301);
		u8 tmpvalue;
		read_nic_byte(dev, 0x301, &tmpvalue);
		if (tmpvalue == 0x03) {
			priv->bDcut = TRUE;
			RT_TRACE(COMP_POWER_TRACKING, "D-cut\n");
@@ -3156,8 +3170,9 @@ static struct net_device_stats *rtl8192_stats(struct net_device *dev)
bool HalTxCheckStuck819xUsb(struct net_device *dev)
{
	struct r8192_priv *priv = ieee80211_priv(dev);
	u16		RegTxCounter = read_nic_word(dev, 0x128);
	u16		RegTxCounter;
	bool		bStuck = FALSE;
	read_nic_word(dev, 0x128, &RegTxCounter);
	RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", __func__, RegTxCounter, priv->TxCounter);
	if (priv->TxCounter == RegTxCounter)
		bStuck = TRUE;
@@ -3204,10 +3219,11 @@ RESET_TYPE TxCheckStuck(struct net_device *dev)

bool HalRxCheckStuck819xUsb(struct net_device *dev)
{
	u16	RegRxCounter = read_nic_word(dev, 0x130);
	u16	RegRxCounter;
	struct r8192_priv *priv = ieee80211_priv(dev);
	bool bStuck = FALSE;
	static u8	rx_chk_cnt;
	read_nic_word(dev, 0x130, &RegRxCounter);
	RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__, RegRxCounter, priv->RxCounter);
	// If rssi is small, we should check rx for long time because of bad rx.
	// or maybe it will continuous silent reset every 2 seconds.
@@ -3494,7 +3510,7 @@ void CAM_read_entry(struct net_device *dev, u32 iIndex)

		//Check polling bit is clear
		while ((i--) >= 0) {
			ulStatus = read_nic_dword(dev, RWCAM);
			read_nic_dword(dev, RWCAM, &ulStatus);
			if (ulStatus & BIT31)
				continue;
			else
@@ -3502,7 +3518,7 @@ void CAM_read_entry(struct net_device *dev, u32 iIndex)
		}
		write_nic_dword(dev, RWCAM, target_command);
		RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A0: %x \n", target_command);
		target_content = read_nic_dword(dev, RCAMO);
		read_nic_dword(dev, RCAMO, &target_content);
		RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n", target_content);
	}
	printk("\n");
+25 −21
Original line number Diff line number Diff line
@@ -480,7 +480,7 @@ static void dm_check_rate_adaptive(struct net_device *dev)
		//
		// Check whether updating of RATR0 is required
		//
		currentRATR = read_nic_dword(dev, RATR0);
		read_nic_dword(dev, RATR0, &currentRATR);
		if(targetRATR !=  currentRATR)
		{
			u32 ratr_value;
@@ -634,7 +634,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
	//DbgPrint("hi, vivi, strange\n");
	for(i = 0;i <= 30; i++)
	{
		Pwr_Flag = read_nic_byte(dev, 0x1ba);
		read_nic_byte(dev, 0x1ba, &Pwr_Flag);

		if (Pwr_Flag == 0)
		{
@@ -642,9 +642,9 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
			continue;
		}
#ifdef RTL8190P
		Avg_TSSI_Meas = read_nic_word(dev, 0x1bc);
		read_nic_word(dev, 0x1bc, &Avg_TSSI_Meas);
#else
		Avg_TSSI_Meas = read_nic_word(dev, 0x13c);
		read_nic_word(dev, 0x13c, &Avg_TSSI_Meas);
#endif
		if(Avg_TSSI_Meas == 0)
		{
@@ -655,12 +655,12 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
		for(k = 0;k < 5; k++)
		{
#ifdef RTL8190P
			tmp_report[k] = read_nic_byte(dev, 0x1d8+k);
			read_nic_byte(dev, 0x1d8+k, &tmp_report[k]);
#else
			if(k !=4)
				tmp_report[k] = read_nic_byte(dev, 0x134+k);
				read_nic_byte(dev, 0x134+k, &tmp_report[k]);
			else
				tmp_report[k] = read_nic_byte(dev, 0x13e);
				read_nic_byte(dev, 0x13e, &tmp_report[k]);
#endif
			RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]);
		}
@@ -2397,6 +2397,7 @@ static void dm_initial_gain(
	u8					initial_gain=0;
	static u8				initialized, force_write;
	static u32			reset_cnt;
	u8				tmp;

	if(dm_digtable.dig_algorithm_switch)
	{
@@ -2437,7 +2438,8 @@ static void dm_initial_gain(
		reset_cnt = priv->reset_count;
	}

	if(dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1))
	read_nic_byte(dev, rOFDM0_XAAGCCore1, &tmp);
	if (dm_digtable.pre_ig_value != tmp)
		force_write = 1;

	{
@@ -2727,7 +2729,8 @@ static void dm_check_edca_turbo(
			// TODO:  Modified this part and try to set acm control in only 1 IO processing!!

					PACI_AIFSN	pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]);
					u8		AcmCtrl = read_nic_byte(dev, AcmHwCtrl);
					u8		AcmCtrl;
					read_nic_byte(dev, AcmHwCtrl, &AcmCtrl);
					if(pAciAifsn->f.ACM)
					{ // ACM bit is 1.
						AcmCtrl |= AcmHw_BeqEn;
@@ -2881,7 +2884,7 @@ static void dm_check_pbc_gpio(struct net_device *dev)
	u8 tmp1byte;


	tmp1byte = read_nic_byte(dev,GPI);
	read_nic_byte(dev, GPI, &tmp1byte);
	if(tmp1byte == 0xff)
		return;

@@ -2933,7 +2936,7 @@ extern void dm_gpio_change_rf_callback(struct work_struct *work)
		{
			// 0x108 GPIO input register is read only
			//set 0x108 B1= 1: RF-ON; 0: RF-OFF.
			tmp1byte = read_nic_byte(dev,GPI);
			read_nic_byte(dev, GPI, &tmp1byte);

			eRfPowerStateToSet = (tmp1byte&BIT1) ?  eRfOn : eRfOff;

@@ -2996,7 +2999,7 @@ extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work)

	/* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will
	   always be the same. We only read 0xc04 now. */
	rfpath = read_nic_byte(dev, 0xc04);
	read_nic_byte(dev, 0xc04, &rfpath);

	// Check Bit 0-3, it means if RF A-D is enabled.
	for (i = 0; i < RF90_PATH_MAX; i++)
@@ -3052,12 +3055,13 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev)

	if(!cck_Rx_Path_initialized)
	{
		DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf);
		read_nic_byte(dev, 0xa07, &DM_RxPathSelTable.cck_Rx_path);
		DM_RxPathSelTable.cck_Rx_path &= 0xf;
		cck_Rx_Path_initialized = 1;
	}

	DM_RxPathSelTable.disabledRF = 0xf;
	DM_RxPathSelTable.disabledRF &= ~(read_nic_byte(dev, 0xc04));
	read_nic_byte(dev, 0xc04, &DM_RxPathSelTable.disabledRF);
	DM_RxPathSelTable.disabledRF = ~DM_RxPathSelTable.disabledRF & 0xf;

	if(priv->ieee80211->mode == WIRELESS_MODE_B)
	{
@@ -3731,17 +3735,17 @@ extern void dm_shadow_init(struct net_device *dev)
	for (page = 0; page < 5; page++)
		for (offset = 0; offset < 256; offset++)
		{
			dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
			read_nic_byte(dev, offset+page*256, &dm_shadow[page][offset]);
			//DbgPrint("P-%d/O-%02x=%02x\r\n", page, offset, DM_Shadow[page][offset]);
		}

	for (page = 8; page < 11; page++)
		for (offset = 0; offset < 256; offset++)
			dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
			read_nic_byte(dev, offset+page*256, &dm_shadow[page][offset]);

	for (page = 12; page < 15; page++)
		for (offset = 0; offset < 256; offset++)
			dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
			read_nic_byte(dev, offset+page*256, &dm_shadow[page][offset]);

}   /* dm_shadow_init */

@@ -3858,14 +3862,14 @@ static void dm_check_txrateandretrycount(struct net_device *dev)
	struct ieee80211_device *ieee = priv->ieee80211;
	//for 11n tx rate
//	priv->stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
	ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
	read_nic_byte(dev, Current_Tx_Rate_Reg, &ieee->softmac_stats.CurrentShowTxate);
	//printk("=============>tx_rate_reg:%x\n", ieee->softmac_stats.CurrentShowTxate);
	//for initial tx rate
//	priv->stats.last_packet_rate = read_nic_byte(dev, Initial_Tx_Rate_Reg);
	ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg);
	read_nic_byte(dev, Initial_Tx_Rate_Reg, &ieee->softmac_stats.last_packet_rate);
	//for tx tx retry count
//	priv->stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
	ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
	read_nic_dword(dev, Tx_Retry_Count_Reg, &ieee->softmac_stats.txretrycount);
}

static void dm_send_rssi_tofw(struct net_device *dev)
+5 −4
Original line number Diff line number Diff line
@@ -388,10 +388,11 @@ enum _RTL8192Usb_HW {
#define EPROM_CMD_NORMAL 0
#define EPROM_CMD_LOAD 1
#define EPROM_CMD_PROGRAM 2
#define EPROM_CS_SHIFT 3
#define EPROM_CK_SHIFT 2
#define EPROM_W_SHIFT 1
#define EPROM_R_SHIFT 0
#define EPROM_CS_BIT BIT(3)
#define EPROM_CK_BIT BIT(2)
#define EPROM_W_BIT  BIT(1)
#define EPROM_R_BIT  BIT(0)

	MAC0			= 0x000,
	MAC1			= 0x001,
	MAC2			= 0x002,
Loading