Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3626118ybe; Sun, 15 Sep 2019 20:40:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0saw/7BxHhn1+UAvy1x3EqybX2s73sRbTLmwdCYSP6AY7xC7N9JHsnl3pswFAv0c3R1LJ X-Received: by 2002:a17:906:1cc7:: with SMTP id i7mr14925557ejh.81.1568605256742; Sun, 15 Sep 2019 20:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568605256; cv=none; d=google.com; s=arc-20160816; b=KtlwxNpUhxMr7UPoAjUe3efCqlT9LmtX275+UaFjX4NXdaZW0vnM2u4FprzyPFT88y fXPNVnp8EOtB5f4szsCbBamIzLjQuveHC31IYRwRZ9515X4NsMq+Jp04FjVeyk9NJx6K fMeK+oO4GsyE/LWYiGQobGcXZKOri2AIG0qL+DouwuryCuCqPxa0lJCiiNQ7YF8axC/C PQT+zfqPgGurw0MzMHENTOgrJJjzHsFYQMt/oR+NgDylLhOojRaz6yfz0+6LYlIOcOh8 BCRa8ScywkymnZPDeuUkdhQe/fH9GrmanLk/wEMlMinq86dw9QmK+gGlalV3fsfY6kJ4 Q6XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UkbeehaenRMFwzD4RtVp+gl3t0RfSIKxixqD4Aaof8w=; b=YVproaefI77D6EFZ1I8MTleZPr5QVMkJtRAwDJGDtum1ofXtYilj/6jfbBlPR7eOBv LffiPtxzKD0XmqRte+RmSbDBs/xj0N6qxDthB/ROByVBQOQPrisC54CWRLc14kmEET4Q AhDx+MAhmhez6hqchI87shmJLpo150I/AuNq8OznFtJFjjSjXzmekzw8w58CvZmr8Ttl L1QyerIetnQvQZjB7AGgL+mJmc/Q0Xl12Mz1UttUyIehxtrCKra01jMr+33aI4HHQAkF /csiGjaxogmOyQblk2zH32F5WO7GZhlvLqengsuYW9o9M2CHRfTQH2LIwBktyxbGSbx/ 0P1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kH85YD9m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si748253ejx.135.2019.09.15.20.40.33; Sun, 15 Sep 2019 20:40:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kH85YD9m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728808AbfIPDgw (ORCPT + 99 others); Sun, 15 Sep 2019 23:36:52 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45860 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727387AbfIPDgv (ORCPT ); Sun, 15 Sep 2019 23:36:51 -0400 Received: by mail-lf1-f65.google.com with SMTP id r134so26215190lff.12 for ; Sun, 15 Sep 2019 20:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UkbeehaenRMFwzD4RtVp+gl3t0RfSIKxixqD4Aaof8w=; b=kH85YD9mPyeTRuGwGOZ1gN4kMOj11Zq/GXQMmWR6A9mvIB57pXuEsJUkOWhgCDntu/ zZsZLHAYPVDyBgmEgGs6sXQEzdfRO5afswIBdAmD+aQ6DihFvfONfjBtwcMRHSHhmlj7 edK0TPpN3gGA2HbhltGv127JrqmtCt7Hb1tgI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UkbeehaenRMFwzD4RtVp+gl3t0RfSIKxixqD4Aaof8w=; b=hocBmD6v3bnx8Z98OWixiTx16f3SdGURm1g3R7giSTZMquNGkldMwvWEEGtY6E1RNv exFWn3Dn5xy6qO/g7WSvHB4or+isOWOZJ1Rih9lLWjcIGipIv5Vd/jq2UJOlUW37ISc1 CbFjxht2COlr7kPi1SyCje8L0p+99KNO9fWMRnIWISKdwiTlW3vv2PnfYLxs4vAeU+ky p+PJsPeZLcmBEMMlIEwipBE6DtbjjockUqme329QDRSBS8dxFpfCWK+Gc/TsqY15JrIO eIkCYqFCX0gREpICqPLmlRxc9uyJuFG2cQ7AZPwcrA9DuxkvpzD3cMhLQfTRi4waa152 Zr8g== X-Gm-Message-State: APjAAAXzvBc4E7OKRrMC4RjH43p8RZFapPhnULqkOaLVSVPf7G1tq/ut IzhumwlCmq+lX93cS168RXZkLE5JkOQ= X-Received: by 2002:ac2:5ec1:: with SMTP id d1mr36103516lfq.83.1568605007675; Sun, 15 Sep 2019 20:36:47 -0700 (PDT) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com. [209.85.167.46]) by smtp.gmail.com with ESMTPSA id z9sm7981944ljn.78.2019.09.15.20.36.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 Sep 2019 20:36:46 -0700 (PDT) Received: by mail-lf1-f46.google.com with SMTP id c195so11356663lfg.9 for ; Sun, 15 Sep 2019 20:36:46 -0700 (PDT) X-Received: by 2002:ac2:46d2:: with SMTP id p18mr7986062lfo.140.1568605006264; Sun, 15 Sep 2019 20:36:46 -0700 (PDT) MIME-Version: 1.0 References: <20190913220317.58289-1-dtor@chromium.org> In-Reply-To: From: Dmitry Torokhov Date: Sun, 15 Sep 2019 20:36:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/3] HID: google: whiskers: more robust tablet mode detection To: Nicolas Boichat Cc: Jiri Kosina , Benjamin Tissoires , Benson Leung , "open list:HID CORE LAYER" , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 15, 2019 at 8:26 PM Nicolas Boichat wrote: > > On Sat, Sep 14, 2019 at 6:03 AM Dmitry Torokhov wrote: > > > > The USB interface may get detected before the platform/EC one, so let's > > note the state of the base (if we receive event) and use it to correctly > > initialize the tablet mode switch state. > > > > Also let's start the HID interface immediately when probing, this will > > ensure that we correctly process "base folded" events that may be sent > > as we initialize the base. Note that this requires us to add a release() > > s/release/remove/ ? You are right. > > > function where we stop and close the hardware and switch the LED > > registration away from devm interface as we need to make sure that we > > destroy the LED instance before we stop the hardware. > > > > Signed-off-by: Dmitry Torokhov > > --- > > drivers/hid/hid-google-hammer.c | 71 ++++++++++++++++++++++++++------- > > 1 file changed, 56 insertions(+), 15 deletions(-) > > > > diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c > > index 84f8c127ebdc..4f64f93ddfcb 100644 > > --- a/drivers/hid/hid-google-hammer.c > > +++ b/drivers/hid/hid-google-hammer.c > > @@ -208,7 +209,14 @@ static int __cbas_ec_probe(struct platform_device *pdev) > > return error; > > } > > > > - input_report_switch(input, SW_TABLET_MODE, !cbas_ec.base_present); > > + if (!cbas_ec.base_present) > > + cbas_ec.base_folded = false; > > I'm not sure to see why this is necessary? The folded base state > should be in bss and false anyway, and even if it was true, it would > not change the result of the expression below (!cbas_ec.base_present > || cbas_ec.base_folded). To have a more accurate printout generated by the line below. The fact that it is in bss it not relevant, as I can unbind and rebind the driver via sysfs, so it could have stale data from the previous run. > > > + > > + dev_dbg(&pdev->dev, "%s: base: %d, folded: %d\n", __func__, > > + cbas_ec.base_present, cbas_ec.base_folded); > > + > > + input_report_switch(input, SW_TABLET_MODE, > > + !cbas_ec.base_present || cbas_ec.base_folded); > > > > cbas_ec_set_input(input); > > Thanks, Dmitry