arm:replace ifdef's by runtime checks in the lan8710a driver.

Change-Id: I1f345240b88362658e987a85f1642324471119c3
This commit is contained in:
Kees Jongenburger 2014-02-10 12:19:33 +01:00
parent 7e11828c6e
commit 5ec8c93e95

View file

@ -3,12 +3,12 @@
#include <net/gen/ether.h> #include <net/gen/ether.h>
#include <net/gen/eth_io.h> #include <net/gen/eth_io.h>
#include <minix/sysutil.h> #include <minix/sysutil.h>
#include <minix/board.h>
#include "assert.h" #include "assert.h"
#include "lan8710a.h" #include "lan8710a.h"
#include "lan8710a_reg.h" #include "lan8710a_reg.h"
/* Local functions */ /* Local functions */
#ifdef AM335X
static void lan8710a_readv_s(message *m, int from_int); static void lan8710a_readv_s(message *m, int from_int);
static void lan8710a_writev_s(message *m, int from_int); static void lan8710a_writev_s(message *m, int from_int);
static void lan8710a_conf(message *m); static void lan8710a_conf(message *m);
@ -45,7 +45,6 @@ static lan8710a_t lan8710a_state;
static void sef_local_startup(void); static void sef_local_startup(void);
static int sef_cb_init_fresh(int type, sef_init_info_t *info); static int sef_cb_init_fresh(int type, sef_init_info_t *info);
static void sef_cb_signal_handler(int signal); static void sef_cb_signal_handler(int signal);
#endif /* AM335X */
/*============================================================================* /*============================================================================*
* main * * main *
@ -53,52 +52,56 @@ static void sef_cb_signal_handler(int signal);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
#ifdef AM335X
/* Local variables */ /* Local variables */
message m; message m;
int r; int r;
int ipc_status; int ipc_status;
struct machine machine ;
/* SEF local startup */ sys_getmachine(&machine);
env_setargs(argc, argv); if ( BOARD_IS_BB(machine.board_id)) {
sef_local_startup();
/* Main driver loop */ /* SEF local startup */
for (;;) { env_setargs(argc, argv);
r = netdriver_receive(ANY, &m, &ipc_status); sef_local_startup();
if (r != OK) {
panic("netdriver_receive failed: %d", r);
}
if (is_ipc_notify(ipc_status)) { /* Main driver loop */
switch (_ENDPOINT_P(m.m_source)) { for (;;) {
case HARDWARE: r = netdriver_receive(ANY, &m, &ipc_status);
lan8710a_interrupt(&m); if (r != OK) {
break; panic("netdriver_receive failed: %d", r);
} }
} else {
switch (m.m_type) { if (is_ipc_notify(ipc_status)) {
case DL_WRITEV_S: switch (_ENDPOINT_P(m.m_source)) {
lan8710a_writev_s(&m, FALSE); case HARDWARE:
break; lan8710a_interrupt(&m);
case DL_READV_S: break;
lan8710a_readv_s(&m, FALSE); }
break; } else {
case DL_CONF: switch (m.m_type) {
lan8710a_conf(&m); case DL_WRITEV_S:
break; lan8710a_writev_s(&m, FALSE);
case DL_GETSTAT_S: break;
lan8710a_getstat(&m); case DL_READV_S:
break; lan8710a_readv_s(&m, FALSE);
default: break;
panic("Illegal message: %d", m.m_type); case DL_CONF:
lan8710a_conf(&m);
break;
case DL_GETSTAT_S:
lan8710a_getstat(&m);
break;
default:
panic("Illegal message: %d", m.m_type);
}
} }
} }
} }
#endif /* AM335X */
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#ifdef AM335X
/*============================================================================* /*============================================================================*
* sef_local_startup * * sef_local_startup *
*============================================================================*/ *============================================================================*/
@ -1236,4 +1239,3 @@ lan8710a_t *e;
panic("send() failed: %d", r); panic("send() failed: %d", r);
} }
} }
#endif /* AM335X */