* [PATCH v3 2/5] leds: led-test: Provide test for registration with missing default_label
2025-05-22 8:06 [PATCH v3 1/5] leds: led-test: Move common LED class registration code into helper function Lee Jones
@ 2025-05-22 8:06 ` Lee Jones
2025-05-22 8:06 ` [PATCH v3 3/5] leds: led-test: Provide test for registration with missing devicename Lee Jones
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2025-05-22 8:06 UTC (permalink / raw)
To: lee, Pavel Machek, linux-leds, linux-kernel
Cc: bettyzhou, ynaffit, tkjos, jacek.anaszewski
Insist on non-DT registration with init_data, but omit the
default_label, which should fail with an invalid argument error.
Signed-off-by: Lee Jones <lee@kernel.org>
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
---
drivers/leds/led-test.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/leds/led-test.c b/drivers/leds/led-test.c
index 0f152fb12dfb..760c393f5c5d 100644
--- a/drivers/leds/led-test.c
+++ b/drivers/leds/led-test.c
@@ -93,9 +93,25 @@ static void led_test_class_add_lookup_and_get(struct kunit *test)
led_remove_lookup(&lookup);
}
+static void led_test_class_init_data_missing_default_label(struct kunit *test)
+{
+ struct led_test_ddata *ddata = test->priv;
+ struct led_classdev *cdev = &ddata->cdev;
+ struct device *dev = ddata->dev;
+ int ret;
+
+ struct led_init_data init_data = {
+ .devicename = "led-test-devicename",
+ };
+
+ ret = devm_led_classdev_register_ext(dev, cdev, &init_data);
+ KUNIT_EXPECT_EQ(test, ret, -EINVAL);
+}
+
static struct kunit_case led_test_cases[] = {
KUNIT_CASE(led_test_class_register),
KUNIT_CASE(led_test_class_add_lookup_and_get),
+ KUNIT_CASE(led_test_class_init_data_missing_default_label),
{ }
};
--
2.49.0.1143.g0be31eac6b-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/5] leds: led-test: Provide test for registration with missing devicename
2025-05-22 8:06 [PATCH v3 1/5] leds: led-test: Move common LED class registration code into helper function Lee Jones
2025-05-22 8:06 ` [PATCH v3 2/5] leds: led-test: Provide test for registration with missing default_label Lee Jones
@ 2025-05-22 8:06 ` Lee Jones
2025-05-22 8:06 ` [PATCH v3 4/5] leds: led-test: Provide test for registration with a name that is too long Lee Jones
2025-05-22 8:06 ` [PATCH v3 5/5] leds: led-test: Provide test for successful registration using init_data Lee Jones
3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2025-05-22 8:06 UTC (permalink / raw)
To: lee, Pavel Machek, linux-leds, linux-kernel
Cc: bettyzhou, ynaffit, tkjos, jacek.anaszewski
Insist on non-DT registration with init_data, but omit the devicename,
which should fail with an invalid argument error.
Signed-off-by: Lee Jones <lee@kernel.org>
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
---
drivers/leds/led-test.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/leds/led-test.c b/drivers/leds/led-test.c
index 760c393f5c5d..d378c905546b 100644
--- a/drivers/leds/led-test.c
+++ b/drivers/leds/led-test.c
@@ -108,10 +108,26 @@ static void led_test_class_init_data_missing_default_label(struct kunit *test)
KUNIT_EXPECT_EQ(test, ret, -EINVAL);
}
+static void led_test_class_init_data_missing_devicename(struct kunit *test)
+{
+ struct led_test_ddata *ddata = test->priv;
+ struct led_classdev *cdev = &ddata->cdev;
+ struct device *dev = ddata->dev;
+ int ret;
+
+ struct led_init_data init_data = {
+ .default_label = "led-test-label",
+ };
+
+ ret = devm_led_classdev_register_ext(dev, cdev, &init_data);
+ KUNIT_EXPECT_EQ(test, ret, -EINVAL);
+}
+
static struct kunit_case led_test_cases[] = {
KUNIT_CASE(led_test_class_register),
KUNIT_CASE(led_test_class_add_lookup_and_get),
KUNIT_CASE(led_test_class_init_data_missing_default_label),
+ KUNIT_CASE(led_test_class_init_data_missing_devicename),
{ }
};
--
2.49.0.1143.g0be31eac6b-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 4/5] leds: led-test: Provide test for registration with a name that is too long
2025-05-22 8:06 [PATCH v3 1/5] leds: led-test: Move common LED class registration code into helper function Lee Jones
2025-05-22 8:06 ` [PATCH v3 2/5] leds: led-test: Provide test for registration with missing default_label Lee Jones
2025-05-22 8:06 ` [PATCH v3 3/5] leds: led-test: Provide test for registration with missing devicename Lee Jones
@ 2025-05-22 8:06 ` Lee Jones
2025-05-22 8:06 ` [PATCH v3 5/5] leds: led-test: Provide test for successful registration using init_data Lee Jones
3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2025-05-22 8:06 UTC (permalink / raw)
To: lee, Pavel Machek, linux-leds, linux-kernel
Cc: bettyzhou, ynaffit, tkjos, jacek.anaszewski
Insist on non-DT registration with init_data whilst providing a
default_label and devicename that when concatenated together results in
a device name that is unacceptably long.
Signed-off-by: Lee Jones <lee@kernel.org>
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
---
drivers/leds/led-test.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/leds/led-test.c b/drivers/leds/led-test.c
index d378c905546b..d5017c6dca08 100644
--- a/drivers/leds/led-test.c
+++ b/drivers/leds/led-test.c
@@ -123,11 +123,28 @@ static void led_test_class_init_data_missing_devicename(struct kunit *test)
KUNIT_EXPECT_EQ(test, ret, -EINVAL);
}
+static void led_test_class_init_data_name_too_long(struct kunit *test)
+{
+ struct led_test_ddata *ddata = test->priv;
+ struct led_classdev *cdev = &ddata->cdev;
+ struct device *dev = ddata->dev;
+ int ret;
+
+ struct led_init_data init_data = {
+ .devicename = "led-test-devicename-very-long-names-fail",
+ .default_label = "led-test-label-also-very-long-names-fail",
+ };
+
+ ret = devm_led_classdev_register_ext(dev, cdev, &init_data);
+ KUNIT_EXPECT_EQ(test, ret, -E2BIG);
+}
+
static struct kunit_case led_test_cases[] = {
KUNIT_CASE(led_test_class_register),
KUNIT_CASE(led_test_class_add_lookup_and_get),
KUNIT_CASE(led_test_class_init_data_missing_default_label),
KUNIT_CASE(led_test_class_init_data_missing_devicename),
+ KUNIT_CASE(led_test_class_init_data_name_too_long),
{ }
};
--
2.49.0.1143.g0be31eac6b-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 5/5] leds: led-test: Provide test for successful registration using init_data
2025-05-22 8:06 [PATCH v3 1/5] leds: led-test: Move common LED class registration code into helper function Lee Jones
` (2 preceding siblings ...)
2025-05-22 8:06 ` [PATCH v3 4/5] leds: led-test: Provide test for registration with a name that is too long Lee Jones
@ 2025-05-22 8:06 ` Lee Jones
3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2025-05-22 8:06 UTC (permalink / raw)
To: lee, Pavel Machek, linux-leds, linux-kernel
Cc: bettyzhou, ynaffit, tkjos, jacek.anaszewski
This time both the default_label and devicename are provided such that
when concatenated together result in a device name that is acceptable.
In this case registration should succeed.
Signed-off-by: Lee Jones <lee@kernel.org>
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
---
drivers/leds/led-test.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/leds/led-test.c b/drivers/leds/led-test.c
index d5017c6dca08..9bdebbe04462 100644
--- a/drivers/leds/led-test.c
+++ b/drivers/leds/led-test.c
@@ -139,12 +139,29 @@ static void led_test_class_init_data_name_too_long(struct kunit *test)
KUNIT_EXPECT_EQ(test, ret, -E2BIG);
}
+static void led_test_class_init_data(struct kunit *test)
+{
+ struct led_test_ddata *ddata = test->priv;
+ struct led_classdev *cdev = &ddata->cdev;
+ struct device *dev = ddata->dev;
+ int ret;
+
+ struct led_init_data init_data = {
+ .devicename = "led-test-devicename",
+ .default_label = "led-test-label",
+ };
+
+ ret = devm_led_classdev_register_ext(dev, cdev, &init_data);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+}
+
static struct kunit_case led_test_cases[] = {
KUNIT_CASE(led_test_class_register),
KUNIT_CASE(led_test_class_add_lookup_and_get),
KUNIT_CASE(led_test_class_init_data_missing_default_label),
KUNIT_CASE(led_test_class_init_data_missing_devicename),
KUNIT_CASE(led_test_class_init_data_name_too_long),
+ KUNIT_CASE(led_test_class_init_data),
{ }
};
--
2.49.0.1143.g0be31eac6b-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread