From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Wise Subject: Re: idr_get_new_exact ? Date: Mon, 20 Sep 2010 15:07:40 -0500 Message-ID: <4C97BF0C.6070809@opengridcomputing.com> References: <20100920123140.f524de79.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Jean Delvare (PC drivers, core)" , "Ben Dooks (embedded platforms)" , Roland Dreier , Sean Hefty , Hal Rosenstock , Steve Wise , Neil Brown , Paul Mackerras , linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-ppp-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Ohad Ben-Cohen Return-path: In-Reply-To: <20100920123140.f524de79.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Sender: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: netdev.vger.kernel.org On 09/20/2010 02:31 PM, Andrew Morton wrote: > On Mon, 20 Sep 2010 16:11:31 +0200 > Ohad Ben-Cohen 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. > > Looks ok to me also. This is exactly what cxgb* needs. IE the driver manages the ID space and never expects an idr insertion to fail because its already inserted. That constitutes a driver bug (which is why the BUG_ON() is there :)). Steve.