Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp50216lqg; Fri, 26 Apr 2024 08:29:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLnMMTe5sRHCVYkSoxyqeEi/J6QCt2oZOVK2fEnsesqtiKgDPY9l2fTaYR4XwLXEtr65hpLgSCUjQjIIc/nLGntl4DtnSABX1H4sJ22Q== X-Google-Smtp-Source: AGHT+IEBvuvAIAbpXgKwo0lZcwpzNpXuetgaR+Fi/s1TSFF8vi2Vv+fs2EDW/a7Nq3IiagcjeZ7H X-Received: by 2002:a17:906:3145:b0:a58:7ce0:8e13 with SMTP id e5-20020a170906314500b00a587ce08e13mr2064642eje.34.1714145345591; Fri, 26 Apr 2024 08:29:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714145345; cv=pass; d=google.com; s=arc-20160816; b=Wl37Oyctqjk66f9aqu8Z5GkJsoYL8UCY/DVSLm3hmNeA2U3TxQmKncjaeoSxw0n+p/ V4LQjETH9QaSt87Dpv9Pmm3/W20sQjG9HajKrpin6sQ8QZNG9/QrmLUeQ2o3Rd98q3bl AoO5O8le4rjHGhQ7o7S/JsoNm5TLuxBCbMqeXlmhRm18h5J1qK/z6QAuPeBEhiwyRIvv jBSH7DPajEkkfwltuPCBKJY7CdVi8vdbxTD6A1MEEei+pmQepTzlRn8RFzXymEuzu8Oh lEO59TNPrJEoLgNG00yDEiGvTITGdAhTVrw5umMw0IBjsEf/nRGdihmgn1Gcbnma2qkW JzNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=VL2JVp5517IAZMpOsSFYe/avtgfEuaWIXQ+vHOFMkZg=; fh=vR7WsEJBNt+u6T/1NNMRVTu/PKbZNqvvF7rbEI+koe4=; b=MvVit3ViA/tub+FnE/ihj5DaGVMYOJTa3l+PdE4MQNz1IhZCHkLFx25u0sVRrx0umV 78TYOramWARB+5ebpMJ9yx6GbU4T0IXy/odjCXmpROWXL+WgB7EGdCNxs6Ou+7STD3QP oeZy6p2hL4DbtsBKjt9yBUQNGzzqaP5sErI5o9cHH22FEpE450gVcXjjFbq7aSTQVWJ8 44HMIubPDOJPl0yM2T+ono/vI6xanMbUDNexAWNv4bAKmR7PmF99KhE1UeaiKJ1nSZP/ esU1ygToNGPjZ1Drqb0tfMFDA5qCR1VizEgHMK6vqIFi9ELYr/cpuxDNsCcty2YktNH5 41IQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DM4OUv02; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-160286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id sh42-20020a1709076eaa00b00a559f2abcfasi9294626ejc.357.2024.04.26.08.29.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:29:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DM4OUv02; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-160286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 077461F21612 for ; Fri, 26 Apr 2024 15:29:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EF82149C73; Fri, 26 Apr 2024 15:28:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DM4OUv02" Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F10911DFFC for ; Fri, 26 Apr 2024 15:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714145331; cv=none; b=oSCxB9M56mx/QuhYN0mNLGWHliJIlBCwKu0tN/JqGdCB5vKZW/jrOAAZCnVNCNyKdwFdjUvpFly7zKWqZ8TPThgHh67oVPC1Hqntq3KyF51fUz1FV66EjCQo8s8p3hlE1tFJDqEM7rQU+MewsSR4btcOtZcCbj6+vxmU0snFd9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714145331; c=relaxed/simple; bh=z3wetYYdH8wk8Em0w+t39MUpCyxIrWZv9/n56pQWjAY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=g/tfLWFnjxlrDuA6AkcAfQRqMs6uQ0BY6z+4rfkJASviED9t1GR2aEIxR89E31l20CZCZC7nFH6KGo5qCklVcVC6FbsisGFaHmFF0N2UL5F2Q/IIUQBIQjVXR9H8LD8qEzeICioeHmUPeU3u4tHPSkFbtmyWwoJN4PChZdjD/GM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=DM4OUv02; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-78ef9ce897bso144454485a.0 for ; Fri, 26 Apr 2024 08:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714145327; x=1714750127; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VL2JVp5517IAZMpOsSFYe/avtgfEuaWIXQ+vHOFMkZg=; b=DM4OUv02f5NlrTrhb8EmBrbOEAJdFDev1vsmTJr01j3Rg1eRtD2ligx+FdLejLiB8V gsOvl7vaiqlW+Q29Z5hash7Zr1hDZimy3oR9dWUTml7arbYvQ/IAMF2Mq5QgQlghfWad csH1wSRx113nKTLV/Anek5gGeD+Lpp83Q2n+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714145327; x=1714750127; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VL2JVp5517IAZMpOsSFYe/avtgfEuaWIXQ+vHOFMkZg=; b=umLR9VGl/IloPEGQIL0N1z0ZzvYhWCz6CH/GDOY1SCAFyzwC9fUCQDIX7iSIlS8ELs S5xHBAGj5tU3Kp5AZgDm/K8A4abl+9ebYIv34Giig4/ZAvNFjO8TwLRBKbyisIeXqPLs ziFoOMbHBYLsXKlDw0vcyQLd0AQyp121MWrRVQZqChj36kW+ffOIQVEZkHxU7yGvs8LC WDIuQnLG84J03aOCPaEyusHucHEVNc2iBez5wc3B5q4/W2XsegrmzmVxVCSPERtUH/a9 rIFEn8fOGQTMrET8qGxCWQgobSaN6twMvo3g3fTr1oLVKL0UZsz+eECisvVzYgbmAD9s ha0A== X-Forwarded-Encrypted: i=1; AJvYcCXG5QVlM4pN/m39T2R4/6DKoPnQgnF0vCfueaJecm1hk6rMgNr4JCJGLQrFupbmOscbVf6jxKxXCL9AfFx2OGOFrFOo/ovgsN9PnoJm X-Gm-Message-State: AOJu0Yy+vCvgzlF0jGBE8s/n+mp3AsbCjEnTgG8e+exeqh4NyAnuUih1 IoPZG7zbZu9HqQQYFjrLZ149aFhEtH2RbBo8TUu7ZkAo+lzw8/fxWeUBD3fEF/SJPwGrVM4m5Wk = X-Received: by 2002:a05:620a:11ae:b0:790:88d6:7982 with SMTP id c14-20020a05620a11ae00b0079088d67982mr2978918qkk.29.1714145327439; Fri, 26 Apr 2024 08:28:47 -0700 (PDT) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com. [209.85.160.174]) by smtp.gmail.com with ESMTPSA id m6-20020ae9e006000000b0078efdcd9aa6sm8010659qkk.127.2024.04.26.08.28.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Apr 2024 08:28:46 -0700 (PDT) Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-439b1c72676so447831cf.1 for ; Fri, 26 Apr 2024 08:28:46 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUMUQho0g/THk0tWPEA8ZOsib9INcOoxoGBc/EToMeBnN8ThQrZgnlxgG0pL/qrRJJ0ZbYBVJpEpNAcTTM8LYWF8XZABkQEgKYkJd6I X-Received: by 2002:ac8:72d8:0:b0:434:d055:5b00 with SMTP id o24-20020ac872d8000000b00434d0555b00mr280304qtp.20.1714145326083; Fri, 26 Apr 2024 08:28:46 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240424172017.1.Id15fae80582bc74a0d4f1338987fa375738f45b9@changeid> <87pludq2g0.fsf@intel.com> <8734r85tcf.fsf@intel.com> In-Reply-To: <8734r85tcf.fsf@intel.com> From: Doug Anderson Date: Fri, 26 Apr 2024 08:28:30 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drm/mipi-dsi: Reduce driver bloat of mipi_dsi_*_write_seq() To: Jani Nikula Cc: dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Neil Armstrong , Dmitry Baryshkov , linus.walleij@linaro.org, Cong Yang , lvzhaoxiong@huaqin.corp-partner.google.com, Hsin-Yi Wang , Sam Ravnborg , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Fri, Apr 26, 2024 at 3:09=E2=80=AFAM Jani Nikula wrote: > > > 2. Accept that a slightly less efficient handling of the error case > > and perhaps a less intuitive API, but avoid the goto. > > > > Essentially you could pass in "ret" and have the function be a no-op > > if an error is already present. Something like this: > > > > void mipi_dsi_dcs_write_buffer_multi(struct mipi_dsi_device *dsi, > > const void *data, size_t len, int *accum_ret) > > { > > if (*accum_ret) > > return; > > > > *accum_ret =3D mipi_dsi_dcs_write_buffer(dsi, data, len); > > No reason you couldn't do error logging here > > if (*accum_ret) > dev_err(...) Yup, exactly. This is probably best. > > } > > > > ...and then the caller: > > > > int ret; > > > > ret =3D 0; > > mipi_dsi_dcs_write_seq_multi(dsi, HX83102_SETSPCCMD, 0xcd, &ret); > > mipi_dsi_dcs_write_seq_multi(dsi, HX83102_SETMIPI, 0x84, &ret); > > mipi_dsi_dcs_write_seq_multi(dsi, HX83102_SETSPCCMD, 0x3f, &ret); > > mipi_dsi_dcs_write_seq_multi(dsi, HX83102_SETVDC, 0x1b, 0x04, &ret); > > if (ret) > > goto some_cmd_failed; > > > > This has similar properties to solution #1. > > I like this option the best, for the simple reason that the caller side > is aware of what's going on, there's no magic control flow happening, > and they can add error handling in the middle if they so choose. Sounds good to me. I went back and forth a bit between solution #1 and this and I see the benefits of both. If folks like this one I think we should run with it. Certainly it's better than the current hidden return. > I don't find this unintuitive, but if it helps, you could conceivably > add a context parameter: > > struct mipi_dsi_seq_context context =3D { > .dsi =3D dsi, > }; > > mipi_dsi_dcs_write_seq(&context, HX83102_SETSPCCMD, 0xcd); > ... > > if (context.ret) > ... > > And even have further control in the context whether to log or keep > going or whatever. I agree there are some benefits of adding the extra "context" abstraction and we can go that way if you want, but I lean towards the simplicity of just passing in the accumulated return value like I did in my example. I'll try to write up patches and see if I can post them later today. -Doug