diff options
author | Vyacheslav Pedash <vyacheslav.pedash@globallogic.com> | 2022-03-22 12:18:25 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2022-04-12 16:39:36 -0500 |
commit | 5e681baa71e96d1ae1de317c4ee74dfdc9b72b1c (patch) | |
tree | ca9865d8f8cf7f3191b4eed83dc510a1f52b9a6a | |
parent | 0b40f9b600011eef536af0947425549d835f9f20 (diff) | |
download | mts-io-5e681baa71e96d1ae1de317c4ee74dfdc9b72b1c.tar.gz mts-io-5e681baa71e96d1ae1de317c4ee74dfdc9b72b1c.tar.bz2 mts-io-5e681baa71e96d1ae1de317c4ee74dfdc9b72b1c.zip |
Create symlink in /sys/devices/platform to mts-io node in case it is placed in other directory in sysfs4.9.3
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | io-module/mts-io.c | 47 | ||||
-rw-r--r-- | io-module/version.h | 2 |
3 files changed, 49 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index d65d2a5..010f2ac 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([mts-io], [4.9.1]) +AC_INIT([mts-io], [4.9.3]) AC_CONFIG_SRCDIR([util/mts_util_lora2_reset.c]) AM_INIT_AUTOMAKE AM_CONFIG_HEADER([config.h]) diff --git a/io-module/mts-io.c b/io-module/mts-io.c index ca7fdcb..a6e5204 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -93,16 +93,63 @@ EXPORT_SYMBOL(mts_get_hw_version); struct platform_device *mts_io_platform_device; EXPORT_SYMBOL(mts_io_platform_device); +#ifdef PLATFORM_BUS_SYMLINK +struct mts_io_drvdata { + bool f_platform_bus_symlink; +}; +#endif // PLATFORM_BUS_SYMLINK static int mts_io_probe(struct platform_device *pdev) { +#ifdef PLATFORM_BUS_SYMLINK + struct device *dev = &pdev->dev; + const char *symlink_name = kobject_name(&pdev->dev.kobj); + struct mts_io_drvdata *mts_io_dd; + int res; +#endif // PLATFORM_BUS_SYMLINK + mts_io_platform_device = pdev; dev_dbg(&pdev->dev,"%s: ENTER\n",__func__); + +#ifdef PLATFORM_BUS_SYMLINK + mts_io_dd = devm_kzalloc(dev, sizeof(*mts_io_dd), GFP_KERNEL); + if (!mts_io_dd) { + return -ENOMEM; + }; + mts_io_dd->f_platform_bus_symlink = false; + platform_set_drvdata(pdev, mts_io_dd); + + if (!dev->parent) { + log_warning("Parent device is not found"); + } else if (dev->parent == &platform_bus) { + log_info("Parent device is platform_bus. No need to create symlink"); + goto exit; + } + log_info("Creating symlink on platform_bus to %s", symlink_name); + + res = sysfs_create_link(&platform_bus.kobj, &dev->kobj, symlink_name); + if (!res) { + mts_io_dd->f_platform_bus_symlink = true; + } else { + log_warning("Failed to create symlink"); + } + +exit: +#endif // PLATFORM_BUS_SYMLINK + return 0; } static int mts_io_remove(struct platform_device *pdev) { +#ifdef PLATFORM_BUS_SYMLINK + struct mts_io_drvdata *mts_io_dd = platform_get_drvdata(pdev); + const char *symlink_name = kobject_name(&pdev->dev.kobj); + if (mts_io_dd && mts_io_dd->f_platform_bus_symlink) { + log_info("Removing %s symlink from platform_bus", symlink_name); + sysfs_remove_link(&platform_bus.kobj, symlink_name); + } +#endif // PLATFORM_BUS_SYMLINK return 0; } diff --git a/io-module/version.h b/io-module/version.h index e61e6ed..5b6304b 100644 --- a/io-module/version.h +++ b/io-module/version.h @@ -1,7 +1,7 @@ #ifndef __VERSION_H #define __VERSION_H -#define DRIVER_VERSION "v4.9.2" +#define DRIVER_VERSION "v4.9.3" #define DRIVER_AUTHOR "Multitech Systems" #define DRIVER_DESC "MTS-IO Controller" #define DRIVER_NAME "mts-io" |