From patchwork Tue Jun 5 17:16:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 10448823 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 B34A760375 for ; Tue, 5 Jun 2018 17:16:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0C6629A77 for ; Tue, 5 Jun 2018 17:16:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9480629A8D; Tue, 5 Jun 2018 17:16:21 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 4643F29A77 for ; Tue, 5 Jun 2018 17:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753076AbeFERQK (ORCPT ); Tue, 5 Jun 2018 13:16:10 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:44135 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbeFERQI (ORCPT ); Tue, 5 Jun 2018 13:16:08 -0400 Received: by mail-pl0-f68.google.com with SMTP id z9-v6so1904526plk.11; Tue, 05 Jun 2018 10:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=rKJIqJOmb3Ko5IiOC5+VKCvqZInbZLQXlKqjdLCapoY=; b=jgP8S3Rv36KZZGbyvROCNDp5Q2jzrg7g2HKRFU/6SrJ081VGsVHEEiLIFRMLhPpUyB DNmrpOIECaH9XWrU6cat0AL07uPqIS2a73T2E2TKPBvLnzAuO2Xeb2LZz/3LKLHZsGlt vfEWKxoOVw7/JAeGE3Z3IcDr9vxh9+myP6Ft1xoWdeDdCFXbTj5IBPtj2L/blzI6MMsM sHo7jdRy4yxAjwDCfdnFlP/lMDbQB+TNsW4Nx2MnrdMKz0vfKmxKEqcg2tphLXU4Qt5G D9nVVPo+Bwkg+KTzk/daTd1ocWFYhfMXEZFDBg4iW/agtbw9CO1d7L4tYpR8sjfd5wTC 2jww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=rKJIqJOmb3Ko5IiOC5+VKCvqZInbZLQXlKqjdLCapoY=; b=B+47l2IjilV9DZFjZidIb17YpljFjcxDD5fmOC+W6481o4frKXTjqiG0c44/sxuKH7 39PADPv1l8uuhKBRFqPQKESPLqUAS/f6y3vRiCDaCeV/FPZHdSwaweke25bctC/mDh2m ZTyFSPs3rdxz8HtJTxi24n0+gEhCeuv0ZqD9BU7/NaEZ4JVybQfIar6x9M8aGVcBhjeW Ob/pLf1W+rwe2f0H5qZDxSM95d8pKUe8Veuw6GPASOf8ZMR8DIkVHnuSjOFus2m7G0Z7 0Z9Yzd8ra70Wv0PrS8nnLt7sIFkAaGmGLWXrFPX+6RUeLulQUIxlwxFc+u+t5U/yLND1 zLXw== X-Gm-Message-State: ALKqPwdHFRcRQy66iKDg6LdFnGrkERngqoUhXxlieAGqxmjRpdH1svF0 +m9TNtQ389QBH136KzW9PG4wKr7n X-Google-Smtp-Source: ADUXVKL/CWk4lJg+HgHQGhyobSArqRgVt6xQq2POFCcuqeAwmqmUGPs+wFW0dLzAV3nPhAHBgoebfQ== X-Received: by 2002:a17:902:781:: with SMTP id 1-v6mr27429874plj.150.1528218967201; Tue, 05 Jun 2018 10:16:07 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id q8-v6sm50374093pfi.96.2018.06.05.10.16.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 10:16:06 -0700 (PDT) Date: Tue, 5 Jun 2018 10:16:04 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Henrik Rydberg , Benjamin Tissoires , linux-kernel@vger.kernel.org Subject: [RFC/PATCH] Input: make input_report_slot_state() return boolean Message-ID: <20180605171604.GA221901@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Let's make input_report_slot_state() return boolean representing whether the contact is active or not. This will allow writing code like: if (input_mt_report_slot_state(input, obj->mt_tool, obj->type != RMI_2D_OBJECT_NONE) { input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x); input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y); ... } instead of: input_mt_report_slot_state(input, obj->mt_tool, obj->type != RMI_2D_OBJECT_NONE); if (obj->type != RMI_2D_OBJECT_NONE) { input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x); input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y); ... } Signed-off-by: Dmitry Torokhov Acked-by: Benjamin Tissoires --- drivers/input/input-mt.c | 10 +++++++--- include/linux/input/mt.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 7ca4b318ed419..4a69716e54614 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c @@ -131,8 +131,10 @@ EXPORT_SYMBOL(input_mt_destroy_slots); * inactive, or if the tool type is changed, a new tracking id is * assigned to the slot. The tool type is only reported if the * corresponding absbit field is set. + * + * Returns true if contact is active. */ -void input_mt_report_slot_state(struct input_dev *dev, +bool input_mt_report_slot_state(struct input_dev *dev, unsigned int tool_type, bool active) { struct input_mt *mt = dev->mt; @@ -140,14 +142,14 @@ void input_mt_report_slot_state(struct input_dev *dev, int id; if (!mt) - return; + return false; slot = &mt->slots[mt->slot]; slot->frame = mt->frame; if (!active) { input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); - return; + return false; } id = input_mt_get_value(slot, ABS_MT_TRACKING_ID); @@ -156,6 +158,8 @@ void input_mt_report_slot_state(struct input_dev *dev, input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id); input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type); + + return true; } EXPORT_SYMBOL(input_mt_report_slot_state); diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h index d7188de4db968..3f4bf60b0bb55 100644 --- a/include/linux/input/mt.h +++ b/include/linux/input/mt.h @@ -100,7 +100,7 @@ static inline bool input_is_mt_axis(int axis) return axis == ABS_MT_SLOT || input_is_mt_value(axis); } -void input_mt_report_slot_state(struct input_dev *dev, +bool input_mt_report_slot_state(struct input_dev *dev, unsigned int tool_type, bool active); void input_mt_report_finger_count(struct input_dev *dev, int count);