factors out functions for sending mgmt errors from clock and port

Adds port_management_send_error and clock_management_send_error to
avoid repeatedly checking the result of port_managment_send_error and
calling pr_err if it failed. Future patches send more mgmt errors so
this will avoid repeated code.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
master
Geoff Salmon 2013-02-04 13:05:37 -05:00 committed by Richard Cochran
parent d5af4196fc
commit 1500605ff5
2 changed files with 17 additions and 10 deletions

12
clock.c
View File

@ -131,6 +131,13 @@ static void clock_freq_est_reset(struct clock *c)
c->fest.count = 0; c->fest.count = 0;
}; };
static void clock_management_send_error(struct port *p,
struct ptp_message *msg, int error_id)
{
if (port_management_error(port_identity(p), p, msg, error_id))
pr_err("failed to send management error status");
}
static int clock_management_get_response(struct clock *c, struct port *p, static int clock_management_get_response(struct clock *c, struct port *p,
int id, struct ptp_message *req) int id, struct ptp_message *req)
{ {
@ -610,7 +617,6 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
{ {
int i; int i;
struct management_tlv *mgt; struct management_tlv *mgt;
struct PortIdentity pid;
struct ClockIdentity *tcid, wildcard = { struct ClockIdentity *tcid, wildcard = {
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
}; };
@ -669,9 +675,7 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
case ALTERNATE_TIME_OFFSET_PROPERTIES: case ALTERNATE_TIME_OFFSET_PROPERTIES:
case TRANSPARENT_CLOCK_DEFAULT_DATA_SET: case TRANSPARENT_CLOCK_DEFAULT_DATA_SET:
case PRIMARY_DOMAIN: case PRIMARY_DOMAIN:
pid = port_identity(p); clock_management_send_error(p, msg, NOT_SUPPORTED);
if (port_management_error(pid, p, msg, NOT_SUPPORTED))
pr_err("failed to send management error status");
break; break;
default: default:
for (i = 0; i < c->nports; i++) { for (i = 0; i < c->nports; i++) {

15
port.c
View File

@ -431,6 +431,13 @@ static int port_is_ieee8021as(struct port *p)
return p->pod.follow_up_info ? 1 : 0; return p->pod.follow_up_info ? 1 : 0;
} }
static void port_management_send_error(struct port *p, struct port *ingress,
struct ptp_message *msg, int error_id)
{
if (port_management_error(p->portIdentity, ingress, msg, error_id))
pr_err("port %hu: management error failed", portnum(p));
}
static int port_management_get_response(struct port *target, static int port_management_get_response(struct port *target,
struct port *ingress, int id, struct port *ingress, int id,
struct ptp_message *req) struct ptp_message *req)
@ -1691,9 +1698,7 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
return 0; return 0;
break; break;
case SET: case SET:
if (port_management_error(p->portIdentity, ingress, msg, port_management_send_error(p, ingress, msg, NOT_SUPPORTED);
NOT_SUPPORTED))
pr_err("port %hu: management error failed", portnum(p));
break; break;
case COMMAND: case COMMAND:
case RESPONSE: case RESPONSE:
@ -1717,9 +1722,7 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
case TRANSPARENT_CLOCK_PORT_DATA_SET: case TRANSPARENT_CLOCK_PORT_DATA_SET:
case DELAY_MECHANISM: case DELAY_MECHANISM:
case LOG_MIN_PDELAY_REQ_INTERVAL: case LOG_MIN_PDELAY_REQ_INTERVAL:
if (port_management_error(p->portIdentity, ingress, msg, port_management_send_error(p, ingress, msg, NOT_SUPPORTED);
NOT_SUPPORTED))
pr_err("port %hu: management error failed", portnum(p));
break; break;
default: default:
return -1; return -1;