drivers: led: lp5562: Allow support for multiple instances
Driver originally only allowed one instance to be created. Updated to allow for multiple. Signed-off-by: Jamal Davis <jamaldavis@fb.com>
This commit is contained in:
parent
b937f0315b
commit
54c311e5b3
1 changed files with 13 additions and 9 deletions
|
@ -938,12 +938,6 @@ static int lp5562_led_init(const struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct lp5562_config lp5562_led_config = {
|
|
||||||
.bus = I2C_DT_SPEC_INST_GET(0),
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct lp5562_data lp5562_led_data;
|
|
||||||
|
|
||||||
static const struct led_driver_api lp5562_led_api = {
|
static const struct led_driver_api lp5562_led_api = {
|
||||||
.blink = lp5562_led_blink,
|
.blink = lp5562_led_blink,
|
||||||
.set_brightness = lp5562_led_set_brightness,
|
.set_brightness = lp5562_led_set_brightness,
|
||||||
|
@ -951,6 +945,16 @@ static const struct led_driver_api lp5562_led_api = {
|
||||||
.off = lp5562_led_off,
|
.off = lp5562_led_off,
|
||||||
};
|
};
|
||||||
|
|
||||||
DEVICE_DT_INST_DEFINE(0, &lp5562_led_init, NULL, &lp5562_led_data,
|
#define LP5562_DEFINE(id) \
|
||||||
&lp5562_led_config, POST_KERNEL, CONFIG_LED_INIT_PRIORITY,
|
static const struct lp5562_config lp5562_config_##id = { \
|
||||||
&lp5562_led_api);
|
.bus = I2C_DT_SPEC_INST_GET(id), \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
struct lp5562_data lp5562_data_##id; \
|
||||||
|
DEVICE_DT_INST_DEFINE(id, &lp5562_led_init, NULL, \
|
||||||
|
&lp5562_data_##id, \
|
||||||
|
&lp5562_config_##id, POST_KERNEL, \
|
||||||
|
CONFIG_LED_INIT_PRIORITY, \
|
||||||
|
&lp5562_led_api); \
|
||||||
|
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY(LP5562_DEFINE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue