From 3189a7bc0a5cd673a1ef5794b6117b502c219e70 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Mon, 10 Aug 2015 21:41:01 +0200 Subject: [PATCH] transport: store the configuration in the transport data structure. This will allow modules to read out various user options. Signed-off-by: Richard Cochran --- pmc_common.c | 2 +- port.c | 3 ++- transport.c | 7 +++++-- transport.h | 6 +++++- transport_private.h | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pmc_common.c b/pmc_common.c index 0a365f5..d92b0cd 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -85,7 +85,7 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type, pmc->domain_number = domain_number; pmc->transport_specific = transport_specific; - pmc->transport = transport_create(transport_type); + pmc->transport = transport_create(cfg, transport_type); if (!pmc->transport) { pr_err("failed to create transport"); goto failed; diff --git a/port.c b/port.c index 3ed5e7b..028df32 100644 --- a/port.c +++ b/port.c @@ -2495,6 +2495,7 @@ struct port *port_open(int phc_index, struct interface *interface, struct clock *clock) { + struct config *cfg = clock_config(clock); struct port *p = malloc(sizeof(*p)); if (!p) @@ -2524,7 +2525,7 @@ struct port *port_open(int phc_index, p->pod = interface->pod; p->name = interface->name; p->clock = clock; - p->trp = transport_create(interface->transport); + p->trp = transport_create(cfg, interface->transport); if (!p->trp) goto err_port; p->timestamping = timestamping; diff --git a/transport.c b/transport.c index fc18740..d24c05b 100644 --- a/transport.c +++ b/transport.c @@ -87,7 +87,8 @@ enum transport_type transport_type(struct transport *t) return t->type; } -struct transport *transport_create(enum transport_type type) +struct transport *transport_create(struct config *cfg, + enum transport_type type) { struct transport *t = NULL; switch (type) { @@ -108,8 +109,10 @@ struct transport *transport_create(enum transport_type type) case TRANS_PROFINET: break; } - if (t) + if (t) { t->type = type; + t->cfg = cfg; + } return t; } diff --git a/transport.h b/transport.h index 8e0d421..5d6ba98 100644 --- a/transport.h +++ b/transport.h @@ -26,6 +26,8 @@ #include "fd.h" #include "msg.h" +struct config; + /* Values from networkProtocol enumeration 7.4.1 Table 3 */ enum transport_type { /* 0 is Reserved in spec. Use it for UDS */ @@ -123,10 +125,12 @@ int transport_protocol_addr(struct transport *t, uint8_t *addr); /** * Allocate an instance of the specified transport. + * @param config Pointer to the configuration database. * @param type Which transport to obtain. * @return Pointer to a transport instance on success, NULL otherwise. */ -struct transport *transport_create(enum transport_type type); +struct transport *transport_create(struct config *cfg, + enum transport_type type); /** * Free an instance of a transport. diff --git a/transport_private.h b/transport_private.h index 3e0ba9a..b54f32a 100644 --- a/transport_private.h +++ b/transport_private.h @@ -28,6 +28,7 @@ struct transport { enum transport_type type; + struct config *cfg; int (*close)(struct transport *t, struct fdarray *fda);