From patchwork Thu Jun 3 10:00:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 453602 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=-13.8 required=3.0 tests=BAYES_00, 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 4C322C47082 for ; Thu, 3 Jun 2021 10:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31949613F3 for ; Thu, 3 Jun 2021 10:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbhFCKCM (ORCPT ); Thu, 3 Jun 2021 06:02:12 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:33577 "EHLO mail-lf1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbhFCKCM (ORCPT ); Thu, 3 Jun 2021 06:02:12 -0400 Received: by mail-lf1-f46.google.com with SMTP id t7so803403lff.0; Thu, 03 Jun 2021 03:00:27 -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:mime-version :content-disposition; bh=TRbcTChcfkbQw4wqZMWbz/6Kdy4VvqYAnpfbOiOSptQ=; b=dN5ldU6qj80YD0vsJSXWzlngvlYZf7fGOx7/esxidU2YnsypVsiGR+WpmKYsoFq/5a PFPZq+8vHFnFyH+QLdgB710d16WHuM9G7jhul/srUB1CMAsVzfDct9vVSLS26XuXmj2f M6fRyZpKxnB+voIwsI0TEqCh/V5eqDBDh975szs/gi12rocTCzCZb+BBgK/yGT9goFJI SQi7GZcKuH6o91NTrpaK0i+dc8Tkl+kcKSPkxCGGsQmMjWwEDgFL9AQnTBx3VQUXSRRn UZ69zosRmIkeV3zjQ07jTQU2nw/Sv4dI6ihwXSe4RrIC51Kzh7SzKIf0lnkp1ycy8l9y PYhQ== X-Gm-Message-State: AOAM532daTPrrCKl7KvbaXMhTFDlBbzVoIF5dIKy5RmdotP/Dfw5/DF4 KpyF5c8h84xmdVDEcmsbF6o= X-Google-Smtp-Source: ABdhPJzFtsTeq1E+bv/fTUEFuA99L+zXukpk5I4VUVz1CO258k5OntRzitZPinm2ciozxRShW5GXiA== X-Received: by 2002:a19:4803:: with SMTP id v3mr11616510lfa.115.1622714426972; Thu, 03 Jun 2021 03:00:26 -0700 (PDT) Received: from localhost.localdomain (dc7vkhyyyyyyyyyyyyycy-3.rev.dnainternet.fi. [2001:14ba:16e2:8300::4]) by smtp.gmail.com with ESMTPSA id c33sm305826ljr.85.2021.06.03.03.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 03:00:26 -0700 (PDT) Date: Thu, 3 Jun 2021 13:00:21 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Michael Walle , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: gpio-regmap: Use devm_add_action_or_reset() Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Slightly simplify the devm_gpio_regmap_register() by using the devm_add_action_or_reset(). Reviewed-by: Andy Shevchenko Reviewed-by: Michael Walle Signed-off-by: Matti Vaittinen --- This patch was originally part of the series here: https://lore.kernel.org/lkml/cover.1622008846.git.matti.vaittinen@fi.rohmeurope.com/ Other patches from the series were dropped. 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 134cedf151a7..1ead1290eb3f 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -311,9 +311,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); } /** @@ -330,20 +330,17 @@ static void devm_gpio_regmap_unregister(struct device *dev, void *res) struct gpio_regmap *devm_gpio_regmap_register(struct device *dev, const struct gpio_regmap_config *config) { - 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); - 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; }