Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp132027rdg; Thu, 12 Oct 2023 00:29:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtIDfQ7KKJZ94FaNepkS2f7ZABF7rLvt08E3nw5b5R5JpDGtUOHlMGAV+ba/xpAR7RU7k1 X-Received: by 2002:a05:6808:3a85:b0:3af:b6ea:2e2 with SMTP id fb5-20020a0568083a8500b003afb6ea02e2mr19858656oib.59.1697095784784; Thu, 12 Oct 2023 00:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697095784; cv=none; d=google.com; s=arc-20160816; b=zHPq2SzLpS0A9jmj52jC/zaNRigCjANfLlGI0KPl63MPxYjsoUW89bz/cOA6E4hOM0 mDEGzoaxL1aYrMU0xn5tq0/MTIAcB/bosvcp1C7IfysLgagsdUGB1vg8/Rzkm3yxrnuq qRZc7AlcQIGdqpKeq7ZQZDhMHUDYBQsugWPzclQ/R/ZmmM/l4898N7tl5Qoheqsnwf1a K6kr6MdAfanOPDNU1s+M8IXNd6MIxQiuj8ECdmxP5pFCgcTBDtakN2EN7fOh31S7Z54s Lg50539bPHRom/c9zAc0VhhvtThc5hdQtJQ1IKJbTZqBkWf4qvdEnrVKmvRGVFhfigXG aCfQ== 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=KfdyDikc5Jy5Tz4SbVlRx+G5cNhsbLSoadX+FI6C2bI=; fh=16lcV1Xs+7gq3HTelB50A7cWthZ2A1B50w+EjLJzyFk=; b=yXvaZKcRMAV7/rm28Oli5HXRxUBI1hwgYjafkv1kv73dB1c8ogUxtB7qPBctmJ0EKF tu/iy1RWXMb9IpGv46xVMbePO37K9XqAZKKBFLrzmWUYn3XmH4u4NxZMEQGtD29nOiEW JF2L2eCtr8PO8rJGgbmqjzHvbyFJKjUfcs7q+aUIpxoLke2LB66uwplzZj6M1MZEaQ4T timKWtzcyN145IwsU6L7G8tdWmIEo6w0LZhHuAXvJCmf3YJ8u6fAC7SQ3sO7x2JAlOTK oA/JPPrlN0gKjykrktV+agvM0EiMsBukL4Zlk0N5vKSJoRUP1uFgY3SRTBCs7t7DkU4i gW8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b9-20020a63d809000000b005637962e15esi1559929pgh.603.2023.10.12.00.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 00:29:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E71A080E73D7; Thu, 12 Oct 2023 00:29:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377791AbjJLH3h (ORCPT + 99 others); Thu, 12 Oct 2023 03:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234125AbjJLH3g (ORCPT ); Thu, 12 Oct 2023 03:29:36 -0400 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE72F90; Thu, 12 Oct 2023 00:29:32 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VtzY4pG_1697095769; Received: from 30.97.48.41(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VtzY4pG_1697095769) by smtp.aliyun-inc.com; Thu, 12 Oct 2023 15:29:30 +0800 Message-ID: <6110db84-546d-fc5c-f241-7923d673bbd5@linux.alibaba.com> Date: Thu, 12 Oct 2023 15:29:44 +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: [RESEND PATCH V2] leds: sc27xx: Move mutex_init() to the end of probe To: Chunyan Zhang , Pavel Machek , Lee Jones Cc: linux-leds@vger.kernel.org, Orson Zhai , Chunyan Zhang , LKML References: <20231012034735.804157-1-chunyan.zhang@unisoc.com> From: Baolin Wang In-Reply-To: <20231012034735.804157-1-chunyan.zhang@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 00:29:44 -0700 (PDT) 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().