public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Rodolfo Giometti <giometti@enneenne.com>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	corbet@lwn.net, Hall Christopher S <christopher.s.hall@intel.com>,
	Mohan Subramanian <subramanian.mohan@intel.com>,
	tglx@linutronix.de, andriy.shevchenko@linux.intel.com,
	Dong Eddie <eddie.dong@intel.com>,
	N Pandith <pandith.n@intel.com>,
	T R Thejesh Reddy <thejesh.reddy.t.r@intel.com>,
	Zage David <david.zage@intel.com>,
	Chinnadurai Srinivasan <srinivasan.chinnadurai@intel.com>
Subject: Re: [RFC 1/3] drivers pps: add PPS generators support
Date: Thu, 10 Oct 2024 12:04:42 +0200	[thread overview]
Message-ID: <2024101022-scoundrel-ravage-19a2@gregkh> (raw)
In-Reply-To: <253ff116-6ead-42f1-a3a7-0d627ac90b5e@enneenne.com>

On Thu, Oct 10, 2024 at 11:53:44AM +0200, Rodolfo Giometti wrote:
> On 10/10/24 09:54, Greg KH wrote:
> > On Thu, Oct 10, 2024 at 09:32:22AM +0200, Rodolfo Giometti wrote:
> > > On 10/10/24 09:15, Greg KH wrote:
> > > > On Wed, Oct 09, 2024 at 10:48:14AM +0200, Rodolfo Giometti wrote:
> > > > > > > +#ifdef CONFIG_COMPAT
> > > > > > > +static long pps_gen_cdev_compat_ioctl(struct file *file,
> > > > > > > +		unsigned int cmd, unsigned long arg)
> > > > > > > +{
> > > > > > > +	cmd = _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(void *));
> > > > > > > +	return pps_gen_cdev_ioctl(file, cmd, arg);
> > > > > > > +}
> > > > > > > +#else
> > > > > > > +#define pps_gen_cdev_compat_ioctl	NULL
> > > > > > > +#endif
> > > > > > > +
> > > > > > > +static struct pps_gen_device *pps_gen_idr_get(unsigned long id)
> > > > > > > +{
> > > > > > > +	struct pps_gen_device *pps_gen;
> > > > > > > +
> > > > > > > +	mutex_lock(&pps_gen_idr_lock);
> > > > > > > +	pps_gen = idr_find(&pps_gen_idr, id);
> > > > > > > +	if (pps_gen)
> > > > > > > +		kobject_get(&pps_gen->dev->kobj);
> > > > > > > +
> > > > > > > +	mutex_unlock(&pps_gen_idr_lock);
> > > > > > 
> > > > > > Doesn't an idr have a lock in it?  I can never remember...
> > > > > 
> > > > > As far as I know we must use a mutex...
> > > > 
> > > > If you do, someone will come along and remove it, please see:
> > > > 	https://lore.kernel.org/r/b1fcc6707ec2b6309d50060fa52ccc2c892afde2.1728507153.git.christophe.jaillet@wanadoo.fr
> > > > as an example (with links that show it is not needed).
> > > 
> > > Here is an example about ida API, but I'm using idr API.
> > 
> > Why not use ida then?  :)
> 
> Because we need an ID associated with a pointer.

Ah, ok, but why?  Why is the "id" here the mapping to the pointer?  Why
not use the structures you already have to store this in (i.e. the
normal driver model stuff?)

All you should need an idr/ida for is to pick a unique "number" for
naming your class device.  Everything after that should already be there
for you to get access to the structures you need to get access to.

thanks,

greg k-h

  reply	other threads:[~2024-10-10 10:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 13:50 [RFC 0/3] Add PPS generators Rodolfo Giometti
2024-10-08 13:50 ` [RFC 1/3] drivers pps: add PPS generators support Rodolfo Giometti
2024-10-08 15:42   ` Greg KH
2024-10-09  8:48     ` Rodolfo Giometti
2024-10-09  9:19       ` Greg KH
2024-10-10  7:25         ` Rodolfo Giometti
2024-10-10  7:15       ` Greg KH
2024-10-10  7:32         ` Rodolfo Giometti
2024-10-10  7:54           ` Greg KH
2024-10-10  9:53             ` Rodolfo Giometti
2024-10-10 10:04               ` Greg KH [this message]
2024-10-10 10:18                 ` Rodolfo Giometti
2024-10-09  2:49   ` Hall, Christopher S
2024-10-09  8:48     ` Rodolfo Giometti
2024-10-08 13:50 ` [RFC 2/3] Documentation pps.rst: add PPS generators documentation Rodolfo Giometti
2024-10-08 15:43   ` Greg KH
2024-10-09  8:48     ` Rodolfo Giometti
2024-10-09  9:14       ` Greg KH
2024-10-10  7:26         ` Rodolfo Giometti
2024-10-08 13:50 ` [RFC 3/3] Documentation ABI: add PPS generators documentaion Rodolfo Giometti
2024-10-08 15:43   ` Greg KH
2024-10-09  8:48     ` Rodolfo Giometti
2024-10-09  9:15       ` Greg KH

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=2024101022-scoundrel-ravage-19a2@gregkh \
    --to=greg@kroah.com \
    --cc=akpm@linux-foundation.org \
    --cc=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=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