From 9dd101c26fff95e596039d6168d4ad25e080071c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 8 Jun 2016 20:51:00 -0400 Subject: [PATCH] irq: Prefer irq_disable/enable instead of irq_save/restore in cmds/tasks Task and command handlers always run with irqs enabled, so it is not necessary to save/restore the irq state when disabling irqs in these handlers. Signed-off-by: Kevin O'Connor --- src/adccmds.c | 8 ++++---- src/endstop.c | 6 +++--- src/gpiocmds.c | 6 +++--- src/stepper.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/adccmds.c b/src/adccmds.c index 2ae7f43c..9c70ab88 100644 --- a/src/adccmds.c +++ b/src/adccmds.c @@ -6,7 +6,7 @@ #include "basecmd.h" // alloc_oid #include "board/gpio.h" // struct gpio_adc -#include "board/irq.h" // irq_save +#include "board/irq.h" // irq_disable #include "command.h" // DECL_COMMAND #include "sched.h" // DECL_TASK @@ -90,15 +90,15 @@ analog_in_task(void) foreach_oid(oid, a, command_config_analog_in) { if (a->state != a->sample_count) continue; - uint8_t flag = irq_save(); + irq_disable(); if (a->state != a->sample_count) { - irq_restore(flag); + irq_enable(); continue; } uint16_t value = a->value; uint32_t next_begin_time = a->next_begin_time; a->state++; - irq_restore(flag); + irq_enable(); sendf("analog_in_state oid=%c next_clock=%u value=%hu" , oid, next_begin_time, value); } diff --git a/src/endstop.c b/src/endstop.c index bc177605..6f155cda 100644 --- a/src/endstop.c +++ b/src/endstop.c @@ -7,7 +7,7 @@ #include // offsetof #include "basecmd.h" // alloc_oid #include "board/gpio.h" // struct gpio -#include "board/irq.h" // irq_save +#include "board/irq.h" // irq_disable #include "command.h" // DECL_COMMAND #include "sched.h" // struct timer #include "stepper.h" // stepper_stop @@ -73,11 +73,11 @@ DECL_COMMAND(command_end_stop_home, static void end_stop_report(uint8_t oid, struct end_stop *e) { - uint8_t flag = irq_save(); + irq_disable(); uint32_t position = stepper_get_position(e->stepper); uint8_t eflags = e->flags; e->flags &= ~ESF_REPORT; - irq_restore(flag); + irq_enable(); sendf("end_stop_state oid=%c homing=%c pin=%c pos=%i" , oid, !!(eflags & ESF_HOMING), gpio_in_read(e->pin) diff --git a/src/gpiocmds.c b/src/gpiocmds.c index 70608a6f..864d6526 100644 --- a/src/gpiocmds.c +++ b/src/gpiocmds.c @@ -6,7 +6,7 @@ #include "basecmd.h" // alloc_oid #include "board/gpio.h" // struct gpio_out -#include "board/irq.h" // irq_save +#include "board/irq.h" // irq_disable #include "command.h" // DECL_COMMAND #include "sched.h" // sched_timer @@ -188,7 +188,7 @@ command_schedule_soft_pwm_out(uint32_t *args) if (s->max_duration) next_flags |= SPF_NEXT_CHECK_END; } - uint8_t flag = irq_save(); + irq_disable(); if (s->flags & SPF_CHECK_END && sched_is_before(s->end_time, time)) shutdown("next soft pwm extends existing pwm"); s->end_time = time; @@ -204,7 +204,7 @@ command_schedule_soft_pwm_out(uint32_t *args) s->timer.func = soft_pwm_load_event; sched_timer(&s->timer); } - irq_restore(flag); + irq_enable(); } DECL_COMMAND(command_schedule_soft_pwm_out, "schedule_soft_pwm_out oid=%c clock=%u value=%c"); diff --git a/src/stepper.c b/src/stepper.c index 9dedaf45..0d4754f9 100644 --- a/src/stepper.c +++ b/src/stepper.c @@ -8,7 +8,7 @@ #include "autoconf.h" // CONFIG_* #include "basecmd.h" // alloc_oid #include "board/gpio.h" // gpio_out_write -#include "board/irq.h" // irq_save +#include "board/irq.h" // irq_disable #include "command.h" // DECL_COMMAND #include "sched.h" // struct timer #include "stepper.h" // command_config_stepper @@ -113,7 +113,7 @@ command_queue_step(uint32_t *args) m->next = NULL; m->flags = 0; - uint8_t flag = irq_save(); + irq_disable(); if (!!(s->flags & SF_LAST_DIR) != !!(s->flags & SF_NEXT_DIR)) { s->flags ^= SF_LAST_DIR; m->flags |= MF_DIR; @@ -129,7 +129,7 @@ command_queue_step(uint32_t *args) stepper_load_next(s); sched_timer(&s->time); } - irq_restore(flag); + irq_enable(); } DECL_COMMAND(command_queue_step, "queue_step oid=%c interval=%u count=%hu add=%hi");