[U-Boot-Users] [RFC][PATCH 1/1] Add board_eth_init() function

Shinya Kuribayashi skuribay at ruby.dti.ne.jp
Sun Mar 23 07:19:55 CET 2008


Vlad Lungu wrote:
> Shinya Kuribayashi wrote:
>>> +int board_eth_init(bd_t *bis) __attribute((weak, 
>>> alias("__board_eth_init")));
>>> +
>>> #ifdef CFG_GT_6426x
>>> extern int gt6426x_eth_initialize(bd_t *bis);
>>> #endif
>>>     
>>
>> [This comment is not for Ben, but for everyone.]
>>
>> Do we need such alias to empty function? Only __attribute((weak)) is
>> enough for me. If we have some default behavior which isn't empty, I
>> can see the weak & alias. Thought?
>>
>>   
> Weak functions with no alias are NULL. You can test the value of 
> board_eth_init before calling
> or you can provide an alias so there are no surprises. If you don't do 
> one or the other... exceptions happen.
> Personally, I prefer to have an alias.

Thanks for clarifying. Now what I feel annoying is turned out to having
an empty function with *another* name, such as `__foo() against foo()'.

Find the patch below:
 - change weak usage
 - change netdev.h usage

FWIW I think this is easier to read wrt the relationship between `weak'
and `overridden'. I'm not going to argue with someone, though.

---

 board/atum8548/atum8548.c |    2 ++
 include/netdev.h          |    2 +-
 net/eth.c                 |    4 +---
 3 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/board/atum8548/atum8548.c b/board/atum8548/atum8548.c
index d6bd8ae..01a5134 100644
--- a/board/atum8548/atum8548.c
+++ b/board/atum8548/atum8548.c
@@ -421,6 +421,8 @@ ft_board_setup(void *blob, bd_t *bd)
 
 int board_eth_init(bd_t *bis)
 {
+	extern int tsec_initialize(bd_t * bis, int index, char *devname);
+
 #if defined(CONFIG_TSEC1)
 	tsec_initialize(bis, 0, CONFIG_TSEC1_NAME);
 #endif
diff --git a/include/netdev.h b/include/netdev.h
index 19195fa..7cba0a7 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -28,7 +28,7 @@
 #ifndef _NETDEV_H_
 #define _NETDEV_H_
 
-int tsec_initialize(bd_t * bis, int index, char *devname);
+extern int board_eth_init(bd_t *bis);
 
 #endif /* _NETDEV_H_ */
 
diff --git a/net/eth.c b/net/eth.c
index 3d02272..80432a1 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -28,13 +28,11 @@
 
 #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI)
 
-int __board_eth_init(bd_t *bis)
+int __attribute((weak)) board_eth_init(bd_t *bis)
 {
 	return 0;
 }
 
-int board_eth_init(bd_t *bis) __attribute((weak, alias("__board_eth_init")));
-
 #ifdef CFG_GT_6426x
 extern int gt6426x_eth_initialize(bd_t *bis);
 #endif




More information about the U-Boot mailing list