transport: store the configuration in the transport data structure.

This will allow modules to read out various user options.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-10 21:41:01 +02:00
parent bbbc0cd451
commit 3189a7bc0a
5 changed files with 14 additions and 5 deletions

View File

@ -85,7 +85,7 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
pmc->domain_number = domain_number; pmc->domain_number = domain_number;
pmc->transport_specific = transport_specific; pmc->transport_specific = transport_specific;
pmc->transport = transport_create(transport_type); pmc->transport = transport_create(cfg, transport_type);
if (!pmc->transport) { if (!pmc->transport) {
pr_err("failed to create transport"); pr_err("failed to create transport");
goto failed; goto failed;

3
port.c
View File

@ -2495,6 +2495,7 @@ struct port *port_open(int phc_index,
struct interface *interface, struct interface *interface,
struct clock *clock) struct clock *clock)
{ {
struct config *cfg = clock_config(clock);
struct port *p = malloc(sizeof(*p)); struct port *p = malloc(sizeof(*p));
if (!p) if (!p)
@ -2524,7 +2525,7 @@ struct port *port_open(int phc_index,
p->pod = interface->pod; p->pod = interface->pod;
p->name = interface->name; p->name = interface->name;
p->clock = clock; p->clock = clock;
p->trp = transport_create(interface->transport); p->trp = transport_create(cfg, interface->transport);
if (!p->trp) if (!p->trp)
goto err_port; goto err_port;
p->timestamping = timestamping; p->timestamping = timestamping;

View File

@ -87,7 +87,8 @@ enum transport_type transport_type(struct transport *t)
return t->type; 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; struct transport *t = NULL;
switch (type) { switch (type) {
@ -108,8 +109,10 @@ struct transport *transport_create(enum transport_type type)
case TRANS_PROFINET: case TRANS_PROFINET:
break; break;
} }
if (t) if (t) {
t->type = type; t->type = type;
t->cfg = cfg;
}
return t; return t;
} }

View File

@ -26,6 +26,8 @@
#include "fd.h" #include "fd.h"
#include "msg.h" #include "msg.h"
struct config;
/* Values from networkProtocol enumeration 7.4.1 Table 3 */ /* Values from networkProtocol enumeration 7.4.1 Table 3 */
enum transport_type { enum transport_type {
/* 0 is Reserved in spec. Use it for UDS */ /* 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. * Allocate an instance of the specified transport.
* @param config Pointer to the configuration database.
* @param type Which transport to obtain. * @param type Which transport to obtain.
* @return Pointer to a transport instance on success, NULL otherwise. * @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. * Free an instance of a transport.

View File

@ -28,6 +28,7 @@
struct transport { struct transport {
enum transport_type type; enum transport_type type;
struct config *cfg;
int (*close)(struct transport *t, struct fdarray *fda); int (*close)(struct transport *t, struct fdarray *fda);