From nobody Sun Apr 5 18:18:48 2026 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (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 C4F2E274B42 for ; Thu, 19 Feb 2026 02:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771468182; cv=none; b=nVV/O17r0qImRWQtOr6KyAAGdDgMXXJL8zQT7mDqMzykE2ytCrGTlyHrWAz1Eoz/4ipIYIe5gNyaIaeCbhSvMasI7GeKXwHS7edfDl3/iwyss0A7tDzDMi9bdcyDWjrRtlX5P0SxmrBwzyJvCdKe4BSJkT+YlTjj7g5si1mG6/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771468182; c=relaxed/simple; bh=kauiL/ONWk2RY4xVUjE4kT+PlTVn5lZxv/b4OFnIWtQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=blyI24HmpngXxZx4GeB/bTlrDHYLpHG7mObplbwA39lrapWe1dwzmy88qZbE4dmqRgBdRoqMMwwku7r3ScghyqJ6geeuloXEYDpCHFSXMgA2WhTJ7ssKoCm8tNsaCJMOE5dDTkeGscGKIwvCY7H/uPGj3mCRpKtBqM9zwba2K6Q= 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=irb+B+g5; arc=none smtp.client-ip=74.125.82.175 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="irb+B+g5" Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-2baa098ffc6so446227eec.0 for ; Wed, 18 Feb 2026 18:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771468180; x=1772072980; 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=M1ZTHJlxuM3aGdOYJnVvaMVfaR/Kwe29wbgQ93rKb+E=; b=irb+B+g5bq5qwaeDebSv+F7Bj1xwGldMkWuC4sXz422pLm0SzMem7PJCD2Db1XZx6A 5XdBeXxCCh4zrF21i9sNCuPPx4M//RjdIUWxwGFbUfI/bNr2W+DLirSlACbvdqHvhxvk GKueIoU2nXMDL0EJsPqaA2Um0rYIgMUiD3HOFQW71RVx10wsy262odbZWa8bgFHMt6Xn n4xKdvRp9ST4EyNX9yksq71cMwtcVPq2qRFhJ9S6F6V+bilS8CH7Oq7NaW1bvYGSTVOb RFWbcJ18/uN5oum+TCvGnVCeSq7HeqIj1D45ImcpRREW+HO9Fw8GIUTPMeC3HBox1JbP 1KoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771468180; x=1772072980; 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=M1ZTHJlxuM3aGdOYJnVvaMVfaR/Kwe29wbgQ93rKb+E=; b=gCGnnLptocx7PMyUcJ5Uo1bViBtpONZySz5PXQRWKPDTE+vdx1LoVJTxX0vriz+diW kI2UQs2I9+ZAwfkVSBx4C4NGpjrxsPhpqS7xcO0X+vhC1TiTEIUnXXBBpmh1dbjw4Kb9 fl8B1nfCHM7UQKG2eZycYLDFp+2QcTdarfEBXQWLuA5b1/xdJxx6tmG6rkmXQDtHSjLa Dv9A9RztOJBo/WHDwy3CBcacThZ6qGKnubHZVb3jsPV1A73nwWHFiGUYjQtz1R8sWesG R2MCW8jN0mlZBKrHcltAQ3OM8c1w5OXfTEpdetAjFSGBWCEdlfNDsCACfceWGg0m6q2a W+4w== X-Forwarded-Encrypted: i=1; AJvYcCUQB3qnJiTzJ9RDamNbwbSa9r4QYnKaTE5DmLurCDu35I6sdtPjamTeJFZuCh2tG3va5eJ2BVt11hQWNhk=@vger.kernel.org X-Gm-Message-State: AOJu0YxLz19uLpkv0VMPdRnTWzUcYgshPdbfxM2BKtPJZfKz9pbuNzFS PBUAv0VYl0cdnYINVi0+PCC8fm2peUC6em82cx9xkgvpdnlXR/xrgWHq X-Gm-Gg: AZuq6aJShvKmjO3o0oYOWvlYy631R9onAPSJftHpd2DPIcmciNlOjcP5LLCMpb1fELM xxvsP+gXkgTFGlT8bJfTtHzFWTO9llXYpZvBxrZVzi86mgfRkzveZGO8ioMHVKturJNElDaYslD HDUokFs/FVbqfmf1DCDMUVyzXMKfawP1ydW43M3apttDwcp1a+B2zFqI54IyNN8tsm2z93lX4MN fFkodsI8Rs1j3y/dXwGLB0wTDD376bLsEXcnQ6SnzpS+zvmglqNkihsYI7KcAm+An0JPYhGF0RX W1HKKzCrbufkRcLkh7g07JqXjN9hfU9MRNru1OodrR30Ijx6N56GAKR4dT2kSmWN/shAY0bfOWM 3qFmBJFAlxixz2kTZiEEJM2W/9hHDnQZxzai5EvBJtEX71DnrlB1szB3oBQteiowcI6O0LZih9z iaIYqAfz1Zt2a4Um5tTBXirUa1UZX0jUv8IR+OP4LWBbgKuLwdB5hFx7BJSQ00bFySNiXKC2/j3 ERL0lpWjUZVimJgqqcNv7Zcmg== X-Received: by 2002:a05:7301:d19:b0:2ba:6d87:cf68 with SMTP id 5a478bee46e88-2baba05b5c2mr9113620eec.16.1771468179912; Wed, 18 Feb 2026 18:29:39 -0800 (PST) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:265b:f5ad:9e03:677e]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bacb577bcasm19609433eec.12.2026.02.18.18.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Feb 2026 18:29:39 -0800 (PST) From: Dmitry Torokhov To: Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [PATCH v2 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources Date: Wed, 18 Feb 2026 18:29:28 -0800 Message-ID: <20260219022929.3558081-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.53.0.335.g19a08e0c02-goog In-Reply-To: <20260219022929.3558081-1-dmitry.torokhov@gmail.com> References: <20260219022929.3558081-1-dmitry.torokhov@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" All resources that the driver needs have managed API now. Switch to using them to make code clearer and drop ti_ads7950_remove(). Signed-off-by: Dmitry Torokhov --- drivers/iio/adc/ti-ads7950.c | 98 +++++++++++++++--------------------- 1 file changed, 40 insertions(+), 58 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index d31397f37ec4..1c53e000bdcc 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -528,19 +528,26 @@ static int ti_ads7950_init_hw(struct ti_ads7950_state= *st) return 0; } =20 +static void ti_ads7950_power_off(void *data) +{ + struct ti_ads7950_state *st =3D data; + + regulator_disable(st->reg); +} + static int ti_ads7950_probe(struct spi_device *spi) { struct ti_ads7950_state *st; struct iio_dev *indio_dev; const struct ti_ads7950_chip_info *info; - int ret; + int error; =20 spi->bits_per_word =3D 16; spi->mode |=3D SPI_CS_WORD; - ret =3D spi_setup(spi); - if (ret < 0) { + error =3D spi_setup(spi); + if (error) { dev_err(&spi->dev, "Error in spi setup\n"); - return ret; + return error; } =20 indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); @@ -598,36 +605,36 @@ static int ti_ads7950_probe(struct spi_device *spi) mutex_init(&st->slock); =20 st->reg =3D devm_regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) { - ret =3D dev_err_probe(&spi->dev, PTR_ERR(st->reg), + error =3D PTR_ERR_OR_ZERO(st->reg); + if (error) + return dev_err_probe(&spi->dev, error, "Failed to get regulator \"vref\"\n"); - goto error_destroy_mutex; - } =20 - ret =3D regulator_enable(st->reg); - if (ret) { - dev_err(&spi->dev, "Failed to enable regulator \"vref\"\n"); - goto error_destroy_mutex; - } + error =3D regulator_enable(st->reg); + if (error) + return dev_err_probe(&spi->dev, error, + "Failed to enable regulator \"vref\"\n"); =20 - ret =3D iio_triggered_buffer_setup(indio_dev, NULL, - &ti_ads7950_trigger_handler, NULL); - if (ret) { - dev_err(&spi->dev, "Failed to setup triggered buffer\n"); - goto error_disable_reg; - } + error =3D devm_add_action_or_reset(&spi->dev, ti_ads7950_power_off, st); + if (error) + return error; =20 - ret =3D ti_ads7950_init_hw(st); - if (ret) { - dev_err(&spi->dev, "Failed to init adc chip\n"); - goto error_cleanup_ring; - } + error =3D devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, + &ti_ads7950_trigger_handler, + NULL); + if (error) + return dev_err_probe(&spi->dev, error, + "Failed to setup triggered buffer\n"); =20 - ret =3D iio_device_register(indio_dev); - if (ret) { - dev_err(&spi->dev, "Failed to register iio device\n"); - goto error_cleanup_ring; - } + error =3D ti_ads7950_init_hw(st); + if (error) + return dev_err_probe(&spi->dev, error, + "Failed to init adc chip\n"); + + error =3D devm_iio_device_register(&spi->dev, indio_dev); + if (error) + return dev_err_probe(&spi->dev, error, + "Failed to register iio device\n"); =20 /* Add GPIO chip */ st->chip.label =3D dev_name(&st->spi->dev); @@ -642,36 +649,12 @@ static int ti_ads7950_probe(struct spi_device *spi) st->chip.get =3D ti_ads7950_get; st->chip.set =3D ti_ads7950_set; =20 - ret =3D gpiochip_add_data(&st->chip, st); - if (ret) { - dev_err(&spi->dev, "Failed to init GPIOs\n"); - goto error_iio_device; - } + error =3D devm_gpiochip_add_data(&spi->dev, &st->chip, st); + if (error) + return dev_err_probe(&spi->dev, error, + "Failed to init GPIOs\n"); =20 return 0; - -error_iio_device: - iio_device_unregister(indio_dev); -error_cleanup_ring: - iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - regulator_disable(st->reg); -error_destroy_mutex: - mutex_destroy(&st->slock); - - return ret; -} - -static void ti_ads7950_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev =3D spi_get_drvdata(spi); - struct ti_ads7950_state *st =3D iio_priv(indio_dev); - - gpiochip_remove(&st->chip); - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - regulator_disable(st->reg); - mutex_destroy(&st->slock); } =20 static const struct spi_device_id ti_ads7950_id[] =3D { @@ -714,7 +697,6 @@ static struct spi_driver ti_ads7950_driver =3D { .of_match_table =3D ads7950_of_table, }, .probe =3D ti_ads7950_probe, - .remove =3D ti_ads7950_remove, .id_table =3D ti_ads7950_id, }; module_spi_driver(ti_ads7950_driver); --=20 2.53.0.335.g19a08e0c02-goog