netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload
@ 2015-10-30 12:49 Javier Martinez Canillas
  2015-10-30 12:49 ` [PATCH 1/2] net: encx24j600: Fix SPI id table definition Javier Martinez Canillas
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Javier Martinez Canillas @ 2015-10-30 12:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev, Jon Ringle, davem, Javier Martinez Canillas

Hello,

Recently I've been trying to fix module autoloading for all SPI drivers and
found that the encx24j600 driver does not fill module alias information due
missing a MODULE_DEVICE_TABLE() so module autload won't work and the driver
Kconfig symbol is tristate which means the driver can be built as a module.

But also the SPI id table is not correctly defined so this series fixes both
issues.

The patches have been applied on top of the next-next tree master branch:

git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master

Best regards,
Javier


Javier Martinez Canillas (2):
  net: encx24j600: Fix SPI id table definition
  net: encx24j600: Export missing SPI module alias information

 drivers/net/ethernet/microchip/encx24j600.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

-- 
2.4.3

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

* [PATCH 1/2] net: encx24j600: Fix SPI id table definition
  2015-10-30 12:49 [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload Javier Martinez Canillas
@ 2015-10-30 12:49 ` Javier Martinez Canillas
  2015-10-30 12:49 ` [PATCH 2/2] net: encx24j600: Export missing SPI module alias information Javier Martinez Canillas
  2015-11-02 20:33 ` [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Javier Martinez Canillas @ 2015-10-30 12:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev, Jon Ringle, davem, Javier Martinez Canillas

A driver's SPI id table is expected to be an array of struct spi_device_id
that ends with a zero-initialized sentinel entry. But this driver defines
the table as a single struct spi_device_id and sets .id_table to a pointer
to this struct.

But spi_match_id() has a loop that iterates while the struct spi_device_id
.name[0] is not NULL, so not having a sentinel can cause a NULL pointer
deference error.

This patch defines the SPI id table correctly as all other SPI drivers do.

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

 drivers/net/ethernet/microchip/encx24j600.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/microchip/encx24j600.c b/drivers/net/ethernet/microchip/encx24j600.c
index bf08ce2baf8d..c2dafc1c53de 100644
--- a/drivers/net/ethernet/microchip/encx24j600.c
+++ b/drivers/net/ethernet/microchip/encx24j600.c
@@ -1094,8 +1094,9 @@ static int encx24j600_spi_remove(struct spi_device *spi)
 	return 0;
 }
 
-static const struct spi_device_id encx24j600_spi_id_table = {
-	.name = "encx24j600"
+static const struct spi_device_id encx24j600_spi_id_table[] = {
+	{ .name = "encx24j600" },
+	{ /* sentinel */ }
 };
 
 static struct spi_driver encx24j600_spi_net_driver = {
@@ -1106,7 +1107,7 @@ static struct spi_driver encx24j600_spi_net_driver = {
 	},
 	.probe		= encx24j600_spi_probe,
 	.remove		= encx24j600_spi_remove,
-	.id_table	= &encx24j600_spi_id_table,
+	.id_table	= encx24j600_spi_id_table,
 };
 
 static int __init encx24j600_init(void)
-- 
2.4.3

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

* [PATCH 2/2] net: encx24j600: Export missing SPI module alias information
  2015-10-30 12:49 [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload Javier Martinez Canillas
  2015-10-30 12:49 ` [PATCH 1/2] net: encx24j600: Fix SPI id table definition Javier Martinez Canillas
@ 2015-10-30 12:49 ` Javier Martinez Canillas
  2015-11-02 20:33 ` [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Javier Martinez Canillas @ 2015-10-30 12:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev, Jon Ringle, davem, Javier Martinez Canillas

The driver Kconfig symbol is tristate which means that it can be built as
a module but the module alias information is not added to the module info
so module autoload won't work since user-space won't have the information.

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

---

 drivers/net/ethernet/microchip/encx24j600.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/microchip/encx24j600.c b/drivers/net/ethernet/microchip/encx24j600.c
index c2dafc1c53de..2056b719c262 100644
--- a/drivers/net/ethernet/microchip/encx24j600.c
+++ b/drivers/net/ethernet/microchip/encx24j600.c
@@ -1098,6 +1098,7 @@ static const struct spi_device_id encx24j600_spi_id_table[] = {
 	{ .name = "encx24j600" },
 	{ /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(spi, encx24j600_spi_id_table);
 
 static struct spi_driver encx24j600_spi_net_driver = {
 	.driver = {
-- 
2.4.3

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

* Re: [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload
  2015-10-30 12:49 [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload Javier Martinez Canillas
  2015-10-30 12:49 ` [PATCH 1/2] net: encx24j600: Fix SPI id table definition Javier Martinez Canillas
  2015-10-30 12:49 ` [PATCH 2/2] net: encx24j600: Export missing SPI module alias information Javier Martinez Canillas
@ 2015-11-02 20:33 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-11-02 20:33 UTC (permalink / raw)
  To: javier; +Cc: linux-kernel, netdev, jringle

From: Javier Martinez Canillas <javier@osg.samsung.com>
Date: Fri, 30 Oct 2015 13:49:16 +0100

> Recently I've been trying to fix module autoloading for all SPI drivers and
> found that the encx24j600 driver does not fill module alias information due
> missing a MODULE_DEVICE_TABLE() so module autload won't work and the driver
> Kconfig symbol is tristate which means the driver can be built as a module.
> 
> But also the SPI id table is not correctly defined so this series fixes both
> issues.

Series applied to net-next, thanks.

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

end of thread, other threads:[~2015-11-02 20:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 12:49 [PATCH 0/2] net: encx24j600: Fix SPI driver module autoload Javier Martinez Canillas
2015-10-30 12:49 ` [PATCH 1/2] net: encx24j600: Fix SPI id table definition Javier Martinez Canillas
2015-10-30 12:49 ` [PATCH 2/2] net: encx24j600: Export missing SPI module alias information Javier Martinez Canillas
2015-11-02 20:33 ` [PATCH 0/2] net: encx24j600: Fix SPI driver 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).