Skip to contentSkip to conversation

input: mc13783: Make mc13xxx_buttons_platform_data more flexible

PATCH In review Alexander Shiyan 2 participants 6 messages Feb 10, 2014 – Feb 11, 2014

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 input: mc13783: Make mc13xxx_buttons_platform_data more flexible

Instead of define each button in separate variable, make an array for storing all buttons. This change will help to add support for other types of PMIC and add support for probing with devicetree in the future.

---
 arch/arm/mach-imx/mach-mx31moboard.c   |  9 ++++--
 drivers/input/misc/mc13783-pwrbutton.c | 56 +++++++++++++++++-----------------
 include/linux/mfd/mc13xxx.h            | 28 +++++++++--------
 3 files changed, 49 insertions(+), 44 deletions(-)
arch/arm/mach-imx/mach-mx31moboard.c +6 -3
index b3738e6..7f13c47 100644
@@ -276,9 +276,12 @@ static struct mc13xxx_leds_platform_data moboard_leds = {
 };
 
 static struct mc13xxx_buttons_platform_data moboard_buttons = {
-	.b1on_flags = MC13783_BUTTON_DBNC_750MS | MC13783_BUTTON_ENABLE |
-			MC13783_BUTTON_POL_INVERT,
-	.b1on_key = KEY_POWER,
+	.buttons[0] = {
+		.keycode	= KEY_POWER,
+		.flags		= MC13XXX_BUTTON_ENABLE |
+				  MC13XXX_BUTTON_DBNC_750MS |
+				  MC13XXX_BUTTON_POL_INVERT,
+	},
 };
 
 static struct mc13xxx_codec_platform_data moboard_codec = {
drivers/input/misc/mc13783-pwrbutton.c +28 -28

115 lines not on this page · raw message

include/linux/mfd/mc13xxx.h +15 -13
index a326c85..4cedec4 100644
@@ -172,20 +172,22 @@ struct mc13xxx_leds_platform_data {
 	u32 led_control[MAX_LED_CONTROL_REGS];
 };
 
+#define MAX13XXX_NUM_BUTTONS	3
+
+struct mc13xxx_button {
+	u16		keycode;
+	unsigned int	flags;
+#define MC13XXX_BUTTON_DBNC_0MS		0
+#define MC13XXX_BUTTON_DBNC_30MS	1
+#define MC13XXX_BUTTON_DBNC_150MS	2
+#define MC13XXX_BUTTON_DBNC_750MS	3
+#define MC13XXX_BUTTON_ENABLE		(1 << 2)
+#define MC13XXX_BUTTON_POL_INVERT	(1 << 3)
+#define MC13XXX_BUTTON_RESET_EN		(1 << 4)
+};
+
 struct mc13xxx_buttons_platform_data {
-#define MC13783_BUTTON_DBNC_0MS		0
-#define MC13783_BUTTON_DBNC_30MS	1
-#define MC13783_BUTTON_DBNC_150MS	2
-#define MC13783_BUTTON_DBNC_750MS	3
-#define MC13783_BUTTON_ENABLE		(1 << 2)
-#define MC13783_BUTTON_POL_INVERT	(1 << 3)
-#define MC13783_BUTTON_RESET_EN		(1 << 4)
-	int b1on_flags;
-	unsigned short b1on_key;
-	int b2on_flags;
-	unsigned short b2on_key;
-	int b3on_flags;
-	unsigned short b3on_key;
+	struct mc13xxx_button	buttons[MAX13XXX_NUM_BUTTONS];
 };
 
 struct mc13xxx_ts_platform_data {
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 10 lines

Instead of define each button in separate variable, make an array for storing all buttons. This change will help to add support for other types of PMIC and add support for probing with devicetree in the future.

---
 arch/arm/mach-imx/mach-mx31moboard.c   |  9 ++++--
 drivers/input/misc/mc13783-pwrbutton.c | 56 +++++++++++++++++-----------------
 include/linux/mfd/mc13xxx.h            | 28 +++++++++--------

Are all the changes in these files entangled? If there is any way to make them orthogonal, then all the better.

<snip>

Quoted 10 lines
include/linux/mfd/mc13xxx.h +4 -0
@@ -172,20 +172,22 @@ struct mc13xxx_leds_platform_data {
 	u32 led_control[MAX_LED_CONTROL_REGS];
 };
 
+#define MAX13XXX_NUM_BUTTONS	3
+
+struct mc13xxx_button {
+	u16		keycode;

include/linux/mfd/mc13xxx.h struct mc13xxx_leds_platform_data { · line 188

Quoted 10 lines
include/linux/mfd/mc13xxx.h +10 -0
+	unsigned int	flags;
+#define MC13XXX_BUTTON_DBNC_0MS		0
+#define MC13XXX_BUTTON_DBNC_30MS	1
+#define MC13XXX_BUTTON_DBNC_150MS	2
+#define MC13XXX_BUTTON_DBNC_750MS	3
+#define MC13XXX_BUTTON_ENABLE		(1 << 2)
+#define MC13XXX_BUTTON_POL_INVERT	(1 << 3)
+#define MC13XXX_BUTTON_RESET_EN		(1 << 4)
+};
+

Please take the opportunity to remove this slab list of #defines from the centre of the struct definition. Just above will be fine.

Quoted 18 lines
include/linux/mfd/mc13xxx.h +1 -13
 struct mc13xxx_buttons_platform_data {
-#define MC13783_BUTTON_DBNC_0MS		0
-#define MC13783_BUTTON_DBNC_30MS	1
-#define MC13783_BUTTON_DBNC_150MS	2
-#define MC13783_BUTTON_DBNC_750MS	3
-#define MC13783_BUTTON_ENABLE		(1 << 2)
-#define MC13783_BUTTON_POL_INVERT	(1 << 3)
-#define MC13783_BUTTON_RESET_EN		(1 << 4)
-	int b1on_flags;
-	unsigned short b1on_key;
-	int b2on_flags;
-	unsigned short b2on_key;
-	int b3on_flags;
-	unsigned short b3on_key;
+	struct mc13xxx_button	buttons[MAX13XXX_NUM_BUTTONS];
 };
 
 struct mc13xxx_ts_platform_data {
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Hello.

Понедельник, 10 февраля 2014, 11:29 UTC от Lee Jones <[email protected]>:

Quoted 9 lines
Quoted 9 lines

Instead of define each button in separate variable, make an array for storing all buttons. This change will help to add support for other types of PMIC and add support for probing with devicetree in the future.

---
 arch/arm/mach-imx/mach-mx31moboard.c   |  9 ++++--
 drivers/input/misc/mc13783-pwrbutton.c | 56
Quoted 5 lines

+++++++++++++++++-----------------

Quoted 1 line
 include/linux/mfd/mc13xxx.h            | 28 +++++++++--------

Are all the changes in these files entangled? If there is any way to make them orthogonal, then all the better.

Can you say the same thing in other words, I didn't understand a bit of your comment.

...

Quoted 7 lines
Quoted 7 lines
include/linux/mfd/mc13xxx.h +7 -0
+struct mc13xxx_button {
+	u16		keycode;
+	unsigned int	flags;
+#define MC13XXX_BUTTON_DBNC_0MS		0
+#define MC13XXX_BUTTON_DBNC_30MS	1
+#define MC13XXX_BUTTON_DBNC_150MS	2
+#define MC13XXX_BUTTON_DBNC_750MS	3
Quoted 8 lines

include/linux/mfd/mc13xxx.h struct mc13xxx_leds_platform_data { · line 188

Quoted 5 lines
include/linux/mfd/mc13xxx.h +5 -0
+#define MC13XXX_BUTTON_ENABLE		(1 << 2)
+#define MC13XXX_BUTTON_POL_INVERT	(1 << 3)
+#define MC13XXX_BUTTON_RESET_EN		(1 << 4)
+};
+

Please take the opportunity to remove this slab list of #defines from the centre of the struct definition. Just above will be fine.

I would like to make it in a separate patch for the whole header file later.

---

#3 lore raw
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Instead of define each button in separate variable, make an array for storing all buttons. This change will help to add support for other types of PMIC and add support for probing with devicetree in the future.

---
 arch/arm/mach-imx/mach-mx31moboard.c   |  9 ++++--
 drivers/input/misc/mc13783-pwrbutton.c | 56
Quoted 8 lines
Quoted 5 lines

+++++++++++++++++-----------------

Quoted 1 line
 include/linux/mfd/mc13xxx.h            | 28 +++++++++--------

Are all the changes in these files entangled? If there is any way to make them orthogonal, then all the better.

Can you say the same thing in other words, I didn't understand a bit of your comment.

Do all of this changes in each of the files listed above depend on each other?

Quoted 17 lines

...

Quoted 7 lines
Quoted 7 lines
include/linux/mfd/mc13xxx.h +7 -0
+struct mc13xxx_button {
+	u16		keycode;
+	unsigned int	flags;
+#define MC13XXX_BUTTON_DBNC_0MS		0
+#define MC13XXX_BUTTON_DBNC_30MS	1
+#define MC13XXX_BUTTON_DBNC_150MS	2
+#define MC13XXX_BUTTON_DBNC_750MS	3
Quoted 8 lines

include/linux/mfd/mc13xxx.h struct mc13xxx_leds_platform_data { · line 188

Quoted 5 lines
include/linux/mfd/mc13xxx.h +5 -0
+#define MC13XXX_BUTTON_ENABLE		(1 << 2)
+#define MC13XXX_BUTTON_POL_INVERT	(1 << 3)
+#define MC13XXX_BUTTON_RESET_EN		(1 << 4)
+};
+

Please take the opportunity to remove this slab list of #defines from the centre of the struct definition. Just above will be fine.

Quoted 1 line

I would like to make it in a separate patch for the whole header file later.

You may as well do it in this commit? Just add them outside of the struct definition instead of inside.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Hello.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines

Instead of define each button in separate variable, make an array for storing all buttons. This change will help to add support for other types of PMIC and add support for probing with devicetree in the future.

---
 arch/arm/mach-imx/mach-mx31moboard.c   |  9 ++++--
 drivers/input/misc/mc13783-pwrbutton.c | 56

+++++++++++++++++-----------------

Quoted 1 line
 include/linux/mfd/mc13xxx.h            | 28 +++++++++--------
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Are all the changes in these files entangled? If there is any way to make them orthogonal, then all the better.

Can you say the same thing in other words, I didn't understand a bit of your comment.

Do all of this changes in each of the files listed above depend on each other?

Yes, mc13783-pwrbutton.c & mc13xxx.h - changing the structure, mach-mx31moboard.c - updating current users.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

include/linux/mfd/mc13xxx.h struct mc13xxx_leds_platform_data { · line 188

Quoted 12 lines
include/linux/mfd/mc13xxx.h +12 -0
+struct mc13xxx_button {
+	u16		keycode;
+	unsigned int	flags;
+#define MC13XXX_BUTTON_DBNC_0MS		0
+#define MC13XXX_BUTTON_DBNC_30MS	1
+#define MC13XXX_BUTTON_DBNC_150MS	2
+#define MC13XXX_BUTTON_DBNC_750MS	3
+#define MC13XXX_BUTTON_ENABLE		(1 << 2)
+#define MC13XXX_BUTTON_POL_INVERT	(1 << 3)
+#define MC13XXX_BUTTON_RESET_EN		(1 << 4)
+};
+

Please take the opportunity to remove this slab list of #defines from the centre of the struct definition. Just above will be fine.

Quoted 4 lines
Quoted 1 line

I would like to make it in a separate patch for the whole header file later.

You may as well do it in this commit? Just add them outside of the struct definition instead of inside.

OK, I'll do it in version 2, but I meant that I could change it for the other structures in this header. As part of the input subsystem, I can not do that. Thanks.

---

#5 lore raw
Quoted 40 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines

Instead of define each button in separate variable, make an array for storing all buttons. This change will help to add support for other types of PMIC and add support for probing with devicetree in the future.

---
 arch/arm/mach-imx/mach-mx31moboard.c   |  9 ++++--
 drivers/input/misc/mc13783-pwrbutton.c | 56

+++++++++++++++++-----------------

Quoted 1 line
 include/linux/mfd/mc13xxx.h            | 28 +++++++++--------
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Are all the changes in these files entangled? If there is any way to make them orthogonal, then all the better.

Can you say the same thing in other words, I didn't understand a bit of your comment.

Do all of this changes in each of the files listed above depend on each other?

Yes, mc13783-pwrbutton.c & mc13xxx.h - changing the structure, mach-mx31moboard.c - updating current users.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

include/linux/mfd/mc13xxx.h struct mc13xxx_leds_platform_data { · line 188

Quoted 12 lines
include/linux/mfd/mc13xxx.h +12 -0
+struct mc13xxx_button {
+	u16		keycode;
+	unsigned int	flags;
+#define MC13XXX_BUTTON_DBNC_0MS		0
+#define MC13XXX_BUTTON_DBNC_30MS	1
+#define MC13XXX_BUTTON_DBNC_150MS	2
+#define MC13XXX_BUTTON_DBNC_750MS	3
+#define MC13XXX_BUTTON_ENABLE		(1 << 2)
+#define MC13XXX_BUTTON_POL_INVERT	(1 << 3)
+#define MC13XXX_BUTTON_RESET_EN		(1 << 4)
+};
+

Please take the opportunity to remove this slab list of #defines from the centre of the struct definition. Just above will be fine.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I would like to make it in a separate patch for the whole header file later.

You may as well do it in this commit? Just add them outside of the struct definition instead of inside.

OK, I'll do it in version 2, but I meant that I could change it for the other structures in this header. As part of the input subsystem, I can not do that.

If changes can be subsystem orthogonal, it's better to keep them that way. Fix this issue in this patch and fix any other issues within this file in another patch which will go through the MFD tree.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html