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 <***@se-instruments.com>
---
clock.c | 12 ++++++++----
port.c | 15 +++++++++------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/clock.c b/clock.c
index 67271a9..14ea25e 100644
--- a/clock.c
+++ b/clock.c
@@ -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++) {
diff --git a/port.c b/port.c
index 6528cf9..0b58fbd 100644
--- a/port.c
+++ b/port.c
@@ -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)
@@ -1687,9 +1694,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:
@@ -1713,9 +1718,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;
--
1.8.1.2