Received: by 2002:a9a:4c47:0:b029:116:c383:538 with SMTP id u7csp7574955lko; Fri, 30 Jul 2021 06:48:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwwDO3K7bDNg4he61xZlXzKHeFQwh+wEd1hXe2fo3dflcTEYQeo7+ISzKidAGulMzQRU1+ X-Received: by 2002:a17:906:d101:: with SMTP id b1mr2601890ejz.424.1627652909633; Fri, 30 Jul 2021 06:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627652909; cv=none; d=google.com; s=arc-20160816; b=osU32D+HwTNhpW4htt8kZTiEG0ogldK3bC3Oymd5LTU2W02B5H8FCCMwHl27ZcH3uV uQzI0PVI66LaMTK/K9RRsU+b2E0xsRHtUk5dzUffIjPgEqdb+ZfgvxgNZAGhjmu7HtGN e6u7NodvypkXrL5ZRXT/5mO7jq5ohNsn3AFu3n0hStsFKe9JxuEl41JxTtCZDEdrCz/7 M7NbIXcjJUS8mLQR6rl51BbrtuF+0CMzZ41mEQQtDj7RCbZooZKZKncwTHZYn6b8gVA1 pygTPGpZCSIj5++EDx557NMNfHmSk48Y9N/mrOWh1Mp2W0Q8/f2eeph5kEjZK52rqz+D O9tg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=/lp+b5eKsJtdAzw031d0FRdPIKA69wxpJT4WiOZGVSQ=; b=M5ebdkvcDTXC0z59nAqJJva+Z4KG4FsP4X8tP8TZsw7/h7V8lXqDNfRtSyliVbVGV4 NRXbLzkkOxqtxsxxUOZ3NLa1T1O9Qu6HQ+QB2eSx4nT8gdn1TaH+5TWPPjXXsgx9X/4c ydmK7W93A+lw3rWFAf0HbCt4oPPRN3zUcSCF/Wlp83eoGCVbIASXxsKGEjLA2x2qATMt wn43XQfEi2Ssrwsbvv4BAkGxBo6avSidgOqgIlaUYXDKtrSAj7a5jmDz/eo0nPvXcH8P 3YISVqH0X1yIQUZeZwuKEWI/xCalUldYaoUCqV3bK3ByONV8pdESC1mjHIs7fCCViKzt ARpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si1677066edw.436.2021.07.30.06.47.41; Fri, 30 Jul 2021 06:48:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239010AbhG3NpO (ORCPT + 99 others); Fri, 30 Jul 2021 09:45:14 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3542 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238970AbhG3NpN (ORCPT ); Fri, 30 Jul 2021 09:45:13 -0400 Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GbpLq3j0vz6G9mJ; Fri, 30 Jul 2021 21:35:47 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 30 Jul 2021 15:45:06 +0200 Received: from localhost (10.47.1.48) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 30 Jul 2021 14:45:06 +0100 Date: Fri, 30 Jul 2021 14:44:39 +0100 From: Jonathan Cameron To: Hui Liu CC: , , , , , , , , , , , , , , , Subject: Re: [PATCH v1] iio: mtk-auxadc: add mutex_destroy Message-ID: <20210730144439.00005e26@Huawei.com> In-Reply-To: <20210729080135.17436-2-hui.liu@mediatek.com> References: <20210729080135.17436-1-hui.liu@mediatek.com> <20210729080135.17436-2-hui.liu@mediatek.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.1.48] X-ClientProxiedBy: lhreml753-chm.china.huawei.com (10.201.108.203) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Jul 2021 16:01:35 +0800 Hui Liu wrote: > Add mutex_destroy when probe fail and remove device. > > Signed-off-by: Hui Liu Hi Hui Liu, Two things here. 1) You need to explain with a clear example flow when this would serve a useful purpose. As I explained before, we do no in general put mutex_destroy() in remove paths as it is usually just noise. 2) It's in the wrong order logically. mutex init is between the clk_prepare_enable and iio_device_register, hence if we are going to have mutex destroy it must also be in that that location (remove should be reverse of probe or there should be a clear comment explaining why we need to do things in a different order. 3) If touching this code at all, please move all of the probe / remove to devm_ managed code so that we don't need to get this ordering right at all because it will be done automatically. So I won't apply this without 1 and even if I accepted the principle, it's still in the wrong place in remove. Jonathan > --- > drivers/iio/adc/mt6577_auxadc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c > index 79c1dd68b909..d57243037ad6 100644 > --- a/drivers/iio/adc/mt6577_auxadc.c > +++ b/drivers/iio/adc/mt6577_auxadc.c > @@ -289,6 +289,7 @@ static int mt6577_auxadc_probe(struct platform_device *pdev) > ret = iio_device_register(indio_dev); > if (ret < 0) { > dev_err(&pdev->dev, "failed to register iio device\n"); > + mutex_destroy(&adc_dev->lock); > goto err_power_off; > } > > @@ -313,6 +314,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev) > 0, MT6577_AUXADC_PDN_EN); > > clk_disable_unprepare(adc_dev->adc_clk); > + mutex_destroy(&adc_dev->lock); > > return 0; > }