From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559Ab2G0Thg (ORCPT ); Fri, 27 Jul 2012 15:37:36 -0400 Received: from zoneX.GCU-Squad.org ([194.213.125.0]:45599 "EHLO services.gcu-squad.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752404Ab2G0Thf (ORCPT ); Fri, 27 Jul 2012 15:37:35 -0400 Date: Fri, 27 Jul 2012 21:37:23 +0200 From: Jean Delvare To: Greg Kroah-Hartman Cc: LKML Subject: Re: [PATCH/RFC] platform: Add support for automatic device IDs Message-ID: <20120727213723.46b8b34f@endymion.delvare> In-Reply-To: <20120727182155.GD23564@kroah.com> References: <20120727134625.71e29d2d@endymion.delvare> <20120727182155.GD23564@kroah.com> X-Mailer: Claws Mail 3.7.10 (GTK+ 2.24.7; x86_64-suse-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, On Fri, 27 Jul 2012 11:21:55 -0700, Greg Kroah-Hartman wrote: > On Fri, Jul 27, 2012 at 01:46:25PM +0200, Jean Delvare wrote: > > Right now we have support for explicit platform device IDs, as well as > > ID-less platform devices when a given device type can only have one > > instance. However there are cases where multiple instances of a device > > type can exist, and their IDs aren't (and can't be) known in advance > > and do not matter. In that case we need automatic device IDs to avoid > > device name collisions. > > > > I am using magic ID value -4 for this (I left -2 and -3 free in case > > we ever need a couple of other magic values.) The automatically > > allocated device IDs are global (to avoid an additional per-driver > > cost) and are stored internally as negative numbers, starting with -4. > > This is required so that the IDs can be freed later. Externally the > > positive value is used. > > > > Signed-off-by: Jean Delvare > > Cc: Greg Kroah-Hartman > > --- > > If anyone has a problem with the -4 or using negative device IDs > > internally, it would be possible to avoid that by adding a boolean > > attribute to every platform device to record whether the ID needs to > > be freed. This would cost some memory. > > A boolean is "free" don't worry about that. Don't overload the device > id with "magic" values like this, I don't like that at all. I suspected so... > I'd prefer > to see another field added if this is really going to be needed. OK, I'll send a different implementation in a moment. Note though that PLATFORM_DEVID_AUTO will have to stay, as we still need a way to tell the platform subsystem that we want an automatic ID. Thanks, -- Jean Delvare