From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [PATCH] spi/spi-altera: Allow to explicitely override bus number via dts Date: Wed, 1 Feb 2012 10:59:20 -0700 Message-ID: References: <1328025246-23450-1-git-send-email-tklauser@distanz.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, Frederic Lambert , Rob Herring To: Tobias Klauser Return-path: In-Reply-To: <1328025246-23450-1-git-send-email-tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Sender: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org List-Id: linux-spi.vger.kernel.org On Tue, Jan 31, 2012 at 8:54 AM, Tobias Klauser wrote: > From: Frederic Lambert > > Until now we let the code in spi.c assign us the bus number if the platfo= rm > device didn't specify its id. This patch adds the possibility to explicit= ely > specify the bus number via device tree. > > Signed-off-by: Frederic Lambert > Signed-off-by: Tobias Klauser > --- > diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c > index 4813a63..d5bf52b 100644 > --- a/drivers/spi/spi-altera.c > +++ b/drivers/spi/spi-altera.c > @@ -226,6 +226,15 @@ static int __devinit altera_spi_probe(struct platfor= m_device *pdev) > =A0 =A0 =A0 =A0if (!master) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return err; > > + =A0 =A0 =A0 /* bus_num is dynamically assigned when undefined (see spi.= c) =A0*/ > + =A0 =A0 =A0 /* look for a DTS entry to override this */ > + =A0 =A0 =A0 if (pdev->id =3D=3D -1 && pdev->dev.of_node !=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 u32 tmp; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (of_property_read_u32(pdev->dev.of_node,= "bus-number", &tmp) =3D=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdev->id =3D tmp; BTW, it is absolutely illegal for device drivers to modify the pdev->id field. Once a device is registered, the id and name cannot be changed. g.