From 75b1083611dca5fcaf396cc1f3d04b4eb5003f42 Mon Sep 17 00:00:00 2001 From: Alessandro Rubini <rubini@gnudd.com> Date: Thu, 27 Oct 2016 11:45:43 +0200 Subject: [PATCH] shell/cmd_ptp: take over 'mode' command Signed-off-by: Alessandro Rubini <rubini@gnudd.com> --- shell/cmd_mode.c | 43 ------------------------------------------- shell/cmd_ptp.c | 7 +++++++ shell/shell.mk | 1 - 3 files changed, 7 insertions(+), 44 deletions(-) delete mode 100644 shell/cmd_mode.c diff --git a/shell/cmd_mode.c b/shell/cmd_mode.c deleted file mode 100644 index 3ca95103f..000000000 --- a/shell/cmd_mode.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This work is part of the White Rabbit project - * - * Copyright (C) 2012 CERN (www.cern.ch) - * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> - * - * Released according to the GNU GPL, version 2 or any later version. - */ -/* Command: mode - Arguments: PTP mode: gm = grandmaster, master = free-running master, slave = slave - - Description: (re)starts/stops the PTP session. */ - -#include <errno.h> -#include <string.h> -#include <wrc.h> - -#include "shell.h" -#include "wrc_ptp.h" - -static int cmd_mode(const char *args[]) -{ - int mode; - static const char *modes[] = - { "unknown", "grandmaster", "master", "slave" }; - - if (!strcasecmp(args[0], "gm")) - mode = WRC_MODE_GM; - else if (!strcasecmp(args[0], "master")) - mode = WRC_MODE_MASTER; - else if (!strcasecmp(args[0], "slave")) - mode = WRC_MODE_SLAVE; - else { - pp_printf("%s\n", modes[wrc_ptp_get_mode()]); - return 0; - } - return wrc_ptp_set_mode(mode); -} - -DEFINE_WRC_COMMAND(mode) = { - .name = "mode", - .exec = cmd_mode, -}; diff --git a/shell/cmd_ptp.c b/shell/cmd_ptp.c index c85279358..b15b7b933 100644 --- a/shell/cmd_ptp.c +++ b/shell/cmd_ptp.c @@ -21,6 +21,9 @@ struct subcmd { {"delay", wrc_ptp_sync_mech, PP_E2E_MECH}, {"p2p", wrc_ptp_sync_mech, PP_P2P_MECH}, {"pdelay", wrc_ptp_sync_mech, PP_P2P_MECH}, + {"gm", wrc_ptp_set_mode, WRC_MODE_GM}, + {"master", wrc_ptp_set_mode, WRC_MODE_MASTER}, + {"slave", wrc_ptp_set_mode, WRC_MODE_SLAVE}, }; static int cmd_ptp(const char *args[]) @@ -38,3 +41,7 @@ DEFINE_WRC_COMMAND(ptp) = { .name = "ptp", .exec = cmd_ptp, }; +DEFINE_WRC_COMMAND(mode) = { + .name = "mode", + .exec = cmd_ptp, +}; diff --git a/shell/shell.mk b/shell/shell.mk index 2da508e11..45b5d8e1f 100644 --- a/shell/shell.mk +++ b/shell/shell.mk @@ -2,7 +2,6 @@ obj-$(CONFIG_WR_NODE) += \ shell/shell.o \ shell/cmd_version.o \ shell/cmd_ptp.o \ - shell/cmd_mode.o \ shell/cmd_help.o \ shell/cmd_mac.o \ shell/cmd_ps.o \ -- GitLab