* [PATCH 0/3] char: misc: Trivial cleanup
@ 2025-06-20 14:35 Zijun Hu
2025-06-20 14:35 ` [PATCH 1/3] char: misc: Remove redundant forward declarations Zijun Hu
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Zijun Hu @ 2025-06-20 14:35 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman; +Cc: Zijun Hu, linux-kernel, Zijun Hu
This patch series is to do trivial cleanup for miscdevice driver.
Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
Zijun Hu (3):
char: misc: Remove redundant forward declarations
char: misc: Rename a local variable in misc_init()
char: misc: Fix improper and inaccurate error code returned by misc_init()
drivers/char/misc.c | 10 +++++-----
include/linux/miscdevice.h | 3 ---
2 files changed, 5 insertions(+), 8 deletions(-)
---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250620-fix_mischar-794de4259592
Best regards,
--
Zijun Hu <zijun.hu@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] char: misc: Remove redundant forward declarations
2025-06-20 14:35 [PATCH 0/3] char: misc: Trivial cleanup Zijun Hu
@ 2025-06-20 14:35 ` Zijun Hu
2025-06-20 14:35 ` [PATCH 2/3] char: misc: Rename a local variable in misc_init() Zijun Hu
2025-06-20 14:35 ` [PATCH 3/3] char: misc: Fix improper and inaccurate error code returned by misc_init() Zijun Hu
2 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2025-06-20 14:35 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman; +Cc: Zijun Hu, linux-kernel, Zijun Hu
From: Zijun Hu <zijun.hu@oss.qualcomm.com>
Header miscdevice.h includes linux/device.h which has definations for
below two forward declarations directly or indirectly:
struct device;
struct attribute_group;
Remove these redundant forward declarations from miscdevice.h
Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
include/linux/miscdevice.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 69e110c2b86a9b16c1637778a25e1eebb3fd0111..3e6deb00fc8535a7571f85489c74979e18385bad 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -73,9 +73,6 @@
#define RFKILL_MINOR 242
#define MISC_DYNAMIC_MINOR 255
-struct device;
-struct attribute_group;
-
struct miscdevice {
int minor;
const char *name;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] char: misc: Rename a local variable in misc_init()
2025-06-20 14:35 [PATCH 0/3] char: misc: Trivial cleanup Zijun Hu
2025-06-20 14:35 ` [PATCH 1/3] char: misc: Remove redundant forward declarations Zijun Hu
@ 2025-06-20 14:35 ` Zijun Hu
2025-06-24 15:47 ` Greg Kroah-Hartman
2025-06-20 14:35 ` [PATCH 3/3] char: misc: Fix improper and inaccurate error code returned by misc_init() Zijun Hu
2 siblings, 1 reply; 5+ messages in thread
From: Zijun Hu @ 2025-06-20 14:35 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman; +Cc: Zijun Hu, linux-kernel, Zijun Hu
From: Zijun Hu <zijun.hu@oss.qualcomm.com>
Local variable @ret is not used for return value in misc_init().
Give it a different name @pde.
Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
drivers/char/misc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index d5accc10a110098f7090dd0f900bc5fae5f75f74..f5ef8c175adb559e67dfe905d43d1404b249cc9e 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -289,9 +289,9 @@ EXPORT_SYMBOL(misc_deregister);
static int __init misc_init(void)
{
int err;
- struct proc_dir_entry *ret;
+ struct proc_dir_entry *pde;
- ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
+ pde = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
err = class_register(&misc_class);
if (err)
goto fail_remove;
@@ -305,7 +305,7 @@ static int __init misc_init(void)
pr_err("unable to get major %d for misc devices\n", MISC_MAJOR);
class_unregister(&misc_class);
fail_remove:
- if (ret)
+ if (pde)
remove_proc_entry("misc", NULL);
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] char: misc: Fix improper and inaccurate error code returned by misc_init()
2025-06-20 14:35 [PATCH 0/3] char: misc: Trivial cleanup Zijun Hu
2025-06-20 14:35 ` [PATCH 1/3] char: misc: Remove redundant forward declarations Zijun Hu
2025-06-20 14:35 ` [PATCH 2/3] char: misc: Rename a local variable in misc_init() Zijun Hu
@ 2025-06-20 14:35 ` Zijun Hu
2 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2025-06-20 14:35 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman; +Cc: Zijun Hu, linux-kernel, Zijun Hu
From: Zijun Hu <zijun.hu@oss.qualcomm.com>
misc_init() returns -EIO for __register_chrdev() invocation failure, but:
- -EIO is for I/O error normally, but __register_chrdev() does not do I/O.
- -EIO can not cover various error codes returned by __register_chrdev().
Fix by returning error code of __register_chrdev().
Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
drivers/char/misc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index f5ef8c175adb559e67dfe905d43d1404b249cc9e..e5ea36bbf6b3d1313eb35d3259617bf90c55727d 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -296,8 +296,8 @@ static int __init misc_init(void)
if (err)
goto fail_remove;
- err = -EIO;
- if (__register_chrdev(MISC_MAJOR, 0, MINORMASK + 1, "misc", &misc_fops))
+ err = __register_chrdev(MISC_MAJOR, 0, MINORMASK + 1, "misc", &misc_fops);
+ if (err < 0)
goto fail_printk;
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] char: misc: Rename a local variable in misc_init()
2025-06-20 14:35 ` [PATCH 2/3] char: misc: Rename a local variable in misc_init() Zijun Hu
@ 2025-06-24 15:47 ` Greg Kroah-Hartman
0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2025-06-24 15:47 UTC (permalink / raw)
To: Zijun Hu; +Cc: Arnd Bergmann, linux-kernel, Zijun Hu
On Fri, Jun 20, 2025 at 10:35:19PM +0800, Zijun Hu wrote:
> From: Zijun Hu <zijun.hu@oss.qualcomm.com>
>
> Local variable @ret is not used for return value in misc_init().
>
> Give it a different name @pde.
>
> Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
> ---
> drivers/char/misc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> index d5accc10a110098f7090dd0f900bc5fae5f75f74..f5ef8c175adb559e67dfe905d43d1404b249cc9e 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -289,9 +289,9 @@ EXPORT_SYMBOL(misc_deregister);
> static int __init misc_init(void)
> {
> int err;
> - struct proc_dir_entry *ret;
> + struct proc_dir_entry *pde;
"pde" is an odd name.
> - ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
> + pde = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
Why not "misc_proc_file" as a better name?
> err = class_register(&misc_class);
> if (err)
> goto fail_remove;
> @@ -305,7 +305,7 @@ static int __init misc_init(void)
> pr_err("unable to get major %d for misc devices\n", MISC_MAJOR);
> class_unregister(&misc_class);
> fail_remove:
> - if (ret)
> + if (pde)
Again, "pde" is a rough name, let's pick a better one please.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-24 15:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 14:35 [PATCH 0/3] char: misc: Trivial cleanup Zijun Hu
2025-06-20 14:35 ` [PATCH 1/3] char: misc: Remove redundant forward declarations Zijun Hu
2025-06-20 14:35 ` [PATCH 2/3] char: misc: Rename a local variable in misc_init() Zijun Hu
2025-06-24 15:47 ` Greg Kroah-Hartman
2025-06-20 14:35 ` [PATCH 3/3] char: misc: Fix improper and inaccurate error code returned by misc_init() Zijun Hu
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).