Skip to content
Snippets Groups Projects
Commit 5c3f4d21 authored by Lorenz Meier's avatar Lorenz Meier
Browse files

GPIO led: Do not allocate memory statically, but only when module loads

parent 6aba6a4f
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,7 @@ struct gpio_led_s {
int counter;
};
static struct gpio_led_s gpio_led_data;
static struct gpio_led_s *gpio_led_data;
static bool gpio_led_started = false;
__EXPORT int gpio_led_main(int argc, char *argv[]);
......@@ -170,10 +170,11 @@ int gpio_led_main(int argc, char *argv[])
}
}
memset(&gpio_led_data, 0, sizeof(gpio_led_data));
gpio_led_data.use_io = use_io;
gpio_led_data.pin = pin;
int ret = work_queue(LPWORK, &gpio_led_data.work, gpio_led_start, &gpio_led_data, 0);
gpio_led_data = malloc(sizeof(struct gpio_led_s));
memset(gpio_led_data, 0, sizeof(struct gpio_led_s));
gpio_led_data->use_io = use_io;
gpio_led_data->pin = pin;
int ret = work_queue(LPWORK, &(gpio_led_data->work), gpio_led_start, gpio_led_data, 0);
if (ret != 0) {
errx(1, "failed to queue work: %d", ret);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment