summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorYacine Belkadi2012-07-09 17:34:00 +0200
committerYacine Belkadi2012-07-18 13:34:25 +0200
commit7bdf6977ac8ba34280489a8ad203bc1665a77867 (patch)
treeef775cd4f2ca02a7098ba06bba4d53370bb60070 /cleopatre
parentd3386fce958698ccd0c79b8189f64c3d05058c4b (diff)
cleo/{buildroot, managerd}: add CONFIG_EXTRA_LEDS, refs #3240
Instead of depending directly on the board type (SPK300 or SPK300G) in the code, depend on a config option. This option is set, depending on the board, at buildroot's level. The main objective of the changes is to remove the dependency that managerd had on the "autoconf.h" file of the Linux Kernel. NB: The "#if defined" in gpio_event.h included CONFIG_MACH_SPK310, but not the other ones in gpio_event.c. So in reality, the feature was not available for SPK310. So this commit enables it only for SPK300 and SPK300G.
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/application/managerd/inc/gpio_event.h6
-rw-r--r--cleopatre/application/managerd/src/gpio_event.c21
-rw-r--r--cleopatre/buildroot/package/managerd/managerd.mk9
3 files changed, 19 insertions, 17 deletions
diff --git a/cleopatre/application/managerd/inc/gpio_event.h b/cleopatre/application/managerd/inc/gpio_event.h
index 2840088098..3d332fbbae 100644
--- a/cleopatre/application/managerd/inc/gpio_event.h
+++ b/cleopatre/application/managerd/inc/gpio_event.h
@@ -21,8 +21,6 @@
#ifndef GPIO_EVENT_H
#define GPIO_EVENT_H
-#include "../../linux/autoconf.h"
-
struct managerd_ctx;
/** GPIO number for SC button and it associated LED */
@@ -30,10 +28,6 @@ struct managerd_ctx;
/** LED GPIO numbers */
#define LED_ATTACHMENT_GPIO_NUM 3
-#if (defined CONFIG_MACH_SPK300G || defined CONFIG_MACH_SPK300 || defined CONFIG_MACH_SPK310)
-# define LED1_GPIO_NUM 13
-# define LED2_GPIO_NUM 12
-#endif
/** Blinking timers */
#define LED_FAST_TIMER_US 100000
diff --git a/cleopatre/application/managerd/src/gpio_event.c b/cleopatre/application/managerd/src/gpio_event.c
index b81dcc5b79..11a9178149 100644
--- a/cleopatre/application/managerd/src/gpio_event.c
+++ b/cleopatre/application/managerd/src/gpio_event.c
@@ -33,6 +33,7 @@
#include "../../linux/gpio.h"
#include "managerd.h"
+#include "managerd_config.h"
#include "gpio_event.h"
/* Global variable for "/dev/gpio" file descriptor
@@ -298,9 +299,9 @@ led1_event (struct managerd_ctx *ctx, const char *cco)
assert (NULL != ctx);
assert (NULL != cco);
-#if (defined CONFIG_MACH_SPK300G || defined CONFIG_MACH_SPK300)
+#if defined (CONFIG_EXTRA_LEDS)
/* Set GPIO number */
- ctx->led_gpio.gpioval.num = LED1_GPIO_NUM;
+ ctx->led_gpio.gpioval.num = CONFIG_LED1_GPIO_NUM;
if (!strcmp (LIBSPID_HPAV_INFO_VALUE_CCO_STATION, cco)
|| !strcmp (LIBSPID_HPAV_INFO_VALUE_CCO_PROXY, cco))
@@ -351,9 +352,9 @@ led2_event (struct managerd_ctx *ctx, libspid_boolean_t is_backup_cco)
/* Check arguments */
assert (NULL != ctx);
-#if (defined CONFIG_MACH_SPK300G || defined CONFIG_MACH_SPK300)
+#if defined (CONFIG_EXTRA_LEDS)
/* Set GPIO number */
- ctx->led_gpio.gpioval.num = LED2_GPIO_NUM;
+ ctx->led_gpio.gpioval.num = CONFIG_LED2_GPIO_NUM;
if (LIBSPID_FALSE == is_backup_cco)
{
@@ -414,16 +415,16 @@ led_init (struct managerd_ctx *ctx)
strerror (errno));
}
-#if (defined CONFIG_MACH_SPK300G || defined CONFIG_MACH_SPK300)
+#if defined (CONFIG_EXTRA_LEDS)
/* Set GPIO direction of LED1&2 */
- ctx->led_gpio.gpiodir.num = LED1_GPIO_NUM;
+ ctx->led_gpio.gpiodir.num = CONFIG_LED1_GPIO_NUM;
if (0 > (ioctl (ctx->gpio_fd, GPIOIOC_SETDIRECTION,
(unsigned long *) &ctx->led_gpio)))
{
syslog (LOG_WARNING, "cannot call ioctl SETDIRECTION for LED1 GPIO (%s)",
strerror (errno));
}
- ctx->led_gpio.gpiodir.num = LED2_GPIO_NUM;
+ ctx->led_gpio.gpiodir.num = CONFIG_LED2_GPIO_NUM;
if (0 > (ioctl (ctx->gpio_fd, GPIOIOC_SETDIRECTION,
(unsigned long *) &ctx->led_gpio)))
{
@@ -466,16 +467,16 @@ led_uninit (struct managerd_ctx *ctx)
strerror (errno));
}
-#if (defined CONFIG_MACH_SPK300G || defined CONFIG_MACH_SPK300)
+#if defined (CONFIG_EXTRA_LEDS)
/* Reset GPIO value of LED1&2 */
- ctx->led_gpio.gpioval.num = LED1_GPIO_NUM;
+ ctx->led_gpio.gpioval.num = CONFIG_LED1_GPIO_NUM;
if (0 > (ioctl (ctx->gpio_fd, GPIOIOC_SETVALUE,
(unsigned long *) &ctx->led_gpio)))
{
syslog (LOG_WARNING, "cannot call ioctl SETVALUE for LED1 GPIO (%s)",
strerror (errno));
}
- ctx->led_gpio.gpioval.num = LED2_GPIO_NUM;
+ ctx->led_gpio.gpioval.num = CONFIG_LED2_GPIO_NUM;
if (0 > (ioctl (ctx->gpio_fd, GPIOIOC_SETVALUE,
(unsigned long *) &ctx->led_gpio)))
{
diff --git a/cleopatre/buildroot/package/managerd/managerd.mk b/cleopatre/buildroot/package/managerd/managerd.mk
index 59a53f158e..6929d9f0e4 100644
--- a/cleopatre/buildroot/package/managerd/managerd.mk
+++ b/cleopatre/buildroot/package/managerd/managerd.mk
@@ -36,7 +36,14 @@ $(MANAGERD_DIR)/.unpacked:
touch $(MANAGERD_DIR)/.unpacked
$(MANAGERD_DIR)/.configured: $(MANAGERD_DIR)/.unpacked $(BUILDROOT_CONFIG_FILE)
- > $(MANAGERD_DIR)/.config
+ifeq (y,$(findstring y,$(BR2_TARGET_SPIDCOM_SPK300)$(BR2_TARGET_SPIDCOM_SPK300G)))
+ (echo "CONFIG_EXTRA_LEDS=y" ; \
+ echo "CONFIG_LED1_GPIO_NUM=13" ; \
+ echo "CONFIG_LED2_GPIO_NUM=12" ; \
+ ) > $(MANAGERD_DIR)/.config
+else
+ echo "# CONFIG_EXTRA_LEDS is not set" > $(MANAGERD_DIR)/.config
+endif
touch $(MANAGERD_DIR)/.configured
$(MANAGERD_DIR)/managerd: $(MANAGERD_DIR)/.configured