Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2143515lqp; Sun, 24 Mar 2024 05:19:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAi134yn3Wer/d5Lh72dISmsGrlMKf/+HEiFIhoXOct38VlmTV7ZYJrIL2ilDPW5Yvvn6Cgqr1XASfGFge6s9V6aKLDC5vb+Qu2hhddg== X-Google-Smtp-Source: AGHT+IEOvd4HfeknY+ZB8/mClujc714NiFweo3ziZ7vHgxhzHwxmt9tYYNyt1KyveGuk3WjEG2TJ X-Received: by 2002:a17:906:3b4d:b0:a46:9985:b265 with SMTP id h13-20020a1709063b4d00b00a469985b265mr3454443ejf.48.1711282756286; Sun, 24 Mar 2024 05:19:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711282756; cv=pass; d=google.com; s=arc-20160816; b=I8XLslb+jQclV2u21mLA3BdAbK/IrsNd0uppQouz0L3bUYWicez/AIhUGiLr11zV30 8nRaPePxrWrAPQKlU9n3ezKkZXUod3imGaQJ/AfC9zMJgtuhFRUyThM8V9RTGB73GFm7 kgv3QXqrrWFkdV4TKwTcyfYwGvSDFKNhn1mj9wm+k3IXjZTrQOaAtqq57h5rFu5UUoiC DbwPehZzgMbBSYRNXKJEBRkZc0SwOYJOvqmj5N+sRiz1eiZ9qon5UTXjMhq5ogFO8L4d 8S+BNLIo1NRro/qxk14v5yCCvU2/BhRYdcZxUK1lsz0D5hESy05wcwUp5Eh/g5G+kzgu Uf/A== 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:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=3pEPU/lCi+quXHKjvg8oII2dVFw8fvGMLLxADC7TjaA=; fh=2NN6EXegScgCLKF+RyDJVhH64+rCXPclxCc+GbryVeQ=; b=c4A9+xR5ixV7RhFg/aJJKtsfeBf3635/Yk/8IyqcSC95f7B6wyZ6Rv7Q7Mvj+e6FpU ntxuohroXhPzy1cbPxBLQOAP+e80fmvzjO7kmAky6HVIzjvZab11RQohncoOa+ipwHwA ctGK41IuDqk5KI6BhgyjoOy5/VDEfFPSbC72Tn6OfV7Abfj3rUdVM7FJs2Cf+U+fudFs OS9uvQHMyTTTn+DUSBFezfvhpL9pwfOJ1tzIwQ88fjHD3+AilEQXsZRhbmVOTiDEuPHD HsonjBjiffJl6CXtvSGwPdd7uWDPAdvsz9MwtWHOzqlX387m7n+HGW2VKNHu7iPKU3mu YmyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="YYMg6VO/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w2-20020a1709060a0200b00a4635b598efsi1671177ejf.130.2024.03.24.05.19.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 05:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="YYMg6VO/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 00FBB1F21477 for ; Sun, 24 Mar 2024 12:19:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A725F17BBB; Sun, 24 Mar 2024 12:19:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YYMg6VO/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CEF2B2CA4; Sun, 24 Mar 2024 12:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711282747; cv=none; b=pbGuRqq2nXqSdO9u1zJIHVEHlRBrC6R9KrlO/JNPArfXZpm6l1guHEuRvgBg9RDQHnoPU6W+4sCvLkgiSvmA515jTWmS5ypJQJ2MTLGOuLjdn6dF7EwAyDiH9F2T1emjxKO04l36VVOsJqAZcaC61IxXO+00EgYsbVj0Xm+dEFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711282747; c=relaxed/simple; bh=+pU0k+ZWilbCia11XhbE7gGOdKY/GmRecul8h9PKu88=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LQeHp5lpuJRbGHynVivNYMfOYr0wzmmejL2U+rDLvb7+TsK7vF7ZC8K41jK01D+ltDA7kyOLzH825YP3J97WuMYv6yaJhyO4YO+3WnFi1Ei2YylANc5pdlJ+kjDvEZBjGzGASD/mVGbk+myIDTXxUOXXRwom9dckqBn/6odCEQM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YYMg6VO/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9E44C433C7; Sun, 24 Mar 2024 12:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711282747; bh=+pU0k+ZWilbCia11XhbE7gGOdKY/GmRecul8h9PKu88=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YYMg6VO/64puC/UfwZMRjYpEiwE10K9N5zInYwqr9GFBeEjm9EIgT2f04QGJ4WeYC 6A+jillw6tEA3Y0HS56QKe8LahS8ev7njVTBVN4Qqjaeb/+w9WfntMLFzjpR9NK3O0 6u1UbMxKNfCO4vJ6q834jG31nz3LMutzsdjRKm0fXrfy70nn/y0QsZHTXjbhRO7kR6 Jh4qaF353ifpq8CmzsCj7w19wODa3f72Z5W9OwQ5Tm5b184/ux03gbGtYqFp+OZ/RS mDebvOoBO8+CiRW8mZzkNkgNl/I8bo1a5HA6r9FEoZ1z7rocdlxchm7zt4mMSdA9Ex AE26KNGlwVrBA== Date: Sun, 24 Mar 2024 12:18:53 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: David Lechner , Michael Hennerich , Nuno =?UTF-8?B?U8Oh?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: adc: ad7944: simplify adi,spi-mode property parsing Message-ID: <20240324121853.460ba5f8@jic23-huawei> In-Reply-To: References: <20240319-ad7944-cleanups-v2-1-50e77269351b@baylibre.com> <20240323182918.2cf624b6@jic23-huawei> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, 23 Mar 2024 22:44:37 +0200 Andy Shevchenko wrote: > Sat, Mar 23, 2024 at 06:29:18PM +0000, Jonathan Cameron kirjoitti: > > On Tue, 19 Mar 2024 10:28:31 -0500 > > David Lechner wrote: =20 > > > On Tue, Mar 19, 2024 at 10:01=E2=80=AFAM Andy Shevchenko > > > wrote: =20 > > > > On Tue, Mar 19, 2024 at 4:28=E2=80=AFPM David Lechner wrote: =20 >=20 > ... >=20 > > > > > + ret =3D device_property_match_property_string(dev, "adi,s= pi-mode", > > > > > + ad7944_spi_mo= des, > > > > > + ARRAY_SIZE(ad= 7944_spi_modes)); > > > > > + if (ret < 0) { > > > > > + if (ret !=3D -EINVAL) > > > > > + return dev_err_probe(dev, ret, > > > > > + "getting adi,spi-mod= e property failed\n"); =20 > > > > =20 > > > > > - adc->spi_mode =3D ret; > > > > > - } else { =20 > > > > > > > > Actually we may even leave these unchanged > > > > =20 > > > > > /* absence of adi,spi-mode property means default= mode */ > > > > > adc->spi_mode =3D AD7944_SPI_MODE_DEFAULT; > > > > > + } else { > > > > > + adc->spi_mode =3D ret; > > > > > } =20 > > > > > > > > ret =3D device_property_match_property_string(dev, "adi,spi-= mode", > > > > ad7944_spi_modes, > > > > > > > > ARRAY_SIZE(ad7944_spi_modes)); > > > > if (ret >=3D 0) { > > > > adc->spi_mode =3D ret; > > > > } else if (ret !=3D -EINVAL) { > > > > return dev_err_probe(dev, ret, > > > > "getting adi,spi-mode > > > > property failed\n"); > > > > } else { > > > > /* absence of adi,spi-mode property means default mo= de */ > > > > adc->spi_mode =3D AD7944_SPI_MODE_DEFAULT; > > > > } > > > > > > > > But I can admit this is not an often used approach. > > > > =20 > > >=20 > > > I think Jonathan prefers to have the error path first, so I would like > > > to wait and see if he has an opinion here. =20 > > I do prefer error paths first. Thanks. =20 >=20 > Still the above can be refactored to have one line less >=20 > ret =3D device_property_match_property_string(dev, "adi,spi-mode", > ad7944_spi_modes, > ARRAY_SIZE(ad7944_spi_modes)); > if (ret =3D=3D -EINVAL) { > /* absence of adi,spi-mode property means default mode */ > adc->spi_mode =3D AD7944_SPI_MODE_DEFAULT; > } else if (ret < 0) { > return dev_err_probe(dev, ret, "getting adi,spi-mode property failed\n"= ); > } else { > adc->spi_mode =3D ret; > } >=20 True. I'll take a patch doing that, but I'm not going to tweak it again directly. Thanks, Jonathan