Skip to content

Commit 7a4f471

Browse files
thedjnKhenrikbrixandersen
authored andcommitted
drivers: led_strip: Make update channels function optional
Makes the update channels function optional, this is only implemented in one driver so can be safely omitted from most drivers Signed-off-by: Jamie McCrae <spam@helper3000.net>
1 parent 50b7d61 commit 7a4f471

File tree

7 files changed

+7
-54
lines changed

7 files changed

+7
-54
lines changed

drivers/led_strip/apa102.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ static int apa102_update_rgb(const struct device *dev, struct led_rgb *pixels,
7474
return apa102_update(dev, pixels, sizeof(struct led_rgb) * count);
7575
}
7676

77-
static int apa102_update_channels(const struct device *dev, uint8_t *channels,
78-
size_t num_channels)
79-
{
80-
/* Not implemented */
81-
return -EINVAL;
82-
}
83-
8477
static size_t apa102_length(const struct device *dev)
8578
{
8679
const struct apa102_config *config = dev->config;
@@ -101,7 +94,6 @@ static int apa102_init(const struct device *dev)
10194

10295
static const struct led_strip_driver_api apa102_api = {
10396
.update_rgb = apa102_update_rgb,
104-
.update_channels = apa102_update_channels,
10597
.length = apa102_length,
10698
};
10799

drivers/led_strip/tlc5971.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,6 @@ static int tlc5971_update_rgb(const struct device *dev, struct led_rgb *pixels,
253253
return tlc5971_transmit_data(dev, num_pixels);
254254
}
255255

256-
static int tlc5971_update_channels(const struct device *dev, uint8_t *channels, size_t num_channels)
257-
{
258-
ARG_UNUSED(dev);
259-
ARG_UNUSED(channels);
260-
ARG_UNUSED(num_channels);
261-
262-
return -ENOTSUP;
263-
}
264-
265256
static size_t tlc5971_length(const struct device *dev)
266257
{
267258
const struct tlc5971_config *cfg = dev->config;
@@ -333,7 +324,6 @@ static int tlc5971_init(const struct device *dev)
333324

334325
static const struct led_strip_driver_api tlc5971_api = {
335326
.update_rgb = tlc5971_update_rgb,
336-
.update_channels = tlc5971_update_channels,
337327
.length = tlc5971_length,
338328
};
339329

drivers/led_strip/ws2812_gpio.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,6 @@ static int ws2812_gpio_update_rgb(const struct device *dev,
180180
return send_buf(dev, (uint8_t *)pixels, num_pixels * config->num_colors);
181181
}
182182

183-
static int ws2812_gpio_update_channels(const struct device *dev,
184-
uint8_t *channels,
185-
size_t num_channels)
186-
{
187-
LOG_ERR("update_channels not implemented");
188-
return -ENOTSUP;
189-
}
190-
191183
static size_t ws2812_gpio_length(const struct device *dev)
192184
{
193185
const struct ws2812_gpio_cfg *config = dev->config;
@@ -197,7 +189,6 @@ static size_t ws2812_gpio_length(const struct device *dev)
197189

198190
static const struct led_strip_driver_api ws2812_gpio_api = {
199191
.update_rgb = ws2812_gpio_update_rgb,
200-
.update_channels = ws2812_gpio_update_channels,
201192
.length = ws2812_gpio_length,
202193
};
203194

drivers/led_strip/ws2812_i2s.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,6 @@ static int ws2812_strip_update_rgb(const struct device *dev, struct led_rgb *pix
164164
return ret;
165165
}
166166

167-
static int ws2812_strip_update_channels(const struct device *dev, uint8_t *channels,
168-
size_t num_channels)
169-
{
170-
LOG_ERR("update_channels not implemented");
171-
return -ENOTSUP;
172-
}
173-
174167
static size_t ws2812_strip_length(const struct device *dev)
175168
{
176169
const struct ws2812_i2s_cfg *cfg = dev->config;
@@ -225,7 +218,6 @@ static int ws2812_i2s_init(const struct device *dev)
225218

226219
static const struct led_strip_driver_api ws2812_i2s_api = {
227220
.update_rgb = ws2812_strip_update_rgb,
228-
.update_channels = ws2812_strip_update_channels,
229221
.length = ws2812_strip_length,
230222
};
231223

drivers/led_strip/ws2812_rpi_pico_pio.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ static int ws2812_led_strip_update_rgb(const struct device *dev, struct led_rgb
109109
return 0;
110110
}
111111

112-
static int ws2812_led_strip_update_channels(const struct device *dev, uint8_t *channels,
113-
size_t num_channels)
114-
{
115-
LOG_DBG("update_channels not implemented");
116-
return -ENOTSUP;
117-
}
118-
119112
static size_t ws2812_led_strip_length(const struct device *dev)
120113
{
121114
const struct ws2812_led_strip_config *config = dev->config;
@@ -125,7 +118,6 @@ static size_t ws2812_led_strip_length(const struct device *dev)
125118

126119
static const struct led_strip_driver_api ws2812_led_strip_api = {
127120
.update_rgb = ws2812_led_strip_update_rgb,
128-
.update_channels = ws2812_led_strip_update_channels,
129121
.length = ws2812_led_strip_length,
130122
};
131123

drivers/led_strip/ws2812_spi.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ static int ws2812_strip_update_rgb(const struct device *dev,
134134
return rc;
135135
}
136136

137-
static int ws2812_strip_update_channels(const struct device *dev,
138-
uint8_t *channels,
139-
size_t num_channels)
140-
{
141-
LOG_ERR("update_channels not implemented");
142-
return -ENOTSUP;
143-
}
144-
145137
static size_t ws2812_strip_length(const struct device *dev)
146138
{
147139
const struct ws2812_spi_cfg *cfg = dev_cfg(dev);
@@ -179,7 +171,6 @@ static int ws2812_spi_init(const struct device *dev)
179171

180172
static const struct led_strip_driver_api ws2812_spi_api = {
181173
.update_rgb = ws2812_strip_update_rgb,
182-
.update_channels = ws2812_strip_update_channels,
183174
.length = ws2812_strip_length,
184175
};
185176

include/zephyr/drivers/led_strip.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static inline int led_strip_update_rgb(const struct device *dev,
125125
}
126126

127127
/**
128-
* @brief Function to update an LED strip with the given channel array
128+
* @brief Optional function to update an LED strip with the given channel array
129129
* (each channel byte corresponding to an individually addressable color
130130
* channel or LED. Channels are updated linearly in strip order.
131131
*
@@ -134,7 +134,8 @@ static inline int led_strip_update_rgb(const struct device *dev,
134134
* @param num_channels Length of channels array.
135135
*
136136
* @retval 0 on success.
137-
* @retval -errno negative errno code on failure.
137+
* @retval -ENOSYS if not implemented.
138+
* @retval -errno negative errno code on other failure.
138139
*
139140
* @warning This routine may overwrite @a channels.
140141
*/
@@ -145,6 +146,10 @@ static inline int led_strip_update_channels(const struct device *dev,
145146
const struct led_strip_driver_api *api =
146147
(const struct led_strip_driver_api *)dev->api;
147148

149+
if (api->update_channels == NULL) {
150+
return -ENOSYS;
151+
}
152+
148153
return api->update_channels(dev, channels, num_channels);
149154
}
150155

0 commit comments

Comments
 (0)