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;
};
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,
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;
struct management_tlv *mgt;
struct PortIdentity pid;
struct ClockIdentity *tcid, wildcard = {
{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 TRANSPARENT_CLOCK_DEFAULT_DATA_SET:
case PRIMARY_DOMAIN:
pid = port_identity(p);
if (port_management_error(pid, p, msg, NOT_SUPPORTED))
pr_err("failed to send management error status");
clock_management_send_error(p, msg, NOT_SUPPORTED);
break;
default:
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;
}
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,
struct port *ingress, int id,
struct ptp_message *req)
@ -1691,9 +1698,7 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
return 0;
break;
case SET:
if (port_management_error(p->portIdentity, ingress, msg,
NOT_SUPPORTED))
pr_err("port %hu: management error failed", portnum(p));
port_management_send_error(p, ingress, msg, NOT_SUPPORTED);
break;
case COMMAND:
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 DELAY_MECHANISM:
case LOG_MIN_PDELAY_REQ_INTERVAL:
if (port_management_error(p->portIdentity, ingress, msg,
NOT_SUPPORTED))
pr_err("port %hu: management error failed", portnum(p));
port_management_send_error(p, ingress, msg, NOT_SUPPORTED);
break;
default:
return -1;