From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: subramanian.mohan@intel.com
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
gregkh@linuxfoundation.org, giometti@enneenne.com,
tglx@linutronix.de, corbet@lwn.net, eddie.dong@intel.com,
christopher.s.hall@intel.com, pandith.n@intel.com,
thejesh.reddy.t.r@intel.com, david.zage@intel.com,
srinivasan.chinnadurai@intel.com
Subject: Re: [PATCH v13 1/4] drivers pps/generators: replace copy of pps-gen info struct with const pointer
Date: Mon, 10 Feb 2025 08:04:59 +0200 [thread overview]
Message-ID: <Z6mXC7loE3qRYpUQ@smile.fi.intel.com> (raw)
In-Reply-To: <20250210050421.29256-2-subramanian.mohan@intel.com>
On Mon, Feb 10, 2025 at 10:34:18AM +0530, subramanian.mohan@intel.com wrote:
> From: Subramanian Mohan <subramanian.mohan@intel.com>
>
> Some PPS generator drivers may need to retrieve a pointer to their
> internal data while executing the PPS generator enable() method.
>
> During the driver registration the pps_gen_device pointer is returned
> from the framework, and for that reason, there is difficulty in
> getting generator driver data back in the enable function. We won't be
> able to use container_of macro as it results in static assert, and we
> might end up in using static pointer.
>
> To solve the issue and to get back the generator driver data back, we
> should not copy the struct pps_gen_source_info within the struct
> pps_gen_device during the registration stage, but simply save the
> pointer of the driver one. In this manner, driver may get a pointer
> to their internal data as shown below:
>
> struct pps_gen_foo_data_s {
> ...
> struct pps_gen_source_info gen_info;
> struct pps_gen_device *pps_gen;
> ...
> };
>
> static int __init pps_gen_foo_init(void)
> {
> struct pps_gen_foo_data_s *foo;
> ...
>
> foo->pps_gen = pps_gen_register_source(&foo->gen_info);
> ...
> }
>
> Then, in the enable() method, we can retrieve the pointer to the main
> struct by using the code below:
>
> static int pps_gen_foo_enable(struct pps_gen_device *pps_gen, bool enable)
> {
> struct pps_gen_foo_data_s *foo = container_of(pps_gen->info,
> struct pps_gen_foo_data_s, gen_info);
TABs/spaces mix.
> ...
> }
> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
Hmm... Is Rodolfo indeed a correct to be mentioned here?
I think you wanted Suggested-by with somebody else.
...
> -struct pps_gen_device *pps_gen_register_source(struct pps_gen_source_info *info)
> +struct pps_gen_device *pps_gen_register_source(
> + const struct pps_gen_source_info *info)
Still leave it a single line.
...
Otherwise looks good to me, thanks for taking this approach!
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-02-10 6:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 5:04 [PATCH v13 0/4] Add support for Intel PPS Generator subramanian.mohan
2025-02-10 5:04 ` [PATCH v13 1/4] drivers pps/generators: replace copy of pps-gen info struct with const pointer subramanian.mohan
2025-02-10 6:04 ` Andy Shevchenko [this message]
2025-02-10 8:00 ` Rodolfo Giometti
2025-02-10 8:06 ` Andy Shevchenko
2025-02-10 9:47 ` Mohan, Subramanian
2025-02-10 5:04 ` [PATCH v13 2/4] pps: generators: Add PPS Generator TIO Driver subramanian.mohan
2025-02-10 5:04 ` [PATCH v13 3/4] Documentation: driver-api: pps: Add Intel Timed I/O PPS generator subramanian.mohan
2025-02-10 5:04 ` [PATCH v13 4/4] ABI: pps: Add ABI documentation for Intel TIO subramanian.mohan
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=Z6mXC7loE3qRYpUQ@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=christopher.s.hall@intel.com \
--cc=corbet@lwn.net \
--cc=david.zage@intel.com \
--cc=eddie.dong@intel.com \
--cc=giometti@enneenne.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pandith.n@intel.com \
--cc=srinivasan.chinnadurai@intel.com \
--cc=subramanian.mohan@intel.com \
--cc=tglx@linutronix.de \
--cc=thejesh.reddy.t.r@intel.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