From: Varsha Rao <rvarsha016@gmail.com>
To: Matthew Wilcox <mawilcox@microsoft.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator.
Date: Sun, 9 Apr 2017 10:50:25 +0530 [thread overview]
Message-ID: <CAAFX7JTCjpDG3me_VO3YnhPysxyWSym8RW+KzoXf+HZVDpcRYQ@mail.gmail.com> (raw)
In-Reply-To: <CAAFX7JSQ349OQ1kAXqGX7ozRTWdqqDm6tC1FW1MbyvjR6h32Bw@mail.gmail.com>
>> 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
next prev parent reply other threads:[~2017-04-09 5:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
[not found] <cover.1491235332.git.rvarsha016@gmail.com>
2017-04-03 16:11 ` Varsha Rao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAFX7JTCjpDG3me_VO3YnhPysxyWSym8RW+KzoXf+HZVDpcRYQ@mail.gmail.com \
--to=rvarsha016@gmail.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mawilcox@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).