Skip to contentSkip to conversation

smc911x: Fix SMC_WRITE_EEPROM_CMD macro

PATCH In review [email protected] 2 participants 4 messages Sep 13, 2006 – Sep 14, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/12 smc911x: Fix SMC_WRITE_EEPROM_CMD macro

SMC_WRITE_EEPROM_CMD macro is wrong

drivers/net/smc911x.h +7 -3
Index: linux-2.6.18-rc4/drivers/net/smc911x.h
===================================================================
@@ -827,9 +828,13 @@
 
 #define SMC_WRITE_EEPROM_CMD(cmd, addr)					\
 	do {								\
-		while (SMC_GET_E2P_CMD() & MAC_CSR_CMD_CSR_BUSY_);	\
-		SMC_SET_MAC_CMD(MAC_CSR_CMD_R_NOT_W_ | a );		\
-		while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_);	\
+		while (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)		\
+			cpu_relax();					\
+		SMC_SET_E2P_DATA((v) & 0xFF);				\
+		SMC_SET_E2P_CMD(E2P_CMD_EPC_BUSY_ | 			\
+				(cmd) << 28 | ((addr) & 0xFF));		\
+		while (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)		\
+			cpu_relax();					\
 	} while (0)
 
 #endif	 /* _SMC911X_H_ */
#1 lore raw

[email protected] <[email protected]> :
[...]

drivers/net/smc911x.h line 838

Quoted 13 lines

#define SMC_WRITE_EEPROM_CMD(cmd, addr) \

drivers/net/smc911x.h +7 -3
 	do {								\
-		while (SMC_GET_E2P_CMD() & MAC_CSR_CMD_CSR_BUSY_);	\
-		SMC_SET_MAC_CMD(MAC_CSR_CMD_R_NOT_W_ | a );		\
-		while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_);	\
+		while (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)		\
+			cpu_relax();					\
+		SMC_SET_E2P_DATA((v) & 0xFF);				\
+		SMC_SET_E2P_CMD(E2P_CMD_EPC_BUSY_ | 			\
+				(cmd) << 28 | ((addr) & 0xFF));		\
+		while (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)		\
+			cpu_relax();					\
 	} while (0)

Macro abuse. It should be a function.

Signature · 1 line
Ueimor
#2 lore raw

Hi,

Thanks for your comments.

Quoted 17 lines · Francois Romieu

[email protected] <[email protected]> :
[...]

drivers/net/smc911x.h line 838

Quoted 13 lines

#define SMC_WRITE_EEPROM_CMD(cmd, addr) \

drivers/net/smc911x.h +7 -3
 	do {								\
-		while (SMC_GET_E2P_CMD() & MAC_CSR_CMD_CSR_BUSY_);	\
-		SMC_SET_MAC_CMD(MAC_CSR_CMD_R_NOT_W_ | a );		\
-		while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_);	\
+		while (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)		\
+			cpu_relax();					\
+		SMC_SET_E2P_DATA((v) & 0xFF);				\
+		SMC_SET_E2P_CMD(E2P_CMD_EPC_BUSY_ | 			\
+				(cmd) << 28 | ((addr) & 0xFF));		\
+		while (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)		\
+			cpu_relax();					\
 	} while (0)

Macro abuse. It should be a function.

Yes but I got smc911x.h and smc91x.h as a basis. In the smc911x.c there are macros which is longer than it, e.g. SMC_GET_MII. In the same way, smc91x.h contains even more longer like SMC_PUSH_DATA. But, of course, it doesnt mean they are correct. It's two different things. Just want to explain it.

Do you think if I convert them(smc911x.h) to static inline, would that be correct?

--
Bora SAHIN