Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp131310pxb; Mon, 16 Aug 2021 01:31:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6RyBfbuzI1hLtjVRIpD1t5sZFjgXUNiTAWDz3AwgGHonRuF1Pcw94r7lHq42cBDhYDNYc X-Received: by 2002:a05:6402:402:: with SMTP id q2mr18954286edv.387.1629102718138; Mon, 16 Aug 2021 01:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629102718; cv=none; d=google.com; s=arc-20160816; b=x6RAubNX5YnhqgiQyVYYu3Fb1L8ANfA2FK5/oYSy6WKqkY5SL813ZBYwHMvMhaBRSw Nd8pVZk9o9/bb9rjsMM1RiNOBqn+QcFJmLweWdk8JgJVosTifaobOtkU6ThyU+lf59MJ mgYVLp0it6qgRMGD3hGIg6Qsndpvd6AHNjk1pDb1Ol1JqWF68VbKU4YRGHLOKCGyIYSK H/7RhBRAI/vE3PNGeoIIa5vgsxi1AFLnp8ceiuEQpihHll/A92fE0/1S8HVOG0Sg+JuK IWxbPyW4lyIUMA9zQIPU4AEfClFSyxMcIrGcw+32TtWMJXI76x2AATV4YvvC483jbelp QTQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5WMr44yPAMXR7U++aypQuBSuQpWu0zm/8yXjvAvdLxE=; b=iLDVyBthb9xa/to+NVcNPzndjX9VkFUyIgmSALCnzrgnmASRKeR2FZvKfb9UBAfkUF Za58WJ+IPU3CviA1N0Fh1ldMHGc2FudBWaHC/KNNpTtWoJmE/jghJzDaP7VJjZ6z96rV xWEqDsHmkfF0KtoNuIhQbFIkUkpr9eKoQXjzDVFvwLMpo2XJ4X7mCzZ3b8MrYKDBrjLN UQFNbBWOPbg+XWYiuVR8/AizgUzuL2K5Zr1AOt75nB6KaI0nY01MzfS1NqOO/YMJZIsw Nloq19bd2PQFBdmVAyvTiPUFbnWR8Zm71eD0NOR/bKr7kzxhni9us8zt4BRjIqnhTmxb HQ2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=H71IE2ez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u17si10281362eda.469.2021.08.16.01.31.35; Mon, 16 Aug 2021 01:31:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=H71IE2ez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234778AbhHPIao (ORCPT + 99 others); Mon, 16 Aug 2021 04:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234707AbhHPIan (ORCPT ); Mon, 16 Aug 2021 04:30:43 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 488B2C061764 for ; Mon, 16 Aug 2021 01:30:12 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id q3so21051999edt.5 for ; Mon, 16 Aug 2021 01:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5WMr44yPAMXR7U++aypQuBSuQpWu0zm/8yXjvAvdLxE=; b=H71IE2ezU7i4vmqOy956D6R5WpAa8yBdvbDU8iAIfAXbyEnWkCMEhWsUvjhbZ804YA XXS6ArFuaByhPuiNDhOYCYLkLmKkTbNm52h8CkLDrH0YuOPtAB5hzbCGCj96YKXdkF1m nHYsIaoaEP2jzary0gTK3YVSkVAtF9c9+zFx9CRfDtOz242ix3lBfcXtWdBUG2bXZqMZ SvHkWWW0JyUjiPXcccExKr5gT7xBgwH9cCSN/juFUTKn4JtjwIbBjH2yw32VpdWmpCta 5uWN/fLc440JEsT5KwvQdrMHf23zwmY8oqQVLiMyhcOoWpH5J3GMA24mA6qpd3g1l2gR JTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5WMr44yPAMXR7U++aypQuBSuQpWu0zm/8yXjvAvdLxE=; b=m7mO70cPfFCZcVUbi8Nxm6FGxhb5pTCgH0HgmvdbiB7PRocCWi5QDkePPftRpb0AgP qGgia+UKiGHu++fNRsbdgq3kErtHYB3fzyS9agfGRLZiw0T30G2Kx/RlcLarfK9gfoYO POdzRAqky9bOTUoRW4OMRc5UVwj4LqWijPgqcJQLcnmu+rpKjgqK0s/yftFozikjemlC eoPtuqlSUERl7Tp0DhKmQB2MsjmwsoaUSlwWtdUKw3WyLbTYdlGUIOwdSNSiJYNfWzgR 52YqPusUoZoh39fP/H+UeNsELJb5k9xGdq8cWIuEoQ/s52Zsq6QNdLY8l+PkMNtFgF2N icsA== X-Gm-Message-State: AOAM5324xtcG8okTXNUoncG3w9MpZ+5LlnYyW61oDKTijjb6kzpwIjD9 jaftbiAPsIKn8SAX9H04Edrxzw== X-Received: by 2002:a05:6402:17d7:: with SMTP id s23mr18483271edy.344.1629102610960; Mon, 16 Aug 2021 01:30:10 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id q30sm4516878edi.84.2021.08.16.01.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 01:30:10 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: denis.ciocca@st.com, jic23@kernel.org, Alexandru Ardelean , Lee Jones , Linus Walleij , Andy Shevchenko Subject: [PATCH v2 1/5] iio: st_sensors: disable regulators after device unregistration Date: Mon, 16 Aug 2021 11:28:32 +0300 Message-Id: <20210816082836.67511-2-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210816082836.67511-1-aardelean@deviqon.com> References: <20210816082836.67511-1-aardelean@deviqon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Up until commit ea7e586bdd331 ("iio: st_sensors: move regulator retrieveal to core") only the ST pressure driver seems to have had any regulator disable. After that commit, the regulator handling was moved into the common st_sensors logic. In all instances of this regulator handling, the regulators were disabled before unregistering the IIO device. This can cause issues where the device would be powered down and still be available to userspace, allowing it to send invalid/garbage data. This change moves the st_sensors_power_disable() after the common probe functions. These common probe functions also handle unregistering the IIO device. Fixes: 774487611c949 ("iio: pressure-core: st: Provide support for the Vdd power supply") Fixes: ea7e586bdd331 ("iio: st_sensors: move regulator retrieveal to core") Cc: Lee Jones Cc: Denis CIOCCA Cc: Linus Walleij Cc: Andy Shevchenko Signed-off-by: Alexandru Ardelean --- drivers/iio/accel/st_accel_i2c.c | 4 ++-- drivers/iio/accel/st_accel_spi.c | 4 ++-- drivers/iio/gyro/st_gyro_i2c.c | 4 ++-- drivers/iio/gyro/st_gyro_spi.c | 4 ++-- drivers/iio/magnetometer/st_magn_i2c.c | 4 ++-- drivers/iio/magnetometer/st_magn_spi.c | 4 ++-- drivers/iio/pressure/st_pressure_i2c.c | 4 ++-- drivers/iio/pressure/st_pressure_spi.c | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index f711756e41e3..cba57459e90a 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -193,10 +193,10 @@ static int st_accel_i2c_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); - st_sensors_power_disable(indio_dev); - st_accel_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index bb45d9ff95b8..5167fae1ee8e 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -143,10 +143,10 @@ static int st_accel_spi_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - st_sensors_power_disable(indio_dev); - st_accel_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index 3ef86e16ee65..a8164fe48b85 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c @@ -106,10 +106,10 @@ static int st_gyro_i2c_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); - st_sensors_power_disable(indio_dev); - st_gyro_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c index 41d835493347..9d8916871b4b 100644 --- a/drivers/iio/gyro/st_gyro_spi.c +++ b/drivers/iio/gyro/st_gyro_spi.c @@ -110,10 +110,10 @@ static int st_gyro_spi_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - st_sensors_power_disable(indio_dev); - st_gyro_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index 2dfe4ee99591..fa78f0a3b53e 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -102,10 +102,10 @@ static int st_magn_i2c_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); - st_sensors_power_disable(indio_dev); - st_magn_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index fba978796395..ff43cbf61b05 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -96,10 +96,10 @@ static int st_magn_spi_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - st_sensors_power_disable(indio_dev); - st_magn_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 52fa98f24478..6215de677017 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -119,10 +119,10 @@ static int st_press_i2c_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); - st_sensors_power_disable(indio_dev); - st_press_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index ee393df54cee..5001aae8f00b 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -102,10 +102,10 @@ static int st_press_spi_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - st_sensors_power_disable(indio_dev); - st_press_common_remove(indio_dev); + st_sensors_power_disable(indio_dev); + return 0; } -- 2.31.1