linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Staging: comedi: Proc FS related cleanup
@ 2016-12-30 11:24 Cheah Kok Cheong
  2016-12-30 11:25 ` [PATCH 1/5] Staging: comedi: comedi_fops: Avoid orphaned proc entry Cheah Kok Cheong
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Cheah Kok Cheong @ 2016-12-30 11:24 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: devel, linux-kernel, Cheah Kok Cheong

This series does trivial cleanup for COMEDI proc fs related stuff.

Cheah Kok Cheong (5):
  Staging: comedi: comedi_fops: Avoid orphaned proc entry
  Staging: comedi: proc: Change file permission to read only
  Staging: comedi: proc: Add __init prefix
  Staging: comedi: proc: Add module owner
  Staging: comedi: proc: Warn if unable to create proc entry

 drivers/staging/comedi/comedi_fops.c | 6 +++---
 drivers/staging/comedi/proc.c        | 6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

-- 
2.7.4

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

* [PATCH 1/5] Staging: comedi: comedi_fops: Avoid orphaned proc entry
  2016-12-30 11:24 [PATCH 0/5] Staging: comedi: Proc FS related cleanup Cheah Kok Cheong
@ 2016-12-30 11:25 ` Cheah Kok Cheong
  2016-12-30 11:26 ` [PATCH 2/5] Staging: comedi: proc: Change file permission to read only Cheah Kok Cheong
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Cheah Kok Cheong @ 2016-12-30 11:25 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: devel, linux-kernel, Cheah Kok Cheong

Move comedi_proc_init to the end to avoid orphaned proc entry
if module loading failed.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
---
 drivers/staging/comedi/comedi_fops.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 64b3966..02df354 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2898,9 +2898,6 @@ static int __init comedi_init(void)
 
 	comedi_class->dev_groups = comedi_dev_groups;
 
-	/* XXX requires /proc interface */
-	comedi_proc_init();
-
 	/* create devices files for legacy/manual use */
 	for (i = 0; i < comedi_num_legacy_minors; i++) {
 		struct comedi_device *dev;
@@ -2917,6 +2914,9 @@ static int __init comedi_init(void)
 		mutex_unlock(&dev->mutex);
 	}
 
+	/* XXX requires /proc interface */
+	comedi_proc_init();
+
 	return 0;
 }
 module_init(comedi_init);
-- 
2.7.4

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

* [PATCH 2/5] Staging: comedi: proc: Change file permission to read only
  2016-12-30 11:24 [PATCH 0/5] Staging: comedi: Proc FS related cleanup Cheah Kok Cheong
  2016-12-30 11:25 ` [PATCH 1/5] Staging: comedi: comedi_fops: Avoid orphaned proc entry Cheah Kok Cheong
@ 2016-12-30 11:26 ` Cheah Kok Cheong
  2016-12-30 11:26 ` [PATCH 3/5] Staging: comedi: proc: Add __init prefix Cheah Kok Cheong
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Cheah Kok Cheong @ 2016-12-30 11:26 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: devel, linux-kernel, Cheah Kok Cheong

As there's no write operation, change to read only.
Was inadvertantly switched to 0644 in commit 1f817b86d5e6
("comedi: Don't use create_proc_read_entry()").

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
---
 drivers/staging/comedi/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c
index 91dea25..3513f4c 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/staging/comedi/proc.c
@@ -88,7 +88,7 @@ static const struct file_operations comedi_proc_fops = {
 
 void comedi_proc_init(void)
 {
-	proc_create("comedi", 0644, NULL, &comedi_proc_fops);
+	proc_create("comedi", 0444, NULL, &comedi_proc_fops);
 }
 
 void comedi_proc_cleanup(void)
-- 
2.7.4

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

* [PATCH 3/5] Staging: comedi: proc: Add __init prefix
  2016-12-30 11:24 [PATCH 0/5] Staging: comedi: Proc FS related cleanup Cheah Kok Cheong
  2016-12-30 11:25 ` [PATCH 1/5] Staging: comedi: comedi_fops: Avoid orphaned proc entry Cheah Kok Cheong
  2016-12-30 11:26 ` [PATCH 2/5] Staging: comedi: proc: Change file permission to read only Cheah Kok Cheong
@ 2016-12-30 11:26 ` Cheah Kok Cheong
  2016-12-30 11:27 ` [PATCH 4/5] Staging: comedi: proc: Add module owner Cheah Kok Cheong
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Cheah Kok Cheong @ 2016-12-30 11:26 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: devel, linux-kernel, Cheah Kok Cheong

Add __init prefix so that symbol will be discarded after
module loading.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
---
 drivers/staging/comedi/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c
index 3513f4c..6d13b51 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/staging/comedi/proc.c
@@ -86,7 +86,7 @@ static const struct file_operations comedi_proc_fops = {
 	.release	= single_release,
 };
 
-void comedi_proc_init(void)
+void __init comedi_proc_init(void)
 {
 	proc_create("comedi", 0444, NULL, &comedi_proc_fops);
 }
-- 
2.7.4

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

* [PATCH 4/5] Staging: comedi: proc: Add module owner
  2016-12-30 11:24 [PATCH 0/5] Staging: comedi: Proc FS related cleanup Cheah Kok Cheong
                   ` (2 preceding siblings ...)
  2016-12-30 11:26 ` [PATCH 3/5] Staging: comedi: proc: Add __init prefix Cheah Kok Cheong
@ 2016-12-30 11:27 ` Cheah Kok Cheong
  2016-12-30 11:27 ` [PATCH 5/5] Staging: comedi: proc: Warn if unable to create proc entry Cheah Kok Cheong
  2017-01-03 10:43 ` [PATCH 0/5] Staging: comedi: Proc FS related cleanup Ian Abbott
  5 siblings, 0 replies; 7+ messages in thread
From: Cheah Kok Cheong @ 2016-12-30 11:27 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: devel, linux-kernel, Cheah Kok Cheong

Since this is a loadable kernel module, add module ownership
to follow LKM semantics.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
---
 drivers/staging/comedi/proc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c
index 6d13b51..99b23b2e 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/staging/comedi/proc.c
@@ -80,6 +80,7 @@ static int comedi_proc_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations comedi_proc_fops = {
+	.owner		= THIS_MODULE,
 	.open		= comedi_proc_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
-- 
2.7.4

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

* [PATCH 5/5] Staging: comedi: proc: Warn if unable to create proc entry
  2016-12-30 11:24 [PATCH 0/5] Staging: comedi: Proc FS related cleanup Cheah Kok Cheong
                   ` (3 preceding siblings ...)
  2016-12-30 11:27 ` [PATCH 4/5] Staging: comedi: proc: Add module owner Cheah Kok Cheong
@ 2016-12-30 11:27 ` Cheah Kok Cheong
  2017-01-03 10:43 ` [PATCH 0/5] Staging: comedi: Proc FS related cleanup Ian Abbott
  5 siblings, 0 replies; 7+ messages in thread
From: Cheah Kok Cheong @ 2016-12-30 11:27 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: devel, linux-kernel, Cheah Kok Cheong

The proc entry is not essential for the comedi system as
evident by the support for !CONFIG_PROC_FS. So for failure
to create, just warn and continue loading.

Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
---
 drivers/staging/comedi/proc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c
index 99b23b2e..2644dd4 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/staging/comedi/proc.c
@@ -89,7 +89,8 @@ static const struct file_operations comedi_proc_fops = {
 
 void __init comedi_proc_init(void)
 {
-	proc_create("comedi", 0444, NULL, &comedi_proc_fops);
+	if (!proc_create("comedi", 0444, NULL, &comedi_proc_fops))
+		pr_warn("comedi: unable to create proc entry\n");
 }
 
 void comedi_proc_cleanup(void)
-- 
2.7.4

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

* Re: [PATCH 0/5] Staging: comedi: Proc FS related cleanup
  2016-12-30 11:24 [PATCH 0/5] Staging: comedi: Proc FS related cleanup Cheah Kok Cheong
                   ` (4 preceding siblings ...)
  2016-12-30 11:27 ` [PATCH 5/5] Staging: comedi: proc: Warn if unable to create proc entry Cheah Kok Cheong
@ 2017-01-03 10:43 ` Ian Abbott
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Abbott @ 2017-01-03 10:43 UTC (permalink / raw)
  To: Cheah Kok Cheong, hsweeten, gregkh; +Cc: devel, linux-kernel

On 30/12/16 11:24, Cheah Kok Cheong wrote:
> This series does trivial cleanup for COMEDI proc fs related stuff.
>
> Cheah Kok Cheong (5):
>   Staging: comedi: comedi_fops: Avoid orphaned proc entry
>   Staging: comedi: proc: Change file permission to read only
>   Staging: comedi: proc: Add __init prefix
>   Staging: comedi: proc: Add module owner
>   Staging: comedi: proc: Warn if unable to create proc entry
>
>  drivers/staging/comedi/comedi_fops.c | 6 +++---
>  drivers/staging/comedi/proc.c        | 6 ++++--
>  2 files changed, 7 insertions(+), 5 deletions(-)
>

Looks good, thanks!

Reviewed-by: Ian Abbott <abbotti@mev.co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

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

end of thread, other threads:[~2017-01-03 10:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-30 11:24 [PATCH 0/5] Staging: comedi: Proc FS related cleanup Cheah Kok Cheong
2016-12-30 11:25 ` [PATCH 1/5] Staging: comedi: comedi_fops: Avoid orphaned proc entry Cheah Kok Cheong
2016-12-30 11:26 ` [PATCH 2/5] Staging: comedi: proc: Change file permission to read only Cheah Kok Cheong
2016-12-30 11:26 ` [PATCH 3/5] Staging: comedi: proc: Add __init prefix Cheah Kok Cheong
2016-12-30 11:27 ` [PATCH 4/5] Staging: comedi: proc: Add module owner Cheah Kok Cheong
2016-12-30 11:27 ` [PATCH 5/5] Staging: comedi: proc: Warn if unable to create proc entry Cheah Kok Cheong
2017-01-03 10:43 ` [PATCH 0/5] Staging: comedi: Proc FS related cleanup Ian Abbott

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