Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1651644rwp; Thu, 13 Jul 2023 14:24:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrLv0xo5PKObXxY8ySLsaJUJWZ7RNzlX8M8rwRehlHPJW2XiEFGGZFL/TR2vapfmjuziTZ X-Received: by 2002:a17:902:724b:b0:1b8:b436:c006 with SMTP id c11-20020a170902724b00b001b8b436c006mr1945317pll.12.1689283455759; Thu, 13 Jul 2023 14:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689283455; cv=none; d=google.com; s=arc-20160816; b=FmlrwyzsfGBpXuC2kRa5D5iVbWy8rmaAdwMdw/lp16kK5t0ORl4L9l96Yh1xmK/N1h kuZli/UDof9mLuj41dTAg7Yq7RXY9GCsGOfCWKA7NTVekKsJZXY+shtbSeSI9pOuY3+H pfpUbzmSKNubV5/gCzNSJnum0SmJHgcQKV3PNv/7Zpe1oNCYKn32RlXjgXw7B3l7wYFG QYg200QT8fxz6KlmTnII1yxFuSgf8Kv0a57Z+uRS4VHV2ipROuLWdBccP1dWQKMjlmZp bfYUx80L5AcrwsAhB4btCwKWE9jshE4/VbS2Zu9OxDuhlt2L61rnZ05oNsPt7iKXDv3l 6gbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SboTTTCH8PwJ1k7g+TtwxjrJ+lEO716FlHbTBOahELk=; fh=hnNHy+cX7cjukn8OYfdmkSHwhgxGBfmsMN9+m9951DU=; b=mJlqK9NDozrQBejQ4vpcHOL/Db7b8RBG+reD/vu4YalXak2fXsS8e+tuizm9d7zJdN 4QsZk1nGDm+X9d+8ovipxhMjn2R288Q9lX3tHvwa15OmrrP28SGhM3nZ4kP9oWJ+j5Bn k/iVDOdlsRmO/qNxc7ha0E+ph2iO1quMEOlP2zaKDsCSAR/KexAF9qlGOxiWoFPCRTXR XHx7ZknUQmofd8oc4KXr/80BD5cm9Xm80t7EfLBTYkaYeE9fw0ano4lXg+YZKA29KAAI gq8wmK1W1ZVao6KF9osceV1kAdXhWIvqa7vowSIZlyn9xL7evcBSWdWtTgd8b0UwHoJ0 W+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=SKbVRNck; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb1-20020a17090b4a4100b002636b31935asi6321035pjb.120.2023.07.13.14.23.59; Thu, 13 Jul 2023 14:24:15 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=SKbVRNck; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233881AbjGMUux (ORCPT + 99 others); Thu, 13 Jul 2023 16:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232270AbjGMUuw (ORCPT ); Thu, 13 Jul 2023 16:50:52 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 131A730C3; Thu, 13 Jul 2023 13:50:21 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-51dec0b6fecso1528539a12.1; Thu, 13 Jul 2023 13:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689281420; x=1691873420; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SboTTTCH8PwJ1k7g+TtwxjrJ+lEO716FlHbTBOahELk=; b=SKbVRNckqBlwzRAuMF9yH+PurYvVsa8fqvtw+zDL/az2bGnW9qsiq2mVvgsSwr+FdN CBy1I39CdxXEslgDuDmanPf5qL4HvmE4lRmorJzmRezxl1sshoopUN6mmNVIMcRoCkOI V2SJYzsAxDTT69wUQ7FPgkAyyhW/fnXTskNoJ3mYDQ0tZZt8L4B24cdHey3tu9kvcQhW TUz8IrU4W+T04jRsvUa90+zjKcCWCk6Xx9CuKqa29Pa/Bj/GhtIDPkNRwn+SLAc/j4Eg kiFGW971JsIhaOrYYGDrlOctZxrcom4e1WzSmldUqvkAOQ/1gUuG3ltCyYnBqTJ+KuIq nJrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689281420; x=1691873420; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SboTTTCH8PwJ1k7g+TtwxjrJ+lEO716FlHbTBOahELk=; b=J05ZH4JdS97pwtMKNzSQj2IwDolmRZp2fTcl8OATrtYXRHslaoueHP0oAVK2P98xlH 7uCz4lq+wXQg44oRiVG2czRc7G3io7+Uc6hC4Qqp5hv5s509HHgHrxU5tVflsm/e2UZ7 DiB1dPCDUeCraWQRQ8f0aH7BIPk2dE9BqB+vTMEpr4R/8lGzPSqbGlOlx5sw86aeDIj/ /0gkG+J5VY8B8mh7+EHvzhJeogaU6WLebAmo1nPtMRs295ddEYXaVhw1LjzdLD49ltvF sXiIuy01ttlfIRlnp8agN/rCwHTlJMY4sqsT+opWK2xXO68Jg7xTjAAVID/PR+VhLexy 1zug== X-Gm-Message-State: ABy/qLajmbgs/cxtQ4uYb4LveOP8D/GxQB0DvTeSJIuUq1dxQBYSwb4v wani98Kt6OUeBX2o2g1aTgo4Zko6irSPWgWf4PquJmzykPw= X-Received: by 2002:aa7:da4b:0:b0:51e:1692:1111 with SMTP id w11-20020aa7da4b000000b0051e16921111mr3271001eds.3.1689281419941; Thu, 13 Jul 2023 13:50:19 -0700 (PDT) MIME-Version: 1.0 References: <20230713202046.150986-1-afd@ti.com> In-Reply-To: <20230713202046.150986-1-afd@ti.com> From: Andy Shevchenko Date: Thu, 13 Jul 2023 23:49:43 +0300 Message-ID: Subject: Re: [PATCH v4] gpio: pisosr: Use devm_gpiochip_add_data() to simplify remove path To: Andrew Davis Cc: Peter Tyser , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Thu, Jul 13, 2023 at 11:20=E2=80=AFPM Andrew Davis wrote: > > Use devm version of gpiochip add function to handle removal for us. > > While here update copyright and module author. Reviewed-by: Andy Shevchenko > Signed-off-by: Andrew Davis > --- > > Changes from v3: > - Do not cast void * lock explicitly > - Rebase on v6.5-rc1 > > Changes from v2: > - Rebase on v6.4-rc2 > > Changes from v1: > - Use devm to cleanup mutex > > drivers/gpio/gpio-pisosr.c | 28 ++++++++++++---------------- > 1 file changed, 12 insertions(+), 16 deletions(-) > > diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c > index 67071bea08c26..e3013e778e151 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,11 @@ static const struct gpio_chip template_chip =3D { > .can_sleep =3D true, > }; > > +static void pisosr_mutex_destroy(void *lock) > +{ > + mutex_destroy(lock); > +} > + > static int pisosr_gpio_probe(struct spi_device *spi) > { > struct device *dev =3D &spi->dev; > @@ -126,8 +131,6 @@ static int pisosr_gpio_probe(struct spi_device *spi) > if (!gpio) > return -ENOMEM; > > - spi_set_drvdata(spi, gpio); > - > gpio->chip =3D template_chip; > gpio->chip.parent =3D dev; > of_property_read_u16(dev->of_node, "ngpios", &gpio->chip.ngpio); > @@ -145,8 +148,11 @@ static int pisosr_gpio_probe(struct spi_device *spi) > "Unable to allocate load GPIO\n"); > > mutex_init(&gpio->lock); > + ret =3D devm_add_action_or_reset(dev, pisosr_mutex_destroy, &gpio= ->lock); > + if (ret) > + return ret; > > - ret =3D gpiochip_add_data(&gpio->chip, gpio); > + ret =3D devm_gpiochip_add_data(dev, &gpio->chip, gpio); > if (ret < 0) { > dev_err(dev, "Unable to register gpiochip\n"); > return ret; > @@ -155,15 +161,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 =3D spi_get_drvdata(spi); > - > - gpiochip_remove(&gpio->chip); > - > - mutex_destroy(&gpio->lock); > -} > - > static const struct spi_device_id pisosr_gpio_id_table[] =3D { > { "pisosr-gpio", }, > { /* sentinel */ } > @@ -182,11 +179,10 @@ static struct spi_driver pisosr_gpio_driver =3D { > .of_match_table =3D pisosr_gpio_of_match_table, > }, > .probe =3D pisosr_gpio_probe, > - .remove =3D pisosr_gpio_remove, > .id_table =3D 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"); > -- > 2.39.2 > --=20 With Best Regards, Andy Shevchenko