Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1919901lqg; Mon, 4 Mar 2024 07:40:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUvQLtYA9qidDP0u9dj5r7eIElRlmWLsl6esxXrtAGBVfOSLn1s7N6X0cUx+wN1b5H4n+kcNMer0ieMYUcAbdHedQcZs85o4UGkJAyvNQ== X-Google-Smtp-Source: AGHT+IEM1womOpz+/CX9MP9qv4vkilbtVk2q6zdmVTxttJztHzQf1AASBSr9ld31Z89PtcYI8kCu X-Received: by 2002:a17:90a:9b02:b0:299:2807:1eb1 with SMTP id f2-20020a17090a9b0200b0029928071eb1mr7671444pjp.34.1709566844406; Mon, 04 Mar 2024 07:40:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566844; cv=pass; d=google.com; s=arc-20160816; b=N4OcodxIq64oj4DZZGos8xd4gRuM93GPg1o2Theh7elDCXgQRMhJrAtU4iJ5u/BnMV IinzPPte76fIYSXdrArGQXizKLe6jwN5oMNB4616yCIDsz4ag7jcqYOe4fp+Qtsn8WPo iWyT6xYr+GLKuieu92KRLQEA2dznRDRY9Eaj91XrmfcdC9f4y4KA5Cm8QqDWnF9XFLBn YTz5y1dkfTgJWaCvTSSRtdDpXxo68WFPyILBR2mlq28OzxIeadyjXCPw61m7CYbjL28q I5kgH5bZtmpieHgjE56H66SKCsvH6hbxOjIiRa/XKh2aFoyEDiKPxgl+hdjCWI2/lqfm wKUg== 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=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=w5qL/RdCOoMRGVhjYU9c1omhoqIwTncw1GilO3XrhxsFsdPicbT77sOk3zgAqrjkSB CtGxn12Y6pr/L1JRp7rdvW9WxSMck4PMNXX7FoLUBDKmvUf2Q8P51lykrNVvDrp05Cie 8sycbwI7C7lRUP4VGcJrsKKi2MZHkyycm5tEDagkEzSGfxZo3TgcxSUF6A/S2/Nn928h 3snEQfZlf9IR69Y3SXaO7wS7dVSCcxQ9ZMniZ3OjRBpbSokKxyJOzbTqXZgL0EQsk2M+ wFBR0CzKTPzP+xX0LiK+xKPqvi7Xn0/K6sVfYpMocYZPo9fUPD9csMqTvOO+nLiLWBaA H+6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Nddqbk+p; 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-90843-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90843-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 st5-20020a17090b1fc500b0029a5cacd272si8538649pjb.154.2024.03.04.07.40.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90843-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=Nddqbk+p; 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-90843-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90843-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 8D19B286252 for ; Mon, 4 Mar 2024 15:37:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2D774EB3F; Mon, 4 Mar 2024 15:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Nddqbk+p" 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 718234CB46; Mon, 4 Mar 2024 15:36:18 +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=1709566581; cv=none; b=dzHvua12n8wUa95oyAWpbGZ60TB7Uk/N5UUKwCwwLdwgFqZH0kuWvMmk6YykorPPmXokZd6oA1RxJ7R5wXWv1jpj5vgQJW+FmHxuz4oVKqkaKHYYWgDn3ut1aQuZOh8sLsAC9pXj9YoYVBvRH2sYkADNEzddMaJDNyLU+nfTftY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566581; c=relaxed/simple; bh=bhAcdQhNVtJ/WY7T35xnlNhq8WgY2YmZ/UU091QPnqA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y/sMnXfYGobwfHXgk6ikoQ2f3ht6ixLQI5ZqSKnZhiccjQVLnmetKvivW2zpJM29SwMI3w4TSWzPJQQhQSs8+hZp9tJHdbY8HJbMTjKh3S0XOBxx1+vCcrGBTPdqFAGw2+8P+rQFXvVOxCO5K3C8VCD5WY8mZF7kMyTksB4hXDQ= 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=Nddqbk+p; 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 E0A431BF20B; Mon, 4 Mar 2024 15:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566576; 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=Nddqbk+pnI5GQTwJOSSeWAzxXi5gSfG5PpAV94Uq5te126mltno/izPKS64YRUTqXKDTnm +Gp5xWr6NztvDTcDfj/s1ytS/ahX7cwiNQoGEGWpS63q9eQpf+MHfqygyMrNH3PPdOVL/U pPvOKKdtZB6sGHKS+T5CM/txXhSuYxu9dXW2fBRF5uDkDiU+bc9fw1EaMRrdboy2C1E+U7 RgnAtiyRcXJiz4keIm/8ucfWJOlRtAqj9V0617CC2uTPY/YIBLj3I4La4veDTPfL+8L4Vz mZ7UDFy88LEfitW8/gzny0fz6MMMuSNKCGpurLDN1rEszy0q2htWNQt8xmeUEg== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:47 +0100 Subject: [PATCH v4 04/18] 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-v4-4-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.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