
3 Jul
2024
3 Jul
'24
1:27 p.m.
Mikhail Kshevetskiy mikhail.kshevetskiy@iopsys.eu writes:
+static int led_sw_set_period(struct udevice *dev, int period_ms) +{
- struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
- struct cyclic_info *cyclic = uc_plat->cyclic;
- struct led_ops *ops = led_get_ops(dev);
- char cyclic_name[64];
- int half_period_us;
- uc_plat->sw_blink_state = LED_SW_BLINK_ST_NONE;
- ops->set_state(dev, LEDST_OFF);
- half_period_us = period_ms * 1000 / 2;
- if (cyclic) {
cyclic->delay_us = half_period_us;
cyclic->start_time_us = timer_get_us();
- } else {
snprintf(cyclic_name, sizeof(cyclic_name),
"led_sw_blink_%s", uc_plat->label);
cyclic = cyclic_register(led_sw_blink, half_period_us,
cyclic_name, dev);
if (!cyclic) {
log_err("Registering of blinking function for %s failed\n",
uc_plat->label);
return -ENOMEM;
}
uc_plat->cyclic = cyclic;
- }
You need to be aware of the API change that is by now in master, see https://lore.kernel.org/u-boot/20240521084652.1726460-1-rasmus.villemoes@pre... and in particular commits 3a11eada38e and 008c4b3c3115. The latter you'll find soon enough because this won't build.
The former is a bit more subtle and would silently break here (as passing an auto array is no longer allowed) - consider whether you really need the led_sw_blink_ to be part of the name, or if uc_plat->label itself isn't descriptive enough.
Rasmus