Commit f44d4a0a authored by Alessandro Rubini's avatar Alessandro Rubini

general: use symbolic names for configuration values

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent a433215b
......@@ -72,12 +72,13 @@ int main(int argc, char **argv)
ppi->glbs = ppg;
ppi->iface_name = ppi->cfg.iface_name;
ppi->ethernet_mode = (ppi->cfg.proto == 0) ? 1 : 0;
if (ppi->cfg.role == 1) {
/* this old-fashioned "ethernet_mode" is a single bit */
ppi->ethernet_mode = (ppi->cfg.proto == PPSI_PROTO_RAW);
if (ppi->cfg.role == PPSI_ROLE_MASTER) {
ppi->master_only = 1;
ppi->slave_only = 0;
}
else if (ppi->cfg.role == 2) {
else if (ppi->cfg.role == PPSI_ROLE_SLAVE) {
ppi->master_only = 0;
ppi->slave_only = 1;
}
......
......@@ -101,12 +101,13 @@ int main(int argc, char **argv)
ppi->glbs = ppg;
ppi->iface_name = ppi->cfg.iface_name;
ppi->ethernet_mode = (ppi->cfg.proto == 0) ? 1 : 0;
if (ppi->cfg.role == 1) {
/* this old-fashioned "ethernet_mode" is a single bit */
ppi->ethernet_mode = (ppi->cfg.proto == PPSI_PROTO_RAW);
if (ppi->cfg.role == PPSI_ROLE_MASTER) {
ppi->master_only = 1;
ppi->slave_only = 0;
}
else if (ppi->cfg.role == 2) {
else if (ppi->cfg.role == PPSI_ROLE_SLAVE) {
ppi->master_only = 0;
ppi->slave_only = 1;
}
......
......@@ -258,6 +258,17 @@ extern int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv);
extern int pp_config_file(struct pp_globals *ppg, int *argcp, char **argv,
char *default_name, char *default_conf);
#define PPSI_PROTO_RAW 0
#define PPSI_PROTO_UDP 1
#define PPSI_ROLE_AUTO 0
#define PPSI_ROLE_MASTER 1
#define PPSI_ROLE_SLAVE 2
#define PPSI_EXT_NONE 0
#define PPSI_EXT_WR 1
/* Servo */
extern void pp_servo_init(struct pp_instance *ppi);
extern void pp_servo_got_sync(struct pp_instance *ppi); /* got t1 and t2 */
......
......@@ -37,12 +37,12 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts)
* wr_data. May I move it to pp_globals? */
ppg->pp_instances[i].ext_data = &wr_data;
if (ppi->cfg.ext) {
if (ppi->cfg.ext == PPSI_EXT_WR) {
switch (ppi->cfg.role) {
case 1:
case PPSI_ROLE_MASTER:
WR_DSPOR(ppi)->wrConfig = WR_M_ONLY;
break;
case 2:
case PPSI_ROLE_SLAVE:
WR_DSPOR(ppi)->wrConfig = WR_S_ONLY;
break;
default:
......
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