Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp687449rdg; Thu, 12 Oct 2023 19:21:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWlyxisddHB/PFR1H49iy2TA+k2nIOHav9LBr2Fq1+CXKNrkO2OXRfh64dqDsNaIVW/U5U X-Received: by 2002:a17:902:a604:b0:1c7:37e2:13fb with SMTP id u4-20020a170902a60400b001c737e213fbmr24234616plq.55.1697163704709; Thu, 12 Oct 2023 19:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697163704; cv=none; d=google.com; s=arc-20160816; b=P9frC+QaCCFZWvy/rkjJ+tE16h+FEffhFDmzbwE419HvpCUdFxJgKvYPJJ2/fBKokF p0PVOj8MXQB1JbJIwAwKTPCbkN2tVUQxDUw3VX4yh2ljiGB2U2UDeVR8vdzKzr8fPion dhM4Sed8jZMZZ4PDl0iGFVpXjYiK10X3fEZ5FhZKwZjJk9hjmfhlwOaNsANOQbdeolAF SAydNFc3EsiTcQcTJbiPZz5fRx0lVYTSWOr21DN12i8E4clETgwbBru7QGBhPBDguYTg abZ2oOGlCaZvaNxretR7YJ6LdKJc77dQ/on7AoIa47WFW/WW7J/dGMdiEFPA5lWv8SOz ChKw== 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=2O82hO5/fPYAQNeYdUUnkmmezBIefa5IHJp3zdDxNVU=; fh=VK4GYMBebvMQCrcu2n2Zae3yc77oFdyfZTM6QfHDfeY=; b=l1Nyhkyxw5sJztVITbYGUi5m10+7cL0sQ7QjGYThEb5FaYzMK4HxWtc96fE9pbDxW4 EMI3CDU1ta/+sKWC3nED0U08D8tYavM10eukTzFpd/hM6gwdK3psZFjqiuRBoc+XSP8e jzWGlvaME70Cpa2RSb953UJZmM+XZFBP33rR11Ic+5shN6fMhIU6l/bfESUFPB5uyeZ8 MyTnxuXNR6A6HRlidpdSNB5RwqgGMlFoSPPxDzWyxXZ01tV8VFLL0TwsnP9ivE7sASse skNH9GRLTeMQQ4r+bQiq7gslFEiXTw6mFlH2rOVbHwGXIhQz0S92ksskEsu+W8XawOxK GVYQ== 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:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id i12-20020a170902c94c00b001c74d83470bsi3788532pla.206.2023.10.12.19.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 19:21:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DCA0E81C3645; Thu, 12 Oct 2023 19:21:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbjJMCVb (ORCPT + 99 others); Thu, 12 Oct 2023 22:21:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjJMCVa (ORCPT ); Thu, 12 Oct 2023 22:21:30 -0400 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 253FF95; Thu, 12 Oct 2023 19:21:25 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 39D2KavT049391; Fri, 13 Oct 2023 10:20:36 +0800 (+08) (envelope-from Chunyan.Zhang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4S699Y2KqQz2KG27m; Fri, 13 Oct 2023 10:16:33 +0800 (CST) Received: from ubt.spreadtrum.com (10.0.73.88) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 13 Oct 2023 10:20:34 +0800 From: Chunyan Zhang To: Pavel Machek , Lee Jones CC: , Baolin Wang , Orson Zhai , Chunyan Zhang , Chunyan Zhang , LKML Subject: [PATCH V3] leds: sc27xx: Move mutex_init() down Date: Fri, 13 Oct 2023 10:20:10 +0800 Message-ID: <20231013022010.854367-1-chunyan.zhang@unisoc.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.73.88] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 39D2KavT049391 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 19:21:41 -0700 (PDT) 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. 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); -- 2.41.0