Commit fa54b326 authored by Aaron Sierra's avatar Aaron Sierra Committed by Greg Kroah-Hartman

vme: change LM callback argument to void pointer

Make the location monitor callback function prototype more useful by
changing the argument from an integer to a void pointer.

All VME bridge drivers were simply passing the location monitor index
(e.g. 0-3) as the argument to these callbacks. It is much more useful
to pass back a pointer to data that the callback-registering driver
cares about.

There appear to be no in-kernel callers of vme_lm_attach (or
vme_lme_request for that matter), so this change only affects the VME
subsystem and bridge drivers.

This has been tested with Tsi148 hardware, but the CA91Cx42 changes
have only been compiled.
Signed-off-by: default avatarAaron Sierra <asierra@xes-inc.com>
Acked-by: default avatarMartyn Welch <martyn@welchs.me.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 655745b0
...@@ -385,13 +385,13 @@ location monitor location. Each location monitor can monitor a number of ...@@ -385,13 +385,13 @@ location monitor location. Each location monitor can monitor a number of
adjacent locations: adjacent locations:
int vme_lm_attach(struct vme_resource *res, int num, int vme_lm_attach(struct vme_resource *res, int num,
void (*callback)(int)); void (*callback)(void *));
int vme_lm_detach(struct vme_resource *res, int num); int vme_lm_detach(struct vme_resource *res, int num);
The callback function is declared as follows. The callback function is declared as follows.
void callback(int num); void callback(void *data);
Slot Detection Slot Detection
......
...@@ -69,7 +69,7 @@ static u32 ca91cx42_LM_irqhandler(struct ca91cx42_driver *bridge, u32 stat) ...@@ -69,7 +69,7 @@ static u32 ca91cx42_LM_irqhandler(struct ca91cx42_driver *bridge, u32 stat)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (stat & CA91CX42_LINT_LM[i]) { if (stat & CA91CX42_LINT_LM[i]) {
/* We only enable interrupts if the callback is set */ /* We only enable interrupts if the callback is set */
bridge->lm_callback[i](i); bridge->lm_callback[i](bridge->lm_data[i]);
serviced |= CA91CX42_LINT_LM[i]; serviced |= CA91CX42_LINT_LM[i];
} }
} }
...@@ -1410,7 +1410,7 @@ static int ca91cx42_lm_get(struct vme_lm_resource *lm, ...@@ -1410,7 +1410,7 @@ static int ca91cx42_lm_get(struct vme_lm_resource *lm,
* Callback will be passed the monitor triggered. * Callback will be passed the monitor triggered.
*/ */
static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor, static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor,
void (*callback)(int)) void (*callback)(void *), void *data)
{ {
u32 lm_ctl, tmp; u32 lm_ctl, tmp;
struct ca91cx42_driver *bridge; struct ca91cx42_driver *bridge;
...@@ -1438,6 +1438,7 @@ static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor, ...@@ -1438,6 +1438,7 @@ static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor,
/* Attach callback */ /* Attach callback */
bridge->lm_callback[monitor] = callback; bridge->lm_callback[monitor] = callback;
bridge->lm_data[monitor] = data;
/* Enable Location Monitor interrupt */ /* Enable Location Monitor interrupt */
tmp = ioread32(bridge->base + LINT_EN); tmp = ioread32(bridge->base + LINT_EN);
...@@ -1477,6 +1478,7 @@ static int ca91cx42_lm_detach(struct vme_lm_resource *lm, int monitor) ...@@ -1477,6 +1478,7 @@ static int ca91cx42_lm_detach(struct vme_lm_resource *lm, int monitor)
/* Detach callback */ /* Detach callback */
bridge->lm_callback[monitor] = NULL; bridge->lm_callback[monitor] = NULL;
bridge->lm_data[monitor] = NULL;
/* If all location monitors disabled, disable global Location Monitor */ /* If all location monitors disabled, disable global Location Monitor */
if ((tmp & (CA91CX42_LINT_LM0 | CA91CX42_LINT_LM1 | CA91CX42_LINT_LM2 | if ((tmp & (CA91CX42_LINT_LM0 | CA91CX42_LINT_LM1 | CA91CX42_LINT_LM2 |
......
...@@ -43,7 +43,8 @@ struct ca91cx42_driver { ...@@ -43,7 +43,8 @@ struct ca91cx42_driver {
wait_queue_head_t dma_queue; wait_queue_head_t dma_queue;
wait_queue_head_t iack_queue; wait_queue_head_t iack_queue;
wait_queue_head_t mbox_queue; wait_queue_head_t mbox_queue;
void (*lm_callback[4])(int); /* Called in interrupt handler */ void (*lm_callback[4])(void *); /* Called in interrupt handler */
void *lm_data[4];
void *crcsr_kernel; void *crcsr_kernel;
dma_addr_t crcsr_bus; dma_addr_t crcsr_bus;
struct mutex vme_rmw; /* Only one RMW cycle at a time */ struct mutex vme_rmw; /* Only one RMW cycle at a time */
......
...@@ -102,7 +102,7 @@ static u32 tsi148_LM_irqhandler(struct tsi148_driver *bridge, u32 stat) ...@@ -102,7 +102,7 @@ static u32 tsi148_LM_irqhandler(struct tsi148_driver *bridge, u32 stat)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (stat & TSI148_LCSR_INTS_LMS[i]) { if (stat & TSI148_LCSR_INTS_LMS[i]) {
/* We only enable interrupts if the callback is set */ /* We only enable interrupts if the callback is set */
bridge->lm_callback[i](i); bridge->lm_callback[i](bridge->lm_data[i]);
serviced |= TSI148_LCSR_INTC_LMC[i]; serviced |= TSI148_LCSR_INTC_LMC[i];
} }
} }
...@@ -2047,7 +2047,7 @@ static int tsi148_lm_get(struct vme_lm_resource *lm, ...@@ -2047,7 +2047,7 @@ static int tsi148_lm_get(struct vme_lm_resource *lm,
* Callback will be passed the monitor triggered. * Callback will be passed the monitor triggered.
*/ */
static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor,
void (*callback)(int)) void (*callback)(void *), void *data)
{ {
u32 lm_ctl, tmp; u32 lm_ctl, tmp;
struct vme_bridge *tsi148_bridge; struct vme_bridge *tsi148_bridge;
...@@ -2077,6 +2077,7 @@ static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, ...@@ -2077,6 +2077,7 @@ static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor,
/* Attach callback */ /* Attach callback */
bridge->lm_callback[monitor] = callback; bridge->lm_callback[monitor] = callback;
bridge->lm_data[monitor] = data;
/* Enable Location Monitor interrupt */ /* Enable Location Monitor interrupt */
tmp = ioread32be(bridge->base + TSI148_LCSR_INTEN); tmp = ioread32be(bridge->base + TSI148_LCSR_INTEN);
...@@ -2124,6 +2125,7 @@ static int tsi148_lm_detach(struct vme_lm_resource *lm, int monitor) ...@@ -2124,6 +2125,7 @@ static int tsi148_lm_detach(struct vme_lm_resource *lm, int monitor)
/* Detach callback */ /* Detach callback */
bridge->lm_callback[monitor] = NULL; bridge->lm_callback[monitor] = NULL;
bridge->lm_data[monitor] = NULL;
/* If all location monitors disabled, disable global Location Monitor */ /* If all location monitors disabled, disable global Location Monitor */
if ((lm_en & (TSI148_LCSR_INTS_LM0S | TSI148_LCSR_INTS_LM1S | if ((lm_en & (TSI148_LCSR_INTS_LM0S | TSI148_LCSR_INTS_LM1S |
......
...@@ -38,7 +38,8 @@ struct tsi148_driver { ...@@ -38,7 +38,8 @@ struct tsi148_driver {
void __iomem *base; /* Base Address of device registers */ void __iomem *base; /* Base Address of device registers */
wait_queue_head_t dma_queue[2]; wait_queue_head_t dma_queue[2];
wait_queue_head_t iack_queue; wait_queue_head_t iack_queue;
void (*lm_callback[4])(int); /* Called in interrupt handler */ void (*lm_callback[4])(void *); /* Called in interrupt handler */
void *lm_data[4];
void *crcsr_kernel; void *crcsr_kernel;
dma_addr_t crcsr_bus; dma_addr_t crcsr_bus;
struct vme_master_resource *flush_image; struct vme_master_resource *flush_image;
......
...@@ -1321,7 +1321,7 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base, ...@@ -1321,7 +1321,7 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,
EXPORT_SYMBOL(vme_lm_get); EXPORT_SYMBOL(vme_lm_get);
int vme_lm_attach(struct vme_resource *resource, int monitor, int vme_lm_attach(struct vme_resource *resource, int monitor,
void (*callback)(int)) void (*callback)(void *), void *data)
{ {
struct vme_bridge *bridge = find_bridge(resource); struct vme_bridge *bridge = find_bridge(resource);
struct vme_lm_resource *lm; struct vme_lm_resource *lm;
...@@ -1338,7 +1338,7 @@ int vme_lm_attach(struct vme_resource *resource, int monitor, ...@@ -1338,7 +1338,7 @@ int vme_lm_attach(struct vme_resource *resource, int monitor,
return -EINVAL; return -EINVAL;
} }
return bridge->lm_attach(lm, monitor, callback); return bridge->lm_attach(lm, monitor, callback, data);
} }
EXPORT_SYMBOL(vme_lm_attach); EXPORT_SYMBOL(vme_lm_attach);
......
...@@ -160,7 +160,8 @@ struct vme_bridge { ...@@ -160,7 +160,8 @@ struct vme_bridge {
int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32); int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *, int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
u32 *); u32 *);
int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int)); int (*lm_attach)(struct vme_lm_resource *, int,
void (*callback)(void *), void *);
int (*lm_detach) (struct vme_lm_resource *, int); int (*lm_detach) (struct vme_lm_resource *, int);
/* CR/CSR space functions */ /* CR/CSR space functions */
......
...@@ -166,7 +166,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *); ...@@ -166,7 +166,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *);
int vme_lm_count(struct vme_resource *); int vme_lm_count(struct vme_resource *);
int vme_lm_set(struct vme_resource *, unsigned long long, u32, u32); int vme_lm_set(struct vme_resource *, unsigned long long, u32, u32);
int vme_lm_get(struct vme_resource *, unsigned long long *, u32 *, u32 *); int vme_lm_get(struct vme_resource *, unsigned long long *, u32 *, u32 *);
int vme_lm_attach(struct vme_resource *, int, void (*callback)(int)); int vme_lm_attach(struct vme_resource *, int, void (*callback)(void *), void *);
int vme_lm_detach(struct vme_resource *, int); int vme_lm_detach(struct vme_resource *, int);
void vme_lm_free(struct vme_resource *); void vme_lm_free(struct vme_resource *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment