From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [PATCH 2/5] of/fdt: add kernel command line option for dtb_compat string Date: Tue, 16 Nov 2010 17:16:14 -0700 Message-ID: References: <348d48851a244bbd60bbfc4d60bee330e5c91eae.1289943240.git.dirk.brandewie@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <348d48851a244bbd60bbfc4d60bee330e5c91eae.1289943240.git.dirk.brandewie@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: dirk.brandewie@gmail.com Cc: devicetree-discuss@lists.ozlabs.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, sodaville@linutronix.de, microblaze-uclinux@itee.uq.edu.au, arjan@linux.intel.com List-Id: linux-arch.vger.kernel.org On Tue, Nov 16, 2010 at 3:41 PM, wrote: > From: Dirk Brandewie > > Adds a kernel command line option "dtb_compat=3D" and functio= ns > for architecture/platform specific code to retrieve the command line > string and locate the compatible DTB linked into the kernel > > of_flat_dt_get_dtb_compatible_string() returns a pointer string passe= d > from the command line or a pointer to an empty string. > > of_flat_dt_find_compatible_dtb() returns a pointer to a DTB that is > compatible with the "compatible" string or a NULL pointer if no > matching DTB is present. > > Signed-off-by: Dirk Brandewie > --- [...] > +void __init *of_flat_dt_find_compatible_dtb(char *name) > +{ > + =A0 =A0 =A0 void *rc =3D NULL; > + =A0 =A0 =A0 unsigned long root, size; > + =A0 =A0 =A0 struct boot_param_header =A0*orig_initial_boot_params; > + =A0 =A0 =A0 uint8_t *blob; > + > + =A0 =A0 =A0 orig_initial_boot_params =3D initial_boot_params; > + =A0 =A0 =A0 blob =3D __dtb_start; > + =A0 =A0 =A0 initial_boot_params =3D (struct boot_param_header *)blo= b; > + > + =A0 =A0 =A0 while (blob < __dtb_end && > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (be32_to_cpu(initial_boot_params->magic= ) =3D=3D OF_DT_HEADER)) { The kernel needs to complain *loudly* if this occurs because it represents a bug. I'm tempted to say use BUG, but that would halt the kernel and prevent any possibility of kernel log output. WARN_ON() is probably best. g. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-iw0-f174.google.com ([209.85.214.174]:62134 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757418Ab0KQAQf convert rfc822-to-8bit (ORCPT ); Tue, 16 Nov 2010 19:16:35 -0500 MIME-Version: 1.0 In-Reply-To: <348d48851a244bbd60bbfc4d60bee330e5c91eae.1289943240.git.dirk.brandewie@gmail.com> References: <348d48851a244bbd60bbfc4d60bee330e5c91eae.1289943240.git.dirk.brandewie@gmail.com> From: Grant Likely Date: Tue, 16 Nov 2010 17:16:14 -0700 Message-ID: Subject: Re: [PATCH 2/5] of/fdt: add kernel command line option for dtb_compat string Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-arch-owner@vger.kernel.org List-ID: To: dirk.brandewie@gmail.com Cc: devicetree-discuss@lists.ozlabs.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, sodaville@linutronix.de, microblaze-uclinux@itee.uq.edu.au, arjan@linux.intel.com Message-ID: <20101117001614.b_9KXR7gScIw3NudGeXFZSUfSo1m_Jtu0dlO0YDZNhE@z> On Tue, Nov 16, 2010 at 3:41 PM, wrote: > From: Dirk Brandewie > > Adds a kernel command line option "dtb_compat=" and functions > for architecture/platform specific code to retrieve the command line > string and locate the compatible DTB linked into the kernel > > of_flat_dt_get_dtb_compatible_string() returns a pointer string passed > from the command line or a pointer to an empty string. > > of_flat_dt_find_compatible_dtb() returns a pointer to a DTB that is > compatible with the "compatible" string or a NULL pointer if no > matching DTB is present. > > Signed-off-by: Dirk Brandewie > --- [...] > +void __init *of_flat_dt_find_compatible_dtb(char *name) > +{ > +       void *rc = NULL; > +       unsigned long root, size; > +       struct boot_param_header  *orig_initial_boot_params; > +       uint8_t *blob; > + > +       orig_initial_boot_params = initial_boot_params; > +       blob = __dtb_start; > +       initial_boot_params = (struct boot_param_header *)blob; > + > +       while (blob < __dtb_end && > +               (be32_to_cpu(initial_boot_params->magic) == OF_DT_HEADER)) { The kernel needs to complain *loudly* if this occurs because it represents a bug. I'm tempted to say use BUG, but that would halt the kernel and prevent any possibility of kernel log output. WARN_ON() is probably best. g.