From patchwork Sun Oct 1 15:01:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 147117 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp916177vqb; Sun, 1 Oct 2023 08:03:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiv8HeaA7pkasi0wXABkpj3bHUWAwFKTYW83K/IsN445qmm32cnmZB/6ZQnUp1HompRudl X-Received: by 2002:a05:6a21:3e0a:b0:163:b85e:6337 with SMTP id bk10-20020a056a213e0a00b00163b85e6337mr2286874pzc.38.1696172614779; Sun, 01 Oct 2023 08:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696172614; cv=none; d=google.com; s=arc-20160816; b=eCLh+2jhQpqXzg0x8SIkMFS+SxFNBQqm0qhDbhsj7b1IXW9kAubYvpzzLKyWLo8B0G 13r0955e02LM1Bql2F5LoBxE9agAjRYjjZHExwmp1Hjc04hiLva/QirGMF0mIGgU7YAt SFxh5r4IBq+z71Xc+PtnGiHPV0cNEcLf8BcsRPYGm6G1sIIiGcxElaZmj52ulFSr8Mi2 uLwWFJylNfTYRLGUvB7MUFn8tHRJWbXx7g3PJgBfJg12I4WQhTpHBu2rhjYlwtzsCgYt aSv8Y3HagzBxx6PP8dSGbfTniXtPBNfQpLmV0XsQE8YTwd1JV/A82Xwb9S16T5DIK/oQ MK+g== 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; bh=AK0kydBIdonXtKjXa8WjPCs2FsUGcWla1rU/pGhzJ5I=; fh=xeSrQ7kCdgcCVb2zAn5rBkDAdtmCo24cOODwKpU9NDo=; b=RRE7pTszq3G1BrTXnQ1HdUORCTowMyasDP9cyFvGm4cwrPOvH0a3HmIcno4djyTh+l UpxwZJxRMMUkLKA0DBcIPcoCXUPOi/Yz3yPYrLorCiJCqFVqH/bhvOqToNDIApb+1Nm0 JdFrYIuOE0qWx6mqKaCB80aKQSt5HuhKSLa46l1shFPYGxqrvJ3shQE6iOxHYlAYFqeb DxLP27QSd9qv9QuoLFbv4rKsfkL0eNFgesiaff8UOghLH/eUcoFFkzQWOTUfw2GNTIxw mnlaTn+V5wRH5LalB2fGitCEj/C3BBYCw7LT6VxxrXyBbrY0B4wC2vKfLHcYz1X1LJ/y WffA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x19-20020aa793b3000000b0068e4704fd5bsi23463589pff.346.2023.10.01.08.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 08:03:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 362858085F92; Sun, 1 Oct 2023 08:01:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235148AbjJAPB2 (ORCPT + 18 others); Sun, 1 Oct 2023 11:01:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235142AbjJAPB1 (ORCPT ); Sun, 1 Oct 2023 11:01:27 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5898FD9; Sun, 1 Oct 2023 08:01:25 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.03,191,1694703600"; d="scan'208";a="181547672" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Oct 2023 00:01:25 +0900 Received: from localhost.localdomain (unknown [10.226.92.25]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 24735420635B; Mon, 2 Oct 2023 00:01:22 +0900 (JST) From: Biju Das To: Linus Walleij Cc: Biju Das , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das , Andy Shevchenko Subject: [PATCH v4 2/3] pinctrl: mcp23s08_spi: Simplify probe() Date: Sun, 1 Oct 2023 16:01:12 +0100 Message-Id: <20231001150113.7752-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231001150113.7752-1-biju.das.jz@bp.renesas.com> References: <20231001150113.7752-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 (howler.vger.email [0.0.0.0]); Sun, 01 Oct 2023 08:01:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778565895700829988 X-GMAIL-MSGID: 1778565895700829988 Simpilfy probe() by replacing device_get_match_data() and ID lookup for retrieving match data by spi_get_device_match_data(). While at it, replace data type of variable type from 'int'->'unsigned int' and declare variables following a reverse christmas tree order. Signed-off-by: Biju Das Reviewed-by: Andy Shevchenko --- v3->v4: * No change. v2->v3: * Added Rb tag from Andy * Reordered the patch. v2: * New patch. --- drivers/pinctrl/pinctrl-mcp23s08_spi.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c index ea059b9c5542..caf528284d07 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c +++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c @@ -143,22 +143,17 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev, static int mcp23s08_probe(struct spi_device *spi) { - struct device *dev = &spi->dev; struct mcp23s08_driver_data *data; + struct device *dev = &spi->dev; unsigned long spi_present_mask; - const void *match; - unsigned int addr; unsigned int ngpio = 0; + unsigned int type; + unsigned int addr; int chips; - int type; int ret; u32 v; - match = device_get_match_data(dev); - if (match) - type = (int)(uintptr_t)match; - else - type = spi_get_device_id(spi)->driver_data; + type = (uintptr_t)spi_get_device_match_data(spi); ret = device_property_read_u32(dev, "microchip,spi-present-mask", &v); if (ret) {