Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3206976lqo; Wed, 15 May 2024 03:03:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9j1OVPVxvkAtV9jY9M7Z1yTXwxzmMS3BmxQNlAU3UkfByO15m8Ry0/s1pKLg2TbY2kL/+LNJueLhsmf7kFq8BHqoC4A6vdEPberFpww== X-Google-Smtp-Source: AGHT+IGERtcjQWpseKET2/ujGZHzuB1n43XFpI+aoTwKjwWeo7NkXPckfiwZJJcigzr3MQVb5iSi X-Received: by 2002:a17:90b:37cb:b0:2b0:e3b3:78c2 with SMTP id 98e67ed59e1d1-2b6ccd8e08dmr12866359a91.48.1715767386211; Wed, 15 May 2024 03:03:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715767386; cv=pass; d=google.com; s=arc-20160816; b=zOp7wFsof51QzTsLUYzp9ifGSc+R2bonZ6SUgJDdlHzzaJCLN4zZuo46HlZAhZ51l8 qNZ355kc8bM3od2BXrrEF0YX+Cc9xlgAJAPBQ+QWcFGapy3t5MfErksB8DulC16XCLVM +xquw0G1Ta2w/ZBnhF4oZ7afXqzVRyLdbYsaGgXlwGvWGcc6cCFHoUh9HtavU5SVwm76 B0XW5yBIllSXGNZuItFk1n3vyjKlBqJEnhOlgRFUlAS2zSd1Lz97p5FSztFyiZ2LQr3v K7PW5CoXnuq5Wc3OyeUqV1IS2Kw2vR2DZJSgka4cBN7eTR4rvi/0wt5klPo4BKndvWNJ uIDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=N+wkZZoLT0Vq8kTdRlFm+WcHMzeYn9ukxLpZ0zVifpE=; fh=+6o6d2KGt2ZTSidIuE8uz1q8yt3pK0TjTqozrmclSIs=; b=eU+87uEumn+sy6LYQ2ia5xs9sq8/nQamOPKCmWQ1xZc03pB0ycbzeccB9HHonEo9FL 4iDli4n82CAfge3Pr8TeiHACd7bJGrXIyXRQlwAq7osfZhFDw6eoyiEv27gkSqoMWuhl u414FcuOPZdb4D6gOAk9jR6wkZDXA09oI56juKeA+tn6ciCq4BtUJa+xeDnvyacGp0UC hKICgMf5ZxEFa/TqQhbXgPoU9Um6g/vk8HCEyXELKTSYMcyYAsrotKolHeAuIt/1HXtc qKkcR/QIsTJqi/NJZpiXIUBlL88mkAB10d3l1Kjml61mkOn5y/SFhGBteEUoMdwUXLhH CODQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cNBRb8zB; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-179738-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628ea7561si15140332a91.97.2024.05.15.03.03.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 03:03:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179738-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cNBRb8zB; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-179738-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0BC44285804 for ; Wed, 15 May 2024 10:02:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9948865E20; Wed, 15 May 2024 10:01:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="cNBRb8zB" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BD7857CB5; Wed, 15 May 2024 10:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715767294; cv=none; b=JcPRVJnP1n36rbJ2zsMDygT/sS9UfX/CqPatt5C97OMLP6yWsw99GwoP0uPivnJWkz3XdlWRfH0oydWl5rRnQ+9ZcvyNOegV2wIQe/xcithCSlWwAyGuhDd5uvVZCmRtkztiWYBMqIFwKo2LUt5ZGuA7EzxrYOXgpOKphUD7Ck4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715767294; c=relaxed/simple; bh=bhAcdQhNVtJ/WY7T35xnlNhq8WgY2YmZ/UU091QPnqA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iwLQCu1BmEwz83uxeRNbkt9e2CoX7/LvCnHlF5UNUYUmxWF/JJCkHpmLtcJANgDm+TcKKEPQkmeEVQh1eBzWfrTkZU/Xu3totPVa6qpwYH+NgGLLDgrilx627PEVOonwX3AqFW/nGM0DqayOfEzFobRrXYF6wIY83/aYSI3xVfc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=cNBRb8zB; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id B6D1D1BF210; Wed, 15 May 2024 10:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1715767290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N+wkZZoLT0Vq8kTdRlFm+WcHMzeYn9ukxLpZ0zVifpE=; b=cNBRb8zBe+JjMEZF6FT1jsL9U4lBNAlJGwJ8GS5VMrImE4s0mjD0BJKL7wretuCqvmeNi0 pd1TNX1ChQG0UrHj3htbepPRSyXAiKWpO4VX6FGZDy/iEhA5aQBZLvAfGKtg/YKF0O18vC +H5zg1Zb8yCBDdAqBr7DvDZHtFdlxGSsC7o3nwqN0m4B3eWtzpazkj/CANyenJss7M4iT1 sEL/05ypLF5l4uoAXFXnWn3xY8hnV1UbM0YFOiE4yYOqhfpVJ6kfKtQbBdLJc4/BVwDzRN xkSZN8+Q10U6mn7dNxUKjf65IbSZZgXc5l2rEnYA4jQiac+hm/HUy+QzWyOELQ== From: Thomas Richard Date: Wed, 15 May 2024 12:01:05 +0200 Subject: [PATCH v6 04/12] mux: add mux_chip_resume() function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240102-j7200-pcie-s2r-v6-4-4656ef6e6d66@bootlin.com> References: <20240102-j7200-pcie-s2r-v6-0-4656ef6e6d66@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v6-0-4656ef6e6d66@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Tony Lindgren , Aaro Koskinen , Janusz Krzysztofik , Vignesh R , Andi Shyti , Peter Rosin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Siddharth Vadapalli Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com The mux_chip_resume() function restores a mux_chip using the cached state of each mux. Signed-off-by: Thomas Richard --- drivers/mux/core.c | 29 +++++++++++++++++++++++++++++ include/linux/mux/driver.h | 1 + 2 files changed, 30 insertions(+) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 775816112932..0742aa2a7c73 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -215,6 +215,35 @@ void mux_chip_free(struct mux_chip *mux_chip) } EXPORT_SYMBOL_GPL(mux_chip_free); +/** + * mux_chip_resume() - restores the mux-chip state + * @mux_chip: The mux-chip to resume. + * + * Restores the mux-chip state. + * + * Return: Zero on success or a negative errno on error. + */ +int mux_chip_resume(struct mux_chip *mux_chip) +{ + int ret, i; + + for (i = 0; i < mux_chip->controllers; ++i) { + struct mux_control *mux = &mux_chip->mux[i]; + + if (mux->cached_state == MUX_CACHE_UNKNOWN) + continue; + + ret = mux_control_set(mux, mux->cached_state); + if (ret < 0) { + dev_err(&mux_chip->dev, "unable to restore state\n"); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(mux_chip_resume); + static void devm_mux_chip_release(struct device *dev, void *res) { struct mux_chip *mux_chip = *(struct mux_chip **)res; diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h index 18824064f8c0..2a7e5ec5d540 100644 --- a/include/linux/mux/driver.h +++ b/include/linux/mux/driver.h @@ -88,6 +88,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev, int mux_chip_register(struct mux_chip *mux_chip); void mux_chip_unregister(struct mux_chip *mux_chip); void mux_chip_free(struct mux_chip *mux_chip); +int mux_chip_resume(struct mux_chip *mux_chip); struct mux_chip *devm_mux_chip_alloc(struct device *dev, unsigned int controllers, -- 2.39.2