Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp153349lqb; Thu, 14 Mar 2024 07:51:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUH8eGkrvHxO4ZcXolIRZkzo09tjd1xv1ihPKkfvFP/WKFBzjBUV+aG0QrDptEFSCEYxkvI5VP1yL1CBDFPG6mIlr7DEmdlYLFeRqCrEw== X-Google-Smtp-Source: AGHT+IHKWurYpr6OIxsay7EBrit6nvcu8PNJ9nDX0Xo3DpPxgH05BuWEyICWVh2pjPrQ43FFizXA X-Received: by 2002:a05:6a21:9998:b0:1a3:48c8:6858 with SMTP id ve24-20020a056a21999800b001a348c86858mr357772pzb.2.1710427893425; Thu, 14 Mar 2024 07:51:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710427893; cv=pass; d=google.com; s=arc-20160816; b=Q+rO0ZYgRJ3DMDHboeFhBbrhuudpifjWP/oKddG+duMwBJENocBKJxjR1FicepHLfW vuwJUvGE9Ci8pxA65LMRBFPU7CbJVQsYUsWlMv4AkMHgBNtG4HgGPUqFUEUNzBPt78Hw 1CrTb0zKHK9P7S9Oni7oQ+ZjvjRmOIfC/JAoX0yjxx2MV8hnNK6CSIrAIkHSobpNxmPM wfJRPMaSbFuTd3yVx7aX+cdoioy0bXxO0OPdyd+PxMwT4tStyCO2VffErzW30NOQ3s6c A8S76VXXLmiEi7Hbk8AHhMEAGylZLSUTrrbXQ7zGlVCJmBuBTlxNkmqjSDTG9n5E/dLO F+0g== 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=E5dXVm+EhHcgcbP1e7za1ySA1t+3IF6ahoQKYn5AA4M=; fh=FsMhLzRJe2GFdj0S929tW72hB5/ciC+6nGR5Psy2pn8=; b=AqmI8c4+Psvf2WeTVFWpq287Kfr/prwhaAU+QGO/5PmZqqd2/oajyVtIKI2XCU9X1r C4bm6nFGyO0dULfiVIopDPyrLX2M55huVcj7vJOu4jlU4ckyh+q7rkVIKxjvNthV426G lYKUwapdPyrUUvYmhGRvkzwOECJVBwQag00ePRI0zuoyBgBXIOA8dtnOAlRbWbktqe1V H3ZwwL98+6GsS3J9AznH6fK/SKoOFxCHNQQsbUryF/PcilrDp5XSl4emJKlKk5ad+XQ9 eC8vT5jrfqArFrky7g5kODZ40It76FBSGQLDaVjonp3cfIsxiqNoGAoNDb/4XuO8GjWV XA0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JO0LR9Gf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103437-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ml12-20020a17090b360c00b0029b84ccf15dsi758679pjb.177.2024.03.14.07.51.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:51:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103437-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=pass header.i=@kernel.org header.s=k20201202 header.b=JO0LR9Gf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103437-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103437-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1CF51284BE1 for ; Thu, 14 Mar 2024 14:51:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBAB27172A; Thu, 14 Mar 2024 14:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JO0LR9Gf" 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 E60B76FE3D; Thu, 14 Mar 2024 14:51:25 +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=1710427886; cv=none; b=NMzgA3nWL5a/tAW53YuIzJyzyG4zPzZ+0dE5LDO4GfsWSUIXtPso6aBbayy03nk+eb18RAk1Ok3DZS7Kx7fQoL+vFmjX8e01bksVVKbHLEPzAHxQPH3+IWSvecm8RuZpxsQobBkinr4CzSvWFLGJiWZkcfTg/HUEOqj9e/bmk0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710427886; c=relaxed/simple; bh=a6BsX952dU3UtrN1MaRvQHUha3lFnaN4sTX2EnQLhFM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G/MbtrPgoqB/OzcSg/ksG3FfC0wRgZa3SRaFocgPJS4z3v6qh+8MzoCCDPVtNgSiPiVq3/5mws1WD/MQloiRXCFFnJmQZ9d+kRXXDt0ulddAT/kZgdCiPDna36lK2R/UY8CICcM9smRgx+n4O8CCjniOiQYw8Pk+tLszrzKKcx8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JO0LR9Gf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ED38C433F1; Thu, 14 Mar 2024 14:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710427885; bh=a6BsX952dU3UtrN1MaRvQHUha3lFnaN4sTX2EnQLhFM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JO0LR9GfMEhkMHh6KNx4/Gghs4Li8lTMLYVO9kFRcPKMaVNGCfiy6t0ZQkWOLqP9V 6ufO89sfq0Rhtx0Abj/Io1pVISiFjozQ3PaZEhBEG9bgmRReBW1fTm9EqQc45wA3Fd D6zSrfS998HjW/TdM6hZld7kjkhAS+ghRmtBVUNpSqyKyNWEzcJkTYBqBocnoUcWvU MoHlBiSCKWFPQL9ELCjFJIbbRlbMLSDFv7mXFtUKJvvwcomrpYlcBjpdAQwXPwMh5l 1Ov0+yLbMlkVuUcW2tQTi2BoTL6QyYo4erOSutxeFcJvOQDc5bmoWFcLE+mD9jpW13 DJbkbsIiTyZ/w== Date: Thu, 14 Mar 2024 14:51:09 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: Vasileios Amoiridis , lars@metafoo.de, ang.iglesiasg@gmail.com, mazziesaccount@gmail.com, ak@it-klinger.de, petre.rodan@subdimension.ro, linus.walleij@linaro.org, phil@raspberrypi.com, 579lpy@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/6] iio: pressure: Simplify and make more clear temperature readings Message-ID: <20240314145109.232f6d05@jic23-huawei> In-Reply-To: References: <20240313174007.1934983-1-vassilisamir@gmail.com> <20240313174007.1934983-5-vassilisamir@gmail.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=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 13 Mar 2024 21:04:46 +0200 Andy Shevchenko wrote: > On Wed, Mar 13, 2024 at 06:40:05PM +0100, Vasileios Amoiridis wrote: > > The read_press/read_humid functions need the updated t_fine value > > read_press()/read_humid() > > > > in order to calculate the current pressure/humidity. Temperature > > reads should be removed from the read_press/read_humid functions > > read_press()/read_humid() > > > and should be placed in the oneshot captures before the pressure > > and humidity reads. This makes the code more intuitive. > > ... > > > + if (strcmp(indio_dev->name, "bmp580")) > > + data->chip_info->read_temp(data); > > + > > > + if (strcmp(indio_dev->name, "bmp580")) > > + data->chip_info->read_temp(data); > > Yeah, not a fan of the strcmp(). > Yes - that's a non starter. Add a flag to say it is necessary to chip_info that doesn't rely on name matching. If you do it the way you have here, you have to add another strcmp for each new device supported that needs this code to run. Add a flag and you just set that in the chip_info structure. Much more flexible and extensible. Usual description of this is "when you can do things with data rather than code, do it with data". Jonathan