linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: gregkh@suse.de (Greg KH)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/6] drivers/base: add bus for System-on-Chip devices
Date: Tue, 18 Oct 2011 07:43:09 -0700	[thread overview]
Message-ID: <20111018144309.GC19561@suse.de> (raw)
In-Reply-To: <4E9D5F29.1070303@linaro.org>

On Tue, Oct 18, 2011 at 12:12:41PM +0100, Lee Jones wrote:
> > If you move around things a bit here, you can save 4 lines of code,
> > please do so.
> 
> Telepathy has never been my Fort?. Would you mind alluding to which
> lines I can trim please?
> 
> If you mean the placing the DEVICE_ATTR's after soc_info_get and
> removing its prototype; I had that already, but I was told to do it this
> way as it would make the binary smaller.

Yes, you are correct, I am wrong here, nevermind.

> >> +
> >> +struct bus_type soc_bus_type = {
> >> +	.name  = "soc",
> >> +};
> >> +
> >> +static int __init soc_bus_register(void)
> >> +{
> >> +	return bus_register(&soc_bus_type);
> >> +}
> >> +core_initcall(soc_bus_register);
> > 
> > No unregister?
> 
> The unregister is contained in soc_device_unregister, but as you point
> out in your other email this should be removed. I'm guessing we should
> either count the number of SoCs and unregister as the last one leaves,
> or not unregister at all?

No, make it a module exit function and you will be fine.

> >> +struct attribute *soc_attr[] = {
> >> +	&dev_attr_machine.attr,
> >> +	&dev_attr_family.attr,
> >> +	&dev_attr_soc_id.attr,
> >> +	&dev_attr_revision.attr,
> >> +	NULL,
> >> +};
> >> +
> >> +struct attribute_group soc_attr_group = {
> >> +	.attrs = soc_attr,
> >> +};
> >> +
> >> +struct device *soc_device_register(struct soc_device_attribute *soc_dev_attr)
> >> +{
> >> +	struct soc_device *soc_dev;
> >> +	static atomic_t soc_device_num = ATOMIC_INIT(0);
> > 
> > No, please don't do this, use the proper kernel interface to dynamically
> > handle numbering devices (hint, if you unload a SOC device, you will
> > never reclaim that device number, which isn't that nice.)
> 
> Again, some help would really be appreciated here. I searched the kernel
> last time you mentioned numbering, but this is all I came up with.

ida

> >> +struct soc_device_attribute {
> >> +	const char *machine;
> >> +	const char *family;
> >> +	const char *revision;
> >> +	const char *soc_id;
> >> +};
> > 
> > What happens if one of these attributes is NULL?  Please check for that
> > when you create the attributes so that you don't create an attribute you
> > don't want to.
> 
> By shifting around "struct attribute *soc_attr[]"?
> 
> If one of them is NULL the file will just be empty, is that such a bad
> thing?

Yes.  sysfs files show that if the file is present, then there should be
data in it.  If it isn't present, then that attribute isn't there for
that device.  It is easier for userspace to handle this than by having
to open files and test for a null entry or not.

> >> +
> >> +struct soc_device {
> >> +	struct device dev;
> >> +	struct soc_device_attribute *attr;
> >> +};
> > 
> > Why is this needed to be defined here?  It should be in the .c file as
> > no external code needs to know what it looks like.
> 
> If you want me to pass back a "struct soc_device" instead of a "raw"
> struct device, the calling code will need to know how to separate out
> "struct device dev" won't it?

It depends on what it wants to do with that struct device.  Why would
the caller code care about it?

thanks,

greg k-h

  parent reply	other threads:[~2011-10-18 14:43 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17 11:52 [PATCH 0/6] ux500: Export SoC information and some platform clean-up Lee Jones
2011-10-17 11:52 ` [PATCH 1/6] mach-ux500: pass parent pointer to each platform device Lee Jones
2011-10-17 11:52 ` [PATCH 2/6] drivers/base: add bus for System-on-Chip devices Lee Jones
2011-10-17 12:13   ` Jamie Iles
2011-10-17 16:16   ` Greg KH
2011-10-17 18:03     ` Arnd Bergmann
2011-10-17 18:25       ` Greg KH
2011-10-18 14:00         ` Arnd Bergmann
2011-10-18 14:44           ` Greg KH
2011-10-18 11:12     ` Lee Jones
2011-10-18 14:14       ` Arnd Bergmann
2011-10-18 14:41         ` Greg KH
2011-10-18 14:43       ` Greg KH [this message]
2011-10-17 16:18   ` Greg KH
2011-10-18 11:14     ` Lee Jones
2011-10-18 14:05       ` Arnd Bergmann
2011-10-18 14:15         ` Jamie Iles
2011-10-18 14:38           ` Greg KH
2011-10-18 14:53           ` Arnd Bergmann
2011-10-18 14:56             ` Jamie Iles
2011-10-17 11:52 ` [PATCH 3/6] Documentation: add information for new sysfs soc bus functionality Lee Jones
2011-10-17 11:52 ` [PATCH 4/6] mach-ux500: export System-on-Chip information ux500 via sysfs Lee Jones
2011-10-17 11:52 ` [PATCH 5/6] mach-ux500: move top level platform devices in sysfs to /sys/devices/socX Lee Jones
2011-10-17 11:52 ` [PATCH 6/6] mach-ux500: remove intermediary add_platform_device* functions Lee Jones
2011-10-17 11:59   ` Jamie Iles
2011-10-19 14:43     ` Lee Jones
2011-10-19 14:45       ` Jamie Iles
  -- strict thread matches above, loose matches on Subject: below --
2012-01-20 16:10 [PATCH 0/6] ux500: Export SoC information and some platform clean-up Lee Jones
2012-01-20 16:10 ` [PATCH 2/6] drivers/base: add bus for System-on-Chip devices Lee Jones
2012-01-20 16:36   ` Greg KH
     [not found]     ` <CANmRt2gZe7dfRe5T8fS-1LGkeQXOBzcrbzL8xU+J9M7X4ZuDrA@mail.gmail.com>
2012-01-20 18:20       ` Greg KH
2012-01-20 16:39   ` Greg KH
     [not found]     ` <CANmRt2j4woAAg3dEtyQG4rjxRQ5Sx+4OW84Mathk4_YrFTjChQ@mail.gmail.com>
2012-01-20 18:10       ` Greg KH
2012-01-21 17:08 [PATCH 0/6] ux500: Export SoC information and some platform clean-up Lee Jones
2012-01-21 17:08 ` [PATCH 2/6] drivers/base: add bus for System-on-Chip devices Lee Jones
2012-01-28  1:05   ` Greg KH
2012-01-30 17:58     ` Arnd Bergmann
2012-01-30 18:34       ` Greg KH
2012-02-01  9:23 [PATCH 0/6] ux500: Export SoC information and some platform clean-up Lee Jones
2012-02-01  9:23 ` [PATCH 2/6] drivers/base: add bus for System-on-Chip devices Lee Jones
2012-02-01 15:52   ` Jamie Iles
2012-02-01 16:55     ` Arnd Bergmann
2012-02-06 19:22 [PATCH 0/6] ux500: Export SoC information and some platform clean-up Lee Jones
2012-02-06 19:22 ` [PATCH 2/6] drivers/base: add bus for System-on-Chip devices Lee Jones

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=20111018144309.GC19561@suse.de \
    --to=gregkh@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).