From patchwork Sun Oct 22 17:22:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 13432017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF785CDB474 for ; Sun, 22 Oct 2023 17:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232635AbjJVRXQ (ORCPT ); Sun, 22 Oct 2023 13:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232541AbjJVRXL (ORCPT ); Sun, 22 Oct 2023 13:23:11 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8425C13E; Sun, 22 Oct 2023 10:23:09 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-32d9cb5e0fcso1818860f8f.0; Sun, 22 Oct 2023 10:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697995388; x=1698600188; 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=TR1rbIRAVPmg6FZUklnnnduo61uGU5Ugg06WBamDHUw=; b=RKs4pyD48fYg8PLKWvvb+7iky1q34Gg+JrikWsyCdEtuj2kuKq0R/RTJtenwFp7HI8 szI7nQ00OhnzjyYUPnTiGeHlq+aQHvoAzk1HqS84UEYWL7LaiolsJkBbT028O641Sldx lTAo5D9PAq3ACORRa4JnD1rrXZFRe8LLciOGOFOARG08K+1IBKoCtG1YY8qu493WQuXR dvZhUBTS9R02XOy6YRF2yo06wWaB54RZJgRC9Ylg9PI7oo3/kTYGsC7C8c47jEKQqlUu 48ZVppKik86X+VUrnBdjm0tOIslqALl7WodOXq2e/OxuNDOBIC2vH1YYfCSO1+qEVh0Z MSHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697995388; x=1698600188; 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=TR1rbIRAVPmg6FZUklnnnduo61uGU5Ugg06WBamDHUw=; b=ojj5gUuwlwBhCFNIJMxCJEznsJgfao7zSSNxcE8B+ZIog10uxZE7dqEqOhq7+Z06NW AfZLu4SU4mtzu/mlp2ml3Ssqy5lDopYXh23TBRu6VjeqH1HKIaKm/KxwefEMMp30uETa d0ZPvYx+tyhMT3KXPC7nHahBv2xi/IBRHzdRBbJ8qkMFxcvUJKBoEF1lpNd6ZIzzkKXM BH4RojBy0L4S3e0dzb7D2NTmHdO/egVGu6c4Zi/fYVa9VyvO9nfDRH8uVkZ9PQ3S4akQ JB6WDquAh4loYq19p/ScNV1LmZ/tU/jkWXW8MFon/U+3gv7gZdbp6y5j1aoawQezSlP9 tNpA== X-Gm-Message-State: AOJu0Yzyo7HUEIWlO7f5DPYWNw0qn8OiwD5Qb0UbKMCJ5p3akaWR5hNN DT7RCKkpoARTEweb6YzGX7cOu6Q3mNs= X-Google-Smtp-Source: AGHT+IHKXkwcFSqiGLw9BE2OaR2A81h471j3cwpibbjiSufBeLaZEit2tS4ICIKb52ku2A0mBjhg5Q== X-Received: by 2002:a5d:43c2:0:b0:32d:804c:15d1 with SMTP id v2-20020a5d43c2000000b0032d804c15d1mr5051743wrr.47.1697995387780; Sun, 22 Oct 2023 10:23:07 -0700 (PDT) Received: from toolbox.taileb357.ts.net (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id o12-20020adfe80c000000b0032da49e18fasm6043836wrm.23.2023.10.22.10.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 10:23:07 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Andy Shevchenko , Jonathan Cameron , Lars-Peter Clausen , Angel Iglesias , Phil Elwell , Linus Walleij , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v2 1/5] iio: pressure: bmp280: Use i2c_get_match_data() Date: Sun, 22 Oct 2023 19:22:17 +0200 Message-ID: <0554ddae62ba04ccacf58c2de04ec598c876665e.1697994521.git.ang.iglesiasg@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 Reviewed-by: Andy Shevchenko 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 22 17:22:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 13432018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6234DC001DF for ; Sun, 22 Oct 2023 17:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232617AbjJVRXV (ORCPT ); Sun, 22 Oct 2023 13:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232708AbjJVRXR (ORCPT ); Sun, 22 Oct 2023 13:23:17 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C7CD119; Sun, 22 Oct 2023 10:23:15 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-32d8c2c6dfdso1616764f8f.1; Sun, 22 Oct 2023 10:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697995393; x=1698600193; 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=/Uvqm6njBSoTbqoFZ5igrrI4fi2hQcKwzs6OhXvSIfM=; b=O8zMeb2PJtBLCE2GvaMYdo6zoz4tGDBKVTYdKdE3bx8qCZ4RgmIB36iceC+FG9vuDh hZMuceKDg2D5Vx0HDSLKHHtvBmR8rLoQ8tilcWrHymwP5XCDCYQZe98IyxFLELF3kiOU dED4WBJylOVV9EbX16P4VkKQ4rKOS5gnzZoNFi7/V2M8FfOMuCAEt3o6jpGd8EGo4MKv LG3/ywz7y9bf3RynOorNu5f5mvA14ieNbjZJjj4Ddqzi9uB1voZBistgrQYIdzYLvusx yIEfReA878jbYfPrGpI0+mjbMciO6U4hnlYe8rZw+5043Ca3mHJl/HRAmt2QC1Q7Qe5s gnVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697995393; x=1698600193; 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=/Uvqm6njBSoTbqoFZ5igrrI4fi2hQcKwzs6OhXvSIfM=; b=uwbALmaW9g4SbgdaUmi6xWIBXIH0SY16sDxZXc5ws69+2oTPZxgLOA6VQMQOYREfLV zSkiEF8cqGukfAMiQO5WcL3smIehrFRiekMbSkktbou7xvDTlIcU5YbgE7IbMcZIOBOC gZNJlgu6W36tHDrxDhFvAUyQtO5TGNEkF3wId5EVZtn5E4/Gj84IJH+8wYzEIA3IR9Jg 2JQkx0CALBj/vZPMYjrj4JO1si5GBm+0uUkNtbEIrIw7zK9UT5tNMDhI/uwGlJr4IWUj CTRjC8YmL4d7Hp6zkdNrwyxWFT81N43bMb1WMNOf/a7jKpoBae5iDtXYGUXQeis0onJG wXqQ== X-Gm-Message-State: AOJu0YypB9vMzNZ8DKAdv8qtXtHAZg+XuUuGTYUvRMzy1LjB/HsEPTkm IWefBzrd2wAudbhKeOtFT1nCW87IW2Y= X-Google-Smtp-Source: AGHT+IHg3z/YYy0wIIyL6x3ZWFz5huQ6vNT0zjKTPX5vX/U83OKah6ASKwsIKnmglA/T8eDzEndJGQ== X-Received: by 2002:adf:eed0:0:b0:32d:9572:646e with SMTP id a16-20020adfeed0000000b0032d9572646emr5621672wrp.54.1697995393643; Sun, 22 Oct 2023 10:23:13 -0700 (PDT) Received: from toolbox.taileb357.ts.net (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id o12-20020adfe80c000000b0032da49e18fasm6043836wrm.23.2023.10.22.10.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 10:23:13 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Angel Iglesias , Andy Shevchenko , Jonathan Cameron , Lars-Peter Clausen , Phil Elwell , Linus Walleij , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v2 2/5] iio: pressure: bmp280: Use spi_get_device_match_data() Date: Sun, 22 Oct 2023 19:22:18 +0200 Message-ID: <9ea8ac90b2b8a8cf45803d0435243c0bee009b37.1697994521.git.ang.iglesiasg@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 Reviewed-by: Andy Shevchenko 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 22 17:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 13432019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDFBBC001DF for ; Sun, 22 Oct 2023 17:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231903AbjJVRXc (ORCPT ); Sun, 22 Oct 2023 13:23:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232675AbjJVRXX (ORCPT ); Sun, 22 Oct 2023 13:23:23 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94580D67; Sun, 22 Oct 2023 10:23:21 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-32d9b507b00so1853892f8f.1; Sun, 22 Oct 2023 10:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697995400; x=1698600200; 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=U16I08jUhkJbDT8Pvh8OQ/ehSDzUYHV+MFJhR/fTJvw=; b=Hg97zCj/2MwdNujiJQ+AxNdxOKyLaFQ/W39oU/KUZlpRS7naLVCVV2EWpQf3etSxQY aF7Y4lkC9cm9Oa0KHRhi5aHTWdMznxxErhKNeSNPI/mry2FUekzyUErOPgcjbNTDvBwy gJp5ya698otjAchzIJbZL86hNYzPV6w5WXyWziZkTAHDl5dQP+SeskMP8y/he9CogM0j dnGRzOkfeE6T9sGQE/AIPcSbXRN3FUFjqrBHCdA2Skqn6zaTbpc66giEXZobndQjicMK WfLgpjfDXhOggCs15l+q5XSpJo4IlVhFSrm2AZOSwpMuI8Z2ME8qjOSmL9MYY9YmdTM1 OIeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697995400; x=1698600200; 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=U16I08jUhkJbDT8Pvh8OQ/ehSDzUYHV+MFJhR/fTJvw=; b=mkz7m3h+Vv/mHYiIBBSS66/No3vQ7Qz+jqAdZUU7u7X3Ge9SCrCFt5/QjBwyXGe313 QKGHAos14NapypHn5LIrdkUwtrEPgef4Irr6XDH7YIPgmDFeiRQmGMrtFO7oFeEz0q35 hfqo6tpnd+TC1fhW/lySwGUss5atDVvsfEZvl3qNuluvKcw8k8g6lBdDrIiImvj0DbJA aWIMK5nU7Ff+UXOHBoYxacIT3/saDBlzFDspZbCpKrPPB7aiSokHUagwbVmaFyXSy6tR kaJovx61c2ai8cZUBmZ67Re03yH46bNGApieNcbKhftipjwTboLffw9HaMVXKVpgO27C P6Ug== X-Gm-Message-State: AOJu0Yz0ZboO2MFhNQ29rqXJVp1MnDlc399ynNSYsNawfO1Ukqgrz1WR +Dnad4MkvhRQibwd0mVJLtKA75xyHpA= X-Google-Smtp-Source: AGHT+IHIGoP4U+FJFXwK4w/LAe4EZZyuSEwouQshjCZx+TEc7B/1ohW95mTMiPza0sfTsTNCeQCYAw== X-Received: by 2002:a5d:4704:0:b0:32d:aabd:d70f with SMTP id y4-20020a5d4704000000b0032daabdd70fmr4920709wrq.46.1697995399519; Sun, 22 Oct 2023 10:23:19 -0700 (PDT) Received: from toolbox.taileb357.ts.net (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id o12-20020adfe80c000000b0032da49e18fasm6043836wrm.23.2023.10.22.10.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 10:23:19 -0700 (PDT) From: Angel Iglesias To: linux-iio@vger.kernel.org Cc: Biju Das , linux-kernel@vger.kernel.org, Angel Iglesias , Andy Shevchenko , Jonathan Cameron , Lars-Peter Clausen , Linus Walleij , Phil Elwell , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v2 3/5] iio: pressure: bmp280: Rearrange vars in reverse xmas tree order Date: Sun, 22 Oct 2023 19:22:19 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Small cleanup reordering local variable declarations following reverse christmas tree convention. Signed-off-by: Angel Iglesias Reviewed-by: Andy Shevchenko 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 22 17:22:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 13432020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08EE3CDB474 for ; Sun, 22 Oct 2023 17:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232754AbjJVRXi (ORCPT ); Sun, 22 Oct 2023 13:23:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232773AbjJVRXc (ORCPT ); Sun, 22 Oct 2023 13:23:32 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AA610CA; Sun, 22 Oct 2023 10:23:27 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3296b3f03e5so1748917f8f.2; Sun, 22 Oct 2023 10:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697995405; x=1698600205; 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=0ZN0QEHYImLyvL58njc7Kf8hTMwYcRL9gq6A20t3tjE=; b=YENEl/s655Ztj0EBJZ3jAFoogomsQFsWkUf6Gn0H+1p1mhNlJupt38lb11hTo345vY LY1fJGtoDZt1TtPhARNYVVtBwMr7blcp6vHpxHfUge+nDmyn+M/p91XVG/D6Zt5faF0o QjjzyG/hPwdxbwj7IKrWK0vVLH1oXFKcW85JX7aBldLELLoF9KZ4Vqg2untog7YW4b6+ KLdnqSAhjsFfTpuvhl/H4B0CfEpVb+nfiCLGrflc28QsaaaYMsIqjQWvlAiS7iW1OPB0 tkyG4Z+M70V0hQ8MGPhPKog6ZY/nohDf8FtFR1hGYcwl50PhiUEQxCe7upbEkJ0mDD33 e0FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697995405; x=1698600205; 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=0ZN0QEHYImLyvL58njc7Kf8hTMwYcRL9gq6A20t3tjE=; b=VDeZXCzW5+R4JNFtBack78GhPkzyuOgHVlFEy1EfT91UMnuM369Kg+MV8SFYWoDwUx fU7f6xlQOm0Kuh61+oT6tPOqBDe5Y966A57VtDueu+4MZ6QyfapPyE5JXxfVgPmI6KMc sNgW4NYH6lEZL1cy5lBVYF22Z0oOQXkzh5KW1PyxBtt1uQgDnhTBG5Ocyh6O2iFyfU1G TSjqO2JLqDjrgGR8MYaqc/6rEklvvaLoqnXoueawstFVFfu4719USCHv8PwoOSO41udE XCL5KvQNWG79ybdZuKcxjufdXm33EmVa2QwlQJfTjPp1UF2DoOxuOfUXTv45K36IyVDj pESQ== X-Gm-Message-State: AOJu0Yx1AED91wckYKXd0rEiOeoEOqXKqcC0sa++eGEHK656ety90TRN HkfbeHZ2nw2D78/NpxKIMjdRm7dExis= X-Google-Smtp-Source: AGHT+IHkDQ3bfQ7zHywkp5cjIG7DAoLYtCbQ7ZDHm4uyd8SghYZB3tP5E6VnYps1Ycf13sswMRHnLQ== X-Received: by 2002:adf:ef4e:0:b0:324:8502:6355 with SMTP id c14-20020adfef4e000000b0032485026355mr4475390wrp.46.1697995405412; Sun, 22 Oct 2023 10:23:25 -0700 (PDT) Received: from toolbox.taileb357.ts.net (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id o12-20020adfe80c000000b0032da49e18fasm6043836wrm.23.2023.10.22.10.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 10:23:25 -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 , Phil Elwell , Linus Walleij , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v2 4/5] iio: pressure: bmp280: Allow multiple chips id per family of devices Date: Sun, 22 Oct 2023 19:22:20 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Improve device detection in certain chip families known to have various chip ids. When no known ids match, gives a warning but follows along what device said on the firmware and tries to configure it. Signed-off-by: Angel Iglesias diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index a2ef1373a274..deb336781b26 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -794,10 +794,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 +848,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 +1225,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 +1727,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 +1992,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 +2088,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,12 +2154,19 @@ 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]) { + dev_info(dev, "0x%x is a known chip id for %s\n", chip_id, name); + break; + } + dev_warn(dev, "chip id 0x%x does not match known id 0x%x\n", + chip_id, data->chip_info->chip_id[i]); } + if (i == data->chip_info->num_chip_id) + dev_warn(dev, "bad chip id: 0x%x is not a known chip id\n", chip_id); + if (data->chip_info->preinit) { ret = data->chip_info->preinit(data); if (ret) 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 22 17:22:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angel Iglesias X-Patchwork-Id: 13432021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27267C001DF for ; Sun, 22 Oct 2023 17:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbjJVRXw (ORCPT ); Sun, 22 Oct 2023 13:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232774AbjJVRXi (ORCPT ); Sun, 22 Oct 2023 13:23:38 -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 886A0188; Sun, 22 Oct 2023 10:23:33 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4084e49a5e5so21860775e9.3; Sun, 22 Oct 2023 10:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697995411; x=1698600211; 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=79Dx0uLbBVkqJTCtZs4cLaK3T8okZZKMf9z3Pmca9Oo=; b=JiPNAfhDcupoMTkEa4wuCujCo24drVu7+lVyw+XjavznDkQg1NRuoeHgy+IpsuU7RO WClrY9r1GFhqvOXU32Kn9LoHPPu+9yqKet5dKoAGqHuh1Q3ZcQ385oj4ERuI79v52Q7l JqTY4V/Hbw6EWCNu9fdPMeO0EYzszsg+jGfyz4reO89BLwd4+QLEodhg0tryklhBQWGO VXfQcnVwzUToOsPZNgmjj9zkxa70/QdVoUSgBJvewh/bM3sc99TkWbleUxP1x+B1vfam c8frhcEFpzSjT5rNMmZlvAvC9DK5GbsASKvMfSA/DV4XFkK7F4WmVbJqNKShrSYgakbe jxXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697995411; x=1698600211; 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=79Dx0uLbBVkqJTCtZs4cLaK3T8okZZKMf9z3Pmca9Oo=; b=URUudC7aTZhNjKzTk4EVuvHJRl1fdyh2FuIEwl3/lI+zyhRqCVAvLyZwCC794uyw6J Wmwm/yMIjA8fo1HjPONte8HtiD8G6GTqD+MvV9D2hy96UjaNxDAU0QB+kKh3xShvZVDf ZJ+awoAc3WO4gxL1k+++TLGbCeiKDIasUyMSLe4Zb5iRjV0EW8atL3lQSyrLNWabfgCR B6z8kcOEHkpE6ZJ0A1wWyh/X8nLbLT4LU++qPFPJgotIsAbGF+kbtph4b1lDSUrH7DWL kuIVS3mH+fLwumw0OcK808zim9H6ASSR45OzWrC1DzN5zkMU3Es3OO4L5JU5cYDMPKEE uUxQ== X-Gm-Message-State: AOJu0YxqGh/fZy8tDRfmXAmnszUWR+1dBTLeRnlYWOnxW7Mddu+HvdqZ 347V/kdoj7WWWUxjtsMa/gSvGRikrbw= X-Google-Smtp-Source: AGHT+IEHo0j83UHCKmOEJ57H0YfOUxlOeVgfQCKw4Qz64tkfoyF7VQOLu5v2+Pmss52iH5ezoZl9vg== X-Received: by 2002:a05:600c:188a:b0:406:7021:7d8 with SMTP id x10-20020a05600c188a00b00406702107d8mr5560229wmp.20.1697995411245; Sun, 22 Oct 2023 10:23:31 -0700 (PDT) Received: from toolbox.taileb357.ts.net (13.red-83-35-58.dynamicip.rima-tde.net. [83.35.58.13]) by smtp.gmail.com with ESMTPSA id o12-20020adfe80c000000b0032da49e18fasm6043836wrm.23.2023.10.22.10.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 10:23:31 -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 , Linus Walleij , Phil Elwell , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v2 5/5] iio: pressure: bmp280: Add support for BMP390 Date: Sun, 22 Oct 2023 19:22:21 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 deb336781b26..c6c761e84006 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: @@ -1225,7 +1226,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