Commit b6c0719e authored by Adam Wujek's avatar Adam Wujek 💬

userspace/libwr: remove function hal_port_lookup

hal_port_lookup was redundant with hal_lookup_port.
File hal_shmem.c is not needed anymore.
add const qualifier to name parameter of hal_lookup_port function
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 37315c81
OBJS = init.o fpga_io.o util.o pps_gen.o i2c.o shw_io.o i2c_bitbang.o \
i2c_fpga_reg.o pio.o libshw_i2c.o i2c_sfp.o fan.o i2c_io.o hwiu.o \
ptpd_netif.o hal_client.o \
shmem.o hal_shmem.o rt_client.o \
shmem.o rt_client.o \
dot-config.o wrs-msg.o
LIB = libwr.a
......
#include <string.h>
#include <math.h>
#include <libwr/hal_shmem.h>
#include <libwr/switch_hw.h>
/*
* The following functions were in wrsw_hal/hal_ports (the callee)
* but with moving to shared memory they are run in the caller.
*/
extern struct hal_port_state *ports; /* FIXME: temporarily */
extern int hal_port_nports;
struct hal_port_state *hal_port_lookup(struct hal_port_state *ports,
const char *name)
{
int i;
for (i = 0; i < HAL_MAX_PORTS; i++)
if (ports[i].in_use && !strcmp(name, ports[i].name))
return &ports[i];
return NULL;
}
......@@ -110,15 +110,6 @@ struct hal_shmem_header {
struct hal_port_state *ports;
};
/*
* The following functions were in userspace/wrsw_hal/hal_ports.c,
* and are used to marshall data for the RPC format. Now that we
* offer shared memory, it is the caller who must convert data to
* the expected format (which remains the RPC one as I write this).
*/
struct hal_port_state *hal_port_lookup(struct hal_port_state *ports,
const char *name);
static inline int state_up(int state)
{
return (state != HAL_PORT_STATE_LINK_DOWN
......@@ -126,7 +117,8 @@ static inline int state_up(int state)
}
static inline struct hal_port_state *hal_lookup_port(
struct hal_port_state *ports, int nports, char *name)
struct hal_port_state *ports, int nports,
const char *name)
{
int i;
......
......@@ -551,7 +551,8 @@ void hal_port_update_all()
int hal_port_enable_tracking(const char *port_name)
{
const struct hal_port_state *p = hal_port_lookup(ports, port_name);
const struct hal_port_state *p = hal_lookup_port(ports,
hal_port_nports, port_name);
if (!p)
return -1;
......@@ -563,7 +564,8 @@ int hal_port_enable_tracking(const char *port_name)
* WR link setup phase. */
int hal_port_start_lock(const char *port_name, int priority)
{
struct hal_port_state *p = hal_port_lookup(ports, port_name);
struct hal_port_state *p = hal_lookup_port(ports, hal_port_nports,
port_name);
if (!p)
return -1;
......@@ -585,7 +587,8 @@ int hal_port_start_lock(const char *port_name, int priority)
/* Returns 1 if the port is locked */
int hal_port_check_lock(const char *port_name)
{
const struct hal_port_state *p = hal_port_lookup(ports, port_name);
const struct hal_port_state *p = hal_lookup_port(ports,
hal_port_nports, port_name);
struct rts_pll_state *hs = &hal_port_rts_state;
if (!p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment