From patchwork Tue Mar 7 16:54:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 65739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2550243wrd; Tue, 7 Mar 2023 09:13:30 -0800 (PST) X-Google-Smtp-Source: AK7set8iPPV+E/1kalxM4bmtmPu0D5R5E3PnsVhVclHCugg5Kdu9pqCQMorV/mwTKGwe+7AUHKYK X-Received: by 2002:a17:902:c40a:b0:19e:21d0:5b97 with SMTP id k10-20020a170902c40a00b0019e21d05b97mr20200756plk.50.1678209210505; Tue, 07 Mar 2023 09:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678209210; cv=none; d=google.com; s=arc-20160816; b=iW0FPxuPbE6D6JPGZfPUwPrZeW/jMIY0Rqj4oiagDVGvEWa7Wx41OgDesAq/+ZMtGk iNO8ZGk7QvzWE/s3Xb8OpSaqrD+gA+15ODEQ7P+d1o6fDh/3lqiU+R1/1z1vqw0vGGgv RwUqrDNottykUT7QetaefiPUa5HMRiKSWS6KTA723T2u50laLhCPh11L1PmIz7KKJLJ7 wnljzuMKTOwh/eJ2n/JzCLj9lLQ+gv7Nng54d5CRgw2Lm+w9LYe2QAvfaPtUA1z7awdW q0yefLfZunTRITz670gGaW0flcRyp5WZjgaKLc1DpAFnrVjnrQCdLRfKgsgTKeMY15ya 92uQ== 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=2QKk8MDasC9TQp6Y/MGWR5Z7h/GdVQwRLQTrVMYwwAU=; b=P9n/sDjLOVbP27szijj/a7FPBUFLF9YYnGtKKZj2WUX7ydbBmjetyzXX4HfWSAeF64 70sq9vUXUsPOEPowpdn2JtpV+TThjd9NFw/s7KTMSPCJ0P4gx3NX05C5CJEviO+8G/TH XC1M6eUUWxkI2M7x0K3tj8MJ/RXwMktVn8ydwZsZlrUKN6Bil0JBEu6LNCbWB6HCu8O2 UHiBWH4SEv7aNOikurwuGcOUoGMCsIuVBGdD6DyFOayCLGfEj7oTfZHdqFII9w+YcrTp wSdti4IAgggLstuzcZc0rnSfPTNrhJTybTM+IremQUmJB/HPRf+UxKThB0fCv+t2pdIH vFTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=pfhjQruv; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ka4-20020a170903334400b0019e69892709si11791010plb.596.2023.03.07.09.13.17; Tue, 07 Mar 2023 09:13:30 -0800 (PST) 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=@ti.com header.s=ti-com-17Q1 header.b=pfhjQruv; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbjCGQ7f (ORCPT + 99 others); Tue, 7 Mar 2023 11:59:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230429AbjCGQ6J (ORCPT ); Tue, 7 Mar 2023 11:58:09 -0500 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C2BE9439B; Tue, 7 Mar 2023 08:54:38 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 327GsXY5127689; Tue, 7 Mar 2023 10:54:33 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1678208073; bh=2QKk8MDasC9TQp6Y/MGWR5Z7h/GdVQwRLQTrVMYwwAU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=pfhjQruvytSSDyzqywO5GuSy4+jR60eiVzWkxzAHueQF5hIHLPLDMB4GyzzjBPBrX 3gZeIVb+cvg+6X3b6+a1geru6VQIALQcGdGfuy8cThUciJhPDqukoesc8mn7DD3gsh tEWP29+MyTEKFHX9hnkBIyKCsXESglGGXBjI66dk= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 327GsXrf028276 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 7 Mar 2023 10:54:33 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 7 Mar 2023 10:54:32 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 7 Mar 2023 10:54:32 -0600 Received: from ula0226330.dal.design.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 327GsWdU084852; Tue, 7 Mar 2023 10:54:32 -0600 From: Andrew Davis To: Peter Tyser , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski CC: , , Andrew Davis Subject: [PATCH 3/6] gpio: sch311x: Use devm_gpiochip_add_data() to simplify remove path Date: Tue, 7 Mar 2023 10:54:29 -0600 Message-ID: <20230307165432.25484-3-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307165432.25484-1-afd@ti.com> References: <20230307165432.25484-1-afd@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759729901030923287?= X-GMAIL-MSGID: =?utf-8?q?1759729901030923287?= Use devm version of gpiochip add function to handle removal for us. Signed-off-by: Andrew Davis --- drivers/gpio/gpio-sch311x.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index da01e1cad7cb..ba7c300511a5 100644 --- a/drivers/gpio/gpio-sch311x.c +++ b/drivers/gpio/gpio-sch311x.c @@ -281,8 +281,6 @@ static int sch311x_gpio_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - platform_set_drvdata(pdev, priv); - for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) { block = &priv->blocks[i]; @@ -305,36 +303,17 @@ static int sch311x_gpio_probe(struct platform_device *pdev) block->data_reg = sch311x_gpio_blocks[i].data_reg; block->runtime_reg = pdata->runtime_reg; - err = gpiochip_add_data(&block->chip, block); + err = devm_gpiochip_add_data(&pdev->dev, &block->chip, block); if (err < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", err); - goto exit_err; + return err; } dev_info(&pdev->dev, "SMSC SCH311x GPIO block %d registered.\n", i); } return 0; - -exit_err: - /* release already registered chips */ - for (--i; i >= 0; i--) - gpiochip_remove(&priv->blocks[i].chip); - return err; -} - -static int sch311x_gpio_remove(struct platform_device *pdev) -{ - struct sch311x_gpio_priv *priv = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) { - gpiochip_remove(&priv->blocks[i].chip); - dev_info(&pdev->dev, - "SMSC SCH311x GPIO block %d unregistered.\n", i); - } - return 0; } static struct platform_driver sch311x_gpio_driver = {