From: Sherry Sun <sherry.sun@nxp.com>
To: sudeep.dutt@intel.com, ashutosh.dixit@intel.com, arnd@arndb.de,
gregkh@linuxfoundation.org, masahiroy@kernel.org,
michal.lkml@markovi.net, lee.jones@linaro.org
Cc: linux-kernel@vger.kernel.org, linux-imx@nxp.com,
linux-kbuild@vger.kernel.org
Subject: [PATCH V2 2/2] mic: cosm: module autoprobing support for cosm driver
Date: Tue, 29 Sep 2020 16:02:14 +0800 [thread overview]
Message-ID: <20200929080214.23553-3-sherry.sun@nxp.com> (raw)
In-Reply-To: <20200929080214.23553-1-sherry.sun@nxp.com>
Add uevent callback for cosm_bus and add cosm_device_id for cosm driver
which is needed for MODULE_DEVICE_TABLE. Also adding struct
cosm_device_id in devicetable-offsets.c and the cosm entry point in
file2alias.c.
Cosm driver will be autoloaded when cosm device appears.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
drivers/misc/mic/bus/cosm_bus.c | 8 ++++++++
drivers/misc/mic/cosm/cosm_main.c | 7 +++++++
include/linux/mod_devicetable.h | 8 ++++++++
scripts/mod/devicetable-offsets.c | 3 +++
scripts/mod/file2alias.c | 11 +++++++++++
5 files changed, 37 insertions(+)
diff --git a/drivers/misc/mic/bus/cosm_bus.c b/drivers/misc/mic/bus/cosm_bus.c
index 5f2141c71738..736e27bbc9f9 100644
--- a/drivers/misc/mic/bus/cosm_bus.c
+++ b/drivers/misc/mic/bus/cosm_bus.c
@@ -14,6 +14,13 @@
/* Unique numbering for cosm devices. */
static DEFINE_IDA(cosm_index_ida);
+static int cosm_uevent(struct device *d, struct kobj_uevent_env *env)
+{
+ struct cosm_device *dev = dev_to_cosm(d);
+
+ return add_uevent_var(env, "MODALIAS=cosm:cosm-dev%u", dev->index);
+}
+
static int cosm_dev_probe(struct device *d)
{
struct cosm_device *dev = dev_to_cosm(d);
@@ -33,6 +40,7 @@ static int cosm_dev_remove(struct device *d)
static struct bus_type cosm_bus = {
.name = "cosm_bus",
+ .uevent = cosm_uevent,
.probe = cosm_dev_probe,
.remove = cosm_dev_remove,
};
diff --git a/drivers/misc/mic/cosm/cosm_main.c b/drivers/misc/mic/cosm/cosm_main.c
index ebb0eac43754..627e7d5f3a83 100644
--- a/drivers/misc/mic/cosm/cosm_main.c
+++ b/drivers/misc/mic/cosm/cosm_main.c
@@ -12,6 +12,7 @@
#include <linux/idr.h>
#include <linux/slab.h>
#include <linux/cred.h>
+#include <linux/mod_devicetable.h>
#include "cosm_main.h"
static const char cosm_driver_name[] = "mic";
@@ -323,6 +324,12 @@ static int cosm_suspend(struct device *dev)
return 0;
}
+static struct cosm_device_id __maybe_unused cosm_driver_id_table[] = {
+ { .name = "cosm-dev*" },
+ { },
+};
+MODULE_DEVICE_TABLE(cosm, cosm_driver_id_table);
+
static const struct dev_pm_ops cosm_pm_ops = {
.suspend = cosm_suspend,
.freeze = cosm_suspend
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 736cdc236cf9..ea6cdfe1a3a3 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -845,4 +845,12 @@ struct vop_device_id {
};
#define VOP_DEV_ANY_ID 0xffffffff
+/* cosm */
+#define COSM_NAME_SIZE 32
+#define COSM_MODULE_PREFIX "cosm:"
+
+struct cosm_device_id {
+ char name[COSM_NAME_SIZE];
+};
+
#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index 393acaa5302a..499a2832878d 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -247,5 +247,8 @@ int main(void)
DEVID_FIELD(vop_device_id, device);
DEVID_FIELD(vop_device_id, vendor);
+ DEVID(cosm_device_id);
+ DEVID_FIELD(cosm_device_id, name);
+
return 0;
}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 8063b778eedf..f7c80e4da137 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1383,6 +1383,16 @@ static int do_vop_entry(const char *filename, void *symval,
return 1;
}
+/* Looks like: cosm:S */
+static int do_cosm_entry(const char *filename, void *symval,
+ char *alias)
+{
+ DEF_FIELD_ADDR(symval, cosm_device_id, name);
+ sprintf(alias, COSM_MODULE_PREFIX "%s", *name);
+
+ return 1;
+}
+
/* Does namelen bytes of name exactly match the symbol? */
static bool sym_is(const char *name, unsigned namelen, const char *symbol)
{
@@ -1458,6 +1468,7 @@ static const struct devtable devtable[] = {
{"wmi", SIZE_wmi_device_id, do_wmi_entry},
{"mhi", SIZE_mhi_device_id, do_mhi_entry},
{"vop", SIZE_vop_device_id, do_vop_entry},
+ {"cosm", SIZE_cosm_device_id, do_cosm_entry},
};
/* Create MODULE_ALIAS() statements.
--
2.17.1
next prev parent reply other threads:[~2020-09-29 8:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 8:02 [PATCH V2 0/2] Add module autoloading support for vop and cosm driver Sherry Sun
2020-09-29 8:02 ` [PATCH V2 1/2] mic: vop: module autoprobing support for vop drivers Sherry Sun
2020-09-29 8:02 ` Sherry Sun [this message]
2020-10-13 8:52 ` [PATCH V2 0/2] Add module autoloading support for vop and cosm driver Sherry Sun
2020-10-13 9:08 ` gregkh
2020-10-13 9:20 ` Sherry Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200929080214.23553-3-sherry.sun@nxp.com \
--to=sherry.sun@nxp.com \
--cc=arnd@arndb.de \
--cc=ashutosh.dixit@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-imx@nxp.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=michal.lkml@markovi.net \
--cc=sudeep.dutt@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).