{"id":2197984,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2197984/?format=json","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/1.0/projects/42/?format=json","name":"Linux GPIO development","link_name":"linux-gpio","list_id":"linux-gpio.vger.kernel.org","list_email":"linux-gpio@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260219022929.3558081-5-dmitry.torokhov@gmail.com>","date":"2026-02-19T02:29:28","name":"[v2,4/4] iio: adc: ti-ads7950: complete conversion to using managed resources","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"384dac67d8edc7227fdb80ff5a7c8abc274fbf35","submitter":{"id":695,"url":"http://patchwork.ozlabs.org/api/1.0/people/695/?format=json","name":"Dmitry Torokhov","email":"dmitry.torokhov@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260219022929.3558081-5-dmitry.torokhov@gmail.com/mbox/","series":[{"id":492631,"url":"http://patchwork.ozlabs.org/api/1.0/series/492631/?format=json","date":"2026-02-19T02:29:24","name":"ti-ads7950: fix gpio handling and facelift","version":2,"mbox":"http://patchwork.ozlabs.org/series/492631/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2197984/checks/","tags":{},"headers":{"Return-Path":"\n <linux-gpio+bounces-31838-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=irb+B+g5;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-31838-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"irb+B+g5\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=74.125.82.174","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fGcnq0RZ0z1xpY\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 19 Feb 2026 13:31:27 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 1E0C33075F88\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 19 Feb 2026 02:29:47 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 5EB85280A5A;\n\tThu, 19 Feb 2026 02:29:42 +0000 (UTC)","from mail-dy1-f174.google.com (mail-dy1-f174.google.com\n [74.125.82.174])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B93B8278156\n\tfor <linux-gpio@vger.kernel.org>; Thu, 19 Feb 2026 02:29:40 +0000 (UTC)","by mail-dy1-f174.google.com with SMTP id\n 5a478bee46e88-2b6b0500e06so521801eec.1\n        for <linux-gpio@vger.kernel.org>;\n Wed, 18 Feb 2026 18:29:40 -0800 (PST)","from dtor-ws.sjc.corp.google.com\n ([2a00:79e0:2ebe:8:265b:f5ad:9e03:677e])\n        by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2bacb577bcasm19609433eec.12.2026.02.18.18.29.39\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 18 Feb 2026 18:29:39 -0800 (PST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1771468182; cv=none;\n b=diqRWJH0gC37L1QB8/cmfPw2jarLJNRT+BFZpbuuZwO7ZkobH7alFZzV4xWp+dnAyrYfHPHHfe/chOTvhvJr1WOcRHK1OXxXarzJrfQ6uM4K05MCQZvWjjjJVX3H73b7rbfNTmobFTfHhjXJcVNVb9unVrdpTc81RMYxYw7/4x4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1771468182; c=relaxed/simple;\n\tbh=kauiL/ONWk2RY4xVUjE4kT+PlTVn5lZxv/b4OFnIWtQ=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=blyI24HmpngXxZx4GeB/bTlrDHYLpHG7mObplbwA39lrapWe1dwzmy88qZbE4dmqRgBdRoqMMwwku7r3ScghyqJ6geeuloXEYDpCHFSXMgA2WhTJ7ssKoCm8tNsaCJMOE5dDTkeGscGKIwvCY7H/uPGj3mCRpKtBqM9zwba2K6Q=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=irb+B+g5; arc=none smtp.client-ip=74.125.82.174","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20230601; t=1771468180; x=1772072980;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=M1ZTHJlxuM3aGdOYJnVvaMVfaR/Kwe29wbgQ93rKb+E=;\n        b=irb+B+g5bq5qwaeDebSv+F7Bj1xwGldMkWuC4sXz422pLm0SzMem7PJCD2Db1XZx6A\n         5XdBeXxCCh4zrF21i9sNCuPPx4M//RjdIUWxwGFbUfI/bNr2W+DLirSlACbvdqHvhxvk\n         GKueIoU2nXMDL0EJsPqaA2Um0rYIgMUiD3HOFQW71RVx10wsy262odbZWa8bgFHMt6Xn\n         n4xKdvRp9ST4EyNX9yksq71cMwtcVPq2qRFhJ9S6F6V+bilS8CH7Oq7NaW1bvYGSTVOb\n         RFWbcJ18/uN5oum+TCvGnVCeSq7HeqIj1D45ImcpRREW+HO9Fw8GIUTPMeC3HBox1JbP\n         1KoQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20230601; t=1771468180; x=1772072980;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=M1ZTHJlxuM3aGdOYJnVvaMVfaR/Kwe29wbgQ93rKb+E=;\n        b=vlV9sl3LIv6m3aWWw/ICXy8dtzCWcDiTC2BvKU03sXy4d0U2HavCTtJbb+gU7JVATV\n         v8MgAXrLL7IYupAtqZxXdMqYLXvH2EDMGL14f1NVm7bpiEdj5RbG36055rHTSSsAbWTi\n         3Ijp9/eca7p9IuHrEexo2q8tXXG0cSzSz67ja07tweOF54LTBgZlcaGFYaopOmslMoiH\n         XWz35bMoZYOeXQNuJbOoO9YroN2E10CF751Vp6SLbi1GdmfnzWiE+Yx+550Jw1Z5I2i5\n         1ZFMEnp5eOhe/B+piMYg+8aL6yzHyjEMithfheiyrWSmilOnAbn46jeQr2WC6hviRywC\n         duaQ==","X-Forwarded-Encrypted":"i=1;\n AJvYcCUoxPje4btmRG6tx7Pbie1l+jkB/JNLedLg8bN/5cgZV8QkX3WnoFcHOz6G7PvlPPwRf8Exzk9E13XR@vger.kernel.org","X-Gm-Message-State":"AOJu0YxFMNY12NnRTYhWZRVxLakFr+j6y/9ZDDS5EZv22tqriePleRXN\n\t2NE0YHpcecohWghnzezG2l7DZNqJ/z9yrS5/E8iLPRn9H+a6aoz3oUl+","X-Gm-Gg":"AZuq6aLcJ/11f7bCxuxG+Szc/7AqdGwbErYIxWhAvV5FSVdBrTzo0uBqmYTWkWl8/5K\n\tL4xeS1v0k/eBgtxSQBuDCRRkBotTSu0gAhfqbiG2dBrw1NWIRNfofRTLKFWXhsVIGe95BJeGDfR\n\t5R9zHUrwmv7GLb7zWS9YXc41HwaisZQdf67U322YT18VXSL63m4on+Md2R/BW5R6BwDdFbkA6jI\n\tTVObyV123u4EwpePDziWh/Nosy47QzcwvzNgE+lvjmpO5HG3BfThEvSwTPIkdQ5gH6KTcg5UrfP\n\tt4cQdreInEZs7pia4nK9mQnwY44YyUvP7usmh2XWEOKv6yqasp8gq4njgjmEeXoS1nUY0UKJDge\n\tVY0RWdscB60oH9Vtz7ZmG8bqW/+0dw/ZeFpwMSnAOsVepKlFnMDfegwTo2YNvbGCPdDy/3lcrGb\n\tAUItal+PlHrcUSKvTjTTngRtqdKkm4hNakU6aAtf7q59ufy2KTjUh8oJusxosqQXsd/VR4k6ztP\n\t2zeOpLzF9S9pF5ayG42BGqGyA==","X-Received":"by 2002:a05:7301:d19:b0:2ba:6d87:cf68 with SMTP id\n 5a478bee46e88-2baba05b5c2mr9113620eec.16.1771468179912;\n        Wed, 18 Feb 2026 18:29:39 -0800 (PST)","From":"Dmitry Torokhov <dmitry.torokhov@gmail.com>","To":"Jonathan Cameron <jic23@kernel.org>","Cc":"David Lechner <dlechner@baylibre.com>,\n =?utf-8?q?Nuno_S=C3=A1?= <nuno.sa@analog.com>,\n Andy Shevchenko <andy@kernel.org>, Linus Walleij <linusw@kernel.org>,\n Bartosz Golaszewski <brgl@kernel.org>, linux-iio@vger.kernel.org,\n linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org","Subject":"[PATCH v2 4/4] iio: adc: ti-ads7950: complete conversion to using\n 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-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"All resources that the driver needs have managed API now. Switch to\nusing them to make code clearer and drop ti_ads7950_remove().\n\nSigned-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\n---\n drivers/iio/adc/ti-ads7950.c | 98 +++++++++++++++---------------------\n 1 file changed, 40 insertions(+), 58 deletions(-)","diff":"diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c\nindex d31397f37ec4..1c53e000bdcc 100644\n--- a/drivers/iio/adc/ti-ads7950.c\n+++ b/drivers/iio/adc/ti-ads7950.c\n@@ -528,19 +528,26 @@ static int ti_ads7950_init_hw(struct ti_ads7950_state *st)\n \treturn 0;\n }\n \n+static void ti_ads7950_power_off(void *data)\n+{\n+\tstruct ti_ads7950_state *st = data;\n+\n+\tregulator_disable(st->reg);\n+}\n+\n static int ti_ads7950_probe(struct spi_device *spi)\n {\n \tstruct ti_ads7950_state *st;\n \tstruct iio_dev *indio_dev;\n \tconst struct ti_ads7950_chip_info *info;\n-\tint ret;\n+\tint error;\n \n \tspi->bits_per_word = 16;\n \tspi->mode |= SPI_CS_WORD;\n-\tret = spi_setup(spi);\n-\tif (ret < 0) {\n+\terror = spi_setup(spi);\n+\tif (error) {\n \t\tdev_err(&spi->dev, \"Error in spi setup\\n\");\n-\t\treturn ret;\n+\t\treturn error;\n \t}\n \n \tindio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));\n@@ -598,36 +605,36 @@ static int ti_ads7950_probe(struct spi_device *spi)\n \tmutex_init(&st->slock);\n \n \tst->reg = devm_regulator_get(&spi->dev, \"vref\");\n-\tif (IS_ERR(st->reg)) {\n-\t\tret = dev_err_probe(&spi->dev, PTR_ERR(st->reg),\n+\terror = PTR_ERR_OR_ZERO(st->reg);\n+\tif (error)\n+\t\treturn dev_err_probe(&spi->dev, error,\n \t\t\t\t     \"Failed to get regulator \\\"vref\\\"\\n\");\n-\t\tgoto error_destroy_mutex;\n-\t}\n \n-\tret = regulator_enable(st->reg);\n-\tif (ret) {\n-\t\tdev_err(&spi->dev, \"Failed to enable regulator \\\"vref\\\"\\n\");\n-\t\tgoto error_destroy_mutex;\n-\t}\n+\terror = regulator_enable(st->reg);\n+\tif (error)\n+\t\treturn dev_err_probe(&spi->dev, error,\n+\t\t\t\t     \"Failed to enable regulator \\\"vref\\\"\\n\");\n \n-\tret = iio_triggered_buffer_setup(indio_dev, NULL,\n-\t\t\t\t\t &ti_ads7950_trigger_handler, NULL);\n-\tif (ret) {\n-\t\tdev_err(&spi->dev, \"Failed to setup triggered buffer\\n\");\n-\t\tgoto error_disable_reg;\n-\t}\n+\terror = devm_add_action_or_reset(&spi->dev, ti_ads7950_power_off, st);\n+\tif (error)\n+\t\treturn error;\n \n-\tret = ti_ads7950_init_hw(st);\n-\tif (ret) {\n-\t\tdev_err(&spi->dev, \"Failed to init adc chip\\n\");\n-\t\tgoto error_cleanup_ring;\n-\t}\n+\terror = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL,\n+\t\t\t\t\t\t&ti_ads7950_trigger_handler,\n+\t\t\t\t\t\tNULL);\n+\tif (error)\n+\t\treturn dev_err_probe(&spi->dev, error,\n+\t\t\t\t     \"Failed to setup triggered buffer\\n\");\n \n-\tret = iio_device_register(indio_dev);\n-\tif (ret) {\n-\t\tdev_err(&spi->dev, \"Failed to register iio device\\n\");\n-\t\tgoto error_cleanup_ring;\n-\t}\n+\terror = ti_ads7950_init_hw(st);\n+\tif (error)\n+\t\treturn dev_err_probe(&spi->dev, error,\n+\t\t\t\t     \"Failed to init adc chip\\n\");\n+\n+\terror = devm_iio_device_register(&spi->dev, indio_dev);\n+\tif (error)\n+\t\treturn dev_err_probe(&spi->dev, error,\n+\t\t\t\t     \"Failed to register iio device\\n\");\n \n \t/* Add GPIO chip */\n \tst->chip.label = dev_name(&st->spi->dev);\n@@ -642,36 +649,12 @@ static int ti_ads7950_probe(struct spi_device *spi)\n \tst->chip.get = ti_ads7950_get;\n \tst->chip.set = ti_ads7950_set;\n \n-\tret = gpiochip_add_data(&st->chip, st);\n-\tif (ret) {\n-\t\tdev_err(&spi->dev, \"Failed to init GPIOs\\n\");\n-\t\tgoto error_iio_device;\n-\t}\n+\terror = devm_gpiochip_add_data(&spi->dev, &st->chip, st);\n+\tif (error)\n+\t\treturn dev_err_probe(&spi->dev, error,\n+\t\t\t\t     \"Failed to init GPIOs\\n\");\n \n \treturn 0;\n-\n-error_iio_device:\n-\tiio_device_unregister(indio_dev);\n-error_cleanup_ring:\n-\tiio_triggered_buffer_cleanup(indio_dev);\n-error_disable_reg:\n-\tregulator_disable(st->reg);\n-error_destroy_mutex:\n-\tmutex_destroy(&st->slock);\n-\n-\treturn ret;\n-}\n-\n-static void ti_ads7950_remove(struct spi_device *spi)\n-{\n-\tstruct iio_dev *indio_dev = spi_get_drvdata(spi);\n-\tstruct ti_ads7950_state *st = iio_priv(indio_dev);\n-\n-\tgpiochip_remove(&st->chip);\n-\tiio_device_unregister(indio_dev);\n-\tiio_triggered_buffer_cleanup(indio_dev);\n-\tregulator_disable(st->reg);\n-\tmutex_destroy(&st->slock);\n }\n \n static const struct spi_device_id ti_ads7950_id[] = {\n@@ -714,7 +697,6 @@ static struct spi_driver ti_ads7950_driver = {\n \t\t.of_match_table = ads7950_of_table,\n \t},\n \t.probe\t\t= ti_ads7950_probe,\n-\t.remove\t\t= ti_ads7950_remove,\n \t.id_table\t= ti_ads7950_id,\n };\n module_spi_driver(ti_ads7950_driver);\n","prefixes":["v2","4/4"]}