The phc.c file already has phc_get_caps to obtain the capabilities for a
PHC clock. Expose this and use it in phc_ctl.c instead of re-implementing
it.

Signed-off-by: Jacob Keller <jacob.e.kel...@intel.com>
---
 phc.c     |  4 +---
 phc.h     | 11 +++++++++++
 phc_ctl.c |  3 +--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/phc.c b/phc.c
index c121c64f9177..4491a91d55f0 100644
--- a/phc.c
+++ b/phc.c
@@ -37,8 +37,6 @@
 #define BITS_PER_LONG  (sizeof(long)*8)
 #define MAX_PPB_32     32767999        /* 2^31 - 1 / 65.536 */
 
-static int phc_get_caps(clockid_t clkid, struct ptp_clock_caps *caps);
-
 clockid_t phc_open(const char *phc)
 {
        clockid_t clkid;
@@ -74,7 +72,7 @@ void phc_close(clockid_t clkid)
        close(CLOCKID_TO_FD(clkid));
 }
 
-static int phc_get_caps(clockid_t clkid, struct ptp_clock_caps *caps)
+int phc_get_caps(clockid_t clkid, struct ptp_clock_caps *caps)
 {
        int fd = CLOCKID_TO_FD(clkid), err;
 
diff --git a/phc.h b/phc.h
index c48f906b84f5..830e002a8690 100644
--- a/phc.h
+++ b/phc.h
@@ -37,6 +37,17 @@ clockid_t phc_open(const char *phc);
  */
 void phc_close(clockid_t clkid);
 
+/**
+ * Get PTP hardware clock capabilities.
+ *
+ * @param clkid A clock ID obtained using phc_open().
+ * @param caps  Pointer to a PTP clock capabilities structure. On success,
+ *              this structure is filled with the clock capabilities.
+ *
+ * @return Zero on success, non-zero otherwise.
+ */
+int phc_get_caps(clockid_t clkid, struct ptp_clock_caps *caps);
+
 /**
  * Query the maximum frequency adjustment of a PTP hardware clock device.
  *
diff --git a/phc_ctl.c b/phc_ctl.c
index 92e597c40a23..4344184c364b 100644
--- a/phc_ctl.c
+++ b/phc_ctl.c
@@ -29,7 +29,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/ioctl.h>
 #include <sys/queue.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -288,7 +287,7 @@ static int do_caps(clockid_t clkid, int cmdc, char *cmdv[])
                return 0;
        }
 
-       if (ioctl(CLOCKID_TO_FD(clkid), PTP_CLOCK_GETCAPS, &caps)) {
+       if (phc_get_caps(clkid, &caps)) {
                pr_err("get capabilities failed: %s",
                        strerror(errno));
                return -1;
-- 
2.41.0.1.g9857a21e0017.dirty



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to