linux-embedded.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bill Gatliff <bgat@billgatliff.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: linux-embedded@vger.kernel.org
Subject: Re: [PWM 01/10] API to consolidate PWM devices behind a common user and kernel interface
Date: Wed, 20 Oct 2010 13:13:34 -0500	[thread overview]
Message-ID: <AANLkTikLnoAiZpZpA-aUPa3kSW7ZO=542wLgzFUqiL_4@mail.gmail.com> (raw)
In-Reply-To: <20101016074240.GC653@angua.secretlab.ca>

Grant:

> I'm not hugely keen on the naming approach, and I'd rather see the
> pwm core be responsible for the namespace.

The problem with that, as I see it, is that then the channel
identifiers become dependent on the order of device initialization.
By allowing driver authors to assign names, however, users are capable
of pinning their channel requests to specific devices and channels
with confidence that those names will remain valid regardless of the
sequence they compile their kernel in.

> Nitpick: putting the filename into the file itself I find tends to be
> useless

Agreed.  Those tend to sneak in during my early development, and then
I get so used to seeing them that I forget to take them out.

>> +static int __pwm_create_sysfs(struct pwm_device *pwm);
>
> If you order the functions in this file correct, the forward
> declaration should not be necessary.

In theory, I agree completely with you.  In this specific instance,
however, I haven't been able to structure things in a way that
eliminates at least one forward declaration.

One possibility would be to move all the sysfs-related stuff out to a
separate file altogether.  Depending on what the class attribute
rework ends up doing to the code, I just might do that.  Of course,
that wouldn't eliminate the forward declaration--- it would just move
it.  :)

>> +     for (wchan = 0; wchan < pwm->nchan; wchan++) {
>> +             dev = class_find_device(&pwm_class, NULL,
>> +                                     &pwm->channels[wchan],
>> +                                     __match_device);
>
> If the pwm_channel structure carried a pointer to its device
> structure, then this lookup wouldn't be needed.

This comment, combined with your other one on the class attributes
(below) convince me that the device model isn't quite right yet.  I
will rework this until seems correct.

> The above 8 functions are so tiny that they should probably be static
> inlines in the header file.

Agreed.

> Rather than open coding the registration of sysfs files, I believe the
> right thing to do is to use class attributes so that the files get
> automatically registered for you and are immediately advertised to
> userspace (very important for correct interaction with udev).

I think I'm either still a little weak on my device model
understanding, or things have been changing there lately and I haven't
had the time to notice.  Regardless, this code always seemed a little
awkward--- you seem to agree, so I'll do some research and come back
with something better.

> Also, sysfs_create_group() should not be called directly when working
> with devices.

Probably necessary because I'm not doing something right elsewhere.  :)

>> +     /* TODO: how to deal with devices that register very early? */
>
> Same thing we always do for bootstrapping.  If it *must* be early,
> then we do a simple direct access to get things running in platform
> code, and then take over in the driver when it finally gets probed.
> The driver model helps with many things, but really early stuff isn't
> one of them.

I _think_ you and I are saying the same thing: that the device model
only works well with late-registering devices.  I'm not sure I
understand your suggestion for how to deal with must-be-early devices.



b.g.
-- 
Bill Gatliff
bgat@billgatliff.com

  reply	other threads:[~2010-10-20 18:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-01 15:17 [PWM 01/10] API to consolidate PWM devices behind a common user and kernel interface Bill Gatliff
2010-10-01 15:17 ` [PWM 02/10] Emulates PWM hardware using a high-resolution timer and a GPIO pin Bill Gatliff
2010-10-16  6:54   ` Grant Likely
2010-10-01 15:17 ` [PWM 03/10] Expunge old Atmel PWMC driver, replacing it with one that conforms to the PWM API Bill Gatliff
2010-10-16  7:50   ` Grant Likely
2010-10-01 15:17 ` [PWM 04/10] Implements PWM-based LED control Bill Gatliff
2010-10-16  7:58   ` Grant Likely
2010-10-01 15:17 ` [PWM 05/10] LED "dim" trigger based on PWM control of the LED Bill Gatliff
2010-10-16  8:00   ` Grant Likely
2010-10-01 15:17 ` [PWM 06/10] Incorporate PWM API code into KBuild Bill Gatliff
2010-10-16  8:02   ` Grant Likely
2010-10-19  2:17     ` Bill Gatliff
2010-10-01 15:17 ` [PWM 07/10] PWM API driver for MPC52xx GPT peripheral Bill Gatliff
2010-10-01 15:17 ` [PWM 08/10] Initial support for PXA PWM peripheral; compile-tested only Bill Gatliff
2010-10-01 15:17 ` Bill Gatliff
2010-10-01 15:17 ` [PWM 09/10] Build pwm.o only if CONFIG_GENERIC_PWM is set Bill Gatliff
2010-10-01 15:17 ` [PWM 10/10] Expunge previous driver for PXA PWM Bill Gatliff
2010-10-01 22:00 ` [PWM 01/10] API to consolidate PWM devices behind a common user and kernel interface Kevin Hilman
2010-10-02  5:13   ` Jason Kridner
2010-10-06 18:45   ` Bill Gatliff
2010-10-06 19:08     ` Kevin Hilman
2010-10-02 12:25 ` Hector Oron
2010-10-06 18:48   ` Bill Gatliff
2010-10-16  6:05     ` Grant Likely
2010-10-05 10:35 ` sugumar
2010-10-06 18:50   ` Bill Gatliff
2010-10-06 19:02     ` Grosen, Mark
2010-10-07  7:58     ` Sugumar Natarajan
2010-10-16  7:42 ` Grant Likely
2010-10-20 18:13   ` Bill Gatliff [this message]
2010-10-20 18:34     ` Grant Likely
2010-10-20 19:32       ` Bill Gatliff
2010-10-21 13:18         ` Bill Gatliff

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='AANLkTikLnoAiZpZpA-aUPa3kSW7ZO=542wLgzFUqiL_4@mail.gmail.com' \
    --to=bgat@billgatliff.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-embedded@vger.kernel.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).