From nobody Fri Jun 19 07:48:48 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.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 B89C8E555 for ; Sun, 26 Apr 2026 11:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777202682; cv=none; b=buMJmld/AUXIo5jH3Gg+ttGYNkpcIbk1miEZ9qTEHWW/NEoADIpN+7uTjLgGL/ZJvniGV3DRQWgfr2TbSNuVpuxgcC8sam1GfsWb2lq40e6MNcfkJABOhjVJQOM3MeRHWH5uhGOaUUAJ4dCGKS5EJNR9+MG0a2dIvGwqMBYZfGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777202682; c=relaxed/simple; bh=/jmB0fipwl8okFB2Vmucadgw0UcFEpeu5ZevPPsDyIg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NEuh2pjmMlsCvW2m0iqC9Pq0M3HMJbgdrmGzyTvZU4Ldcgdk9sVYCaKTo00p+XhP6nXYQ0sZc0oTQYAdqmxWbpINnstBil6QyKBR08HlKZHwGFcvZbbV9OjEUxg2LsH+ARw5ILuPq2hBpZipFVBvUakoyACj6dx1a5rT7lEOwHA= 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=fnUXevz9; arc=none smtp.client-ip=209.85.221.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="fnUXevz9" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-43eb05b1875so5385307f8f.3 for ; Sun, 26 Apr 2026 04:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777202679; x=1777807479; 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=wz1CIrJzu+0kl09RZSfojpdkCNsJ2tTjzUAFrodJSzI=; b=fnUXevz9mAyz1nq5vTa7976D3x684OZUY/EHfoTTR1jbn8U0ZoixnLR2QtSira48F7 4TU4TRwDDqENNNRNNab5WSteKAOzkW9X0auPQk8bg7BwYtrKhv7AIXzUaE2c4DA70dxd MKVCyqBfRk/bepU2HZA8XgZ2NdsiTLkrywexdE9ThJ5YcRiFtdjRbdweGA+mxODzUotE wn2z6OxGHMF10GZpvoVaPCTkEY2UMXyudyym3FnBV7SriNzKuRBLPuXWc/GMZjdHlsCN k4fBj6OSTV85i9qSPUI8vAer8/MI7aQUQqVJpY1xK1yPMJ24vmfWtR4sWHZhgDX5fUTw 4N5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777202679; x=1777807479; 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=wz1CIrJzu+0kl09RZSfojpdkCNsJ2tTjzUAFrodJSzI=; b=tQYvyY+tFC14YLiONpCbXZGys9/kdv99ZONIdYpTM6dKgGqYnYcjpVWxBfeCm5VGqh 7vkFm3pMX7tc5w4sfzhOqwY1UffnQb0FoRM/CyTq/hCRhKQ46YzNKTH49XjJLWbRw0up wTcG4Q+3/iAJdMP90pDWmyyLvABXtLHdiEzgXsHVi0VjZPHq3zvpu5r/OG/SCcNYC368 hyKlqAzowBcW1s9TRUWVAb7lTGAj/yfF+m35OXIiaCN+IqMKfSW+DzLvqFjKiatOS0hF C4YZ5ygyukwVn6qe0LbbuGcMdHET7oRag/96iAhI+SViBMgOnTmhpNGv6AgI6BTcUe1g PV6Q== X-Forwarded-Encrypted: i=1; AFNElJ+UiwPeArsuVW2wE8xFhkuLJy5ZYMsX/uGBfP6dsDaNylELC1Rmd95N/F7Tj2Ob4NEo2xzyZTXGBuDPz7I=@vger.kernel.org X-Gm-Message-State: AOJu0YxGdZfCB00SrubJJhxuHAAKjNoe4PUfQ8ed8cbkdo24xgwhO22U 7nGeC8A+2cSJbKmUk45UvN95FAd9Kwhmv6H+06Qb2ZasOuKyvnT2nxRx X-Gm-Gg: AeBDiespVHCsTI9rv3U3nmsIHPpI/YyFJdsrgHLJMM7bETM0GrMOF6FnsFk+TJoBW/K ev9Ep3YbnEDkn30Bkmh+8PU7SWQuJ4zb9kOIsenqCfWBUg8rTxxnq2eqGa0G1SkRAEdDu3HjCRv MwGgxLybzmasTllj9QRIuJ7Ba5Krjm6GB4V89gPay406NYgMVWYF5rJeihX7SYDLq58/FZF02p4 7qAv3DnG7d+Uj9rpzawPfs6WXUwEPqDJ3KJrDGLyNIQFN5J5s/RxreWBglBwN+ZglgkZzbmDa14 AiHtlqwRgGHy47a5NiwJSiJbW2WfnBiveG5wSEcv3aDBSK9trip6zr00PvIodp7U+Spb5HdVGRn kXOgVrMOojUmRW6Qo38leP7UAUQvadMixHqguP0tHMD/DrOzBKASb6zl5VF2N9d6gTQ/DOUDWtL U/TM31PGVP8Fnssx/atuoJkwaPXWcK6puW/kX9 X-Received: by 2002:a05:6000:186c:b0:43d:7946:badd with SMTP id ffacd0b85a97d-43fe3e0be7bmr60192582f8f.35.1777202679120; Sun, 26 Apr 2026 04:24:39 -0700 (PDT) Received: from new-nest ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44123d23e0bsm33285999f8f.15.2026.04.26.04.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 04:24:38 -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 v3 1/3] iio: imu: inv_mpu6050: fix unbalanced regulator_disable calls, when probe fails Date: Sun, 26 Apr 2026 14:23:32 +0300 Message-ID: <20260426112334.3938774-2-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260426112334.3938774-1-andrej.skvortzov@gmail.com> References: <20260426112334.3938774-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 functions 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 that, 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: pm_runtime 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 pm_runtime already. But this information is available only after pm_runtime 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 pm_runtime is properly initialized. To handle cases, when probe fails before pm_runtime is enabled, explicitly disable regulators in error paths. Signed-off-by: Andrey Skvortsov Fixes: 07c12b1c007c ("iio: imu: mpu6050: add support for regulator framewor= k") --- 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 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 25 ++++++++++++---------- 1 file changed, 14 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 5796896d54cd8..49fdf33adec99 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) @@ -1976,23 +1978,15 @@ int inv_mpu_core_probe(struct regmap *regmap, int i= rq, const char *name, return result; } =20 - result =3D devm_add_action_or_reset(dev, inv_mpu_core_disable_regulator_a= ction, - st); - if (result) { - dev_err(dev, "Failed to setup regulator cleanup action %d\n", - result); - return result; - } - /* fill magnetometer orientation */ result =3D inv_mpu_magn_set_orient(st); if (result) - return result; + goto error_vddio_off; =20 /* power is turned on inside check chip type*/ result =3D inv_check_and_setup_chip(st); if (result) - return result; + goto error_vddio_off; =20 result =3D inv_mpu6050_init_config(indio_dev); if (result) { @@ -2018,6 +2012,12 @@ int inv_mpu_core_probe(struct regmap *regmap, int ir= q, const char *name, result =3D pm_runtime_set_active(dev); if (result) goto error_power_off; + + result =3D devm_add_action_or_reset(dev, inv_mpu_core_disable_regulator_a= ction, + st); + if (result) + return dev_err_probe(dev, result, + "Failed to setup regulator cleanup action\n"); pm_runtime_get_noresume(dev); pm_runtime_enable(dev); pm_runtime_set_autosuspend_delay(dev, INV_MPU6050_SUSPEND_DELAY_MS); @@ -2114,6 +2114,9 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq= , const char *name, =20 error_power_off: inv_mpu6050_set_power_itg(st, false); +error_vddio_off: + inv_mpu_core_disable_regulator_vddio(st); + regulator_disable(st->vdd_supply); return result; } EXPORT_SYMBOL_NS_GPL(inv_mpu_core_probe, "IIO_MPU6050"); --=20 2.53.0 From nobody Fri Jun 19 07:48:48 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 41D2FE555 for ; Sun, 26 Apr 2026 11:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777202690; cv=none; b=DENQEF6es84jWI9ZlmE/p9Z2watmGzBaALw/TGDg7/8kuPdE5WI0cQPV/EAZRbZ7iGb+Of1XEREU8ufmyUiiW8DEGSOlYjiTHiRowSVQ+xSaYo9H2Heoid+heu045yn71ZXlJlt/59vwIAkTVVElGPSd4rtqtF1kYqTD0u8gw8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777202690; c=relaxed/simple; bh=yMNm5zjOxUykvv4PaPRt8aNP4Hd4KD43T5gTpHm3H6Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LissiZYU4/e1xpxuLzIppzqrA4FgqNKEYV8r+nt7aUb9N8353QKLH6IAV9rGtmT+8V23uFfnxxu8tTkPtxIq98M7RZoOiEpHK42oT6GmMC6qYKqti0ar9jizw4/aHhg0amnK8W+l250hQA5dia/d3ZSz+bK+b+DtkQCQU5zOh10= 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=BL1cJsVR; arc=none smtp.client-ip=209.85.221.54 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="BL1cJsVR" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43d734223e4so6309460f8f.0 for ; Sun, 26 Apr 2026 04:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777202687; x=1777807487; 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=Q6unAoYNjYf00ljt6zTAD3QYR+yt3cVTnuHzBTrptS8=; b=BL1cJsVRNXfNySL6dAlIQabv19XABjtZn3IxjdAN6wqvAxuUsk9wM4BO4TO2f/PDsn i/1xV2kuR+ywF+aWEp3GwiiQPSICcz7DWmCyVZNAx2ybIZhoAwigCJcQ35WMFqT4uVct H2QAPe2iDaZP7fH4AKxOR1ggq/iQ72vWs6Ohz0Z0F8OBxanxDJ7z+eNUyM1MLobUiHSV BwLd6cqBjBReurMMk+ersxETOaXAWuVaqGsWg/S2Esz1p+n1FdHo+3keLFuUTWBv51VF /jbT+KznoRumPgs/DDeARRoe7uF+3bqVTDglKKZiUFioYZKamrrOLTGIUJTdKis20i9a O89g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777202687; x=1777807487; 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=Q6unAoYNjYf00ljt6zTAD3QYR+yt3cVTnuHzBTrptS8=; b=d70hOGCvWVd7qeeI3LIEYjJCl3+iT4X92Y5F53EUUY2cC38Tj7Y3wf41wksVYFbeq+ de5IdJSn+y1UGymLRzOIsFb7Zuo23RFfRuA2mcgUTkUYgFhUlV+Y1SII4Bj/pp2fp/vR +wNWk9rvEsvjoZFfh2Ocxn0Wnw61BxZs0JoV8Oy/4w+U1B1cRCVfnjF5B8go3U88LsUL Y+faq/CgPYzbgK2+PMgBLdZIQNyUxH1laSk0k9JdgA+oiXVqRzKZkBIetMTDbABT0acw CqeMdg6GjnV6xYobOIKRq7ZMNb1XsLk2NyItDwc/8SpwSDgbJCIZBM5tDP/uQSGwD8Cs TJww== X-Forwarded-Encrypted: i=1; AFNElJ+a2qCJvwT7hBXoHjV8/N+FmUiZm/z5QpIB7n7sAMIjKsTm4oIDbeVFJ7i0YvYzxQ6CR+8CIpiBfZjaIHs=@vger.kernel.org X-Gm-Message-State: AOJu0YyIGKMtKooqds2ENxwMDRdqtOyJWBbJPOaCsSVVCIdjQ/OH4yu+ 59yeWUq7g3PtkOe3B2C4KiFvL8JtDcv93BMxd7BUPkDMedjo30KP0uqB X-Gm-Gg: AeBDieuTDptIZ1HdruRxbcW5l5Wo030BgzircT3IM8VE5cWXmq2D2VIiWQ8QoV8I8OP Z7deYMVj08bwbgVw9+31RhpOwnNbNUNlh4nqtg17nVMZSxZpd0KS8gctKhCWl3XIwP0nE3y3vDv 1d4PiyTL/lsa5sBkJ787KxdmCwYbF121Y3DBn+UIMgHALjRHmC8/PDiUEu3NPvmQyClb2UiVCAx NuyGGEaRo6EKK/gn0PpmFziUB1XwifWsxNfztJs2f+OlnbBzwVA2oASobkTth+XnaYq9ZrnZJJi dmVFyzkpUiwDkgqZxv5xlBuEJUlglUlDaLZCKZafeg5RnlgtSaDsHwT7MOgg3uBupyx7ENoitKy gk4Wwz54u0GMGU28TzCiHFUB7Y9l44y2M7plWs4ptEdBP7OKNaSZ69n4NBQuHGT2Ew8bClXTsLP wYrIbP+2As/YDNZizw3KWojU9NaAI2Q6PqHSYr X-Received: by 2002:a05:6000:2305:b0:43d:78ae:b785 with SMTP id ffacd0b85a97d-43fe4087e78mr63912555f8f.21.1777202687198; Sun, 26 Apr 2026 04:24:47 -0700 (PDT) Received: from new-nest ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44123d23e0bsm33285999f8f.15.2026.04.26.04.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 04:24:46 -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 v3 2/3] iio: imu: inv_mpu6050: use devres-enabled version of pm_runtime_enable Date: Sun, 26 Apr 2026 14:23:33 +0300 Message-ID: <20260426112334.3938774-3-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260426112334.3938774-1-andrej.skvortzov@gmail.com> References: <20260426112334.3938774-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 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 49fdf33adec99..fc786aaeac5e5 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) { @@ -2019,13 +2012,12 @@ int inv_mpu_core_probe(struct regmap *regmap, int i= rq, const char *name, return dev_err_probe(dev, result, "Failed to setup regulator cleanup action\n"); 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 Fri Jun 19 07:48:48 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 F06F435AC12 for ; Sun, 26 Apr 2026 11:24:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777202693; cv=none; b=VFdkX00OGWHrqBYjra3AyKx6pWQCQVdxQRm1xKFTQu0rGr4g9peX5Nrv+A0HXs8m/7ZwXNEeVGTNYQavSk+P/9xjIfPr8pi6ZkhDrVLBRYIXE1LG+EvjU47JSXZDnBnI/hrdJBtuUh7qUJCNB5P1rBx3tAYd2FT1E6Iun9LMOJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777202693; c=relaxed/simple; bh=cth7IxMx4vL9wP/1C5eXMoW+1v/9cyIj7UCsykLIt3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H7+53k/C8ZyMLc/zC80XkTU86331H7z+QEkJ4yEBwnTq/8k9euSldhsjEecarRy2eXqxKHdQzoXmG3M1ifaTwavwTSkYHRmgwenmI184dpdAeGnFNfr9br3jvU3k6MiB4uR+8a4cIfyAR2yAw3h6ml4vDCgyEiAV7Xc6mONHMAM= 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=UMfv58lR; arc=none smtp.client-ip=209.85.128.45 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="UMfv58lR" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-48374014a77so121886455e9.3 for ; Sun, 26 Apr 2026 04:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777202690; x=1777807490; 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=DEYBGn4RFp3NqRbemrgiMNi+WUGjPXcEfhUYRQfZnUo=; b=UMfv58lRbShEXUOz946BRsy3PsJ80lcu969JwSRVziP38l6G/ZvrRsfFEVCV2sLMmF n9Ynfu6QwqYiWU5q5WJ6i7KgFns+yjfZo63IuPlR2ACcnllzntJmFrOdUUL3kmOGPB15 qZjG3DjDGEKeW3hzy7DmwC/+moU6tfaW7CGwyTDT8TWTCfv7Wdc8WOWUYT5ejBrqQq48 2/q7zK/y7vQCPap7iZuBO8eBDDkbj2cJi/0DMYlhz44s/WDv04uVoglrRnMTcMhoyJDM Th4MLKTkV4f/8Foy5L87bTYX+MNhEy7WEc/Izoopa/nvijtcsdnq3Ojdzc9J3YQXggkd qViw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777202690; x=1777807490; 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=DEYBGn4RFp3NqRbemrgiMNi+WUGjPXcEfhUYRQfZnUo=; b=chNk9QO9Ayp6qpcHW4iC+8EkFw5rI85+adSD1Uy/MtmKIb/BOd+9av/tcvRb0cetnl V7IDqjAYvXeXyYGCCaSR7M4yqMREo5PgiOaLKmlwfU4QcztdFrLIFIYSdcGTRrtO6jF5 yyJSDfbTh05rWohIgDU+CFouDpmwRUdc1vF7pBII9tJbgeVKhOYJFkH3n2p7SvlbtjSU 99Q6836Pr70ygnmlDDiZdsFxQzND1TtW5jKGfxa/nWoLGxArdN01OoLyuBJCyjVuE4eN 1c+MH2f8XriyJrwHtGtjsu5CT5/UCqJ6bFn9bWc7fpZGqAdyxF+jPf6f8sPfKqiRmA2t tJww== X-Forwarded-Encrypted: i=1; AFNElJ/osF494tkciQPxKWvNyA+Zzf562CyE2hQcTMTKbr4G0fBzPPBO3Vs1sm54b8ox2fo0DMGJksfKmII15Fw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9KFsfXuuXoOcC5SHHz0wJR6nPQt0IA1bHNOWqN6PwwKPUVLrE gBWDcQ1NQ14Wut9Gc2RXQZcTrIijvHLApXVIXZ4BNr1gIoNNBCOAPh3c X-Gm-Gg: AeBDieuna7u58rQf/nxzlDjuTNAS4ycPJtAZzUKXXGgHkhiVnZ0xDJBhMXKoZB0bZe2 R4SMvQx4PA4veSY+amYtQfksqz39fMmGSobUPaWelEJEIHLaO6zZ4y0gyM1Me0WYZ/GtlgNeMnW YC6SsPFuZH97Kc05EpQt+BzXTtN05Ke1w4cEh+uObgfd/jVJb/l26Vd2I4GWODJSAsq0AOjEjEy CR5CkZaXfJfd+7XapiRtZQJMm0QlWNkKsO5J6dmWEs/vsF2Rctn+Ta5lOhqCW8C2KhmEskU8UPf J53T0epjl2HyRL+/Q1ZPGNSyHkhxQyvsisfsib+y2rR2HklhbOlfKjt4fKIKml+62vO51GYwV3b 5LFHsfxjDhMU2ebb+Bg/D2Bk6S27VIkW2cBwCzh9AM/Qok7ZiSCXIm/XmQ4KCsIlijQShVs22nD X81ExRfAO7ZTLN/LJRiYQIhWq+cjyTUMfyjnHF X-Received: by 2002:a05:600c:8b28:b0:48a:5c23:cab with SMTP id 5b1f17b1804b1-48a5c230e78mr267530895e9.19.1777202689993; Sun, 26 Apr 2026 04:24:49 -0700 (PDT) Received: from new-nest ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44123d23e0bsm33285999f8f.15.2026.04.26.04.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 04:24:49 -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 v3 3/3] iio: imu: inv_mpu6050: control vdd supply using devm-helpers Date: Sun, 26 Apr 2026 14:23:34 +0300 Message-ID: <20260426112334.3938774-4-andrej.skvortzov@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260426112334.3938774-1-andrej.skvortzov@gmail.com> References: <20260426112334.3938774-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 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 | 24 ++++------------------ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 - 2 files changed, 4 insertions(+), 21 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 fc786aaeac5e5..880bb7b8b83b1 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,28 +1942,19 @@ 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 result =3D inv_mpu_core_enable_regulator_vddio(st); - if (result) { - regulator_disable(st->vdd_supply); + if (result) return result; - } =20 /* fill magnetometer orientation */ result =3D inv_mpu_magn_set_orient(st); @@ -2108,7 +2093,6 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq= , const char *name, inv_mpu6050_set_power_itg(st, false); error_vddio_off: inv_mpu_core_disable_regulator_vddio(st); - regulator_disable(st->vdd_supply); return result; } EXPORT_SYMBOL_NS_GPL(inv_mpu_core_probe, "IIO_MPU6050"); 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