Skip to content

Commit 4501da8

Browse files
committed
drivers: led: rename IS31FL3194 to 9x
In preparation to allow this driver to support more than one IS31FL319x object such as ...97, rename the source file and the functions to make them more generic. I also changed the enumeration/creation of object to generate the right names for the current 94 objects Still have not renamed the Kconfig file yet as was having issues with it not building... Did not load the .c file Signed-off-by: Kurt Eckhardt <@example.com>
1 parent e868e01 commit 4501da8

File tree

7 files changed

+49
-47
lines changed

7 files changed

+49
-47
lines changed

drivers/led/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ zephyr_library()
66

77
# zephyr-keep-sorted-start
88
zephyr_library_sources_ifdef(CONFIG_HT16K33 ht16k33.c)
9-
zephyr_library_sources_ifdef(CONFIG_IS31FL3194 is31fl3194.c)
9+
zephyr_library_sources_ifdef(CONFIG_IS31FL3194 is31fl319x.c)
1010
zephyr_library_sources_ifdef(CONFIG_IS31FL3216A is31fl3216a.c)
1111
zephyr_library_sources_ifdef(CONFIG_IS31FL3733 is31fl3733.c)
1212
zephyr_library_sources_ifdef(CONFIG_LEDS_GROUP_MULTICOLOR leds_group_multicolor.c)

drivers/led/is31fl3194.c renamed to drivers/led/is31fl319x.c

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#define DT_DRV_COMPAT issi_is31fl3194
87

98
/**
109
* @file
@@ -21,7 +20,7 @@
2120

2221
#include <zephyr/dt-bindings/led/led.h>
2322

24-
LOG_MODULE_REGISTER(is31fl3194, CONFIG_LED_LOG_LEVEL);
23+
LOG_MODULE_REGISTER(is31fl319x, CONFIG_LED_LOG_LEVEL);
2524

2625
#define IS31FL3194_PROD_ID_REG 0x00
2726
#define IS31FL3194_CONF_REG 0x01
@@ -43,14 +42,14 @@ static const uint8_t led_channels[] = {
4342
IS31FL3194_OUT3_REG
4443
};
4544

46-
struct is31fl3194_config {
45+
struct is31fl319x_config {
4746
struct i2c_dt_spec bus;
4847
uint8_t num_leds;
4948
const struct led_info *led_infos;
5049
const uint8_t *current_limits;
5150
};
5251

53-
static const struct led_info *is31fl3194_led_to_info(const struct is31fl3194_config *config,
52+
static const struct led_info *is31fl319x_led_to_info(const struct is31fl319x_config *config,
5453
uint32_t led)
5554
{
5655
if (led < config->num_leds) {
@@ -60,12 +59,12 @@ static const struct led_info *is31fl3194_led_to_info(const struct is31fl3194_con
6059
return NULL;
6160
}
6261

63-
static int is31fl3194_get_info(const struct device *dev,
62+
static int is31fl319x_get_info(const struct device *dev,
6463
uint32_t led,
6564
const struct led_info **info_out)
6665
{
67-
const struct is31fl3194_config *config = dev->config;
68-
const struct led_info *info = is31fl3194_led_to_info(config, led);
66+
const struct is31fl319x_config *config = dev->config;
67+
const struct led_info *info = is31fl319x_led_to_info(config, led);
6968

7069
if (info == NULL) {
7170
return -EINVAL;
@@ -75,11 +74,11 @@ static int is31fl3194_get_info(const struct device *dev,
7574
return 0;
7675
}
7776

78-
static int is31fl3194_set_color(const struct device *dev, uint32_t led, uint8_t num_colors,
77+
static int is31fl319x_set_color(const struct device *dev, uint32_t led, uint8_t num_colors,
7978
const uint8_t *color)
8079
{
81-
const struct is31fl3194_config *config = dev->config;
82-
const struct led_info *info = is31fl3194_led_to_info(config, led);
80+
const struct is31fl319x_config *config = dev->config;
81+
const struct led_info *info = is31fl319x_led_to_info(config, led);
8382
int ret;
8483

8584
if (info == NULL) {
@@ -108,7 +107,7 @@ static int is31fl3194_set_color(const struct device *dev, uint32_t led, uint8_t
108107
value = color[2];
109108
break;
110109
default:
111-
/* unreachable: mapping already tested in is31fl3194_check_config */
110+
/* unreachable: mapping already tested in is31fl319x_check_config */
112111
return -EINVAL;
113112
}
114113

@@ -131,10 +130,10 @@ static int is31fl3194_set_color(const struct device *dev, uint32_t led, uint8_t
131130
return ret;
132131
}
133132

134-
static int is31fl3194_set_brightness(const struct device *dev, uint32_t led, uint8_t value)
133+
static int is31fl319x_set_brightness(const struct device *dev, uint32_t led, uint8_t value)
135134
{
136-
const struct is31fl3194_config *config = dev->config;
137-
const struct led_info *info = is31fl3194_led_to_info(config, led);
135+
const struct is31fl319x_config *config = dev->config;
136+
const struct led_info *info = is31fl319x_led_to_info(config, led);
138137
int ret = 0;
139138

140139
if (info == NULL) {
@@ -166,7 +165,7 @@ static int is31fl3194_set_brightness(const struct device *dev, uint32_t led, uin
166165
* Counts red, green, blue channels; returns true if color_id is valid
167166
* and no more than one channel maps to the same color
168167
*/
169-
static bool is31fl3194_count_colors(const struct device *dev,
168+
static bool is31fl319x_count_colors(const struct device *dev,
170169
uint8_t color_id, uint8_t *rgb_counts)
171170
{
172171
bool ret = false;
@@ -191,9 +190,9 @@ static bool is31fl3194_count_colors(const struct device *dev,
191190
return ret;
192191
}
193192

194-
static int is31fl3194_check_config(const struct device *dev)
193+
static int is31fl319x_check_config(const struct device *dev)
195194
{
196-
const struct is31fl3194_config *config = dev->config;
195+
const struct is31fl319x_config *config = dev->config;
197196
const struct led_info *info;
198197
uint8_t rgb_counts[3] = { 0 };
199198
uint8_t i;
@@ -211,7 +210,7 @@ static int is31fl3194_check_config(const struct device *dev)
211210
}
212211

213212
for (i = 0; i < 3; i++) {
214-
if (!is31fl3194_count_colors(dev, info->color_mapping[i], rgb_counts)) {
213+
if (!is31fl319x_count_colors(dev, info->color_mapping[i], rgb_counts)) {
215214
return -EINVAL;
216215
}
217216

@@ -229,7 +228,7 @@ static int is31fl3194_check_config(const struct device *dev)
229228
return -EINVAL;
230229
}
231230

232-
if (!is31fl3194_count_colors(dev, info->color_mapping[0], rgb_counts)) {
231+
if (!is31fl319x_count_colors(dev, info->color_mapping[0], rgb_counts)) {
233232
return -EINVAL;
234233
}
235234
}
@@ -243,15 +242,15 @@ static int is31fl3194_check_config(const struct device *dev)
243242
return 0;
244243
}
245244

246-
static int is31fl3194_init(const struct device *dev)
245+
static int is31fl319x_init(const struct device *dev)
247246
{
248-
const struct is31fl3194_config *config = dev->config;
247+
const struct is31fl319x_config *config = dev->config;
249248
const struct led_info *info = NULL;
250249
int i, ret;
251250
uint8_t prod_id, band;
252251
uint8_t current_reg = 0;
253252

254-
ret = is31fl3194_check_config(dev);
253+
ret = is31fl319x_check_config(dev);
255254
if (ret != 0) {
256255
return ret;
257256
}
@@ -299,10 +298,10 @@ static int is31fl3194_init(const struct device *dev)
299298
return i2c_reg_write_byte_dt(&config->bus, IS31FL3194_CONF_REG, IS31FL3194_CONF_ENABLE);
300299
}
301300

302-
static DEVICE_API(led, is31fl3194_led_api) = {
303-
.set_brightness = is31fl3194_set_brightness,
304-
.get_info = is31fl3194_get_info,
305-
.set_color = is31fl3194_set_color,
301+
static DEVICE_API(led, is31fl319x_led_api) = {
302+
.set_brightness = is31fl319x_set_brightness,
303+
.get_info = is31fl319x_get_info,
304+
.set_color = is31fl319x_set_color,
306305
};
307306

308307
#define COLOR_MAPPING(led_node_id) \
@@ -319,25 +318,28 @@ static DEVICE_API(led, is31fl3194_led_api) = {
319318
#define LED_CURRENT(led_node_id) \
320319
DT_PROP(led_node_id, current_limit),
321320

322-
#define IS31FL3194_DEFINE(id) \
321+
#define IS31FL319X_DEVICE(n, id) \
322+
\
323+
DT_INST_FOREACH_CHILD(n, COLOR_MAPPING) \
323324
\
324-
DT_INST_FOREACH_CHILD(id, COLOR_MAPPING) \
325+
static const struct led_info is31fl319##id##_leds_##n[] = \
326+
{ DT_INST_FOREACH_CHILD(n, LED_INFO) }; \
325327
\
326-
static const struct led_info is31fl3194_leds_##id[] = \
327-
{ DT_INST_FOREACH_CHILD(id, LED_INFO) }; \
328-
static const uint8_t is31fl3194_currents_##id[] = \
329-
{ DT_INST_FOREACH_CHILD(id, LED_CURRENT) }; \
330-
BUILD_ASSERT(ARRAY_SIZE(is31fl3194_leds_##id) > 0, \
331-
"No LEDs defined for " #id); \
328+
static const uint8_t is31fl319##id##_currents_##n[] = \
329+
{ DT_INST_FOREACH_CHILD(n, LED_CURRENT) }; \
330+
BUILD_ASSERT(ARRAY_SIZE(is31fl319##id##_leds_##n) > 0, \
331+
"No LEDs defined for " #n); \
332332
\
333-
static const struct is31fl3194_config is31fl3194_config_##id = { \
334-
.bus = I2C_DT_SPEC_INST_GET(id), \
335-
.num_leds = ARRAY_SIZE(is31fl3194_leds_##id), \
336-
.led_infos = is31fl3194_leds_##id, \
337-
.current_limits = is31fl3194_currents_##id, \
333+
static const struct is31fl319x_config is31fl319##id##_config_##n = { \
334+
.bus = I2C_DT_SPEC_INST_GET(n), \
335+
.num_leds = ARRAY_SIZE(is31fl319##id##_leds_##n), \
336+
.led_infos = is31fl319##id##_leds_##n, \
337+
.current_limits = is31fl319##id##_currents_##n, \
338338
}; \
339-
DEVICE_DT_INST_DEFINE(id, &is31fl3194_init, NULL, NULL, \
340-
&is31fl3194_config_##id, POST_KERNEL, \
341-
CONFIG_LED_INIT_PRIORITY, &is31fl3194_led_api);
339+
DEVICE_DT_INST_DEFINE(n, &is31fl319x_init, NULL, NULL, \
340+
&is31fl319##id##_config_##n, POST_KERNEL, \
341+
CONFIG_LED_INIT_PRIORITY, &is31fl319x_led_api);
342342

343-
DT_INST_FOREACH_STATUS_OKAY(IS31FL3194_DEFINE)
343+
#undef DT_DRV_COMPAT
344+
#define DT_DRV_COMPAT issi_is31fl3194
345+
DT_INST_FOREACH_STATUS_OKAY_VARGS(IS31FL319X_DEVICE, 4)
File renamed without changes.
File renamed without changes.
File renamed without changes.

samples/drivers/led/is31fl3194/sample.yaml renamed to samples/drivers/led/is31fl319x/sample.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
sample:
2-
description: Demonstration of the IS31FL3194 LED driver
3-
name: is31fl3194 sample
2+
description: Demonstration of the IS31FL319x LED driver
3+
name: is31fl319x sample
44
tests:
5-
sample.drivers.led.is31fl3194:
5+
sample.drivers.led.is31fl319x:
66
filter: dt_compat_enabled("issi,is31fl3194")
77
tags: LED
88
depends_on: i2c
File renamed without changes.

0 commit comments

Comments
 (0)