do ioctl multiplexing in ioctl.c
This commit is contained in:
parent
bf790debb6
commit
aa89735e55
|
|
@ -191,7 +191,6 @@ int eccdev_release(struct inode *inode, struct file *filp)
|
||||||
*/
|
*/
|
||||||
long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
long result;
|
|
||||||
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) filp->private_data;
|
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) filp->private_data;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
@ -200,11 +199,7 @@ long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||||
filp, cmd, _IOC_NR(cmd), arg);
|
filp, cmd, _IOC_NR(cmd), arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = ec_ioctl_rt(priv->cdev->master, &priv->ctx, cmd, (void __user *) arg);
|
return ec_ioctl(priv->cdev->master, &priv->ctx, cmd, (void __user *) arg);
|
||||||
if (result == -ENOTTY) {
|
|
||||||
result = ec_ioctl_nrt(priv->cdev->master, &priv->ctx, cmd, (void __user *) arg);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -4665,11 +4665,16 @@ static ATTRIBUTES int ec_ioctl_slave_soe_write(
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
/** ioctl() function to use.
|
/** ioctl() function to use.
|
||||||
|
*
|
||||||
|
* For RTDM, there will be ec_ioctl_rtdm_rt and ec_ioctl_rtdm_nrt.
|
||||||
|
* For "normal" cdev, there will be ec_ioctl_rt only.
|
||||||
*/
|
*/
|
||||||
#ifdef EC_IOCTL_RTDM
|
#ifndef EC_IOCTL_RTDM
|
||||||
#define EC_IOCTL(x) ec_ioctl_rtdm_ ## x
|
static long ec_ioctl_nrt(
|
||||||
#else
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
#define EC_IOCTL(x) ec_ioctl_ ## x
|
ec_ioctl_context_t *ctx, /**< Device context. */
|
||||||
|
unsigned int cmd, /**< ioctl() command identifier. */
|
||||||
|
void *arg /**< ioctl() argument. */);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Called when an ioctl() command is issued.
|
/** Called when an ioctl() command is issued.
|
||||||
|
|
@ -4677,7 +4682,7 @@ static ATTRIBUTES int ec_ioctl_slave_soe_write(
|
||||||
*
|
*
|
||||||
* \return ioctl() return code.
|
* \return ioctl() return code.
|
||||||
*/
|
*/
|
||||||
static long EC_IOCTL(both)(
|
static long ec_ioctl_both(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
ec_ioctl_context_t *ctx, /**< Device context. */
|
ec_ioctl_context_t *ctx, /**< Device context. */
|
||||||
unsigned int cmd, /**< ioctl() command identifier. */
|
unsigned int cmd, /**< ioctl() command identifier. */
|
||||||
|
|
@ -4870,7 +4875,12 @@ static long EC_IOCTL(both)(
|
||||||
ret = ec_ioctl_voe_data(master, arg, ctx);
|
ret = ec_ioctl_voe_data(master, arg, ctx);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
#ifdef EC_IOCTL_RTDM
|
||||||
ret = -ENOTTY;
|
ret = -ENOTTY;
|
||||||
|
#else
|
||||||
|
/* chain non-rt commands for normal cdev */
|
||||||
|
ret = ec_ioctl_nrt(master, ctx, cmd, arg);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4878,11 +4888,16 @@ static long EC_IOCTL(both)(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when an ioctl() command is issued.
|
/** Called when an ioctl() command is issued.
|
||||||
* RT only.
|
* RTDM: RT only.
|
||||||
*
|
*
|
||||||
* \return ioctl() return code.
|
* \return ioctl() return code.
|
||||||
*/
|
*/
|
||||||
long EC_IOCTL(rt)(
|
#ifdef EC_IOCTL_RTDM
|
||||||
|
long ec_ioctl_rtdm_rt
|
||||||
|
#else
|
||||||
|
long ec_ioctl
|
||||||
|
#endif
|
||||||
|
(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
ec_ioctl_context_t *ctx, /**< Device context. */
|
ec_ioctl_context_t *ctx, /**< Device context. */
|
||||||
unsigned int cmd, /**< ioctl() command identifier. */
|
unsigned int cmd, /**< ioctl() command identifier. */
|
||||||
|
|
@ -4967,7 +4982,7 @@ long EC_IOCTL(rt)(
|
||||||
ret = ec_ioctl_voe_exec(master, arg, ctx);
|
ret = ec_ioctl_voe_exec(master, arg, ctx);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = EC_IOCTL(both)(master, ctx, cmd, arg);
|
ret = ec_ioctl_both(master, ctx, cmd, arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4988,14 +5003,19 @@ long EC_IOCTL(rt)(
|
||||||
*
|
*
|
||||||
* \return ioctl() return code.
|
* \return ioctl() return code.
|
||||||
*/
|
*/
|
||||||
long EC_IOCTL(nrt)(
|
#ifdef EC_IOCTL_RTDM
|
||||||
|
long ec_ioctl_rtdm_nrt
|
||||||
|
#else
|
||||||
|
static long ec_ioctl_nrt
|
||||||
|
#endif
|
||||||
|
(
|
||||||
ec_master_t *master, /**< EtherCAT master. */
|
ec_master_t *master, /**< EtherCAT master. */
|
||||||
ec_ioctl_context_t *ctx, /**< Device context. */
|
ec_ioctl_context_t *ctx, /**< Device context. */
|
||||||
unsigned int cmd, /**< ioctl() command identifier. */
|
unsigned int cmd, /**< ioctl() command identifier. */
|
||||||
void *arg /**< ioctl() argument. */
|
void *arg /**< ioctl() argument. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#if DEBUG_LATENCY
|
#if DEBUG_LATENCY && !defined(EC_IOCTL_RTDM)
|
||||||
cycles_t a = get_cycles(), b;
|
cycles_t a = get_cycles(), b;
|
||||||
unsigned int t;
|
unsigned int t;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -5303,11 +5323,15 @@ long EC_IOCTL(nrt)(
|
||||||
ret = ec_ioctl_set_send_interval(master, arg, ctx);
|
ret = ec_ioctl_set_send_interval(master, arg, ctx);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = EC_IOCTL(both)(master, ctx, cmd, arg);
|
#ifdef EC_IOCTL_RTDM
|
||||||
|
ret = ec_ioctl_both(master, ctx, cmd, arg);
|
||||||
|
#else
|
||||||
|
ret = -ENOTTY;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LATENCY
|
#if DEBUG_LATENCY && !defined(EC_IOCTL_RTDM)
|
||||||
b = get_cycles();
|
b = get_cycles();
|
||||||
t = (unsigned int) ((b - a) * 1000LL) / cpu_khz;
|
t = (unsigned int) ((b - a) * 1000LL) / cpu_khz;
|
||||||
if (t > 50) {
|
if (t > 50) {
|
||||||
|
|
|
||||||
|
|
@ -838,9 +838,7 @@ typedef struct {
|
||||||
size_t process_data_size; /**< Size of the \a process_data. */
|
size_t process_data_size; /**< Size of the \a process_data. */
|
||||||
} ec_ioctl_context_t;
|
} ec_ioctl_context_t;
|
||||||
|
|
||||||
long ec_ioctl_rt(ec_master_t *, ec_ioctl_context_t *, unsigned int,
|
long ec_ioctl(ec_master_t *, ec_ioctl_context_t *, unsigned int,
|
||||||
void __user *);
|
|
||||||
long ec_ioctl_nrt(ec_master_t *, ec_ioctl_context_t *, unsigned int,
|
|
||||||
void __user *);
|
void __user *);
|
||||||
|
|
||||||
#ifdef EC_RTDM
|
#ifdef EC_RTDM
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue