From patchwork Sun Oct 15 15:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 153027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2979249vqb; Sun, 15 Oct 2023 08:18:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYpRnvQH2bQwdn6l442eREIWSLZnHD0OWYoQN2WOCMQAIP3JcuTZYFBeXuIWW/h7coNlde X-Received: by 2002:a6b:3b83:0:b0:7a5:cd6b:7581 with SMTP id i125-20020a6b3b83000000b007a5cd6b7581mr12117466ioa.2.1697383081344; Sun, 15 Oct 2023 08:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697383081; cv=none; d=google.com; s=arc-20160816; b=qS3O9lG8ZkWwNgx0oqR9sHIWv80VfQ/zT6rtl+Puygpv5JXKDMj6SODSkDHnT/yuNW rd6EtVjAwBV3CMJI4oWiwKEiA3cs3GOXFnuMYeaAf5/HXzJBc7wrLae1B8equvo7Kg5V SbowDUs1kFG2dDNS0SJGSsGVHp1ma0QfoVeihStXbh9h8fDitnybG7+5tMWYLyKPewPb 530/lXX8zHEcuezZQoh3ijgw0CskI1Gy1pZ65Zvjvxn82ndMAoFn9v2U5RTT2M2giRHU 54PmPP4iUtSOBlt5aA6cws3cgo3Z+db7rSJHfD2I/TkHvgXSJSkJRWbjAYqBZsv7cxyK DLDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bqQVd6iN7ettmPvcpD+SNx5dxlU6xrnXDXy31g/k6O4=; fh=X1oGH+1slwO329sC+ndy1H9PT8W8iA0+rFlmW1O+Rhw=; b=dta6wzN1IRaVWYO6gVL86Ck1zeXWKyv5nNYUGKk0n7CuP5jYSC5AKCcniYsY5XgKes LDgTInJfGD3RjKvl8UEWQYFmRDKwYDNGF0ZO2xJJDH17onugSzKQ3FZME4GJd33Lind+ XD+yQcJMPX7yCeK/sFJM36CbsoiHYzBUS+8XK/OjQUDe7g2qYASr+5Ilof/ZTrOuOkXw 6TrU5ljm7oq9o/0Bv5BgYKrt1v7o9U8o9SsAL7P+X6b0+ZSZxAFKBj0zKmCZ4ripDERJ fgqmub5z7YjEKdJRPNlKKqXfszkAWxYPTWLSBz41FF7vsK9J4GEyt9ojNXd0ZCT810qf Q0OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mFESidvu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y15-20020a056a00180f00b0068e285eaa31si5734631pfa.259.2023.10.15.08.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mFESidvu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5E4C6805DC02; Sun, 15 Oct 2023 08:18:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbjJOPRz (ORCPT + 19 others); Sun, 15 Oct 2023 11:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbjJOPRy (ORCPT ); Sun, 15 Oct 2023 11:17:54 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63D6DAB; Sun, 15 Oct 2023 08:17:52 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4075c58ac39so37847475e9.3; Sun, 15 Oct 2023 08:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697383070; x=1697987870; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bqQVd6iN7ettmPvcpD+SNx5dxlU6xrnXDXy31g/k6O4=; b=mFESidvugez4PIQf+EWQ1UdutKqMqZdMhAJaYnfxRjmwODBuzJb/Tvp9S08mlUVmPm OdqEa/XwhbhkmOqs4w5O61njeMVGeVYRSTxNL9We6BvdSF/WFsU5IOiPglqw9EBQfMDh 5GnVi1y9RQvvIk9zNYLmIqUQTT7ME8Iwmf1l+xFOwe0XcnIUuTcRSyUJEgv8gQsyyEn1 wwcKHfSoOXk0rpBrOsniX3b47FE+CB7moDslsiZZx4UjpDY49WKnf/t7CGc0a0pvhQvp c16b2vM52UCqYV3s4Bk4GUEAnkD+TVklFFRz9XGOt5Wzi6M4U90+Haifs7g7CTHd4WzF ycEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697383070; x=1697987870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bqQVd6iN7ettmPvcpD+SNx5dxlU6xrnXDXy31g/k6O4=; b=sIQS/ep9jFxsgD3HbQSRhYs0uCZZThLUy39qdgDBaXzycPEqscV3Uc17KTpY93QzIi zRb/b1Qe4sAfkp7mH3RMtpmDK8TkL1DoZgepEDB7lBf/mE4+yDsjcUZurwmswhpi3iJr ZlenD4RrxzhSSUyEnqSJ/R6dH0KxKn+af5TGc8W9CtrKaz4N3zo38sO5kNGmYqk+FgP3 J/t5zs1kMLOcmr38BUhVcN/8U+R73Qs3Vak2CW3MtXddKaLHJrAzCS89xUfsD4gNzjfj KrjbyClqcIYWG/9Rh37SvQdLnt3ud/sPuJ0WomNq/xvz763zERkg8MID0OaLMb0iFZA6 aowQ== X-Gm-Message-State: AOJu0YxDOVOLqUyNNDg0fdkSSaJaAEzH3CJrYN4KB3aL+YAeidfGUJb4 DVSNhwGZ81SiOt1gsv+w5qcRhhnT1M8= X-Received: by 2002:a05:600c:2054:b0:402:906:1e87 with SMTP id p20-20020a05600c205400b0040209061e87mr26952161wmg.31.1697383070442; Sun, 15 Oct 2023 08:17:50 -0700 (PDT) Received: from localhost.localdomain (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id n35-20020a05600c3ba300b003fc16ee2864sm4712455wms.48.2023.10.15.08.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:17:50 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen , Angel Iglesias , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= Subject: [PATCH 1/5] iio: pressure: bmp280: Use i2c_get_match_data() Date: Sun, 15 Oct 2023 17:16:23 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 15 Oct 2023 08:18:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779835161735076422 X-GMAIL-MSGID: 1779835161735076422 From: Biju Das Replace device_get_match_data() and id lookup for retrieving match data by i2c_get_match_data(). Signed-off-by: Biju Das diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c index dbe630ad05b5..b3e069730f97 100644 --- a/drivers/iio/pressure/bmp280-i2c.c +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct i2c_client *client) const struct bmp280_chip_info *chip_info; const struct i2c_device_id *id = i2c_client_get_device_id(client); - chip_info = device_get_match_data(&client->dev); - if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info = i2c_get_match_data(client); regmap = devm_regmap_init_i2c(client, chip_info->regmap_config); if (IS_ERR(regmap)) { From patchwork Sun Oct 15 15:16:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 153028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2979349vqb; Sun, 15 Oct 2023 08:18:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpyaZfOSn2bHyJFCh4OMh8Uic4kOFKdLlLDRR3XLr1ZjrObsYVKLl4dhIlAbRXcsshcRRh X-Received: by 2002:a05:6a20:8f01:b0:163:d382:ba99 with SMTP id b1-20020a056a208f0100b00163d382ba99mr39044677pzk.5.1697383098497; Sun, 15 Oct 2023 08:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697383098; cv=none; d=google.com; s=arc-20160816; b=kHokDP6OsyPaMZ/dSlvUy9QVPOipNuFcQxNH3tdaW1/NhoxyHCDgmbSYBXvxKO4UM4 LF1xqQ8M0EJRCU8ShqfjNPdSlEjVkHGUiAgAB2Bg0sVewRMFFHF388oSDa2b5t4yYQ62 CYhR8GO4F05bN3kjWP560aGTw4BeiLDJzk4TNZ7ZY4Rq1m/4R0O/fwoRXm1+RGoFuI8T MKUigsCBnEWSkvLFTFR3GuR+a/SAsi5vdxTyUbdCaEh9AJaGgL3rp+aX56xHzMgiuZYp Yyly6/jVqYJMwAK91ere0I0UOxIMk704TRzPmoW1k4TOSP1nq1pzXtFQGk66Cz881HTv GRcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VeqxvK0uzWzz37Q8uuFTlmCXM4qg5qnRs/tMuLh55uE=; fh=7iFVCHvh+AM/6broDGlcTK1nrHuSVLQyXB5ocMqSQw4=; b=wysaZQbf4o9493jwsTfyOkwkbkfhn0tI9Kb0LlO2dQhHT3Nv8AnX/BkY5bd+abZlld UmJBfr9HgVLLt8KRDHEqZlSmFpjA8yiXDegPQeRrFcVMVzWjiIg9vttrU/E/InMrOwHp nfZbelM1+kbdNkEjclElHU+tZIQPkAeXKICFOYH9hitS/Risj/iZNB1GfuioObvtPShg HkFFi5/OYzwHFDuvGqPYhmw6L0OBitz0B9FqCfeWjKJziJYZgZ+mQ8gljTqOD7NvMFh3 mbqRmY34vdmFLRFphZOyVDaUqj4CGSWe/lNzlXsDSg7JeUWEWI52OtoJIvYxH/6Ms2ya zRxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CNxaX3FU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w9-20020a170902904900b001c754f13381si8569931plz.455.2023.10.15.08.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CNxaX3FU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4DABE80A0DDD; Sun, 15 Oct 2023 08:18:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230089AbjJOPSB (ORCPT + 19 others); Sun, 15 Oct 2023 11:18:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbjJOPR7 (ORCPT ); Sun, 15 Oct 2023 11:17:59 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49CD2AB; Sun, 15 Oct 2023 08:17:58 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40572aeb73cso37434485e9.3; Sun, 15 Oct 2023 08:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697383076; x=1697987876; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VeqxvK0uzWzz37Q8uuFTlmCXM4qg5qnRs/tMuLh55uE=; b=CNxaX3FUbbNckzulXhmeasF4Q7mw2Bu4c7cHTauiPAaG9T6NiLuoRwdTk1HTM6IHh3 mdVuAUQfx7KtzoVShokBEqOqWLZz1rwMHKcW64w/FlzZ+dwaQb5E0qJX/YL5SJsNsadS CEQ4Zulg8WCieAU8W7kjHRvHV02BdEpXmmDroTSYhDSc+j3MSyoTRNcQCN+EHrAiqGNH 8NRL7nrU4yfSDHkMHtjZwA2EyaAlHGd30cbfGdpbwFRlYaLsxKg6AfThsmLOpC6znzEG tlQ3h5RJDkkyk7z9Ko5qs+TAZ0kcTu58sjxzjMGuIK8pQ1Ggv11OhZGl67shjwfRB69O jzDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697383076; x=1697987876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VeqxvK0uzWzz37Q8uuFTlmCXM4qg5qnRs/tMuLh55uE=; b=M29AJosP7ERYPJuSi1r+/jVsRAa6P612pkKxg3+OFEtNsT6ajlacEdgGXtb3cpTqM6 njMH+mBji4IVpIXYlCe/Th6a9Y8hsvSAsvQGc93JJ64KmWpW3mUBQy8chaqXEJzbdL9A nVC7lbPWXjCj7/CD6Q33lBTXJLtwSzez/nk3bl5iLbI/7wHxPl1F5RkwafT5mNPwNa2G NyofRB7Ih5p60yjtofD7ZBN9Xl6ra4mURTfIwnfJoOcWYoqxzU1EaGWVD+oW8g3J2biN X3JNpIEVCDmTVbBl3ux3HmkCcts6QtaavFfbOTA9WcqpRHxgQP1VZsUTf/e89ynol2pW 1FMA== X-Gm-Message-State: AOJu0Yw4mo846f/kvApbjCAk+lqFYCsjeptCUei2aZSAk7eFsk5qf+aS FwSy/+HS52178wDKoGMP1niRNepMqIs= X-Received: by 2002:a1c:6a0d:0:b0:3fc:1a6:7764 with SMTP id f13-20020a1c6a0d000000b003fc01a67764mr27721664wmc.16.1697383076236; Sun, 15 Oct 2023 08:17:56 -0700 (PDT) Received: from localhost.localdomain (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id n35-20020a05600c3ba300b003fc16ee2864sm4712455wms.48.2023.10.15.08.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:17:56 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Angel Iglesias , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= Subject: [PATCH 2/5] iio: pressure: bmp280: Use spi_get_device_match_data() Date: Sun, 15 Oct 2023 17:16:24 +0200 Message-ID: <553d1e9187fac10094116d3a1688b66bebd60cd2.1697381932.git.ang.iglesiasg@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 15 Oct 2023 08:18:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779835179935066662 X-GMAIL-MSGID: 1779835179935066662 Use the spi_get_device_match_data() helper instead of device_get_match_data() and the fallback match_id logic. Signed-off-by: Angel Iglesias diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c index 1dff9bb7c4e9..2eed483a8cc4 100644 --- a/drivers/iio/pressure/bmp280-spi.c +++ b/drivers/iio/pressure/bmp280-spi.c @@ -58,9 +58,7 @@ static int bmp280_spi_probe(struct spi_device *spi) return ret; } - chip_info = device_get_match_data(&spi->dev); - if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info = spi_get_device_match_data(spi); regmap = devm_regmap_init(&spi->dev, &bmp280_regmap_bus, From patchwork Sun Oct 15 15:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 153030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2979498vqb; Sun, 15 Oct 2023 08:18:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF31qS4c0lVfi42RR0A/PyqG6DVcMMf5CptT8RZkPuYhHCMkg+RdDRoUMHw5s6USeT8g/uP X-Received: by 2002:a05:6358:c627:b0:164:8d69:25b8 with SMTP id fd39-20020a056358c62700b001648d6925b8mr14499019rwb.1.1697383125676; Sun, 15 Oct 2023 08:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697383125; cv=none; d=google.com; s=arc-20160816; b=IFEWhigk2QQuBMs6XbR3HBsVt6vI5i7ivPWyNrkQZty2FlbTf8YS3qLn+gMOGxaSTM KDDrtOHdVHnJzNI51JCZzGG8vajKyAJRb/KLYdb09ss/gsJQnA6upfsjt+dmYm9JpZ1M JUyZkrdC8EctOq6pMXbB68QXI//dtIzgzNRIygyoji2KlZlqmwwn9/FpiWR18uXwEE6g I+tyPawTbZTLiXZGYvb5/NtTc6HT1w0/vgoshQxF66qRlPnF0mRUeTNdySbIL6HtayAV VrzLm/YIjCSV5q5Ajk0RJgR5MHH+a3n14UL+QsZuek3U2E7XLwrMxW1Qf2GsJBXZoUh0 lZvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bGL0YH1al5bgYEOMpJxA3ocj/opSXqoY++n/reNrEe0=; fh=7iFVCHvh+AM/6broDGlcTK1nrHuSVLQyXB5ocMqSQw4=; b=LSt+FAqG1BMeMOYLCVrWRToiZ9DPxiBEuGJjT8o2irOUqALGjOL/iK75dyz8BXTtNR bzJujCfbUeFKzVS3994yVplDkGhAMRsFHZHYyKvHYpyA38Z8hMuND0Gm2laPPIaJReLr ePKG7byd3qfAnZYMcu2yu1wOIls5NTiaYHrOz36yO+g1Hc5zTYNlZm6voxZamnNDkJkn 4sHQVjWxSpNf01APAvfGoyu3JXFW+qZitsNdlcYPFt18SUVOVIZiIp2oP73UJCPBgjBz SD49eWlLRbrV6ZvUv1+u0oUeXZQnifR5Lj1s0I+YgUWZH17qUIDmGxbWpXMnkQC6bYp+ MqZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m1w304aM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k184-20020a6384c1000000b005ab45ee3e7esi5609199pgd.299.2023.10.15.08.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m1w304aM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6DBAE807070D; Sun, 15 Oct 2023 08:18:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbjJOPSM (ORCPT + 19 others); Sun, 15 Oct 2023 11:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbjJOPSK (ORCPT ); Sun, 15 Oct 2023 11:18:10 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B529106; Sun, 15 Oct 2023 08:18:04 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40684f53bfcso34445945e9.0; Sun, 15 Oct 2023 08:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697383082; x=1697987882; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bGL0YH1al5bgYEOMpJxA3ocj/opSXqoY++n/reNrEe0=; b=m1w304aMx90BQVokAicwtTBiENyzY7q8VNXoCLJEqAF/+Z2keC6vZ7GB6TFcsoN/T5 e+hx5Lznnzq7rB9pxFi0ImdP2rxZXdc9Zu4iOMcrROAJj1zyJSZIn1v9WJnZMqepMZvZ 0fh7n+CriQ3d7VovZ48K8V1/mKeHXVOZsYq3YJig+0KhBysdRT1UGLZExecM6ChXuhC8 WL3TMEOlvkjMRVxDzLTuIfeMOOGzwNKptik1Xl4N5UGzw4h39oqMVNS5SQy5Ba4GxwoH 6aZB+K1DGQDoq2mBG04jHaor9td4iQb1mrYeLpgSzkByXEczzf03qTcq489jFE1u62rJ KCdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697383082; x=1697987882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bGL0YH1al5bgYEOMpJxA3ocj/opSXqoY++n/reNrEe0=; b=rT1kigJS3Tng7haArCBTNjmoz2QNkradwaFdTtlhFHnpc8x0E4eUp3r5APa+vPtcNa wZ3x3jd6cOHAjnbFrlA8RRUMl6/UAd6hqJq9cept9iggumcglIVl4yAHjuljE5h5LQUJ zS130VujncmrRu/X46/gHnjs5qza/Hx2wIwVzTgxqFsqyP9mpSU0qHrXRIXjRXPCnH4F o7ePRLB6FT4JfNA8xvFoKyUOeeK8/l8UaZZyIQXNxpELuzXQOYTys+8gB0r4pvXtQQgy A/au58C1Hlfcc/wjQSNiGTsuMs1VDFbrTBf87MySjj08yz9tk8RVzYjRS719Ve9OrGdS FbzA== X-Gm-Message-State: AOJu0YxqllE4wzyo+iYtBxEhaBM8lK6PHFc9JXIOyfhO7qtb8qv2I5FB wJlH4Z47maSyU1Pc3r9t6uQrlKZNGB0= X-Received: by 2002:a05:600c:214f:b0:405:3251:47a1 with SMTP id v15-20020a05600c214f00b00405325147a1mr27399649wml.40.1697383082133; Sun, 15 Oct 2023 08:18:02 -0700 (PDT) Received: from localhost.localdomain (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id n35-20020a05600c3ba300b003fc16ee2864sm4712455wms.48.2023.10.15.08.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:01 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Angel Iglesias , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= Subject: [PATCH 3/5] iio: pressure: bmp280: Rearrange vars in reverse xmas tree order Date: Sun, 15 Oct 2023 17:16:25 +0200 Message-ID: <7db5fe65a78513137206ae6b33abb1e48d356fbf.1697381932.git.ang.iglesiasg@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 15 Oct 2023 08:18:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779835208274856277 X-GMAIL-MSGID: 1779835208274856277 Small cleanup reordering local variable declarations following reverse christmas tree convention. Signed-off-by: Angel Iglesias diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 6089f3f9d8f4..ea02a623bb58 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -766,8 +766,8 @@ static const struct iio_info bmp280_info = { static int bmp280_chip_config(struct bmp280_data *data) { - u8 osrs = FIELD_PREP(BMP280_OSRS_TEMP_MASK, data->oversampling_temp + 1) | - FIELD_PREP(BMP280_OSRS_PRESS_MASK, data->oversampling_press + 1); + u8 osrs = FIELD_PREP(BMP280_OSRS_PRESS_MASK, data->oversampling_press + 1) | + FIELD_PREP(BMP280_OSRS_TEMP_MASK, data->oversampling_temp + 1); int ret; ret = regmap_write_bits(data->regmap, BMP280_REG_CTRL_MEAS, diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c index b3e069730f97..34e3bc758493 100644 --- a/drivers/iio/pressure/bmp280-i2c.c +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -7,9 +7,9 @@ static int bmp280_i2c_probe(struct i2c_client *client) { - struct regmap *regmap; - const struct bmp280_chip_info *chip_info; const struct i2c_device_id *id = i2c_client_get_device_id(client); + const struct bmp280_chip_info *chip_info; + struct regmap *regmap; chip_info = i2c_get_match_data(client); diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c index 2eed483a8cc4..433d6fac83c4 100644 --- a/drivers/iio/pressure/bmp280-spi.c +++ b/drivers/iio/pressure/bmp280-spi.c @@ -14,8 +14,7 @@ static int bmp280_regmap_spi_write(void *context, const void *data, size_t count) { - struct device *dev = context; - struct spi_device *spi = to_spi_device(dev); + struct spi_device *spi = to_spi_device(context); u8 buf[2]; memcpy(buf, data, 2); @@ -31,8 +30,7 @@ static int bmp280_regmap_spi_write(void *context, const void *data, static int bmp280_regmap_spi_read(void *context, const void *reg, size_t reg_size, void *val, size_t val_size) { - struct device *dev = context; - struct spi_device *spi = to_spi_device(dev); + struct spi_device *spi = to_spi_device(context); return spi_write_then_read(spi, reg, reg_size, val, val_size); } From patchwork Sun Oct 15 15:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 153029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2979490vqb; Sun, 15 Oct 2023 08:18:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGe+rfFZludgEu6rhvPveozVxCeBAnj4AyGYDkEbLuPPBlKCAk7agYUzbdsgrVeg1VSyMvA X-Received: by 2002:a05:6a00:3386:b0:6b2:51a0:e1c9 with SMTP id cm6-20020a056a00338600b006b251a0e1c9mr7695482pfb.1.1697383124010; Sun, 15 Oct 2023 08:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697383123; cv=none; d=google.com; s=arc-20160816; b=NbW782mKdXWbqlzbEW1v2Xq+ihrpbi+yag3plnyjo057DqevvNCD+XeQoaAGFdtfKt +wjqaltgB2TlruNRHQUAQSBPGva8aaJSPZ/EC/viIQD1leNpm2ev+nuf52tZX1Xg8zpo 0YdGlGeS31kv1zdWYyUTfcxCCS9CJKmEuJzLDK6XnjKCVdbqTe268YVh5qAqsX3bYS1a 9R/cVLwEpxJ1Aqs0OY95LcbRrGgNbLv1Eikai+69voQvxl1EtvjI2Es9pyVG0jERZKNn 5wTB0IL7tamRD1OmI8XzhUA9NPB/vGbG6IwoeuoYLLGr6MAPrAi4fyugDzrqBSK1xN00 fk5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NMdJnM8oHQ7eHl+UF9y/ARFxYpaLioFllg8ThKJYIfg=; fh=7iFVCHvh+AM/6broDGlcTK1nrHuSVLQyXB5ocMqSQw4=; b=Qv2Re6iZ4xNvwkhFu2G6nohHT25Fn5ygUj+bZ5Qaqo9xmolTuAe6qOR2HrOH1QGcI6 EQC8bh1wCWPmb8URjNOSVhDenkJGaN2qAOIymM9/AaiSS5zFNtEmwhlWQ7TdX0TR0k3/ 9msiwH2eeum6IjLcb4fpKaH0x0LF//Qr6oq9ZMNU+k7NXGoeghRHWqiSyu6u6MLjdB50 A5p6+HQgARkWkse204iALNQwBIgsTlYZNtTdi3NSHHl+Yo+6aG2eDPoiUbpCpJsVcBZg 5oKQiM/Adiz/1KANuVZZNZBNQscJrtbRMzd9OlHLok70JejdimGsvvjWMMHBhU5pmz11 UmKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M+UtqsvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id y6-20020a633206000000b0057745b2d018si8416508pgy.390.2023.10.15.08.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M+UtqsvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A123C809FA6B; Sun, 15 Oct 2023 08:18:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbjJOPSU (ORCPT + 19 others); Sun, 15 Oct 2023 11:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbjJOPSO (ORCPT ); Sun, 15 Oct 2023 11:18:14 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6AF1FB; Sun, 15 Oct 2023 08:18:10 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40776b200e5so16255555e9.2; Sun, 15 Oct 2023 08:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697383089; x=1697987889; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NMdJnM8oHQ7eHl+UF9y/ARFxYpaLioFllg8ThKJYIfg=; b=M+UtqsvAtnViL34/Rjoh/Riubp27o6OMLkaELkSqKabmDk9Hx6aytZdkFYZ3PsvhIg 07Rwaa7mu5YW5gDPLiqrPUZlG1ukUVz4JyldU8WprJWVNRknYHDxzn4+9v6LI5k7XaKK sU6wLuc9aK6sENiCTdIEd1P+4bmSCOUoQDThmS0PnVq0W0rkQoFXVOqUKLp8Bt22QCOW 3w4/dUJgizxT09s0HDUUOtN8VzUowkNDvzvbH0jmdEH+GFDO/9RJEl7X2T0W5tFN0Y3+ IY6C7z/9yClKXyoFezHjbPqDVcnfsMqiQ4rrknNnWqAHT2YTcokQ9bXPZi/e7828oq+F TcBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697383089; x=1697987889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NMdJnM8oHQ7eHl+UF9y/ARFxYpaLioFllg8ThKJYIfg=; b=CTuaJA3Lao6Dk6fmeeoR4mS3pp+0bvl7Aysn64zOgl82bigFiFFZySiZQeb/0p2T94 G4cueCf+T+jBm2l+tKRr0pdk3Oufl4d16mcuPQH2nwwDgueITvE34Xx7qh01ywLXJ0uz 6cTmxq4F0amYPJM/i7glGY6wzCtTbobruLCveNoDfGctOXEhSl3sWl+xliHDe9azIbop j96YeeJq3yJ5dEkZkr64yYbrTNR3eMwFeYP7h0lIjnMD09yNZtO9QkYnJAswAgP4p95T JoX8eiZEx8UftagCfIPifpjG027TB/yZvxrihV5jXdVcmvfeD3WavMkFq5Hbtf0pydKd 3SHA== X-Gm-Message-State: AOJu0Yx4gMlPsKsoS/2qRBcOFM1NgTByt7JXJJEbUjm3KOGatfZZO1eG TwLmyORjTEAocIu5ycG5hjxRWa1r2Zk= X-Received: by 2002:a05:600c:3586:b0:406:849c:52c3 with SMTP id p6-20020a05600c358600b00406849c52c3mr26286281wmq.22.1697383088044; Sun, 15 Oct 2023 08:18:08 -0700 (PDT) Received: from localhost.localdomain (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id n35-20020a05600c3ba300b003fc16ee2864sm4712455wms.48.2023.10.15.08.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:07 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Angel Iglesias , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= Subject: [PATCH 4/5] iio: pressure: bmp280: Allow multiple chips id per family of devices Date: Sun, 15 Oct 2023 17:16:26 +0200 Message-ID: <9f8489d82325b2dfb5c8c71c3d558d509b2b01bf.1697381932.git.ang.iglesiasg@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 15 Oct 2023 08:18:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779835206884680048 X-GMAIL-MSGID: 1779835206884680048 Improve device detection in certain chip families known to have various chip ids. Signed-off-by: Angel Iglesias diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index ea02a623bb58..e3bb4d7906a9 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -38,6 +38,7 @@ #include #include /* For irq_get_irq_data() */ #include +#include #include #include @@ -794,10 +795,12 @@ static int bmp280_chip_config(struct bmp280_data *data) } static const int bmp280_oversampling_avail[] = { 1, 2, 4, 8, 16 }; +static const u8 bmp280_chip_ids[] = { BMP280_CHIP_ID }; const struct bmp280_chip_info bmp280_chip_info = { .id_reg = BMP280_REG_ID, - .chip_id = BMP280_CHIP_ID, + .chip_id = bmp280_chip_ids, + .num_chip_id = ARRAY_SIZE(bmp280_chip_ids), .regmap_config = &bmp280_regmap_config, .start_up_time = 2000, .channels = bmp280_channels, @@ -846,9 +849,12 @@ static int bme280_chip_config(struct bmp280_data *data) return bmp280_chip_config(data); } +static const u8 bme280_chip_ids[] = { BME280_CHIP_ID }; + const struct bmp280_chip_info bme280_chip_info = { .id_reg = BMP280_REG_ID, - .chip_id = BME280_CHIP_ID, + .chip_id = bme280_chip_ids, + .num_chip_id = ARRAY_SIZE(bme280_chip_ids), .regmap_config = &bmp280_regmap_config, .start_up_time = 2000, .channels = bmp280_channels, @@ -1220,10 +1226,12 @@ static int bmp380_chip_config(struct bmp280_data *data) static const int bmp380_oversampling_avail[] = { 1, 2, 4, 8, 16, 32 }; static const int bmp380_iir_filter_coeffs_avail[] = { 1, 2, 4, 8, 16, 32, 64, 128}; +static const u8 bmp380_chip_ids[] = { BMP380_CHIP_ID }; const struct bmp280_chip_info bmp380_chip_info = { .id_reg = BMP380_REG_ID, - .chip_id = BMP380_CHIP_ID, + .chip_id = bmp380_chip_ids, + .num_chip_id = ARRAY_SIZE(bmp380_chip_ids), .regmap_config = &bmp380_regmap_config, .start_up_time = 2000, .channels = bmp380_channels, @@ -1720,10 +1728,12 @@ static int bmp580_chip_config(struct bmp280_data *data) } static const int bmp580_oversampling_avail[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; +static const u8 bmp580_chip_ids[] = { BMP580_CHIP_ID, BMP580_CHIP_ID_ALT }; const struct bmp280_chip_info bmp580_chip_info = { .id_reg = BMP580_REG_CHIP_ID, - .chip_id = BMP580_CHIP_ID, + .chip_id = bmp580_chip_ids, + .num_chip_id = ARRAY_SIZE(bmp580_chip_ids), .regmap_config = &bmp580_regmap_config, .start_up_time = 2000, .channels = bmp380_channels, @@ -1983,10 +1993,12 @@ static int bmp180_chip_config(struct bmp280_data *data) static const int bmp180_oversampling_temp_avail[] = { 1 }; static const int bmp180_oversampling_press_avail[] = { 1, 2, 4, 8 }; +static const u8 bmp180_chip_ids[] = { BMP180_CHIP_ID }; const struct bmp280_chip_info bmp180_chip_info = { .id_reg = BMP280_REG_ID, - .chip_id = BMP180_CHIP_ID, + .chip_id = bmp180_chip_ids, + .num_chip_id = ARRAY_SIZE(bmp180_chip_ids), .regmap_config = &bmp180_regmap_config, .start_up_time = 2000, .channels = bmp280_channels, @@ -2077,6 +2089,7 @@ int bmp280_common_probe(struct device *dev, struct bmp280_data *data; struct gpio_desc *gpiod; unsigned int chip_id; + unsigned int i; int ret; indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); @@ -2142,10 +2155,30 @@ int bmp280_common_probe(struct device *dev, ret = regmap_read(regmap, data->chip_info->id_reg, &chip_id); if (ret < 0) return ret; - if (chip_id != data->chip_info->chip_id) { - dev_err(dev, "bad chip id: expected %x got %x\n", - data->chip_info->chip_id, chip_id); - return -EINVAL; + + for (i = 0; i < data->chip_info->num_chip_id; i++) { + if (chip_id == data->chip_info->chip_id[i]) + break; + } + + if (i == data->chip_info->num_chip_id) { + size_t nbuf; + char *buf; + + // 0x, so four chars per number plus one space + ENDL + if (check_mul_overflow(data->chip_info->num_chip_id, 5, &nbuf)) + return ret; + + buf = kmalloc_array(data->chip_info->num_chip_id, 5, GFP_KERNEL); + if (!buf) + return ret; + + for (i = 0; i < data->chip_info->num_chip_id; i++) + snprintf(&buf[i*5], nbuf - i*5, "0x%x ", data->chip_info->chip_id[i]); + + dev_err(dev, "bad chip id: expected one of [ %s ] got 0x%x\n", buf, chip_id); + kfree(buf); + return ret; } if (data->chip_info->preinit) { diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index 5c0563ce7572..a230fcfc4a85 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -418,7 +418,8 @@ struct bmp280_data { struct bmp280_chip_info { unsigned int id_reg; - const unsigned int chip_id; + const u8 *chip_id; + int num_chip_id; const struct regmap_config *regmap_config; From patchwork Sun Oct 15 15:16:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 153031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2979518vqb; Sun, 15 Oct 2023 08:18:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHy4S63hWE8AV10yJExcVMYIfPoJjNUFeeKX8VLNw47QYjUzL37DKSJwExFXpUz0RzxoHOL X-Received: by 2002:a17:902:e28b:b0:1c9:e48c:7260 with SMTP id o11-20020a170902e28b00b001c9e48c7260mr9180322plc.6.1697383128557; Sun, 15 Oct 2023 08:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697383128; cv=none; d=google.com; s=arc-20160816; b=Q6lJRXlmTJMUExWy7+AnXPu7b/dI2CK9+9+JACEFQcVTt/nBUF3ir4YpqBwvGxXHn4 gfkdgyN0Z/cc7TkKRYYEDoDgliMP15n4DxqTLRX33i+aaBIgFY13KXG9pJgL2r8bxtm3 jEX5vJqyaTUoXePizEazYVr65ByF3FiNadz1xsICyvLRHM5WwTIWwsHvkL0UFbqbjhKL 7ZvT5SrRA/F8BeYCxJATL8l9ujgDWw3dU6t6TmFapLUZBXZdKAhaDh3y28ea4QJQY8AA iuT6aFjlENkQaU1TfcbKFT+wCwGpeP3H2Iz7mEjioYgSShEpAihNK18uDv5Vz8OwWl1u mF6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2no0yowA3lGSRYKd2XnR+vjmcZErrr5k9KrUOlR237s=; fh=7iFVCHvh+AM/6broDGlcTK1nrHuSVLQyXB5ocMqSQw4=; b=rH7iPI6BaCCeMz1wbnFDGkGdTnYemp8TwrrgVd4UkwsF/15y4wEGK0KCEVmzAlFIuU ctbAPV8Br7ObooFGIFlCs+LTFEFsu42k3HGlD9SRfR4VpQtw0LUZoajr31uInc1om29g 0DG5ipkXFZLFqK3yl37TfIV5ud39Db2SKZstA2XBmdoYLCmtcOgPN+Y+Q/rtraOYQfqj 4Y0kNDL9RHl1jeL1V+LxactkVwGcfjsUJ4dudOvELfV1bN7TJvORjMQjYr9OipWn+BeC X6AxhFzUU/hLLwYDvPI430Y7aOyDaWn7shMb6Nd0WbVPCZO1QmFx2wwuIEDYwVAsysOm aKYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YEz+0dVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d13-20020a170902cecd00b001c77e00809csi6563815plg.453.2023.10.15.08.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YEz+0dVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4D863805AA25; Sun, 15 Oct 2023 08:18:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbjJOPSY (ORCPT + 19 others); Sun, 15 Oct 2023 11:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjJOPSU (ORCPT ); Sun, 15 Oct 2023 11:18:20 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68F19F5; Sun, 15 Oct 2023 08:18:15 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40684f53ef3so40329875e9.3; Sun, 15 Oct 2023 08:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697383094; x=1697987894; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2no0yowA3lGSRYKd2XnR+vjmcZErrr5k9KrUOlR237s=; b=YEz+0dVCd98HgxT5Fm++IXCiCGydtCQjxYQR9jAi/OmjcXfEa/VNmnV7RQaEbLIYz5 VZzYddcLgDa98hNLHimYSOyBwrfVonWzxJoQXgMocJplkKzrUJuQcwnzQiREQr7rp/Xk ELBcDb0iKk7y7OPxtTL4lCg2HbncQetLeNGrFTlcIHinuo8RAdJN2oRdVE6WFVZv8Pfn kLtXz5/H0g4wqBTpjSoqoomW9zPYDcg9WLekYAluBmXhj2o9f8uPygNCigwZuuwAGPcq J4GFK7+Ys3I4bpjHtHgFqGLdojrlSAXnCpFsBGcwuBPfGimRRg09r+2kUf/Y/B8BM5f7 u6iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697383094; x=1697987894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2no0yowA3lGSRYKd2XnR+vjmcZErrr5k9KrUOlR237s=; b=UT8XptV5YltIAjPwo5VSwrRdD5/ag7EGSZz9d2Kn3fNUUKyCQiDDfgL3y/YFaCH6+e jzTZZ+XWvzJPzupc5fQVNL14fJ5IjezizMV1NzfOD304ngYVIR/c0mvpdvT9ZqT728LJ bWI6vNs+4yFvu+GSJFtE0DoQEFGRu5b31bvNn6f2aMJUDR56tGxCSw9Gsa2AZ8fARMw+ HzxaD/YtWuGP6gtj4rftr2VWMU5F/HwNDKTq3awIeuVcvdxOkbZki7RwmT1ZJfeNtAY/ QC9RHu3FtrrzFNUwWMySmSy2c50QJyRt8mwL9JaTFSrP02f+pvnxfzhK6Vc1wK/L/NOE d0eA== X-Gm-Message-State: AOJu0YynmWRLMWY+fiK+6DD8bwzxC7DWgWKWH6V6gHVn9XiYSnwCS9iG 6vI6PFZLkXmoX2BMrax9JSKoBGYw6OA= X-Received: by 2002:a05:600c:259:b0:403:b64:ad0a with SMTP id 25-20020a05600c025900b004030b64ad0amr25954953wmj.26.1697383093909; Sun, 15 Oct 2023 08:18:13 -0700 (PDT) Received: from localhost.localdomain (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id n35-20020a05600c3ba300b003fc16ee2864sm4712455wms.48.2023.10.15.08.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:18:13 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Angel Iglesias , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= Subject: [PATCH 5/5] iio: pressure: bmp280: Add support for BMP390 Date: Sun, 15 Oct 2023 17:16:27 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 15 Oct 2023 08:18:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779835211046803842 X-GMAIL-MSGID: 1779835211046803842 Add BMP390 device ID to the supported IDs on bmp380 sensor family Signed-off-by: Angel Iglesias diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index e3bb4d7906a9..d2345956ebc8 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -13,6 +13,7 @@ * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp388-ds001.pdf + * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp390-ds002.pdf * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp581-ds004.pdf * * Notice: @@ -1226,7 +1227,7 @@ static int bmp380_chip_config(struct bmp280_data *data) static const int bmp380_oversampling_avail[] = { 1, 2, 4, 8, 16, 32 }; static const int bmp380_iir_filter_coeffs_avail[] = { 1, 2, 4, 8, 16, 32, 64, 128}; -static const u8 bmp380_chip_ids[] = { BMP380_CHIP_ID }; +static const u8 bmp380_chip_ids[] = { BMP380_CHIP_ID, BMP390_CHIP_ID }; const struct bmp280_chip_info bmp380_chip_info = { .id_reg = BMP380_REG_ID, diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index a230fcfc4a85..2971bf58f802 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -292,6 +292,7 @@ #define BMP580_CHIP_ID_ALT 0x51 #define BMP180_CHIP_ID 0x55 #define BMP280_CHIP_ID 0x58 +#define BMP390_CHIP_ID 0x60 #define BME280_CHIP_ID 0x60 #define BMP280_SOFT_RESET_VAL 0xB6