From patchwork Fri Jan 26 14:36:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 192621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp701130dyb; Fri, 26 Jan 2024 06:39:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV8DW+/la4cdvHc7uw8HuD3W8e1KSHTKmuAfVW1yAvWK4GMfm20fFER+AfMbd8ZDkQU7pR X-Received: by 2002:a05:622a:1011:b0:429:cbc5:41b3 with SMTP id d17-20020a05622a101100b00429cbc541b3mr2491116qte.59.1706279970643; Fri, 26 Jan 2024 06:39:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706279970; cv=pass; d=google.com; s=arc-20160816; b=HxKbbSzikdGwzqtIiboXuXKruF0fndR94LifXF46I0R+TDpR0cEnCqoHyGzUp1de66 ZadfrVyqLGhQRYePoWRa8v5iXDB2+QRErboG6BW37/AkIFhZJPnVXXTXf2PsbEaKTkXh dAYS/P8gIkA56fM3472EhgtdVRj5DXrr0OLLrChxd8mKHQeYf6ronNjr5ZdJt87Gq1Zt Km39kc+uw8utrEPWlXsP4CDSgoTSOcOOL1a74JYDdQOkxEynW7LjjNPb0UfKBvOnlxr7 NNdFbJHDYPauAi8OMnu8eDkyXm7f24xh1TqN2K9ytLiWT7hYNsYtBrkBwxg1swvycsLP bJaw== 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=Cbw3dfSNoiflIv8mn1Y7eM6xBgXjeUJCd/7i0kUTDu4=; fh=ihwxVJW8DyodhmdJo1IfhLUDNDWeXh+49SpWXYbpL2Y=; b=cm5i9+oXCPdlhZL+gNd9hulYH+zAZHhsGr86+GGKErAtK2C3SukYWNBdkcVqgP9th/ lrloxxI8dGG/NK4vx+Qmu/ESW7WqeeZBg/zgtpuuKz9DlJckF4rkombqjdhKqaH9qFeE gC71LpgjVfYcAn6d+TrkAMpGx2oqXTvAJeLinIAtautxQ2kRYyOh6p0aQgUh2449Yj4k +4LjNCGKzSYp0ttlP/9xHtJtj6rje/O3eR7KWwYD8aIC/hdi3+c0DYH02NTT8cvYSD2J bKnVRnvYq1BbxncLq/eXZVIzXBdj6RMHhYNMGrdHwZDHimKatzouu46+sy1ST71rcMFO 12rA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HIsJspIS; 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-40203-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40203-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c9-20020a05622a058900b00429948c78d3si1310380qtb.652.2024.01.26.06.39.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:39:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40203-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HIsJspIS; 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-40203-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40203-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6EC141C20BDA for ; Fri, 26 Jan 2024 14:39:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 095C51DFF5; Fri, 26 Jan 2024 14:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HIsJspIS" 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 9D6EB1CFAE; Fri, 26 Jan 2024 14:37:45 +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=1706279868; cv=none; b=cRxEkOKmu5Cw+tNQcfDGaqXR6x3DCmJrZHmYkpAWZOa+tUpq0xEupd+FsbeS71fqXt9YXQXCbo5wjZxhcNAvLc/cswBboyQpxfQbvUU3OII7xBKUaK5kYqUHQlo5R1MeJzPWgKUjj1UQRhcor+oYsHQt4cMlQg9/74tRhVTK2DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706279868; c=relaxed/simple; bh=dQ5Zh+9goreKLgpbAXuuVsk4U2eqh0p5tYj9u6TxiXA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qdfxlA9C3wWuA+dh003s19lGZLDoaqs5JWkZ9WmFLz5GfLdTlghZy2e9b+T5+N5EEVxMGgBUU+GHMenOyJJQhH/vUJtsjmML+COMnPBT7xYOSzPf3S1iU/5IXNETxA0P95UKebn6Eg2twMEaVymyyxp13xYyusPmWhgH2Vy+cyg= 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=HIsJspIS; 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 564F440014; Fri, 26 Jan 2024 14:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279863; 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=Cbw3dfSNoiflIv8mn1Y7eM6xBgXjeUJCd/7i0kUTDu4=; b=HIsJspISmq9+z03H8FRmqs/PxBEH2bY6w4YjXjpYjf84eeKJKyfRd8h7X97Ckfs/vM3MN8 ajG8doZk8ZKGo0M0j2VzYTFIybcYp+s+vCjyP/8oxsw2XTGpgO2xoXsDHyJFC72xsmtC4f AXZsPD7frToR88bXP3aSHZaNt/l/vagv9KnKtzOiWYuEwG3tAnhnHslb77YNE1AKgWGWWX qNQ9WKUME2rM1gjPiHlGBxFadl0hJzjDgSgSdsUbR93+dFkFXzMl7gwvUWiR/Qv1nMJAGk 37288DOuqlcr95ZCxnsxf3sZcdeb0yMzaNJhmrcILe74lVQjnNpKzbZiaQEOvw== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:46 +0100 Subject: [PATCH v2 04/15] 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 Message-Id: <20240102-j7200-pcie-s2r-v2-4-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@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 , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789164226410746833 X-GMAIL-MSGID: 1789164226410746833 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 | 27 +++++++++++++++++++++++++++ include/linux/mux/driver.h | 1 + 2 files changed, 28 insertions(+) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 775816112932..896f74b34eb8 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -215,6 +215,33 @@ 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) { + 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,