From: Kevin Dankwardt <k@kcomputing.com>
To: linux-embedded@vger.kernel.org
Subject: Re: Avoiding platform-specific callbacks in drivers?
Date: Tue, 09 Nov 2010 16:02:45 -0800 [thread overview]
Message-ID: <4CD9E125.2010207@kcomputing.com> (raw)
In-Reply-To: <AANLkTinG4y_Uxes0CJYMH+uwr1TcWwjQy+4+_ftyrnML@mail.gmail.com>
> Guys:
>
>
> Let's say that on a given platform, I need to twiddle with a GPIO pin
> when a chip enters and exits suspend. One way to do that is to hack
> the driver itself; a slightly less-inelegant way is to add a function
> pointer in the platform data, and have the driver call back in its
> suspend() and resume() methods. I'm not real keen on either strategy,
> because they both involve touching driver code that should be
> platform-agnostic. They seem... hacky. :)
>
> I would love to come up with a way that prevents touching the driver
> at all, since the activity is terribly platform-specific. Is there
> such a way?
>
> One possibility is to set up some sort of parent-child relationship
> between the device and a pseudo-device that deals with the GPIO pin.
> But I'm not sure that will actually work, and it seems a bit
> overly-complicated.
>
> Ideas, anyone? I'll be happy to try them out if they seem feasible,
> and post code and feedback.
>
>
> b.g.
>
Isn't the general approach to avoid platform-dependencies to abstract
the behavior? As is used throughout the kernel, an "operations" struct
that provides the abstractions and each driver fills in its
implementation as required. The "polymorphism" approach. Maybe the
operations are "begin_suspend()" and "end_suspend()" and in this case
the functions twiddle a GPIO pin?
next prev parent reply other threads:[~2010-11-10 0:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-09 22:32 Avoiding platform-specific callbacks in drivers? Bill Gatliff
2010-11-10 0:02 ` Kevin Dankwardt [this message]
2010-11-10 4:17 ` Bill Gatliff
2010-11-10 0:10 ` Nicolas Pitre
2010-11-10 4:11 ` 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=4CD9E125.2010207@kcomputing.com \
--to=k@kcomputing.com \
--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 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.