Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1281484imm; Tue, 5 Jun 2018 11:55:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJev+OHcZWYJGeTholZkKp73rdWfw1A/xqpKuacTkRDcJF766S6JwU4bER9zNdNCR6ETioJ X-Received: by 2002:a63:6ec1:: with SMTP id j184-v6mr1747370pgc.332.1528224919853; Tue, 05 Jun 2018 11:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528224919; cv=none; d=google.com; s=arc-20160816; b=CzUPZVcDTAhLRKK81rOPZDJBPwaUGNV9ojkflgtULOySDsg3OD3eY59nJTKM53PAhx 0du0xtLL4qw7DJ89mA64R6h8YiT1SGgI9+rPJoGKUJVvwOI0JTksifxnFIuhM4MFx64d 8W+puzveYfpcZaoTA7T5Kx1JC6hisRAOiANzv5RvjwX+PBOLtMqR2colWr4D2+PyIVeH 1o6I1chdSJ2urATkjFagguwaM75c85C+Z6LkBOW4lcFiJkx7TVbcJOKTYuvZGGI7cUW6 0OD8E8pzdpi25gLnS5gcBFE+Nmi/pTXLCsCm+PkyiFt25QdiT8BQeglF3KdExgnPKCm4 h3SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=aju9AL4eNGVMOER37kIcWaNYzbtcfxoxVuthaeIY8Es=; b=dun8Lc2ed94B+Bt7JyoQ+TqFZZSl0KN1FWtF47Fia+7VKrNqknMG6C49DTrtw3pkNu 8prJ4BIEvjPaYfR6S7Kkxob2GV9QGIQVfyB3yzrXX1ZgQ5SU+Oy6OWfquqPW0yfrN4xn xlMWaAbEHfMY4KUe5zR0AAnYVZ4uuoYnoIx0v7PTv0NfblWWMqzww+eqsSw+7R0Ogzev 85BPpb/iL5H2jqlqA9SdPYOvQwoMGCfBUZjd2MnIViZ6QODy4HApHZLB3JRlNh+i+V2V e4NoYlPLo07oe//Kx7ttwPf+ULKenaxGOl9KipSm2NPkMxSrsUiWy7Mx8yKCIeR1d88H oP2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bitmath.org header.s=20140924 header.b=RmgyOgDo; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si50143103plz.66.2018.06.05.11.55.05; Tue, 05 Jun 2018 11:55:19 -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=@bitmath.org header.s=20140924 header.b=RmgyOgDo; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751987AbeFESyk (ORCPT + 99 others); Tue, 5 Jun 2018 14:54:40 -0400 Received: from mailrelay4-1.pub.mailoutpod1-cph3.one.com ([46.30.210.185]:10992 "EHLO mailrelay4-1.pub.mailoutpod1-cph3.one.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751823AbeFESyj (ORCPT ); Tue, 5 Jun 2018 14:54:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitmath.org; s=20140924; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=aju9AL4eNGVMOER37kIcWaNYzbtcfxoxVuthaeIY8Es=; b=RmgyOgDoOsjWzHJJ1y6PRR+agItHA9eBFD0P1yFZWzw2E0PwDtvoFzRe+B6ub6IxYHebf6ODqKuJm LChUhiL6wf6Zt0JSj3UXHzMpWK7wlqVEA76z3uBtTRDeZJy2t/6lT5yhID2A0Cn4tBw7lQpQOL4O3B LVpc6jai9H4lv2NA= X-HalOne-Cookie: a1baff992037b3e5f4264410afd75ae66ee173c7 X-HalOne-ID: e4c83567-68f1-11e8-a32f-d0431ea8bb10 Received: from [192.168.19.13] (unknown [79.136.64.225]) by mailrelay4.pub.mailoutpod1-cph3.one.com (Halon) with ESMTPSA id e4c83567-68f1-11e8-a32f-d0431ea8bb10; Tue, 05 Jun 2018 18:54:37 +0000 (UTC) Subject: Re: [RFC/PATCH] Input: make input_report_slot_state() return boolean To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Benjamin Tissoires , linux-kernel@vger.kernel.org References: <20180605171604.GA221901@dtor-ws> From: Henrik Rydberg Message-ID: <4d841422-9bc1-1558-d8fb-a450cbec5279@bitmath.org> Date: Tue, 5 Jun 2018 20:54:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180605171604.GA221901@dtor-ws> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/05/2018 07:16 PM, Dmitry Torokhov wrote: > 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 > --- > 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);   Reviewed-by: Henrik Rydberg Thanks, Dmitry. Henrik