Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3750407ybl; Mon, 12 Aug 2019 05:54:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzM6/+kQtBqHK3lctalotx1mlhdmlA8ampY9rqmJoOZ+oQIixRNx65Rz4+inDdcGEllndER X-Received: by 2002:a17:90a:1d0:: with SMTP id 16mr1365804pjd.98.1565614442746; Mon, 12 Aug 2019 05:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565614442; cv=none; d=google.com; s=arc-20160816; b=RUPGDgVBTA5gyd5PJZgTmUTjMS+Ds+1CRdmMG+/MDhmOEbhba3Ai7Byha3zsNHYSnv N7nkiIUyyZ22b12zDGYoy4DRCse5qv3z0XCJIFjJLlUNyZZufDJBiERvQybK2jdIfb9w lSyEoSm4RqWYNzrT/YEOm0ldkHweTxHqQR7uOP9xMG5cXWU9zJRuNkyQtITH3NanbpnM BbiW70isv7CXb0GHNCCwK1LIgYnw2HufGlOU3PW+bqzYx7ENHUWGl1RtIy0QQebW0HV7 Wo9AkVbhJrC24NrEgu6GTrP9rlYS3FeeOKy898KwG88LKvYjJuYeulWy459pHJWz8DBF 04iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kGrGeul0SC/umyrFN5VVINyiciJfk+nILd0h/dFFtd0=; b=hqtmgwpqVVPS79T3Ex643RBC5zP/tP/tOXOERhZMgeNrRJnA5u8c1SSdfgPZBZulOL NRJssy5Mw+/g8HM4HzkIjYBWXKiHB/967qwx5/d9mr6BAciAi3XicZmJNiHuyEd0hmhO SM8vuqoTHUaLmV2QRxZjtNSbRGyNVn6qNXbRt5Xv4PPaoBNKxvKaVg4fIEVbU0tOPAwV cPLpFmCveyDRMnuYRphOEgqatNkTkcw8kAwaRTCRT788mpRBU6XltGhboK3M3/5n3qwS CA5vAU8ANgj3P9bjmwvicSFfxDpE0dazrozG0QHX6xClouZXasv3TNdMXdAn8WfyMkTu kT3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hjkrzO7K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si11855854plv.189.2019.08.12.05.53.47; Mon, 12 Aug 2019 05:54:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hjkrzO7K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728679AbfHLMvi (ORCPT + 99 others); Mon, 12 Aug 2019 08:51:38 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:38662 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfHLMvh (ORCPT ); Mon, 12 Aug 2019 08:51:37 -0400 Received: by mail-ed1-f67.google.com with SMTP id r12so717239edo.5 for ; Mon, 12 Aug 2019 05:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kGrGeul0SC/umyrFN5VVINyiciJfk+nILd0h/dFFtd0=; b=hjkrzO7KDdoCyrll/AIT9a5zlI5P9yMGmS9KOUbaiSUwmlgmfohkjMgRW7iFmuY/kg BAMuoV3oCnAjCNuowFU2Rmfpp3s5/q2ULB4PJ3pSWu7IEdHfpMOrqEykRhLTjVBGsW0o C/jK7YNqSRTaUS0f4quizSP02RTiK22iytfYvD50kwHoCR73Glku+2qHChYVKIgXnjvu C37cV7Gg/FvbVp+ks/PuHAsecNMkmETXx9I0qD+C1gDLtbKeosoLRE2G7XCVDlhcJcsL X9EWwYehg5WFlZRmKtfihCcU3e2JNm6aav4YZcILrd7nDMRWrMpdv4Cn3wc3qwcpQDH9 csvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kGrGeul0SC/umyrFN5VVINyiciJfk+nILd0h/dFFtd0=; b=LI0bbW+e0y72p/ogpgHIjr1oEt+6KixsN350FhlnQIRxXeRT0sJqJqIF0zWCREdn1u 2KM1pdfLu+ok5gv2jjMHsQBfoAmyW/O28sUP43Az62lUB1kYuZoAgcjWkaykKI2t6+om I9UP6YShP1jTGJK7nh8hbffuWFFU4fGbilveDMcTcllJfMMojefV09EAP+6aFEw1gEB+ 9opaPMK2mCB59D8wwozJBCmeoeDz8GMV3aa0YYwsfb3wfnP0w2tr26wGwZSu7fOHfsJZ uon/QkUy/dfaynxwDtbdQ53RPQH9/HAC4AMAaBn+7NKoZcEHuQCRNP5J+HJhk1mTWt7j IDfw== X-Gm-Message-State: APjAAAUuisxfu/Tla92hEQnwhYE6hPOhwmFr+ml3O5Ya+KlPdlGhz8qd U/2h0GtkaJWoB15UMTteZIX/ymGPwSJjEid2W5fPqi4EBQA= X-Received: by 2002:a50:b66f:: with SMTP id c44mr36364139ede.171.1565614296251; Mon, 12 Aug 2019 05:51:36 -0700 (PDT) MIME-Version: 1.0 References: <20190809030352.8387-1-hslester96@gmail.com> <20190809151114.GD3963@sirena.co.uk> <20190812110719.GE4592@sirena.co.uk> In-Reply-To: <20190812110719.GE4592@sirena.co.uk> From: Chuhong Yuan Date: Mon, 12 Aug 2019 20:51:25 +0800 Message-ID: Subject: Re: [PATCH] regulator: core: Add devres versions of regulator_enable/disable To: Mark Brown Cc: Liam Girdwood , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 12, 2019 at 7:07 PM Mark Brown wrote: > > On Sat, Aug 10, 2019 at 09:44:45AM +0800, Chuhong Yuan wrote: > > On Fri, Aug 9, 2019 at 11:11 PM Mark Brown wrote: > > > > I'm not super keen on managed versions of these functions since they're > > > very likely to cause reference counting issues between the probe/remove > > > path and the suspend/resume path which aren't obvious from the code, I'm > > > especially worried about double frees on release. > > > I find that 29 of 31 cases I found call regulator_disable() only when encounter > > probe failure or in .remove. > > So I think the devm versions of regulator_enable/disable() will not cause big > > problems. > > There's way more drivers using regulators than that... > I wrote a new coccinelle script to detect all regulator_disable() in .remove, 101 drivers are found in total. Within them, 25 drivers cannot benefit from devres version of regulator_enable() since they have additional non-devm operations after regulator_disable() in .remove. Within the left 76 cases, 60 drivers (79%) only use regulator_disable() when encounter probe failure or in .remove. The left 16 cases mostly use regulator_disable() in _suspend(). Furthermore, 3 cases of 76 are found to forget to disable regulator when fail in probe. So I think a devres version of regulator_enable/disable() has more benefits than potential risk. > > I even found a driver to forget to disable regulator when encounter > > probe failure, > > which is drivers/iio/adc/ti-adc128s052.c. > > And a devm version of regulator_enable() can prevent such mistakes. > > Yes, it's useful for that.