Re: idr_get_new_exact ?
- To: Ohad Ben-Cohen <ohad@xxxxxxxxxx>
- Subject: Re: idr_get_new_exact ?
- From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 20 Sep 2010 12:31:40 -0700
- Cc: linux-kernel@xxxxxxxxxxxxxxx, "Jean Delvare (PC drivers, core)" <khali@xxxxxxxxxxxx>, "Ben Dooks (embedded platforms)" <ben-linux@xxxxxxxxx>, Roland Dreier <rolandd@xxxxxxxxx>, Sean Hefty <sean.hefty@xxxxxxxxx>, Hal Rosenstock <hal.rosenstock@xxxxxxxxx>, Steve Wise <swise@xxxxxxxxxxx>, Neil Brown <neilb@xxxxxxx>, Paul Mackerras <paulus@xxxxxxxxx>, linux-i2c@xxxxxxxxxxxxxxx, linux-rdma@xxxxxxxxxxxxxxx, dm-devel@xxxxxxxxxx, linux-raid@xxxxxxxxxxxxxxx, linux-ppp@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx
- In-reply-to: <AANLkTi=ZLupVyFR0e2v-TLpeNWdw1bVMZUAhgyxLJ7OV@xxxxxxxxxxxxxx>
On Mon, 20 Sep 2010 16:11:31 +0200
Ohad Ben-Cohen <ohad@xxxxxxxxxx> wrote:
> Occasionally, drivers care about the value that idr associates with
> their pointers.
>
> Today we have idr_get_new_above() which allocates a new idr entry
> above or equal to a given starting id, but sometimes drivers need to
> force an exact value.
>
> To overcome this small API gap, drivers are wrapping idr_get_new_above
> and then either BUG_ON() or just call idr_remove() and returns -EBUSY
> when idr allocates them an id which is different than their requested
> value.
>
> There are only a handful of users who need this (see below. especially
> note the i2c comment :), but it might be nice to have such an API (a
> bit less of code, and a bit less error prone).
>
> Would something like the below be desirable/acceptable ?
It seems OK to me - it's an improvement over what we have now.
> (untested. and i just picked the simplest and straight-forward way to
> implement this; obviously it's not optimal since there's no reason to
> even allocate an id if we know it's not the id we're looking for. but
> it's enough to get the idea, it's not a hot path, and it's what
> drivers are doing today)
Sure, we can speed it up later if that appears to be necessary.
--
To unsubscribe from this list: send the line "unsubscribe linux-ppp" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux Audio Users]
[Hams]
[Kernel Newbies]
[Security]
[Netfilter]
[Bugtraq]
[Photo]
[Yosemite Photos]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Samba]
[Video 4 Linux]
[Linux Resources]
[Fedora Users]