Module: xenomai-3
Branch: arm64
Commit: f2f8376b082ac73ea96f126daa262b9bdeab9f2e
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f2f8376b082ac73ea96f126daa262b9bdeab9f2e

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Sep  9 09:27:10 2015 +0200

drivers/can/raw: force all ioctl handling in secondary mode

RTDM/ioctl is defined as a "probing" syscall by Xenomai 3, which means
that we don't want to provide a rt-specific handler for routing to
rtcan_raw_ioctl(), as some CAN drivers have to execute their ioctl
helpers from secondary mode exclusively (e.g. flexscan's set_mode).

All CAN ioctl helpers are deemed compatible with secondary mode
already, so we may safely route all requests to rtcan_raw_ioctl() from
this context.

---

 kernel/drivers/can/rtcan_flexcan.c |   15 ++++++++++++++-
 kernel/drivers/can/rtcan_raw.c     |    1 -
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/drivers/can/rtcan_flexcan.c 
b/kernel/drivers/can/rtcan_flexcan.c
index adfbef8..27c856d 100644
--- a/kernel/drivers/can/rtcan_flexcan.c
+++ b/kernel/drivers/can/rtcan_flexcan.c
@@ -836,6 +836,13 @@ static int flexcan_mode_stop(struct rtcan_device *dev, 
rtdm_lockctx_t *lock_ctx)
        if (!CAN_STATE_OPERATING(state))
                goto out;
 
+       /*
+        * Drop the device lock early, we should not need it and we
+        * may not hold it for calling the regular kernel
+        * infrastructure.
+        */
+       rtdm_lock_put_irqrestore(&dev->device_lock, *lock_ctx);
+
        flexcan_chip_stop(dev);
 
        /* Wake up waiting senders */
@@ -845,6 +852,7 @@ static int flexcan_mode_stop(struct rtcan_device *dev, 
rtdm_lockctx_t *lock_ctx)
 
        flexcan_clk_disable(priv);
 
+       rtdm_lock_get_irqsave(&dev->device_lock, *lock_ctx);
 out:
        return 0;
 }
@@ -855,6 +863,8 @@ static int flexcan_mode_start(struct rtcan_device *dev,
        struct flexcan_priv *priv = rtcan_priv(dev);
        int err = 0;
 
+       rtdm_lock_put_irqrestore(&dev->device_lock, *lock_ctx);
+
        switch (dev->state) {
 
        case CAN_STATE_ACTIVE:
@@ -897,16 +907,19 @@ static int flexcan_mode_start(struct rtcan_device *dev,
        case CAN_STATE_SLEEPING:
        default:
                /* Never reached, but we don't want nasty compiler warnings ... 
*/
+               err = 0;
                break;
        }
 
-       return 0;
+       goto out;
 
 out_irq_free:
        rtdm_irq_free(&dev->irq_handle);
 out_clk_disable:
        flexcan_clk_disable(priv);
 out:
+       rtdm_lock_get_irqsave(&dev->device_lock, *lock_ctx);
+
        return err;
 }
 
diff --git a/kernel/drivers/can/rtcan_raw.c b/kernel/drivers/can/rtcan_raw.c
index 20e554c..9eb8531 100644
--- a/kernel/drivers/can/rtcan_raw.c
+++ b/kernel/drivers/can/rtcan_raw.c
@@ -978,7 +978,6 @@ static struct rtdm_driver rtcan_driver = {
        .ops = {
                .socket         = rtcan_raw_socket,
                .close          = rtcan_raw_close,
-               .ioctl_rt       = rtcan_raw_ioctl,
                .ioctl_nrt      = rtcan_raw_ioctl,
                .recvmsg_rt     = rtcan_raw_recvmsg,
                .sendmsg_rt     = rtcan_raw_sendmsg,


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to