Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1030771ybl; Fri, 9 Aug 2019 18:47:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOwpMjSk7mlefs055hgUJEbeWMvNbnNDnEJxZEZJ1AhAHUWWoPyvzhBwubG1CJ2o7nwHxr X-Received: by 2002:a63:ab08:: with SMTP id p8mr20831405pgf.340.1565401652322; Fri, 09 Aug 2019 18:47:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565401652; cv=none; d=google.com; s=arc-20160816; b=lASmyrxzL1orNWROlZn+eipH4ncOuYdojAyzcAkkXSRWK1rgZHYXozcJpV8dk8EJpC Amh/UcJclTOvqLgiahLueXyWj6estzwmXZj5DTUx+aKpTf5qCNFxLYZvj2H7bDD0gCfv mvAmtv9Foha9qx74vTXoyIZdEO3fKcgLQ4nvEYQ/gY0MM683oPQPDS2XZzu1usAhI/2K lxGh5DTVnSRVBrg3utCf9RCps9K1BFW5NsB0KXVtGddrTbrc7uPeckc9iQ+VA+h/MFT6 WrDE95BZP8UG1YqBhQr6vTcR/hoHQNYekwwiV6ZVC790Nv3NQGfu5+asgPIjl1zAJ/K9 cLkQ== 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=Hba0YbyURevY2P3XTePra775mSMcCjjlB5vVgIy6gjI=; b=Ekue8hhYoPDKIcOSlz3Lzx37ldLB1ez/QZ5Ao+XFLklnCr5uolfpUU2JL4rfMcDEA6 eIIoTF7zOyG7ptwTnwqJ1+wDbUk7J5t7JekaCezQlApvgJXeAf+VaTAznWtq5JsAqpuo GbxOuuHHCfQXPHdi9Ym4gjkKz4XGkSn52NL9cKHP1OnzPE6jfCqGArX+AiOLUJtJNGbt SdFSYNybfdGLInU3yGjqJJEfw3/Fug7V5EZMXTftjX7nW1JbkaBjKoChXumLyN1uh17v nOEx1Y05V+XPTqjcrnIhVfTS206LwZrAkH0/qdOnuh2xGlYRhZwZSZ5o/ZyFN6ONhx7f DeRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=el0TijmM; 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 u9si57481658pgm.167.2019.08.09.18.47.04; Fri, 09 Aug 2019 18:47:32 -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=el0TijmM; 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 S1729636AbfHJBo6 (ORCPT + 99 others); Fri, 9 Aug 2019 21:44:58 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:38895 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbfHJBo5 (ORCPT ); Fri, 9 Aug 2019 21:44:57 -0400 Received: by mail-ed1-f66.google.com with SMTP id r12so62180085edo.5 for ; Fri, 09 Aug 2019 18:44:56 -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=Hba0YbyURevY2P3XTePra775mSMcCjjlB5vVgIy6gjI=; b=el0TijmMk/+XrZfsG46YQwvSxHXt319zM49YflOTMztmA+89S5Lfgta4z8J+Kt2+vh jPOTSbQeETNk48Ysk10IIOlzLc7j6JZeKhFnpjRsQVYfPXxGyQckZr8iut+4vE4FtPjK IJPUH3SBTfZdTUpZEoF4QmJMYj5o6tXY3Up3C7/yb0uoFdQf3Eu9jsd6OV1jrwzhXbvC h5lvkvfIo5Vw0rOWi73GVc+Nb1eN+TG+7BvY8+4RFKpY3h67nHjWzmOFA1QWKOfPmiPj gOFGH5zsottQ/TBYOnOYt2hW7MlPdI5d4stKCuxmyRWxYCi48ktuiLjSRZ6pHf4xe7fB MazQ== 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=Hba0YbyURevY2P3XTePra775mSMcCjjlB5vVgIy6gjI=; b=QsAJBBLtDNdDqp/xjYq7U6szC3+vyyxTaGhCvkd2R11g48c96tfmLl8hqW9UOC8nEn R4AXH7IQ95Aeuon+0YH+6slDr/HcKN0XlvOcw87dPQw4ZuNlnbLo1/bMoqJAIW6tFXTg ge07zPjBz1mDw4EVEQj4dhJyJo09oUXUshQGNro6pFAKgMS7kffyNVwq5syYKEisY+cu DWqKBhs7GXdgt6JsFJwhtIF04fcMk/btQNMk4wCN+bxIl5ilv8wDe1nu8he9zZjGb9JN uaHV7beZ+yDJdO6u4pW+LLh8ZP/OZCSHNlr0ZStKbh+sY1eAzBchQ8uL/WCqh/g4bqd6 sDrg== X-Gm-Message-State: APjAAAXfWkBjnjOduy3BLScO3yAPwzvZqKs956bh2srgA9bcVMrV7BL+ qda09xtMTgeVHu5qyD5FXzqAw7tUQ7UPBmz/q3U= X-Received: by 2002:a17:906:4890:: with SMTP id v16mr21526067ejq.296.1565401496166; Fri, 09 Aug 2019 18:44:56 -0700 (PDT) MIME-Version: 1.0 References: <20190809030352.8387-1-hslester96@gmail.com> <20190809151114.GD3963@sirena.co.uk> In-Reply-To: <20190809151114.GD3963@sirena.co.uk> From: Chuhong Yuan Date: Sat, 10 Aug 2019 09:44:45 +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 Fri, Aug 9, 2019 at 11:11 PM Mark Brown wrote: > > On Fri, Aug 09, 2019 at 11:03:52AM +0800, Chuhong Yuan wrote: > > I wrote a coccinelle script to detect possible chances > > of utilizing devm_() APIs to simplify the driver. > > The script found 147 drivers in total and 22 of them > > have be patched. > > > Within the 125 left ones, at least 31 of them (24.8%) > > are hindered from benefiting from devm_() APIs because > > of lack of a devres version of regulator_enable(). > > 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. 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.