From nobody Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 94C6020312; Thu, 8 Feb 2024 18:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418167; cv=none; b=F+Sh6BKYu4owIl6z84ddJavJrfMrWgDiB71ijSfyJjIktUOP2njNiafbhUDZmL3b6yA7WaX9MptlqVsHMX5cGHRCjLZFQqFx30QL89CaRrgBnoxAzFqyhZ40nzvgvLlOjZt4hWNzWNWQhigbxWmvn9h7Rbf75K9M67BBzZqNCb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418167; c=relaxed/simple; bh=x8TByPmOrQ+gMAIIaoMyZZvfiNw4po8E/dT9novu62c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cps6cT+J0K/wvETvWfr04MugUYI9gHN9EdraRFydl8HKg7edAztRbODVjena8Rv1o6k6w9jEHPxShnEmC2e1Df9iAMPXp9vR8PtNui1Ozm1iDr5okN9jmOlqDb9G8qYieWsccWueCxGp1RLqBLQyzCTAC7z+9jFoHRCUaAuFUPA= 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=I17fLeB4; arc=none smtp.client-ip=192.198.163.19 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="I17fLeB4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418166; x=1738954166; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x8TByPmOrQ+gMAIIaoMyZZvfiNw4po8E/dT9novu62c=; b=I17fLeB4i0dgIctRhUkJ8acOI7nGvMioLkitbYgIJIR+njz8J79cchtW IEDMhF2NeQBsyIFCi+5nY43bHStTBuR8PGyZE7won5aqb8ROn4sc+rsGi 3d2kCEAvbdN8rIPPZC4/O3O6OcYi53ZXXDSWWyu1SeN0d7Z+aSUgMRsFT O7cNMaLf9n/Qd0yzJh6on7Y8yBvODDo9IhZD6zKRdb/ToqtHRgLF4ymE1 siGtMM5ZsA5+aUCfGT+bGu+5hHQXS82f1sKPbEEogbVJG9j+KfWRQv7IZ uTEbkgUDtyhJTgCMMdAS8ycTSzp5L67yPwRWI0rmXN9HqoLIGEggCHQcJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186079" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186079" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215511" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215511" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 37A626B; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 01/15] auxdisplay: img-ascii-lcd: Make container_of() no-op for struct linedisp Date: Thu, 8 Feb 2024 20:47:59 +0200 Message-ID: <20240208184919.2224986-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 54E2728699; Thu, 8 Feb 2024 18:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418171; cv=none; b=Zr5v2YUk3Co+3L/O8vg5bbEpg5ThLOVQpKZEdST3USMK/4OTKq3iLjGU+y55gqcf53tuLw0oUdoq7baXiZJMiwqvURXr5olSvNK8pRc0EBHq0Ty4Zzw/6rCNmtOcsVJsCBhwHMcW9yMtDFMYCxkMubZ8gcmSLWq/C+LKT8CDd00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418171; c=relaxed/simple; bh=HmO8BJAxHzacI5yK10Y9+ofU0L21g/VbhUyc1S5/3jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AU7KGpekw2luZvZiVoLSHvcyY4/aqdECwvfytXrbU8R7trXSVCPU67ZB2DfNn0/RS8y4QT86n89PytLlQIDTL2VXutD+b5uwoHkuukiuvgnmNpOCG3PMevmqJB1hnhqwsC9WZ1kCf/31kiJDH43zJynhffxyIRg5IOXj9S1I63Q= 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=Ull0gAfJ; arc=none smtp.client-ip=192.198.163.19 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="Ull0gAfJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418169; x=1738954169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmO8BJAxHzacI5yK10Y9+ofU0L21g/VbhUyc1S5/3jg=; b=Ull0gAfJM6EgYPO9Fzm1s1DlV/Yedc+qV8TUHOf3/0kHNSuFmqbkRCf1 9O3raJpxjc1cOZy1Ew66oYALq+f9taZwGKcj3lKUV6yOeawz7Qoh52FVU 2vrf0ZrT+hu1Cs8RSL+3TKGaJGPkpShX1A9KdqEZGrFzRBsKLbZVGZIw0 yq/PwwLadF8+pg7r80EFv6J4cUCriX+jKmYBGBEvWOgNlKtM5rVW4WYxl 2n92zBsj8GJ8ziBhvvjDgjRUwaIZ+4q+58iW4FMVMAtFCw2ij8EDRWqTO i0C84p6IanuwjNiYFyjSxg84i1YLOBe0rIha4t0buvSOffW7zCJSdh8B/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186100" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186100" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215516" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215516" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 44C0113C; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 02/15] auxdisplay: linedisp: Free allocated resources in ->release() Date: Thu, 8 Feb 2024 20:48:00 +0200 Message-ID: <20240208184919.2224986-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 220B623769; Thu, 8 Feb 2024 18:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418168; cv=none; b=aGc7zyBBlvUe82E9p5Yr2zEiJz2eQnT0Ygt/lzOVdDrPgpLBzgmVcMpU0Cr9037y8nV444XVxJWCWbEQuYb0tYOJRM+Iil79sxtheU3cm9EH82t5QE39uOYS5reaVfBwvdlP+4sZ1Wgs2EZeCRXdj8xsp4k4+JmmqCc+5AkroJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418168; c=relaxed/simple; bh=LvC0jNLSvlISq+pfX0tunOut+CloWPeckMMVxbBHVes=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NW7OmF4ZdehdFH0MJMKyW3tguaVVAxLTY8Dk+DgURLNK57nSvX6a1H0/24UJm22fXs3akQ65ArBxqdb73Sy8k7O93zRC6dfPkMT56l1SayOPsvsVD5J0zE6nirE/O6rfSazacGyVrXsOuyiVWQ/9yCOJ25ZKbF3p6p1fZBVB9e4= 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=RkEyE7SD; arc=none smtp.client-ip=192.198.163.19 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="RkEyE7SD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418167; x=1738954167; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LvC0jNLSvlISq+pfX0tunOut+CloWPeckMMVxbBHVes=; b=RkEyE7SD3POtTy8ltnwXMDkbN3t6HkF7H7CteCHFV0QDiyaVvoWNh+Zg yOqKbM0Evd631cDjzhLnLO2DX1YmhLsxoMTJW6o7FjRtXRY/u1yhCY6Sp yke4HE2BpZVmVZ7Qy+1X6qel5Rqc4mAcD7PWErK0cL5S5OQmk20R6n4Vm Y4iaBCs0Jnul1SY5Voyek9NaK7NXVAv25tfri+YQSpi6DCAEnlEwBMmNs zGhljZ4UQc0+xEnTDH/X1scevCCcZAhHUtwTI71SBRxLdvVZ17PrWhFva /2f0AvUIHwkYtR+iMNp7fc6wBUXCEAOarq1j7H1ksfDFKdJq/o9RB8RD6 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186082" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186082" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215512" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215512" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4D0DB1FF; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 03/15] auxdisplay: linedisp: Use unique number for id Date: Thu, 8 Feb 2024 20:48:01 +0200 Message-ID: <20240208184919.2224986-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 BD07F2556D; Thu, 8 Feb 2024 18:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418169; cv=none; b=QID3bS/xMfCKdIA+nzGefU7ztGzolgYpTx4eqTlltASIp/aVEVF63Kh4mNSVk+hmZHa3gxODpEtBcG2Rjwje1vNnHwcOQ8ayP8/5t+ne5Di//swgnJ5iuw1XovF/0Ln4u6BLbagPkCL6+3z95EpIHy0gsYNhVPUbtiamdpdcktg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418169; c=relaxed/simple; bh=xSKeAKNBA96roisQYOcxV4QilUZU+Ks7Czd6oPoWOHU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HcLMgYOJEkumR2LJj0R1iH1xrnNa2lAvOZ9ILp2CmefqAv5e5MZxV/yK5itE7YijORoMSemzfNIuik+hpWBCZnwH0hPyfrZ7bI+xtSWqmsZIHE6m3PgTC+nyz3dJpbnh/EGG8hBBD0wnX2v1aLGKsfFRv78VzyBDTECNjQIBkE4= 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=R3btefzz; arc=none smtp.client-ip=192.198.163.19 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="R3btefzz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418168; x=1738954168; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xSKeAKNBA96roisQYOcxV4QilUZU+Ks7Czd6oPoWOHU=; b=R3btefzzCOmPypUcdfnxzpNw3uuaOhiP2dje0z/Jh8UGVUesKjrIq0GW 68F3L2zIGyH3Y2i4w/0cxNEDNQuHDen/FO5djOOwTXKAZjHlAjHsd69Ws yJjqoED7VQa723nZpQ03dOm0FVx/i+HW3aoXGLZ8dPvOA++GslzqMzfrB uE8ahgWVQXKW6fFBPd7mARsKL6BDPf5hFyaDwry25WLRRD8JSQJ6r8Pu0 PtSGtKdHB21CfQnF06xejPbHI2pZ6PePUks/BA9WKnZIIWvazCsPvq/Zy olwQUI23SA6I0ayQqT50iVTMs5gwPeWHljfXdttQd6S453uRtKtmxdll4 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186088" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186088" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215514" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215514" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 557F532F; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 04/15] auxdisplay: linedisp: Unshadow error codes in ->store() Date: Thu, 8 Feb 2024 20:48:02 +0200 Message-ID: <20240208184919.2224986-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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..4b92ae7781f1 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 ret; =20 - if (kstrtouint(buf, 10, &ms) !=3D 0) - return -EINVAL; + ret =3D kstrtouint(buf, 10, &ms); + if (ret) + return ret; =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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 7D9CB25601; Thu, 8 Feb 2024 18:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418171; cv=none; b=Tr4XC4ayyRsooRnXg0RQf0uRA4OO/RjE9o/jtFDsy+BsKLZFW9gc2GWb7PmWj/iJsJRPpqPHkGbwB4h5dOoTjE8rHzW/wfBSJgyaS2iouCeDeceQrgpjPIzqBFmmFQ7OkmsNRDwH/pmw15nS/CKD1tWEcLFGGy2RC0EmRVLTt68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418171; c=relaxed/simple; bh=FC1cjzT0133HljBbHlbObVyjHCu4QTG/1Zt/QXNpVSA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oii71mtQF7otWjCl095G9BOgsNd+1q0LVWTrEpweatq+gS1ZZV3rKAU2afAGzSDgPWiqU53sKWHIIs3hHYeunbFxJU6pwRaAv8khDIwX/i7kBY9sPXRvTt7AzOWPk2jkCK1uejl5NUk8L704iA8mY4ie8urJORYlLrJQA6wSMSg= 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=FqlpNeW+; arc=none smtp.client-ip=192.198.163.19 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="FqlpNeW+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418169; x=1738954169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FC1cjzT0133HljBbHlbObVyjHCu4QTG/1Zt/QXNpVSA=; b=FqlpNeW+lbDvHeHIE022F/CyRT2UJymtasBjmTiV9RexkxAsXSUrATip ClDAAIX3IApnW+lSoszuXKLNaxBRinehiVkr3yEXw+Hjvf9Z4YU8EQnxB dD5NnQXzzyd/dbfRTTLg4SKOBKoH1E5NKoOICpxWGkCYVkPcFAdRc67yo wHT5ZUcKYMxgXJVKN8N+0j0IdBrUfW5HKFeBba3P+X1coxKFLLarq2hQh 8xAl+ZIXtZ5a8viPOt/ASiu2myqIVuZxoiTXIfzlL40XcHtuhg6ukfAuX T/CqAzSA/Xm9hU/9lqLY3WfNjQmkIbCrHuL/cJ5pu0mIdx2YPU64GGcrl g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186112" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186112" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215530" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215530" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:25 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5E3254C4; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 05/15] auxdisplay: linedisp: Add missing header(s) Date: Thu, 8 Feb 2024 20:48:03 +0200 Message-ID: <20240208184919.2224986-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 4b92ae7781f1..6b3d25e20eeb 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 1A613241E1; Thu, 8 Feb 2024 18:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418174; cv=none; b=pvaV5NRaIwGfvkn9Je3oAnk+RMy5GgnpQ3C6c4GIu2wlS/2eI6gpy0d7J8GDmACE9GfVa/oNjO/fSY0mgEtn5IO36MCgTnjFB9tDvedEKEAREQEhXQLNvjZLHh1EaiJSgY261X23HHaCzRyvIxENO0oCFnKP0OPrDzoez6id5Ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418174; c=relaxed/simple; bh=CF1pX065yGAbwnIQLmXi74KKJnRft9elRt9o2Olm5iY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ml0gfN7JqZ0tTo0sQcYtqa+wyL8vwzQiGDH+tS4ar86+RPtUEg3itOldKKpric/3jMsRMeLupyeG7Ua+FGOz1CM7gOTGXeRPGIER5buewhAwWpHzBZO2pVEU7YF3/NdRyrnzVaVyZ7fen8CijyGoUkQEZkm7NIav2AYYCc0HpAU= 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=kXJR22dM; arc=none smtp.client-ip=192.198.163.19 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="kXJR22dM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418172; x=1738954172; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CF1pX065yGAbwnIQLmXi74KKJnRft9elRt9o2Olm5iY=; b=kXJR22dM4kGGLMdYM5E7umSwxoRLAkXpSgk/LrRN1q/1zuYEcdJiYqNt LEhdev3OSBLWXo6+GbTVrGJJvkkFNbqIEOwoduNOSaMDxjenSkQzl1Q0d MSIqlReqJ3sz170aNiGeFNM1sp5slTTylg/wGtXX4J30uXD+KBXXIMyVw ntu9L2UaSaAsi/mrgn8osCOrYaaNHXwj/Txqh6Vj1zg/dx8DwsaFQlUsB GmSiquQ1zAY0e74qG42QRV3I/RTHRjhxFDSZDiTWgC+djXzlWgQspgnyv noI8p3m9rKT7caSCkdcZk2PpvZy21IRhxq2TcHkiwMDfUwN2aEpAjByoq A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186131" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186131" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215532" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215532" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:25 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 661E5B2C; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 06/15] auxdisplay: linedisp: Move exported symbols to a namespace Date: Thu, 8 Feb 2024 20:48:04 +0200 Message-ID: <20240208184919.2224986-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 6b3d25e20eeb..851b2c0f9443 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 49BC72D044; Thu, 8 Feb 2024 18:49:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418173; cv=none; b=rQiZ8+hvtf3kAhjjMGOiWd7dZD7hPYdCxZ4H1n5GSSgA8pC2apNna7DSn0iyrsPy42/pieNlf8c5m3+jVhGTKPnopZdCLtoqZKtg8j8m40zdsEi58o4HXpulej4HcDxOwDaUqVJP/9S8t9Of1+kCWOOc8HWh1RY3PtI1GIikfjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418173; c=relaxed/simple; bh=Fg8HFd6qXwgrRuKizTmdQy4zN2vPEsdI81OkVtdnatg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gt2ZBJ1rBKTcO9GO57W1sV1lz/2eoErvq4hjwQ2OH+2rCImEFnSEGyM1cVdAxWzkn5X9ZupCcoWQFMAOHYYjKf0KO80Y3E+mFqfOyRgR8Vn3QV3UT0Tem2I8ETXT8IHyO00j85W6TMPLq/Yia5vB9ug7sUHvDzVGD3ADQ09nI8Q= 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=OFWhm9OK; arc=none smtp.client-ip=192.198.163.19 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="OFWhm9OK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418171; x=1738954171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fg8HFd6qXwgrRuKizTmdQy4zN2vPEsdI81OkVtdnatg=; b=OFWhm9OKBi2ICSz9BlfzjdSrPO6mylkBy6yUc2JqoDPJUnGfF8hw9BDB ElhH+yaubG4bZ8BZd3iq0dGFqj+0et8yCum7qh9YgUqN4+9+UtP/wcy+l /pcorJi76mv7IP87nae1mXY6k49BVFY4KOnjwGVIHuTvPRwCNjZxJyC8D JoiCCa+fV+Uo02aLUVS7Y2zCB9EtFb5GIkFZuZzTP6RNiG+okXi2NBvOP kSbrg3LBrW6TlyE+gpjn0aNI8F7fN6cS9d234mNte8YZte8rec2/pPaCY qwKT4jcYyF/CsctB1qnu5P9wzRt6iabgv8mnEV1Nq3BC7xluvOptl3SQ8 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186124" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186124" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215534" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215534" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:25 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6E811B84; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 07/15] auxdisplay: linedisp: Group line display drivers together Date: Thu, 8 Feb 2024 20:48:05 +0200 Message-ID: <20240208184919.2224986-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 ABFAB28DD6; Thu, 8 Feb 2024 18:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418173; cv=none; b=cQqEUaGapcICa89GV1cg8CDwL/m9oW4YrKcvkzUF/fFLw5JtjzrE19jdRwPxKUonQ6kSAp03vW0z42GaIImJqAYky23toXHQVUMqwpiOxRXAqmvBpOxq85rB2gBkLYWfyVrd8Lz4dT86jJEZseCagJGmfwPmnLgM3kmsc3JOuTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418173; c=relaxed/simple; bh=fRF6aaXYm3WO7lZKrdtFCzyzTyXPONtxX7sbViupAFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gd3vdTWd9MiVKxWC2h2iQMTOoK7aoxvN87yDp5w/B2Kdk6DFCUl7CwTnh4cmAViiFgWzDw8JaPFS6VhjlE1qXZHDD3BLTSYepDXcjFBGcEb8Lc8X64CYKmGurKsM5uCSQwtrtQqeNIRk6UTxcfvjunUPyLpW3fyyTQ8bc/cmn30= 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=CcExyo2Z; arc=none smtp.client-ip=192.198.163.19 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="CcExyo2Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418171; x=1738954171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fRF6aaXYm3WO7lZKrdtFCzyzTyXPONtxX7sbViupAFA=; b=CcExyo2Zl2E3fY/QTEIm1qF3w0bkIdBGCSx7vDv779w3UmhXqq4dWkKp kMHsdnWmpR6SOAABYlkqqmh6LC/0khTJUVwyX86Z4M/jOBO/j/7ghNcIU MIAgso2Yp/GMLejrPnqw/3j9k8ZpamuPalQgkhkyD/ZeCEvbioX16Yrgd 5t+1zse7TlfRz7UJ8R+PD0DBNvM++H0rbHRPuIweauax+jMM6c3EMBrY7 jq0Q6WivrTXx/zA/EH7+mR/5UDdsi9OHKz+GBLPiGzsl4LmiMakyM5xk1 8X12a5OuWOtOhabmIvRZAUwURBwXncnz/v5tWveFWNC5UxBp/ubh9vr71 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186120" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186120" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215533" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215533" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:25 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7B81FBA3; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 08/15] auxdisplay: linedisp: Provide struct linedisp_ops for future extension Date: Thu, 8 Feb 2024 20:48:06 +0200 Message-ID: <20240208184919.2224986-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 851b2c0f9443..62e8a911bb12 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 3C0A5364AC; Thu, 8 Feb 2024 18:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418178; cv=none; b=eAZXDONKZMkDYXKGescd/qNd30enCPzmZndRFn9ZSPhtejnflBU5svTvStXhg8sGIMB7hKTrJlWGzi5a06Eshe+KMn08XTGjWUoVtfaDtYTpBHUkT6PQqE9oRia7MzKI+4Eu67VEnFTd1g0Mzoxp0TRK7z5KV89bTl5XNB5FgPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418178; c=relaxed/simple; bh=D9KNXApzrQn/zL4buEhPq3QKCgL53LOywh6Etg3+aBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AHeXwGDXNw8tEwRUHpKVmsNPWldncZYsrcllgwnYFW9U1my+fRPk0uWTyViUqpJP3QG0fM/w+A55QNlHiVd/qXVliyLFXsA76oKD42GCTRlSBEWI8Zq9TfLp6INSBToulHcnbWi4cKgnvHlXaqvNBtqciXvNBLvjyJGb1Ad5cEk= 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=Pe+uwKCP; arc=none smtp.client-ip=192.198.163.19 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="Pe+uwKCP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418174; x=1738954174; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D9KNXApzrQn/zL4buEhPq3QKCgL53LOywh6Etg3+aBQ=; b=Pe+uwKCP5wWcTI3OVyueNad9nlAVHlmgivd/tDuk8jnFOll/ptbxBN7R d1/qq97MKt4jvAW+w/i8jUPP9zErlewuXze3Y4rRHRetWYuUkX4eo3Ye0 AuF05TOKA+pMfkDFYgHRwC5yfH8ZRFRwozczCcfQmXrULu2/mk+UP4tV+ 99d3neBQy59Jcgkord1B99lgqXgEhtI7rJzObBjr+aP+GrGHYCA4FURmS izxbbhucV/+2MAqTjNn0+pardZQ6chf6bF2LVaiwY27WFr1i9ZdvkSgU0 SawjYMX3L+jePM/IQAEWK7bZREDm8Dd8sS5dLcxPU/0znN8XWxW214Sj9 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186135" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186135" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215535" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215535" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8401AF23; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 09/15] auxdisplay: linedisp: Add support for overriding character mapping Date: Thu, 8 Feb 2024 20:48:07 +0200 Message-ID: <20240208184919.2224986-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 62e8a911bb12..da47fc59f6cb 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 865173C481; Thu, 8 Feb 2024 18:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418181; cv=none; b=ZTqDOJm6xaurCGKtVNkH5aKTN/Zvyibr+N2PhK30RwFgfP8gZ/hEFgWfdKXKBjubztfwEj/VzxWr4ng/Zm7FPZ0Z9x0aXaijxxkotyoJljjZfbTTmawaaf1hUKwTkVTZFZG8NNEn8LVIbSxagp8pc6KY1j3BdMaDZXY4fsByn9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418181; c=relaxed/simple; bh=T8KmXvh0YgA9eNWvtIJ49Y3WYjlHB5MaL3TkD79lAqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pxCJSZXfgH6/q3R1qlDumce8iT+5E4CX59LB6Pm4m3Sos55kqErTX6eOSP+MzsHG47ibeYChUysWIYUYy6zG6sSq8IKcCM9HI0lafDullG2tNEakZKulDBTWawhMKI3RZAeynxdX3idFBGZ3dTXWkNjkUDXoe1+9MzDr8GyUVaU= 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=Ma/RGIMH; arc=none smtp.client-ip=192.198.163.19 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="Ma/RGIMH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418179; x=1738954179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T8KmXvh0YgA9eNWvtIJ49Y3WYjlHB5MaL3TkD79lAqw=; b=Ma/RGIMHvJv6U1/NI4+GYuSP+A2np48lLQjbU8D8IOY1Cssf3IN9T2II XBi3SV2XP9RHD7IUZ25LYGfqnqxmr0cf0KaSkWWfWNV4kwvTZVbvlcg2d 9HbGvh/UHc+FSjtcg6NTIY1UGBR+wHaOqQKnLBj+jyNt+hVzSComAZE9o pPyOGc5sirnsA9RYU9p5Vo8g6lES73GN22gn6Io8f1m4snt38f1qXFkpY 9ReV/pEamDS9e/AXqHBKLu969F5KZHOfMB94GDBKlsif1RxDSLHH1ka8D mlXlbABwsmYOYhy3pBnUGL6oaAdwSaBWR46YgcVB1AHo+fAhf90ZlofeT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186162" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186162" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215538" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215538" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8DDA4F3C; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp Date: Thu, 8 Feb 2024 20:48:08 +0200 Message-ID: <20240208184919.2224986-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 da47fc59f6cb..a3c706e1739d 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 CC9E5381B1; Thu, 8 Feb 2024 18:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418180; cv=none; b=Z9TmrAf0h0tVt41SoNiWEA+cKsi1yhZs+Jw6tZ4pnqZ/nuYiKFV9S80SkWHKTf9VmpLUS4YeqQHAr/cvBOGNUWbwE26SGeZj1RVSxfe+z76eocOdXs+fmUwvwAFDb/PbPnOvB9OHe7u5UwasB5DFXwdrqOWISdjMu0DL1mruA2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418180; c=relaxed/simple; bh=5fFTptxgaNSrb8/J39Uzrc6cETbfYvICnOp+m4GRuCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I6x0ra63uzz6g/QZPWIwmyA9JwK52BkxdNGpQM/9JW32ijPWn1oxKXTNPB0S7f/nfvsz+CDOQybjySU74N1mhxqtF3Eip2egk/2RRwsU+mDaDHuClkmA1niyqUG9xdCHD6Cit1XVUbEpVS29M57oIxcOhjpplwMgwChULPqy9eg= 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=bjm5WjVe; arc=none smtp.client-ip=192.198.163.19 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="bjm5WjVe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418178; x=1738954178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5fFTptxgaNSrb8/J39Uzrc6cETbfYvICnOp+m4GRuCg=; b=bjm5WjVesqNwJwuCMUWtLhfJ7HWddeJ7PTrzZApt1GjCW3drJASlUYX6 3S+Yni2MQcLVpDer7WTqCdJ11B/DmeiFSwtvAXaC2W01Q+q0oKc6ZWIJm F9SCooJTKAM4RZRvOaC5eCWl4nB0eEWLCMNyxYyeeScMw/IlYFoSYDa1z +9xOARo4DQ5lI1w4kC7RwA4QHUO+IF0hBA8dCsrCA5lq9S8yTC7h52JgI PJuU1pqqkhbhV85EdbUczUVo+0J45f9e0N1JwjLmrUBClxyrFxtZISBsM gDChrU/kgU64LbH6yUXkSHdg9f0iJG9Nc3oW6TkVlDUYCfNf9lVBR2QXi g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186157" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186157" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215537" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215537" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9306DE1; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 11/15] auxdisplay: ht16k33: Move ht16k33_linedisp_ops down Date: Thu, 8 Feb 2024 20:48:09 +0200 Message-ID: <20240208184919.2224986-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 F220B364A5; Thu, 8 Feb 2024 18:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418179; cv=none; b=VQACZ2k3/xuXYl4SclvmKNJ0EKL98Hhq23ZOcNyowt81lQgnxsg1q34scxjv+n/eiuRXnRcxHWSIOnRST4oRKf6o9Kl5qkA+5WVGcuUKk2bi0zi5vNe9VHCschTDBqC3Q2bVFpaB2gm7AeFZZuoii67QLXrq2asfuLCEwetQXsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418179; c=relaxed/simple; bh=xY52GBdbWlUZAfmSG2absg3scItgooHoNN72W48Llrw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g7JXTSTs7mKWx/G2XiEvpFz5K+t1e2/dOwASCoXONnyXypwQUJw7D2v3azUpIFCHZRaukCKhDY04bMMDBZjPNJ84zPdxIqiygpOM0gQI4Pdja0qpRFkRHK+gZOJN7y41DV5+A19qCJbm7vAHVRVGEu0GH4k5PoKrDbCCbEO1rUg= 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=juptwNZH; arc=none smtp.client-ip=192.198.163.19 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="juptwNZH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418174; x=1738954174; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xY52GBdbWlUZAfmSG2absg3scItgooHoNN72W48Llrw=; b=juptwNZH2fQxy9z/+VkHzyhPXxQ0fqx9xxjARYgTLx82ymngkVIB+7n7 IDznOe1l9HMoqb89DTAXL0yyntY0S0mzLRkaXvmxgc67srbTL7WPx5URh EF1x1bc+lkgbUEI5y7h7j3tMj/NyjLZEFA+TL5QqsfeY//MQk+f68bKRW nO3yl8+nXROR1WeQKKS+eYHPib+XsyM9LoBrAqmaaDgxwf9wA+GY9R6Wd uZdVaaYUCCv4O4eiu6w3bO2FT9Wl8TsqntWNrPLn1wlzrFP79pCTV0gmN 13dosrdYdozj+yOpOnNcBJEn/e1ePzUcV29BQB8qc5PJ6uMcb8sUDL2Vj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186145" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186145" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215539" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215539" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A22571027; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 12/15] auxdisplay: ht16k33: Switch to use line display character mapping Date: Thu, 8 Feb 2024 20:48:10 +0200 Message-ID: <20240208184919.2224986-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 ACAF7383B8; Thu, 8 Feb 2024 18:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418181; cv=none; b=NHmZMaeCGqo+6NRxYsyvYiBgVVKb8Y3W4BW2UhUBsFoSIEqf1UUTIX9EHQckgioxRX47mtahgUxWRT/Q8Qe4Ku9W0RKvTIRjwSJ95zbjSZJmRhv9MgmtuWi5AoOZ3T+crN1RIzC41/5kKHvO2L7gUtW+tnoScJmAsb2wKslcI3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418181; c=relaxed/simple; bh=FH8g0LViq9a54GUNHUMfITSFf708fBC8temf69sHlcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i6SjRyrNyNpZ0Xus86ygZizkbbHHqp/eUUAvomUBT9OavnXCe3PBkU05f+rxN2+WgnKp2PfoeyH+FD3eyKRasTX24En2crQZK88CgjcsViZ++tNMGr79OAAutpzGeSSaxCBjWaP6IkXCYZRKuPen71b1ts0n2/H9RQND1E1XaSw= 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=h6Dh9ahQ; arc=none smtp.client-ip=192.198.163.19 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="h6Dh9ahQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418179; x=1738954179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FH8g0LViq9a54GUNHUMfITSFf708fBC8temf69sHlcE=; b=h6Dh9ahQP+rCEf+4jUtz0ewl+O6oqSwcustfIP0OfKv409rJSY2/WEMV wSwl1ktHrg2UCt7yLoBYqhdIKCkMcz4a9ZsKx6F7qtR1fpob8AtIslzt5 EYJDVdzhlhMIrpkKXp7NVDNZAR1fQvUhFZu2cm68cpi4nr3+wpzbRDPeh Z3db5VfAHGBBwVV9Ut1wCJpj5VBUk7G6pSr/EZuTC/jiHrjTJci2RU7Sw rIWY52bLD7WxuIDHrCE5yBUDdqvQKkfNkledkqFdqIFxN6kraB8R47SOa xrhVECBYRWifZW4TJ4bMZ3zXOy47ahlmGLYKzbPEWnxFz2tN9gL6+T9vR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186152" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186152" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215541" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215541" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AC41CF4D; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 13/15] auxdisplay: ht16k33: Use buffer from struct linedisp Date: Thu, 8 Feb 2024 20:48:11 +0200 Message-ID: <20240208184919.2224986-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 CDB1B36AE1; Thu, 8 Feb 2024 18:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418177; cv=none; b=Yt4z4mqEwKZOENMev72htaE3ycuKJaGyZqz+t6rqM1hufnEE1dCDPW8vHhAEjXirdN8TQ0eJINkLoJQoPBCmJ86ieIYEe0V3q4n0GAFnINUICT0u55021fpLlXnTTKTo89q8Xwbg7chikdZhC+rfdWAeKfhK5NS/yq6ViJK0QTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418177; c=relaxed/simple; bh=xwQv8uq+9wANm7Kp3tnfC+qRvpRyTa5vpEt37Og3eA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NmtedN/pFCbYVpQKWQkl/hlMakijeAK80rLrX9goH1Deu7FXp6DdqpGY5fb2c1KeL+f4iaRU5N72dD54qHflPWd8K3yUPxQnQt3yGps4D4SRbdzwxQTJIBOyP9br82FN3xxKP+x9hg+ghXY0OsByMsS7xuF8krg77D3WSwntwpQ= 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=KPpVkpOw; arc=none smtp.client-ip=192.198.163.19 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="KPpVkpOw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418175; x=1738954175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xwQv8uq+9wANm7Kp3tnfC+qRvpRyTa5vpEt37Og3eA0=; b=KPpVkpOwmpcbJaEuStBBJXt9pcDyw0Yp21ENfTOk3WWVq0SuxU1K9G0+ 694OQtFllPE+ThKBqsS+dqOuZGZTi+Nt1s+hOVi/yCA5ZXjj0s4Xd+dJo /8gpsSpXXGmOY0ONR+q1WypL+1mJO9J70UrMvsWMzjj1bhND6+uk3WfHU ur2qQwGbR3JxHg567nzcRNqdwb3jjgNg1tIjDHNW+FBorwuLoSWtnkW8I oqwVFS/PbVyZoSs1O/uY0CaggrCsegxSf2OchqwGKBwVFHcHFfxdx5eH2 455QXbR7NIGFQE3Q09iWlV1GzxyrvuA/y/wcZL09mEHoXwDvVRb6xIJpT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186141" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186141" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215540" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215540" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BBA6112FC; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 14/15] dt-bindings: auxdisplay: Add Maxim MAX6958/6959 Date: Thu, 8 Feb 2024 20:48:12 +0200 Message-ID: <20240208184919.2224986-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- .../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 Sat Feb 7 21:24:26 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 467AE3F9DF; Thu, 8 Feb 2024 18:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418182; cv=none; b=TZqOtM/ZLUya46DgOmyKHth9nHNSw3XgKjVUL1uVaEU3yLNNR7L81X/S44e/4MHJ1p7dZycbqlvegwYuLMYcSf5GyByJb269NsdBRk6GAuAkiZiq49R/xHhDGUsGzpsuLfadhg6Hz9LHmSuV8L8Zp/p4pjOAiaRycYmFhldruGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418182; c=relaxed/simple; bh=v6wTWOcgnBbdVRVq0vTx2zi8kxA67Ld9K3m1TKyiM1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tZcl5XkVj8K/XqmtFayXVE9qsKH7n9505Sh2QQCrQZQ1C91Hu+6tPeDqK23i9eUT+CS4ddYVd1VjXk44MAdq9D/zJcqRIEISiQw+ZXXYJqErZ8AKMHs6vU7Uv8anSnqG665zkbYC+fDzxmHzCg3h4WxAFbd68kPDteS7uOdrIVo= 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=LIFY9hXr; arc=none smtp.client-ip=192.198.163.19 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="LIFY9hXr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418180; x=1738954180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v6wTWOcgnBbdVRVq0vTx2zi8kxA67Ld9K3m1TKyiM1Q=; b=LIFY9hXr4ZonEoYdzXaF1hVI877SOcxjlIxB/T+8ia+89IBz7IknZpUk EAzT3+qkQc9l+YvqwFtGH52wBxRYakg6Pw3l1BW9qkK5PEiMdfuET/F9T oOo9j57L0J33KbgfKL4SQJBR+O+GTFqXSqDhp01SY47MZpg38uVFzif72 l0eRXX6H6TVE3Ea4lT77YWobMmOdxD1qPKXecbxzaprLcW/ixFMLGLPMO 6VZ26U6MLjF0JfxRw5a0Es3u4zfOEBGzRmMBf594gb5Yf10rBp60pYQeq aSevGCP4S+/W6LBIFKtPyC9ksgSPd0mSVASzcjJLl9mmJ2Mrqf/BCCJS3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186177" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186177" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215554" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215554" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C14AE1043; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 15/15] auxdisplay: Add driver for MAX695x 7-segment LED controllers Date: Thu, 8 Feb 2024 20:48:13 +0200 Message-ID: <20240208184919.2224986-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-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 --- 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