From patchwork Tue Mar 7 19:33:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 65830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2633216wrd; Tue, 7 Mar 2023 12:02:20 -0800 (PST) X-Google-Smtp-Source: AK7set9Mjj4qybriebvVGpDPzRiYxR6dJkReEu00qjIwRjJvFr8+FasUhvWZujeAn3Rh46xT5gKc X-Received: by 2002:a05:6402:150e:b0:4ad:316:b4d9 with SMTP id f14-20020a056402150e00b004ad0316b4d9mr16543258edw.15.1678219340476; Tue, 07 Mar 2023 12:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678219340; cv=none; d=google.com; s=arc-20160816; b=dAoDwyz4S3fVExl4yGBlpiU78jvKt2mlWLabc+oZScElk4IuU8hsHrhJhxWBQexnGa HPM4+kJZ8+7GslfcMwvLSFrU8S1x4Y8AO0o3CD6tFSmgEyD6XBY8duULVovBHkCJRFb/ Ap3J/Hib5ZxC/8uuSnzC6OlLhLQLn0DxF+jYhx/TifUjPae8JdsNMOI3TlaZ/rcHjJHy 7BJ7H40qIVBc406OABspplPLjo7gdGqamxI68LWzEb0KTUONgXI/SSsGeWnmMc2hSg1O OLIvtVyYjNJy6miCxz+h1rrBcKlokp0bPwU3wgxQ3mmFYW37YN9aHEPZpor3qBUpjB22 G3CQ== 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=DjK0sRaZ4GVXYwVt87u0D782I7dRwIU+ZR/XTBfA0TU=; b=SJna7/PQgbQA9KXlI8HyxN9H9OrK3eNE3kzyaxjoKRupqBv209ezw9+hxkZWqDOwMf jgUhU/TU6N8rLIPmkXFw/ITzVplQgMVPk0MfTbEdgKm+JPH0C44gUCXMWNgWoKdM9NoR 4H7F67V+eFNEBv75uWYr8pl1DT2WJdNDNQiEfdKyMdl/YkmyoD+4B+ktfNQouwwekrjF voc6oaWiONHMDbVNFDyOZwKDhKfa16/J8kXKkMVjEamsCzNuiMudwpTde5LUcZI5Zhjz 4hrlshz3B8yUVbmf68qewPd9T/PesYCUtpEthIxmUaZTaWFVIrlpMHqKpISNVx4iMLso w40w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EitCBHAh; 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 j14-20020a170906278e00b008f8929efcf4si1543561ejc.108.2023.03.07.12.01.57; Tue, 07 Mar 2023 12:02:20 -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=EitCBHAh; 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 S229806AbjCGTqR (ORCPT + 99 others); Tue, 7 Mar 2023 14:46:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbjCGToe (ORCPT ); Tue, 7 Mar 2023 14:44:34 -0500 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D29898EAC; Tue, 7 Mar 2023 11:33:51 -0800 (PST) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 327JXkUT129401; Tue, 7 Mar 2023 13:33:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1678217626; bh=DjK0sRaZ4GVXYwVt87u0D782I7dRwIU+ZR/XTBfA0TU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EitCBHAh+cm7VmVxIbji4uMTPu+LdVUOa7hsuXAzdv9vz/sEfS3wFfbzAUwY4V9XL PRXtDV9PkXkSZGDShQHGn/Zb1X8ALlbZlM9cWRA62FZKfmIgHsySoJyOn6FJzg9oUZ PA3tgf7JANtolRhICYY5N6j/BMqOWmyy5kyPjans= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 327JXk6p007552 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 7 Mar 2023 13:33:46 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE108.ent.ti.com (157.170.170.38) 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 13:33:46 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE101.ent.ti.com (157.170.170.31) 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 13:33:46 -0600 Received: from ula0226330.dal.design.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 327JXkWp026389; Tue, 7 Mar 2023 13:33:46 -0600 From: Andrew Davis To: Peter Tyser , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski CC: , , Andrew Davis Subject: [PATCH v2 4/6] gpio: pisosr: Use devm_gpiochip_add_data() to simplify remove path Date: Tue, 7 Mar 2023 13:33:44 -0600 Message-ID: <20230307193346.8718-4-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307193346.8718-1-afd@ti.com> References: <20230307193346.8718-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?1759740523162440779?= X-GMAIL-MSGID: =?utf-8?q?1759740523162440779?= Use devm version of gpiochip add function to handle removal for us. While here update copyright and module author. Signed-off-by: Andrew Davis --- Changes from v1: - Use devm to cleanup mutex drivers/gpio/gpio-pisosr.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c index 67071bea08c2..4c9d138a7dc7 100644 --- a/drivers/gpio/gpio-pisosr.c +++ b/drivers/gpio/gpio-pisosr.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ - * Andrew F. Davis + * Copyright (C) 2015-2023 Texas Instruments Incorporated - https://www.ti.com/ + * Andrew Davis */ #include @@ -116,6 +116,13 @@ static const struct gpio_chip template_chip = { .can_sleep = true, }; +static void pisosr_mutex_destroy(void *data) +{ + struct mutex *lock = data; + + mutex_destroy(lock); +} + static int pisosr_gpio_probe(struct spi_device *spi) { struct device *dev = &spi->dev; @@ -126,8 +133,6 @@ static int pisosr_gpio_probe(struct spi_device *spi) if (!gpio) return -ENOMEM; - spi_set_drvdata(spi, gpio); - gpio->chip = template_chip; gpio->chip.parent = dev; of_property_read_u16(dev->of_node, "ngpios", &gpio->chip.ngpio); @@ -145,8 +150,11 @@ static int pisosr_gpio_probe(struct spi_device *spi) "Unable to allocate load GPIO\n"); mutex_init(&gpio->lock); + ret = devm_add_action_or_reset(dev, pisosr_mutex_destroy, &gpio->lock); + if (ret) + return ret; - ret = gpiochip_add_data(&gpio->chip, gpio); + ret = devm_gpiochip_add_data(dev, &gpio->chip, gpio); if (ret < 0) { dev_err(dev, "Unable to register gpiochip\n"); return ret; @@ -155,15 +163,6 @@ static int pisosr_gpio_probe(struct spi_device *spi) return 0; } -static void pisosr_gpio_remove(struct spi_device *spi) -{ - struct pisosr_gpio *gpio = spi_get_drvdata(spi); - - gpiochip_remove(&gpio->chip); - - mutex_destroy(&gpio->lock); -} - static const struct spi_device_id pisosr_gpio_id_table[] = { { "pisosr-gpio", }, { /* sentinel */ } @@ -182,11 +181,10 @@ static struct spi_driver pisosr_gpio_driver = { .of_match_table = pisosr_gpio_of_match_table, }, .probe = pisosr_gpio_probe, - .remove = pisosr_gpio_remove, .id_table = pisosr_gpio_id_table, }; module_spi_driver(pisosr_gpio_driver); -MODULE_AUTHOR("Andrew F. Davis "); +MODULE_AUTHOR("Andrew Davis "); MODULE_DESCRIPTION("SPI Compatible PISO Shift Register GPIO Driver"); MODULE_LICENSE("GPL v2");