From: Martyn Welch <martyn.welch@ge.com>
To: Manohar Vanga <manohar.vanga@cern.ch>
Cc: gregkh@suse.de, cota@braap.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] staging: vme: keep track of registered buses
Date: Wed, 10 Aug 2011 11:06:43 +0100 [thread overview]
Message-ID: <4E425833.6020907@ge.com> (raw)
In-Reply-To: <1312968830-13377-4-git-send-email-manohar.vanga@cern.ch>
On 10/08/11 10:33, Manohar Vanga wrote:
> This patch adds a list which keeps track of all registered VME
> buses. This is required for adding refcounting later to bridge
> modules, something that is not currently implemented.
>
> This is based on the changes introduced by Emilio G. Cota in the
> patch:
>
> https://lkml.org/lkml/2010/10/25/486
>
> Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>
Looks OK:
Acked-by: Martyn Welch <martyn.welch@ge.com>
> ---
> drivers/staging/vme/vme.c | 46 ++++++++++++++++++++-----------------
> drivers/staging/vme/vme_bridge.h | 1 +
> 2 files changed, 26 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
> index 15a6161..f811d07 100644
> --- a/drivers/staging/vme/vme.c
> +++ b/drivers/staging/vme/vme.c
> @@ -34,9 +34,10 @@
> #include "vme.h"
> #include "vme_bridge.h"
>
> -/* Bitmask and mutex to keep track of bridge numbers */
> +/* Bitmask and list of registered buses both protected by common mutex */
> static unsigned int vme_bus_numbers;
> -static DEFINE_MUTEX(vme_bus_num_mtx);
> +static LIST_HEAD(vme_bus_list);
> +static DEFINE_MUTEX(vme_buses_lock);
>
> static void __exit vme_exit(void);
> static int __init vme_init(void);
> @@ -1309,11 +1310,12 @@ EXPORT_SYMBOL(vme_slot_get);
>
> /* - Bridge Registration --------------------------------------------------- */
>
> -/* call with vme_bus_num_mtx held */
> -static int __vme_alloc_bus_num(int bus_num)
> +/* call with vme_buses_lock held */
> +static int __vme_add_bus(struct vme_bridge *bridge)
> {
> int num;
> int i;
> + int bus_num = bridge->num;
>
> if (bus_num == -1) {
> /* try to find a free bus number */
> @@ -1335,25 +1337,29 @@ static int __vme_alloc_bus_num(int bus_num)
> }
> num = bus_num;
> }
> + bridge->num = num;
> + list_add_tail(&bridge->bus_list, &vme_bus_list);
> vme_bus_numbers |= 1 << num;
> - return num;
> + return 0;
> }
>
> -static int vme_alloc_bus_num(int bus_num)
> +static int vme_add_bus(struct vme_bridge *bridge)
> {
> - int num;
> + int ret;
>
> - mutex_lock(&vme_bus_num_mtx);
> - num = __vme_alloc_bus_num(bus_num);
> - mutex_unlock(&vme_bus_num_mtx);
> - return num;
> + mutex_lock(&vme_buses_lock);
> + ret = __vme_add_bus(bridge);
> + mutex_unlock(&vme_buses_lock);
> +
> + return ret;
> }
>
> -static void vme_free_bus_num(int bus)
> +static void vme_remove_bus(struct vme_bridge *bridge)
> {
> - mutex_lock(&vme_bus_num_mtx);
> - vme_bus_numbers &= ~(0x1 << bus);
> - mutex_unlock(&vme_bus_num_mtx);
> + mutex_lock(&vme_buses_lock);
> + vme_bus_numbers &= ~(1 << bridge->num);
> + list_del(&bridge->bus_list);
> + mutex_unlock(&vme_buses_lock);
> }
>
> int vme_register_bridge(struct vme_bridge *bridge)
> @@ -1362,12 +1368,10 @@ int vme_register_bridge(struct vme_bridge *bridge)
> int retval;
> int i;
>
> - retval = vme_alloc_bus_num(bridge->num);
> - if (retval < 0)
> + retval = vme_add_bus(bridge);
> + if (retval)
> return retval;
>
> - bridge->num = retval;
> -
> /* This creates 32 vme "slot" devices. This equates to a slot for each
> * ID available in a system conforming to the ANSI/VITA 1-1994
> * specification.
> @@ -1398,7 +1402,7 @@ err_reg:
> dev = &bridge->dev[i];
> device_unregister(dev);
> }
> - vme_free_bus_num(bridge->num);
> + vme_remove_bus(bridge);
> return retval;
> }
> EXPORT_SYMBOL(vme_register_bridge);
> @@ -1413,7 +1417,7 @@ void vme_unregister_bridge(struct vme_bridge *bridge)
> dev = &bridge->dev[i];
> device_unregister(dev);
> }
> - vme_free_bus_num(bridge->num);
> + vme_remove_bus(bridge);
> }
> EXPORT_SYMBOL(vme_unregister_bridge);
>
> diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h
> index a9084f0..8959670 100644
> --- a/drivers/staging/vme/vme_bridge.h
> +++ b/drivers/staging/vme/vme_bridge.h
> @@ -112,6 +112,7 @@ struct vme_bridge {
> /* Bridge Info - XXX Move to private structure? */
> struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
> void *driver_priv; /* Private pointer for the bridge driver */
> + struct list_head bus_list; /* list of VME buses */
>
> struct device dev[VME_SLOTS_MAX]; /* Device registered with
> * device model on VME bus
--
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms | Wales (3828642) at 100
T +44(0)127322748 | Barbirolli Square, Manchester,
E martyn.welch@ge.com | M2 3AB VAT:GB 927559189
next prev parent reply other threads:[~2011-08-10 10:06 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 [this message]
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
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=4E425833.6020907@ge.com \
--to=martyn.welch@ge.com \
--cc=cota@braap.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=manohar.vanga@cern.ch \
/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