Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp754194pxk; Thu, 17 Sep 2020 15:37:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkY68S4BlzWJ5Wi89QxxwnIcm+/0xQb+Ginq8vBpfB43YIVMPdt0K5v9e1RyQvxbwmseAv X-Received: by 2002:a17:906:8508:: with SMTP id i8mr34510411ejx.390.1600382246357; Thu, 17 Sep 2020 15:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600382246; cv=none; d=google.com; s=arc-20160816; b=SitpFFcjEUIC/FJdHy0huR2sqTL2xmuZVUo2p+olfrLJsVrVKm/ALsIO/IpHLubD3C nTklQEXqHco4n/7k3VhSxG0oHtRifp7ZF/pBqR9EufyOlcHX3dYbp+caTdbs7v6U/yIg xw/Fbrd7JDkdQoUh8n1AlasuVclFC2rdHY0dD7tBqRAIf7N+wRcZR0HqC1/aFp13ePk/ 5azRwvxRHVSx/fCr2PQeZ/L/VX5OjCKlcXSALkcob4Fw5d/JyCtv+QyojzcgavoMVI9s C1VR8x5yyyo0apDxRyD2Zv7gN2RVaARRVkNvAbAuSRtO9R9oJXdHTDHVhGs232Yv/H7e 7FXw== 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=VR6MqkO/Ks4umen8azHDtppZyjQKrI1mL1fo9wfVeVE=; b=0fO6menii8Tn3CXPMtmvzb5CNFmlS2N4YgXOip0ihA3+3c421uhTevg8icaafFWjj9 0FKnZ/iLg9ezcT4rsGmCyRFwPrnMZWIyrbOmVIIK1UZWyeZ5ZPRuu08DOM76o9zq7F+f kEPaFexIDbO0g53teBYH9tAFZii/eESTk3HtsUs5APnjq49yTsKVVLhMD8WGjzG6RkWw 4mNHuSSCdqaRjXP82LbhWSJ32VsLboTDCWB5NBivmYW2YBpbIzwG3hyamm3ImFDFvOtb MOwXcSAu2SlTgsPLz1+u/yhTZ1r15piUnwo7wtvxdF971naNh8e2c0B9PjiUkuHibjAk Hryw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=WyufPwDE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt6si906748ejb.290.2020.09.17.15.37.03; Thu, 17 Sep 2020 15:37:26 -0700 (PDT) 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=@nic.cz header.s=default header.b=WyufPwDE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726065AbgIQWfX (ORCPT + 99 others); Thu, 17 Sep 2020 18:35:23 -0400 Received: from mail.nic.cz ([217.31.204.67]:36162 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726273AbgIQWeN (ORCPT ); Thu, 17 Sep 2020 18:34:13 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id BEBBA142057; Fri, 18 Sep 2020 00:33:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382039; bh=r26L0sWbFofPCK5+uBb+ErS6T+5q3senbfA1NrJl0WA=; h=From:To:Date; b=WyufPwDEgDkCFWxv20zn7pofIKA0QKGszWLW5eamCBLQKlpm+lSvW8E1dqkiSRLRw E/LV7r+cW8SakWeX55LBvqMKynu93PJQTvOEvE4ECZfD2GhWnGFsYkjQJ9TMEkT9QP Av3Y6cTGg83/7m8QsbxyzQihngDokMnpZ56ZD/YE= From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?UTF-8?q?Ond=C5=99ej=20Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?UTF-8?q?Marek=20Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 36/50] leds: ns2: use devres LED registering function Date: Fri, 18 Sep 2020 00:33:24 +0200 Message-Id: <20200917223338.14164-37-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.nic.cz X-Spam-Status: No, score=0.00 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By using devres version of LED registering function we can remove the .remove method from this driver. The probe method also gets simpler. Signed-off-by: Marek BehĂșn Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 22d38c83b6dca..1a7ef66464b5d 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -227,16 +227,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, led_dat->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; - ret = led_classdev_register(&pdev->dev, &led_dat->cdev); - if (ret < 0) - return ret; - - return 0; -} - -static void delete_ns2_led(struct ns2_led_data *led_dat) -{ - led_classdev_unregister(&led_dat->cdev); + return devm_led_classdev_register(&pdev->dev, &led_dat->cdev); } #ifdef CONFIG_OF_GPIO @@ -380,11 +371,8 @@ static int ns2_led_probe(struct platform_device *pdev) for (i = 0; i < priv->num_leds; i++) { ret = create_ns2_led(pdev, &priv->leds_data[i], &pdata->leds[i]); - if (ret < 0) { - for (i = i - 1; i >= 0; i--) - delete_ns2_led(&priv->leds_data[i]); + if (ret < 0) return ret; - } } platform_set_drvdata(pdev, priv); @@ -392,22 +380,8 @@ static int ns2_led_probe(struct platform_device *pdev) return 0; } -static int ns2_led_remove(struct platform_device *pdev) -{ - int i; - struct ns2_led_priv *priv; - - priv = platform_get_drvdata(pdev); - - for (i = 0; i < priv->num_leds; i++) - delete_ns2_led(&priv->leds_data[i]); - - return 0; -} - static struct platform_driver ns2_led_driver = { .probe = ns2_led_probe, - .remove = ns2_led_remove, .driver = { .name = "leds-ns2", .of_match_table = of_match_ptr(of_ns2_leds_match), -- 2.26.2