astlpc: Provide KCS device path as a binding argument
Currently astlpc binding expects a '/dev/mctp0' device in the system
for the KCS communication. This device is a symbolic link to the
real '/dev/raw-kcsX' device, created by the udev rules populated by the
build system.
This approach is not ideal since the build system populates udev rules
for the KCS3 and KCS4 channels simultaneously and for these channels
only. This means that there are some design limitations for the MCTP
communication. It is only possible on KCS3 or KCS4 channel, and if one
of these channels is used, the other one must be disabled.
To make design more flexible get rid of all the udev rules and provide
'/dev/raw-kcsX' device path as an argument to the binding
initialization code.
Change-Id: I505e44280636c83b59669b314f60279b371d0403
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/Makefile.am b/Makefile.am
index 440b70b..c48a277 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,11 +33,6 @@
pkgconfig_DATA = libmctp.pc
-if LIBMCTP_UDEV_RAW_KCS
-udevrules_DATA = udev/rules.d/mctp0-raw-kcs3.rules \
- udev/rules.d/mctp0-raw-kcs4.rules
-endif
-
if AUTOCONF_CODE_COVERAGE_2019_01_06
include $(top_srcdir)/aminclude_static.am
clean-local: code-coverage-clean
diff --git a/astlpc.c b/astlpc.c
index 33714a8..6de3e37 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -36,7 +36,6 @@
#include <linux/aspeed-lpc-ctrl.h>
/* kernel interface */
-static const char *kcs_path = "/dev/mctp0";
static const char *lpc_path = "/dev/aspeed-lpc-ctrl";
#endif
@@ -1410,7 +1409,8 @@
return rc;
}
-static int mctp_astlpc_init_fileio_kcs(struct mctp_binding_astlpc *astlpc)
+static int mctp_astlpc_init_fileio_kcs(struct mctp_binding_astlpc *astlpc,
+ const char *kcs_path)
{
astlpc->kcs_fd = open(kcs_path, O_RDWR);
if (astlpc->kcs_fd < 0)
@@ -1461,7 +1461,7 @@
return 0;
}
-struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void)
+struct mctp_binding_astlpc *mctp_astlpc_init_fileio(const char *kcs_path)
{
struct mctp_binding_astlpc *astlpc;
int rc;
@@ -1489,7 +1489,7 @@
return NULL;
}
- rc = mctp_astlpc_init_fileio_kcs(astlpc);
+ rc = mctp_astlpc_init_fileio_kcs(astlpc, kcs_path);
if (rc) {
free(astlpc);
return NULL;
@@ -1498,7 +1498,8 @@
return astlpc;
}
#else
-struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void)
+struct mctp_binding_astlpc *
+mctp_astlpc_init_fileio(const char *kcs_path __unused)
{
mctp_prlog(MCTP_LOG_ERR, "%s: Missing support for file IO", __func__);
return NULL;
diff --git a/configure.ac b/configure.ac
index 28d517e..519083f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,12 +21,6 @@
# pkg-config
PKG_PROG_PKG_CONFIG
PKG_INSTALLDIR
-PKG_CHECK_MODULES(udev,
- udev,
- [PKG_CHECK_VAR(udevdir, udev, udevdir)],
- [])
-
-AC_SUBST([udevrulesdir], [$udevdir/rules.d])
AC_ARG_ENABLE([capture],
[AC_HELP_STRING([--enable-capture],
@@ -41,11 +35,6 @@
AC_SUBST([pcap_LIBS])
AM_CONDITIONAL([HAVE_PCAP], [test "x$enable_capture" = "xyes"])
-AC_ARG_ENABLE([astlpc-raw-kcs],
- [AS_HELP_STRING([--enable-astlpc-raw-kcs],
- [Use udev rules to symlink raw-kcs device nodes for the astlpc binding])])
-AM_CONDITIONAL([LIBMCTP_UDEV_RAW_KCS], [test -n "$udevdir" -a "x$enable_astlpc_raw_kcs" = "xyes"])
-
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
[],
@@ -174,6 +163,5 @@
[AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
AX_ADD_AM_MACRO_STATIC([])
-AC_CONFIG_FILES([Makefile libmctp.pc udev/rules.d/mctp0-raw-kcs3.rules
- udev/rules.d/mctp0-raw-kcs4.rules])
+AC_CONFIG_FILES([Makefile libmctp.pc])
AC_OUTPUT
diff --git a/libmctp-astlpc.h b/libmctp-astlpc.h
index 110b998..362e4bb 100644
--- a/libmctp-astlpc.h
+++ b/libmctp-astlpc.h
@@ -45,7 +45,7 @@
int mctp_astlpc_poll(struct mctp_binding_astlpc *astlpc);
/* fileio-based interface */
-struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void);
+struct mctp_binding_astlpc *mctp_astlpc_init_fileio(const char *kcs_path);
struct pollfd;
int mctp_astlpc_init_pollfd(struct mctp_binding_astlpc *astlpc,
diff --git a/udev/rules.d/mctp0-raw-kcs3.rules.in b/udev/rules.d/mctp0-raw-kcs3.rules.in
deleted file mode 100644
index bf4a76f..0000000
--- a/udev/rules.d/mctp0-raw-kcs3.rules.in
+++ /dev/null
@@ -1 +0,0 @@
-ACTION=="add", DEVPATH=="/devices/virtual/misc/raw-kcs3", SUBSYSTEM=="misc", SYMLINK+="mctp0"
diff --git a/udev/rules.d/mctp0-raw-kcs4.rules.in b/udev/rules.d/mctp0-raw-kcs4.rules.in
deleted file mode 100644
index 1df8e9f..0000000
--- a/udev/rules.d/mctp0-raw-kcs4.rules.in
+++ /dev/null
@@ -1 +0,0 @@
-ACTION=="add", DEVPATH=="/devices/virtual/misc/raw-kcs4", SUBSYSTEM=="misc", SYMLINK+="mctp0"
diff --git a/utils/mctp-demux-daemon.c b/utils/mctp-demux-daemon.c
index 8bb77ba..fae4f35 100644
--- a/utils/mctp-demux-daemon.c
+++ b/utils/mctp-demux-daemon.c
@@ -211,13 +211,16 @@
char *const *params __attribute__((unused)))
{
struct mctp_binding_astlpc *astlpc;
+ const char *path;
- if (n_params) {
- warnx("astlpc binding does not accept parameters");
+ if (n_params != 1) {
+ warnx("astlpc binding requires kcs device param");
return -1;
}
- astlpc = mctp_astlpc_init_fileio();
+ path = params[0];
+
+ astlpc = mctp_astlpc_init_fileio(path);
if (!astlpc) {
warnx("could not initialise astlpc binding");
return -1;