summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2017-03-09 15:44:08 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2017-05-14 12:31:58 +0200
commitca4c4164b556fe7d086677a90b5acfd402254364 (patch)
tree0a56301c628baf39b8faf91eb716b2f647fb49e2
parentleon, grcan: fixed race on interrupt mask register (diff)
downloadrtems-ca4c4164b556fe7d086677a90b5acfd402254364.tar.bz2
leon, grcan: updated device name and use it for ISR
-rw-r--r--c/src/lib/libbsp/sparc/shared/can/grcan.c28
-rw-r--r--c/src/lib/libbsp/sparc/shared/include/grcan.h11
2 files changed, 36 insertions, 3 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/can/grcan.c b/c/src/lib/libbsp/sparc/shared/can/grcan.c
index 9e1c05da97..515efa3a48 100644
--- a/c/src/lib/libbsp/sparc/shared/can/grcan.c
+++ b/c/src/lib/libbsp/sparc/shared/can/grcan.c
@@ -217,6 +217,8 @@ static unsigned int __inline__ _grcan_read_nocache(unsigned int address)
}
#endif
+#define NELEM(a) ((int) (sizeof (a) / sizeof (a[0])))
+
static int grcan_count = 0;
static struct grcan_priv *priv_tab[GRCAN_COUNT_MAX];
@@ -307,12 +309,12 @@ int grcan_init3(struct drvmgr_dev *dev)
/* Failed to get prefix, make sure of a unique FS name
* by using the driver minor.
*/
- sprintf(priv->devName, "/dev/grcan%d", dev->minor_drv);
+ sprintf(priv->devName, "grcan%d", dev->minor_drv);
} else {
/* Got special prefix, this means we have a bus prefix
* And we should use our "bus minor"
*/
- sprintf(priv->devName, "/dev/%sgrcan%d", prefix, dev->minor_bus);
+ sprintf(priv->devName, "%sgrcan%d", prefix, dev->minor_bus);
}
return DRVMGR_OK;
@@ -1177,6 +1179,25 @@ int grcan_dev_count(void)
return grcan_count;
}
+void *grcan_open_by_name(char *name, int *dev_no)
+{
+ int i;
+ for (i = 0; i < grcan_count; i++){
+ struct grcan_priv *pDev;
+
+ pDev = priv_tab[i];
+ if (NULL == pDev) {
+ continue;
+ }
+ if (strncmp(pDev->devName, name, NELEM(pDev->devName)) == 0) {
+ if (dev_no)
+ *dev_no = i;
+ return grcan_open(i);
+ }
+ }
+ return NULL;
+}
+
void *grcan_open(int dev_no)
{
struct grcan_priv *pDev;
@@ -1463,7 +1484,8 @@ int grcan_start(void *d)
pDev->started = 1;
/* Register interrupt routine and enable IRQ at IRQ ctrl */
- drvmgr_interrupt_register(pDev->dev, 0, "grcan", grcan_interrupt, pDev);
+ drvmgr_interrupt_register(pDev->dev, 0, pDev->devName,
+ grcan_interrupt, pDev);
return 0;
}
diff --git a/c/src/lib/libbsp/sparc/shared/include/grcan.h b/c/src/lib/libbsp/sparc/shared/include/grcan.h
index 08e663804a..7de76a7286 100644
--- a/c/src/lib/libbsp/sparc/shared/include/grcan.h
+++ b/c/src/lib/libbsp/sparc/shared/include/grcan.h
@@ -171,6 +171,17 @@ extern int grcan_dev_count(void);
extern void *grcan_open(int dev_no);
/*
+ * Open a GRCAN device by name. Finds device index then calls
+ * grcan_open(index).
+ *
+ * name: Device name to open
+ * dev_no: Device number matching name. Will be set if device found.
+ * return: Device handle to use with all other grcan_ API functions. The
+ * function returns NULL if device can not be opened or not found.
+ */
+extern void *grcan_open_by_name(char *name, int *dev_no);
+
+/*
* Close a GRCAN device
*
* return: This function always returns 0 (success)