From: Thierry Reding <thierry.reding@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
linux-sh@vger.kernel.org, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org, Magnus Damm <magnus.damm@gmail.com>,
Paul Mundt <lethal@linux-sh.org>
Subject: Re: [PATCH v2 04/11] pwm: Add Renesas TPU PWM driver
Date: Wed, 12 Jun 2013 10:06:49 +0000 [thread overview]
Message-ID: <20130612100647.GA30841@mithrandir> (raw)
In-Reply-To: <22098838.zqKo9eB0Jt@avalon>
[-- Attachment #1: Type: text/plain, Size: 1901 bytes --]
On Wed, May 29, 2013 at 05:48:50PM +0200, Laurent Pinchart wrote:
> Hi Thierry,
>
> On Thursday 23 May 2013 23:45:17 Thierry Reding wrote:
> > On Wed, Apr 24, 2013 at 10:50:09PM +0200, Laurent Pinchart wrote:
[...]
> > > +struct tpu_device {
> > > + struct platform_device *pdev;
> > > + struct pwm_chip chip;
> > > + spinlock_t lock;
> > > +
> > > + void __iomem *base;
> > > + struct clk *clk;
> > > +
> > > + struct tpu_pwm_device pwms[TPU_CHANNEL_MAX];
> > > +};
> >
> > Can't you reuse the infrastructure built into the PWM subsystem? You can
> > associate chip-specific data with each PWM device. You can look at the
> > pwm-atmel-tcb and pwm-bfin drivers for usage examples. In a nutshell you
> > hook the .request() function and setup the driver-specific structure and
> > associate them with the PWM using pwm_set_chip_data().
> >
> > This has the advantage that you don't need the pwms array in tpu_device
> > and you also don't need TPU_CHANNEL_MAX because only the pwm_chip.npwm
> > field needs to contain the number of channels.
>
> I've actually thought about that, but decided not to do so. It looked pretty
> weird to allocate PWM devices at .request() time, so I decided to allocate the
> devices once only at probe time. Is it considered better to allocate/free PWM
> devices every time they're requested/released ?
Well, I consider it better because it postpones memory allocation until
it is actually used. Typically requesting a PWM device happens at probe
time of other drivers so it isn't actually as bad as it may sound. Also
allocating at request time allows you to easily associate the data with
the PWM device using pwm_set_chip_data(), which was intended to be used
for exactly this purpose.
Doing so will keep the driver-specific data in a well-defined location
instead of putting it somewhere driver-specific.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-06-12 10:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-24 20:50 [PATCH v2 00/11] Renesas TPU PWM support Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 01/11] sh-pfc: sh73a0: Add TPU pin groups and functions Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 02/11] sh-pfc: r8a7740: " Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 03/11] sh-pfc: r8a7790: " Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 04/11] pwm: Add Renesas TPU PWM driver Laurent Pinchart
2013-05-23 21:45 ` Thierry Reding
2013-05-29 15:48 ` Laurent Pinchart
2013-06-12 10:06 ` Thierry Reding [this message]
2013-06-13 15:32 ` Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 05/11] ARM: mach-shmobile: clock-r8a7740: add TPU PWM support Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 06/11] ARM: mach-shmobile: clock-r8a7790: " Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 07/11] ARM: mach-shmobile: armadillo800eva: Add backlight support Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 08/11] ARM: mach-shmobile: kota2: Use leds-pwm + pwm-rmob Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 09/11] sh-pfc: sh73a0: Remove function GPIOs Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 10/11] ARM: shmobile: sh73a0: Remove all GPIOs Laurent Pinchart
2013-04-24 20:50 ` [PATCH v2 11/11] leds: Remove leds-renesas-tpu driver Laurent Pinchart
2013-04-24 20:59 ` Bryan Wu
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=20130612100647.GA30841@mithrandir \
--to=thierry.reding@gmail.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
/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).