Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp948754rdh; Sun, 24 Sep 2023 20:28:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF095ym1SwDBLE8uJNivkEkpS+02Lf4sOUp2+HzGoTl0L3OSeJY+EwQ4WVgMm8sKJ5Kg6J X-Received: by 2002:a17:902:d4c4:b0:1c6:225c:cd24 with SMTP id o4-20020a170902d4c400b001c6225ccd24mr254886plg.37.1695612491405; Sun, 24 Sep 2023 20:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695612491; cv=none; d=google.com; s=arc-20160816; b=Rl5I1EfXzT+PQOVIOzEmOnZMJZ4LW4e8hkmTpCZMAxXPbfYr9lddg6jaDI/4N+9cHw W8c+Ltf1OkwCgGaTidDbs9MlN+KAznRYJh+efe+6pnN4yjPXxlWUuPL3/QHxmepFrg+H Y7RmukrVfrW9WudAGZcPvCq8MKiwNKadu4WERAfC2Yp7egd60usAwsY2EDASreqGxxDO h8CBNevJd6FddNpo6dq2FYX/CGiUxyA0uXh9D8v+TXje3wpumAIHavFZ5s5moB4lCAej 9K52dtrAe5202UoqwKs5eBl884cadgvOpVFgrqqyRcX/ozDhCKcUyOu5q9AZFcgl67uQ hDlA== 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=sdqA/u2JnrhoYWRTT1/7+Co9cuiQYM8ytU3RV4CDK6w=; fh=VK4GYMBebvMQCrcu2n2Zae3yc77oFdyfZTM6QfHDfeY=; b=MhfmvQkT38lO1MahwdIL4gxE/LpdxmBGasnmDtqFq0JnWFjFg3dWrXSz1KlYDCrqBm 916OYFXufVWhi7hzEmDmRDFjlDPOEPoRvKD4PMqRnojkUPt18LxafRknH2Pm2N7jLBjP s2jml0soEc2K68Fc7l8xH08Lc+IJbZ+4EW/h5y5L4Ft5vs21EOmhN7VN+aNGdDAc7j+W whZeF0AFbimc811GG1jvYw741xr8oGm/f4p4wIypK30NgFsd9ngVf3AAAx+nCYGMcWye vQAHIJYKKbzz02YDLBe9JAufEGVajxtePs15KiOnliN/3BCwFiCyT3w92iTAfAHucfKO +RXA== 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:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id kb14-20020a170903338e00b001c5fa46f0e6si4635872plb.190.2023.09.24.20.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 20:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 70723807C85D; Sun, 24 Sep 2023 20:25:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbjIYDZy (ORCPT + 99 others); Sun, 24 Sep 2023 23:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbjIYDZx (ORCPT ); Sun, 24 Sep 2023 23:25:53 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 587CAC5; Sun, 24 Sep 2023 20:25:45 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 38P3P3TH045477; Mon, 25 Sep 2023 11:25:03 +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 4Rv7Sv3hfGz2SX8n4; Mon, 25 Sep 2023 11:21:35 +0800 (CST) Received: from ubt.spreadtrum.com (10.0.73.70) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Mon, 25 Sep 2023 11:25:01 +0800 From: Chunyan Zhang To: Pavel Machek , Lee Jones CC: , Baolin Wang , Orson Zhai , Chunyan Zhang , Chunyan Zhang , LKML Subject: [PATCH V2] leds: sc27xx: Move mutex_init() to the end of probe Date: Mon, 25 Sep 2023 11:24:53 +0800 Message-ID: <20230925032453.724518-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.70] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 38P3P3TH045477 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 morse.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 (morse.vger.email [0.0.0.0]); Sun, 24 Sep 2023 20:25:59 -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 --- 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 e199ea15e406..d9183addf7f5 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 int sc27xx_led_remove(struct platform_device *pdev) -- 2.41.0