From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Corbet <corbet@lwn.net>,
Thierry Reding <thierry.reding@gmail.com>,
Yang Yingliang <yangyingliang@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mark Brown <broonie@kernel.org>,
Matti Vaittinen <mazziesaccount@gmail.com>,
James Clark <james.clark@arm.com>,
linux-doc@vger.kernel.org, kernel@pengutronix.de,
linux-pwm@vger.kernel.org
Subject: Re: [PATCH 01/18] pwm: Provide devm_pwmchip_alloc() function
Date: Tue, 18 Jul 2023 23:05:29 +0300 [thread overview]
Message-ID: <ZLbwib753V6wSHKB@smile.fi.intel.com> (raw)
In-Reply-To: <20230718181849.3947851-2-u.kleine-koenig@pengutronix.de>
On Tue, Jul 18, 2023 at 08:18:32PM +0200, Uwe Kleine-König wrote:
> This function allocates a struct pwm_chip and driver data. Compared to
> the status quo the split into pwm_chip and driver data is new, otherwise
> it doesn't change anything relevant (yet).
>
> The intention is that after all drivers are switched to use this
> allocation function, its possible to add a struct device to struct
> pwm_chip to properly track the latter's lifetime without touching all
> drivers again. Proper lifetime tracking is a necessary precondition to
> introduce character device support for PWMs (that implements atomic
> setting and doesn't suffer from the sysfs overhead of the /sys/class/pwm
> userspace support).
>
> The new function pwmchip_priv() (obviously?) only works for chips
> allocated with devm_pwmchip_alloc().
...
> +void *pwmchip_priv(struct pwm_chip *chip)
> +{
> + return (char *)chip + ALIGN(sizeof(*chip), 32);
Why 32? I haven't found any explanation on the choice. I can understand arch
minimum align, but hard coded value is a bit hard to get.
> +}
...
> +struct pwm_chip *devm_pwmchip_alloc(struct device *parent, size_t sizeof_priv)
> +{
> + struct pwm_chip *chip;
> + size_t alloc_size;
> + alloc_size = ALIGN(sizeof(*chip), 32) + sizeof_priv;
Ditto.
Shouldn't it use a macro from overflow.h?
> + chip = devm_kzalloc(parent, alloc_size, GFP_KERNEL);
> + if (!chip)
> + return NULL;
> +
> + chip->dev = parent;
> +
> + return chip;
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-07-18 20:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 18:18 [PATCH 00/18] pwm: Provide devm_pwmchip_alloc() function Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 01/18] " Uwe Kleine-König
2023-07-18 20:05 ` Andy Shevchenko [this message]
2023-07-19 10:31 ` Uwe Kleine-König
2023-07-19 7:59 ` Thierry Reding
2023-07-19 8:57 ` Uwe Kleine-König
2023-07-25 21:10 ` Uwe Kleine-König
2023-10-10 8:05 ` Uwe Kleine-König
2023-10-13 21:42 ` Saravana Kannan
2023-10-14 16:17 ` Uwe Kleine-König
2023-10-17 23:35 ` Saravana Kannan
2023-10-18 1:42 ` Saravana Kannan
2023-10-18 11:17 ` Uwe Kleine-König
2023-10-18 21:01 ` Saravana Kannan
2023-10-18 21:20 ` Uwe Kleine-König
2023-10-18 22:25 ` Saravana Kannan
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=ZLbwib753V6wSHKB@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=james.clark@arm.com \
--cc=kernel@pengutronix.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=yangyingliang@huawei.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).