* [PATCH 2/5] drivers: char: Add space after ','.
[not found] <cover.1491235332.git.rvarsha016@gmail.com>
@ 2017-04-03 16:09 ` Varsha Rao
0 siblings, 0 replies; 9+ messages in thread
From: Varsha Rao @ 2017-04-03 16:09 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: linux-kernel
Add space which is required after ',' to follow Linux coding style. This
patch fixes the checkpatch issue.
Signed-off-by: Varsha Rao <rvarsha016@gmail.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 ed8f79c..3a19fa3 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -150,7 +150,7 @@ static int misc_open(struct inode *inode, struct file *file)
err = 0;
replace_fops(file, new_fops);
if (file->f_op->open)
- err = file->f_op->open(inode,file);
+ err = file->f_op->open(inode, file);
fail:
mutex_unlock(&misc_mtx);
return err;
@@ -287,7 +287,7 @@ static int __init misc_init(void)
goto fail_remove;
err = -EIO;
- if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
+ if (register_chrdev(MISC_MAJOR, "misc", &misc_fops))
goto fail_printk;
misc_class->devnode = misc_devnode;
return 0;
--
2.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/5] drivers: char: Replace "foo * bar" with "foo *bar".
[not found] <cover.1491563538.git.rvarsha016@gmail.com>
@ 2017-04-07 11:28 ` Varsha Rao
2017-04-07 11:31 ` [PATCH 2/5] drivers: char: Add space after ',' Varsha Rao
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Varsha Rao @ 2017-04-07 11:28 UTC (permalink / raw)
To: Matthew Wilcox, Arnd Bergmann, Greg Kroah-Hartman; +Cc: linux-kernel
Remove space after * in pointer type, to follow linux coding style. This
patch fixes the following checkpatch issue:
ERROR: "foo * bar" should be "foo *bar"
Signed-off-by: Varsha Rao <rvarsha016@gmail.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 8069b36..ed8f79c 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -109,7 +109,7 @@ static const struct file_operations misc_proc_fops = {
};
#endif
-static int misc_open(struct inode * inode, struct file * file)
+static int misc_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
struct miscdevice *c;
@@ -182,7 +182,7 @@ static const struct file_operations misc_fops = {
* failure.
*/
-int misc_register(struct miscdevice * misc)
+int misc_register(struct miscdevice *misc)
{
dev_t dev;
int err = 0;
--
2.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/5] drivers: char: Add space after ','.
[not found] <cover.1491563538.git.rvarsha016@gmail.com>
2017-04-07 11:28 ` [PATCH 1/5] drivers: char: Replace "foo * bar" with "foo *bar" Varsha Rao
@ 2017-04-07 11:31 ` Varsha Rao
2017-04-07 11:32 ` [PATCH 3/5] drivers: char: Add blank line after declaration Varsha Rao
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Varsha Rao @ 2017-04-07 11:31 UTC (permalink / raw)
To: Matthew Wilcox, Arnd Bergmann, Greg Kroah-Hartman; +Cc: linux-kernel
Add space which is required after ',' to follow linux coding style. This
patch fixes the checkpatch issue.
Signed-off-by: Varsha Rao <rvarsha016@gmail.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 ed8f79c..3a19fa3 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -150,7 +150,7 @@ static int misc_open(struct inode *inode, struct file *file)
err = 0;
replace_fops(file, new_fops);
if (file->f_op->open)
- err = file->f_op->open(inode,file);
+ err = file->f_op->open(inode, file);
fail:
mutex_unlock(&misc_mtx);
return err;
@@ -287,7 +287,7 @@ static int __init misc_init(void)
goto fail_remove;
err = -EIO;
- if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
+ if (register_chrdev(MISC_MAJOR, "misc", &misc_fops))
goto fail_printk;
misc_class->devnode = misc_devnode;
return 0;
--
2.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/5] drivers: char: Add blank line after declaration.
[not found] <cover.1491563538.git.rvarsha016@gmail.com>
2017-04-07 11:28 ` [PATCH 1/5] drivers: char: Replace "foo * bar" with "foo *bar" Varsha Rao
2017-04-07 11:31 ` [PATCH 2/5] drivers: char: Add space after ',' Varsha Rao
@ 2017-04-07 11:32 ` Varsha Rao
2017-04-07 11:34 ` [PATCH 4/5] drivers: char: Replace printk with pr_err Varsha Rao
2017-04-07 11:34 ` [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator Varsha Rao
4 siblings, 0 replies; 9+ messages in thread
From: Varsha Rao @ 2017-04-07 11:32 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Matthew Wilcox; +Cc: linux-kernel
Add a blank line after declaration, to fix the checkpatch issue.
Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
drivers/char/misc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 3a19fa3..1312e29 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -194,6 +194,7 @@ int misc_register(struct miscdevice *misc)
if (is_dynamic) {
int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
+
if (i >= DYNAMIC_MINORS) {
err = -EBUSY;
goto out;
--
2.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/5] drivers: char: Replace printk with pr_err.
[not found] <cover.1491563538.git.rvarsha016@gmail.com>
` (2 preceding siblings ...)
2017-04-07 11:32 ` [PATCH 3/5] drivers: char: Add blank line after declaration Varsha Rao
@ 2017-04-07 11:34 ` Varsha Rao
2017-04-07 15:46 ` Greg Kroah-Hartman
2017-04-07 11:34 ` [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator Varsha Rao
4 siblings, 1 reply; 9+ messages in thread
From: Varsha Rao @ 2017-04-07 11:34 UTC (permalink / raw)
To: Matthew Wilcox, Arnd Bergmann, Greg Kroah-Hartman; +Cc: linux-kernel
Replace printk with pr_err to fix the checkpatch issue.
Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
drivers/char/misc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 1312e29..c9cd1ea 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -294,7 +294,7 @@ static int __init misc_init(void)
return 0;
fail_printk:
- printk("unable to get major %d for misc devices\n", MISC_MAJOR);
+ pr_err("unable to get major %d for misc devices\n", MISC_MAJOR);
class_destroy(misc_class);
fail_remove:
if (ret)
--
2.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator.
[not found] <cover.1491563538.git.rvarsha016@gmail.com>
` (3 preceding siblings ...)
2017-04-07 11:34 ` [PATCH 4/5] drivers: char: Replace printk with pr_err Varsha Rao
@ 2017-04-07 11:34 ` Varsha Rao
2017-04-07 15:45 ` Greg Kroah-Hartman
4 siblings, 1 reply; 9+ messages in thread
From: Varsha Rao @ 2017-04-07 11:34 UTC (permalink / raw)
To: Matthew Wilcox, Arnd Bergmann, Greg Kroah-Hartman; +Cc: linux-kernel
Replace bit operation functions with IDA allocator functions. As IDA
allocation is simpler.
Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
drivers/char/misc.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index c9cd1ea..5786281 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -60,7 +60,7 @@ static DEFINE_MUTEX(misc_mtx);
* Assigned numbers, used for dynamic minors
*/
#define DYNAMIC_MINORS 64 /* like dynamic majors */
-static DECLARE_BITMAP(misc_minors, DYNAMIC_MINORS);
+static DEFINE_IDA(misc_minors_ida);
#ifdef CONFIG_PROC_FS
static void *misc_seq_start(struct seq_file *seq, loff_t *pos)
@@ -193,14 +193,18 @@ int misc_register(struct miscdevice *misc)
mutex_lock(&misc_mtx);
if (is_dynamic) {
- int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
+ int i = ida_simple_get(&misc_minors_ida, 0,
+ DYNAMIC_MINORS, GFP_KERNEL);
if (i >= DYNAMIC_MINORS) {
err = -EBUSY;
goto out;
- }
+ } else if (i < 0) {
+ err = i;
+ goto out;
+ } else {
misc->minor = DYNAMIC_MINORS - i - 1;
- set_bit(i, misc_minors);
+ }
} else {
struct miscdevice *c;
@@ -222,7 +226,7 @@ int misc_register(struct miscdevice *misc)
int i = DYNAMIC_MINORS - misc->minor - 1;
if (i < DYNAMIC_MINORS && i >= 0)
- clear_bit(i, misc_minors);
+ ida_simple_remove(&misc_minors_ida, i);
misc->minor = MISC_DYNAMIC_MINOR;
}
err = PTR_ERR(misc->this_device);
@@ -258,7 +262,7 @@ void misc_deregister(struct miscdevice *misc)
list_del(&misc->list);
device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
if (i < DYNAMIC_MINORS && i >= 0)
- clear_bit(i, misc_minors);
+ ida_simple_remove(&misc_minors_ida, i);
mutex_unlock(&misc_mtx);
}
--
2.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator.
2017-04-07 11:34 ` [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator Varsha Rao
@ 2017-04-07 15:45 ` Greg Kroah-Hartman
[not found] ` <CAAFX7JSPg1s8qT5Qr=Z+QnuUYpjvyFr7T_Qf_3D08ecT3P65SQ@mail.gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2017-04-07 15:45 UTC (permalink / raw)
To: Varsha Rao; +Cc: Matthew Wilcox, Arnd Bergmann, linux-kernel
On Fri, Apr 07, 2017 at 05:04:41PM +0530, Varsha Rao wrote:
> Replace bit operation functions with IDA allocator functions. As IDA
> allocation is simpler.
But why does this matter?
>
> Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
> ---
> drivers/char/misc.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> index c9cd1ea..5786281 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -60,7 +60,7 @@ static DEFINE_MUTEX(misc_mtx);
> * Assigned numbers, used for dynamic minors
> */
> #define DYNAMIC_MINORS 64 /* like dynamic majors */
> -static DECLARE_BITMAP(misc_minors, DYNAMIC_MINORS);
> +static DEFINE_IDA(misc_minors_ida);
>
> #ifdef CONFIG_PROC_FS
> static void *misc_seq_start(struct seq_file *seq, loff_t *pos)
> @@ -193,14 +193,18 @@ int misc_register(struct miscdevice *misc)
> mutex_lock(&misc_mtx);
>
> if (is_dynamic) {
> - int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
> + int i = ida_simple_get(&misc_minors_ida, 0,
> + DYNAMIC_MINORS, GFP_KERNEL);
>
> if (i >= DYNAMIC_MINORS) {
> err = -EBUSY;
> goto out;
> - }
> + } else if (i < 0) {
> + err = i;
> + goto out;
> + } else {
> misc->minor = DYNAMIC_MINORS - i - 1;
> - set_bit(i, misc_minors);
> + }
Your indentation is now incorrect :(
> } else {
> struct miscdevice *c;
>
> @@ -222,7 +226,7 @@ int misc_register(struct miscdevice *misc)
> int i = DYNAMIC_MINORS - misc->minor - 1;
>
> if (i < DYNAMIC_MINORS && i >= 0)
> - clear_bit(i, misc_minors);
> + ida_simple_remove(&misc_minors_ida, i);
> misc->minor = MISC_DYNAMIC_MINOR;
> }
> err = PTR_ERR(misc->this_device);
> @@ -258,7 +262,7 @@ void misc_deregister(struct miscdevice *misc)
> list_del(&misc->list);
> device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
> if (i < DYNAMIC_MINORS && i >= 0)
> - clear_bit(i, misc_minors);
> + ida_simple_remove(&misc_minors_ida, i);
As much as I like the ida interface, I don't see why it is required to
use it here, you have not provided any justification for this patch at
all :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/5] drivers: char: Replace printk with pr_err.
2017-04-07 11:34 ` [PATCH 4/5] drivers: char: Replace printk with pr_err Varsha Rao
@ 2017-04-07 15:46 ` Greg Kroah-Hartman
0 siblings, 0 replies; 9+ messages in thread
From: Greg Kroah-Hartman @ 2017-04-07 15:46 UTC (permalink / raw)
To: Varsha Rao; +Cc: Matthew Wilcox, Arnd Bergmann, linux-kernel
On Fri, Apr 07, 2017 at 05:04:06PM +0530, Varsha Rao wrote:
> Replace printk with pr_err to fix the checkpatch issue.
>
> Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
> ---
> drivers/char/misc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> index 1312e29..c9cd1ea 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -294,7 +294,7 @@ static int __init misc_init(void)
> return 0;
>
> fail_printk:
> - printk("unable to get major %d for misc devices\n", MISC_MAJOR);
> + pr_err("unable to get major %d for misc devices\n", MISC_MAJOR);
Is pr_fmt properly set to use this?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator.
[not found] ` <CAAFX7JSQ349OQ1kAXqGX7ozRTWdqqDm6tC1FW1MbyvjR6h32Bw@mail.gmail.com>
@ 2017-04-09 5:20 ` Varsha Rao
0 siblings, 0 replies; 9+ messages in thread
From: Varsha Rao @ 2017-04-09 5:20 UTC (permalink / raw)
To: Matthew Wilcox, Greg Kroah-Hartman, Arnd Bergmann; +Cc: linux-kernel
>> Replace bit operation functions with IDA allocator functions. As IDA
>> allocation is simpler.
>
> But why does this matter?
Few of the files in this driver is already using ida allocation. For maintaining
the uniformity I have used ida allocation.
Files using idr-ida interface
hw_random/virtio-rng.c
tpm/tpm-chip.c
ppdev.c
tpm/tpm-interface.c
tpm/tpm.h
>> if (is_dynamic) {
>> - int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
>> + int i = ida_simple_get(&misc_minors_ida, 0,
>> + DYNAMIC_MINORS, GFP_KERNEL);
>>
>> if (i >= DYNAMIC_MINORS) {
>> err = -EBUSY;
>> goto out;
>> - }
>> + } else if (i < 0) {
>> + err = i;
>> + goto out;
>> + } else {
>> misc->minor = DYNAMIC_MINORS - i - 1;
>> - set_bit(i, misc_minors);
>> + }
>
> Your indentation is now incorrect :(
I don't know but in the patch it has correct indentation as below.
- set_bit(i, misc_minors);
+ }
} else {
struct miscdevice *c;
>> } else {
>> struct miscdevice *c;
>>
>> @@ -222,7 +226,7 @@ int misc_register(struct miscdevice *misc)
>> int i = DYNAMIC_MINORS - misc->minor - 1;
>>
>> if (i < DYNAMIC_MINORS && i >= 0)
>> - clear_bit(i, misc_minors);
>> + ida_simple_remove(&misc_minors_ida, i);
>> misc->minor = MISC_DYNAMIC_MINOR;
>> }
>> err = PTR_ERR(misc->this_device);
>> @@ -258,7 +262,7 @@ void misc_deregister(struct miscdevice *misc)
>> list_del(&misc->list);
>> device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
>> if (i < DYNAMIC_MINORS && i >= 0)
>> - clear_bit(i, misc_minors);
>> + ida_simple_remove(&misc_minors_ida, i);
>
> As much as I like the ida interface, I don't see why it is required to
> use it here, you have not provided any justification for this patch at
> all :(
Here by the usage of ida interface, allocation will be simpler, faster and
more space efficient. Also conversion to it is simple. As I mentioned
earlier in this mail also to maintain uniformity of the driver.
Thanks,
Varsha Rao
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-04-09 5:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1491563538.git.rvarsha016@gmail.com>
2017-04-07 11:28 ` [PATCH 1/5] drivers: char: Replace "foo * bar" with "foo *bar" Varsha Rao
2017-04-07 11:31 ` [PATCH 2/5] drivers: char: Add space after ',' Varsha Rao
2017-04-07 11:32 ` [PATCH 3/5] drivers: char: Add blank line after declaration Varsha Rao
2017-04-07 11:34 ` [PATCH 4/5] drivers: char: Replace printk with pr_err Varsha Rao
2017-04-07 15:46 ` Greg Kroah-Hartman
2017-04-07 11:34 ` [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator Varsha Rao
2017-04-07 15:45 ` Greg Kroah-Hartman
[not found] ` <CAAFX7JSPg1s8qT5Qr=Z+QnuUYpjvyFr7T_Qf_3D08ecT3P65SQ@mail.gmail.com>
[not found] ` <CAAFX7JSQ349OQ1kAXqGX7ozRTWdqqDm6tC1FW1MbyvjR6h32Bw@mail.gmail.com>
2017-04-09 5:20 ` Varsha Rao
[not found] <cover.1491235332.git.rvarsha016@gmail.com>
2017-04-03 16:09 ` [PATCH 2/5] drivers: char: Add space after ',' Varsha Rao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.