mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Greg KH <greg@kroah.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH/RFC] core: add a function to safely try to get device driver owner
Date: Tue, 30 Nov 2010 08:18:16 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.64.1011300016260.27962@axis700.grange> (raw)
In-Reply-To: <20101129152838.4ff57277@bike.lwn.net>

On Mon, 29 Nov 2010, Jonathan Corbet wrote:

> On Mon, 29 Nov 2010 23:10:50 +0100 (CET)
> Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:
> 
> > In my case I have two platform devices: CEU and CSI2. In some cases (with 
> > parallel sensors) CEU operates on its own. With serial (CSI-2) camera 
> > sensors we need the CSI2 driver. So, I want to 
> > try_module_get(csi2_dev->driver->owner) the CSI2 driver from my CEU 
> > driver. This call can Oops if not done safely. Am I missing something? Is 
> > there an easier way to achieve the same?
> 
> This looks exactly like what the V4L2 subdev mechanism was meant to do.
> Is there a reason you can't use that interface?

Subdev doesn't solve this completely. Media controller, probably, will, 
not sure to what extent, but it is not yet in the mainline.

These my devices do use the subdev API, the CEU driver registers a 
v4l2_device, and the CSI2 driver and the attached sensor register 
v4l2_subdev instances. The problem is - when you register v4l2_subdev, you 
have to specify the respective v4l2_device. In case of sensor (and other 
I2C) drivers this is solved with I2C probing. Generally speaking, the 
v4l2_device registers a device for the subdev driver, and expects a driver 
to attach to it. Then, when the subdev driver probes with the newly 
registered device, it passes its v4l2_subdev instance back with its 
i2c_client object, and then the caller can match them. While doing so they 
also allow a race like

	if (!try_module_get(client->driver->driver.owner))

which is exactly what my patch is attempting to fix.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

  reply	other threads:[~2010-11-30  7:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-29 19:43 Guennadi Liakhovetski
2010-11-29 19:56 ` Greg KH
2010-11-29 20:11   ` Guennadi Liakhovetski
2010-11-29 20:17 ` Jonathan Corbet
2010-11-29 20:54   ` Guennadi Liakhovetski
2010-11-29 21:41     ` Greg KH
2010-11-29 22:10       ` Guennadi Liakhovetski
2010-11-29 22:28         ` Jonathan Corbet
2010-11-30  7:18           ` Guennadi Liakhovetski [this message]
2010-11-29 22:32         ` Greg KH
2010-11-29 23:11           ` Guennadi Liakhovetski
2010-11-30 16:56             ` Greg KH
2010-11-30 17:09               ` Guennadi Liakhovetski
2010-11-30 17:15                 ` Greg KH
2010-11-30 17:55                   ` Laurent Pinchart
2010-11-30 18:32                     ` Greg KH
2010-11-30 20:43                       ` Laurent Pinchart
2010-11-30 20:55                         ` Greg KH
2010-11-30 22:19                         ` Hans Verkuil

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=Pine.LNX.4.64.1011300016260.27962@axis700.grange \
    --to=g.liakhovetski@gmx.de \
    --cc=corbet@lwn.net \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®