Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5730954pxb; Mon, 14 Feb 2022 06:23:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQ4nba04Dsc5IM2yRbYpmS9zIRj8A6rH4UIxU1+2lG7EpGK0rQ5zg6xT94Z4f7GafCxjoy X-Received: by 2002:a17:902:f712:: with SMTP id h18mr26519plo.24.1644848606031; Mon, 14 Feb 2022 06:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644848606; cv=none; d=google.com; s=arc-20160816; b=xzXrbzbkrpm2GPA5KS3se0599B1k8kUVxEl9q03bCknbGnr+3EmV+jCZdkTZmXNBX5 v6xA153+R2Cay0C6AA6+H8JsJVrcJcd5Gc1aAfTTf11JZ8wgV8MwgL2XVcQ9i6y98jnW hTekvwa2LILqzG0ffWrxklsaLhenTtRTwghkhhDvmDgrZ6T5A82wTvuSEPTEX6B1hXMu fuxMmf6P2Hx/WgJNCccACXqtqM79xScU/k2bVpoeHhEK2Nf4YID5mh3I9lMJAgSmotgR qege98+3n6gYH56LdjsG3JFRrVL9hfFyjSEifGCCEGp2RTZVBMv13ZmWv7mFnHDSD0K2 9mgw== 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 :message-id:date:subject:cc:to:from; bh=kjSAlw9KUAQnXnWp8jryjx3rnJqPzlPHtGhaoWuEIjQ=; b=bYKW9s8J9V+V7RNQaNXboGWYOOBLWKeoHyuSvz//BtXKkLrQwRFY/NRyec5nP95aF2 bb7/5SdHRmyGcXzYMRXMMh+zrlyt+Odmuz+KCnWJ4qAYviriZ3mFve9nIxdW73Hbhlrf FPoRBUw6oR0Bea91lhTnV6vYtrHxIF6Ty3ES4kSFwZZtb/DHrHobGJkSQPc6JHhUBJ6t 30AuwocQCq0AGezreXRDQLwx3fPmBRbTSgmf8O3AWT2+LADSA2F/cGcB5HSKpFKJOPm5 9pJEYgIdnoIIQesTzEBN3+6KFo7aABqbm8X9tAsgALftjo197h2Xs5BzeW3LV1HNM0Gj +uvg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k189si2262419pgd.234.2022.02.14.06.23.09; Mon, 14 Feb 2022 06:23:26 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbiBMHlw (ORCPT + 99 others); Sun, 13 Feb 2022 02:41:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234062AbiBMHlv (ORCPT ); Sun, 13 Feb 2022 02:41:51 -0500 Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6613033B for ; Sat, 12 Feb 2022 23:41:44 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id J9VsnUjWKSDrIJ9VtnIP2o; Sun, 13 Feb 2022 08:41:42 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 13 Feb 2022 08:41:42 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: Lee Jones , Daniel Thompson , Jingoo Han , Helge Deller Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Subject: [PATCH] backlight: backlight: Slighly simplify devm_of_find_backlight() Date: Sun, 13 Feb 2022 08:41:39 +0100 Message-Id: X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 Use devm_add_action_or_reset() instead of devm_add_action()+hand writing what is done in the release function, should an error occur. This is more straightforward and saves a few lines of code. While at it, remove a useless test in devm_backlight_release(). 'data' is known to be not NULL when this function is called. Signed-off-by: Christophe JAILLET --- drivers/video/backlight/backlight.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 4ae6fae94ac2..b788ff3d0f45 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -710,8 +710,7 @@ static void devm_backlight_release(void *data) { struct backlight_device *bd = data; - if (bd) - put_device(&bd->dev); + put_device(&bd->dev); } /** @@ -737,11 +736,10 @@ struct backlight_device *devm_of_find_backlight(struct device *dev) bd = of_find_backlight(dev); if (IS_ERR_OR_NULL(bd)) return bd; - ret = devm_add_action(dev, devm_backlight_release, bd); - if (ret) { - put_device(&bd->dev); + ret = devm_add_action_or_reset(dev, devm_backlight_release, bd); + if (ret) return ERR_PTR(ret); - } + return bd; } EXPORT_SYMBOL(devm_of_find_backlight); -- 2.32.0