From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753829AbbEHQvh (ORCPT ); Fri, 8 May 2015 12:51:37 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:46918 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753690AbbEHQvf (ORCPT ); Fri, 8 May 2015 12:51:35 -0400 Date: Fri, 8 May 2015 18:46:47 +0200 From: Andrew Lunn To: Bert Vermeulen Cc: f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: mdio-gpio: Allow for unspecified bus id Message-ID: <20150508164647.GK18496@lunn.ch> References: <1431094729-21775-1-git-send-email-bert@biot.com> <20150508154816.GJ18496@lunn.ch> <554CDDD2.6050104@biot.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <554CDDD2.6050104@biot.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> - snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id); > >> + if (bus_id != -1) > >> + snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id); > >> + else > >> + strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE); > > > > Hi Bert > > > > What happens if there are multiple platform_device's with -1? You > > should probably be using use idr_alloc(). > > It's an instance id per driver, not globally, and -1 specifically means it's > the only instance. From Documentation/driver-model/platform.txt: Ah, did not know there can only be one with -1. I've used i2c where this does not apply when registering adaptors. It will allocate a unique id to each added with id = -1. Andrew