Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3340695pxb; Mon, 16 Nov 2020 11:53:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzM9UQoVDbPpt58uC57VwumBps+4+8I+IuQJPHdAWOT6SWyfIFusYXbOEONntySZh8KeUlO X-Received: by 2002:a17:906:6d4:: with SMTP id v20mr17535029ejb.500.1605556392285; Mon, 16 Nov 2020 11:53:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605556392; cv=none; d=google.com; s=arc-20160816; b=KPkFFkwzg9uQ94Jc+uUghZmyh5ay2HpXwQKXCVB41v6ulmMjLqnvmoC0LzGKj4YKYG ZFZZv2ayYiRw3ztpzbaJgNIiAUBWK2bUo4QzWN4D7AoEPtH2aMXdzYflgHq5GbMzmq6N 0TTmgN0v836Cr0Kcqc0/Cfc0HAc+LAbCWcSggW0BCbcsSW27v0czjj8kW3RlEcJxW4fh P+RSv3o0Zs36jl4xpU3iQLV5GSzy2gRTmdwlqJy2zjZrLvy6q0ofuTpDIZ8ybnTn+9D+ 4Rqf3MPRrecHzRxJkX4H6nJxD2584TjwIKBS0EIjyrW8e2yDCh4ktFHeAkuF5YcZYG3U bf8A== 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=v6hO2EdktD6tTwbP0hf9n6mHqN7h4IqXAlEVl1IexRM=; b=Y4Wm9vgEx848HYMg0DdRWdSI8+OHEoEP1LJ8rJS+to5dh3ROdX0q6S8i794NkXu4dA sVk2FPpbqJFMQLmFEfB2fNWvBbGQSNpqfmYW3Ai1GRijwKyDxj+AaBz0ZscfaOij/WJj RwxE+I2IIvKmamBnNzXJNREabr6r4gvyJC8kk++h1QHR7Q5sTUzCjjPsbZ3c6I14MF/s xFF/oFW040kjc13yWrvXRrHHV5ICrWENVBsi2AUj85mtcMsO2I+2Y/fQIRnid2zIfyT9 6b11z4IgIM6f4lWdylJC2UW1dAYZP2VN0M1geFsWJePRVvyupS4eUKjekht5FYZLh+0A 7UjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=T+tUvkIF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si14175031eds.206.2020.11.16.11.52.48; Mon, 16 Nov 2020 11:53:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=T+tUvkIF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729233AbgKPKmz (ORCPT + 99 others); Mon, 16 Nov 2020 05:42:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729211AbgKPKmz (ORCPT ); Mon, 16 Nov 2020 05:42:55 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3163C0617A7 for ; Mon, 16 Nov 2020 02:42:54 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id w24so23156702wmi.0 for ; Mon, 16 Nov 2020 02:42:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v6hO2EdktD6tTwbP0hf9n6mHqN7h4IqXAlEVl1IexRM=; b=T+tUvkIF+iH4K8+P7U64YpgECCTYj+oVV2Ij3yc1MDvVMu+ziOO6jKj29VjW7Zf4UR BGkzB9TV+T8Xcu7p8oR2x2ePl/BzA8jQs6t/cqXalSzA54H0t8+smAzDpF3XqeLGkhkV 26uANPiz6+nqI0KfbuHTnqnGZRrsIJk7gSfik7PFY/WskKul9Ncz4pgNSohp69ulfP3P 4mccSQTOVDm9DnRGvo2m+83H8OGR165kgHaVg/HCu38Nyk1qHbL4GnEGPsL3pTqWJFWE ILMUnR6idga7JubvwejWzkqB87KiqagNkMJsHnjbkbu7n/kTUGOhZ0ZgIqwX5DNVV3ij 4CEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v6hO2EdktD6tTwbP0hf9n6mHqN7h4IqXAlEVl1IexRM=; b=lw2FM8o+c7eT+yedssZeDZdtxtsD8hvMYBj1mSslDnvLXhdv2VDB0uilD7/lKyvPVc RwaytW1XaDMbg2v/naqEvmuL2xTJxnb8Uo2EyD13GWCtkVZEpB7C/iHA/XlPJqYAVMHe vNupPAHf7d6ky7e6HjWqjbdPZ1h4HLdwDlPqonM1IIMuefkFJH9gyRBtKDbLuwt4SRRb O8QhS2HHy1nN0Noy2ZrL/lDqa0prmO9oLage8wzPL3sH4dnO5qhOmoaLFKPAqmWkGX8A j7T63Ih29X+no5hfAUkt5H2xrKfo7c7kGZlov+P++mYx66OkrPyeCZrYmYOOAkd1Y3f4 yjtA== X-Gm-Message-State: AOAM533YcWGZV2Tbw0VdMmAR1X6J0b+maNVmNYGNx7+nx4ahNNUE/MFY wyGBFyTtmCZdqF4xo/fx0QK7hovoXvQ+WA== X-Received: by 2002:a1c:21c1:: with SMTP id h184mr15545483wmh.106.1605523373631; Mon, 16 Nov 2020 02:42:53 -0800 (PST) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id v16sm20583283wml.33.2020.11.16.02.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2020 02:42:53 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 7/7] gpio: exar: use devm action for freeing the IDA and drop remove() Date: Mon, 16 Nov 2020 11:42:42 +0100 Message-Id: <20201116104242.19907-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201116104242.19907-1-brgl@bgdev.pl> References: <20201116104242.19907-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski We can simplify the error path in probe() and drop remove() entirely if we provide a devm action for freeing the device ID. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-exar.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 79fb0964ace3..e4c1ac88d2ba 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -111,6 +111,13 @@ static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) return 0; } +static void exar_devm_ida_free(void *data) +{ + struct exar_gpio_chip *exar_gpio = data; + + ida_free(&ida_index, exar_gpio->index); +} + static const struct regmap_config exar_regmap_config = { .name = "exar-gpio", /* @@ -163,6 +170,10 @@ static int gpio_exar_probe(struct platform_device *pdev) if (index < 0) return index; + ret = devm_add_action_or_reset(dev, exar_devm_ida_free, exar_gpio); + if (ret) + return ret; + sprintf(exar_gpio->name, "exar_gpio%d", index); exar_gpio->gpio_chip.label = exar_gpio->name; exar_gpio->gpio_chip.parent = dev; @@ -178,29 +189,15 @@ static int gpio_exar_probe(struct platform_device *pdev) ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio); if (ret) - goto err_destroy; + return ret; platform_set_drvdata(pdev, exar_gpio); - return 0; - -err_destroy: - ida_free(&ida_index, index); - return ret; -} - -static int gpio_exar_remove(struct platform_device *pdev) -{ - struct exar_gpio_chip *exar_gpio = platform_get_drvdata(pdev); - - ida_free(&ida_index, exar_gpio->index); - return 0; } static struct platform_driver gpio_exar_driver = { .probe = gpio_exar_probe, - .remove = gpio_exar_remove, .driver = { .name = DRIVER_NAME, }, -- 2.29.1