public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: atull@opensource.altera.com (atull)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v20 06/10] fpga: add fpga bridge framework
Date: Mon, 17 Oct 2016 15:25:15 -0500	[thread overview]
Message-ID: <alpine.DEB.2.02.1610171513080.8724@linuxheads99> (raw)
In-Reply-To: <20161017160941.4205-7-atull@opensource.altera.com>

On Mon, 17 Oct 2016, Alan Tull wrote:

> +/**
> + * of_fpga_bridge_get - get an exclusive reference to a fpga bridge
> + *
> + * @np: node pointer of a FPGA bridge
> + * @info: fpga image specific information
> + *
> + * Return fpga_bridge struct if successful.
> + * Return -EBUSY if someone already has a reference to the bridge.
> + * Return -ENODEV if @np is not a FPGA Bridge.
> + */
> +struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
> +				       struct fpga_image_info *info)
> +
> +{
> +	struct device *dev;
> +	struct fpga_bridge *bridge;
> +	int ret = -ENODEV;
> +
> +	of_node_get(np);

I thought I had fixed this.  This of_node_get is unmatched,
never called in fpga_bridge_put.  And it's not necessary
since class_find_device will do kobject_get on the child
device anyway.  So I should remove this of_node_get
and the of_node_put below.

> +
> +	dev = class_find_device(fpga_bridge_class, NULL, np,
> +				fpga_bridge_of_node_match);
> +	if (!dev)
> +		goto err_dev;
> +
> +	bridge = to_fpga_bridge(dev);
> +	if (!bridge)
> +		goto err_dev;
> +
> +	bridge->info = info;
> +
> +	if (!mutex_trylock(&bridge->mutex)) {
> +		ret = -EBUSY;
> +		goto err_dev;
> +	}
> +
> +	if (!try_module_get(dev->parent->driver->owner))
> +		goto err_ll_mod;
> +
> +	dev_dbg(&bridge->dev, "get\n");
> +
> +	return bridge;
> +
> +err_ll_mod:
> +	mutex_unlock(&bridge->mutex);
> +err_dev:
> +	put_device(dev);
> +	of_node_put(np);

Remove of_node_put.

> +	return ERR_PTR(ret);
> +}
> +EXPORT_SYMBOL_GPL(of_fpga_bridge_get);
> +
> +/**
> + * fpga_bridge_put - release a reference to a bridge
> + *
> + * @bridge: FPGA bridge
> + */
> +void fpga_bridge_put(struct fpga_bridge *bridge)
> +{
> +	dev_dbg(&bridge->dev, "put\n");
> +
> +	bridge->info = NULL;
> +	module_put(bridge->dev.parent->driver->owner);
> +	mutex_unlock(&bridge->mutex);
> +	put_device(&bridge->dev);
> +}
> +EXPORT_SYMBOL_GPL(fpga_bridge_put);

  reply	other threads:[~2016-10-17 20:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-17 16:09 [PATCH v20 00/10] Device Tree support for FPGA Programming Alan Tull
2016-10-17 16:09 ` [PATCH v20 01/10] fpga: add bindings document for fpga region Alan Tull
2016-10-17 16:09 ` [PATCH v20 02/10] doc: fpga-mgr: add fpga image info to api Alan Tull
2016-10-17 21:00   ` Moritz Fischer
2016-10-18 18:28     ` atull
2016-10-17 16:09 ` [PATCH v20 03/10] add bindings document for altera freeze bridge Alan Tull
2016-10-18 16:26   ` Rob Herring
2016-10-18 18:34     ` atull
2016-10-17 16:09 ` [PATCH v20 04/10] add sysfs document for fpga bridge class Alan Tull
2016-10-17 16:09 ` [PATCH v20 05/10] fpga-mgr: add fpga image information struct Alan Tull
2016-10-17 16:09 ` [PATCH v20 06/10] fpga: add fpga bridge framework Alan Tull
2016-10-17 20:25   ` atull [this message]
2016-10-17 16:09 ` [PATCH v20 07/10] fpga: fpga-region: device tree control for FPGA Alan Tull
2016-10-17 16:09 ` [PATCH v20 08/10] ARM: socfpga: fpga bridge driver support Alan Tull
2016-10-17 16:09 ` [PATCH v20 09/10] fpga: add altera freeze bridge support Alan Tull
2016-10-17 16:09 ` [PATCH v20 10/10] fpga-manager: Add Socfpga Arria10 support Alan Tull
2016-10-18 21:01   ` Moritz Fischer
2016-10-19 15:49     ` atull

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.1610171513080.8724@linuxheads99 \
    --to=atull@opensource.altera.com \
    --cc=linux-arm-kernel@lists.infradead.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