public inbox for linux-pwm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Cc: "Uwe Kleine-König" <ukleinek@kernel.org>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	jic23@kernel.org, "kernel test robot" <lkp@intel.com>,
	"Trevor Gamblin" <tgamblin@baylibre.com>,
	"Axel Haslam" <ahaslam@baylibre.com>,
	dlechner@baylibre.com
Subject: Re: [PATCH] pwm: Declare waveform stubs for when PWM is not reachable
Date: Tue, 14 Oct 2025 16:46:16 +0100	[thread overview]
Message-ID: <51dab5dee00b95018c8bc6b7ef56b9b722d618f3.camel@gmail.com> (raw)
In-Reply-To: <aOluoP01oaDzaseV@debian-BULLSEYE-live-builder-AMD64>

On Fri, 2025-10-10 at 17:37 -0300, Marcelo Schmitt wrote:
> ...
> > > > 
> > > > I did not tested but I also wonder if 'imply SPI_OFFLOAD_TRIGGER_PWM' is
> > > > not
> > > > similar to the above.
> > > 
> > > It works, and I'll update the IIO patch to have
> > > 	select SPI_OFFLOAD
> > > 	imply PWM
> > > 	imply SPI_OFFLOAD_TRIGGER_PWM
> > > in Kconfig. The PWM imply is because I think SPI offload support meets the
> > > "highly desirable feature" criterion mentioned by kbuild doc [1].
> > 
> > With imply we then need to take care either using stubs (which seems not to
> > be an
> > option) or with preprocessor conditions in your driver. As discussed in the
> > other
> > thread I would just select SPI_OFFLOAD. Basically I would:
> > 
> > 	select SPI_OFFLOAD
> > 	select SPI_OFFLOAD_TRIGGER_PWM
> > 	depends on PWM
> 
> Yeah, depending on PWM is what I was trying to avoid because the ADC can be
> used
> without PWM. Doing the above is the easiest solution - depend on everything,
> select everything. Though, I guess I'm technically not keeping backwards
> compatibility if I add a new dependency to the driver.
> 
> IIO_BUFFER_DMA and IIO_BUFFER_DMAENGINE are part of IIO subsystem so okay to
> select them? Otherwise, yeah, they should be optional too (would either imply
> them or select if SPI_OFFLOAD).
> 
> I'm currently leaning towards
>  	imply PWM
>  	imply SPI_OFFLOAD_TRIGGER_PWM //(SPI_OFFLOAD_TRIGGER_PWM depends on
> SPI_OFFLOAD)
> but not really sure.
> 
> It's sort of a feature bundle we want to enable to provide SPI offloading.
> 
> if SPI_OFFLOAD && PWM
> 	select SPI_OFFLOAD_TRIGGER_PWM
> 	select IIO_BUFFER_DMA
> 	select IIO_BUFFER_DMAENGINE
> 
> we can have
> 	imply IIO_BUFFER_DMA
> 	imply IIO_BUFFER_DMAENGINE
>  	imply PWM
>  	imply SPI_OFFLOAD_TRIGGER_PWM
> 
> but we could then have IIO_BUFFER_DMA=y and PWM=n and still be unable to SPI
> offload?
> 
> Maybe
> 	imply IIO_BUFFER_DMA if (SPI_OFFLOAD && PWM)
> 	imply IIO_BUFFER_DMAENGINE if (SPI_OFFLOAD && PWM)
>  	imply PWM
>  	imply SPI_OFFLOAD_TRIGGER_PWM if (SPI_OFFLOAD && PWM)
> ?
> 

With imply I don't think you need those if (...). However, the key point is that
with it, I believe you'll need the stubs (so you need some convincing) because
those configs can be disabled which means your driver should not compile. While
I feel sympathetic with that "depend on optional code", the above does not look
pretty :). For the IIO_BUFFER* stuff I would likely not care about it and for
PWM and SPI_OFFLOAD either depend on we need the stubs.

But if you really feel strong about this, one possible solution would be to try
and factor out all of the spi_offload related code into an extra source file
like ad4030-offload.c (that would have it's own kconfig knob) and that would
need to depend on PWM and then you would also be "free" to have the ad4030-*
stubs in your header file so that it does not fail to compile in case PWM=n.

- Nuno Sá

> Forgot to add David to CC list on previous reply so doing it now.
> 
> > 
> > - Nuno Sá
> > 	
> > > 
> > > [1]:
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/kbuild/kconfig-language.rst?h=v6.17#n197
> > > 
> > > One alternative to this patch is to have `#if IS_REACHABLE(CONFIG_PWM)` in
> > > the
> > > ADC driver as David suggested in the other thread. I'll probably do that
> > > and
> > > drop the changes to PWM.
> > > 
> > > I first thought of using `#ifdef CONFIG_PWM`, but couldn't convince myself
> > > about
> > > that from the relatively small number of ifdef use-cases in IIO.
> > > 
> > > Thanks,
> > > Marcelo
> > > 
> > > > 
> > > > - Nuno Sá
> > > > 
> > > > > Best regards
> > > > > Uwe

  reply	other threads:[~2025-10-14 15:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 22:19 [PATCH] pwm: Declare waveform stubs for when PWM is not reachable Marcelo Schmitt
2025-10-09 16:53 ` Uwe Kleine-König
2025-10-10 10:26   ` Nuno Sá
2025-10-10 19:01     ` Marcelo Schmitt
2025-10-10 18:51       ` Nuno Sá
2025-10-10 20:37         ` Marcelo Schmitt
2025-10-14 15:46           ` Nuno Sá [this message]
2025-10-13  9:12         ` Uwe Kleine-König

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=51dab5dee00b95018c8bc6b7ef56b9b722d618f3.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=ahaslam@baylibre.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=tgamblin@baylibre.com \
    --cc=ukleinek@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