Message ID | b3483bd87093d4cd0862904b70a167ebbb538644.1691276610.git.ang.iglesiasg@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp707458vqr; Sat, 5 Aug 2023 18:34:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMt89969XeCzvx5/sF5TYVN0xi5luGOZzbKsXbKbqVhrQ8LKnb2rssBIrT2n+pjcoInsmD X-Received: by 2002:a05:6a20:a11a:b0:13e:b58a:e3e8 with SMTP id q26-20020a056a20a11a00b0013eb58ae3e8mr5575296pzk.50.1691285655849; Sat, 05 Aug 2023 18:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691285655; cv=none; d=google.com; s=arc-20160816; b=LWbYzHxYgmhl9eBPzL0T2qiZyAwVtXXsqZMAl55kgsOVlm3zcxTQO2+UNyoGqK5yWM SDZLlH81QSj75zzNTf1RijIA8Y4i5q5qZvaLcpv+bvzW7wOCN3D9SARtuWQ7mCk5XrUn et2jMtZBdEIvHqX8cTZ8sUCFIdzhFom5/Q1NADAgdOljAsuMaFUzfLw5T2JOZmaGYCLB C0hckuHrNkg9mbUTvtMOcq5PXw0neF/99vgetlMdSNycL4TFDDawLcKJqCr26RKyWRK6 j6xmp3lXXKLbF1ecPoHYgQEKeeLsHNyPj+fncOwOLxDhbH0BlHqojOBqP9dBMiPSCVeY 4GZQ== 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=XLYg/J+UJ6fbY/mN9HM7bVyp2sfI4lnm/dmzqkwlIjY=; fh=IsiLy6JSrE46s8FLSvjAHSHod6n3PCFgfRLA/rXEpK4=; b=Xyfal5bkzywIDkHFpFrPvt3pP3xLnMsQorWHw/Z8XAzgAa1xWA9jw290H4K3JrntuL RSqHMDAuy2sg5V1G/bpmEcxXVtX0NIJA1BCQEOgS0qHjgPg1uC/CGpCGLukcMuNbq9nn F1OICMBya14t5pTjVtXTGe68mv2ljGRJbU3s5cDBR2YQ2elOpvLKLJ48bJiY93C7oPQX RijMVcAGblWgHHpKQ5LemMon6AY/ArITOHsAIYOo73VT783nbOYVE2Bmkv2z9+QlxP/3 5i1VkMTUEL1EdsmkjjTtfViNx9CpeQnHK1hcHqlxCNV30Kntga9aXsHkgiyGTxfKMTeo MjZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=H3ug8b0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j34-20020a632322000000b005644829012fsi3874805pgj.701.2023.08.05.18.34.02; Sat, 05 Aug 2023 18:34:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=H3ug8b0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229479AbjHEXP7 (ORCPT <rfc822;david.simonyants@gmail.com> + 99 others); Sat, 5 Aug 2023 19:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbjHEXP6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 5 Aug 2023 19:15:58 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56D426BE; Sat, 5 Aug 2023 16:15:44 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fe4b45a336so13360155e9.1; Sat, 05 Aug 2023 16:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691277343; x=1691882143; 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=XLYg/J+UJ6fbY/mN9HM7bVyp2sfI4lnm/dmzqkwlIjY=; b=H3ug8b0CDCTepLMQsXNP2LkonvE8Y1AJvRJ8q5Sa1DgdXuaKoUGfdeZxRfGyW4zXAD 4d/Cr2HToB5v6VnWHhQiM3pOhOPlR4JGOlJRmRGLXNavcEzA5WsTJygBDiIDlG2675zs prWx7iI2ILpz2ZG28ImDaEE3lnFZyMQxl5INF3azCejE1zsywvc/RePKC2+gc2vRl1NZ kTs0kQ5PMmnk5nci4Ao3h8F/QZwxdhZ9J6C5r2cBjeyg02Z0kG3FFkH1t3kjfKC1D8Cq hdYBKPf9RQHVf0egXPLpHvEWhkK39GhCOaJvg5/hORoluEiwgsSTkXVJBMNRZ+jQ97UB lTJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691277343; x=1691882143; 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=XLYg/J+UJ6fbY/mN9HM7bVyp2sfI4lnm/dmzqkwlIjY=; b=OeAbJE/xK6nEr5mI2wJ9n9yokon1zYnjRVoTg0y3/xuPQYSNGz9dLT6NuFf6V3jl37 Vr9q675BmRzB2bZdd2aUioNpIIk5BCFgp1IzkSJAGk3YB7KTxMHKRmB5+EAlC3fcM03Y Cyv2dvDkiLf9GMXdS7eZwDpO5gCW0En1nKROIge2uFSls/Gf+lR5o5YrLojzan0z7ywq DOVaHF9nwoa0JaRSqfybET1FBdqtbsk+qcDeuktOTuIS75F+hmEA1XjgzWp7pUw4OTKe prkh5au8znO092Yf/uQ1Jq2eRjNaP902Cnic853raT3sP5UvRyVO7X0Ftrk+mc5pf19K hk4g== X-Gm-Message-State: AOJu0YypoCFidl12pbKVDBTHjEa4Spmu6ASgMf9RAmUWXUuSembL54BK AT7Pd18zo6K7wfdnDi7vK5eGEcaS0gw= X-Received: by 2002:a5d:408b:0:b0:317:6653:60b8 with SMTP id o11-20020a5d408b000000b00317665360b8mr3450975wrp.50.1691277342682; Sat, 05 Aug 2023 16:15:42 -0700 (PDT) Received: from toolbox.taileb357.ts.net (89.red-83-35-60.dynamicip.rima-tde.net. [83.35.60.89]) by smtp.gmail.com with ESMTPSA id s9-20020adfecc9000000b0031416362e23sm6212531wro.3.2023.08.05.16.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Aug 2023 16:15:42 -0700 (PDT) From: Angel Iglesias <ang.iglesiasg@gmail.com> To: linux-iio@vger.kernel.org Cc: Angel Iglesias <ang.iglesiasg@gmail.com>, Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= <u.kleine-koenig@pengutronix.de>, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] iio: pressure: bmp280: Use i2c_get_match_data Date: Sun, 6 Aug 2023 01:15:03 +0200 Message-ID: <b3483bd87093d4cd0862904b70a167ebbb538644.1691276610.git.ang.iglesiasg@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <cover.1691276610.git.ang.iglesiasg@gmail.com> References: <cover.1691276610.git.ang.iglesiasg@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773441547696744009 X-GMAIL-MSGID: 1773441547696744009 |
Series |
iio: pressure: bmp280: Use i2c_get_match_data()
|
|
Commit Message
Angel Iglesias
Aug. 5, 2023, 11:15 p.m. UTC
Replaces device_get_match_data() and fallback match_id logic by new
unified helper function i2c_get_match_data().
Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com>
Comments
On Sun, Aug 06, 2023 at 01:15:03AM +0200, Angel Iglesias wrote: > Replaces device_get_match_data() and fallback match_id logic by new > unified helper function i2c_get_match_data(). > > Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> > > diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c > index 693eb1975fdc..4ebaa4edc4fc 100644 > --- a/drivers/iio/pressure/bmp280-i2c.c > +++ b/drivers/iio/pressure/bmp280-i2c.c > @@ -11,9 +11,9 @@ static int bmp280_i2c_probe(struct i2c_client *client) > const struct bmp280_chip_info *chip_info; > struct regmap *regmap; > > - chip_info = device_get_match_data(&client->dev); > + chip_info = i2c_get_match_data(client); > if (!chip_info) > - chip_info = (const struct bmp280_chip_info *) id->driver_data; > + return -ENODEV; the old code assumed that chip_info isn't NULL (implicitly by dereferencing that pointer in the line below). I wouldn't change semantics in a patch converting to a helper and so just do: - chip_info = device_get_match_data(&client->dev); + chip_info = i2c_get_match_data(client); - if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; or alternatively, if you think adding a check is a good idea, add an error message in the error path and mention the semantic change in the commit log. Best regards Uwe
On Sun, 2023-08-06 at 13:30 +0200, Uwe Kleine-König wrote: > On Sun, Aug 06, 2023 at 01:15:03AM +0200, Angel Iglesias wrote: > > Replaces device_get_match_data() and fallback match_id logic by new > > unified helper function i2c_get_match_data(). > > > > Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> > > > > diff --git a/drivers/iio/pressure/bmp280-i2c.c > > b/drivers/iio/pressure/bmp280-i2c.c > > index 693eb1975fdc..4ebaa4edc4fc 100644 > > --- a/drivers/iio/pressure/bmp280-i2c.c > > +++ b/drivers/iio/pressure/bmp280-i2c.c > > @@ -11,9 +11,9 @@ static int bmp280_i2c_probe(struct i2c_client *client) > > const struct bmp280_chip_info *chip_info; > > struct regmap *regmap; > > > > - chip_info = device_get_match_data(&client->dev); > > + chip_info = i2c_get_match_data(client); > > if (!chip_info) > > - chip_info = (const struct bmp280_chip_info *) id- > > >driver_data; > > + return -ENODEV; > > the old code assumed that chip_info isn't NULL (implicitly by > dereferencing that pointer in the line below). I wouldn't change > semantics in a patch converting to a helper and so just do: > > - chip_info = device_get_match_data(&client->dev); > + chip_info = i2c_get_match_data(client); > - if (!chip_info) > - chip_info = (const struct bmp280_chip_info *) id->driver_data; > > or alternatively, if you think adding a check is a good idea, add an > error message in the error path and mention the semantic change in the > commit log. > Oh I see. I didn't take into account all this. Thanks for your time > Best regards > Uwe > Kind regards Angel
diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c index 693eb1975fdc..4ebaa4edc4fc 100644 --- a/drivers/iio/pressure/bmp280-i2c.c +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -11,9 +11,9 @@ static int bmp280_i2c_probe(struct i2c_client *client) const struct bmp280_chip_info *chip_info; struct regmap *regmap; - chip_info = device_get_match_data(&client->dev); + chip_info = i2c_get_match_data(client); if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + return -ENODEV; regmap = devm_regmap_init_i2c(client, chip_info->regmap_config); if (IS_ERR(regmap)) {