Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp312128ybh; Wed, 11 Mar 2020 01:28:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt2KtXG6DCWlhOW4NSyM962cwjOBw5JJhoX4LTAfMUmgITQFbzmuyBBtnHadafh2zfJ1E9s X-Received: by 2002:aca:2b14:: with SMTP id i20mr1135203oik.79.1583915301390; Wed, 11 Mar 2020 01:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583915301; cv=none; d=google.com; s=arc-20160816; b=D2+5RnPSGpwjMiycD4ONv1CM3jJ4PsOYXKRPsaHFuqqp6SmOwpBateDiCy2MWG4hq8 MfLSXVTA1e7s5LCG9AVDLVcHyS9QCHnxfrt7uNs0fDFGqUnA9B9gjAquvtL0L4IYFavp y4Q9kb7FEsKMYi7C/Oz+rFTGZC+K764+rIrB1FMtvE72npP4T4zhU3x1Xb7ulb0L5ChE D8HiEzEuMmEjc87YcAbzx432taMPmzylTGNcCueOmVgJQUe267ZY7efhDMzeZ10VqAQ+ ST8Gq5PIoIB9LUQ3aAg4hdoLGOkmLCSr9dwL2GaXgMbvSpBF4o70TqdLoU51ZMfQDAFr gA7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Vuzfa5Ii3C+114ZZwPqdNHymYuyp0hGwxEjG+i+rX1M=; b=eIxB8bLD6mviuTiB/o0P8oMDsSE34/ETJsUyD+2XhECUGQegWV+3FGYrlGjRsBCcvJ SbJsb8E3Kvuu0v55bHqKVotSZKn8xv5pENrebTNfNDWvyEStf9TMIuXfJ4cmvG7QoHqy dxEvABQoFbUTbPneHGIQg9yeNbqXga0uDEraul3hkXbvEmNQ4HUvDx/Msbsg8182Ufc7 b2cp0S2NbjAcpTqnIKhS/+6Tn3JbUyb4Aa7o1suuk0qHKk7SnZy4rH5Xkcxx7AZKyJCp ezFtIShcGapsS4nLdemXI0AOVduqmOSB+4VHv8J9c9zeni4UAnCyztaZDJA92VSUNSSa CQ/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=KK2szt1h; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m23si784923oic.171.2020.03.11.01.28.09; Wed, 11 Mar 2020 01:28:21 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=KK2szt1h; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbgCKI1H (ORCPT + 99 others); Wed, 11 Mar 2020 04:27:07 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:42640 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726923AbgCKI1H (ORCPT ); Wed, 11 Mar 2020 04:27:07 -0400 Received: by mail-qk1-f196.google.com with SMTP id e11so1238721qkg.9 for ; Wed, 11 Mar 2020 01:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Vuzfa5Ii3C+114ZZwPqdNHymYuyp0hGwxEjG+i+rX1M=; b=KK2szt1h7nFFVCO3f9nxfC++kUNef5i7vZty9U/gBtxe1i+yMWak1f4jIR5Kb4+ZLA 4vw5Iye+6iBjmx4V99eSyyfZWKslZbhILLwKA+Fh0R3xZ4NGcf7fD2K+qr0lK8OL/e1j HEvSqaPf47seotvIOR/52luoXum5Qp7c7fwsU135RB1sY9c8iV1SxIsluGw4hoP8ENKU 6Dc3TfE8HEo36qIXRqrCwGcnJ8/oVPIEMnJh0529oXSU0ZV2sLh+72GfO4C5jjxotBCF ZU43ziooQvVB2uodGzLDDFl0uwQyXL4tiyfagbq7qk+JhQfeh5xNtG0zV0/ao45KwBlg xzvA== 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:content-transfer-encoding; bh=Vuzfa5Ii3C+114ZZwPqdNHymYuyp0hGwxEjG+i+rX1M=; b=RWspj9KMm98cVF2TDY8CKg13m2yNWxzXjoRIYFGMg8udYDEn0hUtFvQOV27PbePfHH Ll0BHjudfIPefNHTQQUnL9CDdjdoiIMPMM3HLmD7AV7xONsN6CCwJTPOnrhRlat3raUA r62JxF37dX+CE1cKK8qrelr9Dx1s9ZROAwH09XafAu/piLIZ4HH5h+4omEgriR9vmTUN CWvmUJ7bngU8vS3KpKtaPbcZO5ArV0byzsUChpeRT4AHay4KLJlsx0OAo76BtfmMfHjY zamr6Q7Cmk5Hts5TRVwzauUj7Xs6Ddn02S6RWSofjW7mxNMeOhjn8K+IY0pmwL2U4Kv/ 5Icg== X-Gm-Message-State: ANhLgQ1UdVfYomRpUHjab4P8R3EgpvkSHxlADeScB4/XAQiGuHNpR0Ub c1p2t90L3/8mxyTW4AHsvCXOm/oBvEi0BwfI3zL/ow== X-Received: by 2002:a37:b9c7:: with SMTP id j190mr1583102qkf.21.1583915225914; Wed, 11 Mar 2020 01:27:05 -0700 (PDT) MIME-Version: 1.0 References: <20200310205841.123084-1-michael.auchter@ni.com> In-Reply-To: <20200310205841.123084-1-michael.auchter@ni.com> From: Bartosz Golaszewski Date: Wed, 11 Mar 2020 09:26:54 +0100 Message-ID: Subject: Re: [PATCH] misc: eeprom: at24: fix regulator underflow To: Michael Auchter Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-i2c , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wt., 10 mar 2020 o 21:59 Michael Auchter napisa=C5= =82(a): > > The at24 driver attempts to read a byte from the device to validate that > it's actually present, and if not, disables the vcc regulator and > returns -ENODEV. However, between the read and the error handling path, > pm_runtime_idle() is called and invokes the driver's suspend callback, > which also disables the vcc regulator. This leads to an underflow of the > regulator enable count if the EEPROM is not present. > > Move the pm_runtime_suspend() call to be after the error handling path > to resolve this. > > Signed-off-by: Michael Auchter > --- > drivers/misc/eeprom/at24.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c > index 031eb64549af..282c9ef68ed2 100644 > --- a/drivers/misc/eeprom/at24.c > +++ b/drivers/misc/eeprom/at24.c > @@ -712,13 +712,14 @@ static int at24_probe(struct i2c_client *client) > * chip is functional. > */ > err =3D at24_read(at24, 0, &test_byte, 1); > - pm_runtime_idle(dev); > if (err) { > pm_runtime_disable(dev); > regulator_disable(at24->vcc_reg); > return -ENODEV; > } > > + pm_runtime_idle(dev); > + > if (writable) > dev_info(dev, "%u byte %s EEPROM, writable, %u bytes/writ= e\n", > byte_len, client->name, at24->write_max); > -- > 2.24.1 > Patch applied for fixes. Bartosz