Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754413AbdIHPqk (ORCPT ); Fri, 8 Sep 2017 11:46:40 -0400 Received: from mail-ve1eur01on0111.outbound.protection.outlook.com ([104.47.1.111]:52448 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753515AbdIHPqe (ORCPT ); Fri, 8 Sep 2017 11:46:34 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; From: Peter Rosin To: Hans de Goede Cc: Peter Rosin , MyungJoo Ham , Chanwoo Choi , Guenter Roeck , Heikki Krogerus , Darren Hart , Andy Shevchenko , Mathias Nyman , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@driverdev.osuosl.org, Kuppuswamy Sathyanarayanan , Sathyanarayanan Kuppuswamy Natarajan , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH 2/2] mux: add explicit hook to leave the mux as-is on init/registration Date: Fri, 8 Sep 2017 17:45:14 +0200 Message-Id: <20170908154514.4463-3-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170908154514.4463-1-peda@axentia.se> References: <20170905164221.11266-6-hdegoede@redhat.com> <20170908154514.4463-1-peda@axentia.se> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [81.224.168.30] X-ClientProxiedBy: HE1PR0301CA0017.eurprd03.prod.outlook.com (2603:10a6:3:76::27) To VI1PR0202MB2557.eurprd02.prod.outlook.com (2603:10a6:801:6::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6b77096-914a-4fa6-660c-08d4f6d0c74c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(2017082002075)(300000503095)(300135400095)(201703131423075)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:VI1PR0202MB2557; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0202MB2557;3:NQNbPGsX11XulRagV2Vxm4Cufuuq7aq+DsJ6thzV3/vAuarBgHPO2mHG8d6CF45Xzo5F2bgiFpSiXXoQDoTdL9Ad4VeD1vUkoYMC/lqJN/c9lCBolV4BLNOpxcaBBBYZOMz7byAxAO3IJYRdcQe5ZsbU/oJUYTzsfjyVQyuf7xZM1i3t2W/y2jAnLK6GJf6mbSF1Mu/S6vpRqsYMOsY/0sBq2riEqH2WovM3YIS2iinsO8kzkzmsxgFrZrik1Vu/;25:/WOPJpyKkYvOZsAYCcYjJDvPE3XWV9OOrnH9GJTATcWO5JbW0inv94YwK5fc306bpXhRPfpjdXRYlocnvPOVNSvjoAQROvXr0ECjZoNgEtYuNPphFT1CfdC43Cp226aJrPmWEgfjvbSdIT5WTJcxCHL5gOBG+oQ5f9yMle/1jEXVXjO5b/GVh1zqQtwMQNpQDI/xZWrBBy0XkZWhgSnh3PYQ9+BKfKS41/HX222i2Im00RylhrwmgcNA7AxBczPBR0Uc5Ae1fu2kc3xitngfiKwnBYe8MIvUgMKRKX9vp7Y6X0xqnK7kxOymlWhHuLnStqmggf21/W5V2imbHKHDAQ==;31:mVtPyThPt+p/V6oU594MBwJovQeWO4kLDFNNyaJt5KlGxOagiCmCVhuciQ7lKNz33+NyBXLq/9/bakD/XcyMNS/gGFxTn2mtxHpL6dz+kKUVxiferKy+tTsxXa21Enj24J83ySosk5QMwzusAZQ1RUTjRtvWQclHSmbvjGHf7cLr91Y2I1YbARhCs95C3OO9O7Xu2bCxfb/lTFAjzQ+6LQei8Hes8qGgDPnxor5kduw= X-MS-TrafficTypeDiagnostic: VI1PR0202MB2557: X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6041248)(20161123558100)(20161123560025)(20161123555025)(2016111802025)(20161123564025)(201703131423075)(201703061421075)(20161123562025)(6042181)(6043046)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0202MB2557;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0202MB2557; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0202MB2557;4:hsW4ykyN9pSR2h1h59CcDwBw5gaLqZ0N96zK4RpNdkICjpJOOjAa6YSVukvV/dKt64hk+stC/Ak9kfJS0ywx08YdS2R/gVPlB3LpvE019weVMA0YP5Rujl4BNcIQzupKO6mEMtCNBNOmaHvJCyhIg5YpcVp6HfRayiU/vRUrELweMRqXOPqPpZ8o0KVfY+rh8kQVV5rzpCuVE+7Z0uebZmMC+1jyuE2qhcez7J4a6GuspxRag18xfY0UvawTPuUt X-Forefront-PRVS: 04244E0DC5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(7370300001)(6009001)(199003)(189002)(6116002)(68736007)(86362001)(189998001)(3846002)(2906002)(6916009)(6666003)(2950100002)(50986999)(1076002)(110136004)(76176999)(4326008)(53936002)(36756003)(54906002)(7350300001)(97736004)(6512007)(5003940100001)(81156014)(81166006)(8676002)(7736002)(66066001)(6506006)(305945005)(50226002)(508600001)(50466002)(7416002)(101416001)(74482002)(105586002)(47776003)(48376002)(42186005)(5660300001)(33646002)(106356001)(25786009)(6486002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0202MB2557;H:orc.pedanet;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0202MB2557;23:bBTuHZW4KFYCvBxDywWcXjFgJkss9x1g6lyMHee?= =?us-ascii?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5zQ57BKtXUHJ9fZoe8T2aHoWADiwMGkNf6aZGXOZxTjzabES38mlNflXwLjSLmufWPIV76jc5bDLtSI0d6ZTov8s2MFi96U92aX/bkXshzO4u0Dxg6pEovGP1UwBZjqQkfVuVLuq5el6AD9rLmx9mUqOq2gjqIXzyoP6e77M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2017 15:46:30.5416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0202MB2557 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2002 Lines: 58 A board may need a mux controller to stay as-is for a while longer, e.g. if setting the normally preferred idle state destroys booting. The mechanism provided here is not perfect in two ways. 1. As soon as the mux controller is registered, some mux consumer can access it and set a state that destroys booting all the same. 2. The mux controller might linger in a state that is not the preferred idle state indefinitely, if no mux consumer ever selects and then deselects the mux. --- drivers/mux/core.c | 3 +++ include/linux/mux/driver.h | 4 ++++ 2 files changed, 7 insertions(+) Untested -> no sign-off, and I'm also really unsure about it because of the imperfections mentioned in the commit message. Cheers, peda diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 2eb234300669..c81db7d4f9c8 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -155,6 +155,9 @@ int mux_chip_register(struct mux_chip *mux_chip) for (i = 0; i < mux_chip->controllers; ++i) { struct mux_control *mux = &mux_chip->mux[i]; + if (mux->init_as_is) + continue; + if (mux->idle_state == mux->cached_state) continue; diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h index 35c3579c3304..21cf6041a962 100644 --- a/include/linux/mux/driver.h +++ b/include/linux/mux/driver.h @@ -36,6 +36,9 @@ struct mux_control_ops { * @states: The number of mux controller states. * @idle_state: The mux controller state to use when inactive, or one * of MUX_IDLE_AS_IS and MUX_IDLE_DISCONNECT. + * @init_as_is: Set to true to have the core leave the mux controller + * state as-is until first selection. If @idle_state is + * MUX_IDLE_AS_IS, @init_as_is is irrelevant. * * Mux drivers may only change @states and @idle_state, and may only do so * between allocation and registration of the mux controller. Specifically, @@ -50,6 +53,7 @@ struct mux_control { unsigned int states; int idle_state; + bool init_as_is; }; /** -- 2.11.0