Move LED device to separate file

We separate out the led as different LED types have different
ways to set patterns, etc
This commit is contained in:
Guido Günther
2023-02-10 15:15:12 +00:00
committed by Guido Gunther
parent 253d178cfc
commit 5fc0372b45
5 changed files with 69 additions and 36 deletions
+34
View File
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2020 Purism SPC
* SPDX-License-Identifier: GPL-3.0+
* Author: Guido Günther <agx@sigxcpu.org>
*
* See Documentation/ABI/testing/sysfs-class-led-trigger-pattern
*/
#define G_LOG_DOMAIN "fbd-dev-led"
#include "fbd-dev-led.h"
#include "fbd-udev.h"
#define LED_BRIGHTNESS_ATTR "brightness"
void
fbd_dev_led_free (FbdDevLed *led)
{
g_object_unref (led->dev);
g_free (led);
}
gboolean
fbd_dev_led_set_brightness (FbdDevLed *led, guint brightness)
{
g_autoptr (GError) err = NULL;
if (!fbd_udev_set_sysfs_path_attr_as_int (led->dev, LED_BRIGHTNESS_ATTR, brightness, &err)) {
g_warning ("Failed to setup brightness: %s", err->message);
return FALSE;
}
return TRUE;
}