From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Raag Jadav <raag.jadav@intel.com>
Cc: u.kleine-koenig@pengutronix.de, jarkko.nikula@linux.intel.com,
mika.westerberg@linux.intel.com, lakshmi.sowjanya.d@intel.com,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/3] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
Date: Sun, 28 Jan 2024 16:53:24 +0200 [thread overview]
Message-ID: <ZbZqZDvdw-_D3hyb@smile.fi.intel.com> (raw)
In-Reply-To: <20240122030238.29437-2-raag.jadav@intel.com>
On Mon, Jan 22, 2024 at 08:32:36AM +0530, Raag Jadav wrote:
> Intel Elkhart Lake PSE includes two instances of PWM as a single PCI
> function with 8 channels each. Add support for the remaining channels.
...
> +static int dwc_pwm_init(struct device *dev, const struct dwc_pwm_info *info, void __iomem *base)
> +{
> + /* Default values for single instance devices */
> + unsigned int nr = 1, size = 0;
> + int i, ret;
> +
> + /* Fill up values from driver_data, if any */
> + if (info) {
> + nr = info->nr;
> + size = info->size;
> + }
> +
> + for (i = 0; i < nr; i++) {
> + struct dwc_pwm *dwc;
> +
> + dwc = dwc_pwm_alloc(dev);
> + if (!dwc)
> + return -ENOMEM;
> +
> + dwc->base = base + (i * size);
> +
> + ret = devm_pwmchip_add(dev, &dwc->chip);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
Why not doing this slightly differently?
First option: Always provide driver data (info is never NULL).
Second option, have the body of the for-loop be factored to a helper
dwc_pwm_init_one() and here
if (!info)
return dwc_pwm_init_one(..., 1, 0);
for (i = 0; i < info->nr; i++) {
ret = dwc_pwm_init_one(...);
if (ret)
return ret;
}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-01-28 14:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 3:02 [PATCH v1 0/3] DesignWare PWM improvements Raag Jadav
2024-01-22 3:02 ` [PATCH v1 1/3] pwm: dwc: Add 16 channel support for Intel Elkhart Lake Raag Jadav
2024-01-28 14:53 ` Andy Shevchenko [this message]
2024-01-30 10:30 ` Raag Jadav
2024-02-01 11:26 ` Andy Shevchenko
2024-02-02 4:02 ` Raag Jadav
2024-02-07 11:48 ` Raag Jadav
2024-02-07 13:11 ` Jarkko Nikula
2024-01-22 3:02 ` [PATCH v1 2/3] pwm: dwc: simplify error handling Raag Jadav
2024-01-28 14:48 ` Andy Shevchenko
2024-01-28 16:58 ` Uwe Kleine-König
2024-02-01 11:22 ` Andy Shevchenko
2024-01-30 8:31 ` Raag Jadav
2024-02-01 11:24 ` Andy Shevchenko
2024-01-22 3:02 ` [PATCH v1 3/3] pwm: dwc: use to_pci_dev() helper Raag Jadav
2024-01-28 14:46 ` Andy Shevchenko
2024-01-28 16:55 ` Uwe Kleine-König
2024-01-31 6:54 ` Raag Jadav
2024-01-24 9:45 ` [PATCH v1 0/3] DesignWare PWM improvements Jarkko Nikula
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=ZbZqZDvdw-_D3hyb@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=lakshmi.sowjanya.d@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=raag.jadav@intel.com \
--cc=u.kleine-koenig@pengutronix.de \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).