ptp4l: pass struct interface directly instead of passing it's sub arguments
the port_open function takes a large number of command options, a few of which are actually all values of struct interface. This patch modifies the port_open call to take a struct interface value instead of all the other values. This simplifies the overall work necessary and allows for adding new port configuration values by appending them to the struct interface Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>master
parent
0499513f1e
commit
64dcf257e3
3
clock.c
3
clock.c
|
@ -267,8 +267,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count,
|
|||
c->fault_timeout = FAULT_RESET_SECONDS;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
c->port[i] = port_open(pod, phc_index, iface[i].name, iface[i].transport,
|
||||
timestamping, 1+i, iface[i].dm, c);
|
||||
c->port[i] = port_open(pod, phc_index, timestamping, 1+i, &iface[i], c);
|
||||
if (!c->port[i]) {
|
||||
pr_err("failed to open port %s", iface[i].name);
|
||||
return NULL;
|
||||
|
|
12
port.c
12
port.c
|
@ -1539,11 +1539,9 @@ struct ptp_message *port_management_reply(struct PortIdentity pid,
|
|||
|
||||
struct port *port_open(struct port_defaults *pod,
|
||||
int phc_index,
|
||||
char *name,
|
||||
enum transport_type transport,
|
||||
enum timestamp_type timestamping,
|
||||
int number,
|
||||
enum delay_mechanism dm,
|
||||
struct interface *interface,
|
||||
struct clock *clock)
|
||||
{
|
||||
struct port *p = malloc(sizeof(*p));
|
||||
|
@ -1554,7 +1552,7 @@ struct port *port_open(struct port_defaults *pod,
|
|||
|
||||
memset(p, 0, sizeof(*p));
|
||||
|
||||
if (sk_interface_phc(name, &checked_phc_index))
|
||||
if (sk_interface_phc(interface->name, &checked_phc_index))
|
||||
pr_warning("port %d: get_ts_info not supported", number);
|
||||
else if (phc_index >= 0 && phc_index != checked_phc_index) {
|
||||
pr_err("port %d: PHC device mismatch", number);
|
||||
|
@ -1564,9 +1562,9 @@ struct port *port_open(struct port_defaults *pod,
|
|||
}
|
||||
|
||||
p->pod = *pod;
|
||||
p->name = name;
|
||||
p->name = interface->name;
|
||||
p->clock = clock;
|
||||
p->trp = transport_create(transport);
|
||||
p->trp = transport_create(interface->transport);
|
||||
if (!p->trp) {
|
||||
free(p);
|
||||
return NULL;
|
||||
|
@ -1575,7 +1573,7 @@ struct port *port_open(struct port_defaults *pod,
|
|||
p->portIdentity.clockIdentity = clock_identity(clock);
|
||||
p->portIdentity.portNumber = number;
|
||||
p->state = PS_INITIALIZING;
|
||||
p->delayMechanism = dm;
|
||||
p->delayMechanism = interface->dm;
|
||||
p->versionNumber = PTP_VERSION;
|
||||
|
||||
p->avg_delay = mave_create(PORT_MAVE_LENGTH);
|
||||
|
|
16
port.h
16
port.h
|
@ -25,7 +25,9 @@
|
|||
#include "fsm.h"
|
||||
#include "transport.h"
|
||||
|
||||
struct clock; /*forward declaration*/
|
||||
/* forward declarations */
|
||||
struct interface;
|
||||
struct clock;
|
||||
|
||||
/** Opaque type. */
|
||||
struct port;
|
||||
|
@ -128,21 +130,17 @@ struct ptp_message *port_management_reply(struct PortIdentity pid,
|
|||
* Open a network port.
|
||||
* @param pod A pointer to a default port data set for this port.
|
||||
* @param phc_index The PHC device index for the network device.
|
||||
* @param name The name of the network interface.
|
||||
* @param transport The network transport type to use on this port.
|
||||
* @param timestamping The flavor of time stamping to use on this port.
|
||||
* @param number An arbitrary port number for this port.
|
||||
* @param dm Which delay mechanism to use on this port.
|
||||
* @param timestamping The timestamping mode for this port.
|
||||
* @param number An arbitrary number assigned to this port.
|
||||
* @param interface The interface data
|
||||
* @param clock A pointer to the system PTP clock.
|
||||
* @return A pointer to an open port on success, or NULL otherwise.
|
||||
*/
|
||||
struct port *port_open(struct port_defaults *pod,
|
||||
int phc_index,
|
||||
char *name,
|
||||
enum transport_type transport,
|
||||
enum timestamp_type timestamping,
|
||||
int number,
|
||||
enum delay_mechanism dm,
|
||||
struct interface *interface,
|
||||
struct clock *clock);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue