From nobody Mon Apr 6 18:22:53 2026 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 F02692F547F for ; Fri, 3 Apr 2026 08:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203593; cv=none; b=SPNO06yLA566dd3P18jvgCDbYQJe8xCaPbocXuOaEYzGtzupUx6kWim28q1c0KFsqfMbYU6oxlVvbMJDhwOOpzyTT020DDk9HobyEccRqTqqwOz1vAV5Qq5ODEJFSbvZ3xWJY3M3SCfJQB/Tznk02PQI6zwugDuXY5DhtTq+MIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203593; c=relaxed/simple; bh=ct7uGHPjqUnB8e1rthoWoDqs6UOvFlQbDqGPqVutLkM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o+xN1plOXRk0zxkq+or62Z4I+iuPXwOyV1WT19dskmj0NDZxlfRp67wUE6b2Zq4m/IhKQrxPVHLzF4GtFLV5NPCtdwY2vAdxFRIxpKAIVRhwRgHQIVzecIZZCNkSyK8jyAILdMCohAHdLzjkJOBuzckBe/TABy4zr/jhKLfZIqY= 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=VxW/06aT; arc=none smtp.client-ip=209.85.210.170 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="VxW/06aT" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82cf636dac8so768931b3a.3 for ; Fri, 03 Apr 2026 01:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775203591; x=1775808391; 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=zkOUIY36rHh+B06Th/hdhTi/x0+53xtFclztLcGxX9g=; b=VxW/06aT+eEfixwL2/Q0Zl1b5UFCn8wP9bQ15olD7YrAjFw608zJ7FsAMVjROkGMey FqJS+lLki2WbdKlOUKKdqnCpok05+UYvYyw6ff5M818Fb2etvA5aSb8hVHby0oHAWIYO g5ryJjrQPWn5JCVUE4UOPDxXI2bHZz8JUVqh7k328k2vTFfktPgjPdMJM9sf4kROWQRL fmgv+9JwccSsucCqQJMFjr9SxMTz+PYtxWwKB7JGbPODTJePjJ+Emz1JFGVZYx0p2qtg OVd8mImodmBIuazNu9NNA4ATtBE8dYIk0+Ez0xlugLvrGiAiTVmHsT2eQWTipbhfZR0M 4ZBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775203591; x=1775808391; 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=zkOUIY36rHh+B06Th/hdhTi/x0+53xtFclztLcGxX9g=; b=lS4VSFmtwY5F8IwAfCG/XIA49OkCFZjSM4txXcVoRKd6mOPgLfmyLh1jSylWV69QeB zHrx5zn5OP7GjKzyiPnT8Acn1o4DccD4XSsJeUfUQGB0uUm6bAUYQV/31vO5/ho222dw NEf+JCvtA0TrT3ptENd6AxArFGs09i7N0L3GwKl+V5XB7Urgmxst/0S95zSG2j8PEzUe OyW//h4Pzw/1X89Wxf8WyKPUMFEgKuSKzr/Jva9tRTS0fg4M1KEf9paY30w0lw0++fd0 3d8oVlc6SqsOm6y1rP0fQT5IeWcCTlnrHat5jjlHbDHtvduOh6HyDHnpXUAOkv2T2GIz MwaQ== X-Forwarded-Encrypted: i=1; AJvYcCXIYBGoPMF/dTM7uFWzZ+fX/ESsyS3I9a20HAH75zNiS6YC+mMMMvlBHuMhDi2UHvvAxnt1RUPN61LyCHc=@vger.kernel.org X-Gm-Message-State: AOJu0YzpNsRzq6tgOpORaWIkKh4CsHibWUtuDvWbS1CJSJaL+wli0jUH KuzdpvEENjc+w802hriIooNmNFrrJnmc2zpTw5bRGdf6BVBcJ7s8dtIw X-Gm-Gg: AeBDieuPCFcLjGGZCU8S7NomNuQOJZgglN0YKydjGuzihM7nexQGzq7857H53epx7Un sX2d+0E75Xq4VBJPCnCmQsJiFZtaZzAxOOVhKp6uRgIwiaIQWn/U44QXCc3yusTE1VOW4r85Wxh McwRRm/JIKezBanRGqfsSB5EqZMO/NU7CwHvA91DQNtPPxIk1vCCBldOAPbAJTFNvwBF9k81GgT 5fvzRhW3cqft7VWzGp8s+95lwJA1wDjCs8atefVpnD/LsCGC4nSqkRAkuc0sX8539q/93KNky/y h4jF2F+xcscPVN5/LgZUVoNzXcGME9sh1I3Nf4T3GxZYUhp2tGG+Ah+SbYCetUCKOlOEvrbp8AT hdBGZ4R8RfseCHx8Cq9d3sShon/vk0uKz4EuKXHC+DsuG5cLLGXzjVoaV5RlCXoPCkTtvOmqcKJ +ZGuj1lZ4N2pWQkmG7JAF/dF3r6LHcZNyLcpZwi3vYQufa+0qwxa96x2D9nibP9cL+dlZdT7KNi g== X-Received: by 2002:a05:6a00:3902:b0:82c:9fe1:aa4d with SMTP id d2e1a72fcca58-82d0da6d649mr2238540b3a.13.1775203591258; Fri, 03 Apr 2026 01:06:31 -0700 (PDT) Received: from debian.ari ([152.58.181.253]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9c6ad8asm5481093b3a.40.2026.04.03.01.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 01:06:30 -0700 (PDT) From: Archit Anant To: jic23@kernel.org, dlechner@baylibre.com Cc: lars@metafoo.de, Michael.Hennerich@analog.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Archit Anant Subject: [PATCH v7 1/5] iio: adc: ad799x: sort headers alphabetically Date: Fri, 3 Apr 2026 13:36:10 +0530 Message-Id: <20260403080614.14213-2-architanant5@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260403080614.14213-1-architanant5@gmail.com> References: <20260403080614.14213-1-architanant5@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" Reorder header includes to maintain proper alphabetical ordering. No functional changes. Signed-off-by: Archit Anant Reviewed-by: David Lechner --- drivers/iio/adc/ad799x.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 108bb22162ef..f37f1fda2dc4 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -18,23 +18,23 @@ * ad7998 and similar chips. */ =20 -#include +#include #include -#include -#include +#include #include +#include +#include +#include +#include #include #include +#include #include -#include -#include -#include -#include =20 +#include +#include #include #include -#include -#include #include #include =20 --=20 2.39.5 From nobody Mon Apr 6 18:22:53 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 090B430B514 for ; Fri, 3 Apr 2026 08:06:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203599; cv=none; b=t8zKWQ1eFtN54onwdXaIHgKXorinSTj5AFsSED/Ejm9UoohZmdoXxqESuikTHvjoI1VRzKFCkvBVCVJrf+w4VVcmU/Vj0FKg1iRHPxhXHCUhGtVBykgu4b+LWqgK+Av3KgunFllG1fNo08e8tve32mK/mXoaYkb85CVJy1VkIvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203599; c=relaxed/simple; bh=Lf5g+RN+RFRx5DSamfvVjA0BW8eDenTuDrgfdqstkA0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JRGhnck4MCJFWdkFfM5HlEZ1HxMZHw0ZI/kQ7fk2bdC27T33XqNFw5cBq6q3b4Z5sFi2v7iK9MscMN3sbiM/IHwPvpN7Rwv34vWSsJpZEBX5sn4unCEVLj9DxCrfimvDB2ekrmiGm+1+KsVXyrTGqkLCl8AuQFi+udI8Ce5LmY4= 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=FUQ3gIdX; arc=none smtp.client-ip=209.85.210.177 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="FUQ3gIdX" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-82c28f0a4ecso1283688b3a.3 for ; Fri, 03 Apr 2026 01:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775203596; x=1775808396; 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=k1kRvoMLvRpc27HAkVeOWBr+cEQlRdyB+O8+VNEKt40=; b=FUQ3gIdXIrdvDFdBQRrj6EZL3Z/Gi/D9mDvFHbdtcqMn7z2TfuwioI8anKGrGECQQo FNDW2BophhcqkuElg2Xh5m99zAof9Y2pHSiNBMfjrssvWZS+Nw2snvCln+Bcpze6oxc/ Axkdrh0RDr/ja7DOQIHdrZ5njasQgmAyeRy220BU/g7CoyTqu4FtA2cWre7vrBO2SKfD 9Ovki5F067jbHOUtpy51EEj0Y+0mSwm/NapMIc/taSsOpXk9l6nmiyV7Doov3Jp22vmi UmlMGoKLjkDwRVs6aGhUJd+laKkxF60O1+3bnePx8s9xgatEc9lvDruk//GvOeNv/AuH PWcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775203596; x=1775808396; 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=k1kRvoMLvRpc27HAkVeOWBr+cEQlRdyB+O8+VNEKt40=; b=mWHnqVT8h0ZKJXKsJPJtMTMBp4/wLMf3jNlSfazGCXZ5RPEX0FI9woOmSxsuwqpAxB /j/EdG+n0USe5Ju1pDUcEzHJ08yDuyebQpvwekPuT7sYhvrhmi/8edVeCYQGuqWdjdDA BM7WuHq86qAUTLsM8z2HWsX0NVyWvEO+iNDem8xC6z84SYVSl2VPxP4psV+5MT6j+nQM MeEUZv/2ajelocpkKmsj0CPyjT1SQdkTMwjarZyyztzDdF+vJq3YHBg0cSA8Jb3p2B9n 8Vviqers5+fC3+5MJ11wOj71z17Y3uvDjcQVU165XKjjgWn/BMdVkrWV9DEz/Iofe38E gtEQ== X-Forwarded-Encrypted: i=1; AJvYcCX4qjAPDB01sR3Veb+r8DldYRSP5/FlYsRJRhbsync7LDmw03unnFjLH2ogtx4ez9xx5M97yy12ifcIh80=@vger.kernel.org X-Gm-Message-State: AOJu0Yye6WH1GaC2HPl3mDA5usJGtKA+dxPnQIZcIy48Ypl0dUgr4v1D Ej+KlbDs5CyURLY+F4E1gwhC2yKqEtUyEKEgbtIBIA5j80QepVi4McbF X-Gm-Gg: AeBDiev1ul5pl3JtOpL/Hft/teJSW9saFK6CEVC0xVgQaoUVBmQDUSItHNtyvV2RbTy JxIjn/OyFTWr1fZoqkB3JRoO7olnuYT9/8MCnl9jx4qTLuH0B/aoHhqnIh990xGIbPa946PTFlf 26ySTsrHdH1qSvizj7NpEhjSE0zWwg3Shmh08bJzpoMLA1ozNtjXiPU7SyovUdvsXzL/6TUr4Hv jiUNlMuBnV1VFuRYmvlw//ak/GX/UUQikZFVet/BIOO1jU4Npj0+0IsZFZtL44Gt9rIqrvItrZv 8utgo68BTEkATGZnYfR3tkS9M9csEUmAnMCn8SWC16GkEWB4lBe/GX1DDRHypFBRB+dpmH906ZU z4sE9/GLl/QnnLm/PHlnCN9lnYHPqvgzJo0ARR4MirChks/aeMJEyG3baSu6c29OPJLBqWSnVVr r7j5vp7VbfKWVrT0Ibqt1ILAUc35FDbU7ICN1e2fyT3gbeo5SUxph4qhahn0dzGAkMM+zifxkYR Q== X-Received: by 2002:aa7:9069:0:b0:829:bd4d:3817 with SMTP id d2e1a72fcca58-82d0db5ad37mr2326020b3a.28.1775203596399; Fri, 03 Apr 2026 01:06:36 -0700 (PDT) Received: from debian.ari ([152.58.181.253]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9c6ad8asm5481093b3a.40.2026.04.03.01.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 01:06:36 -0700 (PDT) From: Archit Anant To: jic23@kernel.org, dlechner@baylibre.com Cc: lars@metafoo.de, Michael.Hennerich@analog.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Archit Anant Subject: [PATCH v7 2/5] iio: adc: ad799x: use local device pointer in probe Date: Fri, 3 Apr 2026 13:36:11 +0530 Message-Id: <20260403080614.14213-3-architanant5@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260403080614.14213-1-architanant5@gmail.com> References: <20260403080614.14213-1-architanant5@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" Introduce a local device pointer 'dev' in ad799x_probe() and use it throughout the function instead of accessing &client->dev repeatedly. Signed-off-by: Archit Anant Reviewed-by: David Lechner --- drivers/iio/adc/ad799x.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index f37f1fda2dc4..bf0575585a59 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -783,6 +783,7 @@ static const struct ad799x_chip_info ad799x_chip_info_t= bl[] =3D { =20 static int ad799x_probe(struct i2c_client *client) { + struct device *dev =3D &client->dev; const struct i2c_device_id *id =3D i2c_client_get_device_id(client); int ret; int extra_config =3D 0; @@ -791,7 +792,7 @@ static int ad799x_probe(struct i2c_client *client) const struct ad799x_chip_info *chip_info =3D &ad799x_chip_info_tbl[id->driver_data]; =20 - indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*st)); + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); if (indio_dev =3D=3D NULL) return -ENOMEM; =20 @@ -807,7 +808,7 @@ static int ad799x_probe(struct i2c_client *client) =20 /* TODO: Add pdata options for filtering and bit delay */ =20 - st->reg =3D devm_regulator_get(&client->dev, "vcc"); + st->reg =3D devm_regulator_get(dev, "vcc"); if (IS_ERR(st->reg)) return PTR_ERR(st->reg); ret =3D regulator_enable(st->reg); @@ -816,17 +817,17 @@ static int ad799x_probe(struct i2c_client *client) =20 /* check if an external reference is supplied */ if (chip_info->has_vref) { - st->vref =3D devm_regulator_get_optional(&client->dev, "vref"); + st->vref =3D devm_regulator_get_optional(dev, "vref"); ret =3D PTR_ERR_OR_ZERO(st->vref); if (ret) { if (ret !=3D -ENODEV) goto error_disable_reg; st->vref =3D NULL; - dev_info(&client->dev, "Using VCC reference voltage\n"); + dev_info(dev, "Using VCC reference voltage\n"); } =20 if (st->vref) { - dev_info(&client->dev, "Using external reference voltage\n"); + dev_info(dev, "Using external reference voltage\n"); extra_config |=3D AD7991_REF_SEL; ret =3D regulator_enable(st->vref); if (ret) @@ -853,7 +854,7 @@ static int ad799x_probe(struct i2c_client *client) goto error_disable_vref; =20 if (client->irq > 0) { - ret =3D devm_request_threaded_irq(&client->dev, + ret =3D devm_request_threaded_irq(dev, client->irq, NULL, ad799x_event_handler, --=20 2.39.5 From nobody Mon Apr 6 18:22:53 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 26D0732D0CF for ; Fri, 3 Apr 2026 08:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203605; cv=none; b=Ufjb/p7zqD9PPr1EP1TciNBHr5uXMsEhed7wkZQZlc3GJRC9Y5FaF4RmT1zzLQJWGlLLIMFiO+TIjqXORBTXmQkpqo5rptjF84Om7f0KHLDtcv75fjIsZ+omYAvEn+x0uLmhglwrR4C4Cycz1n0fJXF2EkdGL/PiQhuaqyMZcFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203605; c=relaxed/simple; bh=06tA7WRRm4UYgbG/TUxpnj8tNbPyfPxX+h5jV2aHqbY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eWdKE2nwOcotPXc9CTdvLUH37IlY+/v0wkV45uhxDgzxOkgDJbqlP5ndU40zy1p11e6W947KWnpPXBY9IHVVadkmWt54phBNLlsLFnyz5qGWmFyshpztVqMj2iVPT53MViO2/xaPp2ImzPnjGMY5dJDLukl3UVM9T44wcbK5vTo= 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=cFGQcaND; arc=none smtp.client-ip=209.85.210.181 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="cFGQcaND" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-82a7539851fso761272b3a.1 for ; Fri, 03 Apr 2026 01:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775203601; x=1775808401; 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=AiZFrpUFOrr6RoZaJU9vWVycZYWOFjUTDkEI0B+J/4s=; b=cFGQcaNDmQDHPS+4iS1F9OA33EHYwsYbMt0x7N9XWANUjN48W4fDLGC7D1eeX0RJWW FbUyq5Ow8DCmr4E9rmOxwOY+/PJv1JbIZwywM8isVNgirUQEtUERvoEzKCm8o1P8/E1j MralbhhGNedX7Oc0zch3a7ATKul1fjC+43dWrimy16Ks8ILsgls2710gYVcDVe61bB82 BumS22ZSdGh1Yv5mKCNykqHLVv5shpcBXow1EPZtVTA0naUmpqAen0iHjl+ERdHEOSzl dysdcJ+tdpSXlpEPY5dMPL38evngTCMyLWZ66uI3cDOYlfpL0NiY13sW9wm31oODtQdx QcSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775203601; x=1775808401; 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=AiZFrpUFOrr6RoZaJU9vWVycZYWOFjUTDkEI0B+J/4s=; b=eG/sPFl1M7T0m8w1t7KzHvGLO+3Wyi7+WxFV3ZEDE0v2txRsD47b6csIaHe+JKRFSH WSc9Bf0w6GUJLP+3iN/uP5WIY1S+DDS9hgCR5Uco8WDiqZKkKfGSZNcb7YhbF+gAgnwf 2o32kDlGYwEZ3nfN0KY6tEgGxrvEd+wSIcXl7/2++3+aYIZd1Qmu2irNnYGetL3xjkST r/mnd3+GYAUywmTxlBHP7Ldrw2U54deg592lrTweARYFby6FTTMqSnAQ1mbtsYm4Zh/T GyDch9hiJelyp0tSG4gFaOtRCN+6ebR6bPW88bqYk2VJqQn8ZU5F71eg/C2sOaW/TZ9Y HD7g== X-Forwarded-Encrypted: i=1; AJvYcCU2zwvMVryuKtYocOZS9cypgUwCbpAnxUwSUHYg8GUA1W57i041ie0wGa+0I7WO9fNgiB66PYzlUN6WX5g=@vger.kernel.org X-Gm-Message-State: AOJu0Yxh3C6tG5eteQH5roVmtnbw7JPhPy3xY021Ab3ZEs1WjZslhlGX wVYbJAevjXVz99wt2FZpornhUB9gCQlZ3D+NudHq3VMnGfU0EL12c2dZ X-Gm-Gg: AeBDievOuXIQyoxuKrxc8URUJ0CnonV9xSsUXKClm88t1ExNF/LDAix1T3kfM0hMc0s GR60PLDUfoqakbr6/A+1i9l2nm4huf4gGdOXjiGo5vOU5EOF4eab5/OTOBPGeJj3i+Ps5YLnjSl dKH36u5zbm32kNgr2UavRj9F0IrmnAqXdO90Jels5uNi/cGjmEF/WC5+H193jWJ9HePUgHz+UYY +1eyYudGNJ3VlGdA0aoH0yNogbVj4Ddma0yfj+CYC8ELoNviYEeY7HyA2n4xL/sxlK22jtXTmSh 35mAsC4n64kzxwIvPk7DuWPoEGVS9yfL18W4vD6KrdBgW08mCS+iUHnU5CjKpIv0J+xbYdpgcJc czQ4XunmhkMyhRCIGcf0EMP9GzWiZn5XbE8wWjhJfcVw9yCdEKGCvuQatO5F0xUZ6d8ELcIh30C +h0UR1PgviBvqiLcFNLUVVIydAmmjk4ne0d/o7RNvZi22czLs3HXrlSRQQfNJpJ94Q2Dvw7S28H A== X-Received: by 2002:a05:6a00:b94:b0:82c:75df:10ab with SMTP id d2e1a72fcca58-82d0dbe53famr2001361b3a.58.1775203601334; Fri, 03 Apr 2026 01:06:41 -0700 (PDT) Received: from debian.ari ([152.58.181.253]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9c6ad8asm5481093b3a.40.2026.04.03.01.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 01:06:40 -0700 (PDT) From: Archit Anant To: jic23@kernel.org, dlechner@baylibre.com Cc: lars@metafoo.de, Michael.Hennerich@analog.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Archit Anant Subject: [PATCH v7 3/5] iio: adc: ad799x: use a static buffer for scan data Date: Fri, 3 Apr 2026 13:36:12 +0530 Message-Id: <20260403080614.14213-4-architanant5@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260403080614.14213-1-architanant5@gmail.com> References: <20260403080614.14213-1-architanant5@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" Currently, rx_buf is dynamically allocated using kmalloc() every time ad799x_update_scan_mode() is called. This can lead to memory leaks if the scan mask is updated multiple times. Drop the dynamic allocation and replace it with a static buffer at the end of the state structure using IIO_DECLARE_BUFFER_WITH_TS(). This eliminates the allocation overhead, prevents leaks, and removes the need for manual kfree() on driver removal. Signed-off-by: Archit Anant Reviewed-by: David Lechner --- drivers/iio/adc/ad799x.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index bf0575585a59..d8389b6e19b5 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -39,6 +39,7 @@ #include =20 #define AD799X_CHANNEL_SHIFT 4 +#define AD799X_MAX_CHANNELS 8 =20 /* * AD7991, AD7995 and AD7999 defines @@ -133,8 +134,8 @@ struct ad799x_state { unsigned int id; u16 config; =20 - u8 *rx_buf; unsigned int transfer_size; + IIO_DECLARE_BUFFER_WITH_TS(__be16, rx_buf, AD799X_MAX_CHANNELS); }; =20 static int ad799x_write_config(struct ad799x_state *st, u16 val) @@ -217,7 +218,8 @@ static irqreturn_t ad799x_trigger_handler(int irq, void= *p) } =20 b_sent =3D i2c_smbus_read_i2c_block_data(st->client, - cmd, st->transfer_size, st->rx_buf); + cmd, st->transfer_size, + (u8 *)st->rx_buf); if (b_sent < 0) goto out; =20 @@ -234,11 +236,6 @@ static int ad799x_update_scan_mode(struct iio_dev *ind= io_dev, { struct ad799x_state *st =3D iio_priv(indio_dev); =20 - kfree(st->rx_buf); - st->rx_buf =3D kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (!st->rx_buf) - return -ENOMEM; - st->transfer_size =3D bitmap_weight(scan_mask, iio_get_masklength(indio_dev)) * 2; =20 @@ -896,7 +893,6 @@ static void ad799x_remove(struct i2c_client *client) if (st->vref) regulator_disable(st->vref); regulator_disable(st->reg); - kfree(st->rx_buf); } =20 static int ad799x_suspend(struct device *dev) --=20 2.39.5 From nobody Mon Apr 6 18:22:53 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 E277A3370EA for ; Fri, 3 Apr 2026 08:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203607; cv=none; b=L6vU87eZq6nAiTqb6lAj1ZYp+z8lzw0Sph5PV25NMR2M/aBUV2JZdCxE4RRWXPFsl/72iAmQtfDxp8pGsIrCtG7dYkciM80zAAOSmAbN9RpQ4f/NEKj0gqRfmKFXc63HOlk0vhRoK0yVAp0I2Z5gXiHs4jcaAe2gZFQYSwXo3N4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203607; c=relaxed/simple; bh=cfn1ijAobwTrXyt5+z+cKX2dHKqOw+biyb82n/YresU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GJARsJ1h8Q3mhUAls8arptw8ujDL3zUhquWOoOLC45xUpMJ+3POyLqKa5zTcjWNdv3EMWiMoptBgaV96LsWoLqTGVXQ+nEPJDBOAHnMGWY/lzNHR4i/4v/KjRjU675j7LJ8ioRgp9gLP5cpzFpFaojrPo0bIBmI3mMePdTUuVjM= 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=n9VQvp8o; arc=none smtp.client-ip=209.85.210.169 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="n9VQvp8o" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-82c70e4654eso780529b3a.2 for ; Fri, 03 Apr 2026 01:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775203605; x=1775808405; 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=hEif9Z5kuu/R+mzMUqLNULAX8wRxNRnpj5puPaiJPIw=; b=n9VQvp8oUC9HCkg9eGfBrrXwPwRR7qesoF8s3jW7d/9PzPJlLx7E59ou7/7HwjXq5z I6OZBocYOmoAyEOJlO4Cvbkj95e/BOwNhg9GNIDnBiFx9v9JoFkANp+LInQctdhG4wcc aRT0UMJ6vYKJp4/ptDnxoW1Sger2vlPQqzkxq7FjwQ7tkHjx9b5pABD9GBDS0FGSZ49o PgmeTlsp9dwuR0T7QLIJkH2Rbmkw7NnRhg5EPAwJ9JVFFIRM4eH2tiOqR0maNLre+UzC oMygCy5TAZBsqjKf2rc43SRYb5kefgcafwLfAHi4UujtkKHCh5pNy8FH7ouXtr4gJZPy s+JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775203605; x=1775808405; 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=hEif9Z5kuu/R+mzMUqLNULAX8wRxNRnpj5puPaiJPIw=; b=Tr+tWXP/MAlks313wGMX6I90iXv6zeywxjesWv4clyJPUthk4WQYPesfnxcGrzcNXV Ee+M3Zd2gruAQixDGWRxhU+jlkLOy8VBCbd7AZ3ezC7n9uunDYVsJxa+z+P/DS5ZhtJ9 3iwUmb1Tmr45AUFhMTvw/ynCFojv7+qzFgg2ZSAhP/7T7khzFR3rWSDoLfUs4NAVDT0E Xxi6EbG6ZQ6WfYJMrl508gY3xNma8ZViclxKJHo+BvchyAXy1vcWjsybDiUm0FZPj1uS Azo4GHUgaaJroZX+A6nth2Ws7d/Kzk1BTewkBQe/Z2kH2aBi1O6t5H8Jg/VbXtUrpQQR OGiA== X-Forwarded-Encrypted: i=1; AJvYcCWgPATAYxFQbcncIa0WTGzBQW9g8CpxCy1p/imEQVtZ4tIHvNVqScAcNj9vPk8WKzuvUOZrnqbMrQd/wp4=@vger.kernel.org X-Gm-Message-State: AOJu0YzBz4ED8oqA4ZlcwAlZDq0kFqKoobAzMJeQ84vAW3wYdkIygx8d 5E79VQdQwASLtZNliMd7DwnR8M9Zn2QmRG2AG0iSRAlZjFefH7kgg2V7 X-Gm-Gg: ATEYQzzpjaMvHqzsvHbYVAR0wvaJKIOK+KPsHZWOTohlIXbO4uCe7fLLwKhqZypVjZ0 XPk6o6dFCCaVzTEEkBddOy5c6VkpuKJ2MLzvP6+xqYjehV1qQfen+IOx+Hb5fEu1jMUY1EKmGEF Jj7hojpV7oW8Uqdmrn2td8+BPDlWCZyAvaa18cThLH1pKztX3cOGxEOvf+mwsF2YsBnaMemOzjz CIgWaPR388+vR/MfkW2LPY4OGNKwKnbvzGin7E6YDIWUruDkEjpxBZKeLZn2njekgXqfcUV+G34 zZhvePHEB8F1dNxeTtv9CLdfP+GRt59LqSi+B4Aq42IrX8F+H4wZ62Chc3ymFpuEDVJN03IPd5B xb5IJ+C3WrhvMprZ6syP9haj2QUyWjpTY2J3ePfZSfy601FhZSEW3luf8ls8woiWhcQE8uxn8lR soXioSHwbtif2q43DU74h5FQsFPtfO49D2QTYjay0SD7k6ZdHsll5M88ElJL6zCxg7+s/bwQxqs w== X-Received: by 2002:a05:6a00:408d:b0:829:8c23:f70e with SMTP id d2e1a72fcca58-82d0dbabbf2mr2193957b3a.45.1775203605279; Fri, 03 Apr 2026 01:06:45 -0700 (PDT) Received: from debian.ari ([152.58.181.253]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9c6ad8asm5481093b3a.40.2026.04.03.01.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 01:06:44 -0700 (PDT) From: Archit Anant To: jic23@kernel.org, dlechner@baylibre.com Cc: lars@metafoo.de, Michael.Hennerich@analog.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Archit Anant Subject: [PATCH v7 4/5] iio: adc: ad799x: cache regulator voltages during probe Date: Fri, 3 Apr 2026 13:36:13 +0530 Message-Id: <20260403080614.14213-5-architanant5@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260403080614.14213-1-architanant5@gmail.com> References: <20260403080614.14213-1-architanant5@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" Since the reference voltage for this ADC is not expected to change at runtime, determine the active reference voltage (either VREF or VCC) during probe() and cache it in a single variable in the state structure. This improves the performance of ad799x_read_raw() and removes the dependency on the regulator pointers during fast-path reads. Suggested-by: Jonathan Cameron Suggested-by: David Lechner Signed-off-by: Archit Anant Reviewed-by: David Lechner --- drivers/iio/adc/ad799x.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index d8389b6e19b5..e37bb64edd2b 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -30,6 +30,7 @@ #include #include #include +#include =20 #include #include @@ -135,6 +136,9 @@ struct ad799x_state { u16 config; =20 unsigned int transfer_size; + + int vref_uV; + IIO_DECLARE_BUFFER_WITH_TS(__be16, rx_buf, AD799X_MAX_CHANNELS); }; =20 @@ -303,14 +307,7 @@ static int ad799x_read_raw(struct iio_dev *indio_dev, GENMASK(chan->scan_type.realbits - 1, 0); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - if (st->vref) - ret =3D regulator_get_voltage(st->vref); - else - ret =3D regulator_get_voltage(st->reg); - - if (ret < 0) - return ret; - *val =3D ret / 1000; + *val =3D st->vref_uV / (MICRO / MILLI); *val2 =3D chan->scan_type.realbits; return IIO_VAL_FRACTIONAL_LOG2; } @@ -829,9 +826,20 @@ static int ad799x_probe(struct i2c_client *client) ret =3D regulator_enable(st->vref); if (ret) goto error_disable_reg; + ret =3D regulator_get_voltage(st->vref); + if (ret < 0) + goto error_disable_vref; + st->vref_uV =3D ret; } } =20 + if (!st->vref) { + ret =3D regulator_get_voltage(st->reg); + if (ret < 0) + goto error_disable_reg; + st->vref_uV =3D ret; + } + st->client =3D client; =20 indio_dev->name =3D id->name; --=20 2.39.5 From nobody Mon Apr 6 18:22:53 2026 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 F2A2E339870 for ; Fri, 3 Apr 2026 08:06:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203616; cv=none; b=DOIUdelGnd+wqZx+ZlVwv+Wc4J6sdIxZNJmMgpwu7JAE+mKQihJMRneYgcl8nCBLownEqQJ9bTHZtQEKFzXHoYN9WjBWhNpUqHCxIo3bJDELrPCxPXUkLP1C8+BsS5KIk55rEynLf6gZfokfNqR9ZiXKFCwVU+F5SBKb1eioe0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203616; c=relaxed/simple; bh=m1KMSyTgNoTIjs0yfbu3OFUljzgRa7Od+ZK3UUmuaKc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PqYjOhunHpziWcOak9nEDpyHe/HTn4IYNS8w/3w9iz8Z1WsVt3lQtQOJ6zSIp41CHKf8WwQZ54alT59THCrRsFRE8GYaI8BPEg7l1n+dAUseDeA6zx63o3hBWNIGmodgUCk+I1ROzWTM0zYsYBNeo+GTpY1mw2BvyDF2CTZ+xmY= 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=HL2M4Okh; arc=none smtp.client-ip=209.85.210.170 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="HL2M4Okh" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82cef263bedso827867b3a.0 for ; Fri, 03 Apr 2026 01:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775203610; x=1775808410; 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=tTtWp6TMoxddZliac+SyJr7XIDYz1K5UHMGnb/koc6g=; b=HL2M4OkhlDKV39yQmT4yAMAASyq+ODmQqgc3DM1mpBYVZjXSm5Iu71C0ScB5wHEVBu 5zNsSXkSIB0bQxIVRe/EDguWIilGFZ0BqKB08FBVLs7xuZfMeKArTDomYexy88e+/+g6 Ny4j41jO+P5icKlwU8mCrqnnw62/W+DEf+rcmN7Mhc2ugwjMnhzF3aNEjlhbIOYFEjSc GAEWGQhatMpILB82qhbEYghesei97+bE6U+LLfNnpcNM5KXlNQlbtYFjQ5/NvBUvrEF0 pAU6IMeJnUsgcpMTJpe2ueb3Ko74FtfL1rJEfniO4cmyVon0R/gLjvy2/xChXJZSQGle OS9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775203610; x=1775808410; 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=tTtWp6TMoxddZliac+SyJr7XIDYz1K5UHMGnb/koc6g=; b=Ln6sV/Musp9R1dzXF2qGUQa+xpeAjPjoIvhwqigd07EdrNaeyfuGKkRpHwv9W4wEzx LDAyVnvnm7/u17UJPPVlDbGuvDbOzef/KFqUrnC9Gmr6mgKbbZCwfQlzXkYtmHANMvRP 5UZX7FoOf1beI0CWNGIfgn2py44+jGWjyen/ns9M7j+5t35ZkgALuzmCiR+gFjgEzg1B syourRC82iAEpm/4TkVFOHiOsYaEIGvFhERCHpMl76wWeXq5tlfThHfBIjDEDzNQQ9/y zUB00cPjRTxaV1BxMsk9jcxctFOTYA2EBJdyAufvctFAzZ5a1Fb6qpqmRSS4cCAgg4kw aMcA== X-Forwarded-Encrypted: i=1; AJvYcCWba8aY95+wsAiwrZqGVBYrOGvwULBajDCx+4vMXzY/u9GRRfmLbYkPqdwtGn3WhExNCsHr8X+d0VaXads=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4mJ+3VlVdCbND0a/Amd5Squ80JZ6ES0OjIG/HrKmIsKn5xTeG 5/qcGC8vEQb08z1VYTottIA7hTIS2x6o9RSUhEo1g3DNhxXYDNL1OgQP X-Gm-Gg: AeBDiesJsWPq3Ep/yRDam5l3SYK2Gaohsh2lQ4s2PfxR7OrOBaaEGsTysYV7lHBVTK5 /ilhTLwyIPpntI7JLavtXqMAWkowtKnndA/6hkwrqm5sW8SJqDwYwL0q94B0Vlc5LAMBfag1D80 jiWainBGEGhnT+P2uam3XK4TCG4pCxYO73svDvs0QPpsfubjPU1kj1yCcrlj5gcpXP6/J1VsW5U 6+1VAykNO3E38Ryw/wEdYBiFPbdKyVAOVns40dVjPy+Mj6TRsgX367rEwt7oy1V0RdDUv5Z6gkx gT0pETWxZQBaADGIeRa9FG2A/BWOlRrSjqqf822SpZOgh7mFcj1Mp22RR4cBjm9dDgazFDMuFOE DaQBtpenpgFFWKFKb/NY273JpE6o0Bp+UYrZtwsbANyGxr0XfoU+20yS9Q2GC4hY52w+j8urdy2 hsw+vXD3aDZGw8TD7jS+zCYzPMJziXFHpveNfUbWSEroAhiVy8q69DSBvVxqrAtM9oYFF43kneN g== X-Received: by 2002:a05:6a00:2d15:b0:82c:9c47:fefb with SMTP id d2e1a72fcca58-82d0da4de31mr2178254b3a.20.1775203610142; Fri, 03 Apr 2026 01:06:50 -0700 (PDT) Received: from debian.ari ([152.58.181.253]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9c6ad8asm5481093b3a.40.2026.04.03.01.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 01:06:49 -0700 (PDT) From: Archit Anant To: jic23@kernel.org, dlechner@baylibre.com Cc: lars@metafoo.de, Michael.Hennerich@analog.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Archit Anant , Andy Shevchenko Subject: [PATCH v7 5/5] iio: adc: ad799x: convert to fully managed resources and drop remove() Date: Fri, 3 Apr 2026 13:36:14 +0530 Message-Id: <20260403080614.14213-6-architanant5@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260403080614.14213-1-architanant5@gmail.com> References: <20260403080614.14213-1-architanant5@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" Convert the driver's remaining manual resource management to use the devm_ infrastructure, allowing for the complete removal of the ad799x_remove() function and the simplification of the probe error paths. Specifically: - Initialize the mutex using devm_mutex_init() and move it to the top of probe() (before IRQ registration) to prevent a race condition where an interrupt could attempt to take an uninitialized lock. - Use devm_add_action_or_reset() to ensure that the VCC and VREF regulators are disabled safely and in the correct order during driver teardown or probe failure. - Refactor the optional VREF error handling path for better readability. - Convert iio_triggered_buffer_setup() and iio_device_register() to their devm_ variants. Because all resources are now managed by the devm core, the unwinding order is guaranteed to follow the reverse order of allocation. All manual error handling goto labels in ad799x_probe() have been removed. Suggested-by: Jonathan Cameron Suggested-by: David Lechner Suggested-by: Andy Shevchenko Signed-off-by: Archit Anant Reviewed-by: David Lechner --- drivers/iio/adc/ad799x.c | 69 ++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index e37bb64edd2b..9170109d64ef 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -775,6 +775,11 @@ static const struct ad799x_chip_info ad799x_chip_info_= tbl[] =3D { }, }; =20 +static void ad799x_reg_disable(void *reg) +{ + regulator_disable(reg); +} + static int ad799x_probe(struct i2c_client *client) { struct device *dev =3D &client->dev; @@ -793,6 +798,9 @@ static int ad799x_probe(struct i2c_client *client) st =3D iio_priv(indio_dev); /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); + ret =3D devm_mutex_init(dev, &st->lock); + if (ret) + return ret; =20 st->id =3D id->driver_data; if (client->irq > 0 && chip_info->irq_config.info) @@ -809,15 +817,19 @@ static int ad799x_probe(struct i2c_client *client) if (ret) return ret; =20 + ret =3D devm_add_action_or_reset(dev, ad799x_reg_disable, st->reg); + if (ret) + return ret; + /* check if an external reference is supplied */ if (chip_info->has_vref) { st->vref =3D devm_regulator_get_optional(dev, "vref"); ret =3D PTR_ERR_OR_ZERO(st->vref); - if (ret) { - if (ret !=3D -ENODEV) - goto error_disable_reg; + if (ret =3D=3D -ENODEV) { st->vref =3D NULL; dev_info(dev, "Using VCC reference voltage\n"); + } else if (ret) { + return ret; } =20 if (st->vref) { @@ -825,10 +837,15 @@ static int ad799x_probe(struct i2c_client *client) extra_config |=3D AD7991_REF_SEL; ret =3D regulator_enable(st->vref); if (ret) - goto error_disable_reg; + return ret; + + ret =3D devm_add_action_or_reset(dev, ad799x_reg_disable, st->vref); + if (ret) + return ret; + ret =3D regulator_get_voltage(st->vref); if (ret < 0) - goto error_disable_vref; + return ret; st->vref_uV =3D ret; } } @@ -836,7 +853,7 @@ static int ad799x_probe(struct i2c_client *client) if (!st->vref) { ret =3D regulator_get_voltage(st->reg); if (ret < 0) - goto error_disable_reg; + return ret; st->vref_uV =3D ret; } =20 @@ -851,12 +868,12 @@ static int ad799x_probe(struct i2c_client *client) =20 ret =3D ad799x_update_config(st, st->chip_config->default_config | extra_= config); if (ret) - goto error_disable_vref; + return ret; =20 - ret =3D iio_triggered_buffer_setup(indio_dev, NULL, + ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, &ad799x_trigger_handler, NULL); if (ret) - goto error_disable_vref; + return ret; =20 if (client->irq > 0) { ret =3D devm_request_threaded_irq(dev, @@ -868,39 +885,10 @@ static int ad799x_probe(struct i2c_client *client) client->name, indio_dev); if (ret) - goto error_cleanup_ring; + return ret; } =20 - mutex_init(&st->lock); - - ret =3D iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - - return 0; - -error_cleanup_ring: - iio_triggered_buffer_cleanup(indio_dev); -error_disable_vref: - if (st->vref) - regulator_disable(st->vref); -error_disable_reg: - regulator_disable(st->reg); - - return ret; -} - -static void ad799x_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev =3D i2c_get_clientdata(client); - struct ad799x_state *st =3D iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - - iio_triggered_buffer_cleanup(indio_dev); - if (st->vref) - regulator_disable(st->vref); - regulator_disable(st->reg); + return devm_iio_device_register(dev, indio_dev); } =20 static int ad799x_suspend(struct device *dev) @@ -970,7 +958,6 @@ static struct i2c_driver ad799x_driver =3D { .pm =3D pm_sleep_ptr(&ad799x_pm_ops), }, .probe =3D ad799x_probe, - .remove =3D ad799x_remove, .id_table =3D ad799x_id, }; module_i2c_driver(ad799x_driver); --=20 2.39.5