Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp440833lqj; Sun, 2 Jun 2024 05:50:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+hVxVrhbNV8BbpaeuYYV2DBMSYK1DADFDOTN1LR9Uhek7j3wOGepRjQjlUHlFfAwV27YuhKUFIknAcgXDObD8sUw0zE5R0kXxxPJKzQ== X-Google-Smtp-Source: AGHT+IF7Fgxp4Q68GdBG2oTT7xC+bmtp5KEPPNh6j+uv9C09mhQXTfz222AaGgiLk/OSAUtOWoGR X-Received: by 2002:a05:6358:3120:b0:199:42c8:389a with SMTP id e5c5f4694b2df-19b48c2894amr771047455d.10.1717332655310; Sun, 02 Jun 2024 05:50:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717332655; cv=pass; d=google.com; s=arc-20160816; b=kIpj6agJ6iDlpaPzoF7rtp7KMl0UfREXki3jsOps+5RqL2yz3EfZ+Bqsw5+woNacsP f4AHzG8IDwCHO3adMQllEXW/DG9OfHcMzgujETNaPtzAdRC9ux5ucqTYO873FF6lTRNP uRsfWW6uAUOGu3/7Hc0gW/fRZmRDiasff95BHW9R8vN0SkX5HcpeIblRpJxQdkaN/dve 1wqQq07QCp2rp+NOsxiqjwcVrp8HSXXiXMXNcDQmsSTCfaKMWXYFqqrXNc5kEtsj+C+X iEGcscedLZvyqSxwn6LBrqxpSwJgm1D6C7C4+1ikRGVSDcCc5pVnwGE3rkenhgPJqsBU DGkQ== 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=HabdHfvHz9sQPjRvaoGPqpyWCl3bIXXP7SGb2J29Zhc=; fh=xjsdCYuomEJyS1EkfNUc5fKtF34cXQ1mOBn36d3R9dU=; b=L69rve43ewVOlRrI6T/IPX4XLx3etErC6hB27u36broZJFmlmWvx5U/46yzqNczXUH tBknMNTmGXtZqf3a2tR/ChqgAf4dyph2kr/xT1gr55KZ0Sgo1LM8HOGvyWiYJ+pfsZSq /rqU5MsIDPFmvSI1eiq1rjapg6DxacSRZMeDPb68PNDhGYGQJV60ntLGZk8ifvY+zvG7 kwz92KOtsQdrH51YSmE4EoN3otYkCoQMrg4QQIeUz/TjgnwIq7gz5k2wId3LaCbezdku arsPyjd6NQ0EKlghapGUUhc9xj9QEUSDVA8mzAbXiKSIjNtOSTglNidmVUvFvSl/8AyI Zbgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HspO+oaX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198239-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3540fae9dsi4759369a12.35.2024.06.02.05.50.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 05:50:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HspO+oaX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198239-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 9C20B282408 for ; Sun, 2 Jun 2024 12:50:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 284183B781; Sun, 2 Jun 2024 12:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HspO+oaX" 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 4B60617C7C; Sun, 2 Jun 2024 12:50:46 +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=1717332647; cv=none; b=nSlS+8EpmsR9bbOOcZ0PXP6cVX55bfvbVzma4J7zyjAsYmXU4hvhqMycd4HwQbSM66DVdDCHz/dsgg9c3g+KtYypy/TfBPsFmpM6ImsbAMBYwn09R8JM23tsfHP2CsubtSXwkYdSl1IiAPcS8LY3Ldqsg6Hq6pz0bc8AjkeBMcA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717332647; c=relaxed/simple; bh=ZzrJSXC2KX0xVuIkGuX0b53uOU8xn9fAxt0LCjbRsfU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kinKn7rNZ1Lz2pOri8kMYBg91WDbJh0qDOx3U/5zrow0E8hlO9uGgDZBnqEAq/EqtEUUvNFcxEcAWvVftuSZpDfQxuwSF7tZ34IOO7cFHtYjbxbFsharLO7fEBkSS6GG7g5qofzcMZwSLaRvtKYFeOL3rgzs4rxXX1O3hODV3As= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HspO+oaX; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB4AEC2BBFC; Sun, 2 Jun 2024 12:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717332646; bh=ZzrJSXC2KX0xVuIkGuX0b53uOU8xn9fAxt0LCjbRsfU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HspO+oaXCW/ii0XPseip0y6mCEOtkis+KCYTrlP98nKCYyybpxnfHLGHYVFIQo3Gk Q+O6ojoFDTu9iMIs0CXyjwBhwhhcKP2zbUzj1xqZgIWqV4eoP/7uFTzbRtySJ/1RWS rFJSgYVKsG88mCZw1Wi7CcgzsxvNBeSj5RES246EfdjyNZmzdHxos3Zym2fvTEpNIW TOoa2+//hsAlqoTIunJ8UpneHg3OY05MU39UODY+T1GpVpdK4OzjmqN1dnyDoGv6JG UYfzwO+Ky5QbaPV4q3lLhSJMUVfTNFKxQ2t2VwXKcO90Rydj1pWctc4tVgs++MrKCY cNy2fONTM5hFA== Date: Sun, 2 Jun 2024 13:50:36 +0100 From: Jonathan Cameron To: Vasileios Amoiridis Cc: lars@metafoo.de, himanshujha199640@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 10/17] iio: chemical: bme680: Remove duplicate register read Message-ID: <20240602135036.27b0ee9a@jic23-huawei> In-Reply-To: <20240527183805.311501-11-vassilisamir@gmail.com> References: <20240527183805.311501-1-vassilisamir@gmail.com> <20240527183805.311501-11-vassilisamir@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; 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 Mon, 27 May 2024 20:37:58 +0200 Vasileios Amoiridis wrote: > The LSB of the gas register was read first to check if the following > check was correct and then the MSB+LSB were read together. Simplify > this by reading together the MSB+LSB immediately. > > Signed-off-by: Vasileios Amoiridis A few trivial things. I wrote a nice comment on dma safe buffers then noticed this does a custom regmap using spi_write_then_read() so despite not looking like it from this code, DMA safe buffers are used. Just thought I'd mention it for any other reviewers! > --- > drivers/iio/chemical/bme680_core.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c > index 96423861c79a..681f271f9b06 100644 > --- a/drivers/iio/chemical/bme680_core.c > +++ b/drivers/iio/chemical/bme680_core.c > @@ -748,7 +748,7 @@ static int bme680_read_gas(struct bme680_data *data, > int ret; > __be16 tmp = 0; > unsigned int check; > - u16 adc_gas_res; > + u16 adc_gas_res, gas_regs_val; > u8 gas_range; > > /* Set heater settings */ > @@ -771,11 +771,14 @@ static int bme680_read_gas(struct bme680_data *data, > return -EBUSY; > } > > - ret = regmap_read(data->regmap, BME680_REG_GAS_R_LSB, &check); > + ret = regmap_bulk_read(data->regmap, BME680_REG_GAS_MSB, > + &tmp, sizeof(tmp)); > if (ret < 0) { > - dev_err(dev, "failed to read gas_r_lsb register\n"); > + dev_err(dev, "failed to read gas resistance\n"); > return ret; > } > + gas_regs_val = be16_to_cpu(tmp); > + adc_gas_res = gas_regs_val >> BME680_ADC_GAS_RES_SHIFT; I'd rather see this as a FIELD_GET() but given this was what was originally here I guess I can cope with keeping it a little longer! > > /* > * occurs if either the gas heating duration was insuffient > @@ -783,20 +786,12 @@ static int bme680_read_gas(struct bme680_data *data, > * heater temperature was too high for the heater sink to > * reach. > */ > - if ((check & BME680_GAS_STAB_BIT) == 0) { > + if ((gas_regs_val & BME680_GAS_STAB_BIT) == 0) { > dev_err(dev, "heater failed to reach the target temperature\n"); > return -EINVAL; > } > > - ret = regmap_bulk_read(data->regmap, BME680_REG_GAS_MSB, > - &tmp, sizeof(tmp)); > - if (ret < 0) { > - dev_err(dev, "failed to read gas resistance\n"); > - return ret; > - } > - > - gas_range = check & BME680_GAS_RANGE_MASK; > - adc_gas_res = be16_to_cpu(tmp) >> BME680_ADC_GAS_RES_SHIFT; > + gas_range = gas_regs_val & BME680_GAS_RANGE_MASK; Whilst you are here, may this a FIELD_GET() so we don't have to go check that it includes the LSB. > > *val = bme680_compensate_gas(data, adc_gas_res, gas_range); > return IIO_VAL_INT;