led-qcom: Check for LED driver
The hw_pattern attribute is driver specific. Ensure we don't apply the LED pattern to unknown drivers. Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/77
This commit is contained in:
+34
-1
@@ -18,6 +18,8 @@
|
|||||||
#define LED_REPEAT_ATTR "repeat"
|
#define LED_REPEAT_ATTR "repeat"
|
||||||
#define LED_REPEAT_INFINITY "-1"
|
#define LED_REPEAT_INFINITY "-1"
|
||||||
#define QCOM_LPG_MAX_PAUSE_MS 511
|
#define QCOM_LPG_MAX_PAUSE_MS 511
|
||||||
|
#define LED_DRIVER_PROP "DRIVER"
|
||||||
|
#define QCOM_LED_DRIVER "qcom-spmi-lpg"
|
||||||
|
|
||||||
typedef struct _FbdDevLedQcom {
|
typedef struct _FbdDevLedQcom {
|
||||||
FbdDevLed parent;
|
FbdDevLed parent;
|
||||||
@@ -27,6 +29,30 @@ typedef struct _FbdDevLedQcom {
|
|||||||
G_DEFINE_TYPE (FbdDevLedQcom, fbd_dev_led_qcom, FBD_TYPE_DEV_LED)
|
G_DEFINE_TYPE (FbdDevLedQcom, fbd_dev_led_qcom, FBD_TYPE_DEV_LED)
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fbd_dev_led_qcom_check_driver (FbdDevLedQcom *self, const char *name)
|
||||||
|
{
|
||||||
|
g_autoptr (GUdevDevice) dev = NULL;
|
||||||
|
gboolean found = FALSE;
|
||||||
|
|
||||||
|
dev = g_object_ref (fbd_dev_led_get_device (FBD_DEV_LED (self)));
|
||||||
|
do {
|
||||||
|
g_autoptr (GUdevDevice) parent = NULL;
|
||||||
|
const char *driver = g_udev_device_get_property (dev, LED_DRIVER_PROP);
|
||||||
|
|
||||||
|
if (g_strcmp0 (driver, QCOM_LED_DRIVER) == 0) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent = g_udev_device_get_parent (dev);
|
||||||
|
g_set_object (&dev, parent);
|
||||||
|
} while (dev);
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fbd_dev_led_qcom_probe (FbdDevLed *led, GError **error)
|
fbd_dev_led_qcom_probe (FbdDevLed *led, GError **error)
|
||||||
{
|
{
|
||||||
@@ -40,7 +66,14 @@ fbd_dev_led_qcom_probe (FbdDevLed *led, GError **error)
|
|||||||
if (index == NULL) {
|
if (index == NULL) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
"%s is no QCOM LED with HW support", name);
|
"%s is no LED with HW support", name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fbd_dev_led_qcom_check_driver (FBD_DEV_LED_QCOM (led), QCOM_LED_DRIVER)) {
|
||||||
|
g_set_error (error,
|
||||||
|
G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
"%s is no QCOM LED with HW support", name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user