From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 946363FB1F; Mon, 12 Feb 2024 17:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757490; cv=none; b=nj5TVjaJJCNU9DO3q+h8Z+jWius5BALxS0vGsdflHafzcnDs7ZM7PAOtJj4SwQX7hNPIr3qiJgvKpIWUkGcNU08AR6Q+LzIoD4va1GCyY/zSeM3eh752xxPJVVHz64Ujr3h/+G9vpVG5zWgZ5vYgalcV9i1+09AWQca1IB742/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757490; c=relaxed/simple; bh=x8TByPmOrQ+gMAIIaoMyZZvfiNw4po8E/dT9novu62c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tX5/9Wu/tVFGBTRY/QXm/G+Zy81B/70aadyhvJ7x4xQQNZGENrc/PjkUKz8ogzdGrC7Z9R8BAk6P6YJLyem8NeSC/8+rKYwrqIkxOVPFeg0Ya7lgjDsFXS0K6EbgxGm6e02Q0kXjw4mNcjgPj1cXpSvM4t4UwDxXrzAcV1vdzcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=A25fG6PI; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="A25fG6PI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757489; x=1739293489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x8TByPmOrQ+gMAIIaoMyZZvfiNw4po8E/dT9novu62c=; b=A25fG6PId2B6nwDtMnvawUaaTLhcRTGYoUkAeypqaZbKso93/mihPwBx kDKSpdeLCor/aL6ryPOPQQ3P8pYlUj2nZxP7OJQtxT5gCaHNZGfz/exkN xCP+dOkd1PaGRv5VS4NeVrGuLXOUjcSBpTQusvpRVQNG/QxMIPW7I2oWM JYirSHIeI5SCsyqpivT3H0R5VYqklDms5xsHB9cyofBGY9BaD0SrBlkGH f0qIghZHHU7BBNuST1+uNMwKuewdvG5Cegu2JllCpfCIhu9CLOr6lI/vL zGNC69M5YstUFYzim5MMPcjSAEFWW0HBHKycFF3Qmy9v4AyYfdSR7M6Q1 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153170" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153170" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116808" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116808" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 90163A1; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 01/15] auxdisplay: img-ascii-lcd: Make container_of() no-op for struct linedisp Date: Mon, 12 Feb 2024 19:01:34 +0200 Message-ID: <20240212170423.2860895-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move embedded struct linedisp member to make container_of() no-op. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/img-ascii-lcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-as= cii-lcd.c index 56efda0740fb..09014ada38bd 100644 --- a/drivers/auxdisplay/img-ascii-lcd.c +++ b/drivers/auxdisplay/img-ascii-lcd.c @@ -32,21 +32,21 @@ struct img_ascii_lcd_config { =20 /** * struct img_ascii_lcd_ctx - Private data structure + * @linedisp: line display structure * @base: the base address of the LCD registers * @regmap: the regmap through which LCD registers are accessed * @offset: the offset within regmap to the start of the LCD registers * @cfg: pointer to the LCD model configuration - * @linedisp: line display structure * @curr: the string currently displayed on the LCD */ struct img_ascii_lcd_ctx { + struct linedisp linedisp; union { void __iomem *base; struct regmap *regmap; }; u32 offset; const struct img_ascii_lcd_config *cfg; - struct linedisp linedisp; char curr[] __aligned(8); }; =20 --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED4723FB31; Mon, 12 Feb 2024 17:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757490; cv=none; b=HaSzRab7KNrFVYTNBAp7gYOtcBbn1F/CzvxApm56yxtsCwrz5zMP8pOJC177DZDgmmFZx6QKLK+8XvRWuLBb5SBLNba0+qtqFPLKLls4LV/Dp96geNj6O/LLWhTUwXKIpe7cY4uAualE2iJ627OqPhtqJGxtgTXfhvnTmk78ia4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757490; c=relaxed/simple; bh=HmO8BJAxHzacI5yK10Y9+ofU0L21g/VbhUyc1S5/3jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BmRvP4d7/vNvkSY7QMUGt2NJoScmwgAFzKmu+cr2La6+7KO2EqXYE4RXmSrpM98yKCaHEa3ixijaSTzLxN7H38GmoAZW+jjvGgEc7cDgl4bASksc/0FP0gqUmNhu2NpzBOHQNb53WHf3Lc+tXutT5uUEYclUD0EjGu94oQSMrEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ketLq/a3; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ketLq/a3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757489; x=1739293489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmO8BJAxHzacI5yK10Y9+ofU0L21g/VbhUyc1S5/3jg=; b=ketLq/a3NPAg1xAn5daJ/9KyKS+d1J/OMYrQYZdJmj59VunTrr7S50GG TCe/ro6R4Yt09v8Ox6OnMr2b2sLneIN1BPquKEmooy5mizmA+MkIwdpzs BuQumifUNwpUhY0W1RfmrBmV5eMKUiPdxH8V6WJFWUJZJ8McTXKS5XPuU ntYYZyCOUS52IZEDiPOOsWkfPvp0bws63q09qQznNxTK2jt0y69Mh/RmF vO7Jn1cn236B68xSgkzQ3USBn8FRr9Rf2VUS7ifIpNh79ODsdK+5CZYKu sCaf1lBT/Aa8KGRL/yf5sEg4+yWMkHLEUAANfodTwtzLztUPz6Pd94MKh A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153175" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153175" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116811" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116811" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 99AF2FB; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 02/15] auxdisplay: linedisp: Free allocated resources in ->release() Date: Mon, 12 Feb 2024 19:01:35 +0200 Message-ID: <20240212170423.2860895-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While there is no issue currently with the resources allocation, the code may still be made more robust by deallocating message in the ->release() callback. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/line-display.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 03e7f104aa1a..310e9bfb41ae 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -188,8 +188,16 @@ static struct attribute *linedisp_attrs[] =3D { }; ATTRIBUTE_GROUPS(linedisp); =20 +static void linedisp_release(struct device *dev) +{ + struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); + + kfree(linedisp->message); +} + static const struct device_type linedisp_type =3D { .groups =3D linedisp_groups, + .release =3D linedisp_release, }; =20 /** @@ -253,7 +261,6 @@ void linedisp_unregister(struct linedisp *linedisp) { device_del(&linedisp->dev); del_timer_sync(&linedisp->timer); - kfree(linedisp->message); put_device(&linedisp->dev); } EXPORT_SYMBOL_GPL(linedisp_unregister); --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 320323FE22; Mon, 12 Feb 2024 17:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757491; cv=none; b=jq9dp7Qt92Po8mQk8FqgWD78dkEer0WtsgPZxIjwHACfS8tjcGkY2vgJba59xMtPV4lX6qXA/fJwEal17yKLhZUJk73dSo89R49qgzmf/3+ORcgP3OUZv3bjuQkIK72V4//LAe0hMzc0nPWqZIozmON61oqP2K1rOhuD9rmGcBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757491; c=relaxed/simple; bh=LvC0jNLSvlISq+pfX0tunOut+CloWPeckMMVxbBHVes=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V3rgEtMKZuVG/l5tR9dhdb1uuJ1DH+cASQn/oUGg4/uL1mAQ8Ii0HUanVAAFe279TkNjOlBHAKvY+D+uZ2+TzNCS3R2BqBMA9ma9OmELGB2YLM69Jq4x2HMvkQgvu9QTcYPs8KeQN6+F+h2XBk+ksewdIzF5FYuyGoyb6nszi2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LynqWGE8; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LynqWGE8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757491; x=1739293491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LvC0jNLSvlISq+pfX0tunOut+CloWPeckMMVxbBHVes=; b=LynqWGE8tHLRz/g63tYhFPvqI082pSK9xAdvxatg9Rpw86Cpf/Rz5+Ng 75UUJhizNmy4peZTrH38RDKpuf/emAp+SU9YJCBiN3QA3z0/o/whpNBmK zhrMUHvgd59yf3EoEyQ3sg07xbv6SaIbWoVcUOFhnArn9jfb4Fi9u+iEw HNijb5arUW0Gs8PW5XsmfxKnXYgqIW7vevqruwHSLTOoKcnRWi7gmT7Sv /QYkGczvfRbrjE1gApJRx2evkaUNZ2fB7BXlPYiQOZgCPFRbz2xInuEJw lFMRY6jiuUOvjs1mIPgrlgnXPnR1fxQvfKef1H+29xrmOlNTf//7DUQMR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153187" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153187" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116809" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116809" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A9268138; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 03/15] auxdisplay: linedisp: Use unique number for id Date: Mon, 12 Feb 2024 19:01:36 +0200 Message-ID: <20240212170423.2860895-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The absence of decrementation of linedisp_id is incorrect in two ways, i.e. it may cause: - an ID exhaustion - (and if the above is addressed) a duplicate id number may be allocated next time a device is added Replace above mentioned approach by using IDA framework. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/line-display.c | 13 ++++++++++--- drivers/auxdisplay/line-display.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 310e9bfb41ae..c4dbb13293d1 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -11,6 +11,7 @@ #include =20 #include +#include #include #include #include @@ -188,11 +189,14 @@ static struct attribute *linedisp_attrs[] =3D { }; ATTRIBUTE_GROUPS(linedisp); =20 +static DEFINE_IDA(linedisp_id); + static void linedisp_release(struct device *dev) { struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); =20 kfree(linedisp->message); + ida_free(&linedisp_id, linedisp->id); } =20 static const struct device_type linedisp_type =3D { @@ -214,7 +218,6 @@ int linedisp_register(struct linedisp *linedisp, struct= device *parent, unsigned int num_chars, char *buf, void (*update)(struct linedisp *linedisp)) { - static atomic_t linedisp_id =3D ATOMIC_INIT(-1); int err; =20 memset(linedisp, 0, sizeof(*linedisp)); @@ -225,9 +228,13 @@ int linedisp_register(struct linedisp *linedisp, struc= t device *parent, linedisp->num_chars =3D num_chars; linedisp->scroll_rate =3D DEFAULT_SCROLL_RATE; =20 + err =3D ida_alloc(&linedisp_id, GFP_KERNEL); + if (err < 0) + return err; + linedisp->id =3D err; + device_initialize(&linedisp->dev); - dev_set_name(&linedisp->dev, "linedisp.%lu", - (unsigned long)atomic_inc_return(&linedisp_id)); + dev_set_name(&linedisp->dev, "linedisp.%u", linedisp->id); =20 /* initialise a timer for scrolling the message */ timer_setup(&linedisp->timer, linedisp_scroll, 0); diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-di= splay.h index 0f5891d34c48..1fbe57fdc4cb 100644 --- a/drivers/auxdisplay/line-display.h +++ b/drivers/auxdisplay/line-display.h @@ -14,6 +14,7 @@ /** * struct linedisp - character line display private data structure * @dev: the line display device + * @id: instance id of this display * @timer: timer used to implement scrolling * @update: function called to update the display * @buf: pointer to the buffer for the string currently displayed @@ -25,6 +26,7 @@ */ struct linedisp { struct device dev; + unsigned int id; struct timer_list timer; void (*update)(struct linedisp *linedisp); char *buf; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 552C83FE2B; Mon, 12 Feb 2024 17:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757492; cv=none; b=RXFvdjon08wvdcmCjKlG4ZcdGuR63rs74Jcivm8P0q2gFVhb6xIb2WJ2y2L8enFYdtbRtN2agmYy5SpnRS+PmD86qfUdu0+XA+gr0Rs7dkcq09+WH0JWmpZIIcETLCRiPnnzC0QYvdJPNA6GJr/UXqaocSwUXhrED82nxb2uQbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757492; c=relaxed/simple; bh=2toHElackSZZyXwXNBaTI+oFom4ViAe7S5c8+PQ2aGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XC5Lp2SnyMqAmVACPOWafl+8lDQwZczWk9kD9mH0nDd3ZAoDoAOZTAco+f74XJRe4aVQpEqoFCWrLs10xud/Bhk/9GFgRlsPAKx10iOt4zUoJTUM7jkEVKOUP35wjxOlvnz5n+7Fg5viZMXwyxOnFGvUyCANZ4RhRL7RmG4+2cY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eTZdTodF; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eTZdTodF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757491; x=1739293491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2toHElackSZZyXwXNBaTI+oFom4ViAe7S5c8+PQ2aGc=; b=eTZdTodFSzzrKE3Dyd7YeTDByOHRyfJETBTUSYKLuwXoHslyTZpdaMjC cZozG2DjeYxWceIDlYUXx35BHDY3X1cavzsa0wA9iCSbjkVacZCM11Fkg vSkUgJUmE7Imv+9ZWT/Zq902wVtzU2vLRyhl7xFnkGsrxakNhRy3esAKJ /dOXu0+/7Kpl83WCrdLbXTBtBUuPsSPW6WC/GOSuu11G5x9JyAOKpObh6 aL4Pv/Nw2u+hD/1FdkQLR7+VryVKcpRb0y2hRqdm058d5T17lFsgRoUSN xQI2rE9wmSVSsDWzlbcithvfTDnLEDGw4+9nwciuOkgmBzPgPT1XNgioW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153181" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153181" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116810" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116810" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AF1E911D; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 04/15] auxdisplay: linedisp: Unshadow error codes in ->store() Date: Mon, 12 Feb 2024 19:01:37 +0200 Message-ID: <20240212170423.2860895-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" kstrtox() may return different error codes. Unshadow them in the ->store() callback to give better error report. While at it, add missing kstrtox.h inclusion. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/line-display.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index c4dbb13293d1..8d91c2099661 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -12,6 +12,7 @@ =20 #include #include +#include #include #include #include @@ -166,9 +167,11 @@ static ssize_t scroll_step_ms_store(struct device *dev, { struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); unsigned int ms; + int err; =20 - if (kstrtouint(buf, 10, &ms) !=3D 0) - return -EINVAL; + err =3D kstrtouint(buf, 10, &ms); + if (err) + return err; =20 linedisp->scroll_rate =3D msecs_to_jiffies(ms); if (linedisp->message && linedisp->message_len > linedisp->num_chars) { --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6D3D41764; Mon, 12 Feb 2024 17:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757493; cv=none; b=MqpjZZ7pQklLXUzOhzPCxmkSVlS2EF77AyKtlYG4gYEk8IQCtOUYbfjPfNXmNHSdEsGXYwXjzPOhLMIcObFcHPCxB0N8qy/A+4xHUpjH59dSRQu4ltw8p+dx50QmffPgGC+pAMtdplBXdQP+SP+/z8hFMdr5fVA2XHvAESHNYh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757493; c=relaxed/simple; bh=T7Mp/G619hZCfbmKq4sfu5Mlrc26ZVC0R/tzaJ91tuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l3OVrSN71A1yvjODEQu3A/jmRgZe4TRmCjBdD5c3vFG28wyhET9tFLU4JN2Tnp0Giw9/9nGomXSvqsjXxP7mnlry4rmPZdKprHC1apBiPoO5ZqGQC1WNNFjly9KB6OOazYC2Q54wPcIDH+1eP0Wh+Gu3JHoG7aRX1WeNuXWjhcQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=d6CtesN0; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="d6CtesN0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757492; x=1739293492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T7Mp/G619hZCfbmKq4sfu5Mlrc26ZVC0R/tzaJ91tuc=; b=d6CtesN0w0FZKj1ZTZ9lc+9xsf/dP8IlKvnpU3iVmD/ML9Cduz/Ao7jp gLTuodxN4MJU6rhhltsdvsI7ipBaL6FvoQ6Rgq6n0x3JSJ+k66WZZIrF/ wVwjc6NWLN/B89lHZCxWtew1LpsDnw08xIrZiCTj/Y+vlaYfLdeGWLP7d ZCuQ8fRXv5+tFNq8/AF1y+o+zqY8dpq35c9/7zsAw/zgxrrRS5o/pvyR8 TXYnGMjDxa4Qcs8SbhoumGG5RoPPxKjdamaHCcA4PnDha8+0S1NKzUB3q 28eRQ7UIaHHEeKwb66tntCg9/BNDjgfLBV247Td3y6MkhbXaRm7Tf2I8d Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153201" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153201" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116820" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116820" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:46 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C465D204; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 05/15] auxdisplay: linedisp: Add missing header(s) Date: Mon, 12 Feb 2024 19:01:38 +0200 Message-ID: <20240212170423.2860895-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Do not imply that some of the generic headers may be always included. Instead, include explicitly what we are direct user of. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/line-display.c | 3 +++ drivers/auxdisplay/line-display.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 8d91c2099661..a0339e4b5939 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -10,8 +10,11 @@ =20 #include =20 +#include #include +#include #include +#include #include #include #include diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-di= splay.h index 1fbe57fdc4cb..d72c1899dc50 100644 --- a/drivers/auxdisplay/line-display.h +++ b/drivers/auxdisplay/line-display.h @@ -11,6 +11,9 @@ #ifndef _LINEDISP_H #define _LINEDISP_H =20 +#include +#include + /** * struct linedisp - character line display private data structure * @dev: the line display device --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F7A84653A; Mon, 12 Feb 2024 17:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757495; cv=none; b=mZBMIZptXxtkX9hBEgwqtWxYVgNtRPn/AN9lBvMnRTGvLcnib7rvdW6z3ECaE9eWve6239WeW8cx6Zg2nIIH4J7s04FbXZXn1m4DPO6RYO8kXQkyZlOmCaRLT6nY3Z68nECqRcTbm3AcsMUfq6AhoGiG40k30fo6pmDL4/t4VE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757495; c=relaxed/simple; bh=bXuKJcg7HA+0Vb4HJgUnDZd4G/OsktT5Y7OPT252SMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p5EhPTuapfMLiGazIAo44BD0LSOtSyyVca7OMkHtZZ0k1udGVMA97uyIB2Z4/BCVUetKHSTvOe+syNGPq3vPf7r5fZbT76qk+KMBxrDymnnHM6MyIHNiB5GWFrNwL/Tth8xzdjz9orYPVNy2qEc8BSC8dJ6znURRUxwdVMT2VD8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HdbcK+O3; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HdbcK+O3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757494; x=1739293494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bXuKJcg7HA+0Vb4HJgUnDZd4G/OsktT5Y7OPT252SMI=; b=HdbcK+O3YVj012egshvSaE2a5sx00TXMmyLj4CCAeJKIEyuenFrfwD4G 4EIPQ1/157D3F6lywrt4DAya+0UxKk4eGLfLaI6G4TNTO3t8L7/UFghou sBLQa7TAZ9eHrLzx/n++kTf9DJsg8LT8mlqDdqMNFnvzcsAfOGVqp9jQd GoHcEXU/ozV01DXb18qAZ4chlN5zJi7kxptxZz33ROrw4lgj96eNmfLl9 emWaAnFfuS6o8YLrjCQbo1LsFAf0PeNLb7FqeTXZYzCe+u/XJs7KtpH4J KhOd+DTEpMjg9L2G2RsmoZZ1vN21gbpN/z0ugsHaOTiaZVlyi3kpeejyt w==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153214" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153214" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116821" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116821" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id CFD172DC; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 06/15] auxdisplay: linedisp: Move exported symbols to a namespace Date: Mon, 12 Feb 2024 19:01:39 +0200 Message-ID: <20240212170423.2860895-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Avoid unnecessary pollution of the global symbol namespace by moving library functions in to a specific namespace and import that into the drivers that make use of the functions. For more info: https://lwn.net/Articles/760045/ Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/ht16k33.c | 1 + drivers/auxdisplay/img-ascii-lcd.c | 1 + drivers/auxdisplay/line-display.c | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index a90430b7d07b..c6a42c5c128f 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -831,4 +831,5 @@ module_i2c_driver(ht16k33_driver); =20 MODULE_DESCRIPTION("Holtek HT16K33 driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(LINEDISP); MODULE_AUTHOR("Robin van der Gracht "); diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-as= cii-lcd.c index 09014ada38bd..c571e54d9eb5 100644 --- a/drivers/auxdisplay/img-ascii-lcd.c +++ b/drivers/auxdisplay/img-ascii-lcd.c @@ -298,3 +298,4 @@ module_platform_driver(img_ascii_lcd_driver); MODULE_DESCRIPTION("Imagination Technologies ASCII LCD Display"); MODULE_AUTHOR("Paul Burton "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(LINEDISP); diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index a0339e4b5939..8d0ebdf0f10d 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -263,7 +263,7 @@ int linedisp_register(struct linedisp *linedisp, struct= device *parent, put_device(&linedisp->dev); return err; } -EXPORT_SYMBOL_GPL(linedisp_register); +EXPORT_SYMBOL_NS_GPL(linedisp_register, LINEDISP); =20 /** * linedisp_unregister - unregister a character line display @@ -276,6 +276,6 @@ void linedisp_unregister(struct linedisp *linedisp) del_timer_sync(&linedisp->timer); put_device(&linedisp->dev); } -EXPORT_SYMBOL_GPL(linedisp_unregister); +EXPORT_SYMBOL_NS_GPL(linedisp_unregister, LINEDISP); =20 MODULE_LICENSE("GPL"); --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B4E34596E; Mon, 12 Feb 2024 17:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757494; cv=none; b=Kf2b5amUD3Wj6dby25Io0gbGmy9fzR1D5O7ZVG1TmerwFTIiR9S2v2jU4owar/uQ/MtwzCWQVgadlxM55k5xwNc9KBmYwnOoGJ4MKMaKAGSOSzhpbVQWkRJZhOI2ujcRsb+OgNEPaRKcinis0pjM7CPZsAGZ1ZpwnvE2VJwhIxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757494; c=relaxed/simple; bh=Fg8HFd6qXwgrRuKizTmdQy4zN2vPEsdI81OkVtdnatg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cPJPzsgZxMfoq78W8TUUy+ykAqnI01KpHuxCj+0H3E0BPaHWO8ZFEWWIf0uDgeY40wkiF/uss/XbeMkMiB7QKrlv6gQ7WPfHXwzGcVHHPRwdOgSOM8GrR74AAmuRefHSZaNwp5qBvfwzy+LDwTcPpTM411ljiOf43CA4hhV76S8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=k8LV/yz1; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="k8LV/yz1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757493; x=1739293493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fg8HFd6qXwgrRuKizTmdQy4zN2vPEsdI81OkVtdnatg=; b=k8LV/yz1igpk/NVNBVSN4fCFBVSqRaVN/juIR0QuYKCVW4xKWBJ3CEXD 20DJ8tplemiltLzATsTcCrVfMh9lDwfp75cDsZ+pQpfLG6HqdNSy7AZt5 5vmhKZmqk0dJ0ZV7zCy8xFpRJBLCFqOM6KjKl9PkY338cpB5xhgflRx6X p0bRRu/ex+PjWsc7mD4e9RUeOM6RgfgwVcS7PitOnntIgkhLI5XsS5gpD NRacAxSe5XC4AxJaqBbcmVWPiP6l8ZePq5Tv2ehr4iRpsdwA4v9pETUwh /3O5n6C51QpfD7fsHO6hUxXxWBqfe8A66cKpLMViBnYtYPAKLUOAYeurO Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153215" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153215" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116825" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116825" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D5900161; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 07/15] auxdisplay: linedisp: Group line display drivers together Date: Mon, 12 Feb 2024 19:01:40 +0200 Message-ID: <20240212170423.2860895-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For better usability group the line display drivers together in Kconfig and Makefile. Signed-off-by: Andy Shevchenko Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/Kconfig | 32 ++++++++++++++++---------------- drivers/auxdisplay/Makefile | 12 ++++++------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig index d944d5298eca..a34a9a52158f 100644 --- a/drivers/auxdisplay/Kconfig +++ b/drivers/auxdisplay/Kconfig @@ -25,12 +25,6 @@ config CHARLCD This is some character LCD core interface that multiple drivers can use. =20 -config LINEDISP - tristate "Character line display core support" if COMPILE_TEST - help - This is the core support for single-line character displays, to be - selected by drivers that use it. - config HD44780_COMMON tristate "Common functions for HD44780 (and compatibles) LCD displays" if= COMPILE_TEST select CHARLCD @@ -52,6 +46,16 @@ config HD44780 kernel and started at boot. If you don't understand what all this is about, say N. =20 +config LCD2S + tristate "lcd2s 20x4 character display over I2C console" + depends on I2C + select CHARLCD + help + This is a driver that lets you use the lcd2s 20x4 character display + from Modtronix engineering as a console output device. The display + is a simple single color character display. You have to connect it + to an I2C bus. + config KS0108 tristate "KS0108 LCD Controller" depends on PARPORT_PC @@ -153,6 +157,12 @@ config CFAG12864B_RATE If you compile this as a module, you can still override this value using the module parameters. =20 +config LINEDISP + tristate "Character line display core support" if COMPILE_TEST + help + This is the core support for single-line character displays, to be + selected by drivers that use it. + config IMG_ASCII_LCD tristate "Imagination Technologies ASCII LCD Display" depends on HAS_IOMEM @@ -177,16 +187,6 @@ config HT16K33 Say yes here to add support for Holtek HT16K33, RAM mapping 16*8 LED controller driver with keyscan. =20 -config LCD2S - tristate "lcd2s 20x4 character display over I2C console" - depends on I2C - select CHARLCD - help - This is a driver that lets you use the lcd2s 20x4 character display - from Modtronix engineering as a console output device. The display - is a simple single color character display. You have to connect it - to an I2C bus. - config ARM_CHARLCD bool "ARM Ltd. Character LCD Driver" depends on PLAT_VERSATILE diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile index 6968ed4d3f0a..43bad850481c 100644 --- a/drivers/auxdisplay/Makefile +++ b/drivers/auxdisplay/Makefile @@ -5,12 +5,12 @@ =20 obj-$(CONFIG_CHARLCD) +=3D charlcd.o obj-$(CONFIG_HD44780_COMMON) +=3D hd44780_common.o -obj-$(CONFIG_ARM_CHARLCD) +=3D arm-charlcd.o +obj-$(CONFIG_HD44780) +=3D hd44780.o +obj-$(CONFIG_LCD2S) +=3D lcd2s.o obj-$(CONFIG_KS0108) +=3D ks0108.o obj-$(CONFIG_CFAG12864B) +=3D cfag12864b.o cfag12864bfb.o -obj-$(CONFIG_IMG_ASCII_LCD) +=3D img-ascii-lcd.o -obj-$(CONFIG_HD44780) +=3D hd44780.o -obj-$(CONFIG_HT16K33) +=3D ht16k33.o -obj-$(CONFIG_PARPORT_PANEL) +=3D panel.o -obj-$(CONFIG_LCD2S) +=3D lcd2s.o obj-$(CONFIG_LINEDISP) +=3D line-display.o +obj-$(CONFIG_IMG_ASCII_LCD) +=3D img-ascii-lcd.o +obj-$(CONFIG_HT16K33) +=3D ht16k33.o +obj-$(CONFIG_ARM_CHARLCD) +=3D arm-charlcd.o +obj-$(CONFIG_PARPORT_PANEL) +=3D panel.o --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85D793FE36; Mon, 12 Feb 2024 17:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757492; cv=none; b=bXjA7I2DEop05XLOgMZkGKPsOgoYk6ZwPVrXvK0fO918Xj2VDr0VI85WTbe0isLPIyo4jC9l3gQW06C3/faRr1qEbPlqx8A7uBJhbr7jx9KMpPJ6eK4hStcMS85pJtdzGNIh2TRimpAkYlnjnuiQi/fWNEsuUhCGORah6aqXQp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757492; c=relaxed/simple; bh=uyaajfAMF51QUWBVV1UZLAXvVVvvLfZdmD+gVT959t8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c5m+cOnuGwQ1yQ9RTEIkf8Mo7POsrxWrs/moZYtcIjZDY1YDz/Sx4ddhq+SIo9hw8nt76D9si+86BgdmDYjJiJXBLDMTjzj6jCaXNqD/WXXOBpshYLKgMq5TSM8Psh3W/XNbzeHhtCrM2GE8wdLZD7s7J9EBJkuN0bOWM1EOmAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aRm/5VjL; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aRm/5VjL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757491; x=1739293491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uyaajfAMF51QUWBVV1UZLAXvVVvvLfZdmD+gVT959t8=; b=aRm/5VjLcCtVzx2QCZg7973t9CAySRaGwu8WBX3VgY7cNUbdh/MGjtSH U44i7ABXFiDUKhIUwYPmRlA5Xt46ry0fuCFUnpC9dWPN9yZ8akT6H73bf P1r7LQYFuUnKkBuE/KBRKgD+cY19cuRGDQG9MvYsseRBNYsLinHl+VigK AMv57aBF1dxcUt07EBe+KthOG573OuRZAyYJ2PrVhK5ax8pJ/8+KpNxWG E5kGGVObX8yKpPNv+AX74ONkvbS15VM0KkNydh1xqFobzlnFXUH3K4dif T9upXlgjDrLrf5YI93VdgW+/olfEDxSnEkgXI56QDIfAJpitb64nvTZap Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153194" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153194" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116823" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116823" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E585D31D; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 08/15] auxdisplay: linedisp: Provide struct linedisp_ops for future extension Date: Mon, 12 Feb 2024 19:01:41 +0200 Message-ID: <20240212170423.2860895-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently the line display library doesn't scale in case we want to provide more operations. Prepare the library to take a newly created struct linedisp_ops that scales. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/ht16k33.c | 7 +++++-- drivers/auxdisplay/img-ascii-lcd.c | 19 ++++++++++++------- drivers/auxdisplay/line-display.c | 11 +++++------ drivers/auxdisplay/line-display.h | 17 +++++++++++++---- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index c6a42c5c128f..0cdf3fbdf81e 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -448,6 +448,10 @@ static void ht16k33_linedisp_update(struct linedisp *l= inedisp) schedule_delayed_work(&priv->work, 0); } =20 +static const struct linedisp_ops ht16k33_linedisp_ops =3D { + .update =3D ht16k33_linedisp_update, +}; + static void ht16k33_seg7_update(struct work_struct *work) { struct ht16k33_priv *priv =3D container_of(work, struct ht16k33_priv, @@ -696,8 +700,7 @@ static int ht16k33_seg_probe(struct device *dev, struct= ht16k33_priv *priv, if (err) return err; =20 - err =3D linedisp_register(&seg->linedisp, dev, 4, seg->curr, - ht16k33_linedisp_update); + err =3D linedisp_register(&seg->linedisp, dev, 4, seg->curr, &ht16k33_lin= edisp_ops); if (err) goto err_remove_map_file; =20 diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-as= cii-lcd.c index c571e54d9eb5..c0ec7d9a1c62 100644 --- a/drivers/auxdisplay/img-ascii-lcd.c +++ b/drivers/auxdisplay/img-ascii-lcd.c @@ -22,12 +22,12 @@ struct img_ascii_lcd_ctx; * struct img_ascii_lcd_config - Configuration information about an LCD mo= del * @num_chars: the number of characters the LCD can display * @external_regmap: true if registers are in a system controller, else fa= lse - * @update: function called to update the LCD + * @ops: character line display operations */ struct img_ascii_lcd_config { unsigned int num_chars; bool external_regmap; - void (*update)(struct linedisp *linedisp); + const struct linedisp_ops ops; }; =20 /** @@ -75,7 +75,9 @@ static void boston_update(struct linedisp *linedisp) =20 static struct img_ascii_lcd_config boston_config =3D { .num_chars =3D 8, - .update =3D boston_update, + .ops =3D { + .update =3D boston_update, + }, }; =20 /* @@ -103,7 +105,9 @@ static void malta_update(struct linedisp *linedisp) static struct img_ascii_lcd_config malta_config =3D { .num_chars =3D 8, .external_regmap =3D true, - .update =3D malta_update, + .ops =3D { + .update =3D malta_update, + }, }; =20 /* @@ -203,7 +207,9 @@ static void sead3_update(struct linedisp *linedisp) static struct img_ascii_lcd_config sead3_config =3D { .num_chars =3D 16, .external_regmap =3D true, - .update =3D sead3_update, + .ops =3D { + .update =3D sead3_update, + }, }; =20 static const struct of_device_id img_ascii_lcd_matches[] =3D { @@ -247,8 +253,7 @@ static int img_ascii_lcd_probe(struct platform_device *= pdev) return PTR_ERR(ctx->base); } =20 - err =3D linedisp_register(&ctx->linedisp, dev, cfg->num_chars, ctx->curr, - cfg->update); + err =3D linedisp_register(&ctx->linedisp, dev, cfg->num_chars, ctx->curr,= &cfg->ops); if (err) return err; =20 diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 8d0ebdf0f10d..6453a62f653f 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -50,7 +50,7 @@ static void linedisp_scroll(struct timer_list *t) } =20 /* update the display */ - linedisp->update(linedisp); + linedisp->ops->update(linedisp); =20 /* move on to the next character */ linedisp->scroll_pos++; @@ -94,7 +94,7 @@ static int linedisp_display(struct linedisp *linedisp, co= nst char *msg, linedisp->message =3D NULL; linedisp->message_len =3D 0; memset(linedisp->buf, ' ', linedisp->num_chars); - linedisp->update(linedisp); + linedisp->ops->update(linedisp); return 0; } =20 @@ -216,20 +216,19 @@ static const struct device_type linedisp_type =3D { * @parent: parent device * @num_chars: the number of characters that can be displayed * @buf: pointer to a buffer that can hold @num_chars characters - * @update: Function called to update the display. This must not sleep! + * @ops: character line display operations * * Return: zero on success, else a negative error code. */ int linedisp_register(struct linedisp *linedisp, struct device *parent, - unsigned int num_chars, char *buf, - void (*update)(struct linedisp *linedisp)) + unsigned int num_chars, char *buf, const struct linedisp_ops *ops) { int err; =20 memset(linedisp, 0, sizeof(*linedisp)); linedisp->dev.parent =3D parent; linedisp->dev.type =3D &linedisp_type; - linedisp->update =3D update; + linedisp->ops =3D ops; linedisp->buf =3D buf; linedisp->num_chars =3D num_chars; linedisp->scroll_rate =3D DEFAULT_SCROLL_RATE; diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-di= splay.h index d72c1899dc50..a4f0d1bf5848 100644 --- a/drivers/auxdisplay/line-display.h +++ b/drivers/auxdisplay/line-display.h @@ -14,12 +14,22 @@ #include #include =20 +struct linedisp; + +/** + * struct linedisp_ops - character line display operations + * @update: Function called to update the display. This must not sleep! + */ +struct linedisp_ops { + void (*update)(struct linedisp *linedisp); +}; + /** * struct linedisp - character line display private data structure * @dev: the line display device * @id: instance id of this display * @timer: timer used to implement scrolling - * @update: function called to update the display + * @ops: character line display operations * @buf: pointer to the buffer for the string currently displayed * @message: the full message to display or scroll on the display * @num_chars: the number of characters that can be displayed @@ -31,7 +41,7 @@ struct linedisp { struct device dev; unsigned int id; struct timer_list timer; - void (*update)(struct linedisp *linedisp); + const struct linedisp_ops *ops; char *buf; char *message; unsigned int num_chars; @@ -41,8 +51,7 @@ struct linedisp { }; =20 int linedisp_register(struct linedisp *linedisp, struct device *parent, - unsigned int num_chars, char *buf, - void (*update)(struct linedisp *linedisp)); + unsigned int num_chars, char *buf, const struct linedisp_ops *ops); void linedisp_unregister(struct linedisp *linedisp); =20 #endif /* LINEDISP_H */ --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D7C144C8B; Mon, 12 Feb 2024 17:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757494; cv=none; b=oXblec86J2s7RDs3gAN9MTbfVoz/7qDQ0J9SqZ7y/BpCdqlzN3cdOC3IKg1CZA0MxjIWX2e5CenUwFzt82h6TGMgEPIU1LU6Mc3+kka653NNrSDuAQ5G4ZjTliGmnnPUyt3bqtsUjsqFKqfMfC2ZPunyWG3jZDXSTcHEp8ZFQO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757494; c=relaxed/simple; bh=Fh1FBaKJwc92BMrBFROUJ6kx0dRqre1zQ6DU0DmV0sM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PTnPdJo4r79Sl6czR0xWcWkCbtXDKOD+ULPCJp1+8FF4qlocTx/t02alf4QvxZDFGv8N9592oLZhr7M0OHBYDdzibK26AkOEukHZPWW2cPIeBTz8cSwiu33xOk4id2ERRof+ua7R0YozGoSWHzV6YDOqmQAisyk4VejJj3c5Ezs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ulhx/DSC; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ulhx/DSC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757493; x=1739293493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fh1FBaKJwc92BMrBFROUJ6kx0dRqre1zQ6DU0DmV0sM=; b=Ulhx/DSC7IviiklRrxduLsSeWQHWUfERlT99nvkfHZjZaktoPK7nbrL+ 1wKLEnTQ6P3PGUEIyVmDPyrcT2k8w15imKdBCPiLUmFhNknoiP2nmqVzl ssORgqN1clpfaKaGxJcyrx5MlhH+861RgYQLFDLlCT8DaktseY6M5soM/ 1fmTxceJ8tk8YLVvaC3hH969vhuieKg7GT/Wy+Oe0GGcf6loKMizeaMCo mvbUDexPCMuidKatHBvnVkIiUahogFLZ/Ak4oF73DmazvBHzt6q+8mgOm NwVfcdBTcPkw/C4BByTVGlRAIWU5e6uPvZeAu6aKoBWZYeo5P43GjKENA A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153204" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153204" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116824" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116824" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id F3653323; Mon, 12 Feb 2024 19:04:42 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 09/15] auxdisplay: linedisp: Add support for overriding character mapping Date: Mon, 12 Feb 2024 19:01:42 +0200 Message-ID: <20240212170423.2860895-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is already the driver using character mapping table for 7 or 14 segment display. It is possible to override it. Make the similar in the line display library to allow other drivers to utilise the same functionality. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/line-display.c | 111 +++++++++++++++++++++++++++++- drivers/auxdisplay/line-display.h | 31 +++++++++ 2 files changed, 140 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 6453a62f653f..75852ce6cc8d 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -22,6 +22,9 @@ #include #include =20 +#include +#include + #include "line-display.h" =20 #define DEFAULT_SCROLL_RATE (HZ / 2) @@ -188,12 +191,71 @@ static ssize_t scroll_step_ms_store(struct device *de= v, =20 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_map *map =3D linedisp->map; + + memcpy(buf, &map->map, map->size); + return map->size; +} + +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_map *map =3D linedisp->map; + + if (count !=3D map->size) + return -EINVAL; + + memcpy(&map->map, buf, count); + return count; +} + +static const SEG7_DEFAULT_MAP(initial_map_seg7); +static DEVICE_ATTR(map_seg7, 0644, map_seg_show, map_seg_store); + +static const SEG14_DEFAULT_MAP(initial_map_seg14); +static DEVICE_ATTR(map_seg14, 0644, map_seg_show, map_seg_store); + static struct attribute *linedisp_attrs[] =3D { &dev_attr_message.attr, &dev_attr_scroll_step_ms.attr, - NULL, + &dev_attr_map_seg7.attr, + &dev_attr_map_seg14.attr, + NULL }; -ATTRIBUTE_GROUPS(linedisp); + +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_map *map =3D linedisp->map; + umode_t mode =3D attr->mode; + + if (attr =3D=3D &dev_attr_map_seg7.attr) { + if (!map) + return 0; + if (map->type !=3D LINEDISP_MAP_SEG7) + return 0; + } + + if (attr =3D=3D &dev_attr_map_seg14.attr) { + if (!map) + return 0; + if (map->type !=3D LINEDISP_MAP_SEG14) + return 0; + } + + return mode; +}; + +static const struct attribute_group linedisp_group =3D { + .is_visible =3D linedisp_attr_is_visible, + .attrs =3D linedisp_attrs, +}; +__ATTRIBUTE_GROUPS(linedisp); =20 static DEFINE_IDA(linedisp_id); =20 @@ -201,6 +263,7 @@ static void linedisp_release(struct device *dev) { struct linedisp *linedisp =3D container_of(dev, struct linedisp, dev); =20 + kfree(linedisp->map); kfree(linedisp->message); ida_free(&linedisp_id, linedisp->id); } @@ -210,6 +273,44 @@ static const struct device_type linedisp_type =3D { .release =3D linedisp_release, }; =20 +static int linedisp_init_map(struct linedisp *linedisp) +{ + struct linedisp_map *map; + int err; + + if (!linedisp->ops->get_map_type) + return 0; + + err =3D linedisp->ops->get_map_type(linedisp); + if (err < 0) + return err; + + map =3D kmalloc(sizeof(*map), GFP_KERNEL); + if (!map) + return -ENOMEM; + + map->type =3D err; + + /* assign initial mapping */ + switch (map->type) { + case LINEDISP_MAP_SEG7: + map->map.seg7 =3D initial_map_seg7; + map->size =3D sizeof(map->map.seg7); + break; + case LINEDISP_MAP_SEG14: + map->map.seg14 =3D initial_map_seg14; + map->size =3D sizeof(map->map.seg14); + break; + default: + kfree(map); + return -EINVAL; + } + + linedisp->map =3D map; + + return 0; +} + /** * linedisp_register - register a character line display * @linedisp: pointer to character line display structure @@ -241,6 +342,11 @@ int linedisp_register(struct linedisp *linedisp, struc= t device *parent, device_initialize(&linedisp->dev); dev_set_name(&linedisp->dev, "linedisp.%u", linedisp->id); =20 + /* initialise a character mapping, if required */ + err =3D linedisp_init_map(linedisp); + if (err) + goto out_put_device; + /* initialise a timer for scrolling the message */ timer_setup(&linedisp->timer, linedisp_scroll, 0); =20 @@ -259,6 +365,7 @@ int linedisp_register(struct linedisp *linedisp, struct= device *parent, device_del(&linedisp->dev); out_del_timer: del_timer_sync(&linedisp->timer); +out_put_device: put_device(&linedisp->dev); return err; } diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-di= splay.h index a4f0d1bf5848..65d782111f53 100644 --- a/drivers/auxdisplay/line-display.h +++ b/drivers/auxdisplay/line-display.h @@ -14,13 +14,43 @@ #include #include =20 +#include +#include + struct linedisp; =20 +/** + * enum linedisp_map_type - type of the character mapping + * @LINEDISP_MAP_SEG7: Map characters to 7 segment display + * @LINEDISP_MAP_SEG14: Map characters to 14 segment display + */ +enum linedisp_map_type { + LINEDISP_MAP_SEG7, + LINEDISP_MAP_SEG14, +}; + +/** + * struct linedisp_map - character mapping + * @type: type of the character mapping + * @map: conversion character mapping + * @size: size of the @map + */ +struct linedisp_map { + enum linedisp_map_type type; + union { + struct seg7_conversion_map seg7; + struct seg14_conversion_map seg14; + } map; + unsigned int size; +}; + /** * struct linedisp_ops - character line display operations + * @get_map_type: Function called to get the character mapping, if required * @update: Function called to update the display. This must not sleep! */ struct linedisp_ops { + int (*get_map_type)(struct linedisp *linedisp); void (*update)(struct linedisp *linedisp); }; =20 @@ -42,6 +72,7 @@ struct linedisp { unsigned int id; struct timer_list timer; const struct linedisp_ops *ops; + struct linedisp_map *map; char *buf; char *message; unsigned int num_chars; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EF9F4776F; Mon, 12 Feb 2024 17:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757495; cv=none; b=ULi6FFrOfR9GFSzag23dPOiXfixjRfxqx4+hCQ0Gp7FkdOe2il8Y9poIS5fONSUhKz4z/b0nwIR8w/ZbLNxFim2K/+5oAF6Ei3gtMoGrTwwzlTBDdYQKpcYyCSD3Z+P/QoQpW5NreA+y3GClQjL+PlMR83hwBA5KBL/ytJbw9N4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757495; c=relaxed/simple; bh=bZSIwuNODdqGZ3IZxNzcIUdpLQwmXGNmwkHg29fDE5g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XHFvWHKHNGGAbRNiXhW2ikgGWD2gWighTwDq2L0m8N/ubwAefJ9Wi0webPARCg8evQHoQXz2F0Roz+NAZKFSYyLzNtTuLwSZT33XzyqMjUgqZzvBFHFUWoMm6bN/F1AGsn4fCEyp691wewp/5P8TnKtvbOD72j00qDN0HUDcBW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HLItknqn; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HLItknqn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757494; x=1739293494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bZSIwuNODdqGZ3IZxNzcIUdpLQwmXGNmwkHg29fDE5g=; b=HLItknqnrSl76axjDpRdgjb6axGJNLnDp0gr3Ewsuv8GeLOLJa+DFP4J KcvvdZ86Bx5BgbgAfmuYlU5scywnY2pSQLqYO9O8UscssSNo4hiF1sKBV yQEGbMszB09Hxv/Mk/DdE6wejlIaKfMfZcENr4Bpw7Pn6a8qJVT0BVLaQ udiylNtgX4wPyfDCjrt5eswjTY6vI4KnHXqftPEgpAULoypmqH802/dSW yD/6YLUTUTaaJVkRIEDyq6eyTugdDPTLhxvTeg/xeO8xD90FGa3YX43KN OTWop5xVGH7qI8ER7OfMm/0ByiX7exZw1v2f0FlC8kGoR1pvtrBXoB73I Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153224" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153224" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116826" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116826" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 09521338; Mon, 12 Feb 2024 19:04:43 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp Date: Mon, 12 Feb 2024 19:01:43 +0200 Message-ID: <20240212170423.2860895-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a driver that uses small buffer for the string, when we add a new one, we may avoid duplication and use one provided by the line display library. Allow user to skip buffer pointer when registering a device. Signed-off-by: Andy Shevchenko Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/line-display.c | 4 ++-- drivers/auxdisplay/line-display.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 75852ce6cc8d..d730cd0e1d03 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -330,8 +330,8 @@ int linedisp_register(struct linedisp *linedisp, struct= device *parent, linedisp->dev.parent =3D parent; linedisp->dev.type =3D &linedisp_type; linedisp->ops =3D ops; - linedisp->buf =3D buf; - linedisp->num_chars =3D num_chars; + linedisp->buf =3D buf ? buf : linedisp->curr; + linedisp->num_chars =3D buf ? num_chars : min(num_chars, LINEDISP_DEFAULT= _BUF_SZ); linedisp->scroll_rate =3D DEFAULT_SCROLL_RATE; =20 err =3D ida_alloc(&linedisp_id, GFP_KERNEL); diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-di= splay.h index 65d782111f53..4c354b8f376e 100644 --- a/drivers/auxdisplay/line-display.h +++ b/drivers/auxdisplay/line-display.h @@ -54,12 +54,15 @@ struct linedisp_ops { void (*update)(struct linedisp *linedisp); }; =20 +#define LINEDISP_DEFAULT_BUF_SZ 8u + /** * struct linedisp - character line display private data structure * @dev: the line display device * @id: instance id of this display * @timer: timer used to implement scrolling * @ops: character line display operations + * @curr: fallback buffer for the string * @buf: pointer to the buffer for the string currently displayed * @message: the full message to display or scroll on the display * @num_chars: the number of characters that can be displayed @@ -73,6 +76,7 @@ struct linedisp { struct timer_list timer; const struct linedisp_ops *ops; struct linedisp_map *map; + char curr[LINEDISP_DEFAULT_BUF_SZ]; char *buf; char *message; unsigned int num_chars; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 086A43DB91; Mon, 12 Feb 2024 17:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757497; cv=none; b=emhMFCdm18isDK02kWGD17nqNPez9GSf0HknpMlNr9WWWJEdu265Dyq5q75xteM7vzP8CkLvIIEV35p4efpa21/hPgZzaoVceim1K98/zhs4GsrUky3sNwGwUMp7Mr3CTuyi010mpgzPmv6gWPAzxv3yPtkFEI0JtAcROjYHToE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757497; c=relaxed/simple; bh=5fFTptxgaNSrb8/J39Uzrc6cETbfYvICnOp+m4GRuCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UCiUmE69CGr+BvVMdbEM1inc+R4bjYGmcawCJy8p9h+W96F5G4Q/6+drba/xaBIcjAozaxsDMHfPDsyKtI1xOiPKEgpse73RRsvd5JgvN0Oxl4BHUXrk7YZFbSY7b9Ee4QFvAApL2+qUiNpx/ib6JdPYME49QJBmlthIvRVb8sI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OMdePW/9; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OMdePW/9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757496; x=1739293496; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5fFTptxgaNSrb8/J39Uzrc6cETbfYvICnOp+m4GRuCg=; b=OMdePW/9xIUPxFEXT6IiC9GrQziBbcASWrlTI9YCtfoX3rlmZTNJe9px VzaEw9M2VITtJQREcA/wXVG2km9xXeXhUHJmaq5wqmf2Nm6F20ZV1Yz6c 9oqaPtcziIE6nCrU3cslbWhx+eXloZvftAOA7LHwroTZ70Qg2cly7paoK xPsJueaZP65fBzGXY8kwaY/rbGCXk1jLAlC/i2m4OGl6y5fZR5JJwXtrw +UbrZuG+Q30i7KOgzWu1a5/7Gt4EP5YC4je4BhE71dYKc9iALaB6scbXi o42UeBzo9Q8AG9OFKuA6eE7NnNHDKciiB1+6S8At5mwFvJ0ALY5h0/Rlx A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153235" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153235" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116828" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116828" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1402933F; Mon, 12 Feb 2024 19:04:43 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 11/15] auxdisplay: ht16k33: Move ht16k33_linedisp_ops down Date: Mon, 12 Feb 2024 19:01:44 +0200 Message-ID: <20240212170423.2860895-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We will need the update functions to be defined before ht16k33_linedisp_ops. Move the latter down in the code. No functional change intended. Signed-off-by: Andy Shevchenko Acked-by: Robin van der Gracht Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/ht16k33.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index 0cdf3fbdf81e..75c4a8d31642 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -440,18 +440,6 @@ static void ht16k33_keypad_stop(struct input_dev *dev) disable_irq(keypad->client->irq); } =20 -static void ht16k33_linedisp_update(struct linedisp *linedisp) -{ - struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv, - seg.linedisp); - - schedule_delayed_work(&priv->work, 0); -} - -static const struct linedisp_ops ht16k33_linedisp_ops =3D { - .update =3D ht16k33_linedisp_update, -}; - static void ht16k33_seg7_update(struct work_struct *work) { struct ht16k33_priv *priv =3D container_of(work, struct ht16k33_priv, @@ -489,6 +477,18 @@ static void ht16k33_seg14_update(struct work_struct *w= ork) i2c_smbus_write_i2c_block_data(priv->client, 0, ARRAY_SIZE(buf), buf); } =20 +static void ht16k33_linedisp_update(struct linedisp *linedisp) +{ + struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv, + seg.linedisp); + + schedule_delayed_work(&priv->work, 0); +} + +static const struct linedisp_ops ht16k33_linedisp_ops =3D { + .update =3D ht16k33_linedisp_update, +}; + static int ht16k33_led_probe(struct device *dev, struct led_classdev *led, unsigned int brightness) { --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4545E47793; Mon, 12 Feb 2024 17:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757496; cv=none; b=Cq+rPK2fEppPyo4gnRIS/KC4RnELlIVDcdNTb+9iQHbfRnAkIIBNYPA7qkTPd4m+3VdzuYiUQXK4Tcbu4In7Pvy9AimLGdkpb6Xth0517WEus5BiK1lVoo8g0MHg3WEkZKQCGbiqqdj8I13vnHBIehhl6XniYN2K8an/JZQ/GzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757496; c=relaxed/simple; bh=xY52GBdbWlUZAfmSG2absg3scItgooHoNN72W48Llrw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bkt5ZYeYzqONf3ZUx1eLIYCYwEvjnGWpXA62BYFuSiGIeBIbRcWZtEgkvlujPDcgOgLU+b3v4YIaLPxB4nn9m+zVB8EQmaoyqrkdCV9Rmvg2MmI2aEiO2D33LPM6exwM1vGSLSujgbM15bd+by+Ys5e6f5j1cX5uSjZaXvGgx1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GSDl3LmM; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GSDl3LmM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757495; x=1739293495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xY52GBdbWlUZAfmSG2absg3scItgooHoNN72W48Llrw=; b=GSDl3LmM6+cv41Xp6hUcfqali2NNwI4qJI0SQ6+oo7KSabB+tOvRTH9W IByvWEA+03xShtY6DFt0eWd+HgRleCegiqNsetdMgD4uOpaoA+zlbnph7 JKi0MzGKlbvffBx1M1Xk7Xr0HrsNVf1MBl9C9GBY/3+QXbK7YFqu9jgRQ XuMcFrZCvvI3Z5uHl15XdfqZ9XsJqVGlBoMw4S0vX0IH6idysI4aUW3fd WvSUrvgSLxBHgcKv6YDvhLPDS6+YeYM1HSKGqn1uSUe3Kss3u8/NLXHJr ZYzNGeMwuquH2mK2UUb09VwP6f6sTcX1gxHF7NcN/tiVJNycB7t0/nXxC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153225" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153225" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116827" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116827" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 25799430; Mon, 12 Feb 2024 19:04:43 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 12/15] auxdisplay: ht16k33: Switch to use line display character mapping Date: Mon, 12 Feb 2024 19:01:45 +0200 Message-ID: <20240212170423.2860895-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since line display library supports necessary bits to map the characters (if required), switch this driver to use that. Signed-off-by: Andy Shevchenko Acked-by: Robin van der Gracht Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/ht16k33.c | 109 +++++++++++------------------------ 1 file changed, 34 insertions(+), 75 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index 75c4a8d31642..b104f08252dd 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -87,11 +87,6 @@ struct ht16k33_fbdev { =20 struct ht16k33_seg { struct linedisp linedisp; - union { - struct seg7_conversion_map seg7; - struct seg14_conversion_map seg14; - } map; - unsigned int map_size; char curr[4]; }; =20 @@ -135,33 +130,6 @@ static const struct fb_var_screeninfo ht16k33_fb_var = =3D { .vmode =3D FB_VMODE_NONINTERLACED, }; =20 -static const SEG7_DEFAULT_MAP(initial_map_seg7); -static const SEG14_DEFAULT_MAP(initial_map_seg14); - -static ssize_t map_seg_show(struct device *dev, struct device_attribute *a= ttr, - char *buf) -{ - struct ht16k33_priv *priv =3D dev_get_drvdata(dev); - - memcpy(buf, &priv->seg.map, priv->seg.map_size); - return priv->seg.map_size; -} - -static ssize_t map_seg_store(struct device *dev, struct device_attribute *= attr, - const char *buf, size_t cnt) -{ - struct ht16k33_priv *priv =3D dev_get_drvdata(dev); - - if (cnt !=3D priv->seg.map_size) - return -EINVAL; - - memcpy(&priv->seg.map, buf, cnt); - return cnt; -} - -static DEVICE_ATTR(map_seg7, 0644, map_seg_show, map_seg_store); -static DEVICE_ATTR(map_seg14, 0644, map_seg_show, map_seg_store); - static int ht16k33_display_on(struct ht16k33_priv *priv) { uint8_t data =3D REG_DISPLAY_SETUP | REG_DISPLAY_SETUP_ON | priv->blink; @@ -445,18 +413,20 @@ static void ht16k33_seg7_update(struct work_struct *w= ork) struct ht16k33_priv *priv =3D container_of(work, struct ht16k33_priv, work.work); struct ht16k33_seg *seg =3D &priv->seg; + struct linedisp *linedisp =3D &seg->linedisp; + struct linedisp_map *map =3D linedisp->map; char *s =3D seg->curr; uint8_t buf[9]; =20 - buf[0] =3D map_to_seg7(&seg->map.seg7, *s++); + buf[0] =3D map_to_seg7(&map->map.seg7, *s++); buf[1] =3D 0; - buf[2] =3D map_to_seg7(&seg->map.seg7, *s++); + buf[2] =3D map_to_seg7(&map->map.seg7, *s++); buf[3] =3D 0; buf[4] =3D 0; buf[5] =3D 0; - buf[6] =3D map_to_seg7(&seg->map.seg7, *s++); + buf[6] =3D map_to_seg7(&map->map.seg7, *s++); buf[7] =3D 0; - buf[8] =3D map_to_seg7(&seg->map.seg7, *s++); + buf[8] =3D map_to_seg7(&map->map.seg7, *s++); =20 i2c_smbus_write_i2c_block_data(priv->client, 0, ARRAY_SIZE(buf), buf); } @@ -466,17 +436,39 @@ static void ht16k33_seg14_update(struct work_struct *= work) struct ht16k33_priv *priv =3D container_of(work, struct ht16k33_priv, work.work); struct ht16k33_seg *seg =3D &priv->seg; + struct linedisp *linedisp =3D &seg->linedisp; + struct linedisp_map *map =3D linedisp->map; char *s =3D seg->curr; uint8_t buf[8]; =20 - put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf); - put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf + 2); - put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf + 4); - put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf + 6); + put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 0); + put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 2); + put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 4); + put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 6); =20 i2c_smbus_write_i2c_block_data(priv->client, 0, ARRAY_SIZE(buf), buf); } =20 +static int ht16k33_linedisp_get_map_type(struct linedisp *linedisp) +{ + struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv, + seg.linedisp); + + switch (priv->type) { + case DISP_MATRIX: + /* not handled here */ + return -EINVAL; + + case DISP_QUAD_7SEG: + INIT_DELAYED_WORK(&priv->work, ht16k33_seg7_update); + return LINEDISP_MAP_SEG7; + + case DISP_QUAD_14SEG: + INIT_DELAYED_WORK(&priv->work, ht16k33_seg14_update); + return LINEDISP_MAP_SEG14; + } +} + static void ht16k33_linedisp_update(struct linedisp *linedisp) { struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv, @@ -486,6 +478,7 @@ static void ht16k33_linedisp_update(struct linedisp *li= nedisp) } =20 static const struct linedisp_ops ht16k33_linedisp_ops =3D { + .get_map_type =3D ht16k33_linedisp_get_map_type, .update =3D ht16k33_linedisp_update, }; =20 @@ -677,39 +670,7 @@ static int ht16k33_seg_probe(struct device *dev, struc= t ht16k33_priv *priv, if (err) return err; =20 - switch (priv->type) { - case DISP_MATRIX: - /* not handled here */ - err =3D -EINVAL; - break; - - case DISP_QUAD_7SEG: - INIT_DELAYED_WORK(&priv->work, ht16k33_seg7_update); - seg->map.seg7 =3D initial_map_seg7; - seg->map_size =3D sizeof(seg->map.seg7); - err =3D device_create_file(dev, &dev_attr_map_seg7); - break; - - case DISP_QUAD_14SEG: - INIT_DELAYED_WORK(&priv->work, ht16k33_seg14_update); - seg->map.seg14 =3D initial_map_seg14; - seg->map_size =3D sizeof(seg->map.seg14); - err =3D device_create_file(dev, &dev_attr_map_seg14); - break; - } - if (err) - return err; - - err =3D linedisp_register(&seg->linedisp, dev, 4, seg->curr, &ht16k33_lin= edisp_ops); - if (err) - goto err_remove_map_file; - - return 0; - -err_remove_map_file: - device_remove_file(dev, &dev_attr_map_seg7); - device_remove_file(dev, &dev_attr_map_seg14); - return err; + return linedisp_register(&seg->linedisp, dev, 4, seg->curr, &ht16k33_line= disp_ops); } =20 static int ht16k33_probe(struct i2c_client *client) @@ -794,8 +755,6 @@ static void ht16k33_remove(struct i2c_client *client) case DISP_QUAD_7SEG: case DISP_QUAD_14SEG: linedisp_unregister(&priv->seg.linedisp); - device_remove_file(&client->dev, &dev_attr_map_seg7); - device_remove_file(&client->dev, &dev_attr_map_seg14); break; } } --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B1C94652F; Mon, 12 Feb 2024 17:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757497; cv=none; b=NM9LT4YNTRxvuWAu4OEzUA/vf2yW6ccpSvEh5SKtuzn3Y6zGpLaYFxrxBhY2D9w/f2RflxYNIIIvxd2tfd7i25hglALZb4+KMBdNh4nKoyI6Gi6WALP8WFWhiJz05Ct8uh0VeVIZBUqUwyIi+rNFvIpyHlI1TA9kHOIldgr4b/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757497; c=relaxed/simple; bh=FH8g0LViq9a54GUNHUMfITSFf708fBC8temf69sHlcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J2pfmXLGIoC7faABCKtVhSAdu967XRpciEJIVTjai+/noiNNcyB/lWnkeuen9Di+V8IxMCyY0rMMo5ByxkPrNBoj5o5CDRFweuMN5BehyddRWdLSWoF4+MY+dx8NcExi+2NUnY5bHUcUZhcLwbG4GSH+T+VjbYATF5XGhD25nEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eiefn8T+; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eiefn8T+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757496; x=1739293496; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FH8g0LViq9a54GUNHUMfITSFf708fBC8temf69sHlcE=; b=eiefn8T+QGEnMSt+huirfFCg/ctPTp4hxasmG6N0LbQYFI9zNUCtzc0F yIYr8GWoArzdux6GbPZvRmWv7DCh1fjeeaofg6/h7mBrZ5kfYkYVKgBFC TnL5Bi+pSEv9qpt/27t1QYk8kCdGccELUHmOiPjODj/cKeTvgmYDkeWlB t/Ttfn+F+k6NiN44DRq3irsJuAbznV9onN8JRS7989RLaeRcgw7Xg/AWJ OgunsjGHV/fFQL08UWWdyRjSXSpAEKK+lnC5z2Nto7hDSwS+sRkMzCxq/ +//MlkA3ww6rEFKsAdab1tEu+Rjz/X8xhtMjNkVLmYbCBoh/butwMfrkb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153236" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153236" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116829" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116829" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3100243E; Mon, 12 Feb 2024 19:04:43 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 13/15] auxdisplay: ht16k33: Use buffer from struct linedisp Date: Mon, 12 Feb 2024 19:01:46 +0200 Message-ID: <20240212170423.2860895-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" struct linedips embedds a small buffer for the string that we may reuse. Update the driver accordingly. Signed-off-by: Andy Shevchenko Acked-by: Robin van der Gracht Reviewed-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/ht16k33.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index b104f08252dd..08cc05b9d216 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -85,11 +85,6 @@ struct ht16k33_fbdev { uint8_t *cache; }; =20 -struct ht16k33_seg { - struct linedisp linedisp; - char curr[4]; -}; - struct ht16k33_priv { struct i2c_client *client; struct delayed_work work; @@ -97,7 +92,7 @@ struct ht16k33_priv { struct ht16k33_keypad keypad; union { struct ht16k33_fbdev fbdev; - struct ht16k33_seg seg; + struct linedisp linedisp; }; enum display_type type; uint8_t blink; @@ -412,10 +407,9 @@ static void ht16k33_seg7_update(struct work_struct *wo= rk) { struct ht16k33_priv *priv =3D container_of(work, struct ht16k33_priv, work.work); - struct ht16k33_seg *seg =3D &priv->seg; - struct linedisp *linedisp =3D &seg->linedisp; + struct linedisp *linedisp =3D &priv->linedisp; struct linedisp_map *map =3D linedisp->map; - char *s =3D seg->curr; + char *s =3D linedisp->curr; uint8_t buf[9]; =20 buf[0] =3D map_to_seg7(&map->map.seg7, *s++); @@ -435,10 +429,9 @@ static void ht16k33_seg14_update(struct work_struct *w= ork) { struct ht16k33_priv *priv =3D container_of(work, struct ht16k33_priv, work.work); - struct ht16k33_seg *seg =3D &priv->seg; - struct linedisp *linedisp =3D &seg->linedisp; + struct linedisp *linedisp =3D &priv->linedisp; struct linedisp_map *map =3D linedisp->map; - char *s =3D seg->curr; + char *s =3D linedisp->curr; uint8_t buf[8]; =20 put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 0); @@ -451,8 +444,7 @@ static void ht16k33_seg14_update(struct work_struct *wo= rk) =20 static int ht16k33_linedisp_get_map_type(struct linedisp *linedisp) { - struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv, - seg.linedisp); + struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv,= linedisp); =20 switch (priv->type) { case DISP_MATRIX: @@ -471,8 +463,7 @@ static int ht16k33_linedisp_get_map_type(struct linedis= p *linedisp) =20 static void ht16k33_linedisp_update(struct linedisp *linedisp) { - struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv, - seg.linedisp); + struct ht16k33_priv *priv =3D container_of(linedisp, struct ht16k33_priv,= linedisp); =20 schedule_delayed_work(&priv->work, 0); } @@ -663,14 +654,13 @@ static int ht16k33_fbdev_probe(struct device *dev, st= ruct ht16k33_priv *priv, static int ht16k33_seg_probe(struct device *dev, struct ht16k33_priv *priv, uint32_t brightness) { - struct ht16k33_seg *seg =3D &priv->seg; int err; =20 err =3D ht16k33_brightness_set(priv, brightness); if (err) return err; =20 - return linedisp_register(&seg->linedisp, dev, 4, seg->curr, &ht16k33_line= disp_ops); + return linedisp_register(&priv->linedisp, dev, 4, NULL, &ht16k33_linedisp= _ops); } =20 static int ht16k33_probe(struct i2c_client *client) @@ -754,7 +744,7 @@ static void ht16k33_remove(struct i2c_client *client) =20 case DISP_QUAD_7SEG: case DISP_QUAD_14SEG: - linedisp_unregister(&priv->seg.linedisp); + linedisp_unregister(&priv->linedisp); break; } } --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 380C34B5CD; Mon, 12 Feb 2024 17:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757497; cv=none; b=i0FqaQ0AgzXbTJcqwchvCeC4tI1XglXk/VAKxAkJ4vleiYWo0qaUU/jagFkMuHDp300C4M3dhF5fwzlJVqnB+1YgV8NRmr2nHS8b5E1gTsr26RqkMCdmmzw2ibEknqy97in5lpOCTuYkXaAe3FUm3WgpCiocXFsD0n7KH3MZtTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757497; c=relaxed/simple; bh=xwQv8uq+9wANm7Kp3tnfC+qRvpRyTa5vpEt37Og3eA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PIX0GcXeT9uDXMJFLZ6r/PWJRukOnAGGOxdnMfFaCWlaqEMyHsJXSwdCPGQT6mmLZp6apuFRVYxUUahWb8J+RgX+k0quVIX8XvbjEH11P7oTGoj44EwobIzXEKN/9iTZ2oa19bh9r+OFib2wffUgKVR+2pgwG8kvsn9EJNbQQ7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=g8rB7BgP; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g8rB7BgP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757497; x=1739293497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xwQv8uq+9wANm7Kp3tnfC+qRvpRyTa5vpEt37Og3eA0=; b=g8rB7BgPxQR73EpAeiCZdrWaSuvI012tT7YtglB5iG3gDMbO4TZgAwu4 37mi5uUCy5F45WWniZZ+XFR58A84Skr/WCpzKs8jnoV+5kC1LwdWbgOqB 5y4L7Sz9nzOUDdOlbknHW6o1HLnOyN4VjYit0Ix6rglaOgXeoXHQGJnh4 mal66F23svj5MeAgMbrJ4IXDWLIzwxqIku196XGHBfBxaUi79wrELmU3Q mSxkpCREH2Y9ku4o3F59Fm8yTVmrgDKMS9mX24T2adQEaHNhiscQxXRbg HSH05FS8rSXVsgIRg9R6x1t9K012YjeUQUUBR5eSAl69G6qK41OJYfm0C A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153240" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153240" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116830" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116830" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:47 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 36C4F2E9; Mon, 12 Feb 2024 19:04:43 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 14/15] dt-bindings: auxdisplay: Add Maxim MAX6958/6959 Date: Mon, 12 Feb 2024 19:01:47 +0200 Message-ID: <20240212170423.2860895-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add initial device tree documentation for Maxim MAX6958/6959. Signed-off-by: Andy Shevchenko Reviewed-by: Krzysztof Kozlowski Tested-by: Geert Uytterhoeven --- .../bindings/auxdisplay/maxim,max6959.yaml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/auxdisplay/maxim,max6= 959.yaml diff --git a/Documentation/devicetree/bindings/auxdisplay/maxim,max6959.yam= l b/Documentation/devicetree/bindings/auxdisplay/maxim,max6959.yaml new file mode 100644 index 000000000000..49ce26176797 --- /dev/null +++ b/Documentation/devicetree/bindings/auxdisplay/maxim,max6959.yaml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/auxdisplay/maxim,max6959.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MAX6958/6959 7-segment LED display controller with keyscan + +maintainers: + - Andy Shevchenko + +properties: + compatible: + const: maxim,max6959 + + reg: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + max6959: max6959@38 { + compatible =3D "maxim,max6959"; + reg =3D <0x38>; + }; + }; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 04:56:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ABCD4CB55; Mon, 12 Feb 2024 17:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757499; cv=none; b=HjNE7/BbVJWdEYwiDb2hiV6l/VNgn3BLvCNPyiaDE4tTzN2kDjgQm/vVsbzIoz6hwDdfIk1qtAAW/NAtb8x6c/Zh7yEfderwT/lH95iMI6/Lnb7KZx4Pr2HNgW+12F5iymmzOs7fa7W9M9num+ksVsv5rHBn/vqFA7sTgmleGBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707757499; c=relaxed/simple; bh=v6wTWOcgnBbdVRVq0vTx2zi8kxA67Ld9K3m1TKyiM1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e0heQ/feYW9kg8ye6UedVXsu73+092ISBwrA8IocMr2Qj275NbJI47n7QtTQO0bo0cZuEZC9Y/5VPVOvM28s+1aA8cJJjI05zDezuy45PSvfunJUFEUf0CC7BNSkXArQt0KVGAkbWVp20W0d+vIEiqQhVb9l0Hmjg9MtgUyHMEQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mP440zFv; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mP440zFv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707757498; x=1739293498; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v6wTWOcgnBbdVRVq0vTx2zi8kxA67Ld9K3m1TKyiM1Q=; b=mP440zFvoBdSr7zyr+42Ec/IzOKZd6ODy1GFnvG+CYdtyOiPC4XhGE8G zM7WulTm8Olilx4PKWzfwG8+QYB1HlEkpYNMOGiqb/6YT/vako1ju1B1s qJl28oofdVrSEY8ftOMSmEqqQgxpaQDfgX7g+Sd3Bml5TJIjI8BVKTp+C SEEbLG1klni1GYnabCViX/Ya6JFjVU4dKQD2gsTBvJQ9eTPNO0x6/kqz0 dDMX+oCM7/0SFsOTMsd1eXus5UtGBILfFC1w9kq7n/1Ag1OYb0xRv4rlq UjNUUnE21mP6WlP0RLjrMUpB3cKqcBq3ufeKkwwOXcuZlzVS5Lw7pZeUM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19153247" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="19153247" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 09:04:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935116836" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="935116836" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 09:04:50 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4740C4E9; Mon, 12 Feb 2024 19:04:43 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v2 15/15] auxdisplay: Add driver for MAX695x 7-segment LED controllers Date: Mon, 12 Feb 2024 19:01:48 +0200 Message-ID: <20240212170423.2860895-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add initial driver for the MAX6958 and MAX6959 7-segment LED controllers. Signed-off-by: Andy Shevchenko Tested-by: Geert Uytterhoeven --- drivers/auxdisplay/Kconfig | 14 +++ drivers/auxdisplay/Makefile | 1 + drivers/auxdisplay/max6959.c | 200 +++++++++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 drivers/auxdisplay/max6959.c diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig index a34a9a52158f..079d58bb0293 100644 --- a/drivers/auxdisplay/Kconfig +++ b/drivers/auxdisplay/Kconfig @@ -187,6 +187,20 @@ config HT16K33 Say yes here to add support for Holtek HT16K33, RAM mapping 16*8 LED controller driver with keyscan. =20 +config MAX6959 + tristate "Maxim MAX6958/6959 7-segment LED controller with keyscan" + depends on I2C + select REGMAP_I2C + select LINEDISP + help + If you say yes here you get support for the following Maxim chips + (I2C 7-segment LED display controller with keyscan): + - MAX6958 + - MAX6959 (debounce support) + + This driver can also be built as a module. If so, the module + will be called max6959. + config ARM_CHARLCD bool "ARM Ltd. Character LCD Driver" depends on PLAT_VERSATILE diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile index 43bad850481c..f62a258809ef 100644 --- a/drivers/auxdisplay/Makefile +++ b/drivers/auxdisplay/Makefile @@ -12,5 +12,6 @@ obj-$(CONFIG_CFAG12864B) +=3D cfag12864b.o cfag12864bfb.o obj-$(CONFIG_LINEDISP) +=3D line-display.o obj-$(CONFIG_IMG_ASCII_LCD) +=3D img-ascii-lcd.o obj-$(CONFIG_HT16K33) +=3D ht16k33.o +obj-$(CONFIG_MAX6959) +=3D max6959.o obj-$(CONFIG_ARM_CHARLCD) +=3D arm-charlcd.o obj-$(CONFIG_PARPORT_PANEL) +=3D panel.o diff --git a/drivers/auxdisplay/max6959.c b/drivers/auxdisplay/max6959.c new file mode 100644 index 000000000000..0c5cbd16c3fe --- /dev/null +++ b/drivers/auxdisplay/max6959.c @@ -0,0 +1,200 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * MAX6958/6959 7-segment LED display controller with keyscan + * Datasheet: + * https://www.analog.com/media/en/technical-documentation/data-sheets/MAX= 6958-MAX6959.pdf + * + * Copyright (c) 2024, Intel Corporation. + * Author: Andy Shevchenko + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "line-display.h" + +/* Registers */ +#define REG_DECODE_MODE 0x01 +#define REG_INTENSITY 0x02 +#define REG_SCAN_LIMIT 0x03 +#define REG_CONFIGURATION 0x04 +#define REG_CONFIGURATION_S_BIT BIT(0) + +#define REG_DIGIT(x) (0x20 + (x)) +#define REG_DIGIT0 0x20 +#define REG_DIGIT1 0x21 +#define REG_DIGIT2 0x22 +#define REG_DIGIT3 0x23 + +#define REG_SEGMENTS 0x24 +#define REG_MAX REG_SEGMENTS + +/* Defines */ +#define MIN_BRIGHTNESS 0x01 +#define MAX_BRIGHTNESS 0x40 + +struct max6959_priv { + struct linedisp linedisp; + + struct delayed_work work; + + struct regmap *regmap; +}; + +static void max6959_disp_update(struct work_struct *work) +{ + struct max6959_priv *priv =3D container_of(work, struct max6959_priv, wor= k.work); + struct linedisp *linedisp =3D &priv->linedisp; + struct linedisp_map *map =3D linedisp->map; + char *s =3D linedisp->curr; + u8 buf[4]; + + /* Map segments according to datasheet */ + buf[0] =3D bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1; + buf[1] =3D bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1; + buf[2] =3D bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1; + buf[3] =3D bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1; + + regmap_bulk_write(priv->regmap, REG_DIGIT(0), buf, ARRAY_SIZE(buf)); +} + +static int max6959_linedisp_get_map_type(struct linedisp *linedisp) +{ + struct max6959_priv *priv =3D container_of(linedisp, struct max6959_priv,= linedisp); + + INIT_DELAYED_WORK(&priv->work, max6959_disp_update); + return LINEDISP_MAP_SEG7; +} + +static void max6959_linedisp_update(struct linedisp *linedisp) +{ + struct max6959_priv *priv =3D container_of(linedisp, struct max6959_priv,= linedisp); + + schedule_delayed_work(&priv->work, 0); +} + +static const struct linedisp_ops max6959_linedisp_ops =3D { + .get_map_type =3D max6959_linedisp_get_map_type, + .update =3D max6959_linedisp_update, +}; + +static int max6959_enable(struct max6959_priv *priv, bool enable) +{ + u8 mask =3D REG_CONFIGURATION_S_BIT; + u8 value =3D enable ? mask : 0; + + return regmap_update_bits(priv->regmap, REG_CONFIGURATION, mask, value); +} + +static void max6959_power_off(void *priv) +{ + max6959_enable(priv, false); +} + +static int max6959_power_on(struct max6959_priv *priv) +{ + struct device *dev =3D regmap_get_device(priv->regmap); + int ret; + + ret =3D max6959_enable(priv, true); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, max6959_power_off, priv); +} + +static const struct regmap_config max6959_regmap_config =3D { + .reg_bits =3D 8, + .val_bits =3D 8, + + .max_register =3D REG_MAX, + .cache_type =3D REGCACHE_MAPLE, +}; + +static int max6959_i2c_probe(struct i2c_client *client) +{ + struct device *dev =3D &client->dev; + struct max6959_priv *priv; + int ret; + + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->regmap =3D devm_regmap_init_i2c(client, &max6959_regmap_config); + if (IS_ERR(priv->regmap)) + return PTR_ERR(priv->regmap); + + ret =3D max6959_power_on(priv); + if (ret) + return ret; + + ret =3D linedisp_register(&priv->linedisp, dev, 4, NULL, &max6959_linedis= p_ops); + if (ret) + return ret; + + i2c_set_clientdata(client, priv); + + return 0; +} + +static void max6959_i2c_remove(struct i2c_client *client) +{ + struct max6959_priv *priv =3D i2c_get_clientdata(client); + + cancel_delayed_work_sync(&priv->work); + linedisp_unregister(&priv->linedisp); +} + +static int max6959_suspend(struct device *dev) +{ + return max6959_enable(dev_get_drvdata(dev), false); +} + +static int max6959_resume(struct device *dev) +{ + return max6959_enable(dev_get_drvdata(dev), true); +} + +static DEFINE_SIMPLE_DEV_PM_OPS(max6959_pm_ops, max6959_suspend, max6959_r= esume); + +static const struct i2c_device_id max6959_i2c_id[] =3D { + { "max6959" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, max6959_i2c_id); + +static const struct of_device_id max6959_of_table[] =3D { + { .compatible =3D "maxim,max6959" }, + { } +}; +MODULE_DEVICE_TABLE(of, max6959_of_table); + +static struct i2c_driver max6959_i2c_driver =3D { + .driver =3D { + .name =3D "max6959", + .pm =3D pm_sleep_ptr(&max6959_pm_ops), + .of_match_table =3D max6959_of_table, + }, + .probe =3D max6959_i2c_probe, + .remove =3D max6959_i2c_remove, + .id_table =3D max6959_i2c_id, +}; +module_i2c_driver(max6959_i2c_driver); + +MODULE_DESCRIPTION("MAX6958/6959 7-segment LED controller with keyscan"); +MODULE_AUTHOR("Andy Shevchenko "); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(LINEDISP); --=20 2.43.0.rc1.1.gbec44491f096