Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3024385rdb; Wed, 15 Nov 2023 19:25:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEg48JKAE8oumPz/Qexsxwqy/6L6as381ha0gKCSVNudjdAmbnMbPnspgYTjO9QCKUrjV5/ X-Received: by 2002:a17:902:c943:b0:1cc:5cbf:50d2 with SMTP id i3-20020a170902c94300b001cc5cbf50d2mr7926099pla.59.1700105148445; Wed, 15 Nov 2023 19:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700105148; cv=none; d=google.com; s=arc-20160816; b=X1uLsimI2MyZJrKtX7uFwRtkl7jREAGueuCnjfQgLq+vHpBHaY4qKOU3x2kIbwetyL arFAH6cCtBg4e0MnDRhVln1GUrHRu42p254p/Kn8imn+9YboMptPoVE/vr0R6htrtwkQ 7OVVpfeR0HOKZwvaasrstf85ZlPYInpr1ajyHFIlmwKoyp8DVFqFwlI4dW4NmHTzFghT O/2LNzHYf6etctTgOB3bZzyho98GZPYZjDta6g4aUbUHMn72/ejSNLMu/onaVbFEsiRy oDJziCkMXFC5tTqLs/SfEWpXwAubw82o4WUrefOSjcbBBSgf/SSwH5hgr+qUy1NMuBMd r2Rg== 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 :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=I4yaIbz0iC/MoFwDc9aSKAR+Xpz3oNadrypAS22c5P4=; fh=XzDSHTydKmSeTZ32CA7ORTvHZsVcSIZEpiiEzwjWZsc=; b=wCP2twgKQ3ArN6hIW02Yg6nXkxBduPypX6oJWujbtq9UIoycghQcPVWU7sUGjP0Ti9 voTyMf7PwOXHV1DPMN+MYsksF+gjCcvLm71jT8bznPB0wvyBgGSGLKpOH59Mv6P8OxIT /x7IMX2YYaK+TcHk/7h0j9iYBnSKAlEQpEM4fD0c42nGPTG+aKhOKcOOdXcANaHj5y5R 2izuthJhPdBprr5bQdhQC+IjOt30EeHqcgzKkkHiFj5pEtsRFUZTVRqg1sYeevTmXxC6 zWMSYOROb9hLaGyZaQTVh5tk2hmzgnPfY/kKwo/qbfIdsX4v8+aX3DGEq1qJhPVYt/Bb H7Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cSBE7Iyi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id l13-20020a170903120d00b001cc589562e2si12436351plh.530.2023.11.15.19.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 19:25:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cSBE7Iyi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id AD45E807F64B; Wed, 15 Nov 2023 19:25:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343567AbjKPDZC (ORCPT + 99 others); Wed, 15 Nov 2023 22:25:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjKPDZB (ORCPT ); Wed, 15 Nov 2023 22:25:01 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01166199; Wed, 15 Nov 2023 19:24:57 -0800 (PST) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AG2h7uB001020; Thu, 16 Nov 2023 03:24:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : from : subject : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=I4yaIbz0iC/MoFwDc9aSKAR+Xpz3oNadrypAS22c5P4=; b=cSBE7IyiBEMcjJWEUbcF5lxCeLmmqJcKyUa/mpYwxwhA0QhL7JXabxsI1vsdx83NiIen 79tVXjidOstynaQrL3OVspMvTtHlJQ3Nz3R/hJdCQn9UXmKGKEm/vgXbAL0j4TVJruC5 d5Q4ZybxlIUXF/PmDYc2pIUVAre4LaJwmp7hRyJHSjAue0kjO5wz/OYGJRZDkdpr4epT 5Sy4Uu0h4+Pa25xHBTpZfrIqm9r6F5aYbzFVe/8w1BjXhS1N2B+wQp/VT4oqd3md4RPJ JrUa7LgLs45VKPFXDGiukMSEcRxE3Q0+7KNNZPmGEBbMCJTXbhEumkSpN5U3yy3crOHX IQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ucfkabny2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Nov 2023 03:24:20 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AG3OI0U026280 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Nov 2023 03:24:18 GMT Received: from [10.216.41.162] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 15 Nov 2023 19:24:08 -0800 Message-ID: <60a058ba-0bd3-9a5e-5021-4f80b9df65a8@quicinc.com> Date: Thu, 16 Nov 2023 08:54:04 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 From: Jishnu Prakash Subject: Re: [PATCH 07/11] iio: adc: Add support for QCOM PMIC5 Gen3 ADC To: Dmitry Baryshkov CC: Jonathan Cameron , , , , , , , , , , , , , Lars-Peter Clausen , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Cosmin Tanislav , Mike Looijmans , Ramona Bolboaca , ChiYuan Huang , Ibrahim Tilki , William Breathitt Gray , Lee Jones , =?UTF-8?Q?Leonard_G=c3=b6hrs?= , Haibo Chen , , , References: <20230708072835.3035398-1-quic_jprakash@quicinc.com> <20230708072835.3035398-8-quic_jprakash@quicinc.com> <20230708165955.08c1159c@jic23-huawei> <13d5dee2-1da4-2ad0-91f8-a53b43adba2b@quicinc.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 385GMTGPE6VVBBer0E3PHCrzfXcbmnY4 X-Proofpoint-GUID: 385GMTGPE6VVBBer0E3PHCrzfXcbmnY4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_20,2023-11-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 clxscore=1011 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 mlxlogscore=934 priorityscore=1501 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311160025 X-Spam-Status: No, score=-2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 15 Nov 2023 19:25:22 -0800 (PST) Hi Dmitry, On 10/23/2023 1:33 PM, Dmitry Baryshkov wrote: > On Mon, 23 Oct 2023 at 09:15, Jishnu Prakash wrote: >> Hi Jonathan, >> >> On 7/8/2023 9:29 PM, Jonathan Cameron wrote: >>> On Sat, 8 Jul 2023 12:58:31 +0530 >>> Jishnu Prakash wrote: > + >>>> + return devm_iio_device_register(dev, indio_dev); >>>> +} >>>> + >>>> +static int adc5_gen3_exit(struct platform_device *pdev) >>>> +{ >>> As you are mixing devm manged cleanup and the explicit sort the >>> result is that you remove the userspace interfaces 'after' you run >>> everything in here. I'm thinking disabling the channels at least >>> isn't a good idea in that case. >>> >>> If you want to use devm (which is good) then you need to work out how >>> to register additional callbacks during probe to tear down everything in >>> the right order (typically the reverse of what happens in probe) >>> devm_add_action_or_reset() is the way to add those extra callbacks. >>> >>> If not, just don't use devm for at least those bits that will end up >>> running out of order (such as iio_device_register()) and manually call their >>> cleanup routines instead. >> I checked some other examples in the iio/adc/ folder, I think I see what >> you mean here. It looks like drivers with a remove callback always use >> iio_device_register and iio_device_unregister instead of the devm_* >> variant, due to the issue with sysfs removal as you said. >> >> I'll update the probe and remove functions similarly, to do explicit >> cleanups as required, avoiding devm_ usage for places where it should be >> avoided. > I think you got the message all wrong. There is nothing bad with using > devm_. As a matter of fact it is a preferred form in most of the > cases. However you have to be careful to tear down your device in the > correct order. And as Jonathan pointed > out, you might add necessary hooks manually by calling > devm_add_action_or_reset(). > > [skipped the rest] Thanks for your comment. I checked the code again and I think we can do the teardown with a devm_add_action() call and drop the remove API entirely in favor of using devm_* APIs , I'll update this in the next patchset. Thanks, Jishnu >