From patchwork Fri Jun 21 20:51:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 807480 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.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 650F017B518 for ; Fri, 21 Jun 2024 20:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719003101; cv=none; b=OxagvJZRKK84cR7pi5ecSOlfpsc40kehgZjfMlDaOXxhKFNCmIWdJZ8aJTKw7mooKY4/nRzftj5soml5d6R/q3ov6E5LXNAFOodUgTcfQS+sUCeFaDd0q1HNqKsSzc0h6ZmGQOp3orustXbc1mFJYcwqmfRMdn7DqqYw+ao1WT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719003101; c=relaxed/simple; bh=+CynpsRL81h40b5tqxPnjqbyMrBT1lpA5JK1F0hNPbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WybGdSlFY5RuzBUfnYrKmpRYgFiwFClWPEWtM3l09G1MoQ9CSjcvqDECHqyyizs+LwJk8FglETX1fYk2q8vf1Vw3hMXRR+pyogRgWPaqx3ymWAwftsYob5Cd/b+dtbT7cwiMt107xrDAp/FLwcQ/V8a7VR92pQ/Q/xTD16VFRPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=mOmvYGs9; arc=none smtp.client-ip=209.85.167.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="mOmvYGs9" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3d21b3da741so1283743b6e.2 for ; Fri, 21 Jun 2024 13:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719003098; x=1719607898; 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=dBilKbtyKaHgD4sJzumuCXzjgUuh0tXDxL1EowMx6eM=; b=mOmvYGs9/0618h9mkFvcnNaYVcsopaZ72ch49Y9QrFQl4GU5yOHXNgzOicn2QpQQ1z FIzipIjm9E3qWhCXtbiAqTH7ESrVwM8zFKsETv4Vh3G5+U7mz1plNdG5LCFPX2xn1v9U POblZHCMvrVzpkxye7LsdjZUx8AOm/UEr4msvlRMGmpA7gA9cWtp/Wxf2avlKurXl8CR AzYxvt7gvK9i8sWStCDkdjDAojSMBt1OD0umcwcvStp4DsUsFoxVkwmXk+Wg7ndWePPA H+Uy0V45A8c3DSxwbhcOzBH4a+VAdrOgKAYxD4nn/G+iKdqqbM1ugECUq+99Ka36L4IT 7Sqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719003098; x=1719607898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dBilKbtyKaHgD4sJzumuCXzjgUuh0tXDxL1EowMx6eM=; b=gIVbj2E4TgNHredmVN1WTqj6VE0R8elwvxEZOv5eFuz1WfC3kV3AB9B3YNsDQann16 VNx/QGVFNOAMfPZPGCy7XcNPxrgwDPT2Wo+6zDV7eeDyrbKgxAfEqDyw1y1raLlZvlCu 0B1BNgn/sZ75Y5oOxf3hqebF7Z1f8ktJStSgOdqrRRkhlpv68hXWrr+nZ324jiWcmILv oRQvyj8BCO6F9ELfpr/37aFduTFPSm1tIOMHq56C51sbf8lxe7CoQev0nFA2n9pu6FI0 +eIU8Ehdqtzb1EjhtWkH24H6RH9DeVCer6E+P9nKB7TLSkRR5O5u13kXTdCho8rZ4w+P tzUg== X-Forwarded-Encrypted: i=1; AJvYcCXM5+wwVPoCu9awXLyVXuPjdplZKU7bhi6I0RN08YnE4p8t3rmeUSelipdJ6WAfDQcPhIyeGGpAmHLF5UfRZi5xnWjPrMFOdxhT X-Gm-Message-State: AOJu0YwoPLJIcYO9uGz/3EKOfQ/kYdtnzNZIOFufvxo7Iu3E6L2Marx1 wMu5BI2ZELEycZh4ruqb8HtDruPQgEidwXzlv6I2QWJXZW4JjCITQ9JXjgwYf78= X-Google-Smtp-Source: AGHT+IHnk+rCUQBAjTY1eOZDYEzFvuFJ00p33gyVBiqrWryWPSi7nD+p40F2ECvVGx8mQu8QqHlakw== X-Received: by 2002:a05:6808:1381:b0:3d2:283c:e51b with SMTP id 5614622812f47-3d51baeef5emr10287287b6e.52.1719003098305; Fri, 21 Jun 2024 13:51:38 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3d5345e584dsm428089b6e.55.2024.06.21.13.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 13:51:37 -0700 (PDT) From: David Lechner To: Mark Brown , Jonathan Cameron Cc: David Lechner , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Marcelo Schmitt , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH 1/3] Documentation: devres: add missing SPI helpers Date: Fri, 21 Jun 2024 15:51:30 -0500 Message-ID: <20240621-devm_spi_optimize_message-v1-1-3f9dcba6e95e@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621-devm_spi_optimize_message-v1-0-3f9dcba6e95e@baylibre.com> References: <20240621-devm_spi_optimize_message-v1-0-3f9dcba6e95e@baylibre.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 A few SPI devm_* helpers were missing from the devres documentation. This patch adds them. Signed-off-by: David Lechner --- Documentation/driver-api/driver-model/devres.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst index 18caebad7376..a1c17bcae68d 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -465,6 +465,8 @@ SPI devm_spi_alloc_master() devm_spi_alloc_slave() devm_spi_register_controller() + devm_spi_register_host() + devm_spi_register_target() WATCHDOG devm_watchdog_register_device() From patchwork Fri Jun 21 20:51:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 806646 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.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 EBF1617BB15 for ; Fri, 21 Jun 2024 20:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719003101; cv=none; b=VzwItkStdpQqvFmIh3/H61+qoU/gk94jTXaAXvfRVnSD1ApoUCHyhnqtwxYjHLCWdXmTaH93wBkZbeXJfNX4W4QE9SaefEV8Op/gznbf/c4SbrUe4qhgsMdtG0E8YsfKqMjsQcanfozz++MKoqInMSXrBj51ff/YPfPyzLZw/8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719003101; c=relaxed/simple; bh=tQGiPDfmisofm11aHAvZFzPZ0bp5Gzbq8GMeABdspDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K7g4NErAjxDpEBj6ZQcWjfAlUHPlCJ2AxU6dkgJXe29Nt3bjOzfek/At9wauG2HOrzjS2K4xVHAfn8sAbIW1bW7qeLEv4mxqc//K7Z7MrUvd15ajiTi9N8kDagcO3/L/BNA9bvhS57WkCqSVmmwYL2iwyduXEXGV3O5i7qhrXYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=i0lEz8LV; arc=none smtp.client-ip=209.85.167.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="i0lEz8LV" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3d513eb6e56so1283600b6e.0 for ; Fri, 21 Jun 2024 13:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719003099; x=1719607899; 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=sRH2tgmU1zOdmEBVnxQ+i5FH9HPtNyS8KbbO3YRf2c8=; b=i0lEz8LVqIAkixVLS4Vts0zMHMbu026Utmz2j84VWucg+ux0OXwZePvNOb7SANnznK +2pspkAN46M+95MTGvMs+1qBn9rQlO6KcZvUc9sz3HUxWI8q8p85PZEnRsDjpcLzWx+Y ivOXbptAGViK6bnsOZlokOPl6je0cZ2LgiUDzRJAns+0g6jkuuZHOWVOaLwgFrWstkW+ zRpM7bCTN0i9VVpKMla8tO090E5I8TWKR2V5ai9xzwJalnvEDoIZDGBQ5cHnNVgL3u1H RNWdVZPpmMkIZGaJDo4XVs+wTAUIZElYqKZINz6z7sJeEeWw/+h+75zp4r7IlaFBLTxL qAzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719003099; x=1719607899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sRH2tgmU1zOdmEBVnxQ+i5FH9HPtNyS8KbbO3YRf2c8=; b=cRR1AqvMdcz5tZf/IRtqZOLRM6s9B31UC0kJphXR0/+KtxVgZD6TpcCWfWSnLbvoEj c8gtPAByXefe60CzFPYC2tQN/wIMIusQtU8+tQezxyfbej9LuEpmFoTeEV6S0NmWezmc UGdApA3v9PtbqSwyHEMHVsPMWvD9q9G43xbLGrEsjTKaIpQjtN1SdydET243L+LbZtDx 6NQsRR3P/ZFSwj0x8RD9HnlUsR/HoIIL/VAAvTb8KLQW4ksN2jSoGlj3k4ntxgKQIdxi o1GFVhwUci5XlCn6Vw+rfqWBSkXFTkgiezPyKOwayjJOJ1MAJLG8qAslAVObMu2+5N00 hKUA== X-Forwarded-Encrypted: i=1; AJvYcCWsd+EevDSVEScXz4G1/Y3p1U+MBjGHfoW3vcAaRw761K+zERtTKrQDexddfrTws8ndoKtysG7nwu93GGDv/p5SjPRpvmyXgsnN X-Gm-Message-State: AOJu0YxmcOEkJgRbLLf8srD1P1zp7UVzMaxPARjEBwNEt+PjyJowh0gX /ZQUThGCWOxcEpqKTDyMBhecQzYlS04Lxc3B7Ic2VwNiEypCfrEjAS+3cljmC7c= X-Google-Smtp-Source: AGHT+IHTuWYSYqKLh17Ge8FwVWf/S8UQalIkBMaDZf4pQVzFsewbBSX2uAh2uzY1f8+9FdIKabxjCA== X-Received: by 2002:a05:6808:15a3:b0:3d2:464e:538b with SMTP id 5614622812f47-3d51b9779e7mr8351026b6e.7.1719003099129; Fri, 21 Jun 2024 13:51:39 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3d5345e584dsm428089b6e.55.2024.06.21.13.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 13:51:38 -0700 (PDT) From: David Lechner To: Mark Brown , Jonathan Cameron Cc: David Lechner , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Marcelo Schmitt , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH 2/3] spi: add devm_spi_optimize_message() helper Date: Fri, 21 Jun 2024 15:51:31 -0500 Message-ID: <20240621-devm_spi_optimize_message-v1-2-3f9dcba6e95e@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621-devm_spi_optimize_message-v1-0-3f9dcba6e95e@baylibre.com> References: <20240621-devm_spi_optimize_message-v1-0-3f9dcba6e95e@baylibre.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 This adds a new helper function devm_spi_optimize_message() that automatically registers spi_unoptimize_message() to be called when the device is removed. Signed-off-by: David Lechner --- Documentation/driver-api/driver-model/devres.rst | 1 + drivers/spi/spi.c | 27 ++++++++++++++++++++++++ include/linux/spi/spi.h | 2 ++ 3 files changed, 30 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst index a1c17bcae68d..ac9ee7441887 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -464,6 +464,7 @@ SLAVE DMA ENGINE SPI devm_spi_alloc_master() devm_spi_alloc_slave() + devm_spi_optimize_message() devm_spi_register_controller() devm_spi_register_host() devm_spi_register_target() diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 54cbe652a4df..3f953504244b 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -4358,6 +4358,33 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) return ctlr->transfer(spi, message); } +static void devm_spi_unoptimize_message(void *msg) +{ + spi_unoptimize_message(msg); +} + +/** + * devm_spi_optimize_message - managed version of spi_optimize_message() + * @dev: the device that manages @msg (usually @spi->dev) + * @spi: the device that will be used for the message + * @msg: the message to optimize + * Return: zero on success, else a negative error code + * + * spi_unoptimize_message() will automatically be called when the device is + * removed. + */ +int devm_spi_optimize_message(struct device *dev, struct spi_device *spi, + struct spi_message *msg) +{ + int ret; + + ret = spi_optimize_message(spi, msg); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, devm_spi_unoptimize_message, msg); +} + /** * spi_async - asynchronous SPI transfer * @spi: device with which data will be exchanged diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 85785bcd20c1..a9388714e7e7 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -1272,6 +1272,8 @@ static inline void spi_message_free(struct spi_message *m) extern int spi_optimize_message(struct spi_device *spi, struct spi_message *msg); extern void spi_unoptimize_message(struct spi_message *msg); +extern int devm_spi_optimize_message(struct device *dev, struct spi_device *spi, + struct spi_message *msg); extern int spi_setup(struct spi_device *spi); extern int spi_async(struct spi_device *spi, struct spi_message *message); From patchwork Fri Jun 21 20:51:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 806645 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 DE8F317B4F2 for ; Fri, 21 Jun 2024 20:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719003103; cv=none; b=jaDAUcFZswvyzQGFrDyPJAspkmlGLJBM6SktQ+wSea4txyhvXMrMizGr/Rf1iE03AFTb0nyqX7ig1FSbQSv5Kgn90YOdE9Qov+gJ1e+k3fAVHeWoRGRsRiHXk3F25ydbKyf4oQJprexCWmlZXECQSKt61+iRkrSWU7w8QpqH93U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719003103; c=relaxed/simple; bh=M5ncsogjwIKi7yTwd3on+qTwjMFKb9OhWUuYpkcn5s4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bkc3gN/BQi4Hze4FndY7bh/T7tzE9YcHC7n5kSJWjkwJQOSQW+pNnx+Oph0J/zlUmfP3QzvEkDSqSANMjCuGftg86E4wudKbErBwrS/j1zkfNAZCMD9+Bpx0mPZVCuQcprXHmET6F/giLUp6nnbDFWxHaaWajsGYFkh5X4unCuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=OQMtcmVH; arc=none smtp.client-ip=209.85.167.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="OQMtcmVH" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3d218ea7750so1331018b6e.3 for ; Fri, 21 Jun 2024 13:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719003100; x=1719607900; 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=keq6dAlPadRHMn2hspGHDGXT5Yre2UihnSFV/6UPPyU=; b=OQMtcmVHb2os4Ig1fSbc4NNPpl18XL6hFGMqxJ/1M1WyX+fBoxFTKG+ayktWk4FB2F b358bfJvHJjh5Ibn9Q8UhU7xWaMz73AKXrHVHr4itznrmB0SrADT+q1g7CUAkR8xQzic QNEII7HYMX4xZntONgf2IftB81wGXVX4cmQCCEkpeadZ4JH+V9EWPe4jHtoUgFbNlYxy GuvYUxoHLWHrA/ZMotsBCBAGI2lOQVZ4auvqaL3k7Q1NMFMynNhu6Whwn4aUUJSWtvqt 0DpcUnqpkPqEvASsjd5mCIradRm6y8QJqNfk/pNtYzj+enT7NSEudIKMtgbamasyNtBK H8Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719003100; x=1719607900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=keq6dAlPadRHMn2hspGHDGXT5Yre2UihnSFV/6UPPyU=; b=dyPSj7i5UUaHu+2fgvSygyiL2ItM2pJ+d00J4C+snX4dXm7B/DEgkEy5ZowyzF9rFg NUac/F8jlss2xVlKACnY37gAx0GuishRjYi6k8/leaoL/A2j2gN+p4JYYSC+Lfp637LU Cm0milSmm0ZDY/VSGnW5Kh5RsXp9Xwf8VTDlFhk3n4yOBEECvv/3PWvfRVefe6/8gqMX 7pvlpOtBMaf7MflsYx5NutpyOCp/LH/FCzXsycwwXnICcd1d9dBzq/HrQ9ACJh24VgFc IG6PrGWvwdklghqmx0z6RZ5UPjLkPA7A7niIDNqhsq5DaDGFt89CMbgB+vG5HmbyJazc r9NA== X-Forwarded-Encrypted: i=1; AJvYcCXkQR8903jPpeReIWFJEuuu47vZb881GZQdkDlEfWdbGZtZPjOcpscJwFmYu5XSFmp/RoMnZxsRzZyXlgmGqMHdzKNZ74r+p2D+ X-Gm-Message-State: AOJu0YxuqyvCrZtlZjXIqhW7Ru4tfDdoHjFX6fW6h0I8kUUAzWp+dbV3 XnTAiW9AuFlBXxpWqXRIarj08h4FJ6WaNy33/AOQ6SGKb57ImdIjZQdpY8cpLnE= X-Google-Smtp-Source: AGHT+IEczRmq7EpJ/frerAFCfsSGm1g7w7xf40xN3hyRyZjge33d8FOSAQi0k4RN4+jkSstOJt1cxg== X-Received: by 2002:a05:6808:f8b:b0:3d2:2aa8:3b2c with SMTP id 5614622812f47-3d51b9e2b73mr10572440b6e.33.1719003099967; Fri, 21 Jun 2024 13:51:39 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3d5345e584dsm428089b6e.55.2024.06.21.13.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 13:51:39 -0700 (PDT) From: David Lechner To: Mark Brown , Jonathan Cameron Cc: David Lechner , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Marcelo Schmitt , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH 3/3] iio: adc: ad7944: use devm_spi_optimize_message() Date: Fri, 21 Jun 2024 15:51:32 -0500 Message-ID: <20240621-devm_spi_optimize_message-v1-3-3f9dcba6e95e@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621-devm_spi_optimize_message-v1-0-3f9dcba6e95e@baylibre.com> References: <20240621-devm_spi_optimize_message-v1-0-3f9dcba6e95e@baylibre.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 Use new devm_spi_optimize_message() helper to simplify repeated code in the ad7944 driver. Signed-off-by: David Lechner --- drivers/iio/adc/ad7944.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/iio/adc/ad7944.c b/drivers/iio/adc/ad7944.c index 4602ab5ed2a6..a6ac17c13a29 100644 --- a/drivers/iio/adc/ad7944.c +++ b/drivers/iio/adc/ad7944.c @@ -134,18 +134,12 @@ AD7944_DEFINE_CHIP_INFO(ad7985, ad7944, 16, 0); /* fully differential */ AD7944_DEFINE_CHIP_INFO(ad7986, ad7986, 18, 1); -static void ad7944_unoptimize_msg(void *msg) -{ - spi_unoptimize_message(msg); -} - static int ad7944_3wire_cs_mode_init_msg(struct device *dev, struct ad7944_adc *adc, const struct iio_chan_spec *chan) { unsigned int t_conv_ns = adc->always_turbo ? adc->timing_spec->turbo_conv_ns : adc->timing_spec->conv_ns; struct spi_transfer *xfers = adc->xfers; - int ret; /* * NB: can get better performance from some SPI controllers if we use @@ -175,11 +169,7 @@ static int ad7944_3wire_cs_mode_init_msg(struct device *dev, struct ad7944_adc * spi_message_init_with_transfers(&adc->msg, xfers, 3); - ret = spi_optimize_message(adc->spi, &adc->msg); - if (ret) - return ret; - - return devm_add_action_or_reset(dev, ad7944_unoptimize_msg, &adc->msg); + return devm_spi_optimize_message(dev, adc->spi, &adc->msg); } static int ad7944_4wire_mode_init_msg(struct device *dev, struct ad7944_adc *adc, @@ -188,7 +178,6 @@ static int ad7944_4wire_mode_init_msg(struct device *dev, struct ad7944_adc *adc unsigned int t_conv_ns = adc->always_turbo ? adc->timing_spec->turbo_conv_ns : adc->timing_spec->conv_ns; struct spi_transfer *xfers = adc->xfers; - int ret; /* * NB: can get better performance from some SPI controllers if we use @@ -209,11 +198,7 @@ static int ad7944_4wire_mode_init_msg(struct device *dev, struct ad7944_adc *adc spi_message_init_with_transfers(&adc->msg, xfers, 2); - ret = spi_optimize_message(adc->spi, &adc->msg); - if (ret) - return ret; - - return devm_add_action_or_reset(dev, ad7944_unoptimize_msg, &adc->msg); + return devm_spi_optimize_message(dev, adc->spi, &adc->msg); } static int ad7944_chain_mode_init_msg(struct device *dev, struct ad7944_adc *adc, @@ -221,7 +206,6 @@ static int ad7944_chain_mode_init_msg(struct device *dev, struct ad7944_adc *adc u32 n_chain_dev) { struct spi_transfer *xfers = adc->xfers; - int ret; /* * NB: SCLK has to be low before we toggle CS to avoid triggering the @@ -249,11 +233,7 @@ static int ad7944_chain_mode_init_msg(struct device *dev, struct ad7944_adc *adc spi_message_init_with_transfers(&adc->msg, xfers, 2); - ret = spi_optimize_message(adc->spi, &adc->msg); - if (ret) - return ret; - - return devm_add_action_or_reset(dev, ad7944_unoptimize_msg, &adc->msg); + return devm_spi_optimize_message(dev, adc->spi, &adc->msg); } /**