Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp136897lqb; Thu, 14 Mar 2024 07:27:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrwGLuM+ZU1NcvNrVErZKDNn9KjC5MjZMgu94Ohgmub29tMxm715uJGElJarLSRyiDTwmi6MqBdx5q/dd/uAyeTgl7Cvj6SMttxRb+zA== X-Google-Smtp-Source: AGHT+IFNU/QYv0GV6aXgh35SOIT6FO/yRmVy5aaf9/2nE7WLMyGX9tKLaphss6emDca09UyWkWfm X-Received: by 2002:a05:6e02:3709:b0:366:4e5c:149a with SMTP id ck9-20020a056e02370900b003664e5c149amr2469320ilb.32.1710426443387; Thu, 14 Mar 2024 07:27:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710426443; cv=pass; d=google.com; s=arc-20160816; b=KsLyw53sS5153XGe18wVmKx5kb7RlyrjvPv7PZ7GVKpi4/YEENBZYGI41D7E5IzcHk 0jDRrSSlY6MwLrOnDa31Pf3y1SZNP19yZ4xKoP0x67GIHrp7mRGUAbO/lLB5R4vEhheV aJ0Mv62bK8BMYdzgN1v4S/2sZSAEqA9fAuHvWEy5Kb6zeX/yR3VZd8kwl2PfmfIc8P5P buWG1vTzHoULarFO+N+oHC4zOoBiSf4yGOfa+w086ivXckvP1fjLL1bqzUlbB0158XbY A/IGNvArS3RH1oNb6scV3qZ6RLw8B69PixsmDDwW2z+ieFh8gy4/7jfNJmWKHYAzXjqF Hf2w== 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=Gmyoz/fmI/Rdwrr2gHao/eF0FM0hSY/6Or+tDcH/JzE=; fh=7R5cUxhTEwaF7a7vsKPD13Aw2KeqNBBYMV8JHZAoxIA=; b=cvINL1ZFmmWX4Evvi1Jux1iVVV/MmS6WtIUAnPd7slNK5jmQlJXVTcOjohUV/EuFAM cgrt/a6W0MFk1hHcEjzX4cvx34dhrZHWRqMEZkwS0sJ6891APSum51BMS/uVFE/LmQpC EJEUUN4uz1kVEihidYYXCJ21ePlMwUXjkiykfvvQ/9LlgoHNJjwp3cwOMwJ0qOYUmj+j pzwrLTybE8wvnQ+yUo3UEFBO791HYk0uQHsKw/d6l7ZwT5hcvDkXhAC3O2/JpqYEoyU0 EHsNQ5AFwDuFgqTg/TMrz6/EnmEuVwNSuChVVwWYOIywCKSpv5ERFURhy40F2/PQsveQ gt4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fw43UPCC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103395-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103395-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 6-20020a630c46000000b005dcbba892cdsi665717pgm.327.2024.03.14.07.27.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:27:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103395-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=Fw43UPCC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103395-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103395-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 1089728B58A for ; Thu, 14 Mar 2024 14:27:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F02196FE25; Thu, 14 Mar 2024 14:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fw43UPCC" 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 2191F5D8F8; Thu, 14 Mar 2024 14:27:16 +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=1710426437; cv=none; b=BOaY5/ro0hQi7L6/Cad+oxQjf7KQWdBHlUtIAC/NWfcgRqChTLU8zqpAwv9nGAzoPl+xL6Ivc8d0UOzSngC5TPTNsSOv0go/nALkQinB3BVIEtis4d4aRvs6YuMWG3WOJCfVqU+zsiDPm9evUsqb13PDA/wNi3Nm3Fm3Gu31ChA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710426437; c=relaxed/simple; bh=x8duBZfq2CwdbVtYRgrRjeErlATVcK0LqzfKY/hrrRs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aAsqo8Y3S2w4JWcTgTIr6vigG6g/HrA3pTOG+crBBuowMtMDJG72zbNly6oWI9ciNhF2XEvkr9DMgbxyU9JiT55Nn1IsgHGHm2Uoq2alfFd5AHJGA0sKuQ2NdYst/6UQYUkr6EYybAdkwdl/EUx6626vXF9kHC58xJSoN9j4u2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fw43UPCC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D1FCC433C7; Thu, 14 Mar 2024 14:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710426436; bh=x8duBZfq2CwdbVtYRgrRjeErlATVcK0LqzfKY/hrrRs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Fw43UPCCPAUskpMLXmkzS+5p+FnIUsZEfgNHQhEu3mU8R17Ld+KbLbSm5JYWmbT0S X3qsH3lY/DxgvcEKoHl8ylTfb0eOVCVYAOnkRlLzIZAk4Me3S7XjsBlJhxRyCEfDrv tjYRK/K/uE1+jAe+BnZ5aeiTMBL8nURHuEqibAcXBjpMzR8Dfx9xtnmzFz6BHNVH8Q El/C5e6llmytVWSDRJe1+lpU28xS3q009KppF1tbsuk3C/Zp7ybfRxSXrTgXJN3+kB 2n9OqA1uYgHsCJSDYrrQzG26QAsc87taVyIPd8zIHl1diCfcAvZh52SVjyWCfpVKJu EskIxOdPDwXUw== Date: Thu, 14 Mar 2024 14:27:00 +0000 From: Jonathan Cameron To: Vasileios Amoiridis Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com, ang.iglesiasg@gmail.com, phil@raspberrypi.com, 579lpy@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: pressure: Fixes SPI support for BMP3xx devices Message-ID: <20240314142700.32df91a2@jic23-huawei> In-Reply-To: <20240311005432.1752853-1-vassilisamir@gmail.com> References: <20240311005432.1752853-1-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 Mon, 11 Mar 2024 01:54:32 +0100 Vasileios Amoiridis wrote: > Bosch does not use unique BMPxxx_CHIP_ID for the different versions of > the device which leads to misidentification of devices if their ID is > used. Use a new value in the chip_info structure instead of the > BMPxxx_CHIP_ID, in order to choose the regmap_bus to be used. > > Fixes: a9dd9ba32311 ("iio: pressure: Fixes BMP38x and BMP390 SPI support") > Signed-off-by: Vasileios Amoiridis Other than switching to a bool as Andy suggested, this looks fine to me. Jonathan > --- > drivers/iio/pressure/bmp280-core.c | 1 + > drivers/iio/pressure/bmp280-spi.c | 9 ++------- > drivers/iio/pressure/bmp280.h | 1 + > 3 files changed, 4 insertions(+), 7 deletions(-) > > diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c > index fe8734468ed3..5ea9039caf75 100644 > --- a/drivers/iio/pressure/bmp280-core.c > +++ b/drivers/iio/pressure/bmp280-core.c > @@ -1233,6 +1233,7 @@ const struct bmp280_chip_info bmp380_chip_info = { > .chip_id = bmp380_chip_ids, > .num_chip_id = ARRAY_SIZE(bmp380_chip_ids), > .regmap_config = &bmp380_regmap_config, > + .spi_read_extra_byte = 1, > .start_up_time = 2000, > .channels = bmp380_channels, > .num_channels = 2, > diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c > index a444d4b2978b..3a5fec5d47fd 100644 > --- a/drivers/iio/pressure/bmp280-spi.c > +++ b/drivers/iio/pressure/bmp280-spi.c > @@ -96,15 +96,10 @@ static int bmp280_spi_probe(struct spi_device *spi) > > chip_info = spi_get_device_match_data(spi); > > - switch (chip_info->chip_id[0]) { > - case BMP380_CHIP_ID: > - case BMP390_CHIP_ID: > + if (chip_info->spi_read_extra_byte) > bmp_regmap_bus = &bmp380_regmap_bus; > - break; > - default: > + else > bmp_regmap_bus = &bmp280_regmap_bus; > - break; > - } > > regmap = devm_regmap_init(&spi->dev, > bmp_regmap_bus, > diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h > index 4012387d7956..70bceaccf447 100644 > --- a/drivers/iio/pressure/bmp280.h > +++ b/drivers/iio/pressure/bmp280.h > @@ -423,6 +423,7 @@ struct bmp280_chip_info { > int num_chip_id; > > const struct regmap_config *regmap_config; > + int spi_read_extra_byte; > > const struct iio_chan_spec *channels; > int num_channels;