Skip to contentSkip to conversation

fixed coding style issues

PATCH In review Baodong Chen 3 participants 6 messages Jul 25, 2012 – Jul 30, 2012

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

PATCH 1/1 fixed coding style issues

Fexed coding style issues from scripts/checkpatch.pl in drivers/input

---
 drivers/input/apm-power.c     |    2 +-
 drivers/input/evdev.c         |   52 +++++++++++++++++++++++++++++++---------
 drivers/input/ff-core.c       |    4 +-
 drivers/input/ff-memless.c    |   12 ++++----
 drivers/input/joydev.c        |    2 +-
 drivers/input/mousedev.c      |   32 ++++++++++++++++--------
 drivers/input/sparse-keymap.c |    4 +-
 7 files changed, 73 insertions(+), 35 deletions(-)
drivers/input/apm-power.c +1 -1
index e90ee3d..543d85b 100644
@@ -33,7 +33,7 @@ static void system_power_event(unsigned int keycode)
 }
 
 static void apmpower_event(struct input_handle *handle, unsigned int type,
-		        unsigned int code, int value)
+			unsigned int code, int value)
 {
 	/* only react on key down events */
 	if (value != 1)
drivers/input/evdev.c +40 -12

64 lines not on this page · raw message

drivers/input/ff-core.c +2 -2
index 480eb9d..f50f6dd 100644
@@ -138,8 +138,8 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect,
 
 	if (effect->id == -1) {
 		for (id = 0; id < ff->max_effects; id++)
-		     if (!ff->effect_owners[id])
-			break;
+			if (!ff->effect_owners[id])
+				break;
 
 		if (id >= ff->max_effects) {
 			ret = -ENOSPC;
drivers/input/ff-memless.c +6 -6
index 5f55885..a237cf2 100644
@@ -72,12 +72,12 @@ static const struct ff_envelope *get_envelope(const struct ff_effect *effect)
 	static const struct ff_envelope empty_envelope;
 
 	switch (effect->type) {
-		case FF_PERIODIC:
-			return &effect->u.periodic.envelope;
-		case FF_CONSTANT:
-			return &effect->u.constant.envelope;
-		default:
-			return &empty_envelope;
+	case FF_PERIODIC:
+		return &effect->u.periodic.envelope;
+	case FF_CONSTANT:
+		return &effect->u.constant.envelope;
+	default:
+		return &empty_envelope;
 	}
 }
 
drivers/input/joydev.c +1 -1
index 26043cc..78f323e 100644
@@ -711,7 +711,7 @@ static long joydev_ioctl(struct file *file,
 
 	case JS_SET_ALL:
 		retval = copy_from_user(&joydev->glue, argp,
-					sizeof(joydev->glue)) ? -EFAULT: 0;
+					sizeof(joydev->glue)) ? -EFAULT : 0;
 		break;
 
 	case JS_GET_ALL:
drivers/input/mousedev.c +21 -11
index 0110b5a..80bbe52 100644
@@ -236,25 +236,36 @@ static void mousedev_key_event(struct mousedev *mousedev,
 
 	case BTN_TOUCH:
 	case BTN_0:
-	case BTN_LEFT:		index = 0; break;
+	case BTN_LEFT:
+		index = 0;
+		break;
 
 	case BTN_STYLUS:
 	case BTN_1:
-	case BTN_RIGHT:		index = 1; break;
+	case BTN_RIGHT:
+		index = 1;
+		break;
 
 	case BTN_2:
 	case BTN_FORWARD:
 	case BTN_STYLUS2:
-	case BTN_MIDDLE:	index = 2; break;
+	case BTN_MIDDLE:
+		index = 2;
+		break;
 
 	case BTN_3:
 	case BTN_BACK:
-	case BTN_SIDE:		index = 3; break;
+	case BTN_SIDE:
+		index = 3;
+		break;
 
 	case BTN_4:
-	case BTN_EXTRA:		index = 4; break;
+	case BTN_EXTRA:
+		index = 4;
+		break;
 
-	default:		return;
+	default:
+		return;
 	}
 
 	if (value) {
@@ -551,17 +562,16 @@ static int mousedev_open(struct inode *inode, struct file *file)
 		return -ENODEV;
 
 	error = mutex_lock_interruptible(&mousedev_table_mutex);
-	if (error) {
+	if (error)
 		return error;
-	}
+
 	mousedev = mousedev_table[i];
 	if (mousedev)
 		get_device(&mousedev->dev);
 	mutex_unlock(&mousedev_table_mutex);
 
-	if (!mousedev) {
+	if (!mousedev)
 		return -ENODEV;
-	}
 
 	client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
 	if (!client) {
@@ -1088,7 +1098,7 @@ static int __init mousedev_init(void)
 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
 	error = misc_register(&psaux_mouse);
 	if (error)
-		pr_warning("could not register psaux device, error: %d\n",
+		pr_warn("could not register psaux device, error: %d\n",
 			   error);
 	else
 		psaux_registered = 1;
drivers/input/sparse-keymap.c +2 -2
index 75fb040..a70aa55 100644
@@ -180,11 +180,11 @@ int sparse_keymap_setup(struct input_dev *dev,
 	for (e = keymap; e->type != KE_END; e++)
 		map_size++;
 
-	map = kcalloc(map_size, sizeof (struct key_entry), GFP_KERNEL);
+	map = kcalloc(map_size, sizeof(struct key_entry), GFP_KERNEL);
 	if (!map)
 		return -ENOMEM;
 
-	memcpy(map, keymap, map_size * sizeof (struct key_entry));
+	memcpy(map, keymap, map_size * sizeof(struct key_entry));
 
 	for (i = 0; i < map_size; i++) {
 		entry = &map[i];
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 1 line · Baodong Chen

Fexed coding style issues from scripts/checkpatch.pl in drivers/input

Not all checkpatch messages need to be "fexed". :)

Please use some taste and judgment before submitting patches based solely on checkpatch output.

drivers/input/apm-power.c

Quoted 1 line
drivers/input/apm-power.c +0 -0

[]

drivers/input/apm-power.c static void system_power_event(unsigned int keycode) · line 36

Quoted 6 lines
drivers/input/apm-power.c +1 -1
@@ -33,7 +33,7 @@ static void system_power_event(unsigned int keycode)
 }
 
 static void apmpower_event(struct input_handle *handle, unsigned int type,
-		        unsigned int code, int value)
+			unsigned int code, int value)

Perhaps prefer alignment to immediately after open parenthesis.

drivers/input/evdev.c

Quoted 1 line
drivers/input/evdev.c +0 -0

[]

drivers/input/evdev.c static int handle_eviocgbit(struct input_dev *dev, · line 550

Quoted 5 lines
drivers/input/evdev.c +0 -1
@@ -547,16 +547,44 @@ static int handle_eviocgbit(struct input_dev *dev,
 
 	switch (type) {
 
-	case      0: bits = dev->evbit;  len = EV_MAX;  break;

[]

drivers/input/evdev.c static int handle_eviocgbit(struct input_dev *dev, · line 553

Quoted 4 lines
drivers/input/evdev.c +4 -0
+	case      0:
+		bits = dev->evbit;
+		len = EV_MAX;
+		break;

not all that better really.

drivers/input/evdev.c static int handle_eviocgbit(struct input_dev *dev, · line 599

Quoted 8 lines
drivers/input/evdev.c +2 -2
@@ -567,8 +595,8 @@ static int handle_eviocgbit(struct input_dev *dev,
 	if (type == EV_KEY && size == OLD_KEY_MAX) {
 		len = OLD_KEY_MAX;
 		if (printk_timed_ratelimit(&keymax_warn_time, 10 * 1000))
-			pr_warning("(EVIOCGBIT): Suspicious buffer size %u, "
-				   "limiting output to %zu bytes. See "
+			pr_warn("(EVIOCGBIT): Suspicious buffer size %u, " \
+				   "limiting output to %zu bytes. See "	\

The line continuations are also not necessary and I think are really ugly. Just coalesce the format.

drivers/input/evdev.c static int handle_eviocgbit(struct input_dev *dev, · line 600

Quoted 1 line
drivers/input/evdev.c +0 -0
 				   "http://userweb.kernel.org/~dtor/eviocgbit-bug.html\n",

dead link I think.

drivers/input/ff-core.c

Quoted 1 line
drivers/input/ff-core.c +0 -0

[]

drivers/input/ff-core.c int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, · line 142

Quoted 8 lines
drivers/input/ff-core.c +2 -2
@@ -138,8 +138,8 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect,
 
 	if (effect->id == -1) {
 		for (id = 0; id < ff->max_effects; id++)
-		     if (!ff->effect_owners[id])
-			break;
+			if (!ff->effect_owners[id])
+				break;

Better surrounded by braces too.

cheers, Joe

#2 lore raw

i want to participate in and to start from
fixing simple issues!
how could i choose issues form checkpatch's output to find which should be fixed which are
not?
or checkpatch.pl should be updated??

Quoted 71 lines · Joe Perches
Quoted 1 line · Baodong Chen

Fexed coding style issues from scripts/checkpatch.pl in drivers/input

Not all checkpatch messages need to be "fexed". :)

Please use some taste and judgment before submitting patches based solely on checkpatch output.

drivers/input/apm-power.c

Quoted 1 line
drivers/input/apm-power.c +0 -0

[]

drivers/input/apm-power.c static void system_power_event(unsigned int keycode) · line 37

Quoted 7 lines
drivers/input/apm-power.c +1 -1
@@ -33,7 +33,7 @@ static void system_power_event(unsigned int keycode)
 }
 
 static void apmpower_event(struct input_handle *handle, unsigned int
 type,
-                     unsigned int code, int value)
+                     unsigned int code, int value)

Perhaps prefer alignment to immediately after open parenthesis.

drivers/input/evdev.c

Quoted 1 line
drivers/input/evdev.c +0 -0

[]

drivers/input/evdev.c static int handle_eviocgbit(struct input_dev *dev, · line 550

Quoted 5 lines
drivers/input/evdev.c +0 -1
@@ -547,16 +547,44 @@ static int handle_eviocgbit(struct input_dev *dev,
 
      switch (type) {
 
-     case      0: bits = dev->evbit;  len = EV_MAX;  break;

[]

drivers/input/evdev.c static int handle_eviocgbit(struct input_dev *dev, · line 553

Quoted 4 lines
drivers/input/evdev.c +4 -0
+     case      0:
+             bits = dev->evbit;
+             len = EV_MAX;
+             break;

not all that better really.

Quoted 10 lines
drivers/input/evdev.c +0 -1
@@ -567,8 +595,8 @@ static int handle_eviocgbit(struct input_dev *dev,
      if (type == EV_KEY && size == OLD_KEY_MAX) {
              len = OLD_KEY_MAX;
              if (printk_timed_ratelimit(&keymax_warn_time, 10 * 1000))
-                     pr_warning("(EVIOCGBIT): Suspicious buffer size %u,

"

drivers/input/evdev.c +1 -1
-                                "limiting output to %zu bytes. See "
+                     pr_warn("(EVIOCGBIT): Suspicious buffer size %u, "

\
+ "limiting output to %zu bytes. See " \

The line continuations are also not necessary and I think are really ugly. Just coalesce the format.

Quoted 2 lines

"http://userweb.kernel.org/~dtor/eviocgbit-bug.html\n",

dead link I think.

drivers/input/ff-core.c

Quoted 1 line
drivers/input/ff-core.c +0 -0

[]

drivers/input/ff-core.c int input_ff_upload(struct input_dev *dev, struct · line 143

Quoted 9 lines
drivers/input/ff-core.c +2 -2
@@ -138,8 +138,8 @@ int input_ff_upload(struct input_dev *dev, struct
 ff_effect *effect,
 
      if (effect->id == -1) {
              for (id = 0; id < ff->max_effects; id++)
-                  if (!ff->effect_owners[id])
-                     break;
+                     if (!ff->effect_owners[id])
+                             break;

Better surrounded by braces too.

cheers, Joe

#3 lore raw
Quoted 2 lines · Baodong Chen

i want to participate in and to start from
fixing simple issues!

That's fine Baodong. Welcome.

Quoted 3 lines

how could i choose issues form checkpatch's output to find which should be fixed which are
not?

checkpatch output is merely a guide for submission of patches to conform to some generic "kernel style". I think there are times when really ugly code should have a pass to make it more "kernel style" like. Most of those cleanup type changes should be done only to code in the "drivers/staging" directory.

I think most of the time, unless you are also fixing some other underlying code defect or shortcoming, checkpatch only cleanups to existing code are best avoided.

I suggest for now, until you are really comfortable with the preferred style, you confine yourself to drivers/staging.

Quoted 1 line

or checkpatch.pl should be updated??

You could work on that too.

One possibility is to write a utility to take checkpatch output and generate patches automatically, or perhaps extend checkpatch itself to do that. (ie: add a --fix option)

cheers, Joe

#4 lore raw
Quoted 16 lines · Joe Perches
Quoted 2 lines · Baodong Chen

i want to participate in and to start from
fixing simple issues!

That's fine Baodong. Welcome.

Quoted 3 lines

how could i choose issues form checkpatch's output to find which should be fixed which are
not?

checkpatch output is merely a guide for submission of patches to conform to some generic "kernel style". I think there are times when really ugly code should have a pass to make it more "kernel style" like. Most of those cleanup type changes should be done only to code in the "drivers/staging" directory.

Quoted 7 lines

I think most of the time, unless you are also fixing some other underlying code defect or shortcoming, checkpatch only cleanups to existing code are best avoided.

I suggest for now, until you are really comfortable with the preferred style, you confine yourself to drivers/staging.

hi,Joe;
thank for your explaining!
ok, i will start from drivers/staging

Quoted 10 lines
Quoted 1 line

or checkpatch.pl should be updated??

You could work on that too.

One possibility is to write a utility to take checkpatch output and generate patches automatically, or perhaps extend checkpatch itself to do that. (ie: add a --fix option)

cheers, Joe

maintainer
#5 lore raw
In reply to Baodong Chen

Hi Baodong,

Quoted 2 lines · Baodong Chen

Fexed coding style issues from scripts/checkpatch.pl in drivers/input

Thank you for your patch. I picked up the parts that made sense and dropped the rest.

Thanks.

Signature · 1 line
Dmitry