From nobody Thu Oct 2 09:16:49 2025 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C4412F7AAF for ; Thu, 18 Sep 2025 12:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197621; cv=none; b=TwG2zGZxjiOjyGBaUdwALGZ67+HGDVoOSxXGRSUP6JCxdFNV9pMBRKFb86QCLNT/NcRTADy5Tq971fTxm2xXmXRauGBrLxXzHJ01vRPehlthkKglkcWI/13KOdU+7lBe+wHpKvy+Mk/LdoryCnIJsslpRarX7r6S172mVXGKJGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197621; c=relaxed/simple; bh=kbkpoL2Akt6x+oN3uvf+R6ZOkbX3aDRtPDE5lFHae1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CjoIfdLOF3pUpzv4Zbidc8xw0C/B71QhyFcrSkqd4oITH5SDrpUtPkN0NzQXHYzp6kakbR/roRRCMkdF0sEt7IpYKH6nCaxW51e4UJxSq4UdMR8+fuEsnEOXc2t5kNvBw/UGsbzYiGFrSyobuovoGUST7SG7iemva15mI72nfOc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VNOH9+pA; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VNOH9+pA" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-80b7a6b2b47so91115585a.0 for ; Thu, 18 Sep 2025 05:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758197617; x=1758802417; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ab3QXXrJI4VoygmqlsUnbOTIldCc4t2kGE8i4cO7wTA=; b=VNOH9+pA9K8jw+GaKpQEhWSjCnXw3b9VLmZg7fXdp9MUewtX2YLmbOJ3J4rErhvDtQ iEsGcDDMWJF7dHzOIBzkpGUn9o+xsIdXqIkAnco7fuV9RAILlC9vnQGe3WqkKFrtWKVq 7tzC/jU1GzaTQ/VBKskm7epZTLwy9Qd6c6nMaOxnQTd+5w1DkfZcJXLlqYNLEBUfn18y HjgKF7o/vLTWMAeAOHoC49FB8sccUOLwmPvm4K7sMaDW5kyqRYdLvB2ybiZSZfcHnlMn 4HUUUnKR9PXkfsOZFKrm+27yvrjwBD3Dhr28AZkPpUeGlScVu5sdb4Jyl0dYlAMFHqz6 c1gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758197617; x=1758802417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ab3QXXrJI4VoygmqlsUnbOTIldCc4t2kGE8i4cO7wTA=; b=v4SngsHrO3PXQ0efAegYME774Nlux1EHe/yIlr39s/N8GIug1oNXdpCGeB2RNqDIwN 1qMFvJ6ODLxqULWcxw/3WJZHK+zhv5MTNR+sNmz98LM3JNKIbmT7lQSMTehNRxKnY5w7 1PClp6IBIGl4BI1Db/c2i+2VTBHkRuCOXYVtuNLm6WmbCpcWPgcZNWarxxWUqfSTvUyU ju7mb5eGyAI9c8oGadDsW4pB/Y9F/nYMApgcGwfeiwNVWyCqI7Lztz/2ytmTjTJnt6fX 5sJzo3ISwyGX19sHkOvNnAeTOuVAVG1z1FuaKqTazhKF5YUe9rzdhmVR8WFvd1ig4OpO 4bdQ== X-Gm-Message-State: AOJu0Yy9PNPzwe9JLF0cN8IuT3TZXjKe58l3N0nW8QryCexGJIe7bBu2 WFbELTpuLbRxwDIXhNw3ulu6W3w7Lb6mbVpjGu+66qLi813s4Wz2I+6zS8XMhA== X-Gm-Gg: ASbGncvo/93qQhOW/8ldWXmPmFQcf0duJeBWwDohtyKRnbyZq36pCljtd2DWDIiHyNK yixzca0la43tN4BVCLkji+4Cp4DZP3xefxFpv0e/5KXshZQkKE+AihRcr8lgnb5djv/DOdVD291 qBNdUMEmbquLocf6gYl2CuR9GupM53mdCF5Gl25sCdIvvhI2KbW5Xn67Hx0Xl8Ezj6Lq26wIOES fnFXpP4zI1lZyzsbC91hzINNS7swRyHHcIVXDVJNVnA1UGI/gDosbhI5z4Co5FphGoBrRAniAhW q2e6ezk3hTWECj2fJgzyU6+YUuWxkst+R0VJn+sFw/KsxzWhLKcrEzkn51qFNjeaU4cCv6xig32 9lb4Yd6JVzFNG5IR72KY77UA7CaPIy9V4bH2pYxGarQfURBGbc8XAFZkQRwV0p+0xX9CzGa1TIu I11pZionLFY8E= X-Google-Smtp-Source: AGHT+IGjdUNnk69PwW9+d9V11avtDyeYy10E9ncxBZLJOQD30m3Prxz2VbeNhnxCw8eKYLAIeFltBw== X-Received: by 2002:a05:620a:7112:b0:812:f9a7:e903 with SMTP id af79cd13be357-83108e4d9f8mr684157385a.32.1758197617072; Thu, 18 Sep 2025 05:13:37 -0700 (PDT) Received: from localhost (modemcable197.17-162-184.mc.videotron.ca. [184.162.17.197]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-79344899b25sm12408376d6.7.2025.09.18.05.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Sep 2025 05:13:35 -0700 (PDT) From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Lessard?= To: Andy Shevchenko , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] docs: ABI: auxdisplay: document linedisp library sysfs attributes Date: Thu, 18 Sep 2025 08:13:11 -0400 Message-ID: <20250918121321.116248-2-jefflessard3@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250918121321.116248-1-jefflessard3@gmail.com> References: <20250918121321.116248-1-jefflessard3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add ABI documentation for sysfs attributes provided by the line-display auxdisplay library module. These attributes enable text message display and configuration on character-based auxdisplay devices. Documents previously undocumented attributes: - message, scroll_step_ms (introduced in v5.16) - map_seg7, map_seg14 (introduced in v6.9) The line-display library is used by multiple auxdisplay drivers and can expose these attributes either on linedisp.N child devices or directly on parent auxdisplay devices. Signed-off-by: Jean-Fran=C3=A7ois Lessard --- .../ABI/testing/sysfs-auxdisplay-linedisp | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-auxdisplay-linedisp diff --git a/Documentation/ABI/testing/sysfs-auxdisplay-linedisp b/Document= ation/ABI/testing/sysfs-auxdisplay-linedisp new file mode 100644 index 000000000000..45cf4e5a2feb --- /dev/null +++ b/Documentation/ABI/testing/sysfs-auxdisplay-linedisp @@ -0,0 +1,79 @@ +What: /sys/.../message +Date: October 2021 +KernelVersion: 5.16 +Description: + Controls the text message displayed on character line displays. + + Reading returns the current message with a trailing newline. + Writing updates the displayed message. Messages longer than the + display width will automatically scroll. Trailing newlines in + input are automatically trimmed. + + Writing an empty string clears the display. + + Example: + echo "Hello World" > message + cat message # Returns "Hello World\n" + +What: /sys/.../scroll_step_ms +Date: October 2021 +KernelVersion: 5.16 +Description: + Controls the scrolling speed for messages longer than the display + width, specified in milliseconds per scroll step. + + Setting to 0 disables scrolling. Default is 500ms. + + Example: + echo "250" > scroll_step_ms # 4Hz scrolling + cat scroll_step_ms # Returns "250\n" + +What: /sys/.../map_seg7 +Date: January 2024 +KernelVersion: 6.9 +Description: + Read/write binary blob representing the ASCII-to-7-segment + display conversion table used by the linedisp driver, as defined + by struct seg7_conversion_map in . + + Only visible on displays with 7-segment capability. + + This attribute is not human-readable. Writes must match the + struct size exactly, else -EINVAL is returned; reads return the + entire mapping as a binary blob. + + This interface and its implementation match existing conventions + used in segment-mapped display drivers since 2005. + + ABI note: This style of binary sysfs attribute *is an exception* + to current "one value per file, text only" sysfs rules, for + historical compatibility and driver uniformity. New drivers are + discouraged from introducing additional binary sysfs ABIs. + + Reference interface guidance: + - include/uapi/linux/map_to_7segment.h + +What: /sys/.../map_seg14 +Date: January 2024 +KernelVersion: 6.9 +Description: + Read/write binary blob representing the ASCII-to-14-segment + display conversion table used by the linedisp driver, as defined + by struct seg14_conversion_map in . + + Only visible on displays with 14-segment capability. + + This attribute is not human-readable. Writes must match the + struct size exactly, else -EINVAL is returned; reads return the + entire mapping as a binary blob. + + This interface and its implementation match existing conventions + used by segment-mapped display drivers since 2005. + + ABI note: This style of binary sysfs attribute *is an exception* + to current "one value per file, text only" sysfs rules, for + historical compatibility and driver uniformity. New drivers are + discouraged from introducing additional binary sysfs ABIs. + + Reference interface guidance: + - include/uapi/linux/map_to_14segment.h --=20 2.43.0 From nobody Thu Oct 2 09:16:49 2025 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F00A41FF7B3 for ; Thu, 18 Sep 2025 12:13:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197621; cv=none; b=r+qDZjvBf8N+0AEsmCPzDD1TzV0Gj8g8FB0IVWNyQsbx8s+FQSWOfYXPOPTo6OsK5SPJv08DWJPOY9k5p5qTLSBUr045TN7V5noWcvKCWJfM4ypzEEdJZnGTKSd1AuRZllg0lAMIsgE4x5sSM++0O4yVNYlYRpZzaEhBv8L7V3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197621; c=relaxed/simple; bh=1G4flghObBmoHal5iOBv5mtrAxWP6etmx/TF7zvVBlA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b40fLb1+6Rjo55w+0uIH7lNErhleZgAxpJ4MHk+1t1AJIcRarccY8nXA4X8gU1hJcvB/5pee3Dw38a7j5eGH8qij21x4zve9+tt8yUXhfABhopP/lU1PAHYe4afrdYx8D1mFR65sGelX2HmDg1AUFFgjrHQUgXuiiCfvayGlbwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N3vo/06k; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N3vo/06k" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-7900952fb89so8014816d6.3 for ; Thu, 18 Sep 2025 05:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758197619; x=1758802419; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aFlo8CznMFg2dIpKqYtA20b3rwjoQ1cupxnccT2OfmM=; b=N3vo/06kD3YuXJPTNZ89KzlGWvTfhdHHqVxp/z1fejwnimr6xsbB6KxnP9D1IhaYEx zCk7VmAYlGwBTwQwYXPMKnc935/m05CjQpvvFkcy0eK0hOR5lbCdY2WVLV37/RPkCaKD pu3USSSHBGpQs58rZmMPwhp1TpnYpUYffvnJlw+L0Fjke31cdiZzVTMQmHgSnlWZ6WFc WHmfIjCXk+Mm0A0FssSkGs3WfUuX3k3AVmMyRlKw2vpG5REGKeDkgHAMhbYS/1NsHrQe F7RrXp/M8Ao89eO8osspgFnlqktx931oR35gMOe2wKWOTGrNk233b2MODY9MNwTqaSbT JcOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758197619; x=1758802419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aFlo8CznMFg2dIpKqYtA20b3rwjoQ1cupxnccT2OfmM=; b=RCrnnHIvS8B5ZIG9vTuagfSeO4H3HBAZQ+f9BM1Z2SZkAcViB6KU10MSd7TmOKqplV /rLiRWnRMEt85zsqp5/A8kHt/A3NF0uLwGbfMpplRwl53HTjS6R+JsF5nw8eoc2nZGZo HFQkuHLXkGY3qblKypmjuA4q65zHwPTNw5Fge6PX866eeFmDeiC+AWsY3KM34gK9BNdo az8iI++Ocd5dWu4B+mTb89j5lp1c3WKiZuXPNUrqMjIQ9BpgFjCRO40Aqrylyjtca/Tm NxIHjMATAMOIbZHnRiwiWpM/gy7l1mdeOzlL09+TYI1RWeiN0AmOi89Q4JbQjRMFxUH5 pVSA== X-Gm-Message-State: AOJu0Ywu6TZnewzfFyu7vewAbhdiZff69ZaRSMeXRRRQ0j5SX+QDw6ZW 3VcVnpBAUJIXx+xg9TfOPaw+9ukUvWuAKUumuWp82DOnSQ94BJPkzkkNrzJMcQ== X-Gm-Gg: ASbGnct7zDMTTwWipE59cUFOpi7LUml5SYWwkAvV8KxzXUXJf2cTm5Rdzgbd0aaEOZC t5uTf/2vt/2Y7FmRO+EYzxm1fzKGz69+/TwgNEq7KLz6+Ym4gNrBDjIVFzCqFSvWMBFzJWi0foi P/r35VZhLIsOgbDjEDGZ2JMgkOhpxPP9PtoCMCwJ9XQ79UFgMl1TzT5wYvAjaGqeczUFJVqwxkr 34B5WWyrIkRpXfikACJr2ffzP2WgFUOPasGFty8HH42FuBPlxHjzXdG5M51SG0BY3pW0syEg46K Rp/wi0JYVUVlzO/h8/sMq0VHnkecsuqiBT6SW/ACcqxHqIczCJDC5Ek4wYaT6C1Hsapc2CmdSwB X+pYlqezx2Ke9bR/FTjDf8iXvpm2dH9QRT1Qf5gsyEGLjtRTIs5O+7JZc9YYgW+t9it3h1G8Mb0 Jtcw7GxgwtKy4= X-Google-Smtp-Source: AGHT+IGP8lFwftwqPiVPMY0ySIs/nKEoP6hDoTdih/xQqIv12ahvrTg2o8QpS8/nsSa988Tlt6wEIQ== X-Received: by 2002:a05:6214:250d:b0:736:514b:b8fc with SMTP id 6a1803df08f44-78ecccff412mr77522746d6.19.1758197618671; Thu, 18 Sep 2025 05:13:38 -0700 (PDT) Received: from localhost (modemcable197.17-162-184.mc.videotron.ca. [184.162.17.197]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-79355725df5sm12016436d6.64.2025.09.18.05.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Sep 2025 05:13:38 -0700 (PDT) From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Lessard?= To: Andy Shevchenko , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] auxdisplay: linedisp: encapsulate container_of usage within to_linedisp Date: Thu, 18 Sep 2025 08:13:12 -0400 Message-ID: <20250918121321.116248-3-jefflessard3@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250918121321.116248-1-jefflessard3@gmail.com> References: <20250918121321.116248-1-jefflessard3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Replace direct container_of() calls with a to_linedisp() helper function throughout the line-display auxdisplay library module. This abstraction prepares for upcoming dual-mode support where linedisp context retrieval will need to handle both dedicated child devices and attached parent auxdisplay devices. No functional changes in this patch. Signed-off-by: Jean-Fran=C3=A7ois Lessard --- drivers/auxdisplay/line-display.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 8590a4cd21e0..e44341b1ea22 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -31,6 +31,11 @@ =20 #define DEFAULT_SCROLL_RATE (HZ / 2) =20 +static struct linedisp *to_linedisp(struct device *dev) +{ + return container_of(dev, struct linedisp, dev); +} + /** * linedisp_scroll() - scroll the display by a character * @t: really a pointer to the private data structure @@ -133,7 +138,7 @@ static int linedisp_display(struct linedisp *linedisp, = const char *msg, static ssize_t message_show(struct device *dev, struct device_attribute *a= ttr, char *buf) { - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); =20 return sysfs_emit(buf, "%s\n", linedisp->message); } @@ -152,7 +157,7 @@ static ssize_t message_show(struct device *dev, struct = device_attribute *attr, static ssize_t message_store(struct device *dev, struct device_attribute *= attr, const char *buf, size_t count) { - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); int err; =20 err =3D linedisp_display(linedisp, buf, count); @@ -164,7 +169,7 @@ static DEVICE_ATTR_RW(message); static ssize_t scroll_step_ms_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); =20 return sysfs_emit(buf, "%u\n", jiffies_to_msecs(linedisp->scroll_rate)); } @@ -173,7 +178,7 @@ static ssize_t scroll_step_ms_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); unsigned int ms; int err; =20 @@ -195,7 +200,7 @@ static DEVICE_ATTR_RW(scroll_step_ms); =20 static ssize_t map_seg_show(struct device *dev, struct device_attribute *a= ttr, char *buf) { - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); struct linedisp_map *map =3D linedisp->map; =20 memcpy(buf, &map->map, map->size); @@ -205,7 +210,7 @@ static ssize_t map_seg_show(struct device *dev, struct = device_attribute *attr, c static ssize_t map_seg_store(struct device *dev, struct device_attribute *= attr, const char *buf, size_t count) { - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); struct linedisp_map *map =3D linedisp->map; =20 if (count !=3D map->size) @@ -232,7 +237,7 @@ static struct attribute *linedisp_attrs[] =3D { static umode_t linedisp_attr_is_visible(struct kobject *kobj, struct attri= bute *attr, int n) { struct device *dev =3D kobj_to_dev(kobj); - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); struct linedisp_map *map =3D linedisp->map; umode_t mode =3D attr->mode; =20 @@ -263,7 +268,7 @@ static DEFINE_IDA(linedisp_id); =20 static void linedisp_release(struct device *dev) { - struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + struct linedisp *linedisp =3D to_linedisp(dev); =20 kfree(linedisp->map); kfree(linedisp->message); --=20 2.43.0 From nobody Thu Oct 2 09:16:49 2025 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64E1B2F83B4 for ; Thu, 18 Sep 2025 12:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197622; cv=none; b=NQwVgfGnq4UgorKJb8h9OmKb03lgRpdP/VSxaDPkWhODKdO1fAq61WNQgvN51uQM9J516K1k4v8hABv0iBKqEHG6S7ItxhCP+Oa7s/jP0Zumm0OXwLi27w1Yf3DG+arf593eWlv1Vpbw+MvFEIABMJhRB41PvTkM/t/beCN1GCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197622; c=relaxed/simple; bh=24Be7G8WgfefB3rgK007NjGcnBPNBuN2h6zVyr5c2XM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kmzwQsp9uA9f//Pfob1XFCeOuSzZ1G4Zgfl+oifmSHeZ+eEGlBCq1gBGRKfXPWV5O3x7nG7oPuBKImpJGizlBeeikJAOcM1Cb2EzEXWFPeTkx3IwTRW2iFRG5RH+kjfUsoR+66atK5WDpgae6xv05jX20J490InjhsmIf9xDuRo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YrZFleHB; arc=none smtp.client-ip=209.85.219.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YrZFleHB" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-78d73eef306so7975266d6.0 for ; Thu, 18 Sep 2025 05:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758197620; x=1758802420; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+oA1EqdG3ZaYUrig5a2R7esA1n5VsBIXfb4bGmd5S/8=; b=YrZFleHBy8/bgTEpDA7xyXMfKrdv0cSs3VbwCIk/eppFatQaj/QzFQtYhouAu2+WF3 i7f4OVZ2q3brVJXlR87ooD8ipqwSXiBNmQbxcRraN/qdlycrEmMT+5cnkLe/K3wlqBif zsJZd2+/2Gn2XKN3CX5jvxvDesKr7kaDxhLbvwsrY11b/6+z5XHQHsbpl56YrpaIeph6 K9+I7L8Wjdi/reaF9Z5nt0+QyUP4dQaPIOZ9le66gu93hsWQKujmhoCHtEF27Ir21Je8 juZNJBEJuVfiK79y9MlGOB0OwiJu5HZXcRo8Uw/gr1jQrwoke8/NFYhMVNSohNeqU1MK euwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758197620; x=1758802420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+oA1EqdG3ZaYUrig5a2R7esA1n5VsBIXfb4bGmd5S/8=; b=gp6CrHm840/xvx/98bCd0RmjpHiiS87KtCdbkJLns8DtfdfaGW5GCTeV06iKFdcaE/ 81lguL5cUUq9Q5abLaI02LQNlv0dLlnmQcEjx/VFmcn+V/gUtT8LzfNy4f+WfzV3tTqT NaJmM64YQIHricmkeJfSLhMHHXhnm1OwtcOF6G+8PhYBe8ZXCxb8LJfkq8hwoMFMumvR qbeTwCO+ImRMRBjmuzwnhVye9f/B7RhJWRybI2z5S8deW0tPBEo0dmsxNiBwEVxriOhF 1f5Mrr1AbVuhK7y/5brddTHYk9xRo3LdZpxP7+3yh2DKM0Mwy5sgK2zB/3VDpq5bcpn/ d5Tw== X-Gm-Message-State: AOJu0YxBXtAeWTWp/sHMwMHqZFJGUsGW8qXsJ9QC6PrYcxY2pxNnrNnX 3Et5vU8Fmu7nfOKkjBmQW36f1kQZ95rj8SbC8SC4a7W5XTmupPKoxSVc X-Gm-Gg: ASbGncsmGCZb2YwK0HlexFe+5IORV1XYIZ9yjalDaUfwCJk6d+tU6vHiWI/VjuQROyU FUrkUTU3zf+3b5y9BMwItCARdbCD/PcN6ZHmSV5X/E7PjNzDTBIAe7i9E0TkU70JtHMjvLTWZgj 0AExR3kX5oGhXxJwl1adW6Bb7nYD4GKg9pOKu/Et5BqlA1qt/UrB02s/f1HWq7hThgim6nj9YhV qJGiae5JoVhjVw3PEkIUA52vmOnjySQ7Xj28iE8itmDQRYE/LjJBbNrTigFloJug6Fe9NtoCMkL rbkb8KZvi9BMAWtQICc68GV8GdOKSpJZxFfrlgNn80XiyTseA+BHLbH2Gb5Gv333cjaRGk2eUJq jWI4pm1GEYAVA99hb0V9/vmz0IJZ6B6hI+6Zc6FQPsrn99RVpxa4aG1QIvAZXX4EXPxom5lpb8k +jfkHZpIgJfpc17k4wRCpCcQ== X-Google-Smtp-Source: AGHT+IHaWs43hwNebF+u8cDrbsFeSgHWNax7eCOWWpmAddYVM297Sxy9MwpRWX7qWPKmSvWLnNvLKA== X-Received: by 2002:a05:6214:5099:b0:773:7118:306f with SMTP id 6a1803df08f44-78ece369c41mr74027136d6.39.1758197620095; Thu, 18 Sep 2025 05:13:40 -0700 (PDT) Received: from localhost (modemcable197.17-162-184.mc.videotron.ca. [184.162.17.197]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-79354c9f26esm12044236d6.62.2025.09.18.05.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Sep 2025 05:13:39 -0700 (PDT) From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Lessard?= To: Andy Shevchenko , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] auxdisplay: linedisp: display static message when length <= display size Date: Thu, 18 Sep 2025 08:13:13 -0400 Message-ID: <20250918121321.116248-4-jefflessard3@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250918121321.116248-1-jefflessard3@gmail.com> References: <20250918121321.116248-1-jefflessard3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Currently, when a message shorter than the display size is written, the content wraps around (e.g., "123" on a 4-digit display shows "1231") without scrolling, which is confusing and unintuitive. Change behavior to display short messages statically with space padding (e.g. "123 ") while only scrolling messages longer than the display width. This provides more natural behavior that aligns with user expectations and current linedisp_display() kernel-doc. The scroll logic is also consolidated into a helper function for clarity. No API changes are introduced. Signed-off-by: Jean-Fran=C3=A7ois Lessard --- drivers/auxdisplay/line-display.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index e44341b1ea22..73e4e77ea4f9 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -36,6 +36,11 @@ static struct linedisp *to_linedisp(struct device *dev) return container_of(dev, struct linedisp, dev); } =20 +static inline bool should_scroll(struct linedisp *linedisp) +{ + return linedisp->message_len > linedisp->num_chars && linedisp->scroll_ra= te; +} + /** * linedisp_scroll() - scroll the display by a character * @t: really a pointer to the private data structure @@ -67,8 +72,7 @@ static void linedisp_scroll(struct timer_list *t) linedisp->scroll_pos %=3D linedisp->message_len; =20 /* rearm the timer */ - if (linedisp->message_len > num_chars && linedisp->scroll_rate) - mod_timer(&linedisp->timer, jiffies + linedisp->scroll_rate); + mod_timer(&linedisp->timer, jiffies + linedisp->scroll_rate); } =20 /** @@ -118,8 +122,16 @@ static int linedisp_display(struct linedisp *linedisp,= const char *msg, linedisp->message_len =3D count; linedisp->scroll_pos =3D 0; =20 - /* update the display */ - linedisp_scroll(&linedisp->timer); + if (should_scroll(linedisp)) { + /* display scrolling message */ + linedisp_scroll(&linedisp->timer); + } else { + /* display static message */ + memset(linedisp->buf, ' ', linedisp->num_chars); + memcpy(linedisp->buf, linedisp->message, + umin(linedisp->num_chars, linedisp->message_len)); + linedisp->ops->update(linedisp); + } =20 return 0; } @@ -186,12 +198,12 @@ static ssize_t scroll_step_ms_store(struct device *de= v, if (err) return err; =20 + timer_delete_sync(&linedisp->timer); + linedisp->scroll_rate =3D msecs_to_jiffies(ms); - if (linedisp->message && linedisp->message_len > linedisp->num_chars) { - timer_delete_sync(&linedisp->timer); - if (linedisp->scroll_rate) - linedisp_scroll(&linedisp->timer); - } + + if (should_scroll(linedisp)) + linedisp_scroll(&linedisp->timer); =20 return count; } --=20 2.43.0 From nobody Thu Oct 2 09:16:49 2025 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7DF4302166 for ; Thu, 18 Sep 2025 12:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197624; cv=none; b=QYW7rCVJ1Jj2SuyaLtpukND/2pgWxgogAIhnsqdDj1Fk0nUfQGkfpAtmgD5n9ZEJb0EZKM95B+89e3+IglH1zvlcyrs2oYycdFARQKv0gd1Bk55LutTIyNrPOo23ns0ETJLr/kNcU643gCUMA/7gNJRfqfdGitRUP8fPlXVvU1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197624; c=relaxed/simple; bh=JsiWJ0idw6/yiGbo3kbDll8GBfeTR6oH0as6tc+6i9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CWYoRboK2QuOBOivgmtzaFuXDqDtOKuSNzFp2uDQjvmYp7xPVAz8fAyONnxqIMMlu/jSw7F9FFiiDC45ckbocSg2mv2RoaHZGpqGu09RL86jCXO1lEjGWjUNScaw+5mS/OLt81EPJgwlyvXYBq3XPAoJFVvA8qcxiYbqwSVR/mg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l1Bu5GRQ; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l1Bu5GRQ" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-4b7ae45a91cso6268261cf.2 for ; Thu, 18 Sep 2025 05:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758197622; x=1758802422; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WwWZNUuCtZ9/86xWHoWdfhxYkVDMpzkc+/3I7/MEfIo=; b=l1Bu5GRQlWCahMDDZENu+ItK/XMMLDelCWS1qqIpCy1TsDzJYC4bDFZoE/2TN4YCVz 6YsA57tKVtPEDKG/DuwuYzE+tK+6Lt1tYbejMAj6jeJDOL0JeFauB5N9fPdmrov4uvRI n2UwWACkQHh78D1sjXU8k5DA9HG7qW0quWntLlO9MNuq+vkW1lh1oImBiF/Em/rwkzis Wj14DnrNq93a4ooj2YRAu6CyDC6IXx+9CuZVCj1+TIl5avtqWa/Nv1CocrYX+uo37mp+ jCtQNXDLFYFjSLcI5+8VD/Hrsy6gmKL/lIA0lQPjNHuSxvJVf4nC57Akzw3RIk4d5rlN IHLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758197622; x=1758802422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WwWZNUuCtZ9/86xWHoWdfhxYkVDMpzkc+/3I7/MEfIo=; b=uhuXnF62nsklWCWcPD1aWCy3hafEaPZlDDepdR5776+sx4JUKCIFoMH8skEZB/VJnN t7r5yEUIc/nuJkTE6TapSST4sOz2M/0b8gdIKOrXdYmDT20S69wtCi0gsw9TpmObisKh +p3BpfOxpO28QVQ0BwOYmWjvU9dlXFrDyXCXW0fxSkXrPf0HOJp8GQ3gQg38PyXmHxzL RPwNKIksFBlMxc6RRzuyTyZn9LAtXu6yI59S+ButqwSenEb7pdI2s/fHiyd3nopazIQR oBqycb9kaYfYsvbP50yHF8nHKFz56PtjRmNK5Qt9Utk1Az98XEtQr1N5zXyH7DKRYLnh VjNw== X-Gm-Message-State: AOJu0Yzd3C1uCdMbgm01N6X/AgRA+trVFkAFlujslJPvOIFmMbxgWHcZ ZDS0eK+rpNRHz7ueip0AVXylqyejFFp5rd/IkJAWXwVKosU2mhbPU0tfmCdJrQ== X-Gm-Gg: ASbGncu8yABRGyE5bee9kZkO/wBwdSUDftsuxMb+5BTQ6Qn+FrIyLuopYwLyCu6U8EF 6Joa6rs9qn8rWPyJ0JLQWUuV5b9kPAH9JqWbCbj4dzpxPz+39B7bwXZl0/6dbu21Qyq4nw7cNmK PRk+hfnTVDTd0N0etRAfps4Gw2kuB6VN1v2Qz/dyN86W8PZNsT5HD5b9GmT3/HM3tdGqu568Spt k8xo9WLQr6fzwlsOQdBzE+3ez2b9VgxIoMpHIjxr7F/eUb10gJeoeNEwaPBSHtf4S+qeiDcHBgd gjRlwbSK0Fia228cpavnIvWtFfFfz8dr1iOJWD3GQwF2RMXl0zyfAG9PcYi8wj358Yx69VuVhvm /UlIUxRPUUTeaeur+M7lkiyY+9btDViGOs/Hnu3KYHjuaW95CzEfXBMKEN4OauZX7wfCGFrDXU/ m6TFihZxDqhsk= X-Google-Smtp-Source: AGHT+IGRc+hNfS3wAF3k/kzEr22/JJ8PvBugFt93cCI74XG8yHk7aPlN4AQJ3WQO6WRjQuc4vGziBA== X-Received: by 2002:a05:622a:5518:b0:4b7:7c2c:8534 with SMTP id d75a77b69052e-4ba655f9703mr63257701cf.15.1758197621571; Thu, 18 Sep 2025 05:13:41 -0700 (PDT) Received: from localhost (modemcable197.17-162-184.mc.videotron.ca. [184.162.17.197]) by smtp.gmail.com with ESMTPSA id af79cd13be357-836278b5cd7sm154528185a.21.2025.09.18.05.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Sep 2025 05:13:41 -0700 (PDT) From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Lessard?= To: Andy Shevchenko , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] auxdisplay: linedisp: add num_chars sysfs attribute Date: Thu, 18 Sep 2025 08:13:14 -0400 Message-ID: <20250918121321.116248-5-jefflessard3@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250918121321.116248-1-jefflessard3@gmail.com> References: <20250918121321.116248-1-jefflessard3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add a read-only 'num_chars' sysfs attribute to report display digit count. The num_chars attribute provides essential capability information to userspace applications that need to know display dimensions before writing messages, complementing the existing message and scroll controls. No functional changes to existing behavior. Signed-off-by: Jean-Fran=C3=A7ois Lessard --- Documentation/ABI/testing/sysfs-auxdisplay-linedisp | 11 +++++++++++ drivers/auxdisplay/line-display.c | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-auxdisplay-linedisp b/Document= ation/ABI/testing/sysfs-auxdisplay-linedisp index 45cf4e5a2feb..55f1b559e84e 100644 --- a/Documentation/ABI/testing/sysfs-auxdisplay-linedisp +++ b/Documentation/ABI/testing/sysfs-auxdisplay-linedisp @@ -15,6 +15,17 @@ Description: echo "Hello World" > message cat message # Returns "Hello World\n" =20 +What: /sys/.../num_chars +Date: November 2025 +KernelVersion: 6.18 +Contact: Jean-Fran=C3=A7ois Lessard +Description: + Read-only attribute showing the character width capacity of + the line display device. Messages longer than this will scroll. + + Example: + cat num_chars # Returns "16\n" for 16-char display + What: /sys/.../scroll_step_ms Date: October 2021 KernelVersion: 5.16 diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 73e4e77ea4f9..7f3e53e2847b 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -178,6 +178,16 @@ static ssize_t message_store(struct device *dev, struc= t device_attribute *attr, =20 static DEVICE_ATTR_RW(message); =20 +static ssize_t num_chars_show(struct device *dev, struct device_attribute = *attr, + char *buf) +{ + struct linedisp *linedisp =3D to_linedisp(dev); + + return sysfs_emit(buf, "%u\n", linedisp->num_chars); +} + +static DEVICE_ATTR_RO(num_chars); + static ssize_t scroll_step_ms_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -240,6 +250,7 @@ static DEVICE_ATTR(map_seg14, 0644, map_seg_show, map_s= eg_store); =20 static struct attribute *linedisp_attrs[] =3D { &dev_attr_message.attr, + &dev_attr_num_chars.attr, &dev_attr_scroll_step_ms.attr, &dev_attr_map_seg7.attr, &dev_attr_map_seg14.attr, --=20 2.43.0 From nobody Thu Oct 2 09:16:49 2025 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D7A6304964 for ; Thu, 18 Sep 2025 12:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197626; cv=none; b=CHX8yUjoKg41pRAlwCKWXLZqpYFB1PzZnsMf0MR15GvcHw/q87XBATxkDpHb+HQpF93dnRI0fAIXoomzsWco2CLdz8XxAn7W19C4z1EdI4dtuocUd6t6xXoeN3GD58GxZ33Qiz3CCqOYxulrcfxl99dY5IgJ9zQ60rtAYbdPdGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758197626; c=relaxed/simple; bh=EIwaWaT37xFsFjgkRrWrrtDUx0Pwb/lABPC/ejoZFhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h8sCQ1IhxL4zwYLgLBdge6CFKsENmaMmt2qvKnoZMyQFg6iXdYRVcPBuRkEenqFVSeL4oO7GvknGGEhk0I+lZr40Akaw6HeEkNn50A9zdsCxu9vvEN2cdo6IErS+pEMAVishZ/9hLbWVn8u1qXfZxqLV4Go9WQLsWD+nZhd2DX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TPcw21yg; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TPcw21yg" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-78f15d5846dso10041866d6.0 for ; Thu, 18 Sep 2025 05:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758197623; x=1758802423; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/KQ73OeZZZwvODsvYl1a5BKB7WUXqf2yiQRx3G0AX38=; b=TPcw21ygTs1b0gvuU+pREZTGcgdc4k7VnbvKewjQjGcGhdlNJ/dn7s/jmWfjNf1HIf vEVLMj3xAq9x29qf3M1F7lNCiY9QitCqzFJ2IOvjOtooagysw4C7dFZzcdYe2GIp7Kcs +7PcmKSWlaBaLpFCPAUhvE5/62QmveU3P6Wl3QRLNoE6zktek3ElZUop7F4XdgJEE6sH p3oaSuJxS4wk1GAZEh9BnqvNoie58+Ki2RINgxV4Mn3R6ijxC/RZi/aMedepAI6zLZ3a HvjZAzirngAZQTyecEuF18j4ETPecpVCGxV1A9/TRi2ZMVcK74gmYBnt1DnffCAeNkH2 XXhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758197623; x=1758802423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/KQ73OeZZZwvODsvYl1a5BKB7WUXqf2yiQRx3G0AX38=; b=V3A5nwe4bpy1p2Uj9ZYX5wxD6NqtmcnCtPxfxZP4C10DTodE4BRDZUHCZQTOWy8HtH FegtAyoYzPb4Iy1Px/11LAP7Cy9uimkuoY9Fe3z3ZsfzWTSZdnF2DUZR1cqWXgwRVmiE sOWJaHE5W2NtTjWzo7rZY+WH/i6Pn5X+jr1i3kTyr6UpIGYTcJo0GcZDnJYcaN631jQ6 gvGvEtkvADPPFPv+j3llRQswVxi2i1ewVn5tCliMBteKXkHQuiE73jS96KkeCJh3G3l0 e59GVGR9fpgIjQ3pZQXAaIL1ceFKDPO4VaIjgmh51OJ8RnkdFJQVyZWsN4kMqXWTNajb WFRA== X-Gm-Message-State: AOJu0Yxe9wQkzVC8Xe0L9ZKPWT09yytuZtqzC9kFFeNd7NV2tGnwEvJl SBuHSOdpSCJY2lund8GxiXq21+wGerL1whRnjzJ7oULNILEk+Gx/BFxqPn/uXQ== X-Gm-Gg: ASbGncuhH534gDS5VVoykyOl2EPL7QGJSQT9JrLe1aRFxXewloFtlID5nq2t4Q2C0V3 +kqSmslLAbMfJC/6r6sYtQy2JrdUw9Ac3Hb5vW2fL9Z4oX2SjNS5sK9FroSCVP4ihigL608YB8N S8gD6ITZhHRDuPuCN5CDDoyvevonZmYL3gVqa4yVhlp+2LvXcnBJ3HZgvdlIilZassSQJ45Vfo/ G+YsudoJ6gVgvM50HY9acyiaL76Oe69vL7vzOvy6uukUTbESwksrDHYfKrtln9ZH7eWMR+qVAMY coEmtphl7KqQKQ3ASLqfa+9SU/tFBvQrL0OXCWvTDuvDql4VlzYFm2sB9XgnzrGgUzqKqomkXDV +GJkG5pcbaMSlXmmmKVV2yCeA6R/PbbQOGip5aKPBuQpi53NArDivz6qPgSyHkH4ekWy70677j9 CXt/W7DCCSbsesYkB41vKSwA== X-Google-Smtp-Source: AGHT+IGXrefQq4AXLV0RINkfLWhu9HvDI2ERr+UwPOvbB51xD085TTu9xIJkIBf8DW0yvCsgPFrFRA== X-Received: by 2002:ad4:5cab:0:b0:709:c7de:ce70 with SMTP id 6a1803df08f44-78ecc43a332mr59381426d6.10.1758197623027; Thu, 18 Sep 2025 05:13:43 -0700 (PDT) Received: from localhost (modemcable197.17-162-184.mc.videotron.ca. [184.162.17.197]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-793472c3946sm12252256d6.28.2025.09.18.05.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Sep 2025 05:13:42 -0700 (PDT) From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Lessard?= To: Andy Shevchenko , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] auxdisplay: linedisp: support attribute attachment to auxdisplay devices Date: Thu, 18 Sep 2025 08:13:15 -0400 Message-ID: <20250918121321.116248-6-jefflessard3@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250918121321.116248-1-jefflessard3@gmail.com> References: <20250918121321.116248-1-jefflessard3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Enable linedisp library integration into existing kernel devices (like LED class) to provide a uniform 7-segment userspace API without creating separate child devices, meeting the consistent interface while maintaining coherent device hierarchies. This allows uniform 7-segment API across all drivers while solving device proliferation and fragmented userspace interfaces. The sysfs attributes appear in one of the two locations depending on usage: 1. On linedisp.N child devices (legacy linedisp_register()) 2. On the parent auxdisplay device (new linedisp_attach()) Functionality is identical in both modes. Existing consumers of linedisp_register() are unaffected. The new API enables drivers like TM16XX to integrate 7-segment display functionality seamlessly within their LED class device hierarchy. Signed-off-by: Jean-Fran=C3=A7ois Lessard --- Notes: The attachment list operations are extremely lightweight (just adding/removing list entries), making spinlock the optimal choice becau= se: - Very short critical sections: Only list traversal and pointer assignments; avoids context switching overhead for brief operations - No sleeping: No memory allocation or I/O within locked sections drivers/auxdisplay/line-display.c | 180 +++++++++++++++++++++++++++++- drivers/auxdisplay/line-display.h | 4 + 2 files changed, 178 insertions(+), 6 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 7f3e53e2847b..4e22373fcc1a 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -6,20 +6,23 @@ * Author: Paul Burton * * Copyright (C) 2021 Glider bv + * Copyright (C) 2025 Jean-Fran=C3=A7ois Lessard */ =20 #ifndef CONFIG_PANEL_BOOT_MESSAGE #include #endif =20 -#include +#include #include #include #include #include #include +#include #include #include +#include #include #include #include @@ -31,9 +34,80 @@ =20 #define DEFAULT_SCROLL_RATE (HZ / 2) =20 +/** + * struct linedisp_attachment - Holds the device to linedisp mapping + * @list: List entry for the linedisp_attachments list + * @device: Pointer to the device where linedisp attributes are added + * @linedisp: Pointer to the linedisp mapped to the device + * @direct: true for directly attached device using linedisp_attach(), + * false for child registered device using linedisp_register() + */ +struct linedisp_attachment { + struct list_head list; + struct device *device; + struct linedisp *linedisp; + bool direct; +}; + +static LIST_HEAD(linedisp_attachments); +static DEFINE_SPINLOCK(linedisp_attachments_lock); + +static int create_attachment(struct device *dev, struct linedisp *linedisp= , bool direct) +{ + struct linedisp_attachment *attachment; + + attachment =3D kzalloc(sizeof(*attachment), GFP_KERNEL); + if (!attachment) + return -ENOMEM; + + attachment->device =3D dev; + attachment->linedisp =3D linedisp; + attachment->direct =3D direct; + + guard(spinlock)(&linedisp_attachments_lock); + list_add(&attachment->list, &linedisp_attachments); + + return 0; +} + +static struct linedisp *delete_attachment(struct device *dev, bool direct) +{ + struct linedisp_attachment *attachment; + struct linedisp *linedisp; + + guard(spinlock)(&linedisp_attachments_lock); + + list_for_each_entry(attachment, &linedisp_attachments, list) { + if (attachment->device =3D=3D dev && + attachment->direct =3D=3D direct) + break; + } + + if (list_entry_is_head(attachment, &linedisp_attachments, list)) + return NULL; + + linedisp =3D attachment->linedisp; + list_del(&attachment->list); + kfree(attachment); + + return linedisp; +} + static struct linedisp *to_linedisp(struct device *dev) { - return container_of(dev, struct linedisp, dev); + struct linedisp_attachment *attachment; + + guard(spinlock)(&linedisp_attachments_lock); + + list_for_each_entry(attachment, &linedisp_attachments, list) { + if (attachment->device =3D=3D dev) + break; + } + + if (list_entry_is_head(attachment, &linedisp_attachments, list)) + return NULL; + + return attachment->linedisp; } =20 static inline bool should_scroll(struct linedisp *linedisp) @@ -348,6 +422,90 @@ static int linedisp_init_map(struct linedisp *linedisp) #define LINEDISP_INIT_TEXT "Linux " UTS_RELEASE " " #endif =20 +/** + * linedisp_attach - attach a character line display + * @linedisp: pointer to character line display structure + * @dev: pointer of the device to attach to + * @num_chars: the number of characters that can be displayed + * @ops: character line display operations + * + * Directly attach the line-display sysfs attributes to the passed device. + * The caller is responsible for calling linedisp_detach() to release reso= urces + * after use. + * + * Return: zero on success, else a negative error code. + */ +int linedisp_attach(struct linedisp *linedisp, struct device *dev, + unsigned int num_chars, const struct linedisp_ops *ops) +{ + int err; + + memset(linedisp, 0, sizeof(*linedisp)); + linedisp->ops =3D ops; + linedisp->num_chars =3D num_chars; + linedisp->scroll_rate =3D DEFAULT_SCROLL_RATE; + + linedisp->buf =3D kzalloc(linedisp->num_chars, GFP_KERNEL); + if (!linedisp->buf) + return -ENOMEM; + + /* initialise a character mapping, if required */ + err =3D linedisp_init_map(linedisp); + if (err) + goto out_free_buf; + + /* initialise a timer for scrolling the message */ + timer_setup(&linedisp->timer, linedisp_scroll, 0); + + err =3D create_attachment(dev, linedisp, true); + if (err) + goto out_del_timer; + + /* display a default message */ + err =3D linedisp_display(linedisp, LINEDISP_INIT_TEXT, -1); + if (err) + goto out_del_attach; + + /* add attribute groups to target device */ + err =3D device_add_groups(dev, linedisp_groups); + if (err) + goto out_del_attach; + + return 0; + +out_del_attach: + delete_attachment(dev, true); +out_del_timer: + timer_delete_sync(&linedisp->timer); +out_free_buf: + kfree(linedisp->buf); + return err; +} +EXPORT_SYMBOL_NS_GPL(linedisp_attach, "LINEDISP"); + +/** + * linedisp_detach - detach a character line display + * @dev: pointer of the device to detach from, that was previously + * attached with linedisp_attach() + */ +void linedisp_detach(struct device *dev) +{ + struct linedisp *linedisp; + + linedisp =3D delete_attachment(dev, true); + if (!linedisp) + return; + + timer_delete_sync(&linedisp->timer); + + device_remove_groups(dev, linedisp_groups); + + kfree(linedisp->map); + kfree(linedisp->message); + kfree(linedisp->buf); +} +EXPORT_SYMBOL_NS_GPL(linedisp_detach, "LINEDISP"); + /** * linedisp_register - register a character line display * @linedisp: pointer to character line display structure @@ -355,6 +513,11 @@ static int linedisp_init_map(struct linedisp *linedisp) * @num_chars: the number of characters that can be displayed * @ops: character line display operations * + * Register the line-display sysfs attributes to a new device named + * "linedisp.N" added to the passed parent device. + * The caller is responsible for calling linedisp_unregister() to release + * resources after use. + * * Return: zero on success, else a negative error code. */ int linedisp_register(struct linedisp *linedisp, struct device *parent, @@ -390,19 +553,23 @@ int linedisp_register(struct linedisp *linedisp, stru= ct device *parent, /* initialise a timer for scrolling the message */ timer_setup(&linedisp->timer, linedisp_scroll, 0); =20 - err =3D device_add(&linedisp->dev); + err =3D create_attachment(&linedisp->dev, linedisp, false); if (err) goto out_del_timer; =20 /* display a default message */ err =3D linedisp_display(linedisp, LINEDISP_INIT_TEXT, -1); if (err) - goto out_del_dev; + goto out_del_attach; + + err =3D device_add(&linedisp->dev); + if (err) + goto out_del_attach; =20 return 0; =20 -out_del_dev: - device_del(&linedisp->dev); +out_del_attach: + delete_attachment(&linedisp->dev, false); out_del_timer: timer_delete_sync(&linedisp->timer); out_put_device: @@ -419,6 +586,7 @@ EXPORT_SYMBOL_NS_GPL(linedisp_register, "LINEDISP"); void linedisp_unregister(struct linedisp *linedisp) { device_del(&linedisp->dev); + delete_attachment(&linedisp->dev, false); timer_delete_sync(&linedisp->timer); put_device(&linedisp->dev); } diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-di= splay.h index 4348d7a2f69a..36853b639711 100644 --- a/drivers/auxdisplay/line-display.h +++ b/drivers/auxdisplay/line-display.h @@ -6,6 +6,7 @@ * Author: Paul Burton * * Copyright (C) 2021 Glider bv + * Copyright (C) 2025 Jean-Fran=C3=A7ois Lessard */ =20 #ifndef _LINEDISP_H @@ -81,6 +82,9 @@ struct linedisp { unsigned int id; }; =20 +int linedisp_attach(struct linedisp *linedisp, struct device *dev, + unsigned int num_chars, const struct linedisp_ops *ops); +void linedisp_detach(struct device *dev); int linedisp_register(struct linedisp *linedisp, struct device *parent, unsigned int num_chars, const struct linedisp_ops *ops); void linedisp_unregister(struct linedisp *linedisp); --=20 2.43.0