Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp930141lqt; Tue, 19 Mar 2024 08:02:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUBtEK7Y514CMzenTQvQciDmCzOJAS+U2WSlH0Z5KnDeDKMo3nkY3/4/d58/hSjX/iT7OtlW07HRNXLZmVzfsHn/ts4JNNH/3vSCOcFTA== X-Google-Smtp-Source: AGHT+IF7eQiUeOYl/BEtRw8/NiTHD0iUG5EVyGBHT/9KgcSmUcTYN1O3aJM0iEzECK2HlClo9b6b X-Received: by 2002:a05:6a00:1813:b0:6e6:9c97:c712 with SMTP id y19-20020a056a00181300b006e69c97c712mr21277845pfa.22.1710860521870; Tue, 19 Mar 2024 08:02:01 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y125-20020a62ce83000000b006e6b5034cf8si11318869pfg.254.2024.03.19.08.02.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 08:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107684-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fC6r3HpT; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-107684-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 86805282CB7 for ; Tue, 19 Mar 2024 15:02:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 89CAC651AD; Tue, 19 Mar 2024 15:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fC6r3HpT" Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 407241E861; Tue, 19 Mar 2024 15:01:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710860515; cv=none; b=MTeKZUviFVJOQEomIY6hi9MyAmk5S7n/U7ZfZTnCMs/mSE1o0vmlfmFX5TFP0OZt/kAbibP6OAdSaNwAdcR14AjRQnSsDuOpAyX8cOYXzGqBOc170J0ejgJIfxexenitwqLZNHImu82hE62cRlExQ3hvvALrFitaInieRF4obzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710860515; c=relaxed/simple; bh=0pg+p+nf+gQwZknlBsp0E0M/W9JhPC25HviPI27Kock=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=sCIp3FwBiwhH2eMx1VElhsGTS9SVj/LSNGveo5GxqpB3aYI2gQlzEtWOcysPngii2j3WlS8tp+5yqSXZIOHBeOpNa2dquhm+LyVCS4Q/aCkR42qaK+FzR7eElX5FV/lI39YWNViDdDuT7s1tR4fXE5bYeKfWXV1OT7HXnKSeEh4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fC6r3HpT; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a468004667aso605829366b.2; Tue, 19 Mar 2024 08:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710860512; x=1711465312; 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=UCpiZXeeM4+jAqCK5wbO1N4j3AitpXA6Bk+sr2xjkM4=; b=fC6r3HpTG0cqgCAmznqa8Iyfnp82rka17IfrcIVYYf5vzhXED6JkiKFUL4niPK0vnO xOhf0RZVOARPro7u9ld9ptK1BYnUE44St73EBK/9pi5NtoHUiHTxyNfZHl1Vr7W1jajL UOYXQJ8g7Kk0sJVJ++ZTHydBCDH1NjP0dGsUA+ccPbAgJqU9I2UBBVGnvZxsFNelljGB AZ7WowSj1YFCQ02f/yAJr8Gda6C2ranMXvh44HeCAn8cihmnZImrNuvhxRYpQVyd1wUR ng9qVtZ4YoawHDdovdZZbI8Vh6Zdpo0FYVQqj5VC+P8SQmxokO8Niahcn85gM8zbPrbR tzkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710860512; x=1711465312; 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=UCpiZXeeM4+jAqCK5wbO1N4j3AitpXA6Bk+sr2xjkM4=; b=pLiXlOHRlIk139EyKjr4BB/8ouj2ZnhfQItdQMHN22bvSYApWQXRR6phlL8NvDqVwx Pq+n34L3bi5WX4ZYrPFF3g8HVLgmej1fca/B/4HabCQkWbjir4Wgh+EDYYU+HcWupPgS F+5JeDLIV2GZdM0SmDnB8GP2X6CNgVX91MpgifwGm+iEW8Z3cmI7A0lvw5r8/asz+7k0 SCCyGOoUpJFSwLjouIabsgzhH9xVgz6xTIxe4qkVi8fSvq40amzvffWvJKWv3bf38xX9 MWx893rnewNKLI8VLZboIPdiGMLoJHAG0jZdOTQQWkYvzM9bIlKA3qGmL7+V0MTMDyAO cTJw== X-Forwarded-Encrypted: i=1; AJvYcCWU+SEb6BdXLOdsTTaBzs4y9rlEFI314HB54XYntYb5R8N4g8xWtGA33k/uJ6/Q4JcuJ2CZG4fZ+sbkijCnXA5JF3hrSBTfux5rajghFRO/VKb/YBiGWmVqLP5exsrR0a8uvNwoJQex X-Gm-Message-State: AOJu0YwBQ6D1Y8rY+HGIrbW3KZmtlx1DLVRAYqwkuHjBvNx9bhXt5Atg SvoWN4idbE2vwkyzx5+vxhytgyBAvtzeeYGhahQGVFKpFHde0zkc/hGS8AIPdq3NzU5yGo4Eacz il9dlJzTKIKIt2xwwXlNW8k3auNU= X-Received: by 2002:a17:907:20e4:b0:a44:7ad0:8069 with SMTP id rh4-20020a17090720e400b00a447ad08069mr8723201ejb.72.1710860512111; Tue, 19 Mar 2024 08:01:52 -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: <20240319-ad7944-cleanups-v2-1-50e77269351b@baylibre.com> From: Andy Shevchenko Date: Tue, 19 Mar 2024 17:01:15 +0200 Message-ID: Subject: Re: [PATCH v2] iio: adc: ad7944: simplify adi,spi-mode property parsing To: David Lechner 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 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-mode"= , > + 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 proper= ty 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. --=20 With Best Regards, Andy Shevchenko