Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2064173lqp; Tue, 16 Apr 2024 06:32:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZyZmYM9EQQ2qtyjA5Pa6AfxKSVooZXduLor4j8JG91ttYcNfAuIN2qxCrDWtbdUk6Otv0EQCuV8JIsB7Z6a0GHhnhCVdOSHJYBb8lmQ== X-Google-Smtp-Source: AGHT+IE5avr4VqlbZRjMEwOeUlVI+SJvqEubioubhSKPmNuTUm4sw5s/GmR3V5ra6ghkEKqRDNZ5 X-Received: by 2002:a50:a411:0:b0:56b:9029:dd48 with SMTP id u17-20020a50a411000000b0056b9029dd48mr9412095edb.5.1713274345584; Tue, 16 Apr 2024 06:32:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713274345; cv=pass; d=google.com; s=arc-20160816; b=k1d5OEHT21RzL+WyjHOma2b9bXv+4fpKOz2tdWu4K8XZTisPAKmBwG59huidWdp6ZA spcznqztn7yyFZqD4DeM79o4atncHtC7PYvHrbOp6CHo+Kc0A6DMosnXZhm0pabI8wyT Qn9JVArAzk89nlZqpXHUMOfrqthHYJxUWhxt8uLAsv2epaAig0mwZYCM9amM+RMZPfBG HEFIx40KcnzWKZvH9kc7OoLpvekEpep++EJf8d5foO0FWXrqXf3WEP74Fq2cP/eMD3X0 ov9AJilt1428ykgTyxyMhr+qzvJjyqzarvBOUjICqWHWB5jM7vdmXzGufoUugYt/Nlq9 rPjA== 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=SQ0kRTR4gxlEX9N4HAd30m4TB4Rs0wzD+hlmlkuLdmjUuq5uHJ0hrT3R8A8bjHyu8O oq+idxPRQvJexlO6KCPsZbmjBCKfahOWiKjoHdNCl7vCq7RPAzQMOcOGXF2Nmf/Ew/tV WDDsektVDtGP1WxmYi3NJgp541+9KxhyvCDqWwfwAw3RWmEE19sjDJDfapMSwELMHOwR asDEMqIU2W3iTqiCCPMMVU2Oxdo08wZ0Vch8G1wzqOH3+lZfKFVIGoctzA2l6siCZf9v g6/O24JIVPMMmdSExqcLUo++Q9pguFz+qZZ+VtV4+yNRuUgM5ijHkSsmpZYTWWwRCiJD fbMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kzUh70Vr; 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-146885-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r9-20020a05640251c900b0056e58bf25a6si5783715edd.528.2024.04.16.06.32.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 06:32:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146885-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kzUh70Vr; 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-146885-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146885-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4E4221F21FA6 for ; Tue, 16 Apr 2024 13:32:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CAB9612FF96; Tue, 16 Apr 2024 13:30:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kzUh70Vr" Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 851AC12D219; Tue, 16 Apr 2024 13:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713274224; cv=none; b=YQnjjM7BHY0IEw18Lh3q3bKts3LUTd2nfchil+YIlSxPwGJKjILcnCJ7ix4FYR76mDLTEf/yFeA/9T4dxrYs7ryUh3Vnid+jhHAth2FMDZLgWXujETLnm10IeCRBFjDCBh/y3gv7o09Wpol5j/kSR7e8vOc3BHBKdKMpqSGbz/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713274224; c=relaxed/simple; bh=bhAcdQhNVtJ/WY7T35xnlNhq8WgY2YmZ/UU091QPnqA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SWDUqJzqUvcxm1pnyCtvygp0/K5p/qG0tXmYC6bongln0GhrlmdvKiIZGorLKGJc5FQ7dTChBuP/4VeidzEl9wasq3YJFjmZ+3A2RdYd9D6QAlQNV/UipS7Gen327lnptMNdZxq2410qJnE2HCFHo7KssMefKBJhXzGgaSzttAs= 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=kzUh70Vr; arc=none smtp.client-ip=217.70.183.194 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 CFF0A40003; Tue, 16 Apr 2024 13:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713274214; 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=kzUh70Vrr4eagnn1vKXVoieorCICcHWLdjzCIVFkuVcRjIywXs6GpVRYI21bGiut28ZERY plMS5KQD7MEEFWSz9A9Hs2rXj0mr4EQDx4XXuihwHXv+xn/5bFVdka3/q0E6kHlgNVJtZw TYwk13IUo79YaWs/1dWzCr5Du4tTPccdaTdc7ZIqXhI4LhI5KyKdyVUaRz/pxEKKEG7Vmu i7SN3aogCjZ/IllAYWg0m+Vkg8lBvz35dRyOBRdN2AJHxxbiVvk0q7Xo7Sc0iW0j33uSu+ npMeqIvd62V9pOCv7yRvabfumVQCXgNCSSj1HCTRIR5lqUDjsuxSA/wEhBuwqA== From: Thomas Richard Date: Tue, 16 Apr 2024 15:29:52 +0200 Subject: [PATCH v5 03/11] 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-v5-3-4b8c46711ded@bootlin.com> References: <20240102-j7200-pcie-s2r-v5-0-4b8c46711ded@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v5-0-4b8c46711ded@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