All of lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] mach-ux500: export System-on-Chip information ux500 via sysfs
Date: Wed, 24 Aug 2011 18:10:20 +0200	[thread overview]
Message-ID: <201108241810.20753.arnd@arndb.de> (raw)
In-Reply-To: <1312981422-13294-3-git-send-email-lee.jones@linaro.org>

On Wednesday 10 August 2011, Lee Jones wrote:
> +
> +static void ux500_get_soc_id(char *buf)
> +{
> +       void __iomem *uid_base;
> +       int i;
> +       ssize_t sz = 0;
> +
> +       if (dbx500_partnumber() == 0x8500) {
> +               uid_base = __io_address(U8500_BB_UID_BASE);
> +               for (i = 0; i < U8500_BB_UID_LENGTH; i++) {
> +                       sz += sprintf(buf + sz, "%08x", readl(uid_base + i * sizeof(u32)));
> +               }
> +               return;
> +       } else {
> +               /* Don't know where it is located for U5500 */
> +               sprintf(buf, "N/A");
> +               return;
> +       }
> +}
> +

This still feels like it's hanging upside-down. You add an SOC node before you know
what it is, and then attach other device to it.

Similarly, having a function named 'ux500_soc_sysfs_init' is plain wrong.

You don't initialize sysfs here, but you should be probing a device with a
driver that happens to have a sysfs interface.

All probing of devices in general should start at the root and then trickle
down as you discover the child devices:
Each board has its own init_machine() callback that knows the main devices,
most importantly the SoC and registers them. When the driver for the SoC
gets loaded, that driver knows what devices are present in the device and
registers those recursively.

When you get this right, you can also eliminate the ugly machine_is_* checks
in the board file.

	Arnd

  parent reply	other threads:[~2011-08-24 16:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-10 13:03 [PATCH 1/4] Framework for exporting System-on-Chip information via sysfs Lee Jones
2011-08-10 13:03 ` [PATCH 2/4] Add documenation for new sysfs devices/soc functionallity Lee Jones
2011-08-10 15:02   ` Greg KH
2011-08-10 13:03 ` [PATCH 3/4] mach-ux500: export System-on-Chip information ux500 via sysfs Lee Jones
2011-08-10 13:34   ` Jamie Iles
2011-08-10 15:03   ` Greg KH
2011-09-01  6:58     ` Lee Jones
2011-09-01 14:24       ` Greg KH
2011-08-24 16:10   ` Arnd Bergmann [this message]
2011-08-25  9:20     ` Lee Jones
2011-08-25 14:56       ` Arnd Bergmann
2011-08-25 15:16         ` Lee Jones
2011-08-10 13:03 ` [PATCH 4/4] Move top level platform devices in sysfs to /sys/devices/soc/X Lee Jones
2011-08-10 15:02   ` Greg KH
2011-08-11 11:57     ` Linus Walleij
2011-08-11 15:22       ` Greg KH
2011-08-11 18:24         ` Linus Walleij
2011-08-24 15:21           ` Arnd Bergmann
2011-08-24 15:25   ` Arnd Bergmann
2011-08-10 13:29 ` [PATCH 1/4] Framework for exporting System-on-Chip information via sysfs Jamie Iles
2011-08-24 14:08   ` Lee Jones
2011-08-24 14:19     ` Jamie Iles
2011-08-24 14:22       ` Jamie Iles
2011-08-10 15:02 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201108241810.20753.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.