From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
To: HyungJae Im <hj2.im@samsung.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"rydberg@bitmath.org" <rydberg@bitmath.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"manivannan.sadhasivam@linaro.org"
<manivannan.sadhasivam@linaro.org>
Subject: Re: [PATCH] Input: add switch event(SW_EXT_PEN_ATTACHED)
Date: Fri, 30 Oct 2020 11:45:13 +0100 [thread overview]
Message-ID: <20201030104513.GA2395528@kroah.com> (raw)
In-Reply-To: <20201030062740epcms1p614195fb639c807cd2db762d117cc69fc@epcms1p6>
On Fri, Oct 30, 2020 at 03:27:40PM +0900, HyungJae Im wrote:
> We need support to various accessories on the device,
> some requiring switch does not exist in switch list.
> So added switch for the following purpose.
>
> SW_EXT_PEN_ATTACHED is for the checking the external pen
> attached or not on the device. We also added driver
> that uses such event.
>
> Signed-off-by: Hyungjae Im <hj2.im@samsung.com>
> ---
> drivers/input/Kconfig | 12 ++
> drivers/input/Makefile | 1 +
> drivers/input/ext_pen_detect.c | 237 +++++++++++++++++++++++++
> include/linux/mod_devicetable.h | 2 +-
> include/uapi/linux/input-event-codes.h | 3 +-
> 5 files changed, 253 insertions(+), 2 deletions(-)
> create mode 100644 drivers/input/ext_pen_detect.c
>
> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
> index ba5e7444c547..5d6d15c8f7e7 100644
> --- a/drivers/input/Kconfig
> +++ b/drivers/input/Kconfig
> @@ -197,6 +197,18 @@ config INPUT_COVER_DETECT
> To compile this driver as a module, choose M here: the
> module will be called cover_detect.
>
> +config INPUT_EXT_PEN_DETECT
> + tristate "Enable external pen attach detection"
> + help
> + Say Y here to enable external pen detection
> + and send a event when external pen is attached/detached.
> + Active gpio state is low and active event value is 0.
> +
> + If unsure, say N.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called ext_pen_detect.
> +
> comment "Input Device Drivers"
>
> source "drivers/input/keyboard/Kconfig"
> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
> index fc8dd9091821..0ccf02e34557 100644
> --- a/drivers/input/Makefile
> +++ b/drivers/input/Makefile
> @@ -31,3 +31,4 @@ obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o
> obj-$(CONFIG_RMI4_CORE) += rmi4/
>
> obj-$(CONFIG_INPUT_COVER_DETECT)+= cover_detect.o
> +obj-$(CONFIG_INPUT_EXT_PEN_DETECT)+= ext_pen_detect.o
> diff --git a/drivers/input/ext_pen_detect.c b/drivers/input/ext_pen_detect.c
> new file mode 100644
> index 000000000000..9a0d106e49f8
> --- /dev/null
> +++ b/drivers/input/ext_pen_detect.c
> @@ -0,0 +1,237 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Support detection pen attachment externally on device
> + *
> + * Copyright (C) 2020 Samsung Electronics Co. Ltd. All Rights Reserved.
> + *
> + */
> +
> +#include <linux/module.h>
> +#include <linux/interrupt.h>
> +#include <linux/pm.h>
> +#include <linux/slab.h>
> +#include <linux/platform_device.h>
> +#include <linux/input.h>
> +#include <linux/gpio.h>
> +#include <linux/of_gpio.h>
> +#include <linux/wakelock.h>
> +
> +struct ext_pen_detect_drvdata {
> + struct input_dev *input;
> + struct delayed_work ext_pen_detect_dwork;
> + struct wakeup_source *ws;
> + int gpio_ext_pen_detect;
> + int irq_ext_pen_detect;
> +};
> +
> +static void ext_pen_detect_work(struct work_struct *work)
> +{
> + struct ext_pen_detect_drvdata *ddata =
> + container_of(work, struct ext_pen_detect_drvdata,
> + ext_pen_detect_dwork.work);
> + bool ext_pen_status;
> +
> + ext_pen_status = gpio_get_value(ddata->gpio_ext_pen_detect);
> +
> + input_report_switch(ddata->input,
> + SW_EXT_PEN_ATTACHED, ext_pen_status);
As this is just a gpio device, again, why is this needed and you can't
just use the gpio_keys driver instead?
Why does this have to be a new driver?
thanks,
greg k-h
prev parent reply other threads:[~2020-10-30 10:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20201030062740epcms1p614195fb639c807cd2db762d117cc69fc@epcms1p6>
2020-10-30 6:27 ` [PATCH] Input: add switch event(SW_EXT_PEN_ATTACHED) HyungJae Im
2020-10-30 10:45 ` gregkh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201030104513.GA2395528@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=hj2.im@samsung.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=rydberg@bitmath.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox