adccmds: Run gpio_adc_setup() before oid_alloc()
Order the adc config code so that a shutdown from gpio_adc_setup() doesn't result in analog_in_shutdown() running on a 'struct analog_in' that hasn't yet been configured. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
6256599a6d
commit
093512b971
|
@ -61,10 +61,11 @@ analog_in_event(struct timer *timer)
|
||||||
void
|
void
|
||||||
command_config_analog_in(uint32_t *args)
|
command_config_analog_in(uint32_t *args)
|
||||||
{
|
{
|
||||||
|
struct gpio_adc pin = gpio_adc_setup(args[1]);
|
||||||
struct analog_in *a = oid_alloc(
|
struct analog_in *a = oid_alloc(
|
||||||
args[0], command_config_analog_in, sizeof(*a));
|
args[0], command_config_analog_in, sizeof(*a));
|
||||||
a->timer.func = analog_in_event;
|
a->timer.func = analog_in_event;
|
||||||
a->pin = gpio_adc_setup(args[1]);
|
a->pin = pin;
|
||||||
a->state = 1;
|
a->state = 1;
|
||||||
}
|
}
|
||||||
DECL_COMMAND(command_config_analog_in, "config_analog_in oid=%c pin=%u");
|
DECL_COMMAND(command_config_analog_in, "config_analog_in oid=%c pin=%u");
|
||||||
|
|
Loading…
Reference in New Issue