All of lore.kernel.org
 help / color / mirror / Atom feed
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 v14 1/4] drivers pps/generators: replace copy of pps-gen info struct with const pointer
Date: Fri, 14 Feb 2025 16:54:55 +0200	[thread overview]
Message-ID: <Z69ZPy5T5eXxVTuH@smile.fi.intel.com> (raw)
In-Reply-To: <20250214090755.37450-2-subramanian.mohan@intel.com>

On Fri, Feb 14, 2025 at 02:37:52PM +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);
>         ...
> }

Shouldn't Subject start with "pps: generators: ..."?

With that fixed,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-02-14 14:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14  9:07 [PATCH v14 0/4] Add support for Intel PPS Generator subramanian.mohan
2025-02-14  9:07 ` [PATCH v14 1/4] drivers pps/generators: replace copy of pps-gen info struct with const pointer subramanian.mohan
2025-02-14 14:54   ` Andy Shevchenko [this message]
2025-02-17  2:46     ` Mohan, Subramanian
2025-02-14  9:07 ` [PATCH v14 2/4] pps: generators: Add PPS Generator TIO Driver subramanian.mohan
2025-02-14  9:07 ` [PATCH v14 3/4] Documentation: driver-api: pps: Add Intel Timed I/O PPS generator subramanian.mohan
2025-02-14  9:07 ` [PATCH v14 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=Z69ZPy5T5eXxVTuH@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 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.