linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload
@ 2016-10-12 18:55 Javier Martinez Canillas
  2016-10-12 18:55 ` [PATCH 2/2] net: wan: slic_ds26522: Export OF module alias information Javier Martinez Canillas
  2016-10-14 14:12 ` [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Javier Martinez Canillas @ 2016-10-12 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, netdev, Zhao Qiang, David S. Miller

If the driver is built as a module, module alias information isn't filled
so the module won't be autoloaded. Add a SPI device ID table and use the
MODULE_DEVICE_TABLE() macro so the information is exported in the module.

Before this patch:

$ modinfo drivers/net/wan/slic_ds26522.ko | grep alias
$

After this patch:

$ modinfo drivers/net/wan/slic_ds26522.ko | grep alias
alias:          spi:ds26522

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

 drivers/net/wan/slic_ds26522.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c
index d06a887a2352..53366a2232f0 100644
--- a/drivers/net/wan/slic_ds26522.c
+++ b/drivers/net/wan/slic_ds26522.c
@@ -223,6 +223,12 @@ static int slic_ds26522_probe(struct spi_device *spi)
 	return ret;
 }
 
+static const struct spi_device_id slic_ds26522_id[] = {
+	{ .name = "ds26522" },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(spi, slic_ds26522_id);
+
 static const struct of_device_id slic_ds26522_match[] = {
 	{
 	 .compatible = "maxim,ds26522",
@@ -239,6 +245,7 @@ static struct spi_driver slic_ds26522_driver = {
 		   },
 	.probe = slic_ds26522_probe,
 	.remove = slic_ds26522_remove,
+	.id_table = slic_ds26522_id,
 };
 
 static int __init slic_ds26522_init(void)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net: wan: slic_ds26522: Export OF module alias information
  2016-10-12 18:55 [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload Javier Martinez Canillas
@ 2016-10-12 18:55 ` Javier Martinez Canillas
  2016-10-14 14:12   ` David Miller
  2016-10-14 14:12 ` [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Javier Martinez Canillas @ 2016-10-12 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, netdev, Zhao Qiang, David S. Miller

When the device is registered via OF, the OF table is used to match the
driver instead of the SPI device ID table, but the entries in the later
are used as aliasses to load the module if the driver was not built-in.

This is because the SPI core always reports an SPI module alias instead
of an OF one, but that could change so it's better to always export it.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

 drivers/net/wan/slic_ds26522.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c
index 53366a2232f0..b776a0ab106c 100644
--- a/drivers/net/wan/slic_ds26522.c
+++ b/drivers/net/wan/slic_ds26522.c
@@ -235,6 +235,7 @@ static const struct of_device_id slic_ds26522_match[] = {
 	 },
 	{},
 };
+MODULE_DEVICE_TABLE(of, slic_ds26522_match);
 
 static struct spi_driver slic_ds26522_driver = {
 	.driver = {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload
  2016-10-12 18:55 [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload Javier Martinez Canillas
  2016-10-12 18:55 ` [PATCH 2/2] net: wan: slic_ds26522: Export OF module alias information Javier Martinez Canillas
@ 2016-10-14 14:12 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-10-14 14:12 UTC (permalink / raw)
  To: javier; +Cc: linux-kernel, netdev, qiang.zhao

From: Javier Martinez Canillas <javier@osg.samsung.com>
Date: Wed, 12 Oct 2016 15:55:40 -0300

> If the driver is built as a module, module alias information isn't filled
> so the module won't be autoloaded. Add a SPI device ID table and use the
> MODULE_DEVICE_TABLE() macro so the information is exported in the module.
> 
> Before this patch:
> 
> $ modinfo drivers/net/wan/slic_ds26522.ko | grep alias
> $
> 
> After this patch:
> 
> $ modinfo drivers/net/wan/slic_ds26522.ko | grep alias
> alias:          spi:ds26522
> 
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] net: wan: slic_ds26522: Export OF module alias information
  2016-10-12 18:55 ` [PATCH 2/2] net: wan: slic_ds26522: Export OF module alias information Javier Martinez Canillas
@ 2016-10-14 14:12   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-10-14 14:12 UTC (permalink / raw)
  To: javier; +Cc: linux-kernel, netdev, qiang.zhao

From: Javier Martinez Canillas <javier@osg.samsung.com>
Date: Wed, 12 Oct 2016 15:55:41 -0300

> When the device is registered via OF, the OF table is used to match the
> driver instead of the SPI device ID table, but the entries in the later
> are used as aliasses to load the module if the driver was not built-in.
> 
> This is because the SPI core always reports an SPI module alias instead
> of an OF one, but that could change so it's better to always export it.
> 
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-14 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12 18:55 [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload Javier Martinez Canillas
2016-10-12 18:55 ` [PATCH 2/2] net: wan: slic_ds26522: Export OF module alias information Javier Martinez Canillas
2016-10-14 14:12   ` David Miller
2016-10-14 14:12 ` [PATCH 1/2] net: wan: slic_ds26522: add SPI device ID table to fix module autoload David Miller

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).