Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp949636lqt; Tue, 19 Mar 2024 08:29:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC64zi1oRHT8eEYe2JKenCVDXrkYArKc+PVphL9CRZ9TqemwEZTMe77JjolZuJBiqg7szTtyc64DAIYHdFYGunk/lfsYaUG/A0q5xLpA== X-Google-Smtp-Source: AGHT+IH98BxbywsOLdYRzbEdrsgp+GQeVIAz5etWg1RcITDhpy4AkxZcH2zmzGTXtikLa57MzWyV X-Received: by 2002:a17:902:f70e:b0:1e0:1d7f:b787 with SMTP id h14-20020a170902f70e00b001e01d7fb787mr3395354plo.51.1710862140411; Tue, 19 Mar 2024 08:29:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710862140; cv=pass; d=google.com; s=arc-20160816; b=A83yH7DBrh4iyZ+jyHjVDLFTV7/BbnYIgmrMb6Ba8exCZ1WLpa9GvK1U7sw6b9yS8/ TuQGrIwpJ/0I+i/uIkRKiYxZWMZ2tCRp4y6h89VBMkpWWz1n/TPFtgS7A8pGJ4aCiats NycCPCimYBJvhMzpmBfZ/QxO40VFfHkriXYBvu/RqdkB47RAQ7OlynyhBEd2q30UPX9F FgmMc/eSknLZNaq5jL0E34l1NpMSkW4ZcLJmRezUoRpsGT8tg/9nvf/1Jk8K3LPZ5EjU AABkj/HSUhM2x8abh0YP/KiE2aziJuLj5kDsUYxb6GWmRj9d/n8ZYmbh2ngUNsEdCvwl BwNg== 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=L0YRQCzEtPOovqBNC+M8TvgB+q1bgObduWmwuxVs4xE=; fh=7F2SZRGHlXzFBwp9mkiopd0OBS3MXL2aQbuKl0n4H+8=; b=C6AkSbvk7V0/Xe04psLJ2rDZqf4eNP+3w9MYZlwX/nM6daazMpop0uaruV3VHs6Sko NQ1rlPMrA3CN6r6nCVohYFV3DOO4akTPlommJtphQlAxSkyKi+hjvRx7lY+xmePMKtZe L8GN6i/4C6nKDlxdSnE4stF8pT1Fgb5zrk5m3CDpihzeukJ0qmrXlkyloFPl7wWAPvrI R2P+5JNc/wg0rCdO/Wwugb9+/X+9voNKzzl3F+zPTouo3SrE01aMmcmflvBeCQFQAz/s vSnOislpEefREMaowoknbLsMbkW/SWymNcSUmaUKsQoRdDv83JdEfXHnhTo/QkI5ia2T SDdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=koSpH4Tf; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-107712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107712-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s15-20020a17090302cf00b001e02c9535e4si3795319plk.0.2024.03.19.08.28.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 08:29:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=koSpH4Tf; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-107712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107712-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A1763B21426 for ; Tue, 19 Mar 2024 15:28:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4F78657BE; Tue, 19 Mar 2024 15:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="koSpH4Tf" Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 54C212D05E for ; Tue, 19 Mar 2024 15:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710862128; cv=none; b=DshVwysHwOj4B8fHPYzosJlulQbkLmpe0wWogfD7XdkiItHSJaxCGPGbPZ8jJZpv54XgY3Rz3Vdl+hoxozqJPR49ArYWWC956zis+fnIE4tOJRkV6N/1uJ7JlBezdW9pc04899u0bM4fUPuvlZ+nQg1XmAe/HHM9/IK2YfZIN0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710862128; c=relaxed/simple; bh=12kIwNAxFbOIGoSa+XT9zKHmXpAAXrGcmFskxrE3FY4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=oMh8w6dgavOnQGUQAC61rhZY7ROeKu+RVn0D9iSC5v4CzvMVB18HU9aqKeiO02Vp9I4dSHPlv+QbR5WK3o++WdcqFybwM/Syupx1FTt+OxPHPiiH345xsqodTMGkPpGbhEulIvS4eOktdWfewrx2AD2vIUU8MrAAlhs8mV3OKnM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=koSpH4Tf; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d687da75c4so7606631fa.0 for ; Tue, 19 Mar 2024 08:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1710862123; x=1711466923; 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=L0YRQCzEtPOovqBNC+M8TvgB+q1bgObduWmwuxVs4xE=; b=koSpH4TfSiPqpr51FGdLdyJz8Vsy2XzbkLTD3PxZslCYXZdWvx73ffXYzVl5OU/Iax pfbGXyIsst08Z3T2QymVjx0CMwR0ZMTUj20utZSLH7Q+r7bv5/AQh7DP9Xdt9d9attvS 2LBJ+c9AB5/mTh7pogQCEHJE8/zLQSzhHY3fXXHbPtfIIyFjbxtmyXLgd/w/YMkexsWa aFfIXn9DuzNk7nPOnpRrdg1VNlGzwFq9NH++bDzrv/tYOzhQ9KzvSaOsh7ajFnyVI+Vt EfrOuC51Lu7/6VJkzkrJrDiyRHsr+pA4kWcEC9rqjCjwAj7msdL3ra+HFjYi+Lo4ko4y PCUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710862123; x=1711466923; 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=L0YRQCzEtPOovqBNC+M8TvgB+q1bgObduWmwuxVs4xE=; b=BEWzbSDa39NOppaRS28ESIKVdK3Avedl/BpDgunpdLrmZIaJfJHQk41hvL0XcsxfOy +G9+QtF6vHcNF/9BkR8qrDeReJCsp4nrLhJvn5viU4CCeqhrZiC+faPKCdkJuv9xOY5g wrnQmSYmrI1QyCDQUTg1mVE0u6w81BRNTQM1dQyElh3GeE1LyBfmWA1C24PP/ZDHxFEt tztGsEeOYppWlEWoLld/ufhQ+RkcLUhp4Xlabw1YZeeSIzAUypvmEVtYUy8flBYbI8VF HJemj8wsi0ARzubFiqRyuvgnkPpQXdcReD69Kt3fnKKIb1ASkoEAVgtbd7fl57ateMXS J1bQ== X-Forwarded-Encrypted: i=1; AJvYcCVaBTSDHXW/hREHJzRBJfSno/MwpTzID/dcZ/XN4B0OnHE6rra1kkEhjkDku+od6Z1XRfzPczLNM/Kh6zI5g8LQ5XFKBwxj/sshJDm0 X-Gm-Message-State: AOJu0Yylk8Ju3pTJ4iVjv8p+dB1CMWzLT/wQdzuS5LAp0kyADlLki1Cm vzvgbxOn7pza5fB0b/EuaeW4bPYLRX+KDKz5NZRqr5FogDx0TnrTOHH1xcQzZh28stbpcGxdrJk jLyPnpU6Hwr/mKYMrAXoBmplgHMbR4QoWPvSCCg== X-Received: by 2002:a2e:b16c:0:b0:2d4:61b6:7a2a with SMTP id a12-20020a2eb16c000000b002d461b67a2amr10423928ljm.1.1710862123335; Tue, 19 Mar 2024 08:28:43 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240319-ad7944-cleanups-v2-1-50e77269351b@baylibre.com> In-Reply-To: From: David Lechner Date: Tue, 19 Mar 2024 10:28:31 -0500 Message-ID: Subject: Re: [PATCH v2] iio: adc: ad7944: simplify adi,spi-mode property parsing To: Andy Shevchenko Cc: Jonathan Cameron , Michael Hennerich , =?UTF-8?B?TnVubyBTw6E=?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: > > > > 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. > > a problem > > ... > > > + ret =3D device_property_match_property_string(dev, "adi,spi-mod= e", > > + ad7944_spi_modes, > > + ARRAY_SIZE(ad7944_s= pi_modes)); > > + if (ret < 0) { > > + if (ret !=3D -EINVAL) > > + return dev_err_probe(dev, ret, > > + "getting adi,spi-mode prop= erty failed\n"); > > > - adc->spi_mode =3D ret; > > - } else { > > Actually we may even leave these unchanged > > > /* absence of adi,spi-mode property means default mode = */ > > adc->spi_mode =3D AD7944_SPI_MODE_DEFAULT; > > + } else { > > + adc->spi_mode =3D ret; > > } > > 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. > I think Jonathan prefers to have the error path first, so I would like to wait and see if he has an opinion here.