linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] char: make tile-srom explicitly non-modular
@ 2016-10-31 17:49 Paul Gortmaker
  2016-11-07 20:56 ` [PATCH] tile-srom: allow the driver to be built as a module Chris Metcalf
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Gortmaker @ 2016-10-31 17:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Arnd Bergmann, Greg Kroah-Hartman, Chris Metcalf

The Kconfig currently controlling compilation of this code is:

drivers/char/Kconfig:config TILE_SROM
drivers/char/Kconfig:   bool "Character-device access via hypervisor to the Tilera SPI ROM"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

We also delete the MODULE_LICENSE tag etc. since all that information
is already contained at the top of the file in the comments.

We also delete the MODULE_LICENSE tag etc. since all that information
was (or is now) contained at the top of the file in the comments.

We leave the moduleparam.h since the file does declare some variables
via module_param().

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/char/tile-srom.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index 69f6b4acc377..d7ae84b1930e 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -18,7 +18,6 @@
  * Greg Kroah-Hartman, published by O'Reilly Media, Inc.
  */
 
-#include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>	/* printk() */
 #include <linux/slab.h>		/* kmalloc() */
@@ -70,8 +69,6 @@ struct srom_dev {
 
 static int srom_major;			/* Dynamic major by default */
 module_param(srom_major, int, 0);
-MODULE_AUTHOR("Tilera Corporation");
-MODULE_LICENSE("GPL");
 
 static int srom_devs;			/* Number of SROM partitions */
 static struct cdev srom_cdev;
@@ -454,19 +451,4 @@ fail_mem:
 	kfree(srom_devices);
 	return result;
 }
-
-/** srom_cleanup() - Clean up the driver's module. */
-static void srom_cleanup(void)
-{
-	int i;
-	for (i = 0; i < srom_devs; i++)
-		device_destroy(srom_class, MKDEV(srom_major, i));
-	class_destroy(srom_class);
-	cdev_del(&srom_cdev);
-	platform_device_unregister(srom_parent);
-	unregister_chrdev_region(MKDEV(srom_major, 0), srom_devs);
-	kfree(srom_devices);
-}
-
-module_init(srom_init);
-module_exit(srom_cleanup);
+device_initcall(srom_init);
-- 
2.8.4

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

* [PATCH] tile-srom: allow the driver to be built as a module
  2016-10-31 17:49 [PATCH] char: make tile-srom explicitly non-modular Paul Gortmaker
@ 2016-11-07 20:56 ` Chris Metcalf
  2016-11-08  0:12   ` Paul Gortmaker
  2016-11-10 14:19   ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Chris Metcalf @ 2016-11-07 20:56 UTC (permalink / raw)
  To: linux-kernel, Paul Gortmaker, Arnd Bergmann, Greg Kroah-Hartman
  Cc: Chris Metcalf

The code was already configured that way, but the Kconfig
file didn't support requesting it.

A buglet caused a null pointer deref when unloading the
module, but this commit also corrects that issue.

Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
---
This is in response to Paul's patch (see the in-reply-to) suggesting
we remove the module infrastructure from the code instead.

I can push this via the tile tree since it's a tile-only device,
or Greg, if you'd prefer to take it via your tree, that's fine too.

 drivers/char/Kconfig     | 2 +-
 drivers/char/tile-srom.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index dcc09739a54e..70124ca5c33d 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -578,7 +578,7 @@ config DEVPORT
 source "drivers/s390/char/Kconfig"
 
 config TILE_SROM
-	bool "Character-device access via hypervisor to the Tilera SPI ROM"
+	tristate "Character-device access via hypervisor to the Tilera SPI ROM"
 	depends on TILE
 	default y
 	---help---
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index 398800edb2cc..3d4cca64b2d4 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -312,7 +312,8 @@ ATTRIBUTE_GROUPS(srom_dev);
 
 static char *srom_devnode(struct device *dev, umode_t *mode)
 {
-	*mode = S_IRUGO | S_IWUSR;
+	if (mode)
+		*mode = 0644;
 	return kasprintf(GFP_KERNEL, "srom/%s", dev_name(dev));
 }
 
-- 
2.7.2

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

* Re: [PATCH] tile-srom: allow the driver to be built as a module
  2016-11-07 20:56 ` [PATCH] tile-srom: allow the driver to be built as a module Chris Metcalf
@ 2016-11-08  0:12   ` Paul Gortmaker
  2016-11-10 14:19   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Gortmaker @ 2016-11-08  0:12 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel, Arnd Bergmann, Greg Kroah-Hartman

[[PATCH] tile-srom: allow the driver to be built as a module] On 07/11/2016 (Mon 15:56) Chris Metcalf wrote:

> The code was already configured that way, but the Kconfig
> file didn't support requesting it.
> 
> A buglet caused a null pointer deref when unloading the
> module, but this commit also corrects that issue.
> 
> Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
> ---
> This is in response to Paul's patch (see the in-reply-to) suggesting
> we remove the module infrastructure from the code instead.

Fine by me; I have to default to keeping the code consistent with the
way it used to be, but people who want modular use cases and can test
those are welcome to extend the functionality accordingly.  In the end
I just want the code to be consistent with the Makefile/Kconfig.

Thanks,
Paul.
--

> 
> I can push this via the tile tree since it's a tile-only device,
> or Greg, if you'd prefer to take it via your tree, that's fine too.
> 
>  drivers/char/Kconfig     | 2 +-
>  drivers/char/tile-srom.c | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> index dcc09739a54e..70124ca5c33d 100644
> --- a/drivers/char/Kconfig
> +++ b/drivers/char/Kconfig
> @@ -578,7 +578,7 @@ config DEVPORT
>  source "drivers/s390/char/Kconfig"
>  
>  config TILE_SROM
> -	bool "Character-device access via hypervisor to the Tilera SPI ROM"
> +	tristate "Character-device access via hypervisor to the Tilera SPI ROM"
>  	depends on TILE
>  	default y
>  	---help---
> diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
> index 398800edb2cc..3d4cca64b2d4 100644
> --- a/drivers/char/tile-srom.c
> +++ b/drivers/char/tile-srom.c
> @@ -312,7 +312,8 @@ ATTRIBUTE_GROUPS(srom_dev);
>  
>  static char *srom_devnode(struct device *dev, umode_t *mode)
>  {
> -	*mode = S_IRUGO | S_IWUSR;
> +	if (mode)
> +		*mode = 0644;
>  	return kasprintf(GFP_KERNEL, "srom/%s", dev_name(dev));
>  }
>  
> -- 
> 2.7.2
> 

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

* Re: [PATCH] tile-srom: allow the driver to be built as a module
  2016-11-07 20:56 ` [PATCH] tile-srom: allow the driver to be built as a module Chris Metcalf
  2016-11-08  0:12   ` Paul Gortmaker
@ 2016-11-10 14:19   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2016-11-10 14:19 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel, Paul Gortmaker, Arnd Bergmann

On Mon, Nov 07, 2016 at 03:56:37PM -0500, Chris Metcalf wrote:
> The code was already configured that way, but the Kconfig
> file didn't support requesting it.
> 
> A buglet caused a null pointer deref when unloading the
> module, but this commit also corrects that issue.
> 
> Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
> ---
> This is in response to Paul's patch (see the in-reply-to) suggesting
> we remove the module infrastructure from the code instead.
> 
> I can push this via the tile tree since it's a tile-only device,
> or Greg, if you'd prefer to take it via your tree, that's fine too.

I'll take it in mine, that's easy enough...

thanks,

greg k-h

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-31 17:49 [PATCH] char: make tile-srom explicitly non-modular Paul Gortmaker
2016-11-07 20:56 ` [PATCH] tile-srom: allow the driver to be built as a module Chris Metcalf
2016-11-08  0:12   ` Paul Gortmaker
2016-11-10 14:19   ` Greg Kroah-Hartman

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