Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp100685rwb; Sat, 17 Sep 2022 01:30:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GFWbsZ/zuxyUk+V5Ha+3WdOUoRf+O9KarhHV7Qa8ACS2yvBVgsk4rHuCu99MLdawmIFLx X-Received: by 2002:a05:6402:e98:b0:44d:c2e0:d8b0 with SMTP id h24-20020a0564020e9800b0044dc2e0d8b0mr6914629eda.165.1663403457571; Sat, 17 Sep 2022 01:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663403457; cv=none; d=google.com; s=arc-20160816; b=LKOh0wotMCcV858cxgn2QzJqoPfAwLKnuW8+WRu4i93kD0rcdtj/9oQaONkP07F+fJ Ls2DI17znoorXqv+kXxu1Ez0M7wM6mmRYrp9/QlRRMlzUwXD6Mej1d/TFOL4tjfawATq WQi7I06oFxlc70veKMh1w1LE0tto66BN6FZA6AeS4nPCV31al9bFEFZ0puhFpjCDh0fg vdkfNM7NQQCsmBRKz5TcnrmWQI1HaCE8TgSNlHfnswDjV3TtrdmF9LCdN3mBu5Ln1Rhx fNmO7c9YmkBKjYpXeJZjKwuJNy773LvGZyKyLPde5hoJ8/8qut0S3B+ZepH3cksV+yqf 1aOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qbcnscgbXlnx/VthFKwUQQtGIklihJr0+Aj2GEclzE4=; b=fQdolJuSlfc3ASA/LB+rjAfU7/w4moJWId2zHTWgPoVlbGiNZ2NEGHPVhwukzHyUnj dvPssmPPA3jakqL42vJtSzgGSRjDQpzfL8NdPDriXpjk2HPkp/U0dfhMp602eBZl7PJB lU3BsU2fwlHT3sFmE6sTa+LmHKJsI5EjCu6doJLn5ASym+DUCpTZBNtMDMOCDr4ndu33 W4V2bzLSWcT/JW4k5FtmAFBgXjUs9wE6hwFPcaFjA+jo7MQppYbJ2YZe2M94Krww737W J1MK8SOqvhSCqESsoh26vFJNjxBfccEgxnRl+SAQ14PlAFUjlSZD5M/+I77f2mNtBxN0 NmuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N99iXbB0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020a1709061ba100b0076fbaba1addsi6291172ejg.896.2022.09.17.01.30.31; Sat, 17 Sep 2022 01:30:57 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N99iXbB0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbiIQIYL (ORCPT + 99 others); Sat, 17 Sep 2022 04:24:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiIQIYI (ORCPT ); Sat, 17 Sep 2022 04:24:08 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFEE94DF08; Sat, 17 Sep 2022 01:24:06 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id s13so18320722qvq.10; Sat, 17 Sep 2022 01:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=qbcnscgbXlnx/VthFKwUQQtGIklihJr0+Aj2GEclzE4=; b=N99iXbB0KSwbZ5ywZGr73/OGP3+8+3/7ZYXD8jFOVMZ+xEkWO9++jg25CP80nYNCPS KITuUA3c6MnYtcICZpAATL7rnPYOkLgkn/wSz0rlWmJ2ANtPnI5QADPNyKHVEaS66Zdt IxFYmKdxR3KLXOZv5zJw93maWYOqLgqpzhwvUvlSmzj+A6avIf5Fw9E6mUkA8NtNCKcN B+SH2J2UznuhKibThEb/UoLpQhIkw7//XkalPFF0nw5daKT5WmRgINuIzeEu2YaBguVv CaogL/xuHvoVjU8HkEv6pN96+htciLYBkBzQw/7ZNiYX0NJLuQkyxSR4rtCOrZgfAME4 8axw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=qbcnscgbXlnx/VthFKwUQQtGIklihJr0+Aj2GEclzE4=; b=iXmbKTgn1wmADVYdjiU0ALZ4jpCxqODEW6rsr/0E5Hope9+TLgSocPNsX1brRL5CAf nl2QwJ27zZtfTA6uxpR6OkmqZRufLibc22DdkOYuROIsM4y5JRr3foWaTEnENnZJbLBV 2aqIR9GeGB0+PYXaMNLAVzVLYXUMB91fRIsrCYx/Os0Vi3UjMrSLZOOQv1O5gdcwnC1K Fim3KxGO+2pL88jmP3/GccV6GdGmy+kdgdtQV7cjVyvYsRO3t+rsD6iTVStUNwGVJ1Un KvX6qKnKXkiNnG0SvMPDQc8UTUSFiSZGz4995zazaIh0uUA1Ci/x/ELPUgsL/UHxmhsg sOEg== X-Gm-Message-State: ACrzQf0S5cpgD7TwADo0uGW2MF8bFth7bh9nwvghIL84Q7iwl8paoWKR xWmj/gCOuq4p52ws+ZwL5Np8oTKpcdOZ5zMLsGA= X-Received: by 2002:a05:6214:19cf:b0:4a9:4241:2399 with SMTP id j15-20020a05621419cf00b004a942412399mr6976820qvc.64.1663403045831; Sat, 17 Sep 2022 01:24:05 -0700 (PDT) MIME-Version: 1.0 References: <20220917081339.3354075-1-jjhiblot@traphandler.com> <20220917081339.3354075-2-jjhiblot@traphandler.com> In-Reply-To: <20220917081339.3354075-2-jjhiblot@traphandler.com> From: Andy Shevchenko Date: Sat, 17 Sep 2022 11:23:29 +0300 Message-ID: Subject: Re: [RESEND PATCH v3 1/4] leds: class: simplify the implementation of devm_of_led_get() To: Jean-Jacques Hiblot Cc: pavel@ucw.cz, robh+dt@kernel.org, sven.schwermer@disruptive-technologies.com, krzysztof.kozlowski+dt@linaro.org, johan+linaro@kernel.org, marijn.suijten@somainline.org, bjorn.andersson@linaro.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, sha@pengutronix.de Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Sat, Sep 17, 2022 at 11:14 AM Jean-Jacques Hiblot wrote: > > Use the devm_add_action_or_reset() helper. Reviewed-by: Andy Shevchenko > Signed-off-by: Jean-Jacques Hiblot > --- > drivers/leds/led-class.c | 20 ++++++-------------- > 1 file changed, 6 insertions(+), 14 deletions(-) > > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c > index 6a8ea94834fa..2c0d979d0c8a 100644 > --- a/drivers/leds/led-class.c > +++ b/drivers/leds/led-class.c > @@ -258,11 +258,9 @@ void led_put(struct led_classdev *led_cdev) > } > EXPORT_SYMBOL_GPL(led_put); > > -static void devm_led_release(struct device *dev, void *res) > +static void devm_led_release(void *cdev) > { > - struct led_classdev **p = res; > - > - led_put(*p); > + led_put(cdev); > } > > /** > @@ -280,7 +278,7 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev, > int index) > { > struct led_classdev *led; > - struct led_classdev **dr; > + int ret; > > if (!dev) > return ERR_PTR(-EINVAL); > @@ -289,15 +287,9 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev, > if (IS_ERR(led)) > return led; > > - dr = devres_alloc(devm_led_release, sizeof(struct led_classdev *), > - GFP_KERNEL); > - if (!dr) { > - led_put(led); > - return ERR_PTR(-ENOMEM); > - } > - > - *dr = led; > - devres_add(dev, dr); > + ret = devm_add_action_or_reset(dev, devm_led_release, led); > + if (ret) > + return ERR_PTR(ret); > > return led; > } > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko