Add module autoprobing support for vop and cosm driver
Subsystems (2)
cover Add module autoprobing support for vop and cosm driver
Add module autoprobing support for vop and cosm driver, when the vop/cosm device appears, the driver will be autoloaded.
Sherry Sun (3):
mic: vop: fix a written error in MODULE_DEVICE_TABLE
mic: vop: module autoprobing support for vop drivers
mic: cosm: module autoprobing support for cosm driver
drivers/misc/mic/bus/cosm_bus.c | 8 ++++++++ drivers/misc/mic/bus/vop_bus.h | 7 +------ drivers/misc/mic/cosm/cosm_main.c | 7 +++++++ drivers/misc/mic/vop/vop_main.c | 2 +- include/linux/mod_devicetable.h | 15 +++++++++++++++ scripts/mod/devicetable-offsets.c | 7 +++++++ scripts/mod/file2alias.c | 27 +++++++++++++++++++++++++++ 7 files changed, 66 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 mic: vop: fix a written error in MODULE_DEVICE_TABLE
For vop bus, the first parameter should be vop in MODULE_DEVICE_TABLE.
--- drivers/misc/mic/vop/vop_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mic/vop/vop_main.c +1 -1
@@ -796,7 +796,7 @@ static struct vop_driver vop_driver = {module_vop_driver (vop_driver); -MODULE_DEVICE_TABLE (mbus, id_table); +MODULE_DEVICE_TABLE (vop, id_table);MODULE_AUTHOR ("Intel Corporation" );MODULE_DESCRIPTION ("Intel(R) Virtio Over PCIe (VOP) driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH 1/3] mic: vop: fix a written error in MODULE_DEVICE_TABLE
Quoted 13 lines · Sherry Sun
For vop bus, the first parameter should be vop in
MODULE_DEVICE_TABLE.Signed-off-by Sherry Sun <[email protected]>Signed-off-by Joakim Zhang <[email protected]>--- drivers/misc/mic/vop/vop_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/mic/vop/vop_main.c +0
-0
drivers/misc/mic/vop/vop_main.c static struct vop_driver vop_driver = { · line 802
Quoted 8 lines
drivers/misc/mic/vop/vop_main.c +1
-1@@ -796,7 +796,7 @@ static struct vop_driver vop_driver = {module_vop_driver (vop_driver); -MODULE_DEVICE_TABLE (mbus, id_table); +MODULE_DEVICE_TABLE (vop, id_table);MODULE_AUTHOR ("Intel Corporation" );MODULE_DESCRIPTION ("Intel(R) Virtio Over PCIe (VOP) driver" );MODULE_LICENSE ("GPL v2" );
Doesn't this have to go _after_ the MODULE_DEVICE_TABLE(vop...) support, which you add in patch 2 of this series?
Does this patch here break the build? If not, how is it working?
And if you only have one vop driver, why do you need autoloading for it?
thanks,
greg k-h
RE: [PATCH 1/3] mic: vop: fix a written error in MODULE_DEVICE_TABLE
Hi Greg,
Quoted 32 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: 2020年9月27日 18:29
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; [email protected]; linux- [email protected]; dl-linux-imx <[email protected]>
Subject: Re: [PATCH 1/3] mic: vop: fix a written error inMODULE_DEVICE_TABLEQuoted 17 lines · Sherry Sun
For vop bus, the first parameter should be vop in
MODULE_DEVICE_TABLE.Signed-off-by Sherry Sun <[email protected]>Signed-off-by Joakim Zhang <[email protected]>--- drivers/misc/mic/vop/vop_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/misc/mic/vop/vop_main.cindexd609f0dc6124..589425fa78d4100644drivers/misc/mic/vop/vop_main.c +0
-0@@ -796,7 +796,7 @@ static struct vop_driver vop_driver = {module_vop_driver (vop_driver);
Quoted 8 lines
drivers/misc/mic/vop/vop_main.c static struct vop_driver vop_driver = { · line 802
Quoted 5 lines
drivers/misc/mic/vop/vop_main.c +1
-1-MODULE_DEVICE_TABLE (mbus, id_table); +MODULE_DEVICE_TABLE (vop, id_table);MODULE_AUTHOR ("Intel Corporation" );MODULE_DESCRIPTION ("Intel(R) Virtio Over PCIe (VOP) driver" );MODULE_LICENSE ("GPL v2" );Doesn't this have to go _after_ the
MODULE_DEVICE_TABLE(vop...)support, which you add in patch 2 of this series?
Yes, this patch must be used in conjunction with Patch2.
But I think here may be a small bug, in order to distinguish it from the driver autoloading support, make this a separate patch.
I can put this patch together with Patch2 if you think it might look more reasonable.
Quoted 5 lines
Does this patch here break the build? If not, how is it working?
And if you only have one vop driver, why do you need autoloading for it?
No, it doesn't break the build. But actually it won't work(autoloaded) when kernel boot and vop device appears.
Although we may only have one vop driver, but in the mic Kconfig, the intel mic/vop/cosm/scif drivers all recommended to be built as modules, if we don't add autoloading for them, we may need modprobe them one by one manually both on EP and RC side.
Obviously, for our use case, driver autoloading is more convenient.
Best regards
Sherry
Quoted 3 lines
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH 1/3] mic: vop: fix a written error in MODULE_DEVICE_TABLE
Quoted 43 lines · Sherry Sun
Hi Greg,
Quoted 32 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: 2020年9月27日 18:29
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; [email protected]; linux- [email protected]; dl-linux-imx <[email protected]>
Subject: Re: [PATCH 1/3] mic: vop: fix a written error inMODULE_DEVICE_TABLEQuoted 17 lines · Sherry Sun
For vop bus, the first parameter should be vop in
MODULE_DEVICE_TABLE.Signed-off-by Sherry Sun <[email protected]>Signed-off-by Joakim Zhang <[email protected]>--- drivers/misc/mic/vop/vop_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/misc/mic/vop/vop_main.cindexd609f0dc6124..589425fa78d4100644drivers/misc/mic/vop/vop_main.c +0
-0@@ -796,7 +796,7 @@ static struct vop_driver vop_driver = {module_vop_driver (vop_driver);Quoted 8 lines
drivers/misc/mic/vop/vop_main.c static struct vop_driver vop_driver = { · line 802
Quoted 5 lines
drivers/misc/mic/vop/vop_main.c +1
-1-MODULE_DEVICE_TABLE (mbus, id_table); +MODULE_DEVICE_TABLE (vop, id_table);MODULE_AUTHOR ("Intel Corporation" );MODULE_DESCRIPTION ("Intel(R) Virtio Over PCIe (VOP) driver" );MODULE_LICENSE ("GPL v2" );Doesn't this have to go _after_ the
MODULE_DEVICE_TABLE(vop...)support, which you add in patch 2 of this series?
Quoted 5 lines
Yes, this patch must be used in conjunction with Patch2.
But I think here may be a small bug, in order to distinguish it from the driver autoloading support, make this a separate patch.I can put this patch together with Patch2 if you think it might look more reasonable.
How about _after_ patch 2, otherwise this patch will break the build, right?
Quoted 11 lines
Quoted 4 lines
Does this patch here break the build? If not, how is it working?
And if you only have one vop driver, why do you need autoloading for it?
No, it doesn't break the build. But actually it won't work(autoloaded) when kernel boot and vop device appears.
Although we may only have one vop driver, but in the mic
Kconfig, the intel mic/vop/cosm/scif drivers all recommended to be built as modules, if we don't add autoloading for them, we may need modprobe them one by one manually both on EP and RC side.Obviously, for our use case, driver autoloading is more convenient.
Why are these all not "mic_SUFFIX" type drivers? Why "vop" and "cosm" and "scif"?
And if you only have 1 driver, then what would cause autoloading?
thanks,
greg k-h
RE: [PATCH 1/3] mic: vop: fix a written error in MODULE_DEVICE_TABLE
Hi Greg,
Quoted 46 lines · Sherry Sun
Quoted 18 lines
Hi Greg,
Quoted 16 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: 2020年9月27日 18:29
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; [email protected]; linux- [email protected]; dl-linux-imx <[email protected]>
Subject: Re: [PATCH 1/3] mic: vop: fix a written error inMODULE_DEVICE_TABLEQuoted 1 line · Sherry Sun
For vop bus, the first parameter should be vop in
MODULE_DEVICE_TABLE.Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Signed-off-by Sherry Sun <[email protected]>Signed-off-by Joakim Zhang <[email protected]>--- drivers/misc/mic/vop/vop_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/misc/mic/vop/vop_main.cindex
d609f0dc6124..589425fa78d4Quoted 16 lines
Quoted 15 lines
drivers/misc/mic/vop/vop_main.c static struct vop_driver vop_driver = { · line 802
Quoted 12 lines
100644
drivers/misc/mic/vop/vop_main.c +1
-1@@ -796,7 +796,7 @@ static struct vop_driver vop_driver = {module_vop_driver (vop_driver); -MODULE_DEVICE_TABLE (mbus, id_table); +MODULE_DEVICE_TABLE (vop, id_table);MODULE_AUTHOR ("Intel Corporation" );MODULE_DESCRIPTION ("Intel(R) Virtio Over PCIe (VOP) driver" );MODULE_LICENSE ("GPL v2" );Doesn't this have to go _after_ the
MODULE_DEVICE_TABLE(vop...)support, which you add in patch 2 of this series?
Quoted 8 lines
Quoted 5 lines
Yes, this patch must be used in conjunction with Patch2. But I think here may be a small bug, in order to distinguish it from the driver autoloading support, make this a separate patch.
I can put this patch together with Patch2 if you think it might look more
reasonable.
How about _after_ patch 2, otherwise this patch will break the build, right?
This change won't break the build, actually no matter what the first parameter of MODULE_DEVICE_TABLE is, it won’t cause any build errors.
Quoted 11 lines
Quoted 6 lines
Quoted 5 lines
Does this patch here break the build? If not, how is it working?
And if you only have one vop driver, why do you need autoloading for it?
No, it doesn't break the build. But actually it won't work(autoloaded) when
kernel boot and vop device appears.
Quoted 4 lines
Although we may only have one vop driver, but in the mic
Kconfig, the intel mic/vop/cosm/scif drivers all recommended to be built as modules, if we don't add autoloading for them, we may need modprobe
Quoted 7 lines
them one by one manually both on EP and RC side.
Quoted 2 lines
Obviously, for our use case, driver autoloading is more convenient.
Why are these all not "
mic_SUFFIX" type drivers? Why "vop" and "cosm" and "scif"?
For VOP driver, it is designed to be a hardware independent Virtio Over PCIe (VOP) driver. This is why we want to reuse it on i.MX platform. In theory, it can be applied to any platform. With some changes, cosm driver also can be hardware independent.
So the names of them don’t use "mic_SUFFIX".
Quoted 1 line
And if you only have 1 driver, then what would cause autoloading?
As I understand it, if we add support for the driver autoloading like patch2, driver will be autoloaded when the matched device appears.
Please correct me if I'm wrong.
Regards
Sherry
Quoted 4 lines
thanks,
greg k-h
PATCH 2/3 mic: vop: module autoprobing support for vop drivers
In reply to Sherry SunAdd vop autoprobing support to MODULE_DEVICE_TABLE() by adding info about struct vop_device_id in devicetable-offsets.c and add a vop entry point in file2alias.c.
The type argument for MODULE_DEVICE_TABLE(type, name) is vop.
--- drivers/misc/mic/bus/vop_bus.h | 7 +------ include/linux/mod_devicetable.h | 7 +++++++ scripts/mod/devicetable-offsets.c | 4 ++++ scripts/mod/file2alias.c | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-)
drivers/misc/mic/bus/vop_bus.h +1 -6
@@ -14,16 +14,11 @@*/ #include <linux/dmaengine.h> #include <linux/interrupt.h> +#include <linux/mod_devicetable.h> #include "../common/mic_dev.h" -struct vop_device_id { -u32 device; -u32 vendor; -}; -#define VOP_DEV_TRNSP 1 -#define VOP_DEV_ANY_ID 0xffffffff/* * Size of the internal buffer used during DMA's as an intermediate buffer * for copy to/from user. Must be an integral number of pages.
include/linux/mod_devicetable.h +7 -0
@@ -838,4 +838,11 @@ struct mhi_device_id { kernel_ulong_t driver_data; }; +/* vop */ +struct vop_device_id { +__u32 device; +__u32 vendor; +}; +#define VOP_DEV_ANY_ID 0xffffffff +#endif /* LINUX_MOD_DEVICETABLE_H */
scripts/mod/devicetable-offsets.c +4 -0
@@ -243,5 +243,9 @@ int main(void)DEVID (mhi_device_id);DEVID_FIELD (mhi_device_id, chan); +DEVID (vop_device_id); +DEVID_FIELD (vop_device_id, device); +DEVID_FIELD (vop_device_id, vendor); +return 0 ; }
scripts/mod/file2alias.c +16 -0
@@ -1368,6 +1368,21 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias)return 1 ; } +/* Looks like: vop:dNvN */ +static int do_vop_entry (const char *filename,void *symval, +char *alias) +{ +DEF_FIELD (symval, vop_device_id, device); +DEF_FIELD (symval, vop_device_id, vendor); + +strcpy (alias,"vop:" ); +ADD (alias,"d" , device !=VOP_DEV_ANY_ID , device); +ADD (alias,"v" , vendor !=VOP_DEV_ANY_ID , vendor); + +add_wildcard (alias); +return 1 ; +} +/* Does namelen bytes of name exactly match the symbol? */ static bool sym_is (const char *name,unsigned namelen,const char *symbol) {
@@ -1442,6 +1457,7 @@ static const struct devtable devtable[] = { {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, {"mhi", SIZE_mhi_device_id, do_mhi_entry}, + {"vop", SIZE_vop_device_id, do_vop_entry}, };/* Create MODULE_ALIAS() statements.
Signature · 1 line
2.17.1
PATCH 3/3 mic: cosm: module autoprobing support for cosm driver
In reply to Sherry SunAdd 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.
--- 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(+)
drivers/misc/mic/bus/cosm_bus.c +8 -0
@@ -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, };
drivers/misc/mic/cosm/cosm_main.c +7 -0
@@ -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
include/linux/mod_devicetable.h +8 -0
@@ -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 */
scripts/mod/devicetable-offsets.c +3 -0
@@ -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 ; }
scripts/mod/file2alias.c +11 -0
@@ -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.
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH 3/3] mic: cosm: module autoprobing support for cosm driver
Quoted 129 lines · Sherry Sun
Add uevent callback for
cosm_busand addcosm_device_idfor cosm driver which is needed forMODULE_DEVICE_TABLE. Also adding structcosm_device_idindevicetable-offsets.cand the cosm entry point infile2alias.c.Cosm driver will be autoloaded when cosm device appears.
Signed-off-by Sherry Sun <[email protected]>--- 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(+)drivers/misc/mic/bus/cosm_bus.c +8
-0@@ -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, };drivers/misc/mic/cosm/cosm_main.c +7
-0@@ -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_suspendinclude/linux/mod_devicetable.h +8
-0@@ -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 */ scripts/mod/devicetable-offsets.c +3
-0@@ -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 ; }scripts/mod/file2alias.c +11
-0@@ -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. Signature · 1 line
2.17.1
You are adding MODULE_DEVICE_TABLE() support for a class of drivers, but then never adding that support to those drivers? Why add this at all then? Shouldn't you also be modifying a bunch of drivers to get this to work properly?
thanks,
greg k-h
RE: [PATCH 3/3] mic: cosm: module autoprobing support for cosm driver
Hi Greg,
Quoted 131 lines · Sherry Sun
Quoted 25 lines
Add uevent callback for
cosm_busand addcosm_device_idfor cosm driver which is needed forMODULE_DEVICE_TABLE. Also adding structcosm_device_idindevicetable-offsets.cand the cosm entry point infile2alias.c.Cosm driver will be autoloaded when cosm device appears.
Signed-off-by Sherry Sun <[email protected]>--- 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(+)(quoted diff) +0
-0
b/drivers/misc/mic/bus/cosm_bus.cindex5f2141c71738..736e27bbc9f9100644drivers/misc/mic/bus/cosm_bus.c +0
-0@@ -14,6 +14,13 @@/* Unique numbering for cosm devices. */ static DEFINE_IDA (cosm_index_ida);drivers/misc/mic/bus/cosm_bus.c line 26
Quoted 10 lines
drivers/misc/mic/bus/cosm_bus.c +7
-0+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
scripts/mod/file2alias.c static int do_vop_entry(const char *filename,
Quoted 70 lines
int
cosm_dev_remove(struct device *d)static struct
bus_typecosm_bus= {drivers/misc/mic/bus/cosm_bus.c +1
-0.name = "cosm_bus", + .uevent = cosm_uevent, .probe = cosm_dev_probe, .remove = cosm_dev_remove, };drivers/misc/mic/cosm/cosm_main.c +1
-0@@ -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)drivers/misc/mic/cosm/cosm_main.c +6
-0return 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(quoted diff) +0
-0
b/include/linux/mod_devicetable.hindex736cdc236cf9..ea6cdfe1a3a3100644include/linux/mod_devicetable.h +8
-0@@ -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 */ scripts/mod/devicetable-offsets.c +3
-0@@ -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 ; }scripts/mod/file2alias.c index renamed from scripts/mod/file2alias.c +0
-0
8063b778eedf..f7c80e4da137100644scripts/mod/file2alias.c +0
-0@@ -1383,6 +1383,16 @@ static int do_vop_entry(const char *filename,void *symval,
Quoted 22 lines
scripts/mod/file2alias.c +11
-0return 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}, };
Quoted 9 lines
Quoted 4 lines
scripts/mod/file2alias.c +0
-1/* Create MODULE_ALIAS() statements. -- 2.17.1
You are adding
MODULE_DEVICE_TABLE()support for a class of drivers, but then never adding that support to those drivers? Why add this at all then? Shouldn't you also be modifying a bunch of drivers to get this to work properly?
I also wonder why Intel didn't add the specific implementation code to support MODULE_DEVICE_TABLE() like here. The MODULE_DEVICE_TABLE() macro was written here, but it has no effect before.
The changes in this patches is enough to support the drivers autoloading, there no need to modify other codes to make this function works.
Regards
sherry
Quoted 4 lines
thanks,
greg k-h