From nobody Mon Feb 9 13:01:26 2026 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 51F39C77B75 for ; Mon, 15 May 2023 17:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244360AbjEORpU (ORCPT ); Mon, 15 May 2023 13:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243494AbjEORo6 (ORCPT ); Mon, 15 May 2023 13:44:58 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3C9F147E8; Mon, 15 May 2023 10:42:34 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 34FHgPLJ025588; Mon, 15 May 2023 12:42:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1684172545; bh=kUoLNLKxxpWuzV2FDVeOM5tQWxiRCQGbtbtkwHxuXrY=; h=From:To:CC:Subject:Date; b=fOG+Gl2tN9XnaoDl9cE9YaZneXCIJabc8zQaW0llSLFPg5WgOh540mNO0xQp4mxTJ EL9vzJHW2Mx7VdesiuAF8U3mHcf+6B030uGfSJu4ZF02lnLT+ORyYCn84eFdeP/nPp qheEMQFDB8INXfsUe4Spav3sfhItF0LLZktt/NEY= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 34FHgPLU095087 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 15 May 2023 12:42:25 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 15 May 2023 12:42:25 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 15 May 2023 12:42:25 -0500 Received: from fllv0039.itg.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 34FHgP8f096075; Mon, 15 May 2023 12:42:25 -0500 From: Andrew Davis To: Peter Tyser , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski CC: , , Andrew Davis Subject: [PATCH v3] gpio: sch311x: Use devm_gpiochip_add_data() to simplify remove path Date: Mon, 15 May 2023 12:42:24 -0500 Message-ID: <20230515174224.494631-1-afd@ti.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use devm version of gpiochip add function to handle removal for us. Signed-off-by: Andrew Davis --- Changes from v2: - Remove platform_driver.remove (thanks kernel test robot) drivers/gpio/gpio-sch311x.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index da01e1cad7cb..ba4fccf3cc94 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 *p= dev) if (!priv) return -ENOMEM; =20 - platform_set_drvdata(pdev, priv); - for (i =3D 0; i < ARRAY_SIZE(priv->blocks); i++) { block =3D &priv->blocks[i]; =20 @@ -305,42 +303,22 @@ static int sch311x_gpio_probe(struct platform_device = *pdev) block->data_reg =3D sch311x_gpio_blocks[i].data_reg; block->runtime_reg =3D pdata->runtime_reg; =20 - err =3D gpiochip_add_data(&block->chip, block); + err =3D 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); } =20 return 0; - -exit_err: - /* release already registered chips */ - for (--i; i >=3D 0; i--) - gpiochip_remove(&priv->blocks[i].chip); - return err; -} - -static int sch311x_gpio_remove(struct platform_device *pdev) -{ - struct sch311x_gpio_priv *priv =3D platform_get_drvdata(pdev); - int i; - - for (i =3D 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; } =20 static struct platform_driver sch311x_gpio_driver =3D { .driver.name =3D DRV_NAME, .probe =3D sch311x_gpio_probe, - .remove =3D sch311x_gpio_remove, }; =20 =20 --=20 2.39.2