Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3752173ybe; Mon, 16 Sep 2019 00:05:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+PUHXCtsKFx/2JPrtsdIl5LVGuJQJP9HEMDhgr6iIclNeb+m7ftNS13k67+8Fr85Xc1Bk X-Received: by 2002:a50:cb8c:: with SMTP id k12mr52468540edi.94.1568617547830; Mon, 16 Sep 2019 00:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568617547; cv=none; d=google.com; s=arc-20160816; b=sFRyvn1jYGmQ8y4hj4CupvpZEyhyp6IP7P+U7Xe+yytHGYIWws/0mJ3nRtqVFEvP8A MB3KxJuOJcYwOzdJjYMddCFaghruJl9OKG5qbGI/mkSOdkUivcM32TKi7XPHJFgTWxnx HDqKNmdERJzFFxYVszpsU9CiMVM0ZRnOMX580LaaRRNrCvoC8QIbo5jg1I3ldhE2h/Kp LS3bbRpm7vqljPIBsGCN5RIIpaEQD7igu5AvUeUMcfwjME7PN/S2hsBzGCTeNbZuSMZ3 fJVCx/zB09lTxbT/J/TCDSnTpHOfFeuHH8MANPMvRWqTucmr7k6uYoMbQx9NC8WzKPS3 zkxA== 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=CHLN0YgFwIwYHZwb2pxqsYeg1mD8xv4r4aaeCn/rYDg=; b=Ejx2hntVFFdvzN+0oAmSlBIryShJaNM5/pa9CEpxY0niCV+Dl9RvNPlNJIqOX5hPMz 8sZmXSo/ekMfa5nh4WA+0iGMZBSImIPSycJCpnZRP/e4+FcvcH/UnhknzJ3NpT8CDVd6 QWjpwyKz69q1ABGZLQ5Tl1JVnz3sF3nwqvYacnU90VEXuxhm+FqQ7w+YL5HQ1ZqoNaoJ Cq14fIsLAYSS6KlVI7dp27Smmo06uDvnBgwWlJZ0SAPbYp9+vzZBAuosPAG2norPoaBH rXZkrXtvR+TO++JgdmA6MdPuZjCubCKsv/QtYHVvm2hoSDtySRm/4FqcXr7jOjs7MFt3 C1/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=giWqacrf; 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 y24si15136316ejb.344.2019.09.16.00.05.23; Mon, 16 Sep 2019 00:05:47 -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=giWqacrf; 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 S1728841AbfIPD0a (ORCPT + 99 others); Sun, 15 Sep 2019 23:26:30 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:45212 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728772AbfIPD03 (ORCPT ); Sun, 15 Sep 2019 23:26:29 -0400 Received: by mail-qt1-f194.google.com with SMTP id c21so2761239qtj.12 for ; Sun, 15 Sep 2019 20:26:27 -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=CHLN0YgFwIwYHZwb2pxqsYeg1mD8xv4r4aaeCn/rYDg=; b=giWqacrfQiVrlrnNCNX19zBLZpYkzv/d++9UCHt+m3d0xxFhBXFbrJvUf9PYWWGly9 QwgCJhzTNtLQmfoHehdFE6KdHrmNsKx8VG6TI3VHmw54e8OGcYdzW9yfAbV0rgZ2wnu+ 0Gvll6Br3/x5sSMVkiy3N1y0nyInMPEA/3gog= 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=CHLN0YgFwIwYHZwb2pxqsYeg1mD8xv4r4aaeCn/rYDg=; b=t9EnZMbFpChNmrkFPFjFyUjOgVkbVSyKN3h8X0YPHS9R2HNJ/Hxgne33TDbF+aU3bo PVCZR7EdhbJkj7UgPJ+/5obQa+H0o6tRs8PA7WY7T/j+3tSxgUZQwRMsowQWvLFGoc7z n2M/4XXA0cnPRQgUtwV4ckblPqj7BoeqBHq776eaqGf4NRzrzybIOVn8VOVeUyoyh2At MTSMYD3HmHssz3h+KbXelhlTC1432IfNMLivzhhWXW7OKWYWkILsLnq8h0tZJmilM4Xq Nk9Y35s16sDe+FX2OKuchcM9JwXRHvE7iVpwzlsnM9W6uFIeQ4EZTOWFmpG5DplA2Hoo QLHg== X-Gm-Message-State: APjAAAUbwhBIzXXs4otKFqySNUhX+RsCDTOUbqQ0KWxljQ6c9p9lMrj3 hvjojrecPojPuacyKyWlL1Xu+evhZLIvymUJwPlJuA== X-Received: by 2002:ac8:3647:: with SMTP id n7mr15936531qtb.159.1568604387185; Sun, 15 Sep 2019 20:26:27 -0700 (PDT) MIME-Version: 1.0 References: <20190913220317.58289-1-dtor@chromium.org> In-Reply-To: <20190913220317.58289-1-dtor@chromium.org> From: Nicolas Boichat Date: Mon, 16 Sep 2019 11:26:16 +0800 Message-ID: Subject: Re: [PATCH 1/3] HID: google: whiskers: more robust tablet mode detection To: Dmitry Torokhov 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 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/ ? > 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). > + > + 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); >