From nobody Mon Jun 8 06:36:57 2026 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EA8A4A2E3A for ; Fri, 5 Jun 2026 09:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780650626; cv=none; b=rPGoEyn3M8h+s3BvcvBcLQ3tesWAz+Ib3q2V9d1C+q53kJdR/5KOvxPNRZtRZXrUbR/8UfPl+KzHrO3TsatRFqtTrjuVQ7An3aF7/+iih2wQZvfJmJci1FK4+y134QsoRZuev7A+X+p56x2d2KjjIuuoVNJUodgdSpzZgcfde/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780650626; c=relaxed/simple; bh=TN+eHTxvvsictDRYnCMOe3Qu306A72uP6lr108XfwUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VMWPFaB5F5Txabf2CZ1xVFE1tXS0KmxwS1fzvt/z9BuWjotn/3484UZdIMxHG5qnvdPLXHpwuAtzUAB21+1XN8h8IJIuhVohu7/caGlQ8DfVnN8dGEcys5X099kymGuVuLvOvOZE9TbgeNCscq8n0QWwEx3XsBrL5t8zVOly+oQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b/l8a5AI; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b/l8a5AI" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-3967726bc47so15942861fa.1 for ; Fri, 05 Jun 2026 02:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780650623; x=1781255423; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yhv+pKU2kF3hG29Q3S1s36oUyTDUZoZ+HjUkHkt6cXo=; b=b/l8a5AIYYZxaJR4200RtrBFj6NScb3h9dbZIG4d3ymEWz1w9BkmqZJgV4T2/7y+uL SdzIQ8tltmd+2/iiIlB9DhHyiU4t6L+v96sCNZf7YLvMyBSdPGofUxgSl9vfr5lK52tx HtnEO2lQm9qtq5ucNDRhrINNjPOusRJTEpvRTm7XHZhduTIh8hHcvDjeSc9EHtm99hGZ 46I3+7dHaEa3JEC968i49wozmQOVWI6sFyfWWSAfB74VfooakMSrd293HxwrfV0BoMHP qKjXaA5Ig/bqkP53GAC8Dm3n6vBC5+WTWFSo6MGvXmfgvcyIAxYu6qg7g3jdHYyo4tJh TJrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780650623; x=1781255423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yhv+pKU2kF3hG29Q3S1s36oUyTDUZoZ+HjUkHkt6cXo=; b=ZkAYKH78jdax69Ab9GCYSwWumzdyi1k2JofxlejsYFjFBcFHeRpkOZGuSCzybk/oFC BvU0KTC78TeeJ6PaDNjmhr/NConTgFlmsSeeL2P1PEjM43XXC8BAM7yYlzQ0k9fGqP+1 LNsbrtp6bhmnaJHkkt3WunyCji+UPAyFxjBDIB3UvkVz61HR2ySU9sIUAuIMJnjqmjBW e6XRgrf4EM949ShOamWm3IsJuvSJ5AIrV0f3LPkVwSaDk7LGozNU68EH2adnOTW2RvBN xScRwCcMUlUrbmY/7bNgvpoEXjqbpVVbhDPFGshejdvleIS+qJdj8N1JcebxjkGOQMrr 6KWQ== X-Forwarded-Encrypted: i=1; AFNElJ9wl1v6fuYlJJDS2rQJRAQ0On1qW0WzibZiYTABcLdTDIuvgN8EO/xgiS+ZDuyfWzP8yje1dBwAAhdFD3U=@vger.kernel.org X-Gm-Message-State: AOJu0Yyp3oLxunvLVxQfFei1oaUUskko0FrBjGHJ59Jge45ZzaYcvLkq 1OWt6Ny9jcfCnXFLk3yBtTvi2t/Q2ACCBMMW2pHa/bRx0p8RIuXVm2bq X-Gm-Gg: Acq92OHFodAFyUO8JM5WBg9IWqNjs+AxApxjRzcxaCux5apf7uJrphrHq0x/k+/qYeR ohxt2huBYm1oMffsdOcODdspVErYK3RXcnFLlltWuAna/hvSBtjUODZUElgsWM8+r2DggJn4JLP ZBuOMZBjCSUtY/xkjXOYdn+HLGrNTKI7mqZ+Woj1AmjkY91cNDQQmwmqT/u2hlpurJyjhetn3u+ 6cQ74OaIWx5XJP3Q4WMkYfRMfNAK+lto6Tn56IAXCOX5+Jw6Wmauzo/6tMXoFvCaR7nkqYcTh6t wJVAnVDYYmrRsUPOFnNoc7/cf7adejZJ9Cd+89BEMrZ+ViV8vDT/Sn3IHWpRTGzjNbD9C7Rwa3g PxKgz42Q1r1Hin31ti5qkLVckilIc3Q5D59BIvrlwq/lql7SZ8jamBcx8gtQSz9hXnQu4nLAQ1H /98nG/MXhY49TCkJOUkhapoEqnUa9LP4snfolN2Yrt/t+W5bpkCbtOzg== X-Received: by 2002:a05:6512:378e:10b0:5aa:116c:4127 with SMTP id 2adb3069b0e04-5aa87bd862fmr679527e87.41.1780650623083; Fri, 05 Jun 2026 02:10:23 -0700 (PDT) Received: from new-nest ([2a05:3580:f312:6c00:1b49:dfce:283c:7307]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aa7b9903e9sm1705914e87.69.2026.06.05.02.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 02:10:22 -0700 (PDT) From: Andrey Skvortsov To: Jean-Baptiste Maneyrol , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Marek , Brian Masney , Rob Herring Cc: Andrey Skvortsov Subject: [PATCH v4 1/3] iio: imu: inv_mpu6050: fix unbalanced regulator_disable() calls, when probe fails Date: Fri, 5 Jun 2026 12:09:38 +0300 Message-ID: <20260605090940.1103750-2-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260605090940.1103750-1-andrej.skvortzov@gmail.com> References: <20260605090940.1103750-1-andrej.skvortzov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" During a probe function after all regulators are enabled, runtime PM is enabled. Before probe function finishes, runtime PM triggers and disables vddio regulator. When probe function fails after vddio regulator is disabled by runtime PM, inv_mpu_core_disable_regulator_action() tries to disable already disabled by runtime PM vddio regulator causing following backtrace: inv-mpu6050-i2c 1-0068: trigger probe fail -19 WARNING: drivers/regulator/core.c:3244 at _regulator_disable+0x2ac/0x600 Call trace: _regulator_disable+0x2ac/0x600 (P) regulator_disable+0xac/0x148 inv_mpu_core_disable_regulator_vddio_action+0x3c/0xb0 [inv_mpu6050] devm_action_release+0x4c/0x88 release_nodes+0xd8/0x178 devres_release_group+0x214/0x3c8 i2c_device_probe+0x6fc/0x9b0 ... inv-mpu6050-i2c 1-0068: Failed to disable vddio regulator: -5 vddio state is handled in two places: runtime PM and inv_mpu_core_disable_regulator_vddio_action() devm action. inv_mpu_core_disable_regulator_vddio_action() has to check, whether regulator is disabled by runtime PM already. But this information is available only after runtime PM state is initialized by pm_runtime_set_active() during a probe. So inv_mpu_core_disable_regulator_vddio_action() has to be called only after runtime PM state is initialized. To handle this correctly runtime PM active status is set just before vddio regulator setup. Signed-off-by: Andrey Skvortsov Fixes: 07c12b1c007c ("iio: imu: mpu6050: add support for regulator framewor= k") --- Changes in v4: - update commit message to address Andy's comment about functions, callbacks and runtime PM names - move pm_runtime_set_active just before vddio regulator is enabled as it was proposed previously in v2. Changes in v3: - make patch to be the first patch of the patchset for easier backporting - update commit message to fix Andy's comment - don't move pm_runtime_set_active from pm_runtime initialization, move activation of inv_mpu_core_disable_regulator_action instead Changes in v2: - minimize call trace in commit message - include specific driver name in patch subject - move pm_runtime_set_active just before vddio regulator is enabled drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/i= nv_mpu6050/inv_mpu_core.c index 5796896d54cd8..8c8b4f9a8ff63 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -1862,6 +1862,7 @@ static int inv_mpu_core_disable_regulator_vddio(struc= t inv_mpu6050_state *st) static void inv_mpu_core_disable_regulator_action(void *_data) { struct inv_mpu6050_state *st =3D _data; + struct device *dev =3D regmap_get_device(st->map); int result; =20 result =3D regulator_disable(st->vdd_supply); @@ -1869,7 +1870,8 @@ static void inv_mpu_core_disable_regulator_action(voi= d *_data) dev_err(regmap_get_device(st->map), "Failed to disable vdd regulator: %d\n", result); =20 - inv_mpu_core_disable_regulator_vddio(st); + if (!pm_runtime_status_suspended(dev)) + inv_mpu_core_disable_regulator_vddio(st); } =20 static void inv_mpu_pm_disable(void *data) @@ -1970,6 +1972,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int ir= q, const char *name, } msleep(INV_MPU6050_POWER_UP_TIME); =20 + /* set pm_runtime active early for disable vddio resource cleanup */ + result =3D pm_runtime_set_active(dev); + if (result) + return result; + result =3D inv_mpu_core_enable_regulator_vddio(st); if (result) { regulator_disable(st->vdd_supply); @@ -2015,9 +2022,6 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq= , const char *name, } =20 /* chip init is done, turning on runtime power management */ - result =3D pm_runtime_set_active(dev); - if (result) - goto error_power_off; pm_runtime_get_noresume(dev); pm_runtime_enable(dev); pm_runtime_set_autosuspend_delay(dev, INV_MPU6050_SUSPEND_DELAY_MS); --=20 2.53.0 From nobody Mon Jun 8 06:36:57 2026 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D4A44BC038 for ; Fri, 5 Jun 2026 09:10:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780650628; cv=none; b=bIJ+lsDkK1OBFbNgk1R7KHEpQocSgQ638Jws+4AXbI0jf26Ikdhy/ROfjXAHK63MFFzge/SkHXknG79rx+BE7K7Ggs6p8g5DSOSlEUJhDPK64vSa+pi69vErKwvztDQ3lHfVOzUapavu9Vm6+SlwCOY8kUE/8PBpEWk2qALSLVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780650628; c=relaxed/simple; bh=cQOCyWEIALkdoLR3TrYUhtEyJOAoHDyTYq9GcxdQAAI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fgecZrceClGt07Wxxy3cUD6k8agqw6PIP1QVHxFzPbQw129MeNpGJBZwAbSrytb6VdH4NJcCcjPBdJPteMJnurG3cWVYFwh7wMiSbIrNNn34TRPVZYFl3KqFFq5E0CrTvv219egNwuNUZA7vRunh4jJzEzgTtijexeFXjxKecVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HuAmDL/N; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HuAmDL/N" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5aa68cd8dd3so1618714e87.0 for ; Fri, 05 Jun 2026 02:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780650626; x=1781255426; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=awNPDfMBLScbqNNAfmJZbvI6wRRhBZ6Yy/Wt1gz41bE=; b=HuAmDL/Ng3heZ0WZ1Re4JxpincnKp0EIFGD2wRz+K5BCF6eMofxxyrKV2aAf4NWGLY 7VCZ+vgu/REuenqOokTHZ7Uj4AgxDtcVHUrqaiKr3juOvXp92LM+7rAn16RH1Zb5v+f/ H8UiHQKW4iiDZYYr25q4ao+PfNEk8pJIw3NccGc8nnuknSXsKmt0aOE/CRICLC2vOxrG IAHbh/oV0al8wJTuFRQJOMzxBcj9APAV+kBT6qMaFRoKciBIL4+Sb7RVXAXVqOpbK/N7 UWrHCGNORC2Iqgn9snseqgMPJDKgMRAnyGWFIix5XtqCfXzgkF1cxaWFVGpq0HUkfZ7Q a0Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780650626; x=1781255426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=awNPDfMBLScbqNNAfmJZbvI6wRRhBZ6Yy/Wt1gz41bE=; b=ePQ42eKyCOL90i/Nud09qgrrJGv03EK7iAA3Y4880u7wtU+Bs2tE0ow4wAHDusPhXT RIRuofNcNBoMDfNJiIA0hhx2++/XJQWb26WFlURNHy1rM6zC7pdDxEAnZYFDl2YQPGVl cnZNY+WN99Djf/2MI4rBNxjkFdfYY9UFdbOJ9OQtVgBZYs+lihS2xf6TJGnVA8VEW2i3 PuIBo+B7GPykF3I+SUBaMCqEySnflAau+jGsvwpe8YKKBl3HiJwO6SBHHL2236P2yD/a ep1QxvSu+g+PT19G9Lt5t+CAl0jMXrNzeVE+Cbrq1evxDMGDrDflFKNfIgsx4PqYClyQ DUCg== X-Forwarded-Encrypted: i=1; AFNElJ9MSn4EtNeExNyw2bTDACtSPkPNaTtGRPCvXV/PZ+ZUgfYqtuparFlufOg/kzQUqCcqz2l2VM4LOhkAI6g=@vger.kernel.org X-Gm-Message-State: AOJu0YxBDiKywGkBUrx01KBt90bbZpZKOKgwk2oRWzMnU+8yExplo8nu qMGF05nY5hKN6DaawBcA+Q2llKjPNpaDm0UTJjNO/CtcgGenUFRwharY X-Gm-Gg: Acq92OE30YOQNGivtV7Rbydf9UvukCfn3cmQydabBJpUs1+dDM5rBwnm6UAfKBB4jkY qt5XBO3Ezd3MEZdqswHjYOZ9bNY58o8VuK0CyNvf+Om4T7aCbTZw14qa2gsfQTnwN1s//EQ7QG5 acCroyQIF8HYTI8dr1g7qiFZrF6IZ/DlTJt9nSE7IwL6EP81n8c5t6zNKPY6/5oKoNGtPkvR8mS 4Yq4hOWHArQebCRc7ti6Gnwu1p582d3giyxLeUX+yTKsPaftUCF4xaYchW7M1sxvuEgi75GPl1C hSHc3vv3sygQpMRN7YSMHe6XKAWy5g+SSCdKTDxlVHSRWfXTtGpB4bfjRHm2zkTFHNjYdykofCu 760NvJKuSGJEd8hgAcQX1h3KhN7+EooQRMi8KrUtGSXe5FUCfxLoIJGhB0KtXmhZxznv7b4pyhS +z5xuZBwFiTC220MY7pzU3sHVM6yJAgT0ruq7epYUGeis= X-Received: by 2002:a05:6512:ad6:b0:5aa:671d:9966 with SMTP id 2adb3069b0e04-5aa87b40683mr814399e87.6.1780650625403; Fri, 05 Jun 2026 02:10:25 -0700 (PDT) Received: from new-nest ([2a05:3580:f312:6c00:1b49:dfce:283c:7307]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aa7b9903e9sm1705914e87.69.2026.06.05.02.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 02:10:24 -0700 (PDT) From: Andrey Skvortsov To: Jean-Baptiste Maneyrol , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Marek , Brian Masney , Rob Herring Cc: Andrey Skvortsov Subject: [PATCH v4 2/3] iio: imu: inv_mpu6050: use devres-enabled version of pm_runtime_enable() Date: Fri, 5 Jun 2026 12:09:39 +0300 Message-ID: <20260605090940.1103750-3-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260605090940.1103750-1-andrej.skvortzov@gmail.com> References: <20260605090940.1103750-1-andrej.skvortzov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Usage of devm_pm_runtime_enable() allows to remove driver-specific action, that does the same as default action. Signed-off-by: Andrey Skvortsov --- Changes in v4: - update commit message to address Andy's comment about functions, callbacks and runtime PM names Changes in v3: - remove extra blank lines in "use devres-enabled version of pm_runtime_en= able" drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/i= nv_mpu6050/inv_mpu_core.c index 8c8b4f9a8ff63..6fd35ea5daabb 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -1874,13 +1874,6 @@ static void inv_mpu_core_disable_regulator_action(vo= id *_data) inv_mpu_core_disable_regulator_vddio(st); } =20 -static void inv_mpu_pm_disable(void *data) -{ - struct device *dev =3D data; - - pm_runtime_disable(dev); -} - int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type) { @@ -2023,13 +2016,12 @@ int inv_mpu_core_probe(struct regmap *regmap, int i= rq, const char *name, =20 /* chip init is done, turning on runtime power management */ pm_runtime_get_noresume(dev); - pm_runtime_enable(dev); + result =3D devm_pm_runtime_enable(dev); + if (result) + return result; pm_runtime_set_autosuspend_delay(dev, INV_MPU6050_SUSPEND_DELAY_MS); pm_runtime_use_autosuspend(dev); pm_runtime_put(dev); - result =3D devm_add_action_or_reset(dev, inv_mpu_pm_disable, dev); - if (result) - return result; =20 switch (chip_type) { case INV_MPU6000: --=20 2.53.0 From nobody Mon Jun 8 06:36:57 2026 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 163304C0400 for ; Fri, 5 Jun 2026 09:10:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780650632; cv=none; b=ZqmorxwP97smaujBqPQxcT+Uiqc7F0STQezUNkkKG4vfwnNSk+KpO3P/Ps2sQ513Aiv5WhpLE4hOL8tMlrHqgQEvjdG6H0WWm+b4XuZAmMoOQOpRnkvNpeBx21hWQOpSHb64YnM/vWXv/pjd+Eg3cLEUqXMCMFCuaOR1cXQiBYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780650632; c=relaxed/simple; bh=hAaX4OC0wXHk6GFCEy1dkXtnVAgO039C1INW5BJ2szk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PwJs7LXlmW9TONOlRLJVT52eHnFUgoMWJw/DsycSagjXJh6xOMNbyTOh8Q6swFSnigp73HpPlyq3+UKiKUHPpOkIDGBDctndJGN3uJ4z0oENJw9iUu4wo5fpKLhjtzWA5J4kYHeqreGhxgsyhq5FG+7MMmOt1m6nDL0f6/nDm0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oV4vJ/D1; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oV4vJ/D1" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-5aa68cf03bfso1638263e87.0 for ; Fri, 05 Jun 2026 02:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780650629; x=1781255429; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DIoCcj2Kf6AY0n+CP4wwAAXAkuwxiGksEj0rioxN5Eg=; b=oV4vJ/D1+jaQ5mZfpJUxKA/j+9+S0tkBUQZDl1Go0eV+epRK1XjOOs/do0BfHP2DHt /sAbV3gb/Hvi7QBNaWtOd5wML7tfhsVdE4sduqRQWM5wakffEjFcaAe5rpPjWN+5lXj5 E85lSeki58Q3kxFCeApzyFNjDNbKFXfsw/DVFkUdP4P1kN17eIHAtwdFjZo965X1N3l7 q9e2ZMWfLEKmCQdjNxEM9VVR/CWom8emby1GSSMo6lU5ZgbLjGoTObVAQye9cMO31pF1 vliYAjT7rT6/MyoAbO3BmfOseY3LXwR37ws741qklKc6pgMnuSvgOy8wpQL+nYYV1/Q/ GW8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780650629; x=1781255429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DIoCcj2Kf6AY0n+CP4wwAAXAkuwxiGksEj0rioxN5Eg=; b=RaC+M0nAz8xH0YPUu6FzTOkHk3xygdsNS1YBUozqW4wZEosV4Y/OVAuHHdiUSUhB/C yvBxiADNXMNtf0eO8Y5NnF2Ja2T0xsqdSBzwnifAapxbcPTaVAQGuZEYJrEbFiCPtO1B jb1CAg+o4vkLuQF9VI1f6eaD6WWkdGEmKJbwVRbHAXG1SqMmZHVn+YjZkgUcPLi9fci8 zerWeF/FxwT5Th+kmid98otcc2JDNu0Nwp4c4caIwv9fG2l25qC4BPQmwC74b9fxQY6c 5rISFZ/GqjQPw1sVHpqqzq4caeuE7WCSqQzgzzOUDIs4bnA8v67f6K3Kl8uciQHxMCtw z8CQ== X-Forwarded-Encrypted: i=1; AFNElJ/Cfh4aVzsWafeUryYc+w+43HXpWg1/RQAxm0Ku7SHV0hv66+RnlK+H+9OBh4IVuX2pIRipQnMFD4CVJ3A=@vger.kernel.org X-Gm-Message-State: AOJu0YymwwO7py7t3b5ho1hU8HqVpvMCnIZ72Av/gSHb3OodudovWcSH aZotN0jiDEnKvvHKI5Mha3Dyk1Wg5fDXm0o9je2QoJqaFxy3Og3Byq3u X-Gm-Gg: Acq92OFhfBAq8pv1iChwOUwyDfg3cQJPr2EFjSzD+9BjFlsMW48aDiU3UEKMhhzqtZM s42aOru3/tVl9JrxC9uOAt9l2/0+Z2Wd6UfLqljME5HB5eS6L6pukJXGVmshCSrnuyUeljJFDfY ZX/1Qgw6s2OeMM5PpVjMVvCq8bI2KZn/JLoGtq0gphB3HsVdE29a9pN8Rw2DZS1GgSMU6bfCocZ QdtuG2aLO4RBgIOla/TJXoxtdiCEt2xh6X8AZf9eWodLb9llgXDqZr+2RTgbQja1HGpJlg2n2UD gDUfgeZguySciJ29OYXOsPrNuuxOdNsyux5SQcAQNYh6Mz0yv0ZdsUbvSstYXQCTxOBTEwKJVwi kLzdsSAEKF4dTmfzZ17VhS9xYUPi1ZNBA+gYgCihktaKIV+4O4EiJsmlQImHenUkPu3k4W4ircj TMYdcebs5EMi83aXxaQZterDOYQfLJZj+qoWFcNmCuoac= X-Received: by 2002:a05:6512:1513:20b0:5aa:6cfc:a208 with SMTP id 2adb3069b0e04-5aa87b73157mr557508e87.15.1780650629249; Fri, 05 Jun 2026 02:10:29 -0700 (PDT) Received: from new-nest ([2a05:3580:f312:6c00:1b49:dfce:283c:7307]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aa7b9903e9sm1705914e87.69.2026.06.05.02.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 02:10:28 -0700 (PDT) From: Andrey Skvortsov To: Jean-Baptiste Maneyrol , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Marek , Brian Masney , Rob Herring Cc: Andrey Skvortsov Subject: [PATCH v4 3/3] iio: imu: inv_mpu6050: control vdd supply using devm-helpers Date: Fri, 5 Jun 2026 12:09:40 +0300 Message-ID: <20260605090940.1103750-4-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260605090940.1103750-1-andrej.skvortzov@gmail.com> References: <20260605090940.1103750-1-andrej.skvortzov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" vdd supply will be automatically disabled on error condition during a probe and on driver cleanup. Signed-off-by: Andrey Skvortsov --- Changes in v4: - no actual changes =20 Changes in v3: - no dead code in inv_mpu_core_disable_regulator_action anymore since st v= ariable is used to get 'struct device' now drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 23 ++++------------------ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 - 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/i= nv_mpu6050/inv_mpu_core.c index 6fd35ea5daabb..c170efce7d31c 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -1863,12 +1863,6 @@ static void inv_mpu_core_disable_regulator_action(vo= id *_data) { struct inv_mpu6050_state *st =3D _data; struct device *dev =3D regmap_get_device(st->map); - int result; - - result =3D regulator_disable(st->vdd_supply); - if (result) - dev_err(regmap_get_device(st->map), - "Failed to disable vdd regulator: %d\n", result); =20 if (!pm_runtime_status_suspended(dev)) inv_mpu_core_disable_regulator_vddio(st); @@ -1948,21 +1942,14 @@ int inv_mpu_core_probe(struct regmap *regmap, int i= rq, const char *name, =20 device_set_wakeup_capable(dev, true); =20 - st->vdd_supply =3D devm_regulator_get(dev, "vdd"); - if (IS_ERR(st->vdd_supply)) - return dev_err_probe(dev, PTR_ERR(st->vdd_supply), - "Failed to get vdd regulator\n"); - st->vddio_supply =3D devm_regulator_get(dev, "vddio"); if (IS_ERR(st->vddio_supply)) return dev_err_probe(dev, PTR_ERR(st->vddio_supply), "Failed to get vddio regulator\n"); =20 - result =3D regulator_enable(st->vdd_supply); - if (result) { - dev_err(dev, "Failed to enable vdd regulator: %d\n", result); - return result; - } + result =3D devm_regulator_get_enable(dev, "vdd"); + if (result) + return dev_err_probe(dev, result, "Failed to enable vdd regulator\n"); msleep(INV_MPU6050_POWER_UP_TIME); =20 /* set pm_runtime active early for disable vddio resource cleanup */ @@ -1971,10 +1958,8 @@ int inv_mpu_core_probe(struct regmap *regmap, int ir= q, const char *name, return result; =20 result =3D inv_mpu_core_enable_regulator_vddio(st); - if (result) { - regulator_disable(st->vdd_supply); + if (result) return result; - } =20 result =3D devm_add_action_or_reset(dev, inv_mpu_core_disable_regulator_a= ction, st); diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/in= v_mpu6050/inv_mpu_iio.h index 6239b1a803f77..2c0cf53c9a627 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -206,7 +206,6 @@ struct inv_mpu6050_state { u8 irq_mask; unsigned skip_samples; struct inv_sensors_timestamp timestamp; - struct regulator *vdd_supply; struct regulator *vddio_supply; bool magn_disabled; s32 magn_raw_to_gauss[3]; --=20 2.53.0