summaryrefslogtreecommitdiff
path: root/io-module
diff options
context:
space:
mode:
authorVyacheslav Pedash <vyacheslav.pedash@globallogic.com>2022-03-22 12:18:25 -0500
committerJohn Klug <john.klug@multitech.com>2022-04-12 16:39:36 -0500
commit5e681baa71e96d1ae1de317c4ee74dfdc9b72b1c (patch)
treeca9865d8f8cf7f3191b4eed83dc510a1f52b9a6a /io-module
parent0b40f9b600011eef536af0947425549d835f9f20 (diff)
downloadmts-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
Diffstat (limited to 'io-module')
-rw-r--r--io-module/mts-io.c47
-rw-r--r--io-module/version.h2
2 files changed, 48 insertions, 1 deletions
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"