From patchwork Thu Oct 17 20:41:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08D2B112B for ; Thu, 17 Oct 2019 20:44:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAD6721835 for ; Thu, 17 Oct 2019 20:44:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BWRmDSXM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439070AbfJQUm0 (ORCPT ); Thu, 17 Oct 2019 16:42:26 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46084 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727269AbfJQUm0 (ORCPT ); Thu, 17 Oct 2019 16:42:26 -0400 Received: by mail-pl1-f194.google.com with SMTP id q24so1685022plr.13; Thu, 17 Oct 2019 13:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FRd9N8H3Zj0SBuvRkmIjq6Ws5g96mPSLFpPokjqPplU=; b=BWRmDSXMRq9DoKgr1v2TSx8T0o32gfU2NU+n8mZZyn9YytbJa1bS48b5fWxU9soMxh R4EVBZEP2tv6sS/FBQP1fpZsiXKue+Z60nLeEvcPQERTXp2beG5IZsvuMoLC8WUp0NAJ uuWPBdqmIsxBfwDlbuwnZKi8M0UqOOUZzAQ8rXvH0yZ0E5eYtkDMnMcH3TsebswcmPFz B5DvU5QvDoJxaskcMtkQkBfRjwTApFS3ULlc8tC2pOJrc+PFV5hKOjzbARkE6n8YMxNL P4RcD8NY3FqR14BrbbWIJzJI2uqB7vR+sTyRcPli8oM7b/v8ThPVExLnd2O0RUmcRSRP 8UUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FRd9N8H3Zj0SBuvRkmIjq6Ws5g96mPSLFpPokjqPplU=; b=XGCsuiz3TUDIzpKSs0uXLXQNfWOBeu/IaKQXffSp5lSLyvJ2nrhJb+nK4vCpTNDwsR v8wgFfpjjoC0piAiKe1HdFcIINLnTuWUeOsay7LrbEgxcFK6ECrTS4c9JW4lKHKWccFw BfneZTuw/5FVkyL5bI1Bpd/c33lCD0+vXJ+1Z2RD4kgWIf6FpGWD98dahVsKvbCc9ssW +k/DCyPtz7720rkl6QL3KMDlJBS1qtGNKtWZTrySRYv6lLX6CPXRaEhGZ4Dpy//68DnE cHS2X/v/X85Oi/Gq80uAiKi7cugD1iUFcFt9+W4egkMyy0SvPxZLA2zp6aWHfUsbxHZk HWFg== X-Gm-Message-State: APjAAAUAoVnUYIqjecTG8ALsvHI5tkyoQBPcLJALxHAxwb8CvCVFT6a+ pdZn69Sz0+1fKbUwm7UivC2OoT+E X-Google-Smtp-Source: APXvYqy4DjIZZDAFfKWysG4JMraEBfmKvTJP+p74rT2vrlpeq0Fph0yu/ub3pwgysEU92y35pS8dMw== X-Received: by 2002:a17:902:ac8a:: with SMTP id h10mr5853080plr.180.1571344943241; Thu, 17 Oct 2019 13:42:23 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:21 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Anders Roxell , Eric Anholt , Jeff LaBundy , Luis Chamberlain , Martin Kepplinger , Nicolas Saenz Julienne , linux-kernel@vger.kernel.org Subject: [PATCH 01/22] Input: raspberrypi-ts - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:41:55 -0700 Message-Id: <20191017204217.106453-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts raspberrypi-ts driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/Kconfig | 1 - drivers/input/touchscreen/raspberrypi-ts.c | 38 ++++++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 46ad9090493b..00e7a9f218bc 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -700,7 +700,6 @@ config TOUCHSCREEN_EDT_FT5X06 config TOUCHSCREEN_RASPBERRYPI_FW tristate "Raspberry Pi's firmware base touch screen support" depends on RASPBERRYPI_FIRMWARE || (RASPBERRYPI_FIRMWARE=n && COMPILE_TEST) - select INPUT_POLLDEV help Say Y here if you have the official Raspberry Pi 7 inch screen on your system. diff --git a/drivers/input/touchscreen/raspberrypi-ts.c b/drivers/input/touchscreen/raspberrypi-ts.c index 69881265d121..0e2e08f3f433 100644 --- a/drivers/input/touchscreen/raspberrypi-ts.c +++ b/drivers/input/touchscreen/raspberrypi-ts.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -34,7 +33,7 @@ struct rpi_ts { struct platform_device *pdev; - struct input_polled_dev *poll_dev; + struct input_dev *input; struct touchscreen_properties prop; void __iomem *fw_regs_va; @@ -57,10 +56,9 @@ struct rpi_ts_regs { } point[RPI_TS_MAX_SUPPORTED_POINTS]; }; -static void rpi_ts_poll(struct input_polled_dev *dev) +static void rpi_ts_poll(struct input_dev *input) { - struct input_dev *input = dev->input; - struct rpi_ts *ts = dev->private; + struct rpi_ts *ts = input_get_drvdata(input); struct rpi_ts_regs regs; int modified_ids = 0; long released_ids; @@ -123,10 +121,9 @@ static int rpi_ts_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct input_polled_dev *poll_dev; + struct input_dev *input; struct device_node *fw_node; struct rpi_firmware *fw; - struct input_dev *input; struct rpi_ts *ts; u32 touchbuf; int error; @@ -160,7 +157,6 @@ static int rpi_ts_probe(struct platform_device *pdev) return error; } - touchbuf = (u32)ts->fw_regs_phys; error = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF, &touchbuf, sizeof(touchbuf)); @@ -170,19 +166,17 @@ static int rpi_ts_probe(struct platform_device *pdev) return error; } - poll_dev = devm_input_allocate_polled_device(dev); - if (!poll_dev) { + input = devm_input_allocate_device(dev); + if (!input) { dev_err(dev, "Failed to allocate input device\n"); return -ENOMEM; } - ts->poll_dev = poll_dev; - input = poll_dev->input; + + ts->input = input; + input_set_drvdata(input, ts); input->name = "raspberrypi-ts"; input->id.bustype = BUS_HOST; - poll_dev->poll_interval = RPI_TS_POLL_INTERVAL; - poll_dev->poll = rpi_ts_poll; - poll_dev->private = ts; input_set_abs_params(input, ABS_MT_POSITION_X, 0, RPI_TS_DEFAULT_WIDTH, 0, 0); @@ -197,7 +191,15 @@ static int rpi_ts_probe(struct platform_device *pdev) return error; } - error = input_register_polled_device(poll_dev); + error = input_setup_polling(input, rpi_ts_poll); + if (error) { + dev_err(dev, "could not set up polling mode, %d\n", error); + return error; + } + + input_set_poll_interval(input, RPI_TS_POLL_INTERVAL); + + error = input_register_device(input); if (error) { dev_err(dev, "could not register input device, %d\n", error); return error; @@ -214,10 +216,10 @@ MODULE_DEVICE_TABLE(of, rpi_ts_match); static struct platform_driver rpi_ts_driver = { .driver = { - .name = "raspberrypi-ts", + .name = "raspberrypi-ts", .of_match_table = rpi_ts_match, }, - .probe = rpi_ts_probe, + .probe = rpi_ts_probe, }; module_platform_driver(rpi_ts_driver); From patchwork Thu Oct 17 20:41:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB01D14ED for ; Thu, 17 Oct 2019 20:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 901B621A49 for ; Thu, 17 Oct 2019 20:44:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aG9qiAf2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440211AbfJQUm2 (ORCPT ); Thu, 17 Oct 2019 16:42:28 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34047 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727269AbfJQUm1 (ORCPT ); Thu, 17 Oct 2019 16:42:27 -0400 Received: by mail-pf1-f195.google.com with SMTP id b128so2392237pfa.1; Thu, 17 Oct 2019 13:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IR9wXPx+VgMHzXyTssPlOjBdtYa1XMszXx3amY1GdBs=; b=aG9qiAf2i+m9OGvs7MBGnS64P7Nnat81BEJrK94hz3F6AE4OHX7n9Zqf5pHUSQMiN8 hpu4QK8j5+lim/xX1ydTdUD3pd9TE0+YmSiF5/nP3laJc1hLQfI76tELt2JPmz3qlg+M vEYWNfbV2ONJIzdzGz+duZkzLgl+HRMsQzIKrTL76FQ+lqs/VxzyzF4yoHrmwMSUBEaA HZB8RdB920kDXdjrVheVqVNgkmSGiVQHxJCsQ85G9nkNP26fqUTT5+cnB1YtRezoo3qp c6aWBEB0xVDRMH7VmZtPZTGJqoYyVlT1XnUAqwH8YyqvJiZxYlzA7AnbYdk+mfZabavQ oaXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IR9wXPx+VgMHzXyTssPlOjBdtYa1XMszXx3amY1GdBs=; b=MeWxqjbRc095a0JKEvZ8s5OEGfOCeTfjP87Q+AK7IJpd2ul8pvmFl0uqyDOwDlZYmj xBF8GlfcK0gFEW4J9RT22LwQpncws4YzuWvU2hT4p8emDG3gds1cfmaq2JgnkWL6bvt8 xmniTn9gl8w+/AD7gwnuoeu0oy4wvuNj6YPIW+k+NPMtyQ1wOKmBXwUKcqk1zXMryKad dWgAdVjk1it4t1MNedEyslHg2C7LOqgcI8Kqo7iBIOgD/3AHqNwIzUfzM82+2VVHs//x NqxCJ3hVzA7WhADqzC9obxDlyGVoFI+QYuKN1slGybS5EdWgfUNdp13Bo2jFfmqjbTLj Smlg== X-Gm-Message-State: APjAAAXPtcjDkRAa4A3+mV1yPfY1p/Y7ILD00KNOHJNXtdWg+8/Y5CBc UvVBz7f8klI2OFZcALsZdF0xQkbd X-Google-Smtp-Source: APXvYqyGY/xepLpzs7oKpDHQvq+XzriiJXpToXeF8sqZS77YlSA+n97vplCXT19O3CjX6GcfLUJkSA== X-Received: by 2002:a63:4d8:: with SMTP id 207mr6448499pge.168.1571344944516; Thu, 17 Oct 2019 13:42:24 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:23 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Allison Randal , Anders Roxell , Eric Anholt , Hans Verkuil , Jeff LaBundy , Martin Kepplinger , Mauro Carvalho Chehab , Nicolas Saenz Julienne , linux-kernel@vger.kernel.org Subject: [PATCH 02/22] Input: sur40 - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:41:56 -0700 Message-Id: <20191017204217.106453-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts sur40 driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/Kconfig | 1 - drivers/input/touchscreen/sur40.c | 92 ++++++++++++++++++------------- 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 00e7a9f218bc..df9cb92166c3 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1209,7 +1209,6 @@ config TOUCHSCREEN_SUR40 tristate "Samsung SUR40 (Surface 2.0/PixelSense) touchscreen" depends on USB && MEDIA_USB_SUPPORT && HAS_DMA depends on VIDEO_V4L2 - select INPUT_POLLDEV select VIDEOBUF2_DMA_SG help Say Y here if you want support for the Samsung SUR40 touchscreen diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index 00cb1ba2d364..04638900fe0e 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -206,7 +206,7 @@ struct sur40_state { struct usb_device *usbdev; struct device *dev; - struct input_polled_dev *input; + struct input_dev *input; struct v4l2_device v4l2; struct video_device vdev; @@ -370,6 +370,10 @@ static int sur40_init(struct sur40_state *dev) goto error; result = sur40_command(dev, SUR40_GET_VERSION, 0x03, buffer, 12); + if (result < 0) + goto error; + + result = 0; /* * Discard the result buffer - no known data inside except @@ -381,22 +385,22 @@ static int sur40_init(struct sur40_state *dev) } /* - * Callback routines from input_polled_dev + * Callback routines from input_dev */ /* Enable the device, polling will now start. */ -static void sur40_open(struct input_polled_dev *polldev) +static int sur40_open(struct input_dev *input) { - struct sur40_state *sur40 = polldev->private; + struct sur40_state *sur40 = input_get_drvdata(input); dev_dbg(sur40->dev, "open\n"); - sur40_init(sur40); + return sur40_init(sur40); } /* Disable device, polling has stopped. */ -static void sur40_close(struct input_polled_dev *polldev) +static void sur40_close(struct input_dev *input) { - struct sur40_state *sur40 = polldev->private; + struct sur40_state *sur40 = input_get_drvdata(input); dev_dbg(sur40->dev, "close\n"); /* @@ -448,10 +452,9 @@ static void sur40_report_blob(struct sur40_blob *blob, struct input_dev *input) } /* core function: poll for new input data */ -static void sur40_poll(struct input_polled_dev *polldev) +static void sur40_poll(struct input_dev *input) { - struct sur40_state *sur40 = polldev->private; - struct input_dev *input = polldev->input; + struct sur40_state *sur40 = input_get_drvdata(input); int result, bulk_read, need_blobs, packet_blobs, i; u32 uninitialized_var(packet_id); @@ -613,10 +616,9 @@ static void sur40_process_video(struct sur40_state *sur40) } /* Initialize input device parameters. */ -static void sur40_input_setup(struct input_dev *input_dev) +static int sur40_input_setup_events(struct input_dev *input_dev) { - __set_bit(EV_KEY, input_dev->evbit); - __set_bit(EV_ABS, input_dev->evbit); + int error; input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, SENSOR_RES_X, 0, 0); @@ -637,8 +639,14 @@ static void sur40_input_setup(struct input_dev *input_dev) input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); - input_mt_init_slots(input_dev, MAX_CONTACTS, - INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); + error = input_mt_init_slots(input_dev, MAX_CONTACTS, + INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); + if (error) { + dev_err(input_dev->dev.parent, "failed to set up slots\n"); + return error; + } + + return 0; } /* Check candidate USB interface. */ @@ -649,7 +657,7 @@ static int sur40_probe(struct usb_interface *interface, struct sur40_state *sur40; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; - struct input_polled_dev *poll_dev; + struct input_dev *input; int error; /* Check if we really have the right interface. */ @@ -670,8 +678,8 @@ static int sur40_probe(struct usb_interface *interface, if (!sur40) return -ENOMEM; - poll_dev = input_allocate_polled_device(); - if (!poll_dev) { + input = input_allocate_device(); + if (!input) { error = -ENOMEM; goto err_free_dev; } @@ -681,26 +689,33 @@ static int sur40_probe(struct usb_interface *interface, spin_lock_init(&sur40->qlock); mutex_init(&sur40->lock); - /* Set up polled input device control structure */ - poll_dev->private = sur40; - poll_dev->poll_interval = POLL_INTERVAL; - poll_dev->open = sur40_open; - poll_dev->poll = sur40_poll; - poll_dev->close = sur40_close; - /* Set up regular input device structure */ - sur40_input_setup(poll_dev->input); - - poll_dev->input->name = DRIVER_LONG; - usb_to_input_id(usbdev, &poll_dev->input->id); + input->name = DRIVER_LONG; + usb_to_input_id(usbdev, &input->id); usb_make_path(usbdev, sur40->phys, sizeof(sur40->phys)); strlcat(sur40->phys, "/input0", sizeof(sur40->phys)); - poll_dev->input->phys = sur40->phys; - poll_dev->input->dev.parent = &interface->dev; + input->phys = sur40->phys; + input->dev.parent = &interface->dev; + + input->open = sur40_open; + input->close = sur40_close; + + error = sur40_input_setup_events(input); + if (error) + goto err_free_input; + + input_set_drvdata(input, sur40); + error = input_setup_polling(input, sur40_poll); + if (error) { + dev_err(&interface->dev, "failed to set up polling"); + goto err_free_input; + } + + input_set_poll_interval(input, POLL_INTERVAL); sur40->usbdev = usbdev; sur40->dev = &interface->dev; - sur40->input = poll_dev; + sur40->input = input; /* use the bulk-in endpoint tested above */ sur40->bulk_in_size = usb_endpoint_maxp(endpoint); @@ -709,11 +724,11 @@ static int sur40_probe(struct usb_interface *interface, if (!sur40->bulk_in_buffer) { dev_err(&interface->dev, "Unable to allocate input buffer."); error = -ENOMEM; - goto err_free_polldev; + goto err_free_input; } /* register the polled input device */ - error = input_register_polled_device(poll_dev); + error = input_register_device(input); if (error) { dev_err(&interface->dev, "Unable to register polled input device."); @@ -796,8 +811,8 @@ static int sur40_probe(struct usb_interface *interface, v4l2_device_unregister(&sur40->v4l2); err_free_buffer: kfree(sur40->bulk_in_buffer); -err_free_polldev: - input_free_polled_device(sur40->input); +err_free_input: + input_free_device(input); err_free_dev: kfree(sur40); @@ -813,8 +828,7 @@ static void sur40_disconnect(struct usb_interface *interface) video_unregister_device(&sur40->vdev); v4l2_device_unregister(&sur40->v4l2); - input_unregister_polled_device(sur40->input); - input_free_polled_device(sur40->input); + input_unregister_device(sur40->input); kfree(sur40->bulk_in_buffer); kfree(sur40); From patchwork Thu Oct 17 20:41:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2C2A112B for ; Thu, 17 Oct 2019 20:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B737A2089C for ; Thu, 17 Oct 2019 20:42:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q+8X1Hp3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440791AbfJQUm3 (ORCPT ); Thu, 17 Oct 2019 16:42:29 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35929 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727269AbfJQUm3 (ORCPT ); Thu, 17 Oct 2019 16:42:29 -0400 Received: by mail-pg1-f195.google.com with SMTP id 23so2026689pgk.3; Thu, 17 Oct 2019 13:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/mXh8WjJ84Xe5TPBXdxoghR6RYUn9xReRFHQXe2AzjQ=; b=Q+8X1Hp37Rq29G/LGyQDyZJT89lEC455WByv5xthezcA/h+TnnZzPFY2NqtFN6/azh TMCMLepNRMYh4Jl9p36ArOoHxdyqt/ZbKK9Dew/TJ8B4vp28LnjZfvkCki6FTouQSWw0 tI4FTA621mPhHvOP9Psoi5HwMD0xrqM1iASIboCGkgWlOP7/CqssYb6SxBeFr1g4nQS8 ODXGqpT2adJw5kl2Vp5m/ag1MNEPhtqwSSmod1azk7y3Y6WyQBt85WISkTQLOnN9OXVG xL0s1sQjNZHncroI2MrnXlGsmw2KEo5sQGigjnZnWnq19OSpo7q9Xpz1Kbe3xrjE83il DhSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/mXh8WjJ84Xe5TPBXdxoghR6RYUn9xReRFHQXe2AzjQ=; b=hj3wY/xeOHEPZlgwWDgNehbHF1FbE66061pf6gScb/92hRHdoLrZtEwZIosEXF1WAl bjL/GRiJAihoF/NUTtyAeelYOuISRhGyETyKKHbmU+KipDfB+UMwtAZdcRodXMqx6Uln 2/t+CjQEiVkDuSzViQOijxwIYaO9D1v1btJMnvuXHIe9zDhpQRtlWCdV9/ep+YU8Na4p XCxgmcu+4heOFnyeC9kQvCx8frvB8vE7AN+hBNC/fcZrqoX3nGzmqTOWz4abbkSLnv5v l2tEJ1LWvoWlfpDdWX6U27BO195rq939pTZxfXAwyhbiGaHrbKVuXBcDG2TPgIS3LgDX tMjg== X-Gm-Message-State: APjAAAXdfWzZd6FKWc/l+oOtX6pvoYQBWGWy0MVVRO7i8WsA86cykpu7 BGX1JIuyOObOwyK98yJMOGasppCr X-Google-Smtp-Source: APXvYqxRpEh6skic+1OjBIzOhOXjdDuMCG/hGlSb2M9JafhBr1a+59XrUWGHA3l+ptZkT0f/Bv4xLw== X-Received: by 2002:a63:b551:: with SMTP id u17mr6092921pgo.88.1571344946094; Thu, 17 Oct 2019 13:42:26 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:25 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Anders Roxell , Jeff LaBundy , Martin Kepplinger , Mukesh Ojha , Nicolas Saenz Julienne , linux-kernel@vger.kernel.org Subject: [PATCH 03/22] Input: ts4800-ts - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:41:57 -0700 Message-Id: <20191017204217.106453-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts ts4800-ts driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/Kconfig | 1 - drivers/input/touchscreen/ts4800-ts.c | 68 +++++++++++++++------------ 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index df9cb92166c3..2c00232b2506 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1037,7 +1037,6 @@ config TOUCHSCREEN_TS4800 depends on HAS_IOMEM && OF depends on SOC_IMX51 || COMPILE_TEST select MFD_SYSCON - select INPUT_POLLDEV help Say Y here if you have a touchscreen on a TS-4800 board. diff --git a/drivers/input/touchscreen/ts4800-ts.c b/drivers/input/touchscreen/ts4800-ts.c index 5b4f5362c67b..6cf66aadc10e 100644 --- a/drivers/input/touchscreen/ts4800-ts.c +++ b/drivers/input/touchscreen/ts4800-ts.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -33,7 +32,7 @@ #define Y_OFFSET 0x2 struct ts4800_ts { - struct input_polled_dev *poll_dev; + struct input_dev *input; struct device *dev; char phys[32]; @@ -46,22 +45,26 @@ struct ts4800_ts { int debounce; }; -static void ts4800_ts_open(struct input_polled_dev *dev) +static int ts4800_ts_open(struct input_dev *input_dev) { - struct ts4800_ts *ts = dev->private; - int ret; + struct ts4800_ts *ts = input_get_drvdata(input_dev); + int error; ts->pendown = false; ts->debounce = DEBOUNCE_COUNT; - ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit); - if (ret) - dev_warn(ts->dev, "Failed to enable touchscreen\n"); + error = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit); + if (error) { + dev_warn(ts->dev, "Failed to enable touchscreen: %d\n", error); + return error; + } + + return 0; } -static void ts4800_ts_close(struct input_polled_dev *dev) +static void ts4800_ts_close(struct input_dev *input_dev) { - struct ts4800_ts *ts = dev->private; + struct ts4800_ts *ts = input_get_drvdata(input_dev); int ret; ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, 0); @@ -70,10 +73,9 @@ static void ts4800_ts_close(struct input_polled_dev *dev) } -static void ts4800_ts_poll(struct input_polled_dev *dev) +static void ts4800_ts_poll(struct input_dev *input_dev) { - struct input_dev *input_dev = dev->input; - struct ts4800_ts *ts = dev->private; + struct ts4800_ts *ts = input_get_drvdata(input_dev); u16 last_x = readw(ts->base + X_OFFSET); u16 last_y = readw(ts->base + Y_OFFSET); bool pendown = last_x & PENDOWN_MASK; @@ -146,7 +148,7 @@ static int ts4800_parse_dt(struct platform_device *pdev, static int ts4800_ts_probe(struct platform_device *pdev) { - struct input_polled_dev *poll_dev; + struct input_dev *input_dev; struct ts4800_ts *ts; int error; @@ -162,32 +164,38 @@ static int ts4800_ts_probe(struct platform_device *pdev) if (IS_ERR(ts->base)) return PTR_ERR(ts->base); - poll_dev = devm_input_allocate_polled_device(&pdev->dev); - if (!poll_dev) + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) return -ENOMEM; snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&pdev->dev)); - ts->poll_dev = poll_dev; + ts->input = input_dev; ts->dev = &pdev->dev; - poll_dev->private = ts; - poll_dev->poll_interval = POLL_INTERVAL; - poll_dev->open = ts4800_ts_open; - poll_dev->close = ts4800_ts_close; - poll_dev->poll = ts4800_ts_poll; + input_set_drvdata(input_dev, ts); + + input_dev->name = "TS-4800 Touchscreen"; + input_dev->phys = ts->phys; + + input_dev->open = ts4800_ts_open; + input_dev->close = ts4800_ts_close; + + input_set_capability(input_dev, EV_KEY, BTN_TOUCH); + input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); + input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); - poll_dev->input->name = "TS-4800 Touchscreen"; - poll_dev->input->phys = ts->phys; + error = input_setup_polling(input_dev, ts4800_ts_poll); + if (error) { + dev_err(&pdev->dev, "Unable to set up polling: %d\n", error); + return error; + } - input_set_capability(poll_dev->input, EV_KEY, BTN_TOUCH); - input_set_abs_params(poll_dev->input, ABS_X, 0, MAX_12BIT, 0, 0); - input_set_abs_params(poll_dev->input, ABS_Y, 0, MAX_12BIT, 0, 0); + input_set_poll_interval(input_dev, POLL_INTERVAL); - error = input_register_polled_device(poll_dev); + error = input_register_device(input_dev); if (error) { dev_err(&pdev->dev, - "Unabled to register polled input device (%d)\n", - error); + "Unable to register input device: %d\n", error); return error; } From patchwork Thu Oct 17 20:41:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3B8714ED for ; Thu, 17 Oct 2019 20:44:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B296721A49 for ; Thu, 17 Oct 2019 20:44:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hkbKRcr0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2501949AbfJQUm3 (ORCPT ); Thu, 17 Oct 2019 16:42:29 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42139 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440678AbfJQUm3 (ORCPT ); Thu, 17 Oct 2019 16:42:29 -0400 Received: by mail-pg1-f194.google.com with SMTP id f14so2006751pgi.9; Thu, 17 Oct 2019 13:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xREUl1NsyRw48QZ1koCr3VjBYFASQ7LMvhvI9Mxd8Eg=; b=hkbKRcr0aDKQQEgH7N63R/GPV3ypco9E2U5GEYGBOHp4gT2lm3d4LglyQbO/fKT+D5 /Yf+zkhIMahQs8azEFXBur489HQqdJ5CEvJhqlhMHnljIOtTqavHAXORy8/py9TL4G09 soYNXlynNEVJQkOu6rS/5m0GYwI1fV6X/2oMRgLXe9m/xptJTe1u3HfUacG5T614DGTY +dXvKok79BUUm0dNlX/9unpfmkXPPszLpC2Z8TK6vFmSetwg510IRA6pcZ3X8AOwbQv4 x2pg5YPPrEi+vQXEg0YhrtiPSCi6vA0vnYuiFNjTP5w803iCKtCcX1WEJlTXOxSA6Uua U+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xREUl1NsyRw48QZ1koCr3VjBYFASQ7LMvhvI9Mxd8Eg=; b=Cmkt0+Qr9roFu7NZt/tpPHCEjSIYA2gUEf8SITU4M2nLi8S0AfKokoogTEwGOFx/3/ nguLmsFTQQaCPWng6TfKyEV/80uw7vwSUi1bA9Z7d1cDWP5ykfI0DNQk2Xby42A+RRzu 2V0FXbtj8OTE/O9hyfCot7PiP5+GIFacyCQeeFF1t+4HCjBAx/4T/JwhKVHUq3uCx9mZ QBHJ0yyC1i5NKPWlrqvY/LUSB2UyL0ZAQ1ov4TfxvPppKxLK0/jOxJ/yPtwHZn49E9Kj pi2ovr9Xzlb365N9uidQt3k1Jw31g5heZFY/ZHXP1tVPM5WPyvrVOjiUUcuVUNhszNvm tRzg== X-Gm-Message-State: APjAAAWnRG6dwlPXKd/ibNc55V5YtYE2DjdwrE/9n96PuUr23KQQ2xco xE+ihxYm7PwBexF+TjIOndPAMetn X-Google-Smtp-Source: APXvYqzS7MmleeeZ6TVFaT71zNM54PUh5o6nDqqhWIdh0jbEFDPo1mN/AzPsjK8jG+rxOjGgSBp7Fg== X-Received: by 2002:a63:5162:: with SMTP id r34mr6146979pgl.339.1571344947454; Thu, 17 Oct 2019 13:42:27 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:26 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Anders Roxell , Jeff LaBundy , Martin Kepplinger , Nicolas Saenz Julienne , linux-kernel@vger.kernel.org Subject: [PATCH 04/22] Input: tsc6507x-ts - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:41:58 -0700 Message-Id: <20191017204217.106453-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts tsc6507x-ts driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/Kconfig | 1 - drivers/input/touchscreen/tps6507x-ts.c | 36 ++++++++++++------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 2c00232b2506..40bfc551ce30 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1243,7 +1243,6 @@ config TOUCHSCREEN_SX8654 config TOUCHSCREEN_TPS6507X tristate "TPS6507x based touchscreens" depends on I2C - select INPUT_POLLDEV help Say Y here if you have a TPS6507x based touchscreen controller. diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c index 75170a7439b1..357a3108f2e5 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,7 @@ struct ts_event { struct tps6507x_ts { struct device *dev; - struct input_polled_dev *poll_dev; + struct input_dev *input; struct tps6507x_dev *mfd; char phys[32]; struct ts_event tc; @@ -148,10 +147,9 @@ static s32 tps6507x_adc_standby(struct tps6507x_ts *tsc) return ret; } -static void tps6507x_ts_poll(struct input_polled_dev *poll_dev) +static void tps6507x_ts_poll(struct input_dev *input_dev) { - struct tps6507x_ts *tsc = poll_dev->private; - struct input_dev *input_dev = poll_dev->input; + struct tps6507x_ts *tsc = input_get_drvdata(input_dev); bool pendown; s32 ret; @@ -205,7 +203,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev) const struct tps6507x_board *tps_board; const struct touchscreen_init_data *init_data; struct tps6507x_ts *tsc; - struct input_polled_dev *poll_dev; struct input_dev *input_dev; int error; @@ -240,23 +237,16 @@ static int tps6507x_ts_probe(struct platform_device *pdev) snprintf(tsc->phys, sizeof(tsc->phys), "%s/input0", dev_name(tsc->dev)); - poll_dev = devm_input_allocate_polled_device(&pdev->dev); - if (!poll_dev) { + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) { dev_err(tsc->dev, "Failed to allocate polled input device.\n"); return -ENOMEM; } - tsc->poll_dev = poll_dev; - - poll_dev->private = tsc; - poll_dev->poll = tps6507x_ts_poll; - poll_dev->poll_interval = init_data ? - init_data->poll_period : TSC_DEFAULT_POLL_PERIOD; - - input_dev = poll_dev->input; - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); + tsc->input = input_dev; + input_set_drvdata(input_dev, tsc); + input_set_capability(input_dev, EV_KEY, BTN_TOUCH); input_set_abs_params(input_dev, ABS_X, 0, MAX_10BIT, 0, 0); input_set_abs_params(input_dev, ABS_Y, 0, MAX_10BIT, 0, 0); input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_10BIT, 0, 0); @@ -275,7 +265,15 @@ static int tps6507x_ts_probe(struct platform_device *pdev) if (error) return error; - error = input_register_polled_device(poll_dev); + error = input_setup_polling(input_dev, tps6507x_ts_poll); + if (error) + return error; + + input_set_poll_interval(input_dev, + init_data ? init_data->poll_period : + TSC_DEFAULT_POLL_PERIOD); + + error = input_register_device(input_dev); if (error) return error; From patchwork Thu Oct 17 20:41:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B88F112B for ; Thu, 17 Oct 2019 20:44:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20EC121A49 for ; Thu, 17 Oct 2019 20:44:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="goASVb+k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394819AbfJQUoF (ORCPT ); Thu, 17 Oct 2019 16:44:05 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42736 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440795AbfJQUm3 (ORCPT ); Thu, 17 Oct 2019 16:42:29 -0400 Received: by mail-pf1-f193.google.com with SMTP id q12so2366456pff.9; Thu, 17 Oct 2019 13:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sSHq9wsAzsKM4AZ9LGW0ongN+PTn6qrVrduasflfRcM=; b=goASVb+k6liB5swYO63ZxWWekRVhGn3GuMsbPw2TeHuX0v/VFzTJCpHLCRpFv0Ngnb LDGiCtYWcJ5zxIOqmhrr8IRDjleOtxitzOhSew4NHmeu8aeP9liDUrHqYjVvAnqwV4zH N5L7jKq6ZDhb3VLiEOTOI33zZuv1Lkfz+qSzqCaS9uscoIxmpqq+I5004S23Amu2lZtA 0LNv4aB5iMDEzF5XBMiWsmGiolIBLswcBn0H8sP70z0tcnbaiNP1bEtvVB5Ax6yN/NoC Vcrf+XdBoZiwnuh+rw/j2N5m6MBuI1x0wXLofqExCv8gVjBRLj+wdnnJqcuOK43KkonH Sg2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sSHq9wsAzsKM4AZ9LGW0ongN+PTn6qrVrduasflfRcM=; b=rOoO7vJdwabAco+NHVuuiWz1sAWZ9hEmaRz9qHVkZhg1cBSA2gUq582FtL7brLvy3q e6S0x3DrI2KZZjGlscccTn1W10dUrmEwIA0HmFhPYF5q1e0V1+USZLtwlRBF3aVJW7ph KbXfYyrGy7+N1tdZ3OpwbZ1Q1tWLuaAlBTJb2guTMQ9eLi3O735dKupSvxSP7b3lSosh iBL2T0b4l91VKtFiN94nWMt25hmI8deRbcFngjWEmfwM5XvZiMot4zPlYj1/w5X3eCj7 R/gn8aXjBsZgQqysX8LKYsB39OrK24AHHA7syk8Rs1F2YYbuEhPF83JVrb7uXJ14TphF JKlg== X-Gm-Message-State: APjAAAU+qOoEdo3CzK+9QebMtIyGCzofVR7Rs69Tj1RA2MaImJCdhvYg xkba92K1NQzCc9cFPNbMn0jpO6o7 X-Google-Smtp-Source: APXvYqyktynoW+tHdAI7M/o/NlB+6UWZag6mmwJUE/SBDpFkO+Z8MwjOuwMRnXuQj9tturz5DYTVgw== X-Received: by 2002:a63:fe44:: with SMTP id x4mr6257421pgj.118.1571344948576; Thu, 17 Oct 2019 13:42:28 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:28 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Allison Randal , Anson Huang , Dong Aisheng , Jacky Bai , Marco Felsch , =?utf-8?q?Ronald_Tschal=C3=A4r?= , Stefan Agner , linux-kernel@vger.kernel.org Subject: [PATCH 05/22] Input: adc-keys - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:41:59 -0700 Message-Id: <20191017204217.106453-6-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts adc-keys driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/Kconfig | 1 - drivers/input/keyboard/adc-keys.c | 36 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index a716a90de683..c6bf99d23b1a 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -16,7 +16,6 @@ if INPUT_KEYBOARD config KEYBOARD_ADC tristate "ADC Ladder Buttons" depends on IIO - select INPUT_POLLDEV help This driver implements support for buttons connected to an ADC using a resistor ladder. diff --git a/drivers/input/keyboard/adc-keys.c b/drivers/input/keyboard/adc-keys.c index 9885fd56f5f9..6d5be48d1b3d 100644 --- a/drivers/input/keyboard/adc-keys.c +++ b/drivers/input/keyboard/adc-keys.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -30,9 +29,9 @@ struct adc_keys_state { const struct adc_keys_button *map; }; -static void adc_keys_poll(struct input_polled_dev *dev) +static void adc_keys_poll(struct input_dev *input) { - struct adc_keys_state *st = dev->private; + struct adc_keys_state *st = input_get_drvdata(input); int i, value, ret; u32 diff, closest = 0xffffffff; int keycode = 0; @@ -55,12 +54,12 @@ static void adc_keys_poll(struct input_polled_dev *dev) keycode = 0; if (st->last_key && st->last_key != keycode) - input_report_key(dev->input, st->last_key, 0); + input_report_key(input, st->last_key, 0); if (keycode) - input_report_key(dev->input, keycode, 1); + input_report_key(input, keycode, 1); - input_sync(dev->input); + input_sync(input); st->last_key = keycode; } @@ -108,7 +107,6 @@ static int adc_keys_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct adc_keys_state *st; - struct input_polled_dev *poll_dev; struct input_dev *input; enum iio_chan_type type; int i, value; @@ -145,19 +143,13 @@ static int adc_keys_probe(struct platform_device *pdev) if (error) return error; - poll_dev = devm_input_allocate_polled_device(dev); - if (!poll_dev) { + input = devm_input_allocate_device(dev); + if (!input) { dev_err(dev, "failed to allocate input device\n"); return -ENOMEM; } - if (!device_property_read_u32(dev, "poll-interval", &value)) - poll_dev->poll_interval = value; - - poll_dev->poll = adc_keys_poll; - poll_dev->private = st; - - input = poll_dev->input; + input_set_drvdata(input, st); input->name = pdev->name; input->phys = "adc-keys/input0"; @@ -174,7 +166,17 @@ static int adc_keys_probe(struct platform_device *pdev) if (device_property_read_bool(dev, "autorepeat")) __set_bit(EV_REP, input->evbit); - error = input_register_polled_device(poll_dev); + + error = input_setup_polling(input, adc_keys_poll); + if (error) { + dev_err(dev, "Unable to set up polling: %d\n", error); + return error; + } + + if (!device_property_read_u32(dev, "poll-interval", &value)) + input_set_poll_interval(input, value); + + error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device: %d\n", error); return error; From patchwork Thu Oct 17 20:42:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 429B014ED for ; Thu, 17 Oct 2019 20:44:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18C2B21A49 for ; Thu, 17 Oct 2019 20:44:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mwk9rJS3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502159AbfJQUmc (ORCPT ); Thu, 17 Oct 2019 16:42:32 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45057 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502089AbfJQUmb (ORCPT ); Thu, 17 Oct 2019 16:42:31 -0400 Received: by mail-pl1-f194.google.com with SMTP id u12so1685953pls.12; Thu, 17 Oct 2019 13:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fxi+sR07mhlS6Muc3/xe4kp58yCZ85m02vfZzkl7bls=; b=mwk9rJS3O/sLFucmG/7gve5kqkBWWhON+TpQ2aqmeO52ZWjOMiubuBN/q2JBV1it0P gipHxm0TDWfYb3aim/NrtxsEfOYD0Dy52CoytANllNV1cklwfFGSPGhInjZUY7QSxHRz IoA78nPgkq0AotgY/PvJ6Atmm57eJcqOQO+0hADz+acB3cQisyeWWIK1dxfY0NVhhHWE vB3XDqBwLH9ml7qnOtYoZKHJNqcqKF5wQmWns+zuWXbtW21SbOjYew7az4K/ZZT3hZ56 ExKJJ63uofsHHR0yldF3qC5ROCNnhzLHVi6x3Ttx5/L68SDA4QadCeClguF7bxbp7BQd T1xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fxi+sR07mhlS6Muc3/xe4kp58yCZ85m02vfZzkl7bls=; b=Hm39Kr7T+ohsfBhi1tMAmedvlCbPZ55y3qX3NgRPERTTs3ofUFpSD/paLGZiMxjJj2 8cAlf5exlwJv9K9X8p40JbN8TM5dYYSrWPM7GaRJphJNotCgickapXcT9rkrvQgToPvj /Ptotwbhqs036EZaXZsMJraCHprOSXSp+4rDKgTMwi2zQdbFc/gjeYphKPpFrDWKk/yg aq1kYTFQSvjx/RTkoKjfK8zq3rBoY9bwwtWqzoPbthEK94sJLTPYEu8khSHpvaibBK0E C+Rxid1xkM8JRUuLHCnnwX8PVQIKrCKUN0KoVINa+D4gH8WOh6i0mBz7ZMvEVw5eAFxD Gmkw== X-Gm-Message-State: APjAAAVyfDZCh3oIdsO96AI0aPk6YCDxbesxLDk4SUEdYZoW+0yY6jQu KXK5gAUP+mQ+JaJKcCOZIdKhzjOD X-Google-Smtp-Source: APXvYqzf4XSgnOksu9P2edG1NQ0lwGyYaajoSSkzKKmR70FFg228zppNN9TgOLau/ptB7g06KJEIXA== X-Received: by 2002:a17:902:b196:: with SMTP id s22mr6234860plr.10.1571344950048; Thu, 17 Oct 2019 13:42:30 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:29 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Alexander Shiyan , Allison Randal , Andy Shevchenko , Anson Huang , Jacky Bai , Marco Felsch , =?utf-8?q?Ronald_Tschal=C3=A4r?= , Stefan Agner , YueHaibing , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/22] Input: clps711x-keypad - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:00 -0700 Message-Id: <20191017204217.106453-7-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts clps711x-keypad driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Also use managed API when allocating input device, this allows us to remove clps711x_keypad_remove() method. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/Kconfig | 1 - drivers/input/keyboard/clps711x-keypad.c | 70 ++++++++++-------------- 2 files changed, 29 insertions(+), 42 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index c6bf99d23b1a..0e7368288dae 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -190,7 +190,6 @@ config KEYBOARD_CLPS711X tristate "CLPS711X Keypad support" depends on OF_GPIO && (ARCH_CLPS711X || COMPILE_TEST) select INPUT_MATRIXKMAP - select INPUT_POLLDEV help Say Y here to enable the matrix keypad on the Cirrus Logic CLPS711X CPUs. diff --git a/drivers/input/keyboard/clps711x-keypad.c b/drivers/input/keyboard/clps711x-keypad.c index c4a5c07a4b98..019dd6ed2c29 100644 --- a/drivers/input/keyboard/clps711x-keypad.c +++ b/drivers/input/keyboard/clps711x-keypad.c @@ -6,7 +6,6 @@ */ #include -#include #include #include #include @@ -30,10 +29,10 @@ struct clps711x_keypad_data { struct clps711x_gpio_data *gpio_data; }; -static void clps711x_keypad_poll(struct input_polled_dev *dev) +static void clps711x_keypad_poll(struct input_dev *input) { - const unsigned short *keycodes = dev->input->keycode; - struct clps711x_keypad_data *priv = dev->private; + const unsigned short *keycodes = input->keycode; + struct clps711x_keypad_data *priv = input_get_drvdata(input); bool sync = false; int col, row; @@ -61,14 +60,14 @@ static void clps711x_keypad_poll(struct input_polled_dev *dev) if (state) { set_bit(col, data->last_state); - input_event(dev->input, EV_MSC, - MSC_SCAN, code); + input_event(input, + EV_MSC, MSC_SCAN, code); } else { clear_bit(col, data->last_state); } if (keycodes[code]) - input_report_key(dev->input, + input_report_key(input, keycodes[code], state); sync = true; } @@ -80,7 +79,7 @@ static void clps711x_keypad_poll(struct input_polled_dev *dev) } if (sync) - input_sync(dev->input); + input_sync(input); } static int clps711x_keypad_probe(struct platform_device *pdev) @@ -88,7 +87,7 @@ static int clps711x_keypad_probe(struct platform_device *pdev) struct clps711x_keypad_data *priv; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct input_polled_dev *poll_dev; + struct input_dev *input; u32 poll_interval; int i, err; @@ -125,53 +124,43 @@ static int clps711x_keypad_probe(struct platform_device *pdev) if (err) return err; - poll_dev = input_allocate_polled_device(); - if (!poll_dev) + input = devm_input_allocate_device(dev); + if (!input) return -ENOMEM; - poll_dev->private = priv; - poll_dev->poll = clps711x_keypad_poll; - poll_dev->poll_interval = poll_interval; - poll_dev->input->name = pdev->name; - poll_dev->input->dev.parent = dev; - poll_dev->input->id.bustype = BUS_HOST; - poll_dev->input->id.vendor = 0x0001; - poll_dev->input->id.product = 0x0001; - poll_dev->input->id.version = 0x0100; + input_set_drvdata(input, priv); + + input->name = pdev->name; + input->dev.parent = dev; + input->id.bustype = BUS_HOST; + input->id.vendor = 0x0001; + input->id.product = 0x0001; + input->id.version = 0x0100; err = matrix_keypad_build_keymap(NULL, NULL, priv->row_count, CLPS711X_KEYPAD_COL_COUNT, - NULL, poll_dev->input); + NULL, input); if (err) - goto out_err; + return err; - input_set_capability(poll_dev->input, EV_MSC, MSC_SCAN); + input_set_capability(input, EV_MSC, MSC_SCAN); if (of_property_read_bool(np, "autorepeat")) - __set_bit(EV_REP, poll_dev->input->evbit); - - platform_set_drvdata(pdev, poll_dev); + __set_bit(EV_REP, input->evbit); /* Set all columns to low */ regmap_update_bits(priv->syscon, SYSCON_OFFSET, SYSCON1_KBDSCAN_MASK, SYSCON1_KBDSCAN(1)); - err = input_register_polled_device(poll_dev); - if (err) - goto out_err; - - return 0; -out_err: - input_free_polled_device(poll_dev); - return err; -} + err = input_setup_polling(input, clps711x_keypad_poll); + if (err) + return err; -static int clps711x_keypad_remove(struct platform_device *pdev) -{ - struct input_polled_dev *poll_dev = platform_get_drvdata(pdev); + input_set_poll_interval(input, poll_interval); - input_unregister_polled_device(poll_dev); - input_free_polled_device(poll_dev); + err = input_register_device(input); + if (err) + return err; return 0; } @@ -188,7 +177,6 @@ static struct platform_driver clps711x_keypad_driver = { .of_match_table = clps711x_keypad_of_match, }, .probe = clps711x_keypad_probe, - .remove = clps711x_keypad_remove, }; module_platform_driver(clps711x_keypad_driver); From patchwork Thu Oct 17 20:42:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B72D014ED for ; Thu, 17 Oct 2019 20:44:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8BEDC21A49 for ; Thu, 17 Oct 2019 20:44:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uqZCfmKx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502278AbfJQUmd (ORCPT ); Thu, 17 Oct 2019 16:42:33 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35657 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502167AbfJQUmc (ORCPT ); Thu, 17 Oct 2019 16:42:32 -0400 Received: by mail-pg1-f194.google.com with SMTP id p30so2035195pgl.2; Thu, 17 Oct 2019 13:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DXOOvgjdHDLcY/TELjuk7480vpSOqwTSHaydEd8CsDk=; b=uqZCfmKxEStzygZDPg+aw/K+714cHqVk4+fZMdDo/w9IGMX2TkOBN5k7U79AJ4uh4D K6N50QhgWjTV1suuVzPDjkBvbnVWhS1JbKN5CdMnFacDxb3iiGEWKyJjyQxMuuxYKlYG NDtSxOfcHFRhb88y7M2QeWsE0mj8yavW4vfWis1nsuqTNbNF0CVpoIMgki8ocNYPeI7W FFGPFQWeGFROmKq5EBJ8nN4/KMSmnKreZHtyyBWdjmqPkzTDzVYWB7WFKxlkSsBBmXMP LJwDdS7v4WHc8eL2aYgPPpTdtWJN6MjgeaaxnM8u17+gENdF4Gwku45KFwf4jD7/rTrv GU4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DXOOvgjdHDLcY/TELjuk7480vpSOqwTSHaydEd8CsDk=; b=b9HTDaWXz6GAf1Fz0bKxcUNNAz2SJX1aYuRhvVelq5Ndys2MEnjLmr5JD7n9/z+rcx FbGCvAOjb2Wj3zdmzDUE2xqLGGfIAvsYRgTcEoStobnWFxAoIhwDLL4PP+EN03exMdLn PRt616IObIIDTZ1D6GK7taRqsyke+DaN7VrP6qv/J5pEKMLqFu1MMfe7CsM0KypgwM9W rTqEFy1UfMtwwehNvEi5MkS/LpcCo5roNuKPepSS/itLQUA64OeUN3rJDSy//emizwrt ZkA+7Go/joeEx2oQSI9ImqTs42AelVfT388codLttAv+uL06fUwDLxgPLxECUL0EOk4L XU4g== X-Gm-Message-State: APjAAAV37AvcBblQHb7zpsbNBjiyebBIL4a4Q+TAiv9jnEMs6cUKyTuH P+FtD1CJGiGg0geaKJ23EqEvwlcp X-Google-Smtp-Source: APXvYqymCrgDzYuBixHWm6GkgUIkI2iLHtFF52oTIoIgv32UpsMspRRf7vYHpgEq1y16QYXegSPl8w== X-Received: by 2002:a62:a504:: with SMTP id v4mr2224847pfm.243.1571344951192; Thu, 17 Oct 2019 13:42:31 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:30 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Allison Randal , Anson Huang , Enrico Weigelt , Jacky Bai , Marco Felsch , =?utf-8?q?Ronald_Tschal=C3=A4r?= , Stefan Agner , YueHaibing , linux-kernel@vger.kernel.org Subject: [PATCH 07/22] Input: jornada680_kbd - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:01 -0700 Message-Id: <20191017204217.106453-8-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts jornada680_kbd driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/Kconfig | 1 - drivers/input/keyboard/jornada680_kbd.c | 37 +++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 0e7368288dae..54b1905ebbfe 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -340,7 +340,6 @@ config KEYBOARD_HIL config KEYBOARD_HP6XX tristate "HP Jornada 6xx keyboard" depends on SH_HP6XX - select INPUT_POLLDEV help Say Y here if you have a HP Jornada 620/660/680/690 and want to support the built-in keyboard. diff --git a/drivers/input/keyboard/jornada680_kbd.c b/drivers/input/keyboard/jornada680_kbd.c index 4232aa876d2e..7e35081393be 100644 --- a/drivers/input/keyboard/jornada680_kbd.c +++ b/drivers/input/keyboard/jornada680_kbd.c @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -64,7 +63,7 @@ static const unsigned short jornada_scancodes[] = { #define JORNADA_SCAN_SIZE 18 struct jornadakbd { - struct input_polled_dev *poll_dev; + struct input_dev *input; unsigned short keymap[ARRAY_SIZE(jornada_scancodes)]; unsigned char length; unsigned char old_scan[JORNADA_SCAN_SIZE]; @@ -73,7 +72,7 @@ struct jornadakbd { static void jornada_parse_kbd(struct jornadakbd *jornadakbd) { - struct input_dev *input_dev = jornadakbd->poll_dev->input; + struct input_dev *input_dev = jornadakbd->input; unsigned short *keymap = jornadakbd->keymap; unsigned int sync_me = 0; unsigned int i, j; @@ -167,9 +166,9 @@ static void jornada_scan_keyb(unsigned char *s) *s++ = __raw_readb(PHDR); } -static void jornadakbd680_poll(struct input_polled_dev *dev) +static void jornadakbd680_poll(struct input_dev *input) { - struct jornadakbd *jornadakbd = dev->private; + struct jornadakbd *jornadakbd = input_get_drvdata(input); jornada_scan_keyb(jornadakbd->new_scan); jornada_parse_kbd(jornadakbd); @@ -179,7 +178,6 @@ static void jornadakbd680_poll(struct input_polled_dev *dev) static int jornada680kbd_probe(struct platform_device *pdev) { struct jornadakbd *jornadakbd; - struct input_polled_dev *poll_dev; struct input_dev *input_dev; int i, error; @@ -188,29 +186,24 @@ static int jornada680kbd_probe(struct platform_device *pdev) if (!jornadakbd) return -ENOMEM; - poll_dev = devm_input_allocate_polled_device(&pdev->dev); - if (!poll_dev) { - dev_err(&pdev->dev, "failed to allocate polled input device\n"); + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) { + dev_err(&pdev->dev, "failed to allocate input device\n"); return -ENOMEM; } - jornadakbd->poll_dev = poll_dev; + jornadakbd->input = input_dev; memcpy(jornadakbd->keymap, jornada_scancodes, sizeof(jornadakbd->keymap)); - poll_dev->private = jornadakbd; - poll_dev->poll = jornadakbd680_poll; - poll_dev->poll_interval = 50; /* msec */ - - input_dev = poll_dev->input; + input_set_drvdata(input_dev, jornadakbd); input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); input_dev->name = "HP Jornada 680 keyboard"; input_dev->phys = "jornadakbd/input0"; input_dev->keycode = jornadakbd->keymap; input_dev->keycodesize = sizeof(unsigned short); input_dev->keycodemax = ARRAY_SIZE(jornada_scancodes); - input_dev->dev.parent = &pdev->dev; input_dev->id.bustype = BUS_HOST; for (i = 0; i < 128; i++) @@ -220,9 +213,17 @@ static int jornada680kbd_probe(struct platform_device *pdev) input_set_capability(input_dev, EV_MSC, MSC_SCAN); - error = input_register_polled_device(jornadakbd->poll_dev); + error = input_setup_polling(input_dev, jornadakbd680_poll); + if (error) { + dev_err(&pdev->dev, "failed to set up polling\n"); + return error; + } + + input_set_poll_interval(input_dev, 50 /* msec */); + + error = input_register_device(input_dev); if (error) { - dev_err(&pdev->dev, "failed to register polled input device\n"); + dev_err(&pdev->dev, "failed to register input device\n"); return error; } From patchwork Thu Oct 17 20:42:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197119 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A6F914ED for ; Thu, 17 Oct 2019 20:42:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED3772089C for ; Thu, 17 Oct 2019 20:42:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hhV1i9Kh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502376AbfJQUmf (ORCPT ); Thu, 17 Oct 2019 16:42:35 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34056 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502279AbfJQUme (ORCPT ); Thu, 17 Oct 2019 16:42:34 -0400 Received: by mail-pf1-f193.google.com with SMTP id b128so2392399pfa.1; Thu, 17 Oct 2019 13:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B0s3tKuBk+lp7xcyPBRGt1DsIYJknXV6umHFo5h/I8Y=; b=hhV1i9KhFm+6Jd1qKeNUgzZv5U/kStM3dgMATNPV7INUHysvn1Vn/jhlU/Ybb7Ab6V ae92VWqfu816kHM1nQtZjiuyV5IMgVbnLmItxXo5Sa6A2n4c/bQbTNgOjzJbvyxRwkKB XKEiAPyRNecUBHUSqG4fuAraNDe4LIjr/chypOBI0qqQFdMaQGee/MLIGyDP6LIxIeN1 eCSGYPAWqQ4MJ1u8nNEC84edr09I8m7FJmgw2LbZ0nQdj9CezswR0eWw8eyeCk/nqsMC tIRXN5JRjpRfRvkSe2IrtsE4KQhN7IP5HU8ndD4FH6+6B+wUh4yn+HTGIdEQT1O5WoG8 71mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B0s3tKuBk+lp7xcyPBRGt1DsIYJknXV6umHFo5h/I8Y=; b=n5SAjxZ5DtrpLRZ+8A2XuAms+Y8AU1Tcm6bV+Np10/o36WIWgtmzXqyDg/dtedlvat Ow+K4OyDAnBcBlivfN/64FU28LxjoOiE1l0sKuA3h3wENUnH9Rmddv/CaZpXeCx5SVl+ ZJ79wfcSkVnobagl+hP5pTJ4at4niYkMYr0sK6uFZ+k5aA4Z6QOYr8T5kKRdDIH3o19E 4FTrp7xa/k/D8/EdQIicr17rM5XLo48ae2sabOD/FIFIOcbZq5Ru+Gc5eMgBPoIlPeWN gUj7n87iX65izTsdV/Q0Paxza5TQ7/Ge7odQChoZTx//JfO8+gPKi9yIBzFna7B9GL4J Bdzg== X-Gm-Message-State: APjAAAUfuKRqdNkbMQZ40WDQnSijFbwGSzrSAM78ra9wRliOhnp9I0eH CuyaN+1XlRDGyGk7iaSY+CM0DTZl X-Google-Smtp-Source: APXvYqz8Qo2V1zykS+Ng5NTW0WOgCtwowevyvaZ7Y0HPzvzwb0JdfI5aakXai4hO12XtpT3FJgbxLw== X-Received: by 2002:a62:4ed6:: with SMTP id c205mr2272074pfb.208.1571344952567; Thu, 17 Oct 2019 13:42:32 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:31 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Andy Shevchenko , Anson Huang , "Enrico Weigelt, metux IT consult" , "Gustavo A. R. Silva" , Jacky Bai , Marco Felsch , =?utf-8?q?Ronald_Tschal=C3=A4r?= , Stefan Agner , YueHaibing , linux-kernel@vger.kernel.org Subject: [PATCH 08/22] Input: gpio_keys_polled - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:02 -0700 Message-Id: <20191017204217.106453-9-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts gpio_keys_polled driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Note that we still keep polled and non-polled gpio-keys drivers separate, as they are different enough and mixing them up would make the code pretty confusing. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/Kconfig | 1 - drivers/input/keyboard/gpio_keys_polled.c | 65 ++++++++++++----------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 54b1905ebbfe..2856b4f72b12 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -248,7 +248,6 @@ config KEYBOARD_GPIO config KEYBOARD_GPIO_POLLED tristate "Polled GPIO buttons" depends on GPIOLIB - select INPUT_POLLDEV help This driver implements support for buttons connected to GPIO pins that are not capable of generating interrupts. diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index 465eecfa6b3f..4c93b85773ad 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -34,7 +33,7 @@ struct gpio_keys_button_data { }; struct gpio_keys_polled_dev { - struct input_polled_dev *poll_dev; + struct input_dev *input; struct device *dev; const struct gpio_keys_platform_data *pdata; unsigned long rel_axis_seen[BITS_TO_LONGS(REL_CNT)]; @@ -42,12 +41,11 @@ struct gpio_keys_polled_dev { struct gpio_keys_button_data data[0]; }; -static void gpio_keys_button_event(struct input_polled_dev *dev, +static void gpio_keys_button_event(struct input_dev *input, const struct gpio_keys_button *button, int state) { - struct gpio_keys_polled_dev *bdev = dev->private; - struct input_dev *input = dev->input; + struct gpio_keys_polled_dev *bdev = input_get_drvdata(input); unsigned int type = button->type ?: EV_KEY; if (type == EV_REL) { @@ -66,7 +64,7 @@ static void gpio_keys_button_event(struct input_polled_dev *dev, } } -static void gpio_keys_polled_check_state(struct input_polled_dev *dev, +static void gpio_keys_polled_check_state(struct input_dev *input, const struct gpio_keys_button *button, struct gpio_keys_button_data *bdata) { @@ -74,10 +72,10 @@ static void gpio_keys_polled_check_state(struct input_polled_dev *dev, state = gpiod_get_value_cansleep(bdata->gpiod); if (state < 0) { - dev_err(dev->input->dev.parent, + dev_err(input->dev.parent, "failed to get gpio state: %d\n", state); } else { - gpio_keys_button_event(dev, button, state); + gpio_keys_button_event(input, button, state); if (state != bdata->last_state) { bdata->count = 0; @@ -86,11 +84,10 @@ static void gpio_keys_polled_check_state(struct input_polled_dev *dev, } } -static void gpio_keys_polled_poll(struct input_polled_dev *dev) +static void gpio_keys_polled_poll(struct input_dev *input) { - struct gpio_keys_polled_dev *bdev = dev->private; + struct gpio_keys_polled_dev *bdev = input_get_drvdata(input); const struct gpio_keys_platform_data *pdata = bdev->pdata; - struct input_dev *input = dev->input; int i; memset(bdev->rel_axis_seen, 0, sizeof(bdev->rel_axis_seen)); @@ -101,10 +98,10 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev) if (bdata->count < bdata->threshold) { bdata->count++; - gpio_keys_button_event(dev, &pdata->buttons[i], + gpio_keys_button_event(input, &pdata->buttons[i], bdata->last_state); } else { - gpio_keys_polled_check_state(dev, &pdata->buttons[i], + gpio_keys_polled_check_state(input, &pdata->buttons[i], bdata); } } @@ -122,18 +119,20 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev) input_sync(input); } -static void gpio_keys_polled_open(struct input_polled_dev *dev) +static int gpio_keys_polled_open(struct input_dev *input) { - struct gpio_keys_polled_dev *bdev = dev->private; + struct gpio_keys_polled_dev *bdev = input_get_drvdata(input); const struct gpio_keys_platform_data *pdata = bdev->pdata; if (pdata->enable) pdata->enable(bdev->dev); + + return 0; } -static void gpio_keys_polled_close(struct input_polled_dev *dev) +static void gpio_keys_polled_close(struct input_dev *input) { - struct gpio_keys_polled_dev *bdev = dev->private; + struct gpio_keys_polled_dev *bdev = input_get_drvdata(input); const struct gpio_keys_platform_data *pdata = bdev->pdata; if (pdata->disable) @@ -232,7 +231,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) struct fwnode_handle *child = NULL; const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev); struct gpio_keys_polled_dev *bdev; - struct input_polled_dev *poll_dev; struct input_dev *input; int error; int i; @@ -255,19 +253,13 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) return -ENOMEM; } - poll_dev = devm_input_allocate_polled_device(dev); - if (!poll_dev) { - dev_err(dev, "no memory for polled device\n"); + input = devm_input_allocate_device(dev); + if (!input) { + dev_err(dev, "no memory for input device\n"); return -ENOMEM; } - poll_dev->private = bdev; - poll_dev->poll = gpio_keys_polled_poll; - poll_dev->poll_interval = pdata->poll_interval; - poll_dev->open = gpio_keys_polled_open; - poll_dev->close = gpio_keys_polled_close; - - input = poll_dev->input; + input_set_drvdata(input, bdev); input->name = pdata->name ?: pdev->name; input->phys = DRV_NAME"/input0"; @@ -277,6 +269,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) input->id.product = 0x0001; input->id.version = 0x0100; + input->open = gpio_keys_polled_open; + input->close = gpio_keys_polled_close; + __set_bit(EV_KEY, input->evbit); if (pdata->rep) __set_bit(EV_REP, input->evbit); @@ -353,11 +348,19 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) fwnode_handle_put(child); - bdev->poll_dev = poll_dev; + bdev->input = input; bdev->dev = dev; bdev->pdata = pdata; - error = input_register_polled_device(poll_dev); + error = input_setup_polling(input, gpio_keys_polled_poll); + if (error) { + dev_err(dev, "unable to set up polling, err=%d\n", error); + return error; + } + + input_set_poll_interval(input, pdata->poll_interval); + + error = input_register_device(input); if (error) { dev_err(dev, "unable to register polled device, err=%d\n", error); @@ -366,7 +369,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) /* report initial state of the buttons */ for (i = 0; i < pdata->nbuttons; i++) - gpio_keys_polled_check_state(poll_dev, &pdata->buttons[i], + gpio_keys_polled_check_state(input, &pdata->buttons[i], &bdev->data[i]); input_sync(input); From patchwork Thu Oct 17 20:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197121 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BB02112B for ; Thu, 17 Oct 2019 20:42:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5143021A49 for ; Thu, 17 Oct 2019 20:42:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DNDNpCdF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502425AbfJQUmh (ORCPT ); Thu, 17 Oct 2019 16:42:37 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36237 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502343AbfJQUmf (ORCPT ); Thu, 17 Oct 2019 16:42:35 -0400 Received: by mail-pf1-f193.google.com with SMTP id y22so2382919pfr.3; Thu, 17 Oct 2019 13:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PVrYmBoDUzQiiHoNw2A+nCbZJE8bePDfQgT4dijBPRw=; b=DNDNpCdFAd9VeiF8CHjBIo/j1+/PJ276Ve7b+Rck3q2D9WkgKlum2WioD8TIZJlWO1 hrzurCLh+Q4pMxpBRfgqxSHsoxr66e593gDDXUYZO6gxl9LpsA8IMt/rdaCA7Oqo2V2L rOEU0OeEHMquodtQeSdBU8xmVrdLnJOVgHFFvB5cOQ6D06KsHNNT1fpXjIzNqIO7+JMz S8e0cQGLm9yJD4bPhhcUJHvheXxUEyvAjyMdM2UMfnng6dFve0cXux1NxDnbba8t0zV3 HzLH1an4pkCtnyBX/ILC9iJlaqcOJ0QczrP4cC2g5pa9wIiiJLbizms+3IADNsxqFpya H/cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PVrYmBoDUzQiiHoNw2A+nCbZJE8bePDfQgT4dijBPRw=; b=qBwnRlz9k9ma/egp0mqbkj8esnW0Vyzja69GuduL6mxHH4VZULiTgt2iJRMXGHr5JT 0oc/Y6vuGcdwZh4n3Y96VTJKwh7HUTKA8UaFyY1CA4bWQMDF5BR+1N2cVJA5Pnz0LQoH 8crXijYbF7UCB214SVmm6ixObHe8SXzFZAtCZ6W5O7CLIsZf8LEgisvdzWI8zSGXCmvy UEIyiON5ccOZLm9edBDmRIUDPY44v+DyhQPcaTxVg7RySc0NtxxIlv5x65rIgOjNwZuN IeN2Ek7HeGK7Pg2bQmIdS61otKiFfckh6Mh7VZ4RqPKWDVff4FQ2usDGo6lqYBarkoIW pioA== X-Gm-Message-State: APjAAAWoEncA/n5Dx76w8lNhxBWlnZ6yWn0kxc7NILD+Ew87c3pMAFF7 TGGZZn+gPCl71366F+xjaszE5Egb X-Google-Smtp-Source: APXvYqwWilu0YT8+PBehmdRToprPAd+XGSdWPKVKJygxm7UFO/unONTgu6oIM937o/0QKQdQ2SFSrQ== X-Received: by 2002:a63:3853:: with SMTP id h19mr2781778pgn.55.1571344953854; Thu, 17 Oct 2019 13:42:33 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:33 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Bartosz Golaszewski , Brian Masney , Enrico Weigelt , Luca Weiss , Maximilian Luz , Sven Van Asbroeck , linux-kernel@vger.kernel.org Subject: [PATCH 09/22] Input: apanel - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:03 -0700 Message-Id: <20191017204217.106453-10-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts apanel driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. While at it, let's convert the driver to use devm. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/apanel.c | 153 +++++++++++++++--------------------- 2 files changed, 64 insertions(+), 90 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 7d9ae394e597..a6b8af69915d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -257,7 +257,6 @@ config INPUT_MMA8450 config INPUT_APANEL tristate "Fujitsu Lifebook Application Panel buttons" depends on X86 && I2C && LEDS_CLASS - select INPUT_POLLDEV select CHECK_SIGNATURE help Say Y here for support of the Application Panel buttons, used on diff --git a/drivers/input/misc/apanel.c b/drivers/input/misc/apanel.c index 53ec40d1b90d..de0deb432fe3 100644 --- a/drivers/input/misc/apanel.c +++ b/drivers/input/misc/apanel.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include @@ -51,19 +51,28 @@ static enum apanel_chip device_chip[APANEL_DEV_MAX]; #define MAX_PANEL_KEYS 12 struct apanel { - struct input_polled_dev *ipdev; + struct input_dev *idev; struct i2c_client *client; unsigned short keymap[MAX_PANEL_KEYS]; - u16 nkeys; + u16 nkeys; struct led_classdev mail_led; }; +static unsigned short apanel_keymap[MAX_PANEL_KEYS] = { + [0] = KEY_MAIL, + [1] = KEY_WWW, + [2] = KEY_PROG2, + [3] = KEY_PROG1, -static int apanel_probe(struct i2c_client *, const struct i2c_device_id *); + [8] = KEY_FORWARD, + [9] = KEY_REWIND, + [10] = KEY_STOPCD, + [11] = KEY_PLAYPAUSE, +}; static void report_key(struct input_dev *input, unsigned keycode) { - pr_debug(APANEL ": report key %#x\n", keycode); + dev_dbg(input->dev.parent, "report key %#x\n", keycode); input_report_key(input, keycode, 1); input_sync(input); @@ -79,10 +88,9 @@ static void report_key(struct input_dev *input, unsigned keycode) * CD keys: * Forward (0x100), Rewind (0x200), Stop (0x400), Pause (0x800) */ -static void apanel_poll(struct input_polled_dev *ipdev) +static void apanel_poll(struct input_dev *idev) { - struct apanel *ap = ipdev->private; - struct input_dev *idev = ipdev->input; + struct apanel *ap = input_get_drvdata(idev); u8 cmd = device_chip[APANEL_DEV_APPBTN] == CHIP_OZ992C ? 0 : 8; s32 data; int i; @@ -112,126 +120,93 @@ static int mail_led_set(struct led_classdev *led, return i2c_smbus_write_word_data(ap->client, 0x10, led_bits); } -static int apanel_remove(struct i2c_client *client) -{ - struct apanel *ap = i2c_get_clientdata(client); - - if (device_chip[APANEL_DEV_LED] != CHIP_NONE) - led_classdev_unregister(&ap->mail_led); - - input_unregister_polled_device(ap->ipdev); - input_free_polled_device(ap->ipdev); - - return 0; -} - -static void apanel_shutdown(struct i2c_client *client) -{ - apanel_remove(client); -} - -static const struct i2c_device_id apanel_id[] = { - { "fujitsu_apanel", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, apanel_id); - -static struct i2c_driver apanel_driver = { - .driver = { - .name = APANEL, - }, - .probe = &apanel_probe, - .remove = &apanel_remove, - .shutdown = &apanel_shutdown, - .id_table = apanel_id, -}; - -static struct apanel apanel = { - .keymap = { - [0] = KEY_MAIL, - [1] = KEY_WWW, - [2] = KEY_PROG2, - [3] = KEY_PROG1, - - [8] = KEY_FORWARD, - [9] = KEY_REWIND, - [10] = KEY_STOPCD, - [11] = KEY_PLAYPAUSE, - - }, - .mail_led = { - .name = "mail:blue", - .brightness_set_blocking = mail_led_set, - }, -}; - -/* NB: Only one panel on the i2c. */ static int apanel_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct apanel *ap; - struct input_polled_dev *ipdev; struct input_dev *idev; u8 cmd = device_chip[APANEL_DEV_APPBTN] == CHIP_OZ992C ? 0 : 8; - int i, err = -ENOMEM; + int i, err; - ap = &apanel; + ap = devm_kzalloc(&client->dev, sizeof(*ap), GFP_KERNEL); + if (!ap) + return -ENOMEM; - ipdev = input_allocate_polled_device(); - if (!ipdev) - goto out1; + idev = devm_input_allocate_device(&client->dev); + if (!idev) + return -ENOMEM; - ap->ipdev = ipdev; + ap->idev = idev; ap->client = client; i2c_set_clientdata(client, ap); err = i2c_smbus_write_word_data(client, cmd, 0); if (err) { - dev_warn(&client->dev, APANEL ": smbus write error %d\n", - err); - goto out3; + dev_warn(&client->dev, "smbus write error %d\n", err); + return err; } - ipdev->poll = apanel_poll; - ipdev->poll_interval = POLL_INTERVAL_DEFAULT; - ipdev->private = ap; + input_set_drvdata(idev, ap); - idev = ipdev->input; idev->name = APANEL_NAME " buttons"; idev->phys = "apanel/input0"; idev->id.bustype = BUS_HOST; - idev->dev.parent = &client->dev; - - set_bit(EV_KEY, idev->evbit); + memcpy(ap->keymap, apanel_keymap, sizeof(apanel_keymap)); idev->keycode = ap->keymap; idev->keycodesize = sizeof(ap->keymap[0]); idev->keycodemax = (device_chip[APANEL_DEV_CDBTN] != CHIP_NONE) ? 12 : 4; + set_bit(EV_KEY, idev->evbit); for (i = 0; i < idev->keycodemax; i++) if (ap->keymap[i]) set_bit(ap->keymap[i], idev->keybit); - err = input_register_polled_device(ipdev); + err = input_setup_polling(idev, apanel_poll); + if (err) + return err; + + input_set_poll_interval(idev, POLL_INTERVAL_DEFAULT); + + err = input_register_device(idev); if (err) - goto out3; + return err; if (device_chip[APANEL_DEV_LED] != CHIP_NONE) { - err = led_classdev_register(&client->dev, &ap->mail_led); + ap->mail_led.name = "mail:blue"; + ap->mail_led.brightness_set_blocking = mail_led_set; + err = devm_led_classdev_register(&client->dev, &ap->mail_led); if (err) - goto out4; + return err; } return 0; -out4: - input_unregister_polled_device(ipdev); -out3: - input_free_polled_device(ipdev); -out1: - return err; } +static void apanel_shutdown(struct i2c_client *client) +{ + struct apanel *ap = i2c_get_clientdata(client); + + if (device_chip[APANEL_DEV_LED] != CHIP_NONE) + led_set_brightness(&ap->mail_led, LED_OFF); +} + +static const struct i2c_device_id apanel_id[] = { + { "fujitsu_apanel", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, apanel_id); + +static struct i2c_driver apanel_driver = { + .driver = { + .name = APANEL, + }, + .probe = &apanel_probe, + .shutdown = &apanel_shutdown, + .id_table = apanel_id, +}; + /* Scan the system ROM for the signature "FJKEYINF" */ static __init const void __iomem *bios_signature(const void __iomem *bios) { From patchwork Thu Oct 17 20:42:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0921B112B for ; Thu, 17 Oct 2019 20:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D946721835 for ; Thu, 17 Oct 2019 20:43:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZFe484p1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502462AbfJQUmj (ORCPT ); Thu, 17 Oct 2019 16:42:39 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39518 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502399AbfJQUmg (ORCPT ); Thu, 17 Oct 2019 16:42:36 -0400 Received: by mail-pg1-f196.google.com with SMTP id p12so2020963pgn.6; Thu, 17 Oct 2019 13:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/u7CQMSqx4AqgCFaDTl7FrvAytzef1LxG8s2tTMpAZA=; b=ZFe484p1up1ZOS/7Ry47ymlyO4ldflOXJZvhXJjjjBkIofzyAXSDpqeLuaPAsLhPES ieRvhebdFRDC9aMNsPB0fD1yevighBZAwBIA7usJY/med0a/JfXNRt1N9mCWzP+RkEXF s8sUhbEFQB7ewA/HgBAzb50Tb4U8zcHLfwSCw0M3kBDRKpT37IpDJDcIQSzxaX6rT+lU jVtdIgI/IgQ1Fu3w06dfyLd5Val90VMqiUqTAbxbMtXaleiu8tcdoxD6cnrgrigPSONC 7HrW6rX5yRQrUVhafTX0kKN70YGbUNi19vg8lHF1deHA+UpXyoFUlPVM8hVoXr+O+Urv q7cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/u7CQMSqx4AqgCFaDTl7FrvAytzef1LxG8s2tTMpAZA=; b=ojg31Y65WaeN+n10GjmZB0fUs8sZWnQJlTNWIEAWKl+jbehajHEO2Nzpz7Q3U7yJoo 4zZE50f1qb8kPb25JJeXhoIEqsKw1GdKklZYXQyJMiv5TmGTIO4BkVpblveMMuggmhdD W87JYfapnzsMuYUSbQPvgx84syYgH08y0/7VagIfK+9yP1EltFIrdinhSQlSD3uXSkvf MqBMyN/MiexxWprpLM8jUco4FqvKxE++Xdgg+dO4eGpiQX9e7kdG8aRIlmTa8KDJSO7l rSr2ubOinWE0jmMzaW2bfFfO1+UmEWEAswkeKnG8PZyU02FnaZoFHSl3qb1OHrvp+NAt +hFA== X-Gm-Message-State: APjAAAVmq+iHC/Dq3ALNu2nD6nhBkJnlW4kRAmF+fxAHJx8Kv0fcAnbt 1PBb4blOjoSO0K3JORk4n9IyRQoU X-Google-Smtp-Source: APXvYqzxQ2/iNypxVHBBbitc/8Q8q1+ZEi6pyXFf2HzrEixssFtagr4mb7W2D+rPQCGMOLxHkqWnKg== X-Received: by 2002:a17:90a:cf98:: with SMTP id i24mr6391907pju.99.1571344955329; Thu, 17 Oct 2019 13:42:35 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:34 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Bartosz Golaszewski , Brian Masney , Luca Weiss , Maximilian Luz , Miloslav Trmac , Pavel Machek , linux-kernel@vger.kernel.org Subject: [PATCH 10/22] Input: wistron_btns - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:04 -0700 Message-Id: <20191017204217.106453-11-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts wistron_btns driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/wistron_btns.c | 51 ++++++++++++++++--------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index a6b8af69915d..248e3b40bd24 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -346,7 +346,6 @@ config INPUT_CPCAP_PWRBUTTON config INPUT_WISTRON_BTNS tristate "x86 Wistron laptop button interface" depends on X86_32 - select INPUT_POLLDEV select INPUT_SPARSEKMAP select NEW_LEDS select LEDS_CLASS diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c index 7ce6cc60d4d2..80dfd72a02d3 100644 --- a/drivers/input/misc/wistron_btns.c +++ b/drivers/input/misc/wistron_btns.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -1030,7 +1030,7 @@ static int __init select_keymap(void) /* Input layer interface */ -static struct input_polled_dev *wistron_idev; +static struct input_dev *wistron_idev; static unsigned long jiffies_last_press; static bool wifi_enabled; static bool bluetooth_enabled; @@ -1114,7 +1114,7 @@ static inline void wistron_led_resume(void) static void handle_key(u8 code) { const struct key_entry *key = - sparse_keymap_entry_from_scancode(wistron_idev->input, code); + sparse_keymap_entry_from_scancode(wistron_idev, code); if (key) { switch (key->type) { @@ -1133,14 +1133,14 @@ static void handle_key(u8 code) break; default: - sparse_keymap_report_entry(wistron_idev->input, - key, 1, true); + sparse_keymap_report_entry(wistron_idev, key, 1, true); break; } jiffies_last_press = jiffies; - } else + } else { printk(KERN_NOTICE "wistron_btns: Unknown key code %02X\n", code); + } } static void poll_bios(bool discard) @@ -1158,21 +1158,23 @@ static void poll_bios(bool discard) } } -static void wistron_flush(struct input_polled_dev *dev) +static int wistron_flush(struct input_dev *dev) { /* Flush stale event queue */ poll_bios(true); + + return 0; } -static void wistron_poll(struct input_polled_dev *dev) +static void wistron_poll(struct input_dev *dev) { poll_bios(false); /* Increase poll frequency if user is currently pressing keys (< 2s ago) */ if (time_before(jiffies, jiffies_last_press + 2 * HZ)) - dev->poll_interval = POLL_INTERVAL_BURST; + input_set_poll_interval(dev, POLL_INTERVAL_BURST); else - dev->poll_interval = POLL_INTERVAL_DEFAULT; + input_set_poll_interval(dev, POLL_INTERVAL_DEFAULT); } static int wistron_setup_keymap(struct input_dev *dev, @@ -1208,35 +1210,37 @@ static int wistron_setup_keymap(struct input_dev *dev, static int setup_input_dev(void) { - struct input_dev *input_dev; int error; - wistron_idev = input_allocate_polled_device(); + wistron_idev = input_allocate_device(); if (!wistron_idev) return -ENOMEM; + wistron_idev->name = "Wistron laptop buttons"; + wistron_idev->phys = "wistron/input0"; + wistron_idev->id.bustype = BUS_HOST; + wistron_idev->dev.parent = &wistron_device->dev; + wistron_idev->open = wistron_flush; - wistron_idev->poll = wistron_poll; - wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT; - input_dev = wistron_idev->input; - input_dev->name = "Wistron laptop buttons"; - input_dev->phys = "wistron/input0"; - input_dev->id.bustype = BUS_HOST; - input_dev->dev.parent = &wistron_device->dev; + error = sparse_keymap_setup(wistron_idev, keymap, wistron_setup_keymap); + if (error) + goto err_free_dev; - error = sparse_keymap_setup(input_dev, keymap, wistron_setup_keymap); + error = input_setup_polling(wistron_idev, wistron_poll); if (error) goto err_free_dev; - error = input_register_polled_device(wistron_idev); + input_set_poll_interval(wistron_idev, POLL_INTERVAL_DEFAULT); + + error = input_register_device(wistron_idev); if (error) goto err_free_dev; return 0; err_free_dev: - input_free_polled_device(wistron_idev); + input_free_device(wistron_idev); return error; } @@ -1285,8 +1289,7 @@ static int wistron_probe(struct platform_device *dev) static int wistron_remove(struct platform_device *dev) { wistron_led_remove(); - input_unregister_polled_device(wistron_idev); - input_free_polled_device(wistron_idev); + input_unregister_device(wistron_idev); bios_detach(); return 0; From patchwork Thu Oct 17 20:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDC0614ED for ; Thu, 17 Oct 2019 20:43:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8E2621835 for ; Thu, 17 Oct 2019 20:43:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tPdmfa5G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502500AbfJQUmk (ORCPT ); Thu, 17 Oct 2019 16:42:40 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35941 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502438AbfJQUmi (ORCPT ); Thu, 17 Oct 2019 16:42:38 -0400 Received: by mail-pg1-f196.google.com with SMTP id 23so2026884pgk.3; Thu, 17 Oct 2019 13:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ee91/xG94vrK174Ap37BZY7hPtCqG3wuDv6y0inOwfc=; b=tPdmfa5GhJgDexdot7dFaorP9ntzYJ8XkuMaPkGiQYZXsUiaEaq13F9ak56x6kExDM t/6JYqXr8/TTdnf2vwoAAGnWG9poQ501bHa9wp3jfXSu0/KNqc7wPpsTbrJGpyv2RGs9 MgRG+LAaHdh4AxyHBxKvV85UPYJJUlPvMvktXV8VzF79jwjHa7dTKu8NWRJ3IIIrFAry cfvXqfNnmaf720tOcGV4avokQN//I6NYgyniyx7Qyi77bf6DswKdFk4V74A+I8Tu+f61 iibwv2BFy1mi9SNR/Tb1d3f96H2fzUjqfQHR8BaFooaeVG1J8gx61Rfda3ZYkaSLqbzu iIEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ee91/xG94vrK174Ap37BZY7hPtCqG3wuDv6y0inOwfc=; b=A50rwOSLaOw6Gi+y4kLzwAQyBNGC3LAOnnybpt9lxomR2abJbpbk6m1kViy6gvkhGq 83ZDEQ/BRTGyEaCIP97DEQH4CPWLsaP2Wmj02CrWroea4pUDGjKJ+K6rVfoWLR2Hya6x dz68P26meq8rO4ZRXc4vUnAMQvJNQ5OgNrIGWJLLNrp8oYva22w2tyFfSbytBm7pWGub l/PSM1nRnS/kfuP+rqe+9ff9Ks02ze6EP5WQ5+F9alwysAcTnqkMZyxoZWska78OdcUG 2fu2nyvyu0wnK6U5Z01Qc3ctUgYWhfYjkgjfL3N8XnRA0sSh8nf8FFIsfqGD7lHhHxrg fo4Q== X-Gm-Message-State: APjAAAXasom7sFxnQWaHgdTuAZL8qmkE9XcDUfvC5+DmAPMaYhesY3R+ neR8OF5wsOJo5WnyG1CwBqBQ+ELM X-Google-Smtp-Source: APXvYqxoeUXnaHbIqvzA0E+PMO+WkVecyxIlVsndoY6dz9fRUAkrKiYqUKP/1oSTGpP4Z52H6aWgKw== X-Received: by 2002:a17:90a:aa97:: with SMTP id l23mr6574076pjq.7.1571344956347; Thu, 17 Oct 2019 13:42:36 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:35 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Jilayne Lovejoy , Steve Winslow , linux-kernel@vger.kernel.org Subject: [PATCH 11/22] Input: cobalt_btns - convert to use managed resources Date: Thu, 17 Oct 2019 13:42:05 -0700 Message-Id: <20191017204217.106453-12-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This simplifies error handling and allows to remove cobalt_buttons_remove() method. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/cobalt_btns.c | 57 ++++++++++---------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c index bcf6174bbd5d..f7c1693fc6bb 100644 --- a/drivers/input/misc/cobalt_btns.c +++ b/drivers/input/misc/cobalt_btns.c @@ -5,6 +5,7 @@ * Copyright (C) 2007-2008 Yoichi Yuasa */ #include +#include #include #include #include @@ -26,7 +27,6 @@ static const unsigned short cobalt_map[] = { }; struct buttons_dev { - struct input_polled_dev *poll_dev; unsigned short keymap[ARRAY_SIZE(cobalt_map)]; int count[ARRAY_SIZE(cobalt_map)]; void __iomem *reg; @@ -67,15 +67,24 @@ static int cobalt_buttons_probe(struct platform_device *pdev) struct resource *res; int error, i; - bdev = kzalloc(sizeof(struct buttons_dev), GFP_KERNEL); - poll_dev = input_allocate_polled_device(); - if (!bdev || !poll_dev) { - error = -ENOMEM; - goto err_free_mem; - } + bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL); + if (!bdev) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EBUSY; + + bdev->reg = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!bdev->reg) + return -ENOMEM; memcpy(bdev->keymap, cobalt_map, sizeof(bdev->keymap)); + poll_dev = devm_input_allocate_polled_device(&pdev->dev); + if (!poll_dev) + return -ENOMEM; + poll_dev->private = bdev; poll_dev->poll = handle_buttons; poll_dev->poll_interval = BUTTONS_POLL_INTERVAL; @@ -84,7 +93,6 @@ static int cobalt_buttons_probe(struct platform_device *pdev) input->name = "Cobalt buttons"; input->phys = "cobalt/input0"; input->id.bustype = BUS_HOST; - input->dev.parent = &pdev->dev; input->keycode = bdev->keymap; input->keycodemax = ARRAY_SIZE(bdev->keymap); @@ -96,39 +104,9 @@ static int cobalt_buttons_probe(struct platform_device *pdev) __set_bit(bdev->keymap[i], input->keybit); __clear_bit(KEY_RESERVED, input->keybit); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - error = -EBUSY; - goto err_free_mem; - } - - bdev->poll_dev = poll_dev; - bdev->reg = ioremap(res->start, resource_size(res)); - dev_set_drvdata(&pdev->dev, bdev); - error = input_register_polled_device(poll_dev); if (error) - goto err_iounmap; - - return 0; - - err_iounmap: - iounmap(bdev->reg); - err_free_mem: - input_free_polled_device(poll_dev); - kfree(bdev); - return error; -} - -static int cobalt_buttons_remove(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct buttons_dev *bdev = dev_get_drvdata(dev); - - input_unregister_polled_device(bdev->poll_dev); - input_free_polled_device(bdev->poll_dev); - iounmap(bdev->reg); - kfree(bdev); + return error; return 0; } @@ -141,7 +119,6 @@ MODULE_ALIAS("platform:Cobalt buttons"); static struct platform_driver cobalt_buttons_driver = { .probe = cobalt_buttons_probe, - .remove = cobalt_buttons_remove, .driver = { .name = "Cobalt buttons", }, From patchwork Thu Oct 17 20:42:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D48F14ED for ; Thu, 17 Oct 2019 20:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CECD2089C for ; Thu, 17 Oct 2019 20:42:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CbQAgdz0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502570AbfJQUmn (ORCPT ); Thu, 17 Oct 2019 16:42:43 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:42318 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502472AbfJQUmk (ORCPT ); Thu, 17 Oct 2019 16:42:40 -0400 Received: by mail-pl1-f195.google.com with SMTP id g9so383799plj.9; Thu, 17 Oct 2019 13:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+B6qJ2+sSOJxH3bWqT0dnUTKHAsVIIfgBFCuwwzUvjw=; b=CbQAgdz0/oATooI3JAjctya7d07Tum22kSzH0rlFQExxNDjvC1yAx+owKU4ysP3SKD 9yb7s2uIEH/105h8+GSQVl60hNegEwtDz0vlIpGCiNerVAwyPJBhFzsip7BRAVbx5NGq 6Q4fkJEmZbjtMlcSuRFk/4AsziJR4GtD3brq1dS20KStyj8folSpT5flYwr1W1ocIiYC WF1I3L6RWhgaYEzacOIm2hOviTTmZ1GcOraxZs2DZMJ0fhuRpaqmZ1Qls112sxOCzyZT 0l081m5qb7VDyMaBTq2YnVEVCX+654J2CfYaNjDBhFcGIBoKSx+iWrdznAFwS0UlIGJN 3N7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+B6qJ2+sSOJxH3bWqT0dnUTKHAsVIIfgBFCuwwzUvjw=; b=OI5DjDt70xeaWZ3UVs8Ox8XuHFgkNsmiOVNtGC9dY6ufWJwVuvsPzYp4pqLYaSkhE1 QEhOs1xXlxDGswBtMSNG8/2RXEuV26v+2L6JaGv3InefdvJGKeJZG8VBkZNE7bKHTyE5 EIa2Q6wg4Pa2A5eAzXV6brm5/DQ0RVdfEMhnKJYI2Si9T8/Zxv13X2sN7sKwP343iFpR ETct7ehRcbbze0xLTWbgygufmdWUey4QNOi2hzC6/uZlsdiWSp27fRj0FbSnHU6d7/cO nlaR+oVTp7RpQ/FqPVJLK6MUUFQtJO5Ma9nB0fGehUCL3wULvppr9K12YQ/Hvz51c/Mu rF3w== X-Gm-Message-State: APjAAAU6xyUhow34h3e6Ov9YtiVD0vaRKS5VxFiLeXFey/JO6YW//jGt oRBBZD0ALiOSt53L5fEMgH2DbfXR X-Google-Smtp-Source: APXvYqzI5gLW8a6HyzNcyCcjJkOmrrq46EKMuhYNuMDZbqFmTjdU0b+0s1BXJwbfkAOFURuuW1V+4A== X-Received: by 2002:a17:902:6acb:: with SMTP id i11mr5767468plt.273.1571344957746; Thu, 17 Oct 2019 13:42:37 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:36 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Allison Randal , Bartosz Golaszewski , Brian Masney , Jilayne Lovejoy , Luca Weiss , Maximilian Luz , linux-kernel@vger.kernel.org Subject: [PATCH 12/22] Input: cobalt_btns - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:06 -0700 Message-Id: <20191017204217.106453-13-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts cobalt_btns driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/cobalt_btns.c | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 248e3b40bd24..05520bf4e31d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -326,7 +326,6 @@ config INPUT_IXP4XX_BEEPER config INPUT_COBALT_BTNS tristate "Cobalt button interface" depends on MIPS_COBALT - select INPUT_POLLDEV help Say Y here if you want to support MIPS Cobalt button interface. diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c index f7c1693fc6bb..b1624f5414ee 100644 --- a/drivers/input/misc/cobalt_btns.c +++ b/drivers/input/misc/cobalt_btns.c @@ -4,7 +4,7 @@ * * Copyright (C) 2007-2008 Yoichi Yuasa */ -#include +#include #include #include #include @@ -32,10 +32,9 @@ struct buttons_dev { void __iomem *reg; }; -static void handle_buttons(struct input_polled_dev *dev) +static void handle_buttons(struct input_dev *input) { - struct buttons_dev *bdev = dev->private; - struct input_dev *input = dev->input; + struct buttons_dev *bdev = input_get_drvdata(input); uint32_t status; int i; @@ -62,7 +61,6 @@ static void handle_buttons(struct input_polled_dev *dev) static int cobalt_buttons_probe(struct platform_device *pdev) { struct buttons_dev *bdev; - struct input_polled_dev *poll_dev; struct input_dev *input; struct resource *res; int error, i; @@ -81,15 +79,12 @@ static int cobalt_buttons_probe(struct platform_device *pdev) memcpy(bdev->keymap, cobalt_map, sizeof(bdev->keymap)); - poll_dev = devm_input_allocate_polled_device(&pdev->dev); - if (!poll_dev) + input = devm_input_allocate_device(&pdev->dev); + if (!input) return -ENOMEM; - poll_dev->private = bdev; - poll_dev->poll = handle_buttons; - poll_dev->poll_interval = BUTTONS_POLL_INTERVAL; + input_set_drvdata(input, bdev); - input = poll_dev->input; input->name = "Cobalt buttons"; input->phys = "cobalt/input0"; input->id.bustype = BUS_HOST; @@ -104,7 +99,14 @@ static int cobalt_buttons_probe(struct platform_device *pdev) __set_bit(bdev->keymap[i], input->keybit); __clear_bit(KEY_RESERVED, input->keybit); - error = input_register_polled_device(poll_dev); + + error = input_setup_polling(input, handle_buttons); + if (error) + return error; + + input_set_poll_interval(input, BUTTONS_POLL_INTERVAL); + + error = input_register_device(input); if (error) return error; From patchwork Thu Oct 17 20:42:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEE5D112B for ; Thu, 17 Oct 2019 20:42:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE7E4222C5 for ; Thu, 17 Oct 2019 20:42:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Etg86CwG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502167AbfJQUmk (ORCPT ); Thu, 17 Oct 2019 16:42:40 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35670 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502467AbfJQUmk (ORCPT ); Thu, 17 Oct 2019 16:42:40 -0400 Received: by mail-pg1-f194.google.com with SMTP id p30so2035378pgl.2; Thu, 17 Oct 2019 13:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HlyTv1vxc6ePybQkoO4f5oM/4dcEruouJB05duaVKOg=; b=Etg86CwGZ+v3CIcN3+OB9F2ezo3lxulhWGvKvFJ/Khi2bemD+HihqF4RzcPR/QO/XU cEpINIkKoz4HldLf/AQwdqTskzwveI1ITM3xLiSULviKiFauPsIKhg3xgatCy00zN+41 zwxYlUvUoJauPL6GJ2GyIgJ5OSJ7TMEVIdPIYBWLW+upLso81zbsRuX0//zV4lT0piAU FIP6XqLXzcXXX53tSCPMDnjByp0Ys0yaufH3JDRpCGNoMeRYLahuD9sYCDD/yugvJk1C Fm7GxgKzRfDPSbvUMxkVg6MVTIW8UpT87L6I8X7dn4f6mnbGSFicZ29tmmXpAfZ9+OLT WPNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HlyTv1vxc6ePybQkoO4f5oM/4dcEruouJB05duaVKOg=; b=mh/JoiBY02hrgyunRDWhArL1q1DyBGU0WgqL8XmYEpTcreK2jqJZtcRo54IH8TvarA FthzLXmGpKP3vyPkppofmW/tQIQJCxY6eTef7KyEJouDV0IH3W/vDmgUezw3eryIgp+i WqLcr+qOYSqE0wLLNEQVzeVgbFDivrAxAt0t/CDVsYB58GF34UqXpP3W130zoxRbAIwQ M8cte37ofZ6wSGZ/TM8d69UFY6kIvlCZtEU9QQbEBcapCQNcOSXjkWSZ/lK4Og5YKI8+ MKzWJJchE5tYC6Pj6UYZbuRUvluF7TcnfQ82ITlo7wnYJv/egHSxLssqbQiV5hcs/DVl XSzg== X-Gm-Message-State: APjAAAXJRyeunsycgSC9Nw8PIbHUZqpgyz/RwR/23s/jMzt8bLYr35b3 BXVefyXEMp1AoChpkiCR78rsLJfA X-Google-Smtp-Source: APXvYqx2rCUUL0uB7Oa8fpKv2VmOqEtr/L5iYRfOD3zpjZFO02ZAaJyVscUDv45qdl9E5OpiRTf61g== X-Received: by 2002:a17:90a:858a:: with SMTP id m10mr6937186pjn.128.1571344958930; Thu, 17 Oct 2019 13:42:38 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:38 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Allison Randal , Jilayne Lovejoy , Steve Winslow , linux-kernel@vger.kernel.org Subject: [PATCH 13/22] Input: sgi_btns - switch to using managed resources Date: Thu, 17 Oct 2019 13:42:07 -0700 Message-Id: <20191017204217.106453-14-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Switching to devm API allows to clean up error handling paths and drop the remove() method. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/sgi_btns.c | 37 ++++++++--------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/drivers/input/misc/sgi_btns.c b/drivers/input/misc/sgi_btns.c index 0fee6ddf3602..829277b4271f 100644 --- a/drivers/input/misc/sgi_btns.c +++ b/drivers/input/misc/sgi_btns.c @@ -45,7 +45,6 @@ static const unsigned short sgi_map[] = { }; struct buttons_dev { - struct input_polled_dev *poll_dev; unsigned short keymap[ARRAY_SIZE(sgi_map)]; int count[ARRAY_SIZE(sgi_map)]; }; @@ -84,12 +83,13 @@ static int sgi_buttons_probe(struct platform_device *pdev) struct input_dev *input; int error, i; - bdev = kzalloc(sizeof(struct buttons_dev), GFP_KERNEL); - poll_dev = input_allocate_polled_device(); - if (!bdev || !poll_dev) { - error = -ENOMEM; - goto err_free_mem; - } + bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL); + if (!bdev) + return -ENOMEM; + + poll_dev = devm_input_allocate_polled_device(&pdev->dev); + if (!poll_dev) + return -ENOMEM; memcpy(bdev->keymap, sgi_map, sizeof(bdev->keymap)); @@ -101,7 +101,6 @@ static int sgi_buttons_probe(struct platform_device *pdev) input->name = "SGI buttons"; input->phys = "sgi/input0"; input->id.bustype = BUS_HOST; - input->dev.parent = &pdev->dev; input->keycode = bdev->keymap; input->keycodemax = ARRAY_SIZE(bdev->keymap); @@ -113,35 +112,15 @@ static int sgi_buttons_probe(struct platform_device *pdev) __set_bit(bdev->keymap[i], input->keybit); __clear_bit(KEY_RESERVED, input->keybit); - bdev->poll_dev = poll_dev; - platform_set_drvdata(pdev, bdev); - error = input_register_polled_device(poll_dev); if (error) - goto err_free_mem; - - return 0; - - err_free_mem: - input_free_polled_device(poll_dev); - kfree(bdev); - return error; -} - -static int sgi_buttons_remove(struct platform_device *pdev) -{ - struct buttons_dev *bdev = platform_get_drvdata(pdev); - - input_unregister_polled_device(bdev->poll_dev); - input_free_polled_device(bdev->poll_dev); - kfree(bdev); + return error; return 0; } static struct platform_driver sgi_buttons_driver = { .probe = sgi_buttons_probe, - .remove = sgi_buttons_remove, .driver = { .name = "sgibtns", }, From patchwork Thu Oct 17 20:42:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A1F015AB for ; Thu, 17 Oct 2019 20:43:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE0C221A4C for ; Thu, 17 Oct 2019 20:43:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iu0ojF5y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503577AbfJQUnp (ORCPT ); Thu, 17 Oct 2019 16:43:45 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36784 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502537AbfJQUmm (ORCPT ); Thu, 17 Oct 2019 16:42:42 -0400 Received: by mail-pl1-f193.google.com with SMTP id j11so1706588plk.3; Thu, 17 Oct 2019 13:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4OSh22+yVoEobbB0Q9LQlMfjUGPQ3hQpM1kovi0TTTE=; b=iu0ojF5yyj3dozHSsziE6kH+Gi584zheA4VlOiCemk4AZQxzKgXLvsn48gtIUW07GV NYtO3c3McBZb+y16uZZkbEdrJll5zVPqOfbr5J1eR56JUNnlneb5jM5y8C6jdeGIq1cs KT1paaVMZXfKM6U0JiYRTdC/Dz8ttXYo8QrNgB8/JbxYHcTspL89Pkg2YIjCzOOW98u6 oojuO2+f6cbLTr0MSPVP59KD190L0rNkxCBbN1MLCN+X7HuFaxjBUkkZe7kLmQY3a8Gx 4Q3fZpcz451JoqXgCcOiW3WE+ARX/EbIveS2ZhP9drB2VMozR94DyNlsk+ZlX1Myqqnr 7OfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4OSh22+yVoEobbB0Q9LQlMfjUGPQ3hQpM1kovi0TTTE=; b=b1hvzDWtkbn79YWU2OKspKEsO4Dx/2k5XUZvRt3gelV3O/DYMLp4UuXoXLncVv3Ugq 0kDLDqdG1NAHeceDnU0d8lw735j0UjO7Pr4KsKd/yoCPmevl0RJpYfzhN41OF9Evv0Ry Ec60+lTxWbcbgVABa/yDl3Cs5vp+bjGqHYHhW39LUlFWQaQfV0kG45k8vs4Ov6rtLKVB 0LL5FVfkDcnIOqriOifVL4tiQrJyYzuE6j6oiV7YHoBmLTfDqWvygRsueIoh+JwORwat EKD/ypCn0qPlS3Uyx/1BdstFlxNimpy0G1Vsgfu9Ra8JgBEQMtVn2b6gICSiHMiWhYHs bN5Q== X-Gm-Message-State: APjAAAULPZHEziLsOI+DIC5/eW5cJNGnzzmNbOlaCtzLqy85tKQTXl4F Pg8Px97G8QsxtbZdBBDViFSYGnZ+ X-Google-Smtp-Source: APXvYqxl19fCY67lB2b4zP9cmS80YAs6fS6GazjMSJQY393kf6FKfGDNK0YS2dKRdIaSqx5sOXj3kw== X-Received: by 2002:a17:902:848e:: with SMTP id c14mr5548629plo.77.1571344960154; Thu, 17 Oct 2019 13:42:40 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:39 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Bartosz Golaszewski , Brian Masney , Luca Weiss , Maximilian Luz , Steve Winslow , linux-kernel@vger.kernel.org Subject: [PATCH 14/22] Input: sgi_btns - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:08 -0700 Message-Id: <20191017204217.106453-15-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts sgi_btns driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/sgi_btns.c | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 05520bf4e31d..c27a9ee4ef9a 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -543,7 +543,6 @@ config INPUT_UINPUT config INPUT_SGI_BTNS tristate "SGI Indy/O2 volume button interface" depends on SGI_IP22 || SGI_IP32 - select INPUT_POLLDEV help Say Y here if you want to support SGI Indy/O2 volume button interface. diff --git a/drivers/input/misc/sgi_btns.c b/drivers/input/misc/sgi_btns.c index 829277b4271f..0657d785b3cc 100644 --- a/drivers/input/misc/sgi_btns.c +++ b/drivers/input/misc/sgi_btns.c @@ -4,7 +4,7 @@ * * Copyright (C) 2008 Thomas Bogendoerfer */ -#include +#include #include #include #include @@ -49,10 +49,9 @@ struct buttons_dev { int count[ARRAY_SIZE(sgi_map)]; }; -static void handle_buttons(struct input_polled_dev *dev) +static void handle_buttons(struct input_dev *input) { - struct buttons_dev *bdev = dev->private; - struct input_dev *input = dev->input; + struct buttons_dev *bdev = input_get_drvdata(input); u8 status; int i; @@ -79,7 +78,6 @@ static void handle_buttons(struct input_polled_dev *dev) static int sgi_buttons_probe(struct platform_device *pdev) { struct buttons_dev *bdev; - struct input_polled_dev *poll_dev; struct input_dev *input; int error, i; @@ -87,17 +85,14 @@ static int sgi_buttons_probe(struct platform_device *pdev) if (!bdev) return -ENOMEM; - poll_dev = devm_input_allocate_polled_device(&pdev->dev); - if (!poll_dev) + input = devm_input_allocate_device(&pdev->dev); + if (!input) return -ENOMEM; memcpy(bdev->keymap, sgi_map, sizeof(bdev->keymap)); - poll_dev->private = bdev; - poll_dev->poll = handle_buttons; - poll_dev->poll_interval = BUTTONS_POLL_INTERVAL; + input_set_drvdata(input, bdev); - input = poll_dev->input; input->name = "SGI buttons"; input->phys = "sgi/input0"; input->id.bustype = BUS_HOST; @@ -112,7 +107,13 @@ static int sgi_buttons_probe(struct platform_device *pdev) __set_bit(bdev->keymap[i], input->keybit); __clear_bit(KEY_RESERVED, input->keybit); - error = input_register_polled_device(poll_dev); + error = input_setup_polling(input, handle_buttons); + if (error) + return error; + + input_set_poll_interval(input, BUTTONS_POLL_INTERVAL); + + error = input_register_device(input); if (error) return error; From patchwork Thu Oct 17 20:42:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2D03112B for ; Thu, 17 Oct 2019 20:43:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C228E21835 for ; Thu, 17 Oct 2019 20:43:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sosHBIU0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503574AbfJQUnp (ORCPT ); Thu, 17 Oct 2019 16:43:45 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42160 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502552AbfJQUmo (ORCPT ); Thu, 17 Oct 2019 16:42:44 -0400 Received: by mail-pg1-f195.google.com with SMTP id f14so2007056pgi.9; Thu, 17 Oct 2019 13:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rw40Y7pRi4fTQvKbY/v46MITEUGL/XAU6ul7eCZwlVo=; b=sosHBIU0RsMqX17uO+wNzNK+kTy+a2nIFoJViL+RO0PmnZeS5wLogNIhsI6ZFet+U0 C8T94GZQOS4cgMpAQ/aUOb3LZ60rTrnwBD5ubj9FE0ZndFOgELM3lw+FnioxXNUR4AQ+ 488KaZljXNL/XiQS5gYiEm0PU0eHrYUhAKlOqzRwv3okyPruZVB2DZ+Lir3uMZzQZsVS wHKseAUYgWvgZMZGpkz1L8lJaO7EacPEQpJalDbuLKRQ1PChklT8VmBA/0FBQJBHuiXV /WOB/wtEw95TcmXnjM8ZZxYeYLPJpp7cN+1amGmo8MihmpH8MaHIkQ64lfha4BkRt9Ma 6Bfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rw40Y7pRi4fTQvKbY/v46MITEUGL/XAU6ul7eCZwlVo=; b=gKtPbzLnFBXMPzfTBPSen+5VeDpXWrB9ycfAvVb7GTGKYXfpUvcXrtvcD/NgF3pSSs czKg8q92SglH3bspWfmuk+qnEWXPF/BGRlO1CIAYda1kVjloG09ddOZLDJH4r7U06No7 4KAqgdRDvvfOX8spefkQ4F9i4vrdd3VvWdteqRNaa6UDtSSOuBxjlBASwpl1Tk+pYf1H jKLO8oOl2IZAfmgLRhnFsv9BbzOwKvT5AvBFIKsWs0NKS4/RywB9ugQcT3vQ4KdQbxco 2dRxmuzUR1CTK4jmteqDMndb16iU+nEU07oRrbLFCSQHxH+uNYqBbiqhVpXxslKTpJi5 DUog== X-Gm-Message-State: APjAAAX0QA9cq7+MTPJPiVLC0Hr1eYxY6RjPzQA0Mej/bkGk50rwueTh o7dB18gO8EFcRKfiBcHWtJZLMeWm X-Google-Smtp-Source: APXvYqwtsuKuPXZsa6pO5sz5LSSNVN+NQpd7xgf5wX3/YM8FzUSQ7oSB8pkq6qaUhvZnucZLxfiB+A== X-Received: by 2002:a17:90a:a407:: with SMTP id y7mr6561565pjp.124.1571344961518; Thu, 17 Oct 2019 13:42:41 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:40 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 15/22] Input: rb532_button - switch to using managed resources Date: Thu, 17 Oct 2019 13:42:09 -0700 Message-Id: <20191017204217.106453-16-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Using devm API allows us to clean up error handling paths and drop the remove() method. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/rb532_button.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/input/misc/rb532_button.c b/drivers/input/misc/rb532_button.c index 4412055f8761..3c43024f4527 100644 --- a/drivers/input/misc/rb532_button.c +++ b/drivers/input/misc/rb532_button.c @@ -58,7 +58,7 @@ static int rb532_button_probe(struct platform_device *pdev) struct input_polled_dev *poll_dev; int error; - poll_dev = input_allocate_polled_device(); + poll_dev = devm_input_allocate_polled_device(&pdev->dev); if (!poll_dev) return -ENOMEM; @@ -68,34 +68,18 @@ static int rb532_button_probe(struct platform_device *pdev) poll_dev->input->name = "rb532 button"; poll_dev->input->phys = "rb532/button0"; poll_dev->input->id.bustype = BUS_HOST; - poll_dev->input->dev.parent = &pdev->dev; - - dev_set_drvdata(&pdev->dev, poll_dev); input_set_capability(poll_dev->input, EV_KEY, RB532_BTN_KSYM); error = input_register_polled_device(poll_dev); - if (error) { - input_free_polled_device(poll_dev); + if (error) return error; - } - - return 0; -} - -static int rb532_button_remove(struct platform_device *pdev) -{ - struct input_polled_dev *poll_dev = dev_get_drvdata(&pdev->dev); - - input_unregister_polled_device(poll_dev); - input_free_polled_device(poll_dev); return 0; } static struct platform_driver rb532_button_driver = { .probe = rb532_button_probe, - .remove = rb532_button_remove, .driver = { .name = DRV_NAME, }, From patchwork Thu Oct 17 20:42:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D1B214ED for ; Thu, 17 Oct 2019 20:43:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A38D21D7D for ; Thu, 17 Oct 2019 20:43:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k+WXYrgl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502733AbfJQUmq (ORCPT ); Thu, 17 Oct 2019 16:42:46 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35439 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502634AbfJQUmp (ORCPT ); Thu, 17 Oct 2019 16:42:45 -0400 Received: by mail-pl1-f195.google.com with SMTP id c3so1709895plo.2; Thu, 17 Oct 2019 13:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H6A+MfE+mY9j5A0d4q4ouMrSZpQoTdVP4FH8jGsUc3A=; b=k+WXYrglf1NX0PyOCClEtSAiyMd1d7VM1QfO5Sz85fU55TkwlyrfQb94f/wcfBlHIp jtrR25t1UA8j8jT1RrlKH85PCFh0i19Z3DCvfiZcpnMXOIYvq6ZpUG33JRtJm0VVEQiS w/hBJwuhMuxg14pZAdEjZobPIiSBkhxsPFFQkb3gvR56z47E9fp3zCl/fR6i/mCGQnOM Lz7DEpsLbzlI9StZFSQxQj4ERwMGQZ6n470f6zGxBZM0KVFvAz9D59/SlTiym9ImweAY J7Px9i9GMYxtMUvgtrPW9P4+xVrwFvrwkPBZB4fg8FS4VZOLRbpXbtWVuPa7nv+vgA+f lwwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H6A+MfE+mY9j5A0d4q4ouMrSZpQoTdVP4FH8jGsUc3A=; b=n3GUk5WW6v691CbHgoG4DOrlnKx7Co8wRAZbNcOz0iy18LmL/MU5rXOXQpsE8Q3vO6 mEoitlqbck1o8XhsUIQ1xqTZ68dDZQx6JV8oQ+RI01eVPlNincnbT13Vrsz31YilQN8r Vs3d6OQZ7vIl0zKFx5hXhyVRHReBeQfEXdVh1iazO1V3a0+lSFjJZOPROvloZF2EQcm8 1j6JviDesRlLLO2ks6g0EuQsfKmcCUpUXccMfN7w0gGi5iKtmyGS/57Zh1+jEpM1c6HE 2iyoPxG47wv+VYihlQmp2Fk6VqYtZvR6Bh4yYcqbgtmQNLtmzrQ3HRBbSX3hxDZ0y6Qp m6aQ== X-Gm-Message-State: APjAAAWF2p/2J7tnXDQrN/l/f22u7gOf0i9QVSGxR4XSTeC0COBPDfpo uTzE316mI6+Kv45gE8Ort0fPj0ll X-Google-Smtp-Source: APXvYqz4i9wKh+YGYMbY0xagOCVnLgkjnbA9wVaJThtTGwv52eBWzmKDT82iWZQZOG9wBygSM0aiuQ== X-Received: by 2002:a17:902:a70f:: with SMTP id w15mr6044474plq.146.1571344963132; Thu, 17 Oct 2019 13:42:43 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:41 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Bartosz Golaszewski , Brian Masney , Luca Weiss , Maximilian Luz , linux-kernel@vger.kernel.org Subject: [PATCH 16/22] Input: rb532_button - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:10 -0700 Message-Id: <20191017204217.106453-17-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts rb532_button driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/rb532_button.c | 32 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index c27a9ee4ef9a..102e993bbd6b 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -633,7 +633,6 @@ config INPUT_RB532_BUTTON tristate "Mikrotik Routerboard 532 button interface" depends on MIKROTIK_RB532 depends on GPIOLIB - select INPUT_POLLDEV help Say Y here if you want support for the S1 button built into Mikrotik's Routerboard 532. diff --git a/drivers/input/misc/rb532_button.c b/drivers/input/misc/rb532_button.c index 3c43024f4527..190a80e1e2c1 100644 --- a/drivers/input/misc/rb532_button.c +++ b/drivers/input/misc/rb532_button.c @@ -5,7 +5,7 @@ * Copyright (C) 2009 Phil Sutter */ -#include +#include #include #include #include @@ -46,32 +46,34 @@ static bool rb532_button_pressed(void) return !val; } -static void rb532_button_poll(struct input_polled_dev *poll_dev) +static void rb532_button_poll(struct input_dev *input) { - input_report_key(poll_dev->input, RB532_BTN_KSYM, - rb532_button_pressed()); - input_sync(poll_dev->input); + input_report_key(input, RB532_BTN_KSYM, rb532_button_pressed()); + input_sync(input); } static int rb532_button_probe(struct platform_device *pdev) { - struct input_polled_dev *poll_dev; + struct input_dev *input; int error; - poll_dev = devm_input_allocate_polled_device(&pdev->dev); - if (!poll_dev) + input = devm_input_allocate_device(&pdev->dev); + if (!input) return -ENOMEM; - poll_dev->poll = rb532_button_poll; - poll_dev->poll_interval = RB532_BTN_RATE; + input->name = "rb532 button"; + input->phys = "rb532/button0"; + input->id.bustype = BUS_HOST; - poll_dev->input->name = "rb532 button"; - poll_dev->input->phys = "rb532/button0"; - poll_dev->input->id.bustype = BUS_HOST; + input_set_capability(input, EV_KEY, RB532_BTN_KSYM); - input_set_capability(poll_dev->input, EV_KEY, RB532_BTN_KSYM); + error = input_setup_polling(input, rb532_button_poll); + if (error) + return error; + + input_set_poll_interval(input, RB532_BTN_RATE); - error = input_register_polled_device(poll_dev); + error = input_register_device(input); if (error) return error; From patchwork Thu Oct 17 20:42:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A893314ED for ; Thu, 17 Oct 2019 20:43:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CF8F2089C for ; Thu, 17 Oct 2019 20:43:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pqLcROSw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389347AbfJQUnk (ORCPT ); Thu, 17 Oct 2019 16:43:40 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36790 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502683AbfJQUmq (ORCPT ); Thu, 17 Oct 2019 16:42:46 -0400 Received: by mail-pl1-f194.google.com with SMTP id j11so1706668plk.3; Thu, 17 Oct 2019 13:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p4qYPdv7CFoLETcuSBMJehUgVm9YqKP05FJFL0znofs=; b=pqLcROSwueULk1UQmRmI4xu4kebA1YY8lp01P56aYflnoLGFbt/RUOlJg0NtCglNHz B75T3HnKlxcyQ5zE7r+Lz033eUuBLMQtbZIDphmg1DnoABAtN9e79YvmlQZnpnMaFYsu bKnVvwKt+Q8iOMsYyTp7jLhgXyNF2lN2MDEm3dD8Mguy1poH/MtiUfdrmGJae1RJP19j sTVwAgOUh5qqj3Ez9uus6ySN/fWX/QTx0IWCbINHoh4qmbwgAQYWJKKYrNMNhAKq5dvI Qp4tGUEfg09sRRcSlTBR4P5aKBAX+CwyBslS8A+uzXlOxTqhlzolAcs6f1gkXplO3OfN ChUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p4qYPdv7CFoLETcuSBMJehUgVm9YqKP05FJFL0znofs=; b=ZD25+nceFGP9z3e5/Sp527/dYzE4uG3Vkh+aJCQD947Jk6bwMz+hZZbgtKXgZJ4hWM j73Abhe2iu+mztm+R3K49tpzFcmIGRFSpvO14CLmgatez80tTjjpXhn90kfRsJ2jkDvw w/cyVCRXbQqLqc8n/Nl6g6UigyJECX3R5FNGFmz6Rrz7PwISaJaxVSw8rL0YzuIZmMr2 WKwueKlKfWFUcy5fogXSypNLASq1CA94Ru8fKKS/nfv/UO2ZN8TKIVF044BILw2UCVlt 4HvRXV9oasoQN4AVh2H/Pm2bHE/6ldDjUb5HcEcdE9RqpZA15agmNYKJ1+iNfrvaNbCm r6wg== X-Gm-Message-State: APjAAAUR/lRalu26yj+SOXgsWSJkVb974dXS+vGcIxmkM7MCVlDEzCdP yf2lpPMfAT9xV1RVs7ganFgBQ092 X-Google-Smtp-Source: APXvYqwDjpGzYiq0sp+iFvgp16XRF6y797HH5834RO2CuHI/TouX8uBOInGBHnJgNbUuMg8eFuOx+w== X-Received: by 2002:a17:902:44d:: with SMTP id 71mr970453ple.320.1571344964914; Thu, 17 Oct 2019 13:42:44 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:43 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Bartosz Golaszewski , Brian Masney , Luca Weiss , Maximilian Luz , linux-kernel@vger.kernel.org Subject: [PATCH 17/22] Input: gpio_decoder - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:11 -0700 Message-Id: <20191017204217.106453-18-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts gpio_decoder driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/gpio_decoder.c | 42 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 102e993bbd6b..b108c992bb7a 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -290,7 +290,6 @@ config INPUT_GPIO_BEEPER config INPUT_GPIO_DECODER tristate "Polled GPIO Decoder Input driver" depends on GPIOLIB || COMPILE_TEST - select INPUT_POLLDEV help Say Y here if you want driver to read status of multiple GPIO lines and report the encoded value as an absolute integer to diff --git a/drivers/input/misc/gpio_decoder.c b/drivers/input/misc/gpio_decoder.c index 1dca526e6f1a..145826a1a9a1 100644 --- a/drivers/input/misc/gpio_decoder.c +++ b/drivers/input/misc/gpio_decoder.c @@ -17,14 +17,12 @@ #include #include #include -#include #include #include #include #include struct gpio_decoder { - struct input_polled_dev *poll_dev; struct gpio_descs *input_gpios; struct device *dev; u32 axis; @@ -53,15 +51,15 @@ static int gpio_decoder_get_gpios_state(struct gpio_decoder *decoder) return ret; } -static void gpio_decoder_poll_gpios(struct input_polled_dev *poll_dev) +static void gpio_decoder_poll_gpios(struct input_dev *input) { - struct gpio_decoder *decoder = poll_dev->private; + struct gpio_decoder *decoder = input_get_drvdata(input); int state; state = gpio_decoder_get_gpios_state(decoder); if (state >= 0 && state != decoder->last_stable) { - input_report_abs(poll_dev->input, decoder->axis, state); - input_sync(poll_dev->input); + input_report_abs(input, decoder->axis, state); + input_sync(input); decoder->last_stable = state; } } @@ -70,20 +68,23 @@ static int gpio_decoder_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct gpio_decoder *decoder; - struct input_polled_dev *poll_dev; + struct input_dev *input; u32 max; int err; - decoder = devm_kzalloc(dev, sizeof(struct gpio_decoder), GFP_KERNEL); + decoder = devm_kzalloc(dev, sizeof(*decoder), GFP_KERNEL); if (!decoder) return -ENOMEM; + decoder->dev = dev; device_property_read_u32(dev, "linux,axis", &decoder->axis); + decoder->input_gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN); if (IS_ERR(decoder->input_gpios)) { dev_err(dev, "unable to acquire input gpios\n"); return PTR_ERR(decoder->input_gpios); } + if (decoder->input_gpios->ndescs < 2) { dev_err(dev, "not enough gpios found\n"); return -EINVAL; @@ -92,22 +93,25 @@ static int gpio_decoder_probe(struct platform_device *pdev) if (device_property_read_u32(dev, "decoder-max-value", &max)) max = (1U << decoder->input_gpios->ndescs) - 1; - decoder->dev = dev; - poll_dev = devm_input_allocate_polled_device(decoder->dev); - if (!poll_dev) + input = devm_input_allocate_device(dev); + if (!input) return -ENOMEM; - poll_dev->private = decoder; - poll_dev->poll = gpio_decoder_poll_gpios; - decoder->poll_dev = poll_dev; + input_set_drvdata(input, decoder); - poll_dev->input->name = pdev->name; - poll_dev->input->id.bustype = BUS_HOST; - input_set_abs_params(poll_dev->input, decoder->axis, 0, max, 0, 0); + input->name = pdev->name; + input->id.bustype = BUS_HOST; + input_set_abs_params(input, decoder->axis, 0, max, 0, 0); + + err = input_setup_polling(input, gpio_decoder_poll_gpios); + if (err) { + dev_err(dev, "failed to set up polling\n"); + return err; + } - err = input_register_polled_device(poll_dev); + err = input_register_device(input); if (err) { - dev_err(dev, "failed to register polled device\n"); + dev_err(dev, "failed to register input device\n"); return err; } From patchwork Thu Oct 17 20:42:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67C49112B for ; Thu, 17 Oct 2019 20:43:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CDBE21D7D for ; Thu, 17 Oct 2019 20:43:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hY7q6Tdy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502911AbfJQUms (ORCPT ); Thu, 17 Oct 2019 16:42:48 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44135 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502847AbfJQUmr (ORCPT ); Thu, 17 Oct 2019 16:42:47 -0400 Received: by mail-pf1-f195.google.com with SMTP id q21so2360330pfn.11; Thu, 17 Oct 2019 13:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GEKRNk3+QkHLGS5SoKpdCHIgbctxhbvYiOrQ84TzMNs=; b=hY7q6TdyrEkXN/Xfmg7eHuNh6G2X8Ih8dc8Auh5ky5Ji0SRfN5zs/D50sXgocYLecb 7x3pDa/f2OFRqW1IflBmLaR1XG0f+C6Be3bvN6pPTxRd0aABI0an7pah2Afpf2N4T1AC WJUqw+dtx9bjP/IJDEMCXyguBN96emVQ7scdzhbW/tFGUdWapD+m7D23SEdguPSTOAKs THjmEiYuhO6xGYXLqyRFXaGYGmtYLK4bQOMamXnwGj8de3pq7xk3wJh7x4mjerXkxdl3 mlcX7tCeQuGipMayOTJMnl9crGbCg996IknwnutfG/JKnx5YLHoa7I0keeZB9AgGM2Eo BJ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GEKRNk3+QkHLGS5SoKpdCHIgbctxhbvYiOrQ84TzMNs=; b=S1y2ZjGuXAZb3GeH+3kZ1QCR7b1ir42HwunI3lU5SvtNPQlpoxSfboke6ZC0uUlyDC Qs2iHBaRCyxMgdf7VlUjUKYaucwkeqQeq7Vk2gt+ISL+Guwpq5u95KgudjSd752h/o/w R8DO3vrEc1hq+cZ+ERGWHhyL8Nl2dlND3fbSrBM78Ll9pZ2fVYBmxpMuQlEdC88Sl5K8 mDMhYXascgkttypC1FW6E2FDNwYsOr6RzO/axWyrMp3LTuAx0ie7+W7bx5LGRHhXs3bc 1ARGbmWC2wYqvWw9Tge4T3APn4DQXbY1dSASFEPC3UH0wL+wo1YMugXMsVCl0sruGIJV yMjA== X-Gm-Message-State: APjAAAX50o5ad0ZFTYHqcq4fWa2ZmxsAK2tNl+LtegXeRX3fSUFXVa0X 4zFvCiq5tSqeMBqd2x9hHoEpBz60 X-Google-Smtp-Source: APXvYqzg9ZKoArye3kOHPW48Es/ba5aPjwjIw9jZ6abbc53culSCzhD4LvQi5DqApogShAzfCU7kEw== X-Received: by 2002:a17:90a:2522:: with SMTP id j31mr6575663pje.123.1571344966474; Thu, 17 Oct 2019 13:42:46 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:45 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Allison Randal , Bartosz Golaszewski , Brian Masney , Luca Weiss , Maximilian Luz , Richard Fontana , linux-kernel@vger.kernel.org Subject: [PATCH 18/22] Input: mma8450 - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:12 -0700 Message-Id: <20191017204217.106453-19-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts mma8450 driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/mma8450.c | 101 ++++++++++++++++------------------- 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index b108c992bb7a..e1309cb190e1 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -246,7 +246,6 @@ config INPUT_MC13783_PWRBUTTON config INPUT_MMA8450 tristate "MMA8450 - Freescale's 3-Axis, 8/12-bit Digital Accelerometer" depends on I2C - select INPUT_POLLDEV help Say Y here if you want to support Freescale's MMA8450 Accelerometer through I2C interface. diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c index 49f5242bc54c..1b5a5e19230a 100644 --- a/drivers/input/misc/mma8450.c +++ b/drivers/input/misc/mma8450.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #define MMA8450_DRV_NAME "mma8450" @@ -39,15 +39,8 @@ #define MMA8450_CTRL_REG1 0x38 #define MMA8450_CTRL_REG2 0x39 -/* mma8450 status */ -struct mma8450 { - struct i2c_client *client; - struct input_polled_dev *idev; -}; - -static int mma8450_read(struct mma8450 *m, unsigned off) +static int mma8450_read(struct i2c_client *c, unsigned int off) { - struct i2c_client *c = m->client; int ret; ret = i2c_smbus_read_byte_data(c, off); @@ -59,9 +52,8 @@ static int mma8450_read(struct mma8450 *m, unsigned off) return ret; } -static int mma8450_write(struct mma8450 *m, unsigned off, u8 v) +static int mma8450_write(struct i2c_client *c, unsigned int off, u8 v) { - struct i2c_client *c = m->client; int error; error = i2c_smbus_write_byte_data(c, off, v); @@ -75,10 +67,9 @@ static int mma8450_write(struct mma8450 *m, unsigned off, u8 v) return 0; } -static int mma8450_read_block(struct mma8450 *m, unsigned off, +static int mma8450_read_block(struct i2c_client *c, unsigned int off, u8 *buf, size_t size) { - struct i2c_client *c = m->client; int err; err = i2c_smbus_read_i2c_block_data(c, off, size, buf); @@ -92,21 +83,21 @@ static int mma8450_read_block(struct mma8450 *m, unsigned off, return 0; } -static void mma8450_poll(struct input_polled_dev *dev) +static void mma8450_poll(struct input_dev *input) { - struct mma8450 *m = dev->private; + struct i2c_client *c = input_get_drvdata(input); int x, y, z; int ret; u8 buf[6]; - ret = mma8450_read(m, MMA8450_STATUS); + ret = mma8450_read(c, MMA8450_STATUS); if (ret < 0) return; if (!(ret & MMA8450_STATUS_ZXYDR)) return; - ret = mma8450_read_block(m, MMA8450_OUT_X_LSB, buf, sizeof(buf)); + ret = mma8450_read_block(c, MMA8450_OUT_X_LSB, buf, sizeof(buf)); if (ret < 0) return; @@ -114,41 +105,42 @@ static void mma8450_poll(struct input_polled_dev *dev) y = ((int)(s8)buf[3] << 4) | (buf[2] & 0xf); z = ((int)(s8)buf[5] << 4) | (buf[4] & 0xf); - input_report_abs(dev->input, ABS_X, x); - input_report_abs(dev->input, ABS_Y, y); - input_report_abs(dev->input, ABS_Z, z); - input_sync(dev->input); + input_report_abs(input, ABS_X, x); + input_report_abs(input, ABS_Y, y); + input_report_abs(input, ABS_Z, z); + input_sync(input); } /* Initialize the MMA8450 chip */ -static void mma8450_open(struct input_polled_dev *dev) +static int mma8450_open(struct input_dev *input) { - struct mma8450 *m = dev->private; + struct i2c_client *c = input_get_drvdata(input); int err; /* enable all events from X/Y/Z, no FIFO */ - err = mma8450_write(m, MMA8450_XYZ_DATA_CFG, 0x07); + err = mma8450_write(c, MMA8450_XYZ_DATA_CFG, 0x07); if (err) - return; + return err; /* * Sleep mode poll rate - 50Hz * System output data rate - 400Hz * Full scale selection - Active, +/- 2G */ - err = mma8450_write(m, MMA8450_CTRL_REG1, 0x01); - if (err < 0) - return; + err = mma8450_write(c, MMA8450_CTRL_REG1, 0x01); + if (err) + return err; msleep(MODE_CHANGE_DELAY_MS); + return 0; } -static void mma8450_close(struct input_polled_dev *dev) +static void mma8450_close(struct input_dev *input) { - struct mma8450 *m = dev->private; + struct i2c_client *c = input_get_drvdata(input); - mma8450_write(m, MMA8450_CTRL_REG1, 0x00); - mma8450_write(m, MMA8450_CTRL_REG2, 0x01); + mma8450_write(c, MMA8450_CTRL_REG1, 0x00); + mma8450_write(c, MMA8450_CTRL_REG2, 0x01); } /* @@ -157,38 +149,37 @@ static void mma8450_close(struct input_polled_dev *dev) static int mma8450_probe(struct i2c_client *c, const struct i2c_device_id *id) { - struct input_polled_dev *idev; - struct mma8450 *m; + struct input_dev *input; int err; - m = devm_kzalloc(&c->dev, sizeof(*m), GFP_KERNEL); - if (!m) + input = devm_input_allocate_device(&c->dev); + if (!input) return -ENOMEM; - idev = devm_input_allocate_polled_device(&c->dev); - if (!idev) - return -ENOMEM; + input_set_drvdata(input, c); + + input->name = MMA8450_DRV_NAME; + input->id.bustype = BUS_I2C; + + input->open = mma8450_open; + input->close = mma8450_close; - m->client = c; - m->idev = idev; + input_set_abs_params(input, ABS_X, -2048, 2047, 32, 32); + input_set_abs_params(input, ABS_Y, -2048, 2047, 32, 32); + input_set_abs_params(input, ABS_Z, -2048, 2047, 32, 32); - idev->private = m; - idev->input->name = MMA8450_DRV_NAME; - idev->input->id.bustype = BUS_I2C; - idev->poll = mma8450_poll; - idev->poll_interval = POLL_INTERVAL; - idev->poll_interval_max = POLL_INTERVAL_MAX; - idev->open = mma8450_open; - idev->close = mma8450_close; + err = input_setup_polling(input, mma8450_poll); + if (err) { + dev_err(&c->dev, "failed to set up polling\n"); + return err; + } - __set_bit(EV_ABS, idev->input->evbit); - input_set_abs_params(idev->input, ABS_X, -2048, 2047, 32, 32); - input_set_abs_params(idev->input, ABS_Y, -2048, 2047, 32, 32); - input_set_abs_params(idev->input, ABS_Z, -2048, 2047, 32, 32); + input_set_poll_interval(input, POLL_INTERVAL); + input_set_max_poll_interval(input, POLL_INTERVAL_MAX); - err = input_register_polled_device(idev); + err = input_register_device(input); if (err) { - dev_err(&c->dev, "failed to register polled input device\n"); + dev_err(&c->dev, "failed to register input device\n"); return err; } From patchwork Thu Oct 17 20:42:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197127 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6612714ED for ; Thu, 17 Oct 2019 20:42:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3AEC9222C7 for ; Thu, 17 Oct 2019 20:42:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b8aIqbUI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502962AbfJQUmt (ORCPT ); Thu, 17 Oct 2019 16:42:49 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37940 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502902AbfJQUms (ORCPT ); Thu, 17 Oct 2019 16:42:48 -0400 Received: by mail-pl1-f195.google.com with SMTP id w8so1702233plq.5; Thu, 17 Oct 2019 13:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5BIGpmeokH2sY4/0NRYi8Dgb6NHFzLHS/Fu+tgAQ27o=; b=b8aIqbUI+I12/63O85JG9GaYo6uedNwIl8VfTpEuBFBxE/m4bCa4XEiHS5/ooQrJja 2RrVlk0otj/5twmTfarVPgwBpU07spppv4SgF8/gg/lsFoYNn4HjfcXjtIMSXBB+jx3W ruD92QMS6MF6R/kcmTjB4seN+rXiEltoLWqqLjK376eOJ3Xa2epzyYCDmvXPkepsLvxX snP6s73ez0/84xfqnslmWgMAD8oyJq3df3tAIrD8uHCRzdZeVpiM80Hfmlo1+780rrSd TUeh2SLnx/MAhkqDIR1EPKMlaX5N7tEXcqS1U9HVWln9JYcxRdDzkrZfgCFpkVKNyGmN 6s+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5BIGpmeokH2sY4/0NRYi8Dgb6NHFzLHS/Fu+tgAQ27o=; b=BsA4qq60pZb+PHJQZMPawJ0Im32zyhuuhOIHLb9AIzipxmZjlWiQjntC6FVlSe/OxA Ah6FG1UeWavchSKCWONby15cZTZt0iLstJIFmJE7hp8ghSmod0UdOHiYVJF2g/MVfi3y 2omP/BWNjWHu/b92suA3NS5ScIt5f7GyZTlJyYrLCpCTzIuE2Fsn4uPzX0ob3jN2BDAp 8oAnAcy1TTQT9wv219UWaO8sy9wEj9QPeoYPmiAhg8SlUi8FBSxm7YxwSpqh45USWhiS XIOLF+0rOr4sNRzbk8XQmuFWs/HC0Im/bqbU4neXELPDm93lpOHGnkQwUb4t+tHtXNKj m+Tg== X-Gm-Message-State: APjAAAUxLO04oJCKw5oewjOl5HuP+W9QeV5YGOsF8Jjy9BPz85bR5/YD CHiIIGWnuxcgfhUf4IpAqUW6fSBz X-Google-Smtp-Source: APXvYqzMrPPmPFf8xEra5/XAodpUzGqyd3bDtsf2KLXUA3HeM6peOxzXezE2E84VvGvFodf2W6YLoA== X-Received: by 2002:a17:902:bb92:: with SMTP id m18mr5740841pls.297.1571344967359; Thu, 17 Oct 2019 13:42:47 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:46 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Jonathan Bakker , =?utf-8?q?Pawe=C5=82_Chmiel?= , Allison Randal , linux-kernel@vger.kernel.org Subject: [PATCH 19/22] Input: bma150 - use managed resources helpers Date: Thu, 17 Oct 2019 13:42:13 -0700 Message-Id: <20191017204217.106453-20-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Jonathan Bakker The driver can be cleaned up by using managed resource helpers. Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel Patchwork-Id: 10794333 [dtor: do not explicitly set parent of input device since we are using devm] Signed-off-by: Dmitry Torokhov --- drivers/input/misc/bma150.c | 51 ++++++++++--------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c index 735d3a46f44b..d65b008a3c7a 100644 --- a/drivers/input/misc/bma150.c +++ b/drivers/input/misc/bma150.c @@ -439,13 +439,11 @@ static int bma150_initialize(struct bma150_data *bma150, return bma150_set_mode(bma150, BMA150_MODE_SLEEP); } -static void bma150_init_input_device(struct bma150_data *bma150, - struct input_dev *idev) +static void bma150_init_input_device(struct input_dev *idev) { idev->name = BMA150_DRIVER; idev->phys = BMA150_DRIVER "/input0"; idev->id.bustype = BUS_I2C; - idev->dev.parent = &bma150->client->dev; idev->evbit[0] = BIT_MASK(EV_ABS); input_set_abs_params(idev, ABS_X, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0); @@ -458,11 +456,11 @@ static int bma150_register_input_device(struct bma150_data *bma150) struct input_dev *idev; int error; - idev = input_allocate_device(); + idev = devm_input_allocate_device(&bma150->client->dev); if (!idev) return -ENOMEM; - bma150_init_input_device(bma150, idev); + bma150_init_input_device(idev); idev->open = bma150_irq_open; idev->close = bma150_irq_close; @@ -471,10 +469,8 @@ static int bma150_register_input_device(struct bma150_data *bma150) bma150->input = idev; error = input_register_device(idev); - if (error) { - input_free_device(idev); + if (error) return error; - } return 0; } @@ -484,7 +480,7 @@ static int bma150_register_polled_device(struct bma150_data *bma150) struct input_polled_dev *ipoll_dev; int error; - ipoll_dev = input_allocate_polled_device(); + ipoll_dev = devm_input_allocate_polled_device(&bma150->client->dev); if (!ipoll_dev) return -ENOMEM; @@ -496,16 +492,14 @@ static int bma150_register_polled_device(struct bma150_data *bma150) ipoll_dev->poll_interval_min = BMA150_POLL_MIN; ipoll_dev->poll_interval_max = BMA150_POLL_MAX; - bma150_init_input_device(bma150, ipoll_dev->input); + bma150_init_input_device(ipoll_dev->input); bma150->input_polled = ipoll_dev; bma150->input = ipoll_dev->input; error = input_register_polled_device(ipoll_dev); - if (error) { - input_free_polled_device(ipoll_dev); + if (error) return error; - } return 0; } @@ -531,7 +525,7 @@ static int bma150_probe(struct i2c_client *client, return -EINVAL; } - bma150 = kzalloc(sizeof(struct bma150_data), GFP_KERNEL); + bma150 = devm_kzalloc(&client->dev, sizeof(*bma150), GFP_KERNEL); if (!bma150) return -ENOMEM; @@ -544,7 +538,7 @@ static int bma150_probe(struct i2c_client *client, dev_err(&client->dev, "IRQ GPIO conf. error %d, error %d\n", client->irq, error); - goto err_free_mem; + return error; } } cfg = &pdata->cfg; @@ -554,14 +548,14 @@ static int bma150_probe(struct i2c_client *client, error = bma150_initialize(bma150, cfg); if (error) - goto err_free_mem; + return error; if (client->irq > 0) { error = bma150_register_input_device(bma150); if (error) - goto err_free_mem; + return error; - error = request_threaded_irq(client->irq, + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, bma150_irq_thread, IRQF_TRIGGER_RISING | IRQF_ONESHOT, BMA150_DRIVER, bma150); @@ -569,13 +563,12 @@ static int bma150_probe(struct i2c_client *client, dev_err(&client->dev, "irq request failed %d, error %d\n", client->irq, error); - input_unregister_device(bma150->input); - goto err_free_mem; + return error; } } else { error = bma150_register_polled_device(bma150); if (error) - goto err_free_mem; + return error; } i2c_set_clientdata(client, bma150); @@ -583,28 +576,12 @@ static int bma150_probe(struct i2c_client *client, pm_runtime_enable(&client->dev); return 0; - -err_free_mem: - kfree(bma150); - return error; } static int bma150_remove(struct i2c_client *client) { - struct bma150_data *bma150 = i2c_get_clientdata(client); - pm_runtime_disable(&client->dev); - if (client->irq > 0) { - free_irq(client->irq, bma150); - input_unregister_device(bma150->input); - } else { - input_unregister_polled_device(bma150->input_polled); - input_free_polled_device(bma150->input_polled); - } - - kfree(bma150); - return 0; } From patchwork Thu Oct 17 20:42:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C28CD112B for ; Thu, 17 Oct 2019 20:42:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97AF721A49 for ; Thu, 17 Oct 2019 20:42:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z/tCFqJZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503026AbfJQUmv (ORCPT ); Thu, 17 Oct 2019 16:42:51 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45152 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502953AbfJQUmt (ORCPT ); Thu, 17 Oct 2019 16:42:49 -0400 Received: by mail-pf1-f196.google.com with SMTP id y72so2361447pfb.12; Thu, 17 Oct 2019 13:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vAKokueiClfgZWoQCwU8Jqzeem8xmhIKqG8ZDiQeajw=; b=Z/tCFqJZa3I/4A0KsK3WCQ/C81WwubeVJRmnywGwef2pwV/hdLrBaJgsq9kU2uIeLJ bnG0t3ls8hgwX0VXXMzH1hkYJngOLZMn20F28VSnQ2r0URsV6b+MTZ3newLpB5Kb+14U CT/CSxJJM9Wp9RpD1AWZ8Z5CmKDcXpxBOuHsKd33slbKH67tQHu2927Kk4iRhrp2cQGQ XmDijMACki6S8Wp0GjlcubP4awb7fqB53748fOWmEcRJ3D2Tqvlmzaw2CE81nt3fUq9p LljZ0f/ot3LJLvrpG4mw3d51ST0KHo8vz7xifta9geDsvH/sOkwTR9Vz8ESHqIodjo3G ScUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vAKokueiClfgZWoQCwU8Jqzeem8xmhIKqG8ZDiQeajw=; b=p56lAOBrNU//aXSSD9DhzoedRoLulIQYaJJuFLkrddcE2c7wY7EIq2tbiMqyriqkYu ebcCJz19/geEpfWlSfUinxaKpTl/suV6JfD6CRyNr2XN1FQs2GbMehE6O5Rxgjp9ILMO QJRXUkM7uXmPc6NXLGj7Dpv98UVKVFUFW7ykgHS8ebCKggF5Gw89oIsMbeExLF7VS3qI QI0QjUPjqdTRRmHUS4YwmddqgERHDJSViSBGhjBN5m6zPeuhcSTZFVhxUjhoAr/I2WMt TB+98xRZzUwnIAdos4MDk9iF4SbUkLKi3fTxQ5INEtXfZ5Scrf38lksgn2xA+L3n4M9u b8hw== X-Gm-Message-State: APjAAAUQYrCgEYAPUlhzVZBHXN2woGvsWa/DDry8uwsm2Ov1GiCj64R1 23F6A3DSB6ohnspFVxh3S+P9eksv X-Google-Smtp-Source: APXvYqzH9x3QO97QM5v5WDXftzGu4GhSKU97aN9yWLR1958al8HyrCnk+VADoa/38Jwj5CAFQLKWGw== X-Received: by 2002:a17:90a:e001:: with SMTP id u1mr6682395pjy.102.1571344968381; Thu, 17 Oct 2019 13:42:48 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:47 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Bartosz Golaszewski , Brian Masney , Jonathan Bakker , Luca Weiss , Maximilian Luz , =?utf-8?q?Pawe=C5=82_Chmiel?= , Richard Fontana , linux-kernel@vger.kernel.org Subject: [PATCH 20/22] Input: bma150 - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:14 -0700 Message-Id: <20191017204217.106453-21-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts bma150 driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 1 - drivers/input/misc/bma150.c | 155 ++++++++++-------------------------- 2 files changed, 44 insertions(+), 112 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index e1309cb190e1..438ec07e3b62 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -100,7 +100,6 @@ config INPUT_ATMEL_CAPTOUCH config INPUT_BMA150 tristate "BMA150/SMB380 acceleration sensor support" depends on I2C - select INPUT_POLLDEV help Say Y here if you have Bosch Sensortec's BMA150 or SMB380 acceleration sensor hooked to an I2C bus. diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c index d65b008a3c7a..a9d984da95f3 100644 --- a/drivers/input/misc/bma150.c +++ b/drivers/input/misc/bma150.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -123,7 +122,6 @@ struct bma150_data { struct i2c_client *client; - struct input_polled_dev *input_polled; struct input_dev *input; u8 mode; }; @@ -336,13 +334,16 @@ static irqreturn_t bma150_irq_thread(int irq, void *dev) return IRQ_HANDLED; } -static void bma150_poll(struct input_polled_dev *dev) +static void bma150_poll(struct input_dev *input) { - bma150_report_xyz(dev->private); + struct bma150_data *bma150 = input_get_drvdata(input); + + bma150_report_xyz(bma150); } -static int bma150_open(struct bma150_data *bma150) +static int bma150_open(struct input_dev *input) { + struct bma150_data *bma150 = input_get_drvdata(input); int error; error = pm_runtime_get_sync(&bma150->client->dev); @@ -362,44 +363,18 @@ static int bma150_open(struct bma150_data *bma150) return 0; } -static void bma150_close(struct bma150_data *bma150) +static void bma150_close(struct input_dev *input) { + struct bma150_data *bma150 = input_get_drvdata(input); + pm_runtime_put_sync(&bma150->client->dev); if (bma150->mode != BMA150_MODE_SLEEP) bma150_set_mode(bma150, BMA150_MODE_SLEEP); } -static int bma150_irq_open(struct input_dev *input) -{ - struct bma150_data *bma150 = input_get_drvdata(input); - - return bma150_open(bma150); -} - -static void bma150_irq_close(struct input_dev *input) -{ - struct bma150_data *bma150 = input_get_drvdata(input); - - bma150_close(bma150); -} - -static void bma150_poll_open(struct input_polled_dev *ipoll_dev) -{ - struct bma150_data *bma150 = ipoll_dev->private; - - bma150_open(bma150); -} - -static void bma150_poll_close(struct input_polled_dev *ipoll_dev) -{ - struct bma150_data *bma150 = ipoll_dev->private; - - bma150_close(bma150); -} - static int bma150_initialize(struct bma150_data *bma150, - const struct bma150_cfg *cfg) + const struct bma150_cfg *cfg) { int error; @@ -439,78 +414,14 @@ static int bma150_initialize(struct bma150_data *bma150, return bma150_set_mode(bma150, BMA150_MODE_SLEEP); } -static void bma150_init_input_device(struct input_dev *idev) -{ - idev->name = BMA150_DRIVER; - idev->phys = BMA150_DRIVER "/input0"; - idev->id.bustype = BUS_I2C; - - idev->evbit[0] = BIT_MASK(EV_ABS); - input_set_abs_params(idev, ABS_X, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0); - input_set_abs_params(idev, ABS_Y, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0); - input_set_abs_params(idev, ABS_Z, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0); -} - -static int bma150_register_input_device(struct bma150_data *bma150) -{ - struct input_dev *idev; - int error; - - idev = devm_input_allocate_device(&bma150->client->dev); - if (!idev) - return -ENOMEM; - - bma150_init_input_device(idev); - - idev->open = bma150_irq_open; - idev->close = bma150_irq_close; - input_set_drvdata(idev, bma150); - - bma150->input = idev; - - error = input_register_device(idev); - if (error) - return error; - - return 0; -} - -static int bma150_register_polled_device(struct bma150_data *bma150) -{ - struct input_polled_dev *ipoll_dev; - int error; - - ipoll_dev = devm_input_allocate_polled_device(&bma150->client->dev); - if (!ipoll_dev) - return -ENOMEM; - - ipoll_dev->private = bma150; - ipoll_dev->open = bma150_poll_open; - ipoll_dev->close = bma150_poll_close; - ipoll_dev->poll = bma150_poll; - ipoll_dev->poll_interval = BMA150_POLL_INTERVAL; - ipoll_dev->poll_interval_min = BMA150_POLL_MIN; - ipoll_dev->poll_interval_max = BMA150_POLL_MAX; - - bma150_init_input_device(ipoll_dev->input); - - bma150->input_polled = ipoll_dev; - bma150->input = ipoll_dev->input; - - error = input_register_polled_device(ipoll_dev); - if (error) - return error; - - return 0; -} - static int bma150_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { const struct bma150_platform_data *pdata = dev_get_platdata(&client->dev); const struct bma150_cfg *cfg; struct bma150_data *bma150; + struct input_dev *idev; int chip_id; int error; @@ -550,11 +461,39 @@ static int bma150_probe(struct i2c_client *client, if (error) return error; - if (client->irq > 0) { - error = bma150_register_input_device(bma150); + idev = devm_input_allocate_device(&bma150->client->dev); + if (!idev) + return -ENOMEM; + + input_set_drvdata(idev, bma150); + bma150->input = idev; + + idev->name = BMA150_DRIVER; + idev->phys = BMA150_DRIVER "/input0"; + idev->id.bustype = BUS_I2C; + + idev->open = bma150_open; + idev->close = bma150_close; + + input_set_abs_params(idev, ABS_X, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0); + input_set_abs_params(idev, ABS_Y, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0); + input_set_abs_params(idev, ABS_Z, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0); + + if (client->irq <= 0) { + error = input_setup_polling(idev, bma150_poll); if (error) return error; + input_set_poll_interval(idev, BMA150_POLL_INTERVAL); + input_set_min_poll_interval(idev, BMA150_POLL_MIN); + input_set_max_poll_interval(idev, BMA150_POLL_MAX); + } + + error = input_register_device(idev); + if (error) + return error; + + if (client->irq > 0) { error = devm_request_threaded_irq(&client->dev, client->irq, NULL, bma150_irq_thread, IRQF_TRIGGER_RISING | IRQF_ONESHOT, @@ -565,10 +504,6 @@ static int bma150_probe(struct i2c_client *client, client->irq, error); return error; } - } else { - error = bma150_register_polled_device(bma150); - if (error) - return error; } i2c_set_clientdata(client, bma150); @@ -585,8 +520,7 @@ static int bma150_remove(struct i2c_client *client) return 0; } -#ifdef CONFIG_PM -static int bma150_suspend(struct device *dev) +static int __maybe_unused bma150_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct bma150_data *bma150 = i2c_get_clientdata(client); @@ -594,14 +528,13 @@ static int bma150_suspend(struct device *dev) return bma150_set_mode(bma150, BMA150_MODE_SLEEP); } -static int bma150_resume(struct device *dev) +static int __maybe_unused bma150_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct bma150_data *bma150 = i2c_get_clientdata(client); return bma150_set_mode(bma150, BMA150_MODE_NORMAL); } -#endif static UNIVERSAL_DEV_PM_OPS(bma150_pm, bma150_suspend, bma150_resume, NULL); From patchwork Thu Oct 17 20:42:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B44BE14ED for ; Thu, 17 Oct 2019 20:43:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 888E021D7D for ; Thu, 17 Oct 2019 20:43:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PnZ4hYwE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503004AbfJQUna (ORCPT ); Thu, 17 Oct 2019 16:43:30 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41602 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503017AbfJQUmv (ORCPT ); Thu, 17 Oct 2019 16:42:51 -0400 Received: by mail-pf1-f193.google.com with SMTP id q7so2368385pfh.8; Thu, 17 Oct 2019 13:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nakS4ni/rzOzl8FCN3SL5jKJ0hRnlt/GoJAm0yqa078=; b=PnZ4hYwEbStV5VEGMzJSEN6FdtifpkFlGbm5q0movRTugtW+PpjBrsmsuTncl1+rkn HdbrHLceCbMiS8URsK6KETlr4YVmaRGhqky0DWLL3ZgyxyVwM1oKnkT/TypiILQgWmnB CxbzFJySVcKjPf7f6qUyw6w0w0QKpDZUQjU0twGJUH4vKrg5Ns167e1U/fSJWJ4lZbSZ //I4SCEofeFxvtVRmvTHOCcVuuAwTySDuAsrxjEQDLVyk+i0b9HZvFZ2j2p6Pr5ynQrq 6Wjkfp9w6jDXHqVId0rNZ+JcBIJuRDehdgkck42U5br2BwmSPbplczIzjcbKm+ZR8z/O ZfpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nakS4ni/rzOzl8FCN3SL5jKJ0hRnlt/GoJAm0yqa078=; b=AS+WgyuqOMzI+AUjo1PgMumvUiZl+0uiBC4AL6m5aSbl4nyhpFF5Y2lxqkd3f7vgzm zNTxlgcP7q3lpJgyAmqE3Nuv7kwQptnSRcCoBvGA9Sy8BhmFMLrPJzaWYYzSHqWXcaAe ivFIzq46XVgZxVOmoRvWucqY4Z0mq3d64/BWoTux74fb9pxtilrUgRrHKgvLWPzvpRsd Id4ZzwHlM2VZHE8d1l0ITct6Ey1OkjER93YcxCZ+24EC3xOiQ73beXV0rri4JGpIz3Di kgmDU4mWD0R+VzdJEowy0Ef54Brfop0snwH+GIjKDacl3XT8GeZQhugig2SHqLUH7T1r 840A== X-Gm-Message-State: APjAAAWamIPhWjYzA3rDhbu4725WLvcnTxrsCNcAW4Du/s493s58v36T 7iBw/qNBsLVdhJ1jDxGo5pGL44qC X-Google-Smtp-Source: APXvYqxkfJlhpt9lZeGxJkPWeJELDZT4tnBWyAeABdOUDsiw4ptS+IX1wWTVg3XEHm/FsGi9WjwEeA== X-Received: by 2002:a62:fc12:: with SMTP id e18mr2326918pfh.257.1571344969228; Thu, 17 Oct 2019 13:42:49 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:48 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Alexios Zavras , Allison Randal , linux-kernel@vger.kernel.org Subject: [PATCH 21/22] Input: kxtj9 - switch to using managed resources Date: Thu, 17 Oct 2019 13:42:15 -0700 Message-Id: <20191017204217.106453-22-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Using devm API allows to clean up error handling and drop the remove() method. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/kxtj9.c | 86 +++++++++++++------------------------- 1 file changed, 28 insertions(+), 58 deletions(-) diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c index db01c4a33914..a86544d575f8 100644 --- a/drivers/input/misc/kxtj9.c +++ b/drivers/input/misc/kxtj9.c @@ -292,7 +292,6 @@ static void kxtj9_init_input_device(struct kxtj9_data *tj9, input_dev->name = "kxtj9_accel"; input_dev->id.bustype = BUS_I2C; - input_dev->dev.parent = &tj9->client->dev; } static int kxtj9_setup_input_device(struct kxtj9_data *tj9) @@ -300,7 +299,7 @@ static int kxtj9_setup_input_device(struct kxtj9_data *tj9) struct input_dev *input_dev; int err; - input_dev = input_allocate_device(); + input_dev = devm_input_allocate_device(&tj9->client->dev); if (!input_dev) { dev_err(&tj9->client->dev, "input device allocate failed\n"); return -ENOMEM; @@ -319,7 +318,6 @@ static int kxtj9_setup_input_device(struct kxtj9_data *tj9) dev_err(&tj9->client->dev, "unable to register input polled device %s: %d\n", tj9->input_dev->name, err); - input_free_device(tj9->input_dev); return err; } @@ -424,8 +422,8 @@ static int kxtj9_setup_polled_device(struct kxtj9_data *tj9) { int err; struct input_polled_dev *poll_dev; - poll_dev = input_allocate_polled_device(); + poll_dev = devm_input_allocate_polled_device(&tj9->client->dev); if (!poll_dev) { dev_err(&tj9->client->dev, "Failed to allocate polled device\n"); @@ -446,19 +444,12 @@ static int kxtj9_setup_polled_device(struct kxtj9_data *tj9) if (err) { dev_err(&tj9->client->dev, "Unable to register polled device, err=%d\n", err); - input_free_polled_device(poll_dev); return err; } return 0; } -static void kxtj9_teardown_polled_device(struct kxtj9_data *tj9) -{ - input_unregister_polled_device(tj9->poll_dev); - input_free_polled_device(tj9->poll_dev); -} - #else static inline int kxtj9_setup_polled_device(struct kxtj9_data *tj9) @@ -466,11 +457,15 @@ static inline int kxtj9_setup_polled_device(struct kxtj9_data *tj9) return -ENOSYS; } -static inline void kxtj9_teardown_polled_device(struct kxtj9_data *tj9) +#endif + +static void kxtj9_platform_exit(void *data) { -} + struct kxtj9_data *tj9 = data; -#endif + if (tj9->pdata.exit) + tj9->pdata.exit(); +} static int kxtj9_verify(struct kxtj9_data *tj9) { @@ -494,7 +489,7 @@ static int kxtj9_verify(struct kxtj9_data *tj9) } static int kxtj9_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { const struct kxtj9_platform_data *pdata = dev_get_platdata(&client->dev); @@ -512,7 +507,7 @@ static int kxtj9_probe(struct i2c_client *client, return -EINVAL; } - tj9 = kzalloc(sizeof(*tj9), GFP_KERNEL); + tj9 = devm_kzalloc(&client->dev, sizeof(*tj9), GFP_KERNEL); if (!tj9) { dev_err(&client->dev, "failed to allocate memory for module data\n"); @@ -525,13 +520,17 @@ static int kxtj9_probe(struct i2c_client *client, if (pdata->init) { err = pdata->init(); if (err < 0) - goto err_free_mem; + return err; } + err = devm_add_action_or_reset(&client->dev, kxtj9_platform_exit, tj9); + if (err) + return err; + err = kxtj9_verify(tj9); if (err < 0) { dev_err(&client->dev, "device not recognized\n"); - goto err_pdata_exit; + return err; } i2c_set_clientdata(client, tj9); @@ -546,59 +545,31 @@ static int kxtj9_probe(struct i2c_client *client, err = kxtj9_setup_input_device(tj9); if (err) - goto err_pdata_exit; + return err; - err = request_threaded_irq(client->irq, NULL, kxtj9_isr, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, - "kxtj9-irq", tj9); + err = devm_request_threaded_irq(&client->dev, client->irq, + NULL, kxtj9_isr, + IRQF_TRIGGER_RISING | + IRQF_ONESHOT, + "kxtj9-irq", tj9); if (err) { dev_err(&client->dev, "request irq failed: %d\n", err); - goto err_destroy_input; + return err; } - err = sysfs_create_group(&client->dev.kobj, &kxtj9_attribute_group); + err = devm_device_add_group(&client->dev, + &kxtj9_attribute_group); if (err) { dev_err(&client->dev, "sysfs create failed: %d\n", err); - goto err_free_irq; + return err; } } else { err = kxtj9_setup_polled_device(tj9); if (err) - goto err_pdata_exit; - } - - return 0; - -err_free_irq: - free_irq(client->irq, tj9); -err_destroy_input: - input_unregister_device(tj9->input_dev); -err_pdata_exit: - if (tj9->pdata.exit) - tj9->pdata.exit(); -err_free_mem: - kfree(tj9); - return err; -} - -static int kxtj9_remove(struct i2c_client *client) -{ - struct kxtj9_data *tj9 = i2c_get_clientdata(client); - - if (client->irq) { - sysfs_remove_group(&client->dev.kobj, &kxtj9_attribute_group); - free_irq(client->irq, tj9); - input_unregister_device(tj9->input_dev); - } else { - kxtj9_teardown_polled_device(tj9); + return err; } - if (tj9->pdata.exit) - tj9->pdata.exit(); - - kfree(tj9); - return 0; } @@ -647,7 +618,6 @@ static struct i2c_driver kxtj9_driver = { .pm = &kxtj9_pm_ops, }, .probe = kxtj9_probe, - .remove = kxtj9_remove, .id_table = kxtj9_id, }; From patchwork Thu Oct 17 20:42:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11197131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 115B715AB for ; Thu, 17 Oct 2019 20:42:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9FCB2089C for ; Thu, 17 Oct 2019 20:42:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OyXVm1JD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503102AbfJQUmx (ORCPT ); Thu, 17 Oct 2019 16:42:53 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43969 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503004AbfJQUmw (ORCPT ); Thu, 17 Oct 2019 16:42:52 -0400 Received: by mail-pf1-f195.google.com with SMTP id a2so2367254pfo.10; Thu, 17 Oct 2019 13:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ds3G9FC0CpY1fgUg7Wus7vKJj7ThQbDWX2QzY5C/6q0=; b=OyXVm1JDEyJk8c/QlnGaThqWEmWDu/Iyv569RjAgsGUes6zgtZyuRQ4T5KNzDcQgJv 9KEjsjTe948KgIn/KYs6bYtdDlOiaLEwmDZRVsvKZsp9hbmYMjhwJzmx0+x0ix+xYcT6 wOjPTsXw1Y7FI4Q+IK/mncyx+5e55Csk8pfzRUd4RNFfa6Cs9kBUVnxeU8sFhbYtbRL7 COL2vG1TYJaQ+a4fPP/hlmDJLUUHH+qsoIeQ9zTgK1Ea4w0CVODq99CbZfiKQmxi9KB9 duBXmsUb5gQmOi/7UZ6DpPC0weierdL536SFvQaw5tg0H+Mln/uu6y5BlY28tv5eTXkr Zs3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ds3G9FC0CpY1fgUg7Wus7vKJj7ThQbDWX2QzY5C/6q0=; b=bj3yGyuVkR6EWYc0NlPKmM+2quLrwYFQYuJOur211kpnKOCcfJDAqU8kLB2ZtkRMgF OUSprCE1u/NGsABfFqms8M7KiUKIDij7KHWjckDXco9f1HvBQAfnoMffkv4+J2ZuyJi0 hCgno4DrFXr9W9W5S9G7KRUUO5N5NUz8bMaOCzI4+10jOgIsQufkbMfwH4Gjcdo/B9ZI bt5zD+yULv/f4MogE8fo1rk5m3q/ZCvC7bOLUwARGU3MxYJTImuVrMboePqxuQLSV7H6 wutbceXazBjFS8hDc0hJOUtQm4AvkRA7eeBwEX6x8eEesZklT7195hdBZu2AdQ0cMqHp zf/g== X-Gm-Message-State: APjAAAX4YpBZO5va9ZzHd6RhCBedClQ4VsIEJ8ERsCxWJ+iNwUsDBGCB hsHGs/hjApNoK4ll9/owhg5i9CsI X-Google-Smtp-Source: APXvYqw5jhqwnF/JJWYXhizL1iPuN5xVmMPI63oZqQ+KNqheNo82aL5C6DGxpyEyHSDecG6AXcnuNQ== X-Received: by 2002:a17:90a:8d82:: with SMTP id d2mr6730121pjo.31.1571344970491; Thu, 17 Oct 2019 13:42:50 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:49 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Alexios Zavras , Allison Randal , Bartosz Golaszewski , Brian Masney , Luca Weiss , Maximilian Luz , linux-kernel@vger.kernel.org Subject: [PATCH 22/22] Input: kxtj9 - switch to using polled mode of input devices Date: Thu, 17 Oct 2019 13:42:16 -0700 Message-Id: <20191017204217.106453-23-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts kxtj9 driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. note that with regular input devices handling polling, there is no longer a benefit in having separate INPUT_KXTJ9_POLLED_MODE config option. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 7 -- drivers/input/misc/kxtj9.c | 152 +++++++++---------------------------- 2 files changed, 37 insertions(+), 122 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 438ec07e3b62..7e2e658d551c 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -404,13 +404,6 @@ config INPUT_KXTJ9 To compile this driver as a module, choose M here: the module will be called kxtj9. -config INPUT_KXTJ9_POLLED_MODE - bool "Enable polling mode support" - depends on INPUT_KXTJ9 - select INPUT_POLLDEV - help - Say Y here if you need accelerometer to work in polling mode. - config INPUT_POWERMATE tristate "Griffin PowerMate and Contour Jog support" depends on USB_ARCH_HAS_HCD diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c index a86544d575f8..52313c6e3fb3 100644 --- a/drivers/input/misc/kxtj9.c +++ b/drivers/input/misc/kxtj9.c @@ -11,7 +11,6 @@ #include #include #include -#include #define NAME "kxtj9" #define G_MAX 8000 @@ -71,9 +70,6 @@ struct kxtj9_data { struct i2c_client *client; struct kxtj9_platform_data pdata; struct input_dev *input_dev; -#ifdef CONFIG_INPUT_KXTJ9_POLLED_MODE - struct input_polled_dev *poll_dev; -#endif unsigned int last_poll_interval; u8 shift; u8 ctrl_reg1; @@ -282,48 +278,6 @@ static void kxtj9_input_close(struct input_dev *dev) kxtj9_disable(tj9); } -static void kxtj9_init_input_device(struct kxtj9_data *tj9, - struct input_dev *input_dev) -{ - __set_bit(EV_ABS, input_dev->evbit); - input_set_abs_params(input_dev, ABS_X, -G_MAX, G_MAX, FUZZ, FLAT); - input_set_abs_params(input_dev, ABS_Y, -G_MAX, G_MAX, FUZZ, FLAT); - input_set_abs_params(input_dev, ABS_Z, -G_MAX, G_MAX, FUZZ, FLAT); - - input_dev->name = "kxtj9_accel"; - input_dev->id.bustype = BUS_I2C; -} - -static int kxtj9_setup_input_device(struct kxtj9_data *tj9) -{ - struct input_dev *input_dev; - int err; - - input_dev = devm_input_allocate_device(&tj9->client->dev); - if (!input_dev) { - dev_err(&tj9->client->dev, "input device allocate failed\n"); - return -ENOMEM; - } - - tj9->input_dev = input_dev; - - input_dev->open = kxtj9_input_open; - input_dev->close = kxtj9_input_close; - input_set_drvdata(input_dev, tj9); - - kxtj9_init_input_device(tj9, input_dev); - - err = input_register_device(tj9->input_dev); - if (err) { - dev_err(&tj9->client->dev, - "unable to register input polled device %s: %d\n", - tj9->input_dev->name, err); - return err; - } - - return 0; -} - /* * When IRQ mode is selected, we need to provide an interface to allow the user * to change the output data rate of the part. For consistency, we are using @@ -389,12 +343,10 @@ static struct attribute_group kxtj9_attribute_group = { .attrs = kxtj9_attributes }; - -#ifdef CONFIG_INPUT_KXTJ9_POLLED_MODE -static void kxtj9_poll(struct input_polled_dev *dev) +static void kxtj9_poll(struct input_dev *input) { - struct kxtj9_data *tj9 = dev->private; - unsigned int poll_interval = dev->poll_interval; + struct kxtj9_data *tj9 = input_get_drvdata(input); + unsigned int poll_interval = input_get_poll_interval(input); kxtj9_report_acceleration_data(tj9); @@ -404,61 +356,6 @@ static void kxtj9_poll(struct input_polled_dev *dev) } } -static void kxtj9_polled_input_open(struct input_polled_dev *dev) -{ - struct kxtj9_data *tj9 = dev->private; - - kxtj9_enable(tj9); -} - -static void kxtj9_polled_input_close(struct input_polled_dev *dev) -{ - struct kxtj9_data *tj9 = dev->private; - - kxtj9_disable(tj9); -} - -static int kxtj9_setup_polled_device(struct kxtj9_data *tj9) -{ - int err; - struct input_polled_dev *poll_dev; - - poll_dev = devm_input_allocate_polled_device(&tj9->client->dev); - if (!poll_dev) { - dev_err(&tj9->client->dev, - "Failed to allocate polled device\n"); - return -ENOMEM; - } - - tj9->poll_dev = poll_dev; - tj9->input_dev = poll_dev->input; - - poll_dev->private = tj9; - poll_dev->poll = kxtj9_poll; - poll_dev->open = kxtj9_polled_input_open; - poll_dev->close = kxtj9_polled_input_close; - - kxtj9_init_input_device(tj9, poll_dev->input); - - err = input_register_polled_device(poll_dev); - if (err) { - dev_err(&tj9->client->dev, - "Unable to register polled device, err=%d\n", err); - return err; - } - - return 0; -} - -#else - -static inline int kxtj9_setup_polled_device(struct kxtj9_data *tj9) -{ - return -ENOSYS; -} - -#endif - static void kxtj9_platform_exit(void *data) { struct kxtj9_data *tj9 = data; @@ -494,6 +391,7 @@ static int kxtj9_probe(struct i2c_client *client, const struct kxtj9_platform_data *pdata = dev_get_platdata(&client->dev); struct kxtj9_data *tj9; + struct input_dev *input_dev; int err; if (!i2c_check_functionality(client->adapter, @@ -538,15 +436,44 @@ static int kxtj9_probe(struct i2c_client *client, tj9->ctrl_reg1 = tj9->pdata.res_12bit | tj9->pdata.g_range; tj9->last_poll_interval = tj9->pdata.init_interval; + input_dev = devm_input_allocate_device(&client->dev); + if (!input_dev) { + dev_err(&client->dev, "input device allocate failed\n"); + return -ENOMEM; + } + + input_set_drvdata(input_dev, tj9); + tj9->input_dev = input_dev; + + input_dev->name = "kxtj9_accel"; + input_dev->id.bustype = BUS_I2C; + + input_dev->open = kxtj9_input_open; + input_dev->close = kxtj9_input_close; + + input_set_abs_params(input_dev, ABS_X, -G_MAX, G_MAX, FUZZ, FLAT); + input_set_abs_params(input_dev, ABS_Y, -G_MAX, G_MAX, FUZZ, FLAT); + input_set_abs_params(input_dev, ABS_Z, -G_MAX, G_MAX, FUZZ, FLAT); + + if (client->irq <= 0) { + err = input_setup_polling(input_dev, kxtj9_poll); + if (err) + return err; + } + + err = input_register_device(input_dev); + if (err) { + dev_err(&client->dev, + "unable to register input polled device %s: %d\n", + input_dev->name, err); + return err; + } + if (client->irq) { /* If in irq mode, populate INT_CTRL_REG1 and enable DRDY. */ tj9->int_ctrl |= KXTJ9_IEN | KXTJ9_IEA | KXTJ9_IEL; tj9->ctrl_reg1 |= DRDYE; - err = kxtj9_setup_input_device(tj9); - if (err) - return err; - err = devm_request_threaded_irq(&client->dev, client->irq, NULL, kxtj9_isr, IRQF_TRIGGER_RISING | @@ -563,11 +490,6 @@ static int kxtj9_probe(struct i2c_client *client, dev_err(&client->dev, "sysfs create failed: %d\n", err); return err; } - - } else { - err = kxtj9_setup_polled_device(tj9); - if (err) - return err; } return 0;