Skip to content

Commit 400766f

Browse files
committed
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 <[email protected]>
1 parent 8803dc1 commit 400766f

File tree

7 files changed

+14
-29
lines changed

7 files changed

+14
-29
lines changed

Makefile.am

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ utils_mctp_demux_daemon_CFLAGS = $(pcap_CFLAGS)
3333

3434
pkgconfig_DATA = libmctp.pc
3535

36-
if LIBMCTP_UDEV_RAW_KCS
37-
udevrules_DATA = udev/rules.d/mctp0-raw-kcs3.rules \
38-
udev/rules.d/mctp0-raw-kcs4.rules
39-
endif
40-
4136
if AUTOCONF_CODE_COVERAGE_2019_01_06
4237
include $(top_srcdir)/aminclude_static.am
4338
clean-local: code-coverage-clean

astlpc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <linux/aspeed-lpc-ctrl.h>
3737

3838
/* kernel interface */
39-
static const char *kcs_path = "/dev/mctp0";
4039
static const char *lpc_path = "/dev/aspeed-lpc-ctrl";
4140

4241
#endif
@@ -1410,7 +1409,8 @@ static int mctp_astlpc_init_fileio_lpc(struct mctp_binding_astlpc *astlpc)
14101409
return rc;
14111410
}
14121411

1413-
static int mctp_astlpc_init_fileio_kcs(struct mctp_binding_astlpc *astlpc)
1412+
static int mctp_astlpc_init_fileio_kcs(struct mctp_binding_astlpc *astlpc,
1413+
const char *kcs_path)
14141414
{
14151415
astlpc->kcs_fd = open(kcs_path, O_RDWR);
14161416
if (astlpc->kcs_fd < 0)
@@ -1461,7 +1461,7 @@ int mctp_astlpc_init_pollfd(struct mctp_binding_astlpc *astlpc,
14611461
return 0;
14621462
}
14631463

1464-
struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void)
1464+
struct mctp_binding_astlpc *mctp_astlpc_init_fileio(const char *kcs_path)
14651465
{
14661466
struct mctp_binding_astlpc *astlpc;
14671467
int rc;
@@ -1489,7 +1489,7 @@ struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void)
14891489
return NULL;
14901490
}
14911491

1492-
rc = mctp_astlpc_init_fileio_kcs(astlpc);
1492+
rc = mctp_astlpc_init_fileio_kcs(astlpc, kcs_path);
14931493
if (rc) {
14941494
free(astlpc);
14951495
return NULL;
@@ -1498,7 +1498,8 @@ struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void)
14981498
return astlpc;
14991499
}
15001500
#else
1501-
struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void)
1501+
struct mctp_binding_astlpc *
1502+
mctp_astlpc_init_fileio(const char *kcs_path __unused)
15021503
{
15031504
mctp_prlog(MCTP_LOG_ERR, "%s: Missing support for file IO", __func__);
15041505
return NULL;

configure.ac

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ AC_CHECK_HEADERS_ONCE([unistd.h fcntl.h])
2121
# pkg-config
2222
PKG_PROG_PKG_CONFIG
2323
PKG_INSTALLDIR
24-
PKG_CHECK_MODULES(udev,
25-
udev,
26-
[PKG_CHECK_VAR(udevdir, udev, udevdir)],
27-
[])
28-
29-
AC_SUBST([udevrulesdir], [$udevdir/rules.d])
3024

3125
AC_ARG_ENABLE([capture],
3226
[AC_HELP_STRING([--enable-capture],
@@ -41,11 +35,6 @@ AC_SUBST([pcap_CFLAGS])
4135
AC_SUBST([pcap_LIBS])
4236
AM_CONDITIONAL([HAVE_PCAP], [test "x$enable_capture" = "xyes"])
4337

44-
AC_ARG_ENABLE([astlpc-raw-kcs],
45-
[AS_HELP_STRING([--enable-astlpc-raw-kcs],
46-
[Use udev rules to symlink raw-kcs device nodes for the astlpc binding])])
47-
AM_CONDITIONAL([LIBMCTP_UDEV_RAW_KCS], [test -n "$udevdir" -a "x$enable_astlpc_raw_kcs" = "xyes"])
48-
4938
AC_ARG_WITH([systemdsystemunitdir],
5039
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
5140
[],
@@ -174,6 +163,5 @@ m4_ifdef([_AX_CODE_COVERAGE_RULES],
174163
[AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
175164
AX_ADD_AM_MACRO_STATIC([])
176165

177-
AC_CONFIG_FILES([Makefile libmctp.pc udev/rules.d/mctp0-raw-kcs3.rules
178-
udev/rules.d/mctp0-raw-kcs4.rules])
166+
AC_CONFIG_FILES([Makefile libmctp.pc])
179167
AC_OUTPUT

libmctp-astlpc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool mctp_astlpc_tx_done(struct mctp_binding_astlpc *astlpc);
4545
int mctp_astlpc_poll(struct mctp_binding_astlpc *astlpc);
4646

4747
/* fileio-based interface */
48-
struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void);
48+
struct mctp_binding_astlpc *mctp_astlpc_init_fileio(const char *kcs_path);
4949

5050
struct pollfd;
5151
int mctp_astlpc_init_pollfd(struct mctp_binding_astlpc *astlpc,

udev/rules.d/mctp0-raw-kcs3.rules.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

udev/rules.d/mctp0-raw-kcs4.rules.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

utils/mctp-demux-daemon.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,16 @@ static int binding_astlpc_init(struct mctp *mctp, struct binding *binding,
211211
char *const *params __attribute__((unused)))
212212
{
213213
struct mctp_binding_astlpc *astlpc;
214+
const char *path;
214215

215-
if (n_params) {
216-
warnx("astlpc binding does not accept parameters");
216+
if (n_params != 1) {
217+
warnx("astlpc binding requires kcs device param");
217218
return -1;
218219
}
219220

220-
astlpc = mctp_astlpc_init_fileio();
221+
path = params[0];
222+
223+
astlpc = mctp_astlpc_init_fileio(path);
221224
if (!astlpc) {
222225
warnx("could not initialise astlpc binding");
223226
return -1;

0 commit comments

Comments
 (0)