Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1806108imu; Wed, 21 Nov 2018 02:10:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/UT5VcfmIk6AKm4zD5iDh/SFGkkNfH47GhUq3vhBkyM+t64Y2wHtu3LWWyyw29AUlOxZ3mn X-Received: by 2002:a17:902:6a87:: with SMTP id n7-v6mr6110431plk.86.1542795038804; Wed, 21 Nov 2018 02:10:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542795038; cv=none; d=google.com; s=arc-20160816; b=VBX+Ib3AnTVxpth8uxsC98weLRw+EcFNOrIbjpF2fn6WMdYYl7wgJV7GYMkgsIubEg o0IVO1RyUKJt5qct8DfR0SI6tj2HTV8tPhOZgVxo3Vwg0437XdUiJ52h6ecEhuinOqe5 kj7INqgJD8mstKKCSPqp2ZGINvoCL5tsJdRld1mC15i4rEMGamioDjPWqGvrfR5jVyxO kN9ysMBYbAQrarvvXRegHd7EANeMtRI55/oW2jhBTq7fkPRGBs4p5ZN4zMqP9DCull+S BRnvw7Zii4fTzIUzTyLu5FzOJ/7NCunb7UE6l4aYYOPk+wCna60+kPZx/CDKbhCyq1g7 AQmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zCXl258BhlJVJxnZPET45BZ7xw37H+7/Umd1D/zWxUs=; b=o2g7WU61/42cxt1qyBShxuvZMqrvnFkpiI0cOwHEqo5T70rj06GnNEPscoQA8LtmIm HiLjYyFeWka31hf+Xtn1k7H9izZiYC59rOEPO1J3r89Q7UBPG2bWMF+lF2RqJLQ3Ivmr ZsOmwWp9Rn6EuuCW5m46d5dcHsn54KKZarcrl1v2xAhLxIosX1xujAE+rBJnY9G60NwB ZngE2608lTLEreb5JXTnKTl1gGF+qepPoYzun6dC9ViTdrF8WfwNs7R0XJ8lEIQtAwDV FwMgAQvk+2YRBpxp0T6ZgjqSj/MmVslD3G9F2LeY8Om8/oZwzrtGNwZZumZPWqRQ8PNT 5tAw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h69si41291656pge.121.2018.11.21.02.10.21; Wed, 21 Nov 2018 02:10:38 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728025AbeKUUlj (ORCPT + 99 others); Wed, 21 Nov 2018 15:41:39 -0500 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:36458 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726147AbeKUUlj (ORCPT ); Wed, 21 Nov 2018 15:41:39 -0500 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wALA4K0F000633; Wed, 21 Nov 2018 04:07:46 -0600 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail3.cirrus.com ([87.246.76.56]) by mx0a-001ae601.pphosted.com with ESMTP id 2nth986m4j-1; Wed, 21 Nov 2018 04:07:45 -0600 Received: from EX17.ad.cirrus.com (ex17.ad.cirrus.com [172.20.9.81]) by mail3.cirrus.com (Postfix) with ESMTP id CEEB4611C8B3; Wed, 21 Nov 2018 04:10:29 -0600 (CST) Received: from imbe.wolfsonmicro.main (198.61.95.81) by EX17.ad.cirrus.com (172.20.9.81) with Microsoft SMTP Server id 14.3.408.0; Wed, 21 Nov 2018 10:07:44 +0000 Received: from imbe.wolfsonmicro.main (imbe.wolfsonmicro.main [198.61.95.81]) by imbe.wolfsonmicro.main (8.14.4/8.14.4) with ESMTP id wALA7hat014725; Wed, 21 Nov 2018 10:07:44 GMT Date: Wed, 21 Nov 2018 10:07:43 +0000 From: Charles Keepax To: Marek Szyprowski CC: , , , , Subject: Re: [PATCH] regulator: wm8994: Don't use devres for enable GPIOs Message-ID: <20181121100743.GF16508@imbe.wolfsonmicro.main> References: <20181120170152.24652-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=886 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811210092 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 21, 2018 at 10:26:30AM +0100, Marek Szyprowski wrote: > On 2018-11-20 18:25, Marek Szyprowski wrote: > > On 2018-11-20 18:01, Charles Keepax wrote: > > ------------[ cut here ]------------ > > WARNING: CPU: 0 PID: 1 at drivers/gpio/gpiolib.c:2421 > > regulator_ena_gpio_free+0x70/0xa0 > > I've checked a bit more and it looks that the issue is caused by > gpiod_put() in regulator_ena_gpio_free(). I've removed gpiod_put() call > from wm8994_ldo_remove(), switched to regulator_register() in > wm8994_ldo_probe() and added regulator_unregister() in > wm8994_ldo_remove(). This way the warning is gone. If there is any > other, simpler way to fix it, let me know. When regulator_register() > fails, gpiod will be freed only in some cases, depending what caused > failure. It looks that this needs some clarification... > Ah.. ok, so is perhaps what is happening here that both the devm_gpio_get and the regualtor_ena_gpio_free are both trying to free the GPIO? I assume the regulator core does this to handle the case of shared GPIOs, so presumably the correct fix would just be to switch from devm_gpiod_get to just plain gpiod_get and not add the additional gpiod_put in wm8994_ldo_remove, as the regulator core will handle freeing the GPIO for us. I will respin the patch and lets see where that gets us to. Thanks, Charles