From nobody Sat Feb 7 21:24:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 BCAC982D65; Thu, 8 Feb 2024 17:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412655; cv=none; b=XRC65yN9nAFroy3B7A8wMwAxgTJpr4PgahI57hi0svmJueP6oap4c0o8lpK2HJY4BsBsw0FSBGbgtsWXLJ8EiHP3eOW4r3T5sBjDTom5n5EwOTus+1iB80/wiK68yRgkdY+tYPBTvYWgkK1BmL/Qrb4injkFygMxY0wwySZVeGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412655; c=relaxed/simple; bh=x8TByPmOrQ+gMAIIaoMyZZvfiNw4po8E/dT9novu62c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I/mJaE/DKYba/l4pJ3R+inl07JqGYBUxs8MBys61j3a8audeU012dNQa/KTsxlSakI+wdN5z0iyUQfIT+CYzgPj7ZsSPASLuePh+Y/uhxmJFe0jyr9FuaNg3Hl1QDESruQmXc59jIQCxJiiOTz7bf5xF/Oa6qpf2K5HdX640SHA= 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=P/FNAa2B; arc=none smtp.client-ip=192.198.163.16 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="P/FNAa2B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412653; x=1738948653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x8TByPmOrQ+gMAIIaoMyZZvfiNw4po8E/dT9novu62c=; b=P/FNAa2BL1MrZVpUJUREpK1qzcvr/XRxc6hhLUy1oOTC7JoaqAd67lwb SFVWcxhZpkCKjcm8lBCdTQfGyhhkrEYDgpj16rTdyjc6rL0dClctSRk8h Ndy4RAkuk4kyPqYwv5A4031RghVu+zWl1IkdCDMqaDztgz3kDsje8qM3k +42kUXR93ZAmoSGdE5VW7+aOfcKCOpxD0dEXooOK9pg9bCV6g4ETDLvpN 4yOb4Ns+EL2uY0aP6g3F0+pjmj04L65FN7FfNoXbpTdlYR8nImZuC4E9X JYigFLWLTMpnSI0luABeIdy468g2tMpWoCQpBFdwRISXD/33RsY83d8eQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565661" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565661" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195370" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195370" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 08F1D1043; Thu, 8 Feb 2024 18:59:40 +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 18:58:44 +0200 Message-ID: <20240208165937.2221193-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 10A2684FAD; Thu, 8 Feb 2024 17:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412656; cv=none; b=BYjJ5vZSIxIvFFc3cU9CVlNac9PsKRWmxlxtz7eRqLzkRRs9nCmRthCCjh1qt9dq7xDTVPmfaJ8EFIxj/IlPlBWNldhtoD3FllVCDW0OMbY/9Yy8YqEEefjkFdWyiJvyKl6U293g5LIxekqkcP3WxSiFSaNYjwdkfBOckAfmzgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412656; c=relaxed/simple; bh=HmO8BJAxHzacI5yK10Y9+ofU0L21g/VbhUyc1S5/3jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gQzI0p83QScPd7J5kLD4xkhEu63XhVUXgVHo4sJUS0pvCB/CwljWyCKHSHoS2jSb+aF0e3La8s3ZfFgYPypV3Ixze56RQBhp0/ZuIVSV9kCwn4Q0oPMYjCLM84qZqqZtLZsRQL9bgpk8XEjDH0LoLTmh3HSuKHF36mR63XKr81Q= 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=fp0c+kZE; arc=none smtp.client-ip=192.198.163.16 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="fp0c+kZE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412655; x=1738948655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmO8BJAxHzacI5yK10Y9+ofU0L21g/VbhUyc1S5/3jg=; b=fp0c+kZEowmfNUNS9/4Jd/LUh9xAaXlw14STOlzb+SRcCIOOvuGQKgVN Tl1IAVql6UUkNjrnpTpSqfpuGsXAyahmB4fv3ON7FPXAmY4FfDMqpA+o1 NrQ/doaAcVS6Rga7GO31fwqC9dSBdn5gDY2hIiqEWWc2QYIFozv7kyrbx qNT6vkLPRaGVkjpCknFgD6TVi0/AYfFUAnuqY69fdHakF6bscpjWhc6iQ 3g409BqEu3b4UoZ2a5GvaXprWIVtzzl3QDDhboWZDvAd5CsK7sda90P/y VCMmpDgGpohWDOLfq3KyzwTu7oKV3T5toJTg/aeXA8zLYpQcsWQmAvfPb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565672" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565672" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195372" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195372" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1BCD013C5; Thu, 8 Feb 2024 18:59:41 +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 18:58:45 +0200 Message-ID: <20240208165937.2221193-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 592CA7CF23; Thu, 8 Feb 2024 17:17:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412651; cv=none; b=Uck6OGV5CNh8fmFabWUedKj39jK87io/K9aFD4zh22nN0PtR97baN8YLx7vsZr3MkCNY6BAjrGZuxM5DsuGHDq8Edg96Yjvwq2TE4aw6JYBTrYBbsUt0QwDgObL67+zsfY+YcGSB72dCOXsjm67t8awZ37yRN+mXv5It2+hDRCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412651; c=relaxed/simple; bh=LvC0jNLSvlISq+pfX0tunOut+CloWPeckMMVxbBHVes=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jSN56725zDkvyIh7k8y1NGW3pJgTc4u63tG69v4WxZabRtJTM0rUY7KtktuZa6LFxslzqHBLjJC6D81mZPjaeYITJm7oZorr36MPmb3uLl+TPasvL6hnUbmfusLKYX2tXIrdRNiVxLHh4ooPopIPTGYDEqjhLw43dGUP1yuhqhs= 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=RXVWHN2j; arc=none smtp.client-ip=192.198.163.16 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="RXVWHN2j" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412649; x=1738948649; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LvC0jNLSvlISq+pfX0tunOut+CloWPeckMMVxbBHVes=; b=RXVWHN2j7xYe3EkiNvYU5TviV2CFsuljkp7R1di2FqeoAZPfvFKrXReQ RG5bns25xeEZlneTRRE7HI1UflSRAhxdT3Gr9xqFwtoilTHNIsp8lebrb KSnYMPiNKEpk18tEApze86BvwOD+WUQe4nMDpw/crthPefh9eB3SWJp95 W9vUR36NkO0368B9LkgyFI+48NSFVlsYow+usFIhfuZOYvhbVQst5/Qgf NFO9A3QtKl8TGOvIQxURYXULgXYU+gRlWqGgTLyQojzAjFjXev25v5jlh RIlK6f3I5qxKVrAdp32LU5F2sszzgFaZcnPt1Gf6DEMIGRJqiQRDES+td g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565633" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565633" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195354" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195354" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 210101374; Thu, 8 Feb 2024 18:59:41 +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 18:58:46 +0200 Message-ID: <20240208165937.2221193-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 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 91E012562A; Thu, 8 Feb 2024 18:45:56 +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=1707417958; cv=none; b=A5S33koOkNEhDdhV33tGykQnwNVvn5WE0bX/5DcttMtrUZffbeLwxTpfpccUw89DQYIM5aeaIcL/30Nv/dk9RVXAVZgYqk/U5pxtOess7h61W/HxDNu3jPXWCzSYRIqaBdAL5Nil/quyRHDWBXLwWF0w+n80CFX9rSpJxzyn79U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417958; c=relaxed/simple; bh=xSKeAKNBA96roisQYOcxV4QilUZU+Ks7Czd6oPoWOHU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mhVTXmIHPj3Tvo4hXEnhtAAJPeHoHAxCAkANgmq9xXp9gv92nwVJscXrbjDkGKPmyJ9Wau1AIrYPbAy1SK+85VEoQIDHBImrHNBo25/3PUtQkXBBGeOi1L2vNixf2kTv+aUW2e1DBtBzs8RXjTt4A7LWvCQaj38Jc7mZ/4wa1kk= 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=UR/MFjBi; 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="UR/MFjBi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707417957; x=1738953957; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xSKeAKNBA96roisQYOcxV4QilUZU+Ks7Czd6oPoWOHU=; b=UR/MFjBiVReft1FQ0unS0YgCo3WyzG1AsdBR2ipGEozVVzBEaP7AMokA aF4MOXbDk5nSN5gTq5ZbXNELDROb9f9sEkPYj0ius5gyBhP+Jd6IETXgY d4oVA4lRZ/cDpDkOOb3L93vyTvxDK7na0rSyNiC/ezP9u4Zcim9qgJt7f 6HtJwouQYMfNKGjI4benqvhr0m3SZDJ0rL1Hq4QLl6gtvwommtS3FRWO8 CPie1DYG7GD3DYmIA6zq4MYLCHNTZU18Xh2ZLo/giAwKDNxnAI8uF3N4Z 5sVDdXuRtkH/XtwVJKoe8PaXFKMVJvIGaXHpQZw6j92ePBihfYTN5b71M w==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1185260" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1185260" 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:45:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934214478" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934214478" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:45:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 397BF142C; Thu, 8 Feb 2024 18:59:41 +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 18:58:47 +0200 Message-ID: <20240208165937.2221193-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 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 066ED2560F; Thu, 8 Feb 2024 18:45:55 +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=1707417957; cv=none; b=SZASSLVHAUy0uo2eyUUHAtUNL7DG/kSiF1f0Lap3cPnbJiAWXyf16P03ymTHgHNlg43b5JEXVQJybqAkj5FlZssL8Uvp1ry2CP1UUhNAoUUkW54T0PyfNep+Ok/6L4AQmOHr0S3pqV0SF4Sa+t/fZNXOErroquGzJIf5CE6oEyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417957; c=relaxed/simple; bh=FC1cjzT0133HljBbHlbObVyjHCu4QTG/1Zt/QXNpVSA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AdLxS789QnRe1OOpI1OpIPuiRxaFZrZJgCF1SylHADx4PwPfzmITI9CZho85BPAwETWgb5NvaRUl4dlhCRSjrKZ6bT6LD5u+OYSRQCbzjkLXjlJznokpnK3uM0Yn96G43a3ACiq3Ni54vsPczzy35jNBts47qGX/nvrm43VkHTU= 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=TnxemnN/; 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="TnxemnN/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707417956; x=1738953956; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FC1cjzT0133HljBbHlbObVyjHCu4QTG/1Zt/QXNpVSA=; b=TnxemnN/eBQMO2L51rE8zBKS2Y6K8M5lIhtDmq/uoJFVmIdkD8wjdC2W y2zBWJpFT+LnFGir060Yu7bTK0hzVyb2+pAITTJwwocxpmHplbolZ+Xyd 82NWqK/x64/5iT98LcVVDzasC9V78BmH5LnhS6+1pqkCmjNOKkOpFJiYk MxA6q8LkzJp/Yiqty4xKOp4ArnzUTkmYPyj1MtVuQ7ONN6dAL6DE4iuHW 3yWe3rll+2KmMdijYXaiM5pM7/wW4MXoEx0kov7MBkNgBTR+bU2w33+2v f2K+4XUDDwFDbvbimkLhIGaEVeJSYXmTksOn7NRvNXlA6Gyu40yqcNVp+ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1185255" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1185255" 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:45:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934214477" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934214477" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:45:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3F5FF13FD; Thu, 8 Feb 2024 18:59:41 +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 18:58:48 +0200 Message-ID: <20240208165937.2221193-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 7034781AAA; Thu, 8 Feb 2024 17:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412659; cv=none; b=JUEgTD8oZZ4WtURLr0lcldAJDzZ/e6alT8M2MmnN8FjZt5p8zkD78itUOjglCzSxS+DivC+yY2/UI7pmHQQCORaqOoIEwsMem78i3AYF2tttta2xjUN21SxOTdFDYtF4ZZefrby5mgw6pdjcFs9OeDiUENPhScBZEpSkF4nMKzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412659; c=relaxed/simple; bh=CF1pX065yGAbwnIQLmXi74KKJnRft9elRt9o2Olm5iY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sBadysBbwNUz8DELFtDL/En/fr/wAvR/FWwqAbmdb6WVicSCAPtJFAA0Pqgyuc/AQW3xp54jpakGzSMNfxdOQPGsCbcxZKOzNHEwCnMiO7Yrk1GmmGP7gSym288KpQa/lr2mNY+QoKksxBcabh8cYygA4PAWL2dB/a6ixJBSirg= 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=Jiu7mqAZ; arc=none smtp.client-ip=192.198.163.16 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="Jiu7mqAZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412657; x=1738948657; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CF1pX065yGAbwnIQLmXi74KKJnRft9elRt9o2Olm5iY=; b=Jiu7mqAZLe5Mlq1X1gYTOo8SDIih0dE85t29c5zpp9XQB94OKyImN29m b48X9cEOyTWlcqRPh5WcDLF095o4SauRY8+I+Rcq2+YI75fQ6ZMeMtkA8 Taze+ZAcP2U7NAsoD4z23zhoyEKPnYySxB0PD+JBhWntly/Z3Xj1VravH eX1JfaM99OlmLM666vRff+NJQylCh/GRua7z2aFK0A48BpZPF112m9pua CPImNcof7pA2FDqOhC1VbU3QinNdobJlBFKlpITVxqhOv5J9yPZBBPvdt m4VRf1L/dqe3PCKuLncQB+21OyTQExeSDZXSmiDAemi4uD3lGTuhSJ433 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565699" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565699" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195385" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195385" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:32 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 496DA144A; Thu, 8 Feb 2024 18:59:41 +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 18:58:49 +0200 Message-ID: <20240208165937.2221193-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 022438121B; Thu, 8 Feb 2024 17:17:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412657; cv=none; b=Rv9KnAlqkyHuRSAhr9ewA0D6x4NSOUXhU86+KB9bW825HsqMqiJgk7IcSUP+Ys9kbvRFXCu+29bekThv2YH7/RbFIMrms/SkkEfGRBFda/2MnS28sbNBfbDtkEYFMXdzlLnGwOWJ223yWrNwapCkJoc16OlQqKT9IHbQJ+n3U0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412657; c=relaxed/simple; bh=Fg8HFd6qXwgrRuKizTmdQy4zN2vPEsdI81OkVtdnatg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qZ5TFir34wpbmLgSaM2ymKOzrUcJJBMJtpjVpabUzMqQNKqNwAX4+H9QA1sMPksjDJEhgjUELJB9u6CYwxoKVOAejP5PD2qKwBjbTpvyuFANe+3/joESmRwMTdDhLFxpmT8Wiluc8KzR9C/y2VBkNAUqqPyJ5eHdWZR8VcQqYmg= 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=inMS7K2y; arc=none smtp.client-ip=192.198.163.16 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="inMS7K2y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412655; x=1738948655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fg8HFd6qXwgrRuKizTmdQy4zN2vPEsdI81OkVtdnatg=; b=inMS7K2y4NKgs4TmUojWeFTQYcLpmiR0bk/Ch8CkMFrp8ThyJLBhG8NE drYRM3C2w/TpbG/USSMEVBJ2f3zNQH1PRIIHqB2qwdl/nd2GDvChKrOyv ygNJw22cFBClhc7WSuvo5xh8R6u5Zfjl+kF+r7cZKyVihTH1L8nusioYf 7lXA6jv12BHgu56hpw866Qz9lpxZcasDW81QeGm+YLuLIjHQ8jTbfR/s1 z77qdPPkdELhPYUxxHuaomDsoF5VOwHbC4RCaG+8zvBhxCbUPG1FIIYOP +ahV7KS06Ul2kEsN6s1KNzJRamJ6/OFWe36dpyegOdBpHyvYR/iuK+teM A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565667" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565667" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195371" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195371" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5B2E6147B; Thu, 8 Feb 2024 18:59:41 +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 18:58:50 +0200 Message-ID: <20240208165937.2221193-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 A517B85C5E; Thu, 8 Feb 2024 17:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412657; cv=none; b=MRCyB4l/UcLTTWN5JWyHc0xIl19r+VwW8fA6niSGCCpYGAyK4vtgeIJ56IS9F6mM/TEZIistOpRzrav8/52Ubm2ePqOZcbSIcQnrroZR6nx3W2cpF/I4HQ+Ofy81IcO1GLlS+0u9RJl8OufpTrfzpmaJK9jDIwG5nzhrguIxaAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412657; c=relaxed/simple; bh=fRF6aaXYm3WO7lZKrdtFCzyzTyXPONtxX7sbViupAFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D7VyuEYR596vEPAftVlTX4hsEoRldgRBhJA0e0Oo1s+GPPSNnszVmHt7+Ym1PaIKu3KaraSmAzFLnzdfhOmyZU6mI50GHtcNlAmMBazHA+jrngWzmJbU5covoUeSfGkOVe+fck/w7iEG8TW1eEjDvMomIcGX30De5vkVPOujcw8= 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=TqqSKuKV; arc=none smtp.client-ip=192.198.163.16 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="TqqSKuKV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412655; x=1738948655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fRF6aaXYm3WO7lZKrdtFCzyzTyXPONtxX7sbViupAFA=; b=TqqSKuKVMhemuwLOQqZ5H0RtPLHhJOZ4Yk2eX/EM2+e/CnQwTEAodJo4 iZGn8soXUTKqK5hwWy1/372F9t9uHhDvSm9Ni756KTH/k96xJoSamGNxe m+UefdwB3KGTuLM7msmSDUqP2efiFFxzuYeooijZ+XT8d5axiQUWQCu/z hNgv+MtsJyi72lcjtFqErABLK+lMUEFdl7aVCdvO6tmcOv2mS91qsRn1b YcmDBf0hfT5XISFxZ/bfa8DgkWtTspGwbQzrX2uoxsLRgv1v4MYPdb922 VTtsqdoMRHe/pI+s5qeRebkX6Gqm2HMH4tT+U3RSgC984HMYboktplaM0 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565685" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565685" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195382" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195382" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:32 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 608DE1458; Thu, 8 Feb 2024 18:59:41 +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 18:58:51 +0200 Message-ID: <20240208165937.2221193-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 B97EC86ADD; Thu, 8 Feb 2024 17:17:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412658; cv=none; b=uKP19JLb8rHmrFamca7c7a9AYFwa76vm6KporXclgOwscpCrAXstcOkDlZup5EGDkpHTnzv5Z0vvug4WXsADSDDr436Znv89nWDbwwmMxx2XCWRqCDHGuIoA0i/6SSe/czxb0uTbUuDAo7TfN+Qh0J5KcMUEjNC/skypgqm2v3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412658; c=relaxed/simple; bh=D9KNXApzrQn/zL4buEhPq3QKCgL53LOywh6Etg3+aBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bFjHG7AXVWPFdeY0F2LrNkpLTT4cMpkYwz0bMCvrDfihil4H4ArjpY0KeUYq0tP4ulK3dxTXkSjw3zMPgpA5eCYIxjwY2C3hKSxo4bEkr4KRj6ocoBKDyynCwjtlNG/grjSk4sa0SBY2aIIqGHK/iSgF96q9h1NbN0rcSt4tKBA= 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=jqWqYyXw; arc=none smtp.client-ip=192.198.163.16 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="jqWqYyXw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412656; x=1738948656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D9KNXApzrQn/zL4buEhPq3QKCgL53LOywh6Etg3+aBQ=; b=jqWqYyXwWSP71CQMfpDYLvg+aC3x2Q36JEMsA/WUkXexpXNwh9YPrBA4 vv1IWfPY3vNlLtEHG6I4bpDbMwjn9VxcM4abHcvzc4+0S6JFncNKnBDqq Y+uSdSs3dPVew9z+7AHmffkEt83Jw+aKS1RcpzADeyJKWoxCg+t/znp6W +OHgSpGPrtKgviktA/vTMJGo56VXX8bbffCOjjqeaBKoWVFRfRuO+Bv+Q 1OWhY9oz7LqkebMJ1ON06FHNujNuMCbhwj9dxiZtLIH24rbRO7c8ePHw1 z3aTO9zt3ae9cEDmCcHYyIkWKBbKC+g5Gu2v4HudBbwj7GKlkknXAXGAR w==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565691" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565691" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195384" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195384" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:32 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6ED341529; Thu, 8 Feb 2024 18:59:41 +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 18:58:52 +0200 Message-ID: <20240208165937.2221193-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 12954823B8; Thu, 8 Feb 2024 17:17:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412654; cv=none; b=UbND9KlPvWqeFLDbN6qs7FfXiTY/lG1gLKcCF8n7f9OPKhzszMUjHJbViBK0kzaqItMjHaUuZPx45gHfoUwPd9F8nIoGQ4FpypgcRjUSv8PiHuuiJkfPpDEv9/YssuQ/O8bo3gZdPvSzthF4c5hnUsfYxX4ydwuFnZYh+j91Pzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412654; c=relaxed/simple; bh=T8KmXvh0YgA9eNWvtIJ49Y3WYjlHB5MaL3TkD79lAqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZN7TqNnLOXUJ/ITgc3mNzcpePZjLGMBTq0zwmOVmn27rbhjq7UlPzx+XSa6zSpX/lwAsKJZy0/PxPd6pOUHRUHSDsyocD/Mg03vUo8//jxz9WpIlIVez/OC5kDGgAr01hjJb2UnPrWGNLNPe8nwfMm/pWUxZz+C3r0TeZ4EAdZo= 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=T1oRVPtq; arc=none smtp.client-ip=192.198.163.16 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="T1oRVPtq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412653; x=1738948653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T8KmXvh0YgA9eNWvtIJ49Y3WYjlHB5MaL3TkD79lAqw=; b=T1oRVPtq7PMGIWzM+VknHMyrmM8jSHoSGWQxn4tPpEpwMCLJl1Ze0qhs b3tixGLW7UwH22X4IfcDjs0B+LNCIDFVq2qaJIoRARgu1m2MzyOV/0S45 NXsDiVfXjJ0R/Pk+dxtPyVy08Tj9UDPvuLt/3q6dJgIuuLYB3wEa71VKu 5WwOZtkwP2/qwYDghRdPprJkl6qo/vDT4w97WIyM5LKfZ1egD1vXzCvnc 7oETkAUuHOTytJWvN+eYt6WYlnG/E7pVSsFHGiYiQUooRQ6dBWHM+qLa8 rrR5Ym4x41GBru/EvSd6VJ/Vzryb5104S3RgniCsRyRSuRizWfS/JLYug w==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565648" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565648" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195357" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195357" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 78AF314B3; Thu, 8 Feb 2024 18:59:41 +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 18:58:53 +0200 Message-ID: <20240208165937.2221193-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 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 7AFB0208DC; Thu, 8 Feb 2024 18:45:54 +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=1707417955; cv=none; b=sl2PvgEX4Cuoo4LSgTFfpXY8qCcKD+bsyxzZFc0WkO7ACFkL85KASlRWqRQpaLVMSDokCtX56hc7SVqRGjJGJ8XdzMk+0Y5KtSR+lw11bBqGO6yedaH0tQK80+S3cEmG3qSHhj+n0JCIGWdtCDJFnAEb7agtXUy5FGvZrCml7zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417955; c=relaxed/simple; bh=5fFTptxgaNSrb8/J39Uzrc6cETbfYvICnOp+m4GRuCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YZaSlBxmJnSFOYEpWp+yfwccduVqjtuQZeM3B99CAYFG3wjeA27fUf2X33lPfaqhfETU/hPp321wL9jujhYzyctZeNU0tYYyjuw9+u8vSrMWIjGL5Kw3SOjU/E8gvSvvzzhhUgLEQezMe1olGS0NIRup7gMMYYxGGGM/2HyMaDQ= 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=PL5U/jqa; 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="PL5U/jqa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707417954; x=1738953954; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5fFTptxgaNSrb8/J39Uzrc6cETbfYvICnOp+m4GRuCg=; b=PL5U/jqaYvanJNb1WeP9R17EfjaHTUI9mCROp5OAvtmcR/gim5r68/9q rk9Dvuti3lnxUJayJhC6+kRrTgY9lo+tHcVOiDKkhxSA9TKuh7pkm/KSR /GUQ7ZU4Fq0Hd4ibtKOExn7lbBbipDC4GgZ8EDs6+ywcC0NEfpxfL4027 YvBrj5I1t88BQvVg40HYUH+GuRTmvpBxMGIHQNPhjz/+YaEgazxKXQzqz jKGwTJxT8QJzgCq1IM6MwGKxi0iMWvR5dzkq/MJDuPT7xjr/1NO9uykCy /kWTZQXW5qId6StBSOg0PHfYqetH1rdG71h2b78R+5W4sGEQzZBI9oASf w==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1185242" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1185242" 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:45:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934214462" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934214462" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:45:49 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 82899157E; Thu, 8 Feb 2024 18:59:41 +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 18:58:54 +0200 Message-ID: <20240208165937.2221193-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 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 BDFC9208BC; Thu, 8 Feb 2024 18:45:52 +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=1707417954; cv=none; b=LQqWbAA3IdaTkCSDHMy6Sp/EBKWogtpUj2sGscK1af2qm0AM/3S6QIbKfRnN6ArsAJE8jnauTaf3VOYXrXHVuPfakCeBUzP4adwBMbqUd1o6weVyvyj/duum3K63ZFNPlCB36KD2BkaPcJ33dAd0FvtTDhK5sJd8M9/nxBGQt78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417954; c=relaxed/simple; bh=xY52GBdbWlUZAfmSG2absg3scItgooHoNN72W48Llrw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EW8M91K6rxplNSPnrijauR1Xs6DDdgTaUbONEf0kBZRjI51MRnEZzzKzgiwZ7e/qZM8wrWJlxSHxMw0wj/E5r0TAJoHJ7RQd3crN4iHG/Gnzz2hdei3R8KEIWj/bx2WTgKIi/C1h7z2DEAOe1Pa143CPgqQmvSg3JiOjQYEBa6g= 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=mfR2G88u; 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="mfR2G88u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707417953; x=1738953953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xY52GBdbWlUZAfmSG2absg3scItgooHoNN72W48Llrw=; b=mfR2G88us051XD8UhJnDdctSAup13yIQ4RrvrOMBM3rJCu+wnkxPMZ6/ e4I85sdnZLCdNoNJNzJpEgfWHzUGCNK2bDm0Y286caroiY/cyYx6luSUX SPKw2m5UIggChvA42vI5fb7opys45t3dfehdDtJw3795y+erItCLhz706 95WodP7EulmmRkiSuW+n7xqhmmXI4XsW/JLaPf09M/oiT4W7PKFKgTb82 zogTPBMvhXdQw9zT1cTIavXWr57qwX0YX4dl+abjhUcLHdonzVaPq0qpy JLERqoYZuhD1KCn4BDzoWMnLHFjbXMFcaRAYo4A21wPzMowlSZIcUiZKh Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1185236" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1185236" 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:45:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934214461" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934214461" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:45:49 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 87EBF1555; Thu, 8 Feb 2024 18:59:41 +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 18:58:55 +0200 Message-ID: <20240208165937.2221193-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 045A8208C6; Thu, 8 Feb 2024 18:45:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417954; cv=none; b=ltluBwFqI4ozoR0I0SOP64EcVRJ46En31qmL1T9rnGpPq9yCA/6+fuaM3mYfypn3JlR3Zl0k8Jd5R3r1darTEmC1ml7MRmhozDZV2qPjRHElGACEOD2e71sKtPQbuLFI8HqQBNADg4OodpPSZ1CbUQq9CzlRuVViOVLIEIBhnAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417954; c=relaxed/simple; bh=FH8g0LViq9a54GUNHUMfITSFf708fBC8temf69sHlcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oKjuhCbg7mHz+hgS+wT7T9AHonoelFh9SVRRrmL7AAZUiJLaqrt63V1TjzeKzyimVTrG63X8ChHZW/7DPu5IIzN5tkcJRoXKDRQqrHCbpCquqRIVCC3RkVCLT5GJonhe+eQ0p8+BFPvR08GhtsGBpsy1rnLnigY8WfaVvJXL4x0= 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=fhuRbQhV; arc=none smtp.client-ip=192.198.163.13 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="fhuRbQhV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707417953; x=1738953953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FH8g0LViq9a54GUNHUMfITSFf708fBC8temf69sHlcE=; b=fhuRbQhVD6PU8cQoVZ5Omd7ZI/53Xf5Jy2txHZFvz5Z1m/MrNl0Uqjix 5vCot3LNWUq0pGCCV8R+jhS6XGPubm3UnhtPauK9m4OfWtg7Cu4BTl5Uf /5kpN1SLUfZjqfiQuLyznaBGMI8M1LJwvxyA9iBmUt4Ac5cNBoP2tY6Hd s/AeRX9GU+K46w+6GarH5zOuWnaVVJnE19z1zztJb0ZUEtgYhthlqRv6/ Ub9JtuhSeoXkGmEdCHh+6YWDYhNWv7NiZJJX70+01rN7fxkvfMtHL8sUw fe7kMnoVZ9LsEPCaZo9K/4CpBTeSJMh8t9nmGvmfvRxLSVkJrLjm+JEhw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="4271444" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="4271444" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:45:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="824919038" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="824919038" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 08 Feb 2024 10:45:49 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 980CF15E0; Thu, 8 Feb 2024 18:59:41 +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 18:58:56 +0200 Message-ID: <20240208165937.2221193-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 005EB81AAA; Thu, 8 Feb 2024 17:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412653; cv=none; b=nWdvk0U51g76fnmLnOK6G4Co8PK2StV7Jz6zQo621uefYVyWlYuUr1kZzm82ndOdmse7A+02NgKDt0Jmj/53G0SWwFL6usbTNOKlNQf0swdKMW/HS03V1g/oQcz4sDxbIHSDzXBQpOqr/HRd84JcnDJF5dSqhiuGgeqxPCFemAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412653; c=relaxed/simple; bh=xwQv8uq+9wANm7Kp3tnfC+qRvpRyTa5vpEt37Og3eA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q2w8G5WazjFI+npjVGfd56gLpTuZwFImHNk4+q/FggEe5ZgMk88xP9NpI6VpopSfNrRwsFqENdGYn73mnol4lJ/tpj/9D2Xi/pcZOvi8z6ywPfqKHoqhfxlglLlchpNtnnuwLgpTAPa4N8jttBk+1IULLkmC0r9DVGtu8+3ko4k= 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=fVsW2fPu; arc=none smtp.client-ip=192.198.163.16 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="fVsW2fPu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412652; x=1738948652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xwQv8uq+9wANm7Kp3tnfC+qRvpRyTa5vpEt37Og3eA0=; b=fVsW2fPu6Wt4oEluiIUrQEpRY63dAi5Jkx3Zspqs+4bXHSQrDm6knJqW IfAtuGWi2kVtVaJoBdNu2sis9OyfS1MVDspFEZ91NbtizdM4XvBUrCxT3 CH+nA6IV70lY183aFYXMGm4XrbKBHOdM5WMDFgkdyNUbgWrKBqrSs6nsu rHSUtnNUgmiEf4TcPAlIcoAiHgsnT6+mFXGSG3yWJ4CSD6ZOE7tF6j/Oq lHmFnBdWMNaWW/9OlvizBJmNJBUF3wRNsyxoMIYtaAF547NbKQO1K4G2R bmM6SPU8XqhjEPQVLYP8myagwTUc/oiIMDLHtieoQmkY8w8Fbfhl6jEz/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565643" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565643" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195355" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195355" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A7AEB168C; Thu, 8 Feb 2024 18:59:41 +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 18:58:57 +0200 Message-ID: <20240208165937.2221193-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 51F228002E; Thu, 8 Feb 2024 17:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412653; cv=none; b=pGfyF3dVRlYb3QepLVmSaO1J5lDiTmZNc1S8xMFtRfEG3wymDRq9Lyrce0+PEPk4GE4Cf8Kqlv295X/D6x2KOQZmza3j4CraE+jeZUIU7zf7SDo0y1T7GbTjARtvQZOHQMVEEfu2G3f8ITAx1y3GC8DoHocnHhhDbAyQoF9vVRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707412653; c=relaxed/simple; bh=v6wTWOcgnBbdVRVq0vTx2zi8kxA67Ld9K3m1TKyiM1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MFGpV7GE0QYB0WTXl0pjSC2zD9/rp7n6IpwT09as7DZHmTBilU8z46WiFU7V9aZ6r3eW64+Ty3+CpNhulhQGDGw02fhkhDR47EilHjlcBaldm0/kqfAaGf4nUU47nc+ynQ7EC7d92HOMfaRopfNyJ6eIv4UHMpwIBwTG89JEkSM= 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=dhPfP0r4; arc=none smtp.client-ip=192.198.163.16 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="dhPfP0r4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707412651; x=1738948651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v6wTWOcgnBbdVRVq0vTx2zi8kxA67Ld9K3m1TKyiM1Q=; b=dhPfP0r47cv/qUFig/NFuKnfa2SUaYAETqttt16MJNs0lqwu/IZ7faUM WDLAxq1KwvA6YXaebERDc/fxlHResNg8WTw8gBLKdQ3A+8SXzCC8PeRha ZcYJYlOc1K95sKw4QC5fK8JZL8ASV70IWtdWw0uE0rHX+W34QN9+QIB/S qKS4D1Luj4BhMukL2/KUVdnCMQcK0vLw7LP6EFtQS3/5g2zL7LvoSvWYB tOODw0N1E1jjQuuqEhwH9db9nmf3wCe0CY8KSg/wHvt4guKF6c4dQ2Eh3 tjHMPCpnraNPmUmMHPoIAhoFeRY/ZdmNst32IkqkAaURyHt0zWcfAwSeB w==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1565638" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1565638" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 09:17:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934195356" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934195356" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 09:17:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AD51B1584; Thu, 8 Feb 2024 18:59:41 +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 18:58:58 +0200 Message-ID: <20240208165937.2221193-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com> References: <20240208165937.2221193-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