forked from Imagelibrary/rtems
leon, grcan: updated device name and use it for ISR
This commit is contained in:
@@ -217,6 +217,8 @@ static unsigned int __inline__ _grcan_read_nocache(unsigned int address)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NELEM(a) ((int) (sizeof (a) / sizeof (a[0])))
|
||||||
|
|
||||||
static int grcan_count = 0;
|
static int grcan_count = 0;
|
||||||
static struct grcan_priv *priv_tab[GRCAN_COUNT_MAX];
|
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
|
/* Failed to get prefix, make sure of a unique FS name
|
||||||
* by using the driver minor.
|
* by using the driver minor.
|
||||||
*/
|
*/
|
||||||
sprintf(priv->devName, "/dev/grcan%d", dev->minor_drv);
|
sprintf(priv->devName, "grcan%d", dev->minor_drv);
|
||||||
} else {
|
} else {
|
||||||
/* Got special prefix, this means we have a bus prefix
|
/* Got special prefix, this means we have a bus prefix
|
||||||
* And we should use our "bus minor"
|
* 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;
|
return DRVMGR_OK;
|
||||||
@@ -1177,6 +1179,25 @@ int grcan_dev_count(void)
|
|||||||
return grcan_count;
|
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)
|
void *grcan_open(int dev_no)
|
||||||
{
|
{
|
||||||
struct grcan_priv *pDev;
|
struct grcan_priv *pDev;
|
||||||
@@ -1463,7 +1484,8 @@ int grcan_start(void *d)
|
|||||||
pDev->started = 1;
|
pDev->started = 1;
|
||||||
|
|
||||||
/* Register interrupt routine and enable IRQ at IRQ ctrl */
|
/* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,17 @@ extern int grcan_dev_count(void);
|
|||||||
*/
|
*/
|
||||||
extern void *grcan_open(int dev_no);
|
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
|
* Close a GRCAN device
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user