mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Emilio G. Cota" <cota@braap.org>
To: Martyn Welch <martyn.welch@ge.com>
Cc: Manohar Vanga <manohar.vanga@cern.ch>,
	gregkh@suse.de, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] staging: vme: add functions for bridge module refcounting
Date: Wed, 10 Aug 2011 15:14:24 -0400	[thread overview]
Message-ID: <20110810191424.GA26147@flamenco.cs.columbia.edu> (raw)
In-Reply-To: <4E4258F4.8040408@ge.com>

On Wed, Aug 10, 2011 at 11:09:56 +0100, Martyn Welch wrote:
> On 10/08/11 10:33, Manohar Vanga wrote:
> >  static struct vme_bridge *find_bridge(struct vme_resource *resource)
> > @@ -1525,9 +1573,13 @@ static int vme_bus_probe(struct device *dev)
> >  	driver = dev_to_vme_driver(dev);
> >  	bridge = dev_to_bridge(dev);
> >  
> > +	vme_bridge_get(bridge->num);

Here the return pointer is not being checked, although things
would need to be very wrong for this to fail here.

> >  	if (driver->probe != NULL)
> >  		retval = driver->probe(dev, bridge->num, vme_calc_slot(dev));
> >  
> > +	if (retval)
> > +		vme_bridge_put(bridge);
> > +
> 
> Given that we are recounting automatically in probe and remove, under what
> circumstances would we need to call them separately?

I agree, it's hard to imagine a scenario where "doubly locking"
the module would make any sense at all.

It would also be nice to:

- Increment the refcount of the bridge device with get_device(),
  this way we protect against the device removal as well.
  Bonus points if we increment the bridge module's refcount
  once per device driver using it and the bridge device's
  refcount once per device sitting on it.

- re-think what the return value of vme_bridge_get should be;
  guess my original idea was to return a reference to a bridge,
  which would be safely used by device drivers from there
  on. Since apparently we're not going this way, then perhaps
  an int (returning 0 on success and -ENXIO on failure) would
  be clearer.

		Emilio

  reply	other threads:[~2011-08-10 19:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-10  9:33 [PATCH 0/6] [RESEND] VME framework fixes Manohar Vanga
2011-08-10  9:33 ` [PATCH 1/6] staging: vme: allow explicit assignment of bus numbers Manohar Vanga
2011-08-10 10:02   ` Martyn Welch
2011-08-10 10:41     ` Manohar Vanga
2011-08-10 12:50       ` Martyn Welch
2011-08-23 22:06         ` Greg KH
2011-08-10  9:33 ` [PATCH 2/6] staging: vme: make [alloc|free]_consistent bridge specific Manohar Vanga
2011-08-10 10:04   ` Martyn Welch
2011-08-10 13:24     ` Dan Carpenter
2011-08-10 13:12   ` Joe Perches
2011-08-10 13:34     ` Martyn Welch
2011-08-10 13:51       ` Joe Perches
2011-08-10 13:55         ` Martyn Welch
2011-08-10 14:30           ` Joe Perches
2011-08-10 14:33             ` Martyn Welch
2011-08-10  9:33 ` [PATCH 3/6] staging: vme: keep track of registered buses Manohar Vanga
2011-08-10 10:06   ` Martyn Welch
2011-08-10  9:33 ` [PATCH 4/6] staging: vme: add functions for bridge module refcounting Manohar Vanga
2011-08-10 10:09   ` Martyn Welch
2011-08-10 19:14     ` Emilio G. Cota [this message]
2011-08-10  9:33 ` [PATCH 5/6] staging: vme: add struct vme_dev for VME devices Manohar Vanga
2011-08-10 10:14   ` Martyn Welch
2011-08-10 10:33     ` Manohar Vanga
2011-08-10  9:33 ` [PATCH 6/6] staging: vme: make match() driver specific to improve non-VME64x support Manohar Vanga
2011-08-10 10:18   ` Martyn Welch

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=20110810191424.GA26147@flamenco.cs.columbia.edu \
    --to=cota@braap.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manohar.vanga@cern.ch \
    --cc=martyn.welch@ge.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

all inboxes | Powered by JetHome®