From patchwork Wed May 26 06:10:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 12280673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B64F2C2B9F7 for ; Wed, 26 May 2021 06:12:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D718613D3 for ; Wed, 26 May 2021 06:12:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D718613D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Gjn2pDCi5/s0f2d0TgEzCZvXu40op/yL8QdSlLNA4Fc=; b=E08L9E0uWy+NbmzMbf64XadItJ ZcTWTsPxlbAzeKnPZ7ZJya0gj7vD+jPooqBW402W0QG/CE5OzILHx80lWRI7HJIccS/9Cx7GxhjAc bMNEJZ+OVNERNVhsAl2jPbdEGgZeLV3w95YYwyBeVNA25csSAOiWBHEX0AdldYe9ecAXE0eFhR9SW qQ7PrnHRP3+LXqyS8q2QQx2Tqe3T4nbuSma6A+i0euERzO3vgQIYsVmk5EhCLHU/pW+aq+v0xzx8N 9wNZzqSQiYuWbcm0OzRGF/4cc0JnTHSy1eUuIFOX/Iq4TLkM4GbLhNMLMkGoFCTMssZN6fuSYIZaQ TCWZJJmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llmkX-00BTN3-Gi; Wed, 26 May 2021 06:10:37 +0000 Received: from mail-lj1-f175.google.com ([209.85.208.175]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llmkT-00BTKm-9S for linux-arm-kernel@lists.infradead.org; Wed, 26 May 2021 06:10:34 +0000 Received: by mail-lj1-f175.google.com with SMTP id e2so133668ljk.4 for ; Tue, 25 May 2021 23:10:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/52t2gRhW9uzV6QfWt9pJg3Wnm3JFbOqeAJZ2k4RlFU=; b=O45zIuag0d/YRZ/ZzJuFcAvKct/Q9BqB8Gv0/e4ZvUKkef7z7rON0FABOGW2Mtl6bq Fr0VdhJsCvSbuTbMQIYH0XqctqmwYyYZeu6SKG53JMgaNgBIupAZEReKNRHJfaEb/5QX hc8v62miP5WHs/oaBzAbTUzTnMG5fEJiU7z+jnISf5nvXYDU+E5S79sya4AeBL2gSjab GRA5j9oDmnt7d8+9NCeJIDvC9lXrxIZosisjXM31Ae74MssHXvP6JQHbdw2r3oQJKcKM WjqLPAO+L/riXNg0uUqz2++FJQDMQUE13bR30cP1UZVNmdvFJtRSTpHcuS4XvnOPM/zt KjGA== X-Gm-Message-State: AOAM532iT9pIXEzXNcudG0QeZnNJOUmkzyqvpK0SIJif1whs41X86hVX rMPBziuCHJnf0q2XJuj+Ahk= X-Google-Smtp-Source: ABdhPJx209K6PEaaWkfSPVYea7B2lR8PTN7rHrCkUSSG2K5hpD/OAINI9/52pFf6kiYcAtMhXpItvw== X-Received: by 2002:a2e:8e26:: with SMTP id r6mr1012954ljk.472.1622009431450; Tue, 25 May 2021 23:10:31 -0700 (PDT) Received: from localhost.localdomain (dc7vkhyyyyyyyyyyyyycy-3.rev.dnainternet.fi. [2001:14ba:16e2:8300::4]) by smtp.gmail.com with ESMTPSA id o20sm1929505lfu.283.2021.05.25.23.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 23:10:30 -0700 (PDT) Date: Wed, 26 May 2021 09:10:24 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Linus Walleij , Bartosz Golaszewski , Matti Vaittinen , Michael Walle , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, Jonas Gorski , =?iso-8859-1?q?=C1lvaro_Fern=E1ndez?= Rojas , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-power@fi.rohmeurope.com, linux-arm-kernel@lists.infradead.org, Andy Shevchenko Subject: [PATCH v4 2/3] gpio: gpio-regmap: Use devm_add_action_or_reset() Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_231033_375911_8D3AAF0F X-CRM114-Status: GOOD ( 16.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Slightly simplify the devm_gpio_regmap_register() by using the devm_add_action_or_reset(). Signed-off-by: Matti Vaittinen Reviewed-by: Michael Walle --- Changelog v3: - gpio-regmap: Use the devm_add_action_or_reset() instead of the devm_add_action() --- drivers/gpio/gpio-regmap.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index 4f0903d1acd5..ce5bc9e0d684 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -341,9 +341,9 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio) } EXPORT_SYMBOL_GPL(gpio_regmap_unregister); -static void devm_gpio_regmap_unregister(struct device *dev, void *res) +static void devm_gpio_regmap_unregister(void *res) { - gpio_regmap_unregister(*(struct gpio_regmap **)res); + gpio_regmap_unregister(res); } /** @@ -361,20 +361,17 @@ struct gpio_regmap *devm_gpio_regmap_register(struct device *dev, const struct gpio_regmap_config *config, const struct gpio_regmap_ops *ops) { - struct gpio_regmap **ptr, *gpio; - - ptr = devres_alloc(devm_gpio_regmap_unregister, sizeof(*ptr), - GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); + struct gpio_regmap *gpio; + int ret; gpio = gpio_regmap_register(config, ops); - if (!IS_ERR(gpio)) { - *ptr = gpio; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } + + if (IS_ERR(gpio)) + return gpio; + + ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio); + if (ret) + return ERR_PTR(ret); return gpio; }