diff mbox series

[RFC,1/2] Input: add `SW_MACHINE_COVER`

Message ID 20200214130249.6845-2-merlijn@wizzup.org (mailing list archive)
State New, archived
Headers show
Series Add SW_MACHINE_COVER key | expand

Commit Message

Merlijn Wajer Feb. 14, 2020, 1:02 p.m. UTC
This event code represents the state of a removable cover of a device.
Value 1 means that the cover is open or removed, value 0 means that the
cover is closed.

This can be used to preempt users removing a removable mmc card or even
the battery, allowing userspace to attempt to safely unmount a card.
---
 include/linux/mod_devicetable.h        | 2 +-
 include/uapi/linux/input-event-codes.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Sebastian Reichel Feb. 14, 2020, 2:38 p.m. UTC | #1
Hi,

On Fri, Feb 14, 2020 at 02:02:47PM +0100, Merlijn Wajer wrote:
> This event code represents the state of a removable cover of a device.
> Value 1 means that the cover is open or removed, value 0 means that the
> cover is closed.

This is the opposit of what is being stated everywhere else. It does
not really matter, but it must be used consistently :)

> This can be used to preempt users removing a removable mmc card or even
> the battery, allowing userspace to attempt to safely unmount a card.

I would drop this sentence, since its very specific to the N900. The
name is generic enough to e.g. also apply for desktop machines, which
sometimes have a cover switch for doing a shutdown (because of poor
airflow when open).

> ---

Missing Signed-off-by. 

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  include/linux/mod_devicetable.h        | 2 +-
>  include/uapi/linux/input-event-codes.h | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 448621c32e4d..4c692cb3cc1d 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -299,7 +299,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_LED_MAX		0x0f
>  #define INPUT_DEVICE_ID_SND_MAX		0x07
>  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> +#define INPUT_DEVICE_ID_SW_MAX		0x10
>  #define INPUT_DEVICE_ID_PROP_MAX	0x1f
>  
>  #define INPUT_DEVICE_ID_MATCH_BUS	1
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 64cee116928e..318a6387cdfb 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -807,7 +807,8 @@
>  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
>  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
>  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> -#define SW_MAX			0x0f
> +#define SW_MACHINE_COVER	 0x10 /* set = cover closed */
> +#define SW_MAX			0x10
>  #define SW_CNT			(SW_MAX+1)
>  
>  /*
> -- 
> 2.23.0
>
Ladislav Michl Feb. 14, 2020, 7:16 p.m. UTC | #2
Hi Merlijn,

On Fri, Feb 14, 2020 at 02:02:47PM +0100, Merlijn Wajer wrote:
> This event code represents the state of a removable cover of a device.
> Value 1 means that the cover is open or removed, value 0 means that the
> cover is closed.
> 
> This can be used to preempt users removing a removable mmc card or even
> the battery, allowing userspace to attempt to safely unmount a card.
> ---
>  include/linux/mod_devicetable.h        | 2 +-
>  include/uapi/linux/input-event-codes.h | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 448621c32e4d..4c692cb3cc1d 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -299,7 +299,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_LED_MAX		0x0f
>  #define INPUT_DEVICE_ID_SND_MAX		0x07
>  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> +#define INPUT_DEVICE_ID_SW_MAX		0x10
>  #define INPUT_DEVICE_ID_PROP_MAX	0x1f
>  
>  #define INPUT_DEVICE_ID_MATCH_BUS	1
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 64cee116928e..318a6387cdfb 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -807,7 +807,8 @@
>  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
>  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
>  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> -#define SW_MAX			0x0f
> +#define SW_MACHINE_COVER	 0x10 /* set = cover closed */

There is an extra space above ^

> +#define SW_MAX			0x10
>  #define SW_CNT			(SW_MAX+1)
>  
>  /*
> -- 
> 2.23.0
Merlijn Wajer Feb. 15, 2020, 9:03 a.m. UTC | #3
Hi Ladislav,

On 14/02/2020 20:16, Ladislav Michl wrote:
> Hi Merlijn,
> 
>> +#define SW_MACHINE_COVER	 0x10 /* set = cover closed */
> 
> There is an extra space above ^

Thanks, will fix.

Cheers,
Merlijn
Merlijn Wajer Feb. 15, 2020, 9:09 a.m. UTC | #4
Hi Sebastian,

On 14/02/2020 15:38, Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Feb 14, 2020 at 02:02:47PM +0100, Merlijn Wajer wrote:
>> This event code represents the state of a removable cover of a device.
>> Value 1 means that the cover is open or removed, value 0 means that the
>> cover is closed.
> 
> This is the opposit of what is being stated everywhere else. It does
> not really matter, but it must be used consistently :)

Oh, my bad. Indeed, value 1 means that the cover is closed, will fix.

>> This can be used to preempt users removing a removable mmc card or even
>> the battery, allowing userspace to attempt to safely unmount a card.
> 
> I would drop this sentence, since its very specific to the N900. The
> name is generic enough to e.g. also apply for desktop machines, which
> sometimes have a cover switch for doing a shutdown (because of poor
> airflow when open).

Fair enough.

>> ---
> 
> Missing Signed-off-by. 

Will add - thanks.

> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Cheers,
Merlijn
diff mbox series

Patch

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 448621c32e4d..4c692cb3cc1d 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -299,7 +299,7 @@  struct pcmcia_device_id {
 #define INPUT_DEVICE_ID_LED_MAX		0x0f
 #define INPUT_DEVICE_ID_SND_MAX		0x07
 #define INPUT_DEVICE_ID_FF_MAX		0x7f
-#define INPUT_DEVICE_ID_SW_MAX		0x0f
+#define INPUT_DEVICE_ID_SW_MAX		0x10
 #define INPUT_DEVICE_ID_PROP_MAX	0x1f
 
 #define INPUT_DEVICE_ID_MATCH_BUS	1
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 64cee116928e..318a6387cdfb 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -807,7 +807,8 @@ 
 #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
 #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
 #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
-#define SW_MAX			0x0f
+#define SW_MACHINE_COVER	 0x10 /* set = cover closed */
+#define SW_MAX			0x10
 #define SW_CNT			(SW_MAX+1)
 
 /*