Linux LED subsystem development
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Pavel Machek <pavel@kernel.org>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: bettyzhou@google.com, ynaffit@google.com, tkjos@google.com,
	jacek.anaszewski@gmail.com
Subject: [PATCH v2 4/5] leds: led-test: Provide test for registration with a name that is too long
Date: Thu, 15 May 2025 09:28:03 +0100	[thread overview]
Message-ID: <20250515082830.800798-5-lee@kernel.org> (raw)
In-Reply-To: <20250515082830.800798-1-lee@kernel.org>

Insist on legacy (non-DT) registration and provide 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>
---
 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.1101.gccaa498523-goog


  parent reply	other threads:[~2025-05-15  8:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15  8:27 [PATCH v2 0/5] leds: KUnit registration tests pertaining to init_data Lee Jones
2025-05-15  8:28 ` [PATCH v2 1/5] leds: led-test: Move common LED class registration code into helper function Lee Jones
2025-05-15  8:28 ` [PATCH v2 2/5] leds: led-test: Provide test for registration with missing default_label Lee Jones
2025-05-15  8:28 ` [PATCH v2 3/5] leds: led-test: Provide test for registration with missing devicename Lee Jones
2025-05-15  8:28 ` Lee Jones [this message]
2025-05-15  8:28 ` [PATCH v2 5/5] leds: led-test: Provide test for successful registration using init_data Lee Jones
2025-05-18 15:32 ` [PATCH v2 0/5] leds: KUnit registration tests pertaining to init_data Jacek Anaszewski
2025-05-19 13:33   ` Lee Jones
2025-05-21 21:26     ` Jacek Anaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250515082830.800798-5-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=bettyzhou@google.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=tkjos@google.com \
    --cc=ynaffit@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox