Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.0/patches/2197983/?format=api
{ "id": 2197983, "url": "http://patchwork.ozlabs.org/api/1.0/patches/2197983/?format=api", "project": { "id": 42, "url": "http://patchwork.ozlabs.org/api/1.0/projects/42/?format=api", "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-4-dmitry.torokhov@gmail.com>", "date": "2026-02-19T02:29:27", "name": "[v2,3/4] iio: adc: ti-ads7950: switch to using guard() notation", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "51f3953c95f5928e403f4c54b1ddf0d8cac0791b", "submitter": { "id": 695, "url": "http://patchwork.ozlabs.org/api/1.0/people/695/?format=api", "name": "Dmitry Torokhov", "email": "dmitry.torokhov@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-gpio/patch/20260219022929.3558081-4-dmitry.torokhov@gmail.com/mbox/", "series": [ { "id": 492631, "url": "http://patchwork.ozlabs.org/api/1.0/series/492631/?format=api", "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/2197983/checks/", "tags": {}, "headers": { "Return-Path": "\n <linux-gpio+bounces-31837-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=UtHtzM2l;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-31837-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=\"UtHtzM2l\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=74.125.82.51", "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 [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fGcnN62Y2z1xpY\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 19 Feb 2026 13:31:04 +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 1181D3069D1E\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 19 Feb 2026 02:29:45 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 82C5327CCEE;\n\tThu, 19 Feb 2026 02:29:41 +0000 (UTC)", "from mail-dl1-f51.google.com (mail-dl1-f51.google.com\n [74.125.82.51])\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 E7F64275AEB\n\tfor <linux-gpio@vger.kernel.org>; Thu, 19 Feb 2026 02:29:39 +0000 (UTC)", "by mail-dl1-f51.google.com with SMTP id\n a92af1059eb24-127423bea4bso1038313c88.0\n for <linux-gpio@vger.kernel.org>;\n Wed, 18 Feb 2026 18:29:39 -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.38\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 18 Feb 2026 18:29:38 -0800 (PST)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1771468181; cv=none;\n b=t+x2JyTMANaQiw+bHFeJz7TD7I1tK50teBVPXvhziI2Hu+dQDF9cGpGNaGk/wmfE+l99vSnSvgrVqGi3y17uLlcRzmDJ3AdkqkpW8oH+CMqZ93rXp9GzR2oTyiM8N6VjLE3y0k2ud7d2D0Qg9nDIFWqUG2za0bTMNDwKe1a1o9U=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1771468181; c=relaxed/simple;\n\tbh=Yz9snSJF0jeyCudaLTFzwfAA3jyjKzrb0jhPuElnXuk=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=Jq5BjeGscvPvt6zpvv6bE/n8CfOXSBg4eo0zo0Khh/i2UePz2u1FgP6HlQDfk9WrNv4wuBTEOf/9t7QRX5Wm3FV10zbXcsNODkxz0uTWmFwl9Yu0lk64DY50DuQTuFNyaMqk3YSAaBCtj41myJ0hVaLpzgml4ui/zLtHUAfmdYI=", "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=UtHtzM2l; arc=none smtp.client-ip=74.125.82.51", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1771468179; x=1772072979;\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=OuFP5v7SMXV4DVA+yxAHBbrT46M+siIg2POmogyVVsY=;\n b=UtHtzM2lxzp+aVqNpkpV0VGus6Ik+wkkq+fE+DX2axiIBVubjliikcWR6RnT2dUcbM\n L5905v9z7fjdbcyO5KhRYiS+5xxI0fTg2BJFkkJ2KbRZMwR0MNPYqE21HZe8DBLjG+YF\n h20X1XMVPgYmLOsTIFCHa1E31Kzm0oVMia/s/DNrpnYumrrUczikmryEVj9s5RA8iDmY\n 5O8ol0W9r3Iqk2+2YHVDy2pW+9ZNZMbbHob3y9J5bLALpXZsBwE1RmoijLcOF+mn3L8i\n u1/yAnwjuaedBiYcPipiPQz7LQ1eDejy8kyukMBw0LBgRvbAaHLWHMcN8Y3RosnB4yJi\n vc9g==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1771468179; x=1772072979;\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=OuFP5v7SMXV4DVA+yxAHBbrT46M+siIg2POmogyVVsY=;\n b=gl7JanmF/qPzca3CSp8taXCct/35PSoG2J6FKCJGW2MkJPmQjfcuxObL6T514WWOSw\n H51kt5iqcfltxvVyql/mbS8R+2MI+QcTqKxXHMH1CyQ2KHAdMj9cDxPsNI2JLpGufKW0\n JtF9OWfB/0BCjQQePKj+ySPjwORefgacazsR3NdgJVKduXOKseTtetSAh6zKDuFiKmZk\n 3CK3wTxztdnBImm3yKtm34fk6pODvHRq5iob/6gWfk2zfjZ+zrgKm+B7qZhGcsMOR75L\n hjP2c0wXVM3F0a8UjKG8x5+fDh6J6J9DZ2g9UgNd6lg8lPzixS024exraWgwoQCtLTpv\n fW5Q==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCU5s/FPl7U4wpjn7KIoMihsOfz4o7vAApXd0eF5qRRbCXzheDbwxEaMWfCKciqHNH0bY9nYHCcrQ3Jr@vger.kernel.org", "X-Gm-Message-State": "AOJu0Yz/yTETd0PrU0pKslevJ3/Iu3kU17xxxFHuPubkzJpJaJgdLyAg\n\tH4qRBJL75ewYFL0JZqXPq5AB0XiLXZXE1kfjjdZXE8TeB9xdEB9Dpf0q", "X-Gm-Gg": "AZuq6aK6o83P9m3wM7hzwOhK2upu6gZtYrCMG05tc5gBf1ywbnCFEXKyJJAwD/6/P+f\n\t/J2/7brGc35odmnmcmpr7EwMQtbt61UlrLuktzg72ZkJXk7skwPlBAYzDOk8/E0yWBuJt6MYAnB\n\t+Pm9gUEVzDebZhoEKhGawJmX4k9cpOFN/XH7siVMXv2x+UjEGwF89ZccByJOszwqyhYyRx1zzVh\n\tLKjG8wNbmTyWZmAFwKoVsecVBmgAyJIDcjMew25hgL6FwN2Y/A58mXnxgFZozZTEcqfMEyU0czp\n\tVIdYsT10JxPlkzFsY5lFtLh7xi7vtEXOQByYTL/cfuDD5JuxVRx4VXqP7oQDXyQGpXlCbOZgxnJ\n\tntyg+UrZZJ4+K6biHHq3MU2Ww8eHsjMlKTfUm3s6cm5hee5Z0xJKw1ECsGDnfvKnbxua9qD5y5e\n\tsMf3xgF0/GUtJI9lez+WGBIsluuWwzmvAInyjGfuvkB4DqI6PocOdH5qBEiTq4wACHWWSQbpPXT\n\tAzXVa4Iklc79RA=", "X-Received": "by 2002:a05:7301:d19:b0:2ba:659f:2002 with SMTP id\n 5a478bee46e88-2babc3c8a4dmr8115517eec.15.1771468178933;\n Wed, 18 Feb 2026 18:29:38 -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 3/4] iio: adc: ti-ads7950: switch to using guard() notation", "Date": "Wed, 18 Feb 2026 18:29:27 -0800", "Message-ID": "<20260219022929.3558081-4-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": "guard() notation allows early returns when encountering errors, making\ncontrol flow more obvious. Use it.\n\nAlso variables that now only hold error codes (or 0) are renamed to\n\"error\" to make their purpose clearer.\n\nSigned-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>\n---\n drivers/iio/adc/ti-ads7950.c | 105 ++++++++++++++++-------------------\n 1 file changed, 48 insertions(+), 57 deletions(-)", "diff": "diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c\nindex 2a7d4a1d9fa9..d31397f37ec4 100644\n--- a/drivers/iio/adc/ti-ads7950.c\n+++ b/drivers/iio/adc/ti-ads7950.c\n@@ -306,18 +306,17 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p)\n \tstruct iio_poll_func *pf = p;\n \tstruct iio_dev *indio_dev = pf->indio_dev;\n \tstruct ti_ads7950_state *st = iio_priv(indio_dev);\n-\tint ret;\n+\tint error;\n \n-\tmutex_lock(&st->slock);\n-\tret = spi_sync(st->spi, &st->ring_msg);\n-\tif (ret < 0)\n-\t\tgoto out;\n+\tscoped_guard(mutex, &st->slock) {\n+\t\terror = spi_sync(st->spi, &st->ring_msg);\n+\t\tif (error)\n+\t\t\tbreak;\n \n-\tiio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2],\n-\t\t\t\t\t iio_get_time_ns(indio_dev));\n+\t\tiio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2],\n+\t\t\t\t\t\t iio_get_time_ns(indio_dev));\n+\t}\n \n-out:\n-\tmutex_unlock(&st->slock);\n \tiio_trigger_notify_done(indio_dev->trig);\n \n \treturn IRQ_HANDLED;\n@@ -326,22 +325,19 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p)\n static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)\n {\n \tstruct ti_ads7950_state *st = iio_priv(indio_dev);\n-\tint ret, cmd;\n+\tint error;\n+\tint cmd;\n+\n+\tguard(mutex)(&st->slock);\n \n-\tmutex_lock(&st->slock);\n \tcmd = TI_ADS7950_MAN_CMD(TI_ADS7950_CR_CHAN(ch));\n \tst->single_tx = cmd;\n \n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\tif (ret)\n-\t\tgoto out;\n-\n-\tret = st->single_rx;\n-\n-out:\n-\tmutex_unlock(&st->slock);\n+\terror = spi_sync(st->spi, &st->scan_single_msg);\n+\tif (error)\n+\t\treturn error;\n \n-\treturn ret;\n+\treturn st->single_rx;\n }\n \n static int ti_ads7950_get_range(struct ti_ads7950_state *st)\n@@ -407,9 +403,9 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,\n \t\t\t int value)\n {\n \tstruct ti_ads7950_state *st = gpiochip_get_data(chip);\n-\tint ret;\n+\tint error;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \tif (value)\n \t\tst->cmd_settings_bitmask |= BIT(offset);\n@@ -417,47 +413,44 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,\n \t\tst->cmd_settings_bitmask &= ~BIT(offset);\n \n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\n-\tmutex_unlock(&st->slock);\n+\terror = spi_sync(st->spi, &st->scan_single_msg);\n+\tif (error)\n+\t\treturn error;\n \n-\treturn ret;\n+\treturn 0;\n }\n \n static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)\n {\n \tstruct ti_ads7950_state *st = gpiochip_get_data(chip);\n-\tint ret = 0;\n \tbool state;\n+\tint error;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \t/* If set as output, return the output */\n \tif (st->gpio_cmd_settings_bitmask & BIT(offset)) {\n \t\tstate = st->cmd_settings_bitmask & BIT(offset);\n-\t\tgoto out;\n+\t\treturn state;\n \t}\n \n \t/* GPIO data bit sets SDO bits 12-15 to GPIO input */\n \tst->cmd_settings_bitmask |= TI_ADS7950_CR_GPIO_DATA;\n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\tif (ret)\n-\t\tgoto out;\n+\terror = spi_sync(st->spi, &st->scan_single_msg);\n+\tif (error)\n+\t\treturn error;\n \n \tstate = (st->single_rx >> 12) & BIT(offset);\n \n \t/* Revert back to original settings */\n \tst->cmd_settings_bitmask &= ~TI_ADS7950_CR_GPIO_DATA;\n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\tif (ret)\n-\t\tgoto out;\n-\n-out:\n-\tmutex_unlock(&st->slock);\n+\terror = spi_sync(st->spi, &st->scan_single_msg);\n+\tif (error)\n+\t\treturn error;\n \n-\treturn ret ?: state;\n+\treturn state;\n }\n \n static int ti_ads7950_get_direction(struct gpio_chip *chip,\n@@ -473,9 +466,9 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,\n \t\t\t\t int input)\n {\n \tstruct ti_ads7950_state *st = gpiochip_get_data(chip);\n-\tint ret = 0;\n+\tint error;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \t/* Only change direction if needed */\n \tif (input && (st->gpio_cmd_settings_bitmask & BIT(offset)))\n@@ -483,15 +476,14 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,\n \telse if (!input && !(st->gpio_cmd_settings_bitmask & BIT(offset)))\n \t\tst->gpio_cmd_settings_bitmask |= BIT(offset);\n \telse\n-\t\tgoto out;\n+\t\treturn 0;\n \n \tst->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n+\terror = spi_sync(st->spi, &st->scan_single_msg);\n+\tif (error)\n+\t\treturn error;\n \n-out:\n-\tmutex_unlock(&st->slock);\n-\n-\treturn ret;\n+\treturn 0;\n }\n \n static int ti_ads7950_direction_input(struct gpio_chip *chip,\n@@ -514,27 +506,26 @@ static int ti_ads7950_direction_output(struct gpio_chip *chip,\n \n static int ti_ads7950_init_hw(struct ti_ads7950_state *st)\n {\n-\tint ret = 0;\n+\tint error;\n \n-\tmutex_lock(&st->slock);\n+\tguard(mutex)(&st->slock);\n \n \t/* Settings for Manual/Auto1/Auto2 commands */\n \t/* Default to 5v ref */\n \tst->cmd_settings_bitmask = TI_ADS7950_CR_RANGE_5V;\n \tst->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\tif (ret)\n-\t\tgoto out;\n+\terror = spi_sync(st->spi, &st->scan_single_msg);\n+\tif (error)\n+\t\treturn error;\n \n \t/* Settings for GPIO command */\n \tst->gpio_cmd_settings_bitmask = 0x0;\n \tst->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);\n-\tret = spi_sync(st->spi, &st->scan_single_msg);\n-\n-out:\n-\tmutex_unlock(&st->slock);\n+\terror = spi_sync(st->spi, &st->scan_single_msg);\n+\tif (error)\n+\t\treturn error;\n \n-\treturn ret;\n+\treturn 0;\n }\n \n static int ti_ads7950_probe(struct spi_device *spi)\n", "prefixes": [ "v2", "3/4" ] }