Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp175990rdg; Thu, 12 Oct 2023 02:16:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfjYMSOwo6SOwTg13hyQLn0o3yPnAJyyeUJLHnl3+0RgWwz+5HDfhKKrBAfS7qYgBKSSAh X-Received: by 2002:a05:6a00:124f:b0:68a:3b39:a486 with SMTP id u15-20020a056a00124f00b0068a3b39a486mr26750194pfi.24.1697102200053; Thu, 12 Oct 2023 02:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697102200; cv=none; d=google.com; s=arc-20160816; b=ZD3Tfq1sKY/bbA408moDWug50uOBWtrh2XKexMI5m4qmgQAicGpsxBoPpAAC5narzM EeFK3lHJlkJILujFyiBqq7CLOgIJzfmJoOu76bp3Eovh0zKBOkhvB5kHLZ6a10wjF7Pn C+njVQUmd8CgeYsd/UbW/G0uWuCSG+pPfvhHbsrZmq8Ltc1ZYvJ9Rq8kEnZELbPzeJh5 ZfCkwDKZS2GwNpX7DbzHftwbx/tpfEHRjtPjQWXVR7kkS4SGGbXgmXFNJrPwQeKxfGqI U6O6SUPbMMyj8mznk0k+iy3rZBltUygjb/upv4PyApyZ+oOlZqzwkGqOz5xk7fiqR11H 6bpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KjzJ1549XPxT0YZoEyPs0RjbgAVvnlzry73Y+4qDrxw=; fh=nU3AJmfDJ87vflU45x6jIlv1QGnp3PCD+htQyKOdfb8=; b=dgVyCvQlp8GgMpBVc100eENPFob23KTkWeoi38XMroLAFgw6iv5qr+znkVxCTD8Q/2 6c8cdfd4ooL35fACJEPW7R76iUKAA6GE1D71wDfX4McBMiwI0u7oHBdAhZEexnnPdwEJ XJvJcK1iR7mKNXbbNshj+ffxNkDRJWV+e4FZyXIXcST3VhVk0iB7Ch3tEyABpCXl5inF lGSggb5JKvbKwVySJkTxWOBulx1fr8GwMSh2MOifZR9w2YrWawhh7KTsB6FxVSO2kijF 3FwAWs4mr8xE3Op1MQQ2JVB+RCbuXbO43ZVboJ3aN7yPJyjCM2eTGBRg8r5gxEJEYasW 1mhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rNjZKIc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f3-20020a056a00228300b00690fec2f3bbsi3775515pfe.85.2023.10.12.02.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 02:16:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rNjZKIc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 463DA8174A7B; Thu, 12 Oct 2023 02:16:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235516AbjJLJQ3 (ORCPT + 99 others); Thu, 12 Oct 2023 05:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235460AbjJLJQJ (ORCPT ); Thu, 12 Oct 2023 05:16:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A247C6; Thu, 12 Oct 2023 02:16:07 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83B6CC433C8; Thu, 12 Oct 2023 09:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697102167; bh=rDqxFRbS36X3wzsamcQt8JNV0Zh3cEeJ9KK8OwPwL34=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rNjZKIc5WgmZe4aHX0ioCqxU8rNxJtEyXsV/NZV4DN1RQmMfka5uyhlwEN23tcH++ DvtKsUTvf7WeFX3gNM1jbai6tEHBjnC5WSe2vcOXwRPCOr/b3FDfIqkksap9giSoRE s8ZzFR5TYZlPEuO1PVfS7muBmugpP9L/kNepxckOC+FZKkDaQYAX7KH91EBMeTI6/s cOt0rlsvEc2dWib0IjTUpxU5qDN83i+LfJoPcELEhqTUqqP8em/P6cOZzwjZysp72F Mt43kC/Rt6W2p/tbfJTbbQItBjW7uSYSQrZQVQgzrbmBZfgEjZfdQY7p/p90selCLE 8WvC5QG/YiH4w== Date: Thu, 12 Oct 2023 10:16:02 +0100 From: Lee Jones To: Baolin Wang Cc: Chunyan Zhang , Pavel Machek , linux-leds@vger.kernel.org, Orson Zhai , Chunyan Zhang , LKML Subject: Re: [RESEND PATCH V2] leds: sc27xx: Move mutex_init() to the end of probe Message-ID: <20231012091602.GD8314@google.com> References: <20231012034735.804157-1-chunyan.zhang@unisoc.com> <6110db84-546d-fc5c-f241-7923d673bbd5@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6110db84-546d-fc5c-f241-7923d673bbd5@linux.alibaba.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 12 Oct 2023 02:16:37 -0700 (PDT) On Thu, 12 Oct 2023, Baolin Wang wrote: > > > On 10/12/2023 11:47 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 > > --- > > Rebased onto linux-next. > > > > V2: > > - Move the mutex_init() to the end of .probe() instead of adding > > mutex_destroy() according to Lee's comments. > > --- > > drivers/leds/leds-sc27xx-bltc.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c > > index af1f00a2f328..ef57e57ecf07 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; > > } > > @@ -325,9 +322,11 @@ static int sc27xx_led_probe(struct platform_device *pdev) > > err = sc27xx_led_register(dev, priv); > > if (err) > > - mutex_destroy(&priv->lock); > > + return err; > > - return err; > > + mutex_init(&priv->lock); > > I think it is better to prepare all the required resources before > registering the led device, what I mean is moving mutex_init() before > calling sc27xx_led_register(). Is the mutex used before this point? If not, I don't see any reason to initialise it sooner. -- Lee Jones [李琼斯]