Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp51434rdg; Wed, 11 Oct 2023 20:48:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsNpx0/HOnxlKRHoe7OmcsVJ77qE4rrO7p2wHkYlvO1Rh6psR6TADg6fHyLZ0Jd6+jmf6G X-Received: by 2002:a25:6a85:0:b0:d99:d1b8:672f with SMTP id f127-20020a256a85000000b00d99d1b8672fmr10976577ybc.33.1697082533838; Wed, 11 Oct 2023 20:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697082533; cv=none; d=google.com; s=arc-20160816; b=iQaeAzHl+ln52BOkIiGydTlQ+mSQ5JCWZhDvvI1mdA1nX+KawcEA9851hwJ7FN1YEw HoDIo5gnbdeh/VC9Wm59W2uhHIjFIJNJ8afXap2dQFRH/tbKQXKjnvXey6QQlsfwb+yf 6P0zpqZvv4VSdwaQebUC4leWkHaaxriVc5u7Cnq6NEQv1jYYY9dvt0SSc9NIttVaIyNY 0rBjTxORTBIVBSc03Lt+qwohcyRi5L2ThPJ28rC0UOPTWTvoRYkQp1sNSFUDmyJv8CSH BNyVNYJywZ0nb+B+KxFycSH1AUtKjzDTmO3jkj2MLXuteWGP+xEjEOYEZhF/1LEnhjI4 9smg== 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=8tm4nlkWTtYw422us457DKyDw4ao4qSskejE0uNSOcI=; fh=VK4GYMBebvMQCrcu2n2Zae3yc77oFdyfZTM6QfHDfeY=; b=Iq5+JzcTCJRDc9yGXaHqd2yWQxRymk9VWKNyhbYl1hOlvYV0VQ/sOYtUdY55Gn+fvV XrU0FJA8pgSzsy9EBT/Sx0kfTxz8gzSLVvGB3yDkLGh7ZQrlvP4LpjwaDKlDprlv7GQh AKer1TxTy/L4wHM+uOD/leFPhuO1rk9gDiMpvItD/FFEYBP1kYOrJyF++sm90Yl1VFIG PGk9FUNEy9hv4jMLIsYn7XDeB3jkozCdT8fDd65CmQ0hVEisT9regwa71ySdmnfFT8FY ZCdQL3NLuAPMQnITrubde6HX1sh0DwyWUgfZUmPYJd5Jj1EKIpeQhnMPw5wq9BwlBrYV Q8ag== 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 e12-20020a63db0c000000b00565cc12ee24si1231395pgg.874.2023.10.11.20.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 20:48:53 -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 3CAED80239C1; Wed, 11 Oct 2023 20:48:51 -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 S1347036AbjJLDse (ORCPT + 99 others); Wed, 11 Oct 2023 23:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbjJLDsd (ORCPT ); Wed, 11 Oct 2023 23:48:33 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464B0A9; Wed, 11 Oct 2023 20:48:30 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 39C3liej099147; Thu, 12 Oct 2023 11:47:44 +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 4S5b8b13nPz2KNwVN; Thu, 12 Oct 2023 11:43:43 +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; Thu, 12 Oct 2023 11:47:42 +0800 From: Chunyan Zhang To: Pavel Machek , Lee Jones CC: , Baolin Wang , Orson Zhai , Chunyan Zhang , Chunyan Zhang , LKML Subject: [RESEND PATCH V2] leds: sc27xx: Move mutex_init() to the end of probe Date: Thu, 12 Oct 2023 11:47:35 +0800 Message-ID: <20231012034735.804157-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 39C3liej099147 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]); Wed, 11 Oct 2023 20:48:51 -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. 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); + + return 0; } static void sc27xx_led_remove(struct platform_device *pdev) -- 2.41.0