From patchwork Fri Sep 22 18:37:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9966843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AE4260381 for ; Fri, 22 Sep 2017 18:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82BD3298F0 for ; Fri, 22 Sep 2017 18:41:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7712C299CD; Fri, 22 Sep 2017 18:41:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 191B3298F0 for ; Fri, 22 Sep 2017 18:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752002AbdIVSiT (ORCPT ); Fri, 22 Sep 2017 14:38:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58464 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbdIVSiQ (ORCPT ); Fri, 22 Sep 2017 14:38:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34F35806AC; Fri, 22 Sep 2017 18:38:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 34F35806AC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com Received: from dhcp-45-79.space.revspace.nl.com (ovpn-112-18.ams2.redhat.com [10.36.112.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87E0F600C4; Fri, 22 Sep 2017 18:38:12 +0000 (UTC) From: Hans de Goede To: MyungJoo Ham , Chanwoo Choi , Guenter Roeck , Heikki Krogerus , Darren Hart , Andy Shevchenko , Peter Rosin , Mathias Nyman Cc: Hans de Goede , 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 v3 02/14] mux: core: Add explicit hook to leave the mux as-is on init/registration Date: Fri, 22 Sep 2017 20:37:51 +0200 Message-Id: <20170922183803.10701-2-hdegoede@redhat.com> In-Reply-To: <20170922183803.10701-1-hdegoede@redhat.com> References: <20170922183803.10701-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 22 Sep 2017 18:38:16 +0000 (UTC) Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Rosin 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. Signed-off-by: Hans de Goede --- drivers/mux/core.c | 3 +++ include/linux/mux/driver.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 244bceb17877..d0ad56abca2a 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; }; /**