From patchwork Mon Jan 31 14:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12730725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7B99C433F5 for ; Mon, 31 Jan 2022 14:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236840AbiAaOfz (ORCPT ); Mon, 31 Jan 2022 09:35:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43277 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237249AbiAaOfz (ORCPT ); Mon, 31 Jan 2022 09:35:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643639754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0fWrmbLp/C7F1V8aRNnqkMIqRJI5t3d6bvJc7n+m0x4=; b=DmFPaJHh0P/QYUNT+4H+KSRWnSTWsSRe0WodsSuyKn/lzySI16GYu38+8WSWQ+e51uGWvl psHwN77iSiyv/J+xxXHjjNLGTNumNXiV10veDuk1Q538UfV1DjpGcVa2fPT1txuC2tGIpi wEqkZOf9WfT+U1jTKtRBLA1kEg7v/nE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-511-yMh2yt-eNe2-oGyqK9pcQg-1; Mon, 31 Jan 2022 09:35:53 -0500 X-MC-Unique: yMh2yt-eNe2-oGyqK9pcQg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3496383DD22; Mon, 31 Jan 2022 14:35:52 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.39.194.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BF962376A; Mon, 31 Jan 2022 14:35:41 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH v2 1/5] Input: Set EV_ABS in dev->evbit even if input_alloc_absinfo() fails Date: Mon, 31 Jan 2022 15:35:35 +0100 Message-Id: <20220131143539.109142-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The input core's error handling for input_alloc_absinfo() failures is based on ignoring the error until input_register_device() runs and then checks for the failure like this: if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) { dev_err(&dev->dev, ...); return -EINVAL; } This relies on EV_ABS actually getting set in dev->evbit even if input_alloc_absinfo() fails, change input_set_abs_params() and input_set_capability() to actually adhere to this. Signed-off-by: Hans de Goede --- Changes in v2: - New patch in v2 of this patch-set --- drivers/input/input.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index ccaeb2426385..3a5156012fb8 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -511,6 +511,9 @@ void input_set_abs_params(struct input_dev *dev, unsigned int axis, { struct input_absinfo *absinfo; + __set_bit(EV_ABS, dev->evbit); + __set_bit(axis, dev->absbit); + input_alloc_absinfo(dev); if (!dev->absinfo) return; @@ -520,9 +523,6 @@ void input_set_abs_params(struct input_dev *dev, unsigned int axis, absinfo->maximum = max; absinfo->fuzz = fuzz; absinfo->flat = flat; - - __set_bit(EV_ABS, dev->evbit); - __set_bit(axis, dev->absbit); } EXPORT_SYMBOL(input_set_abs_params); @@ -2085,9 +2085,6 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int case EV_ABS: input_alloc_absinfo(dev); - if (!dev->absinfo) - return; - __set_bit(code, dev->absbit); break; From patchwork Mon Jan 31 14:35:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12730726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CCF5C433EF for ; Mon, 31 Jan 2022 14:35:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237045AbiAaOf5 (ORCPT ); Mon, 31 Jan 2022 09:35:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21404 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237185AbiAaOf5 (ORCPT ); Mon, 31 Jan 2022 09:35:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643639756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZrOPbfheWkNBX1SvXTkYbq9LsIXt4iOVqpKlJV0f9dw=; b=TWOdHHVmT/5z6E3aOI+lxGjZNs8OIt4KVz1cX3yWf+oPMpCAZRoPxtaazETheYSzV8oUF2 9K5Wujey0lNZo9auqSHltQuxNpMASe/OQMktR5xqIUIE/l/jBFJOScifbPyUHdH2iBBsGw XhoRU/kb7JdHT4MW/GsYyHOnjQSFV1M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-364-I8fUYB3hNdCQlYRTyvuwmw-1; Mon, 31 Jan 2022 09:35:54 -0500 X-MC-Unique: I8fUYB3hNdCQlYRTyvuwmw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBC5481F019; Mon, 31 Jan 2022 14:35:53 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.39.194.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94FD22C2C4; Mon, 31 Jan 2022 14:35:52 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH v2 2/5] Input: Add input_copy_abs() function Date: Mon, 31 Jan 2022 15:35:36 +0100 Message-Id: <20220131143539.109142-2-hdegoede@redhat.com> In-Reply-To: <20220131143539.109142-1-hdegoede@redhat.com> References: <20220131143539.109142-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add a new helper function to copy absinfo from one input_dev to another input_dev. This is useful to e.g. setup a pen/stylus input-device for combined touchscreen/pen hardware where the pen uses the same coordinates as the touchscreen. Suggested-by: Dmitry Torokhov Signed-off-by: Hans de Goede --- Changes in v2: - Check src has EV_ABS and src_axis bits set (and WARN when not) - Use input_set_capability() --- drivers/input/input.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/input.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/input/input.c b/drivers/input/input.c index 3a5156012fb8..4456e82d370b 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -526,6 +526,42 @@ void input_set_abs_params(struct input_dev *dev, unsigned int axis, } EXPORT_SYMBOL(input_set_abs_params); +/** + * input_copy_abs - Copy absinfo from one input_dev to another + * @dst: Destination input device to copy the abs settings to + * @dst_axis: ABS_* value selecting the destination axis + * @src: Source input device to copy the abs settings from + * @src_axis: ABS_* value selecting the source axis + * + * Set absinfo for the selected destination axis by copying it from + * the specified source input device's source axis. + * This is useful to e.g. setup a pen/stylus input-device for combined + * touchscreen/pen hardware where the pen uses the same coordinates as + * the touchscreen. + */ +void input_copy_abs(struct input_dev *dst, unsigned int dst_axis, + const struct input_dev *src, unsigned int src_axis) +{ + /* src must have EV_ABS and src_axis set */ + if (WARN_ON(!(test_bit(EV_ABS, src->evbit) && + test_bit(src_axis, src->absbit)))) + return; + + /* + * input_alloc_absinfo() may have failed for the source. Our caller is + * expected to catch this when registering the input devices, which may + * happen after the input_copy_abs() call. + */ + if (!src->absinfo) + return; + + input_set_capability(dst, EV_ABS, dst_axis); + if (!dst->absinfo) + return; + + dst->absinfo[dst_axis] = src->absinfo[src_axis]; +} +EXPORT_SYMBOL(input_copy_abs); /** * input_grab_device - grabs device for exclusive use diff --git a/include/linux/input.h b/include/linux/input.h index 0354b298d874..49790c1bd2c4 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -475,6 +475,8 @@ static inline void input_set_events_per_packet(struct input_dev *dev, int n_even void input_alloc_absinfo(struct input_dev *dev); void input_set_abs_params(struct input_dev *dev, unsigned int axis, int min, int max, int fuzz, int flat); +void input_copy_abs(struct input_dev *dst, unsigned int dst_axis, + const struct input_dev *src, unsigned int src_axis); #define INPUT_GENERATE_ABS_ACCESSORS(_suffix, _item) \ static inline int input_abs_get_##_suffix(struct input_dev *dev, \ From patchwork Mon Jan 31 14:35:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12730727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC425C433EF for ; Mon, 31 Jan 2022 14:36:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237249AbiAaOgB (ORCPT ); Mon, 31 Jan 2022 09:36:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47333 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237191AbiAaOgA (ORCPT ); Mon, 31 Jan 2022 09:36:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643639760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qpbnLeOni8mc0CQjXRMLFHgwoEKYMoOGWGeI0XonaWo=; b=ZcDCoownrfi9+POHsTr5dWT7PaWehyRiz59xic1cBcca6yJnXg9fIxgCumjzvJXz+rMyAE d/t/HciF8RSmlJN1i7VGH/PmPLP97u7+DysJwK0kvvxosM1P+tmpUKhNgcOigVozpfYkaV FgqIWxVcvmhZabE/Q5kg/WcNWaepKws= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-6Ww8T-euNwuP6BzrPHxJ3w-1; Mon, 31 Jan 2022 09:35:56 -0500 X-MC-Unique: 6Ww8T-euNwuP6BzrPHxJ3w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C566C1091DAF; Mon, 31 Jan 2022 14:35:55 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.39.194.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55D432376A; Mon, 31 Jan 2022 14:35:54 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH v2 3/5] Input: goodix - Use input_copy_abs() helper Date: Mon, 31 Jan 2022 15:35:37 +0100 Message-Id: <20220131143539.109142-3-hdegoede@redhat.com> In-Reply-To: <20220131143539.109142-1-hdegoede@redhat.com> References: <20220131143539.109142-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use the new input_copy_abs() helper and move the 2 input_abs_set_res() calls up to be directly after the 2 input_copy_abs() calls, so that the calls initializing the X and Y axis are all together. Signed-off-by: Hans de Goede --- Changes in v2: - No changes --- drivers/input/touchscreen/goodix.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index a3bfc7a41679..04baf5a770f5 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -306,23 +306,8 @@ static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts) if (!input) return NULL; - input_alloc_absinfo(input); - if (!input->absinfo) { - input_free_device(input); - return NULL; - } - - input->absinfo[ABS_X] = ts->input_dev->absinfo[ABS_MT_POSITION_X]; - input->absinfo[ABS_Y] = ts->input_dev->absinfo[ABS_MT_POSITION_Y]; - __set_bit(ABS_X, input->absbit); - __set_bit(ABS_Y, input->absbit); - input_set_abs_params(input, ABS_PRESSURE, 0, 255, 0, 0); - - input_set_capability(input, EV_KEY, BTN_TOUCH); - input_set_capability(input, EV_KEY, BTN_TOOL_PEN); - input_set_capability(input, EV_KEY, BTN_STYLUS); - input_set_capability(input, EV_KEY, BTN_STYLUS2); - __set_bit(INPUT_PROP_DIRECT, input->propbit); + input_copy_abs(input, ABS_X, ts->input_dev, ABS_MT_POSITION_X); + input_copy_abs(input, ABS_Y, ts->input_dev, ABS_MT_POSITION_Y); /* * The resolution of these touchscreens is about 10 units/mm, the actual * resolution does not matter much since we set INPUT_PROP_DIRECT. @@ -330,6 +315,13 @@ static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts) */ input_abs_set_res(input, ABS_X, 10); input_abs_set_res(input, ABS_Y, 10); + input_set_abs_params(input, ABS_PRESSURE, 0, 255, 0, 0); + + input_set_capability(input, EV_KEY, BTN_TOUCH); + input_set_capability(input, EV_KEY, BTN_TOOL_PEN); + input_set_capability(input, EV_KEY, BTN_STYLUS); + input_set_capability(input, EV_KEY, BTN_STYLUS2); + __set_bit(INPUT_PROP_DIRECT, input->propbit); input->name = "Goodix Active Pen"; input->phys = "input/pen"; From patchwork Mon Jan 31 14:35:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12730728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E366C433F5 for ; Mon, 31 Jan 2022 14:36:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237191AbiAaOgC (ORCPT ); Mon, 31 Jan 2022 09:36:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38691 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237185AbiAaOgA (ORCPT ); Mon, 31 Jan 2022 09:36:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643639760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o7uxVObFhPff7V2h0oKw7ZcbJtwR6FqttvoAm8mrTfQ=; b=bGWl7GAN0Ms4zTs4CBziO9dUv9O9S2kH0Tj0IeYJx17/guvk92ltt2mtVAJhWi/293D0CE Ood6cUZncSeuPWfEsTlRFn0tXmCoEkFo9XaHohyHtotTjO/FE95p5kVOizA4rLFZX3RxPN LhakPFcyqtn1Os4yaWYzJWXIGgVgmkI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-SykFsMIKOnaB34rnDr7I-w-1; Mon, 31 Jan 2022 09:35:58 -0500 X-MC-Unique: SykFsMIKOnaB34rnDr7I-w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F9521091DA2; Mon, 31 Jan 2022 14:35:57 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.39.194.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F1132B6E6; Mon, 31 Jan 2022 14:35:55 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH v2 4/5] Input: goodix - Fix race on driver unbind Date: Mon, 31 Jan 2022 15:35:38 +0100 Message-Id: <20220131143539.109142-4-hdegoede@redhat.com> In-Reply-To: <20220131143539.109142-1-hdegoede@redhat.com> References: <20220131143539.109142-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Because there is no way to detect if the touchscreen has pen support, the driver is allocating and registering the input_pen input_dev on receiving the first pen event. But this means that the input_dev gets allocated after the request_irq() call which means that the devm framework will free it before disabling the irq, leaving a window where the irq handler may run and reference the free-ed input_dev. To fix this move the allocation of the input_pen input_dev to before the request_irq() call, while still only registering it on the first pen event so that the driver does not advertise pen capability on touchscreens without it (most goodix touchscreens do not have pen support). Signed-off-by: Hans de Goede --- Changes in v2: - Only try input_register_device(ts->input_pen) once - Bail early if input_register_device(ts->input_pen) failed --- drivers/input/touchscreen/goodix.c | 35 +++++++++++++++++++----------- drivers/input/touchscreen/goodix.h | 1 + 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 04baf5a770f5..b055815611de 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -297,14 +297,14 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) return -ENOMSG; } -static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts) +static int goodix_create_pen_input(struct goodix_ts_data *ts) { struct device *dev = &ts->client->dev; struct input_dev *input; input = devm_input_allocate_device(dev); if (!input) - return NULL; + return -ENOMEM; input_copy_abs(input, ABS_X, ts->input_dev, ABS_MT_POSITION_X); input_copy_abs(input, ABS_Y, ts->input_dev, ABS_MT_POSITION_Y); @@ -331,25 +331,23 @@ static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts) input->id.product = 0x1001; input->id.version = ts->version; - if (input_register_device(input) != 0) { - input_free_device(input); - return NULL; - } - - return input; + ts->input_pen = input; + return 0; } static void goodix_ts_report_pen_down(struct goodix_ts_data *ts, u8 *data) { - int input_x, input_y, input_w; + int input_x, input_y, input_w, error; u8 key_value; - if (!ts->input_pen) { - ts->input_pen = goodix_create_pen_input(ts); - if (!ts->input_pen) - return; + if (!ts->pen_input_registered) { + error = input_register_device(ts->input_pen); + ts->pen_input_registered = (error == 0) ? 1 : error; } + if (ts->pen_input_registered < 0) + return; + if (ts->contact_size == 9) { input_x = get_unaligned_le16(&data[4]); input_y = get_unaligned_le16(&data[6]); @@ -1207,6 +1205,17 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) return error; } + /* + * Create the input_pen device before goodix_request_irq() calls + * devm_request_threaded_irq() so that the devm framework frees + * it after disabling the irq. + * Unfortunately there is no way to detect if the touchscreen has pen + * support, so registering the dev is delayed till the first pen event. + */ + error = goodix_create_pen_input(ts); + if (error) + return error; + ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT; error = goodix_request_irq(ts); if (error) { diff --git a/drivers/input/touchscreen/goodix.h b/drivers/input/touchscreen/goodix.h index fa8602e78a64..87797cc88b32 100644 --- a/drivers/input/touchscreen/goodix.h +++ b/drivers/input/touchscreen/goodix.h @@ -94,6 +94,7 @@ struct goodix_ts_data { u16 version; bool reset_controller_at_probe; bool load_cfg_from_disk; + int pen_input_registered; struct completion firmware_loading_complete; unsigned long irq_flags; enum goodix_irq_pin_access_method irq_pin_access_method; From patchwork Mon Jan 31 14:35:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12730729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE828C4332F for ; Mon, 31 Jan 2022 14:36:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237185AbiAaOgC (ORCPT ); Mon, 31 Jan 2022 09:36:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50474 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237583AbiAaOgC (ORCPT ); Mon, 31 Jan 2022 09:36:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643639762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lou0y89ZbWs+PPQBKFmRO0jUwiQnv5MhO1SocSooLxM=; b=Zwru/nu8/bcyMPKBQIqS7YKxP+QFMLrDh0SVF5F7Kmi4W5xjZLYy0uCmRm/9IDhTJwAviv dyUJ0IJx4vtmUluwPEyNpIspcXTmpyCLrch3ln0iJDxj4gbyT3j9/f5OeiS8OPAAbZTn8f 6vITthtGynVoKXWCuyJTIOI6c5yYPNM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-xW2yp5IzPh-pzoq6v4_I-A-1; Mon, 31 Jan 2022 09:36:00 -0500 X-MC-Unique: xW2yp5IzPh-pzoq6v4_I-A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 755BB1091DA0; Mon, 31 Jan 2022 14:35:59 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.39.194.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 091952376A; Mon, 31 Jan 2022 14:35:57 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH v2 5/5] Input: goodix - Use the new soc_intel_is_byt() helper Date: Mon, 31 Jan 2022 15:35:39 +0100 Message-Id: <20220131143539.109142-5-hdegoede@redhat.com> In-Reply-To: <20220131143539.109142-1-hdegoede@redhat.com> References: <20220131143539.109142-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use the new soc_intel_is_byt() helper from linux/platform_data/x86/soc.h. Signed-off-by: Hans de Goede --- Changes in v2: - No changes --- drivers/input/touchscreen/goodix.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index b055815611de..dac19a790c35 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -795,21 +796,6 @@ static int goodix_reset(struct goodix_ts_data *ts) } #ifdef ACPI_GPIO_SUPPORT -#include -#include - -static const struct x86_cpu_id baytrail_cpu_ids[] = { - { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT, X86_FEATURE_ANY, }, - {} -}; - -static inline bool is_byt(void) -{ - const struct x86_cpu_id *id = x86_match_cpu(baytrail_cpu_ids); - - return !!id; -} - static const struct acpi_gpio_params first_gpio = { 0, 0, false }; static const struct acpi_gpio_params second_gpio = { 1, 0, false }; @@ -893,7 +879,7 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts) dev_info(dev, "Using ACPI INTI and INTO methods for IRQ pin access\n"); ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_METHOD; gpio_mapping = acpi_goodix_reset_only_gpios; - } else if (is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) { + } else if (soc_intel_is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) { dev_info(dev, "No ACPI GpioInt resource, assuming that the GPIO order is reset, int\n"); ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; gpio_mapping = acpi_goodix_int_last_gpios;