From: chitranshmandhaniya@gmail.com
To: hansg@kernel.org
Cc: ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, Chitransh_Mandhaniya@dell.com
Subject: [PATCH v3 1/2] platform/x86: dell-uart-backlight: extract dell_uart_bl_init() from probe
Date: Fri, 9 Oct 2026 17:56:01 +0530 [thread overview]
Message-ID: <20261009122602.56624-2-chitranshmandhaniya@gmail.com> (raw)
In-Reply-To: <20261009122602.56624-1-chitranshmandhaniya@gmail.com>
From: Chitransh Mandhaniya <Chitransh_Mandhaniya@dell.com>
Move the UART backlight initialization sequence (get_version,
set_bl_power, get_brightness and backlight device registration) out of
dell_uart_bl_serdev_probe() into a new dell_uart_bl_init() helper.
No functional change. This is a preparatory refactor so that a
follow-up patch can inspect the return value of dell_uart_bl_init()
and take an alternative code path on failure.
Tested on OptiPlex AIO 7410 35W (01KP8D) and OptiPlex AIO 7420 35W
(0914RT) -- driver behaviour unchanged, backlight probes identically.
Signed-off-by: Chitransh Mandhaniya <Chitransh_Mandhaniya@dell.com>
---
.../platform/x86/dell/dell-uart-backlight.c | 59 ++++++++++---------
1 file changed, 32 insertions(+), 27 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-uart-backlight.c b/drivers/platform/x86/dell/dell-uart-backlight.c
index f323a667dc2d..e3b7f1beda5b 100644
--- a/drivers/platform/x86/dell/dell-uart-backlight.c
+++ b/drivers/platform/x86/dell/dell-uart-backlight.c
@@ -267,40 +267,19 @@ static const struct serdev_device_ops dell_uart_bl_serdev_ops = {
.write_wakeup = serdev_device_write_wakeup,
};
-static int dell_uart_bl_serdev_probe(struct serdev_device *serdev)
+static int dell_uart_bl_init(struct device *dev, struct dell_uart_backlight *dell_bl)
{
u8 get_version[GET_CMD_LEN], resp[MAX_RESP_LEN];
struct backlight_properties props = {};
- struct dell_uart_backlight *dell_bl;
- struct device *dev = &serdev->dev;
int ret;
- dell_bl = devm_kzalloc(dev, sizeof(*dell_bl), GFP_KERNEL);
- if (!dell_bl)
- return -ENOMEM;
-
- mutex_init(&dell_bl->mutex);
- init_waitqueue_head(&dell_bl->wait_queue);
- dell_bl->dev = dev;
-
- serdev_device_set_drvdata(serdev, dell_bl);
- serdev_device_set_client_ops(serdev, &dell_uart_bl_serdev_ops);
-
- ret = devm_serdev_device_open(dev, serdev);
- if (ret)
- return dev_err_probe(dev, ret, "opening UART device\n");
-
- /* 9600 bps, no flow control, these are the default but set them to be sure */
- serdev_device_set_baudrate(serdev, 9600);
- serdev_device_set_flow_control(serdev, false);
-
get_version[0] = DELL_SOF(GET_CMD_LEN);
get_version[1] = CMD_GET_VERSION;
get_version[2] = dell_uart_checksum(get_version, 2);
ret = dell_uart_bl_command(dell_bl, get_version, GET_CMD_LEN, resp, MAX_RESP_LEN);
if (ret)
- return dev_err_probe(dev, ret, "getting firmware version\n");
+ return ret;
dev_dbg(dev, "Firmware version: %.*s\n", resp[RESP_LEN] - 3, resp + RESP_DATA);
@@ -318,13 +297,39 @@ static int dell_uart_bl_serdev_probe(struct serdev_device *serdev)
props.max_brightness = DELL_BL_MAX_BRIGHTNESS;
props.power = dell_bl->power;
- dell_bl->bl = devm_backlight_device_register(dev, "dell_uart_backlight",
- dev, dell_bl,
- &dell_uart_backlight_ops,
- &props);
+ dell_bl->bl = devm_backlight_device_register(dev, "dell_uart_backlight", dev, dell_bl,
+ &dell_uart_backlight_ops, &props);
return PTR_ERR_OR_ZERO(dell_bl->bl);
}
+static int dell_uart_bl_serdev_probe(struct serdev_device *serdev)
+{
+ struct dell_uart_backlight *dell_bl;
+ struct device *dev = &serdev->dev;
+ int ret;
+
+ dell_bl = devm_kzalloc(dev, sizeof(*dell_bl), GFP_KERNEL);
+ if (!dell_bl)
+ return -ENOMEM;
+
+ mutex_init(&dell_bl->mutex);
+ init_waitqueue_head(&dell_bl->wait_queue);
+ dell_bl->dev = dev;
+
+ serdev_device_set_drvdata(serdev, dell_bl);
+ serdev_device_set_client_ops(serdev, &dell_uart_bl_serdev_ops);
+
+ ret = devm_serdev_device_open(dev, serdev);
+ if (ret)
+ return dev_err_probe(dev, ret, "opening UART device\n");
+
+ /* 9600 bps, no flow control, these are the default but set them to be sure */
+ serdev_device_set_baudrate(serdev, 9600);
+ serdev_device_set_flow_control(serdev, false);
+
+ return dell_uart_bl_init(dev, dell_bl);
+}
+
static struct serdev_device_driver dell_uart_bl_serdev_driver = {
.probe = dell_uart_bl_serdev_probe,
.driver = {
--
2.43.0
next prev parent reply other threads:[~2026-10-09 12:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 14:16 [PATCH] platform/x86: dell-uart-backlight: fall back to PCH PWM on UART timeout chitranshmandhaniya
2026-10-08 14:30 ` Ilpo Järvinen
2026-10-09 7:24 ` [PATCH v2] " chitranshmandhaniya
2026-10-09 10:48 ` Ilpo Järvinen
2026-10-09 12:26 ` [PATCH v3 0/2] " chitranshmandhaniya
2026-10-09 12:26 ` chitranshmandhaniya [this message]
2026-10-09 12:26 ` [PATCH v3 2/2] " chitranshmandhaniya
2026-10-09 23:46 ` [PATCH v2] " kernel test robot
2026-10-10 10:20 ` [PATCH v4 0/2] " chitranshmandhaniya
2026-10-10 10:20 ` [PATCH v4 1/2] platform/x86: dell-uart-backlight: extract dell_uart_bl_init() from probe chitranshmandhaniya
2026-10-10 10:20 ` [PATCH v4 2/2] platform/x86: dell-uart-backlight: fall back to PCH PWM on UART timeout chitranshmandhaniya
2026-10-10 11:41 ` [PATCH v4 0/2] " Hans de Goede
2026-10-10 12:48 ` [PATCH v5] ACPI: video: force native backlight on Dell OptiPlex AIO 7410 35W chitranshmandhaniya
2026-10-12 14:54 ` Hans de Goede
2026-10-12 18:11 ` Rafael J. Wysocki (Intel)
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=20261009122602.56624-2-chitranshmandhaniya@gmail.com \
--to=chitranshmandhaniya@gmail.com \
--cc=Chitransh_Mandhaniya@dell.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.