Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp709371rdg; Thu, 12 Oct 2023 20:35:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElsQIjBFlEwlWvuIO1yqPlEP0TpxWEJjCcp7cGWHXpcmD3sw9R8FqKfJ+0liUtz+9/exZf X-Received: by 2002:a17:90a:408a:b0:26d:43f9:11dd with SMTP id l10-20020a17090a408a00b0026d43f911ddmr22218646pjg.0.1697168157860; Thu, 12 Oct 2023 20:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697168157; cv=none; d=google.com; s=arc-20160816; b=O4yS0JYBX2w8Ve7WQdRfh8znMgdkvWjkO2MTQNWskeJmO6nTAqjfDd+Hw7MqNiF0dt EsGgtZTRxrYC1CTKBcC/UMXks3yJ4ShcPTTHsPYNzj9sLcAL43oxbxwKbZLBShEQiFro H0TA767Py+ia/4eEZOMi867PrTXJSLHj+jt+H9FIcwKqj9q6R8kehMsX8reT7ihPdpR7 LMXXBhuFgkxakpiJ7ctveNxzL8S1US6ElP6nOfX0D2aB5vd5MZlWmy8iw/wBhbb3LZvR 2hRlyp1cJYmxm6JqXVEL9/HwPtX5ZyGSoXn0UPm4n15KP6QKl18rUvOf0gWbLiZ1WdL5 aQjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=FlTORu5GIF0dZmTs/rg+a2w8P3LSnmhkgdpdlzsllUQ=; fh=16lcV1Xs+7gq3HTelB50A7cWthZ2A1B50w+EjLJzyFk=; b=Y7jZKbMdKKuRcC6QKBHyqlg5GfLieC3jb6GV+Xqpp4PGlZw8+YQqjZ6JtYSOk4zvw+ u0KuwIPVXhrtx9bPr5b/YlAud7e70oc8J7drz9i42DOfuDp8GIjvGuwebpfm4BKtSqHc 4n34ddazvSTv5PQwjiZlskLDWIIjMlYs9z37kW0ge39qcMrn28fNG1l+YeIwgB6qRHJu RiPfivzfmVfk+t/D4B7Z3XxRoMigmUTIrSVJKm7x4/bmhkRd20OUvTtV7MK5kQSNb1Pz k2uNCKqkkfYni1+Ru32Ve9/BsygW9CI0xlW/ATKUQzH8jusig0herjhX0eMHNkajqHtg N9tA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id q92-20020a17090a17e500b0026b31ed4895si3535396pja.29.2023.10.12.20.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 20:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 322A4808726D; Thu, 12 Oct 2023 20:35:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbjJMDfp (ORCPT + 99 others); Thu, 12 Oct 2023 23:35:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjJMDfn (ORCPT ); Thu, 12 Oct 2023 23:35:43 -0400 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D473B7; Thu, 12 Oct 2023 20:35:41 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Vu0mA1C_1697168137; Received: from 30.97.48.67(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vu0mA1C_1697168137) by smtp.aliyun-inc.com; Fri, 13 Oct 2023 11:35:38 +0800 Message-ID: Date: Fri, 13 Oct 2023 11:35:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH V3] leds: sc27xx: Move mutex_init() down To: Chunyan Zhang , Pavel Machek , Lee Jones Cc: linux-leds@vger.kernel.org, Orson Zhai , Chunyan Zhang , LKML References: <20231013022010.854367-1-chunyan.zhang@unisoc.com> From: Baolin Wang In-Reply-To: <20231013022010.854367-1-chunyan.zhang@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 20:35:55 -0700 (PDT) On 10/13/2023 10:20 AM, Chunyan Zhang wrote: > Move the mutex_init() to avoid redundant mutex_destroy() calls after > that for each time the probe fails. > > Signed-off-by: Chunyan Zhang LGTM. Thanks. Reviewed-by: Baolin Wang > --- > Rebased onto linux-next. > > V3: Move the mutex_init() before sc27xx_led_register(), in case it maybe > used right after led registerd. > > V2: Move the mutex_init() to the end of .probe() instead of adding mutex_destroy(). > --- > drivers/leds/leds-sc27xx-bltc.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c > index af1f00a2f328..f04db793e8d6 100644 > --- a/drivers/leds/leds-sc27xx-bltc.c > +++ b/drivers/leds/leds-sc27xx-bltc.c > @@ -296,7 +296,6 @@ static int sc27xx_led_probe(struct platform_device *pdev) > return -ENOMEM; > > platform_set_drvdata(pdev, priv); > - mutex_init(&priv->lock); > priv->base = base; > priv->regmap = dev_get_regmap(dev->parent, NULL); > if (!priv->regmap) { > @@ -309,13 +308,11 @@ static int sc27xx_led_probe(struct platform_device *pdev) > err = of_property_read_u32(child, "reg", ®); > if (err) { > of_node_put(child); > - mutex_destroy(&priv->lock); > return err; > } > > if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) { > of_node_put(child); > - mutex_destroy(&priv->lock); > return -EINVAL; > } > > @@ -323,6 +320,8 @@ static int sc27xx_led_probe(struct platform_device *pdev) > priv->leds[reg].active = true; > } > > + mutex_init(&priv->lock); > + > err = sc27xx_led_register(dev, priv); > if (err) > mutex_destroy(&priv->lock);