From: atull <atull@opensource.altera.com>
To: Josh Cartwright <joshc@ni.com>
Cc: <gregkh@linuxfoundation.org>, <jgunthorpe@obsidianresearch.com>,
<hpa@zytor.com>, <monstr@monstr.eu>, <michal.simek@xilinx.com>,
<rdunlap@infradead.org>,
Moritz Fischer <moritz.fischer@ettus.com>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<pantelis.antoniou@konsulko.com>, <robh+dt@kernel.org>,
<grant.likely@linaro.org>, <iws@ovro.caltech.edu>,
<linux-doc@vger.kernel.org>, <pavel@denx.de>,
<broonie@kernel.org>, <philip@balister.org>, <rubini@gnudd.com>,
<s.trumtrar@pengutronix.de>, <jason@lakedaemon.net>,
<kyle.teske@ni.com>, <nico@linaro.org>, <balbi@ti.com>,
<m.chehab@samsung.com>, <davidb@codeaurora.org>,
<rob@landley.net>, <davem@davemloft.net>, <cesarb@cesarb.net>,
<sameo@linux.intel.com>, <akpm@linux-foundation.org>,
<linus.walleij@linaro.org>, <pawel.moll@arm.com>,
<mark.rutland@arm.com>, <ijc+devicetree@hellion.org.uk>,
<galak@codeaurora.org>, <devel@driverdev.osuosl.org>,
Petr Cvek <petr.cvek@tul.cz>, <delicious.quinoa@gmail.com>,
<dinguyen@opensource.altera.com>
Subject: Re: [PATCH v11 3/4] add FPGA manager core
Date: Thu, 24 Sep 2015 15:24:52 -0500 [thread overview]
Message-ID: <alpine.DEB.2.02.1509241523140.5173@linuxheads99> (raw)
In-Reply-To: <20150923230315.GF26335@jcartwri.amer.corp.natinst.com>
On Wed, 23 Sep 2015, Josh Cartwright wrote:
> On Wed, Sep 23, 2015 at 12:10:13PM -0500, atull wrote:
> > On Tue, 22 Sep 2015, Josh Cartwright wrote:
> [..]
> > > > +struct fpga_manager *of_fpga_mgr_get(struct device_node *node)
> > > > +{
> > > > + struct fpga_manager *mgr;
> > > > + struct device *dev;
> > > > +
> > > > + if (!node)
> > > > + return ERR_PTR(-EINVAL);
> > > > +
> > > > + dev = class_find_device(fpga_mgr_class, NULL, node,
> > > > + fpga_mgr_of_node_match);
> > > > + if (!dev)
> > > > + return ERR_PTR(-ENODEV);
> > > > +
> > > > + mgr = to_fpga_manager(dev);
> > > > + put_device(dev);
> > >
> > > Who's ensuring the FPGA manager device's lifetime between _get and _put?
> >
> > Well... get_device and put_device are not sufficient?
>
> Sorry if I was too opaque.
>
> You've just put_device()'d the only reference to the device you had
> here, so nothing is preventing from the device from being ripped away
> while it's being used.
>
> You should remove the put_device() call here, and add a corresponding
> put_device() in fpga_mgr_put().
>
> The module refcounting is also a bit strange, as you are
> acquiring/releasing a reference to THIS_MODULE, but you also should care
> about the lower-level driver's module refcount.
>
Good call. Thanks for the clarification. I'll have something more robust
in v12.
> [..]
> > > > + dt_label = of_get_property(mgr->dev.of_node, "label", NULL);
> > > > + if (dt_label)
> > > > + ret = dev_set_name(&mgr->dev, "%s", dt_label);
> > > > + else
> > > > + ret = dev_set_name(&mgr->dev, "fpga%d", id);
> > >
> > > I'm wondering if an alias {} node is better for this.
> >
> > I could look into that. Is there an example of that you particularly
> > like for this?
>
> Look at i2c's usage of the of_alias_*() functions.
OK yes, will use that in the next version.
Thanks for the review,
Alan
>
> Josh
>
next prev parent reply other threads:[~2015-09-24 20:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 15:21 [PATCH v11 0/4] FPGA Manager Framework atull
2015-09-22 15:21 ` [PATCH v11 1/4] usage documentation for FPGA manager core atull
2015-09-23 0:50 ` Moritz Fischer
2015-09-22 15:21 ` [PATCH v11 2/4] fpga manager: add sysfs interface document atull
2015-09-23 0:52 ` Moritz Fischer
2015-09-22 15:21 ` [PATCH v11 3/4] add FPGA manager core atull
2015-09-22 22:29 ` Josh Cartwright
2015-09-23 13:23 ` Pavel Machek
2015-09-23 14:11 ` Dan Carpenter
2015-09-23 16:15 ` atull
2015-09-24 7:49 ` Dan Carpenter
2015-09-24 20:47 ` atull
2015-09-24 21:13 ` Pavel Machek
2015-09-25 10:00 ` Dan Carpenter
2015-09-23 17:10 ` atull
2015-09-23 23:03 ` Josh Cartwright
2015-09-24 20:24 ` atull [this message]
2015-09-22 15:21 ` [PATCH v11 4/4] fpga manager: add driver for socfpga fpga manager atull
2015-09-22 22:47 ` Josh Cartwright
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=alpine.DEB.2.02.1509241523140.5173@linuxheads99 \
--to=atull@opensource.altera.com \
--cc=akpm@linux-foundation.org \
--cc=balbi@ti.com \
--cc=broonie@kernel.org \
--cc=cesarb@cesarb.net \
--cc=davem@davemloft.net \
--cc=davidb@codeaurora.org \
--cc=delicious.quinoa@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=devicetree@vger.kernel.org \
--cc=dinguyen@opensource.altera.com \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=iws@ovro.caltech.edu \
--cc=jason@lakedaemon.net \
--cc=jgunthorpe@obsidianresearch.com \
--cc=joshc@ni.com \
--cc=kyle.teske@ni.com \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=mark.rutland@arm.com \
--cc=michal.simek@xilinx.com \
--cc=monstr@monstr.eu \
--cc=moritz.fischer@ettus.com \
--cc=nico@linaro.org \
--cc=pantelis.antoniou@konsulko.com \
--cc=pavel@denx.de \
--cc=pawel.moll@arm.com \
--cc=petr.cvek@tul.cz \
--cc=philip@balister.org \
--cc=rdunlap@infradead.org \
--cc=rob@landley.net \
--cc=robh+dt@kernel.org \
--cc=rubini@gnudd.com \
--cc=s.trumtrar@pengutronix.de \
--cc=sameo@linux.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