Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1852651lqp; Sat, 23 Mar 2024 11:29:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYDy8zwCOeIynK3d249QryaNXoiU05WtfjSVTBa2pV9piAXKDxp1eQBQJhq1g7Yic9UawMW5A8ICZkVnZICS09O1BL2hend5ddodB1hw== X-Google-Smtp-Source: AGHT+IEY4D8P4M+5iwHmpK9jwhu+1R657SJx1MbG65rwHCis3rvnFDPZZJ6Z1Tu6tMtZUq1tVAhz X-Received: by 2002:a50:ab53:0:b0:568:a8f5:d47d with SMTP id t19-20020a50ab53000000b00568a8f5d47dmr2097426edc.17.1711218579553; Sat, 23 Mar 2024 11:29:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711218579; cv=pass; d=google.com; s=arc-20160816; b=Ybk8FS9Hqw7mRlBLNXjFkSMO3enI0siZVbzi8RT7qniZJ4E4URuis0NiKI1VE/AmK3 lDAkqsoGxPsXkIdznYYkuKdjBUAGxBgSu1+TQ1WUxhtVFiR6yUga7MUQZSybo2AVC4Dn oeHv1tPTMIVGasxhyC952SD6HFeoEKXWsd0IrAOmnKU6PIq+P8Y3Haknd+zHw0nNk2kl AjLF3PtkX7SScc+dnPw8Q5IS39A+0a3PFq1d2Z4duEKFRENjK9ZueNSyjUheEsTDlB7j 0ZbUiwdzMyFHmtMqbkafRdewQx4ejoDIjF8xbr5d1SQiAapfmAV1IlCUC7dMklN4e4uV 3irg== 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=orDfZHktPHtaws4OixXJyYjZtGVsbMGBTqlGZmxX1vU=; fh=3tBOTQ1m4SCxPnMkRoJNjyEc++VwuEqgWxvbfUS6E0I=; b=E1En3+I+Y5slp5zGeCWhX4+zun7cc2Hk7dQMM8fXWcAa7i1crF/gdianAXZHb+YtPO xE1v+N1gW05zrWePJ4Dq5YONrs/4jFfZVjWKkkBSBM49iyuErgpIGYNZ4u1paUh7HNZz 5MKnJec12t5qD971cuWvAEpfe+Is7OSdQdfhRChVq+Q5jlu/2LigWvYv83vlALRc36jC 6tbRP8alKwjuKYhgiw1cAYOtwRoQQDDW/wu4d6t67ts7X/Fd1C2eYR2+EVtMtmJO+U89 gaDeTjEYtNwWldY9Yyl0DPlG4QvCvC6xrOpFR9aNPEk5KkxwUTeGNs2ySCyHA7Gfe/vX ir5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EVb3S2e2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112445-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112445-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. [147.75.80.249]) by mx.google.com with ESMTPS id s7-20020a508d07000000b0056bcfefe3bdsi1014145eds.536.2024.03.23.11.29.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 11:29:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112445-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=@kernel.org header.s=k20201202 header.b=EVb3S2e2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112445-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112445-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 465FE1F2176F for ; Sat, 23 Mar 2024 18:29:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87C9C56B68; Sat, 23 Mar 2024 18:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EVb3S2e2" 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 AF09F1DFEF; Sat, 23 Mar 2024 18:29:31 +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=1711218571; cv=none; b=qNKLjKwmpDk0XE1COT8sGmSsIlQELlhISoqQOAUqCbDti5m4GI1x3rw3Rob93DvehqBExA62I8PgORNjUkEkzxp1qIj9e+zFHjzTIInR7vk8nu5jLTEsZuRr5e9YlgZqjsZs+VqN4YHj/OpZHt5KW2GP6tCkvBHs829iWqjYuws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711218571; c=relaxed/simple; bh=6yjkejHerchkwYd8HrquKgDGVDNeDah3/MwMAMh7st4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bm0vBT+vj+BZSB6y2vN8kh2v0GCr9Nm6VdGuyVHz/2wO5wT1sllP3Cd9oDjefTKn8Vm5GS6kSsXCeOZ85zJCXyk/MDCns2yBG9Sp82r85Kgu05wwv2Sy3d9qFNQ991k7vntkBg6oe3k33OcPGVX8tQZJDfZt2LW8Frqa9HNWhK4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EVb3S2e2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E17EEC433C7; Sat, 23 Mar 2024 18:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711218571; bh=6yjkejHerchkwYd8HrquKgDGVDNeDah3/MwMAMh7st4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EVb3S2e2IORuiDrurXjosYAm4DKSJkOoqGFqw6X39mGmqcjT0bxQssm4gEKYTrBui Cyq5Fj+1XIgAm0OjwTFM6JOaiu+synfdIqFuzyaKs/J5f3GFZlMIeR9GLNpXfzW8I7 n3KaHDhpL3JXhik+ZPimP21iBNSB+Z1uOzJQQyfhMndxVOnhx2W2BwYDldR8jsHa3I XLD5zaEsigRLokVM8NicMv8M7njTfz54kQI3m76X2ZADFPNVE1DeD21dTye6VodXMN bOzuAqBq5cPcYQ1QZMLUO5z0w6fk2olpsoUuZvaMjeh+2I7bjh1DcHbe38kI4HK1Xk 3udu5npVgWaVg== Date: Sat, 23 Mar 2024 18:29:18 +0000 From: Jonathan Cameron To: David Lechner Cc: Andy Shevchenko , 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: <20240323182918.2cf624b6@jic23-huawei> In-Reply-To: References: <20240319-ad7944-cleanups-v2-1-50e77269351b@baylibre.com> 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 Tue, 19 Mar 2024 10:28:31 -0500 David Lechner wrote: > On Tue, Mar 19, 2024 at 10:01=E2=80=AFAM Andy Shevchenko > wrote: > > > > On Tue, Mar 19, 2024 at 4:28=E2=80=AFPM David Lechner wrote: =20 > > > > > > This simplifies the adi,spi-mode property parsing by using > > > device_property_match_property_string() instead of two separate > > > functions. Also, the error return value is now more informative > > > in cases where there was problem parsing the property. =20 > > > > a problem > > I'll fix that up. > > ... > > =20 > > > + ret =3D device_property_match_property_string(dev, "adi,spi-m= ode", > > > + ad7944_spi_modes, > > > + ARRAY_SIZE(ad7944= _spi_modes)); > > > + if (ret < 0) { > > > + if (ret !=3D -EINVAL) > > > + return dev_err_probe(dev, ret, > > > + "getting adi,spi-mode pr= operty 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 mod= e */ > > > 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 mode */ > > 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. I do prefer error paths first. Thanks. Jonathan