Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp122396imm; Mon, 21 May 2018 03:23:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZppuae2LyGOmPKw9nNYHm/efMG3iheBdTEGiiRcrGsipiJbatyT+bkQHNZWdCfNt3DPRBpl X-Received: by 2002:a17:902:680c:: with SMTP id h12-v6mr20282923plk.113.1526898219546; Mon, 21 May 2018 03:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526898219; cv=none; d=google.com; s=arc-20160816; b=mG51vNGwnjNJezO0ca/oCGDMxxytscCeg54sn4vQNcpTCwezJjHBxO+5jVfnG27CdM UzkNDafycx0XtTaJhgtU1lIlcW4y3r9JQ6fa4zhhvqBd3bVlwbNrANPb4Q3OmQylHpRS xuByXeb7wQitJsgyBbFyM6VyzohZE/r0XEsxbIo+KtO+pMqqb8IWf+rqM6NYylsLzZer AthOT3PTcq1LetY8kBUTHu5A58nBVzOhwLg962xU9kCmkNQEmNpW2LA4jIy3ytVo0nkd w3I06lfVYRm65055BPpi8NgzPySic12G5FZmGU330t5GGGyYcFSvWI8f3bbN9mByHo/v xIsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=bxTCILUY9pvQBU0VjZHDJSGkvX5iZGj7AV2MLQo4tCI=; b=d5GS4t59j2NYhSYargt5GZpvv4J3wmzdiDq8Oth+02JQPhlLLGzUVL8vxCcpwUJpLV qZmiTooDnHGNxFATANl13qLVsLKqq0HNgcuo+inWsaxD1vMvf1AcxykjMmTG0jV9+smL z4TCb7i6Koifh4css1/xQZS+gU46ErAEQx8HGeaunfjPq8RycpQgH+djzzRUSj8jx+pn x9Y/bO8uZIQvE0oraJGvUMdkFTF1jjmrvIWnaNmo5VnJvzqW/h7y39Fyt9oVxRsrSL2O HosPAVStk+M3ZnxDspHp51jMhH4xVNY8FCeeptpN0mKgte2Z8Q5filB6q3g8HidOkliv xFNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1-v6si10288687pgp.212.2018.05.21.03.23.25; Mon, 21 May 2018 03:23:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752714AbeEUKVV (ORCPT + 99 others); Mon, 21 May 2018 06:21:21 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:35615 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751181AbeEUKUu (ORCPT ); Mon, 21 May 2018 06:20:50 -0400 X-IronPort-AV: E=Sophos;i="5.49,426,1520895600"; d="scan'208";a="327708873" Received: from palace.rsr.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA256; 21 May 2018 12:20:48 +0200 From: Julia Lawall To: Peter Rosin Cc: kernel-janitors@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Himanshu Jha Subject: [PATCH 1/3] i2c: mux: pca954x: merge calls to of_match_device and of_device_get_match_data Date: Mon, 21 May 2018 11:49:08 +0200 Message-Id: <1526896150-27134-2-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1526896150-27134-1-git-send-email-Julia.Lawall@lip6.fr> References: <1526896150-27134-1-git-send-email-Julia.Lawall@lip6.fr> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drop call to of_match_device, which is subsumed by the subsequent call to of_device_get_match_data. The code becomes simpler, and a temporary variable can be dropped. The semantic match that makes this change is as follows: (http://coccinelle.lip6.fr/) // @r@ local idexpression match; identifier i; expression x, dev, e, e1; @@ - match@i = of_match_device(x, dev); - if (match) e = of_device_get_match_data(dev); - else e = e1; + e = of_device_get_match_data(dev); + if (!e) e = e1; @@ identifier r.i; @@ - const struct of_device_id *i; ... when != i // Signed-off-by: Julia Lawall --- drivers/i2c/muxes/i2c-mux-pca954x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 09bafd3..ced840f 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -373,7 +373,6 @@ static int pca954x_probe(struct i2c_client *client, int num, force, class; struct i2c_mux_core *muxc; struct pca954x *data; - const struct of_device_id *match; int ret; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) @@ -394,10 +393,8 @@ static int pca954x_probe(struct i2c_client *client, if (IS_ERR(gpio)) return PTR_ERR(gpio); - match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); - if (match) - data->chip = of_device_get_match_data(&client->dev); - else + data->chip = of_device_get_match_data(&client->dev); + if (!data->chip) data->chip = &chips[id->driver_data]; if (data->chip->id.manufacturer_id != I2C_DEVICE_ID_NONE) {