Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2326517rdb; Mon, 12 Feb 2024 00:26:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IFw7wrSVDcAv61hxx5NUHzcca7SThaxkKmObi2/bYGNm52vWY3qkJg1A8iWMWw2ysRhysVu X-Received: by 2002:a05:620a:9da:b0:785:5b35:d64 with SMTP id y26-20020a05620a09da00b007855b350d64mr6435944qky.71.1707726382505; Mon, 12 Feb 2024 00:26:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707726382; cv=pass; d=google.com; s=arc-20160816; b=c30zOlJUiclZGoBXXdNkt5bugCfW4d7xr6Ms2cpojbYRyfVzlRmkEiTgx+i4Vu3mu1 QSpoKKHqE6ID/FRHvpNOHJTALzA0RbYFwU1Wgf1+j+r2Lumc2wKSNhZ1n/7h6xALPD4J uGknxU3VxulAlH0Fy6VE0Tz1EkO9WOV/fA6wiKPIpievyouymHbvoFSUIhwceA7irqwn uBC+mH7FoQJvJhU54JqJBejv0oMGZzq2iSLR2GMUMoyUS04KztIjf89X5tIa8cnqJec7 j6HRNodhTo0lZiBDdtko3WqTfTSWjrSrNkXgLRLoW3SL3QM5XMGDVKp+QI8Jk2+5REIi 0UZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=YXz0LNNR8OkxZMAYpUP/ZX9iKlMCwh3Qzq5yWzxGRH8=; fh=tTUqzx02+wDL/wYrV1jqU/QFoirub736UoG2PYpCFlA=; b=tC9qF6rpFm9EQ+nV/k43/SVrOFcwUBarYqd18PZ5P9Zpi0r/CGcE4JSh0AHNXnADy+ yJ15XhtrwTYJAOEUV/qdNpNHs0F+1j+fx/pBKYFX2xmJCTf82c9oOtwk5X/vIxI5JXqe UUqKC8sVfeHeqe0PwvIg4mKZVSbYCWd6+9nEj26GJX2V7g8NkAkGykJ8ZowghUv4T3cU bWu9Bb9db1XIi9trSrw1OIVV+G+AHCo3lkFp+O0ema2sx/jR3Xn5yG+YGIjxPYeLlTv5 dp8ob18MkOakRknRiw/1IBtejxfoN8mSunKy2XHybkINcfFHU+XrcaX6iACpZAl6K/m2 VxrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@protonic.nl header.s=202111 header.b=V5gtppMN; arc=pass (i=1 spf=pass spfdomain=protonic.nl dkim=pass dkdomain=protonic.nl); spf=pass (google.com: domain of linux-kernel+bounces-61200-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61200-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCV5WeYt6jsY7nZDuTPcs8O72q46GJOsE/T/RXKUr6xG9Vp1psUGyowJDRjL2Po/50g//D6b5nc7PSu7240y+9avGRMda/riVnQU/CP9aQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a19-20020a05620a16d300b00785d92349e2si948598qkn.768.2024.02.12.00.26.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 00:26:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61200-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@protonic.nl header.s=202111 header.b=V5gtppMN; arc=pass (i=1 spf=pass spfdomain=protonic.nl dkim=pass dkdomain=protonic.nl); spf=pass (google.com: domain of linux-kernel+bounces-61200-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61200-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 43FB91C215F8 for ; Mon, 12 Feb 2024 08:26:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1E4FEAE3; Mon, 12 Feb 2024 08:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=protonic.nl header.i=@protonic.nl header.b="V5gtppMN" Received: from smtp16.bhosted.nl (smtp16.bhosted.nl [94.124.121.27]) (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 63483F4E1 for ; Mon, 12 Feb 2024 08:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.124.121.27 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707726374; cv=none; b=RdpoWlRlp4I8x1j+0gMkuZt49vUe7GErLK8wjJnz+N7BbqYaRjXtZcJUxtwEHR5u3hW17K/H3TnJW9iTZpcL9RHS4QkzJHzTUvfTd8TGkM9pjDpErLvjC5CMvgJ6oySAz4SBF3zzP70846hUHTg85jY7VsJMZoG8KYlxoj2wBds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707726374; c=relaxed/simple; bh=tS2qDv3GgiXZz1YCxMg6iiQZEazGXR37umtYi+ZnrIk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VDtLD8TmbZlTecDL+N7JeNLAB61l1jFvdvIWwZ3GiJD11fL08GOZ68+jj9xogeXsM26q4LbfzXTMTG3Px4IBcUU+V/NyQbslHkib6O3nvPtoVPw8UmsuhRb2sn8MnhwDzZ3A2XcfLTade3iJqP3cMLzdS3fzBrQOUXPKYSzfwn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=protonic.nl; spf=pass smtp.mailfrom=protonic.nl; dkim=pass (2048-bit key) header.d=protonic.nl header.i=@protonic.nl header.b=V5gtppMN; arc=none smtp.client-ip=94.124.121.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=protonic.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=protonic.nl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonic.nl; s=202111; h=content-transfer-encoding:content-type:mime-version:references:in-reply-to: message-id:subject:cc:to:from:date:from; bh=YXz0LNNR8OkxZMAYpUP/ZX9iKlMCwh3Qzq5yWzxGRH8=; b=V5gtppMN8pKLoRnUw9GBoSpHtlRT+rM6OH7o1+pAsV29qc1m6MfykVGOyuL2bTVooiRjMm2aWfdRd ZpXYTHzA8dK6pAeipXSQiLp0nfr6BeS96Z3wJeYZ4c05MUpb+KZco2aD+1InQPb75p5LkMsyp7goKK PhiLNV+81okPqPKn2ph6N/OEhk2vI8mcK2SFie2NqYApvpnzYxqZ0V/HP5KUB2bvCYpmEJePBwdR+n 2akHBV6cmBJzGymiQeiwILT8KgxXjWAnzChy8NR4QpJb2NckaoNxYsjvHDHAV5+T3ct1/1x9vaFTgr RBMMpGcZy0PYCavI0nTtH524FdQT1Uw== X-MSG-ID: 37173b61-c980-11ee-a383-005056817704 Date: Mon, 12 Feb 2024 09:25:00 +0100 From: Robin van der Gracht To: Andy Shevchenko Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Burton , Geert Uytterhoeven Subject: Re: [PATCH v1 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp Message-ID: <20240212092500.62f006cc@ERD993> In-Reply-To: <20240208184919.2224986-11-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> <20240208184919.2224986-11-andriy.shevchenko@linux.intel.com> Organization: Protonic Holland X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi Andy, Thank you for your patches. See inline comment below. On Thu, 8 Feb 2024 20:48:08 +0200 Andy Shevchenko wrote: > 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-display.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 = parent; > linedisp->dev.type = &linedisp_type; > linedisp->ops = ops; > - linedisp->buf = buf; > - linedisp->num_chars = num_chars; > + linedisp->buf = buf ? buf : linedisp->curr; > + linedisp->num_chars = buf ? num_chars : min(num_chars, LINEDISP_DEFAULT_BUF_SZ); It's not a big buffer, but now it's always there even if it's not used. And even if it's used, it might be only partially used. Why not used a malloc instead? > linedisp->scroll_rate = DEFAULT_SCROLL_RATE; > > err = ida_alloc(&linedisp_id, GFP_KERNEL); > diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-display.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); > }; > > +#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;