Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp131508lqs; Thu, 13 Jun 2024 06:08:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNXTHC5DfZUznsTXYi9L2cldk8bKmyfv6CJXHqJTy0u3rwh18SN0+O9Ot1upmCNS8feCO5dctezPzH189OkIXsJSKHScVIAgErGiUowg== X-Google-Smtp-Source: AGHT+IGGzREPxtQJSBR7DW/9NVPA51BUkDkMd8rGUYfvDcnBzudqSUPVxfM1BaD3f+UJay9p4tRC X-Received: by 2002:a17:907:97ca:b0:a6c:6f0a:e147 with SMTP id a640c23a62f3a-a6f47f56947mr378345866b.12.1718284126471; Thu, 13 Jun 2024 06:08:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718284126; cv=pass; d=google.com; s=arc-20160816; b=L2lXZjjmdQkdemLp56K9taW78RYYFxmcYU1zdqy30yqzUWupu7hsDgEA0WVwqpfz4R UcQ+bbyfPKeVSj5yGjRxu6XZjm1uP8ut8XoMlgf1HcvepoCRkUN6NDHFsQAJpt5xcdmu AnApN/uVkcyyM7v9Dkgf3rKgNdCyI94QwgKupIKLqMtD+mFmFYs/MQoR2csMQdihlizN 1Nq9wrO70qWtoqdr1dlocolMUJHMQ0fp44kIOMQlnoUxNW15cJw7Qb+m/s5vCJjfg7fM ihRxIGbTpmX7wDmyjtNlxjaRvJIndK3P8vBqVKgbBZ1MlBCGWbT0ZvJAEPXdrLU84Mw2 U+Kg== 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=qpfOLD3dQlg2lQGCyJu7ICX5/KRhRcQjupadFQHV4Ko=; fh=jhDd7fPr50pt/7AT3ZKjMssyVGTEdEgMheLVuKLyfsg=; b=wEwAU5YXgWuuHOjM59TGKox1DoXmJ3MDf75/PZ9oxAPMHPSSznS5kPEQl7kO6JCAer C+bDSgNKrlPzsd8/vrikX0jApVP/La3/IRnwr31mWeM3pgMURWM1lQQgl2dwlUnWQJq8 WLc4hGj9OPYJ61xhei8kZAzO80vOLMKL9xnYhn0anDLhrEm0Owxsnm361kKbrYlHzV/2 QqMiicwkitXWzvXzscN5uZNMDVVDBUkw8FXiejTHoaIPe3ksm0AkYV16gkwvgtYp+Uz+ UuIPKoMyygc8etC+sDT/tcXv4ICqJ1uZl9NXl82xOAR1v4B2l0JcTMblJTIM2Z3wijdx VtdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aSWnI0GJ; 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-213254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213254-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 a640c23a62f3a-a6f56dd6e07si70614766b.326.2024.06.13.06.08.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 06:08:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213254-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=aSWnI0GJ; 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-213254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213254-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 AC5CC1F226A6 for ; Thu, 13 Jun 2024 13:08:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77CDD144317; Thu, 13 Jun 2024 13:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="aSWnI0GJ" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 BB9CA14374F for ; Thu, 13 Jun 2024 13:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718284074; cv=none; b=OuL2pc2HDb77l+hYgecyu6WtKkJnaYLG5bBfdtPth1Rk2OJxaoXpn4j8W/SDSLw7j6t7nHselWn3nLZbMx6WKrPnm7TlDHsvF0enDouzfnA9fNhNJbNtL3b8YA7i6s3hayZagtelKWMZ0d+FGaAksZv+dVF44/TRuOuH+zRgzpw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718284074; c=relaxed/simple; bh=5v3OteQ+iPtQtwsfpvDZgQXYC34uG2KmvqnZtL5tCmw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MmNIV4UhfRhVepwn6c8+OwPqcUaTy7KAEqXaSuqMFfpGRCv4uwuv4vK1CDvWMFKVZXejj3b5setvfp4pR0DBwUNzfhmxjXC20Prn3IgHGEHY4dlACbCq3Y6XVcjJrgg8jOTVGA8MjEffo7FeG6kiAp+8p1gA4xUlOJ7krsOmguE= 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=aSWnI0GJ; arc=none smtp.client-ip=217.70.183.193 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 3045D240010; Thu, 13 Jun 2024 13:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718284064; 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=qpfOLD3dQlg2lQGCyJu7ICX5/KRhRcQjupadFQHV4Ko=; b=aSWnI0GJT5OsyF4/x3DUYccXEeeAlC76BYGQ9IDwjYWAWj/Mh3xZlIJpJg8QW4MshbepBP HnXAYNGeJ3Ol3fWYG3RiNPjrLJOw30KwetwhZOYoWe3VtkLsQYI/2n2d89+XGsNhqDaYfa S38cw8F3QLbqk/pDR3HuagxBGqZ4oB1jFFbhzfzWTMbVnq527E2s6bjSGjg2AtP39bRMvZ Mf6dPd2YiHfkN3GR6rsAhwQBDGA4xYE6bb0RmKKXx5uqpQUIVVEjpyZJtBBVnTNTvIaXIc +wzO+eNYrcQePdOgIN8tLRFA1ZT69BxDsbAA5wm98QuskdBBW8bi5TpX8QxXVA== From: Thomas Richard Date: Thu, 13 Jun 2024 15:07:30 +0200 Subject: [PATCH 1/2] 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: <20240613-mux-mmio-resume-support-v1-1-4525bf56024a@bootlin.com> References: <20240613-mux-mmio-resume-support-v1-0-4525bf56024a@bootlin.com> In-Reply-To: <20240613-mux-mmio-resume-support-v1-0-4525bf56024a@bootlin.com> To: Peter Rosin Cc: linux-kernel@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 78c0022697ec..0858cacae845 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