Skip to contentSkip to conversation

Input: psmouse - use IS_ENABLED instead of homegrown code

PATCH In review Dmitry Torokhov 3 participants 3 messages Dec 29, 2014 – Jan 5, 2015

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: psmouse - use IS_ENABLED instead of homegrown code

Instead of having various protocols provide <protocol>_supported() functions, let's use IS_ENABLED() macro that works well in "if" statements.

---
 drivers/input/mouse/cypress_ps2.c  |  5 -----
 drivers/input/mouse/cypress_ps2.h  |  5 -----
 drivers/input/mouse/focaltech.c    | 10 ----------
 drivers/input/mouse/focaltech.h    |  1 -
 drivers/input/mouse/psmouse-base.c |  6 +++---
 drivers/input/mouse/synaptics.c    | 10 ----------
 drivers/input/mouse/synaptics.h    |  1 -
 7 files changed, 3 insertions(+), 35 deletions(-)
drivers/input/mouse/cypress_ps2.c +0 -5
index 8af34ff..6e5f70b 100644
@@ -710,8 +710,3 @@ err_exit:
 
 	return -1;
 }
-
-bool cypress_supported(void)
-{
-	return true;
-}
drivers/input/mouse/cypress_ps2.h +0 -5
index 4720f21..81f68aa 100644
@@ -172,7 +172,6 @@ struct cytp_data {
 #ifdef CONFIG_MOUSE_PS2_CYPRESS
 int cypress_detect(struct psmouse *psmouse, bool set_properties);
 int cypress_init(struct psmouse *psmouse);
-bool cypress_supported(void);
 #else
 inline int cypress_detect(struct psmouse *psmouse, bool set_properties)
 {
@@ -182,10 +181,6 @@ inline int cypress_init(struct psmouse *psmouse)
 {
 	return -ENOSYS;
 }
-inline bool cypress_supported(void)
-{
-	return 0;
-}
 #endif /* CONFIG_MOUSE_PS2_CYPRESS */
 
 #endif  /* _CYPRESS_PS2_H */
drivers/input/mouse/focaltech.c +0 -10
index fca38ba..757f78a 100644
@@ -424,11 +424,6 @@ fail:
 	return error;
 }
 
-bool focaltech_supported(void)
-{
-	return true;
-}
-
 #else /* CONFIG_MOUSE_PS2_FOCALTECH */
 
 int focaltech_init(struct psmouse *psmouse)
@@ -438,9 +433,4 @@ int focaltech_init(struct psmouse *psmouse)
 	return 0;
 }
 
-bool focaltech_supported(void)
-{
-	return false;
-}
-
 #endif /* CONFIG_MOUSE_PS2_FOCALTECH */
drivers/input/mouse/focaltech.h +0 -1
index 71870a9..ca61ebf 100644
@@ -19,6 +19,5 @@
 
 int focaltech_detect(struct psmouse *psmouse, bool set_properties);
 int focaltech_init(struct psmouse *psmouse);
-bool focaltech_supported(void);
 
 #endif
drivers/input/mouse/psmouse-base.c +3 -3
index 68469fe..4ccd01d 100644
@@ -727,7 +727,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
 	if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
 		if (max_proto > PSMOUSE_IMEX) {
 			if (!set_properties || focaltech_init(psmouse) == 0) {
-				if (focaltech_supported())
+				if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH))
 					return PSMOUSE_FOCALTECH;
 				/*
 				 * Note that we need to also restrict
@@ -776,7 +776,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
  * Try activating protocol, but check if support is enabled first, since
  * we try detecting Synaptics even when protocol is disabled.
  */
-			if (synaptics_supported() &&
+			if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) &&
 			    (!set_properties || synaptics_init(psmouse) == 0)) {
 				return PSMOUSE_SYNAPTICS;
 			}
@@ -801,7 +801,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
  */
 	if (max_proto > PSMOUSE_IMEX &&
 			cypress_detect(psmouse, set_properties) == 0) {
-		if (cypress_supported()) {
+		if (IS_ENABLED(CONFIG_MOUSE_PS2_CYPRESS)) {
 			if (cypress_init(psmouse) == 0)
 				return PSMOUSE_CYPRESS;
 
drivers/input/mouse/synaptics.c +0 -10
index f947292..094bf64 100644
@@ -1817,11 +1817,6 @@ int synaptics_init_relative(struct psmouse *psmouse)
 	return __synaptics_init(psmouse, false);
 }
 
-bool synaptics_supported(void)
-{
-	return true;
-}
-
 #else /* CONFIG_MOUSE_PS2_SYNAPTICS */
 
 void __init synaptics_module_init(void)
@@ -1833,9 +1828,4 @@ int synaptics_init(struct psmouse *psmouse)
 	return -ENOSYS;
 }
 
-bool synaptics_supported(void)
-{
-	return false;
-}
-
 #endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
drivers/input/mouse/synaptics.h +0 -1
index 1bd01f2..feb28a5 100644
@@ -191,6 +191,5 @@ int synaptics_detect(struct psmouse *psmouse, bool set_properties);
 int synaptics_init(struct psmouse *psmouse);
 int synaptics_init_relative(struct psmouse *psmouse);
 void synaptics_reset(struct psmouse *psmouse);
-bool synaptics_supported(void);
 
 #endif /* _SYNAPTICS_H */
Signature · 5 lines
2.2.0.rc0.207.ga3a616c


-- 
Dmitry
Acked-by on v1 1/1
#1 lore raw

Hi,

Looks good to me:

Regards,

Hans

Quoted 156 lines · Dmitry Torokhov

Instead of having various protocols provide <protocol>_supported() functions, let's use IS_ENABLED() macro that works well in "if" statements.

---
  drivers/input/mouse/cypress_ps2.c  |  5 -----
  drivers/input/mouse/cypress_ps2.h  |  5 -----
  drivers/input/mouse/focaltech.c    | 10 ----------
  drivers/input/mouse/focaltech.h    |  1 -
  drivers/input/mouse/psmouse-base.c |  6 +++---
  drivers/input/mouse/synaptics.c    | 10 ----------
  drivers/input/mouse/synaptics.h    |  1 -
  7 files changed, 3 insertions(+), 35 deletions(-)
drivers/input/mouse/cypress_ps2.c +0 -5
index 8af34ff..6e5f70b 100644
@@ -710,8 +710,3 @@ err_exit:
 
  	return -1;
  }
-
-bool cypress_supported(void)
-{
-	return true;
-}
drivers/input/mouse/cypress_ps2.h +0 -5
index 4720f21..81f68aa 100644
@@ -172,7 +172,6 @@ struct cytp_data {
  #ifdef CONFIG_MOUSE_PS2_CYPRESS
  int cypress_detect(struct psmouse *psmouse, bool set_properties);
  int cypress_init(struct psmouse *psmouse);
-bool cypress_supported(void);
  #else
  inline int cypress_detect(struct psmouse *psmouse, bool set_properties)
  {
@@ -182,10 +181,6 @@ inline int cypress_init(struct psmouse *psmouse)
  {
  	return -ENOSYS;
  }
-inline bool cypress_supported(void)
-{
-	return 0;
-}
  #endif /* CONFIG_MOUSE_PS2_CYPRESS */
 
  #endif  /* _CYPRESS_PS2_H */
drivers/input/mouse/focaltech.c +0 -10
index fca38ba..757f78a 100644
@@ -424,11 +424,6 @@ fail:
  	return error;
  }
 
-bool focaltech_supported(void)
-{
-	return true;
-}
-
  #else /* CONFIG_MOUSE_PS2_FOCALTECH */
 
  int focaltech_init(struct psmouse *psmouse)
@@ -438,9 +433,4 @@ int focaltech_init(struct psmouse *psmouse)
  	return 0;
  }
 
-bool focaltech_supported(void)
-{
-	return false;
-}
-
  #endif /* CONFIG_MOUSE_PS2_FOCALTECH */
drivers/input/mouse/focaltech.h +0 -1
index 71870a9..ca61ebf 100644
@@ -19,6 +19,5 @@
 
  int focaltech_detect(struct psmouse *psmouse, bool set_properties);
  int focaltech_init(struct psmouse *psmouse);
-bool focaltech_supported(void);
 
  #endif
drivers/input/mouse/psmouse-base.c +3 -3
index 68469fe..4ccd01d 100644
@@ -727,7 +727,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
  	if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
  		if (max_proto > PSMOUSE_IMEX) {
  			if (!set_properties || focaltech_init(psmouse) == 0) {
-				if (focaltech_supported())
+				if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH))
  					return PSMOUSE_FOCALTECH;
  				/*
  				 * Note that we need to also restrict
@@ -776,7 +776,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
   * Try activating protocol, but check if support is enabled first, since
   * we try detecting Synaptics even when protocol is disabled.
   */
-			if (synaptics_supported() &&
+			if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) &&
  			    (!set_properties || synaptics_init(psmouse) == 0)) {
  				return PSMOUSE_SYNAPTICS;
  			}
@@ -801,7 +801,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
   */
  	if (max_proto > PSMOUSE_IMEX &&
  			cypress_detect(psmouse, set_properties) == 0) {
-		if (cypress_supported()) {
+		if (IS_ENABLED(CONFIG_MOUSE_PS2_CYPRESS)) {
  			if (cypress_init(psmouse) == 0)
  				return PSMOUSE_CYPRESS;
 
drivers/input/mouse/synaptics.c +0 -10
index f947292..094bf64 100644
@@ -1817,11 +1817,6 @@ int synaptics_init_relative(struct psmouse *psmouse)
  	return __synaptics_init(psmouse, false);
  }
 
-bool synaptics_supported(void)
-{
-	return true;
-}
-
  #else /* CONFIG_MOUSE_PS2_SYNAPTICS */
 
  void __init synaptics_module_init(void)
@@ -1833,9 +1828,4 @@ int synaptics_init(struct psmouse *psmouse)
  	return -ENOSYS;
  }
 
-bool synaptics_supported(void)
-{
-	return false;
-}
-
  #endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
drivers/input/mouse/synaptics.h +0 -1
index 1bd01f2..feb28a5 100644
@@ -191,6 +191,5 @@ int synaptics_detect(struct psmouse *psmouse, bool set_properties);
  int synaptics_init(struct psmouse *psmouse);
  int synaptics_init_relative(struct psmouse *psmouse);
  void synaptics_reset(struct psmouse *psmouse);
-bool synaptics_supported(void);
 
  #endif /* _SYNAPTICS_H */
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dmitry Torokhov
Quoted 5 lines · Dmitry Torokhov

Instead of having various protocols provide <protocol>_supported() functions, let's use IS_ENABLED() macro that works well in "if" statements.

---

Cheers,
Benjamin

Quoted 156 lines
 drivers/input/mouse/cypress_ps2.c  |  5 -----
 drivers/input/mouse/cypress_ps2.h  |  5 -----
 drivers/input/mouse/focaltech.c    | 10 ----------
 drivers/input/mouse/focaltech.h    |  1 -
 drivers/input/mouse/psmouse-base.c |  6 +++---
 drivers/input/mouse/synaptics.c    | 10 ----------
 drivers/input/mouse/synaptics.h    |  1 -
 7 files changed, 3 insertions(+), 35 deletions(-)
drivers/input/mouse/cypress_ps2.c +0 -5
index 8af34ff..6e5f70b 100644
@@ -710,8 +710,3 @@ err_exit:
 
 	return -1;
 }
-
-bool cypress_supported(void)
-{
-	return true;
-}
drivers/input/mouse/cypress_ps2.h +0 -5
index 4720f21..81f68aa 100644
@@ -172,7 +172,6 @@ struct cytp_data {
 #ifdef CONFIG_MOUSE_PS2_CYPRESS
 int cypress_detect(struct psmouse *psmouse, bool set_properties);
 int cypress_init(struct psmouse *psmouse);
-bool cypress_supported(void);
 #else
 inline int cypress_detect(struct psmouse *psmouse, bool set_properties)
 {
@@ -182,10 +181,6 @@ inline int cypress_init(struct psmouse *psmouse)
 {
 	return -ENOSYS;
 }
-inline bool cypress_supported(void)
-{
-	return 0;
-}
 #endif /* CONFIG_MOUSE_PS2_CYPRESS */
 
 #endif  /* _CYPRESS_PS2_H */
drivers/input/mouse/focaltech.c +0 -10
index fca38ba..757f78a 100644
@@ -424,11 +424,6 @@ fail:
 	return error;
 }
 
-bool focaltech_supported(void)
-{
-	return true;
-}
-
 #else /* CONFIG_MOUSE_PS2_FOCALTECH */
 
 int focaltech_init(struct psmouse *psmouse)
@@ -438,9 +433,4 @@ int focaltech_init(struct psmouse *psmouse)
 	return 0;
 }
 
-bool focaltech_supported(void)
-{
-	return false;
-}
-
 #endif /* CONFIG_MOUSE_PS2_FOCALTECH */
drivers/input/mouse/focaltech.h +0 -1
index 71870a9..ca61ebf 100644
@@ -19,6 +19,5 @@
 
 int focaltech_detect(struct psmouse *psmouse, bool set_properties);
 int focaltech_init(struct psmouse *psmouse);
-bool focaltech_supported(void);
 
 #endif
drivers/input/mouse/psmouse-base.c +3 -3
index 68469fe..4ccd01d 100644
@@ -727,7 +727,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
 	if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
 		if (max_proto > PSMOUSE_IMEX) {
 			if (!set_properties || focaltech_init(psmouse) == 0) {
-				if (focaltech_supported())
+				if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH))
 					return PSMOUSE_FOCALTECH;
 				/*
 				 * Note that we need to also restrict
@@ -776,7 +776,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
  * Try activating protocol, but check if support is enabled first, since
  * we try detecting Synaptics even when protocol is disabled.
  */
-			if (synaptics_supported() &&
+			if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) &&
 			    (!set_properties || synaptics_init(psmouse) == 0)) {
 				return PSMOUSE_SYNAPTICS;
 			}
@@ -801,7 +801,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
  */
 	if (max_proto > PSMOUSE_IMEX &&
 			cypress_detect(psmouse, set_properties) == 0) {
-		if (cypress_supported()) {
+		if (IS_ENABLED(CONFIG_MOUSE_PS2_CYPRESS)) {
 			if (cypress_init(psmouse) == 0)
 				return PSMOUSE_CYPRESS;
 
drivers/input/mouse/synaptics.c +0 -10
index f947292..094bf64 100644
@@ -1817,11 +1817,6 @@ int synaptics_init_relative(struct psmouse *psmouse)
 	return __synaptics_init(psmouse, false);
 }
 
-bool synaptics_supported(void)
-{
-	return true;
-}
-
 #else /* CONFIG_MOUSE_PS2_SYNAPTICS */
 
 void __init synaptics_module_init(void)
@@ -1833,9 +1828,4 @@ int synaptics_init(struct psmouse *psmouse)
 	return -ENOSYS;
 }
 
-bool synaptics_supported(void)
-{
-	return false;
-}
-
 #endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
drivers/input/mouse/synaptics.h +0 -1
index 1bd01f2..feb28a5 100644
@@ -191,6 +191,5 @@ int synaptics_detect(struct psmouse *psmouse, bool set_properties);
 int synaptics_init(struct psmouse *psmouse);
 int synaptics_init_relative(struct psmouse *psmouse);
 void synaptics_reset(struct psmouse *psmouse);
-bool synaptics_supported(void);
 
 #endif /* _SYNAPTICS_H */
Signature · 5 lines
2.2.0.rc0.207.ga3a616c


-- 
Dmitry