@@ -1479,6 +1479,9 @@ static ssize_t show_blink_behavior(struct device *dev,
if (led->api_rev == LED_API_NUC6)
return nuc6_show_blink_behavior(dev, attr, buf);
+ if (led->indicator != LED_IND_SOFTWARE)
+ return -EINVAL;
+
return offset_show_blink_behavior(dev, attr, 0, buf);
}
@@ -1492,6 +1495,9 @@ static ssize_t store_blink_behavior(struct device *dev,
if (led->api_rev == LED_API_NUC6)
return nuc6_store_blink_behavior(dev, attr, buf, len);
+ if (led->indicator != LED_IND_SOFTWARE)
+ return -EINVAL;
+
return offset_store_blink_behavior(dev, attr, 0, buf, len);
}
@@ -1596,6 +1602,9 @@ static ssize_t show_blink_frequency(struct device *dev,
if (led->api_rev == LED_API_NUC6)
return nuc6_show_blink_frequency(dev, attr, buf);
+ if (led->indicator != LED_IND_SOFTWARE)
+ return -EINVAL;
+
return offset_show_blink_frequency(dev, attr, 0, buf);
}
@@ -1609,26 +1618,12 @@ static ssize_t store_blink_frequency(struct device *dev,
if (led->api_rev == LED_API_NUC6)
return nuc6_store_blink_frequency(dev, attr, buf, len);
+ if (led->indicator != LED_IND_SOFTWARE)
+ return -EINVAL;
+
return offset_store_blink_frequency(dev, attr, 0, buf, len);
}
-static umode_t nuc_wmi_led_blink_is_visible(struct kobject *kobj,
- struct attribute *attr, int idx)
-{
- struct device *dev = kobj_to_dev(kobj);
- struct led_classdev *cdev = dev_get_drvdata(dev);
- struct nuc_nmi_led *led = container_of(cdev, struct nuc_nmi_led, cdev);
- umode_t mode = attr->mode;
-
- if (led->api_rev == LED_API_NUC6)
- return mode;
-
- if (led->id == LED_IND_SOFTWARE)
- return mode;
-
- return 0;
-}
-
/* HDD activity behavior */
static ssize_t show_hdd_default(struct device *dev,
struct device_attribute *attr,
@@ -1788,7 +1783,6 @@ static struct attribute *nuc_wmi_led_blink_behavior_attr[] = {
};
static const struct attribute_group nuc_wmi_led_blink_attribute_group = {
- .is_visible = nuc_wmi_led_blink_is_visible,
.attrs = nuc_wmi_led_blink_behavior_attr,
};
The is_visible logic for it is plain wrong: 1. it is used only during devnode creation; 2. it was using the wrong field (id, instead of indicator). Fix it. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> --- drivers/leds/leds-nuc.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)