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: 48+ 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 ` 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
2023-07-18 18:18 ` [PATCH 02/18] pwm: ab8500: Make use of " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 03/18] pwm: apple: " Uwe Kleine-König
2023-07-18 18:18 ` Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 04/18] pwm: berlin: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 05/18] pwm: clk: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 06/18] pwm: fsl-ftm: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 07/18] pwm: hibvt: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 08/18] pwm: imx1: " Uwe Kleine-König
2023-07-18 18:18 ` Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 09/18] pwm: imx27: " Uwe Kleine-König
2023-07-18 18:18 ` Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 10/18] pwm: jz4740: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 11/18] pwm: keembay: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 12/18] pwm: lpc18xx-sct: " Uwe Kleine-König
2023-07-18 18:18 ` Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 13/18] pwm: lpc32xx: " Uwe Kleine-König
2023-07-18 18:18 ` Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 14/18] pwm: mxs: " Uwe Kleine-König
2023-07-18 18:18 ` Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 15/18] pwm: ntxec: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 16/18] pwm: pxa: " Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 17/18] pwm: stm32: " Uwe Kleine-König
2023-07-18 18:18 ` Uwe Kleine-König
2023-07-18 18:18 ` [PATCH 18/18] gpio: mvebu: " Uwe Kleine-König
2023-07-29 14:09 ` Bartosz Golaszewski
2023-07-29 21:37 ` Uwe Kleine-König
2023-07-30 10:07 ` Bartosz Golaszewski
2023-07-30 14:09 ` Uwe Kleine-König
2023-08-03 9:42 ` Uwe Kleine-König
2023-08-03 11:51 ` Andy Shevchenko
2023-08-03 15:34 ` 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=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 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.