Skip to contentSkip to conversation

driver: thikpad_acpi: deal with checkpatch issues

PATCH New Konrad Zapalowicz 1 participant 12 messages Apr 21, 2014 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

cover driver: thikpad_acpi: deal with checkpatch issues

This serie of patches deals with the checkpatch errors and warnings found in the ./drivers/platform/x86/thinkpad_acpi.c file. In total approx. 76 items have been fixed and in particular these are:
- spaces required around that '?' (ctx:VxW)
- "foo* const bar" should be "foo * const bar"
- Prefer seq_puts to seq_printf
- Missing a blank line after declarations
- braces {} are not necessary for any arm of this statement
- inline keyword should sit between storage class and type
- static const char * array should probably be static const char * const
- simple_strtoul is obsolete, use kstrtoul instead
- __packed is preferred over __attribute__((packed))
- Missing a blank line after declarations
- Unnecessary space before function pointer arguments
- Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
- Prefer [subsystem eg: netdev]_dbg([subsystem]dev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...

The most significiant change is the "simple_strtoul is obsolete, use kstrtoul instead" therefore this patch should be reviewed carefully.

The linux-next tree (36efbdf) has been used as a base for this work.

Konrad Zapalowicz (11):
driver: thinkpad_acpi: add spaces around ?
driver: thinkpad_acpi: add parenthesis around complex macro
driver: thinkpad_acpi: fix minor checkpatch errors
driver: thinkpad_acpi: replace seq_printf with seq_puts
driver: thinkpad_acpi: add blank line after declaration
driver: thinkpad_acpi: remove unnecessary spaces
driver: thinkpad_acpi: remove not necessary {} braces
driver: thinkpad_acpi: replace printk with pr_debug
driver: thinkpad_acpi: replace simple_strtoul with kstrtoul
driver: thinkpad_acpi: fix minor checkpatch warnings
driver: thinkpad_acpi: remove spaces at the beginning

 drivers/platform/x86/thinkpad_acpi.c | 230 ++++++++++++++++++-----------------
 1 file changed, 119 insertions(+), 111 deletions(-)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/11 driver: thinkpad_acpi: add spaces around ?

This commit fixes the "spaces required around that '?' (ctx:VxW)" checkpatch errors in ./drivers/platform/x86/thinkpad_acpi.c file

---
 drivers/platform/x86/thinkpad_acpi.c | 42 ++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +21 -21
index 15e61c1..a306975 100644
@@ -3438,7 +3438,7 @@ err_exit:
 	delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj);
 	hotkey_dev_attributes = NULL;
 
-	return (res < 0)? res : 1;
+	return (res < 0) ? res : 1;
 }
 
 /* Thinkpad X1 Carbon support 5 modes including Home mode, Web browser
@@ -4574,7 +4574,7 @@ static int __init video_init(struct ibm_init_struct *iibm)
 		str_supported(video_supported != TPACPI_VIDEO_NONE),
 		video_supported);
 
-	return (video_supported != TPACPI_VIDEO_NONE)? 0 : 1;
+	return (video_supported != TPACPI_VIDEO_NONE) ? 0 : 1;
 }
 
 static void video_exit(void)
@@ -4667,7 +4667,7 @@ static int video_outputsw_set(int status)
 		return -ENOSYS;
 	}
 
-	return (res)? 0 : -EIO;
+	return (res) ? 0 : -EIO;
 }
 
 static int video_autosw_get(void)
@@ -4693,7 +4693,7 @@ static int video_autosw_get(void)
 
 static int video_autosw_set(int enable)
 {
-	if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", (enable)? 1 : 0))
+	if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", (enable) ? 1 : 0))
 		return -EIO;
 	return 0;
 }
@@ -4728,20 +4728,20 @@ static int video_outputsw_cycle(void)
 		return -EIO;
 	}
 
-	return (res)? 0 : -EIO;
+	return (res) ? 0 : -EIO;
 }
 
 static int video_expand_toggle(void)
 {
 	switch (video_supported) {
 	case TPACPI_VIDEO_570:
-		return acpi_evalf(ec_handle, NULL, "_Q17", "v")?
+		return acpi_evalf(ec_handle, NULL, "_Q17", "v") ?
 			0 : -EIO;
 	case TPACPI_VIDEO_770:
-		return acpi_evalf(vid_handle, NULL, "VEXP", "v")?
+		return acpi_evalf(vid_handle, NULL, "VEXP", "v") ?
 			0 : -EIO;
 	case TPACPI_VIDEO_NEW:
-		return acpi_evalf(NULL, NULL, "\\VEXP", "v")?
+		return acpi_evalf(NULL, NULL, "\\VEXP", "v") ?
 			0 : -EIO;
 	default:
 		return -ENOSYS;
@@ -4885,14 +4885,14 @@ static int light_set_status(int status)
 	if (tp_features.light) {
 		if (cmos_handle) {
 			rc = acpi_evalf(cmos_handle, NULL, NULL, "vd",
-					(status)?
+					(status) ?
 						TP_CMOS_THINKLIGHT_ON :
 						TP_CMOS_THINKLIGHT_OFF);
 		} else {
 			rc = acpi_evalf(lght_handle, NULL, NULL, "vd",
-					(status)? 1 : 0);
+					(status) ? 1 : 0);
 		}
-		return (rc)? 0 : -EIO;
+		return (rc) ? 0 : -EIO;
 	}
 
 	return -ENXIO;
@@ -4921,7 +4921,7 @@ static void light_sysfs_set(struct led_classdev *led_cdev,
 
 static enum led_brightness light_sysfs_get(struct led_classdev *led_cdev)
 {
-	return (light_get_status() == 1)? LED_FULL : LED_OFF;
+	return (light_get_status() == 1) ? LED_FULL : LED_OFF;
 }
 
 static struct tpacpi_led_classdev tpacpi_led_thinklight = {
@@ -5043,7 +5043,7 @@ static ssize_t cmos_command_store(struct device *dev,
 		return -EINVAL;
 
 	res = issue_thinkpad_cmos_command(cmos_cmd);
-	return (res)? res : count;
+	return (res) ? res : count;
 }
 
 static struct device_attribute dev_attr_cmos_command =
@@ -5067,7 +5067,7 @@ static int __init cmos_init(struct ibm_init_struct *iibm)
 	if (res)
 		return res;
 
-	return (cmos_handle)? 0 : 1;
+	return (cmos_handle) ? 0 : 1;
 }
 
 static void cmos_exit(void)
@@ -5177,9 +5177,9 @@ static int led_get_status(const unsigned int led)
 		if (!acpi_evalf(ec_handle,
 				&status, "GLED", "dd", 1 << led))
 			return -EIO;
-		led_s = (status == 0)?
+		led_s = (status == 0) ?
 				TPACPI_LED_OFF :
-				((status == 1)?
+				((status == 1) ?
 					TPACPI_LED_ON :
 					TPACPI_LED_BLINK);
 		tpacpi_led_state_cache[led] = led_s;
@@ -5576,7 +5576,7 @@ static int __init beep_init(struct ibm_init_struct *iibm)
 
 	tp_features.beep_needs_two_args = !!(quirks & TPACPI_BEEP_Q1);
 
-	return (beep_handle)? 0 : 1;
+	return (beep_handle) ? 0 : 1;
 }
 
 static int beep_read(struct seq_file *m)
@@ -6525,7 +6525,7 @@ static int brightness_write(char *buf)
 	if (!rc && ibm_backlight_device)
 		backlight_force_update(ibm_backlight_device,
 					BACKLIGHT_UPDATE_SYSFS);
-	return (rc == -EINTR)? -ERESTARTSYS : rc;
+	return (rc == -EINTR) ? -ERESTARTSYS : rc;
 }
 
 static struct ibm_struct brightness_driver_data = {
@@ -7982,7 +7982,7 @@ static ssize_t fan_pwm1_store(struct device *dev,
 	}
 
 	mutex_unlock(&fan_mutex);
-	return (rc)? rc : count;
+	return (rc) ? rc : count;
 }
 
 static struct device_attribute dev_attr_fan_pwm1 =
@@ -8660,7 +8660,7 @@ static const char * __init str_supported(int is_supported)
 {
 	static char text_unsupported[] __initdata = "not supported";
 
-	return (is_supported)? &text_unsupported[4] : &text_unsupported[0];
+	return (is_supported) ? &text_unsupported[4] : &text_unsupported[0];
 }
 #endif /* CONFIG_THINKPAD_ACPI_DEBUG */
 
@@ -8781,7 +8781,7 @@ err_out:
 		ibm->name, ret);
 
 	ibm_exit(ibm);
-	return (ret < 0)? ret : 0;
+	return (ret < 0) ? ret : 0;
 }
 
 /* Probing */
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/11 driver: thinkpad_acpi: add parenthesis around complex macro

This commit fixes the "Macros with complex values should be enclosed in parenthesis" checkpatch error.

---
 drivers/platform/x86/thinkpad_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/thinkpad_acpi.c +1 -1
index a306975..9506026 100644
@@ -5801,7 +5801,7 @@ static struct sensor_device_attribute sensor_dev_attr_thermal_temp_input[] = {
 };
 
 #define THERMAL_ATTRS(X) \
-	&sensor_dev_attr_thermal_temp_input[X].dev_attr.attr
+	(&sensor_dev_attr_thermal_temp_input[X].dev_attr.attr)
 
 static struct attribute *thermal_temp_input_attr[] = {
 	THERMAL_ATTRS(8),
Signature · 1 line
1.8.1.2
#3 lore raw

PATCH 3/11 driver: thinkpad_acpi: fix minor checkpatch errors

This commit fixes the following checkpatch errors:
- inline keyword should sit between storage class and type
- "foo* const bar" should be "foo * const bar"

---
 drivers/platform/x86/thinkpad_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +2 -2
index 9506026..7e1bc89 100644
@@ -7223,7 +7223,7 @@ static struct ibm_struct volume_driver_data = {
 
 #define alsa_card NULL
 
-static void inline volume_alsa_notify_change(void)
+static inline void volume_alsa_notify_change(void)
 {
 }
 
@@ -8792,7 +8792,7 @@ static bool __pure __init tpacpi_is_fw_digit(const char c)
 }
 
 /* Most models: xxyTkkWW (#.##c); Ancient 570/600 and -SL lacks (#.##c) */
-static bool __pure __init tpacpi_is_valid_fw_id(const char* const s,
+static bool __pure __init tpacpi_is_valid_fw_id(const char * const s,
 						const char t)
 {
 	return s && strlen(s) >= 8 &&
Signature · 1 line
1.8.1.2
#4 lore raw

PATCH 4/11 driver: thinkpad_acpi: replace seq_printf with seq_puts

This commit fixes the "Prefer seq_puts to seq_printf" checkpath warning plus it also fixes a few occurences of this issue not noticed by the script.

---
 drivers/platform/x86/thinkpad_acpi.c | 84 ++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 42 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +42 -42
index 7e1bc89..33fa7fc 100644
@@ -1370,7 +1370,7 @@ static ssize_t tpacpi_rfk_sysfs_enable_store(const enum tpacpi_rfk_id id,
 static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, struct seq_file *m)
 {
 	if (id >= TPACPI_RFK_SW_MAX)
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 	else {
 		int status;
 
@@ -1387,7 +1387,7 @@ static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, struct seq_file *
 		seq_printf(m, "status:\t\t%s\n",
 				(status == TPACPI_RFK_RADIO_ON) ?
 					"enabled" : "disabled");
-		seq_printf(m, "commands:\tenable, disable\n");
+		seq_puts(m, "commands:\tenable, disable\n");
 	}
 
 	return 0;
@@ -3888,7 +3888,7 @@ static int hotkey_read(struct seq_file *m)
 	int res, status;
 
 	if (!tp_features.hotkey) {
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 		return 0;
 	}
 
@@ -3904,10 +3904,10 @@ static int hotkey_read(struct seq_file *m)
 	seq_printf(m, "status:\t\t%s\n", enabled(status, 0));
 	if (hotkey_all_mask) {
 		seq_printf(m, "mask:\t\t0x%08x\n", hotkey_user_mask);
-		seq_printf(m, "commands:\tenable, disable, reset, <mask>\n");
+		seq_puts(m, "commands:\tenable, disable, reset, <mask>\n");
 	} else {
-		seq_printf(m, "mask:\t\tnot supported\n");
-		seq_printf(m, "commands:\tenable, disable, reset\n");
+		seq_puts(m, "mask:\t\tnot supported\n");
+		seq_puts(m, "commands:\tenable, disable, reset\n");
 	}
 
 	return 0;
@@ -4754,7 +4754,7 @@ static int video_read(struct seq_file *m)
 	int status, autosw;
 
 	if (video_supported == TPACPI_VIDEO_NONE) {
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 		return 0;
 	}
 
@@ -4770,18 +4770,18 @@ static int video_read(struct seq_file *m)
 	if (autosw < 0)
 		return autosw;
 
-	seq_printf(m, "status:\t\tsupported\n");
+	seq_puts(m, "status:\t\tsupported\n");
 	seq_printf(m, "lcd:\t\t%s\n", enabled(status, 0));
 	seq_printf(m, "crt:\t\t%s\n", enabled(status, 1));
 	if (video_supported == TPACPI_VIDEO_NEW)
 		seq_printf(m, "dvi:\t\t%s\n", enabled(status, 3));
 	seq_printf(m, "auto:\t\t%s\n", enabled(autosw, 0));
-	seq_printf(m, "commands:\tlcd_enable, lcd_disable\n");
-	seq_printf(m, "commands:\tcrt_enable, crt_disable\n");
+	seq_puts(m, "commands:\tlcd_enable, lcd_disable\n");
+	seq_puts(m, "commands:\tcrt_enable, crt_disable\n");
 	if (video_supported == TPACPI_VIDEO_NEW)
-		seq_printf(m, "commands:\tdvi_enable, dvi_disable\n");
-	seq_printf(m, "commands:\tauto_enable, auto_disable\n");
-	seq_printf(m, "commands:\tvideo_switch, expand_toggle\n");
+		seq_puts(m, "commands:\tdvi_enable, dvi_disable\n");
+	seq_puts(m, "commands:\tauto_enable, auto_disable\n");
+	seq_puts(m, "commands:\tvideo_switch, expand_toggle\n");
 
 	return 0;
 }
@@ -4985,16 +4985,16 @@ static int light_read(struct seq_file *m)
 	int status;
 
 	if (!tp_features.light) {
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 	} else if (!tp_features.light_status) {
-		seq_printf(m, "status:\t\tunknown\n");
-		seq_printf(m, "commands:\ton, off\n");
+		seq_puts(m, "status:\t\tunknown\n");
+		seq_puts(m, "commands:\ton, off\n");
 	} else {
 		status = light_get_status();
 		if (status < 0)
 			return status;
 		seq_printf(m, "status:\t\t%s\n", onoff(status, 0));
-		seq_printf(m, "commands:\ton, off\n");
+		seq_puts(m, "commands:\ton, off\n");
 	}
 
 	return 0;
@@ -5080,10 +5080,10 @@ static int cmos_read(struct seq_file *m)
 	/* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
 	   R30, R31, T20-22, X20-21 */
 	if (!cmos_handle)
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 	else {
-		seq_printf(m, "status:\t\tsupported\n");
-		seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n");
+		seq_puts(m, "status:\t\tsupported\n");
+		seq_puts(m, "commands:\t<cmd> (<cmd> is 0-21)\n");
 	}
 
 	return 0;
@@ -5482,10 +5482,10 @@ static int __init led_init(struct ibm_init_struct *iibm)
 static int led_read(struct seq_file *m)
 {
 	if (!led_supported) {
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 		return 0;
 	}
-	seq_printf(m, "status:\t\tsupported\n");
+	seq_puts(m, "status:\t\tsupported\n");
 
 	if (led_supported == TPACPI_LED_570) {
 		/* 570 */
@@ -5499,7 +5499,7 @@ static int led_read(struct seq_file *m)
 		}
 	}
 
-	seq_printf(m, "commands:\t"
+	seq_puts(m, "commands:\t"
 		       "<led> on, <led> off, <led> blink (<led> is 0-15)\n");
 
 	return 0;
@@ -5582,10 +5582,10 @@ static int __init beep_init(struct ibm_init_struct *iibm)
 static int beep_read(struct seq_file *m)
 {
 	if (!beep_handle)
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 	else {
-		seq_printf(m, "status:\t\tsupported\n");
-		seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n");
+		seq_puts(m, "status:\t\tsupported\n");
+		seq_puts(m, "commands:\t<cmd> (<cmd> is 0-17)\n");
 	}
 
 	return 0;
@@ -5956,14 +5956,14 @@ static int thermal_read(struct seq_file *m)
 	if (unlikely(n < 0))
 		return n;
 
-	seq_printf(m, "temperatures:\t");
+	seq_puts(m, "temperatures:\t");
 
 	if (n > 0) {
 		for (i = 0; i < (n - 1); i++)
 			seq_printf(m, "%d ", t.temp[i] / 1000);
 		seq_printf(m, "%d\n", t.temp[i] / 1000);
 	} else
-		seq_printf(m, "not supported\n");
+		seq_puts(m, "not supported\n");
 
 	return 0;
 }
@@ -6479,10 +6479,10 @@ static int brightness_read(struct seq_file *m)
 
 	level = brightness_get(NULL);
 	if (level < 0) {
-		seq_printf(m, "level:\t\tunreadable\n");
+		seq_puts(m, "level:\t\tunreadable\n");
 	} else {
 		seq_printf(m, "level:\t\t%d\n", level);
-		seq_printf(m, "commands:\tup, down\n");
+		seq_puts(m, "commands:\tup, down\n");
 		seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n",
 			       bright_maxlvl);
 	}
@@ -7109,10 +7109,10 @@ static int volume_read(struct seq_file *m)
 	u8 status;
 
 	if (volume_get_status(&status) < 0) {
-		seq_printf(m, "level:\t\tunreadable\n");
+		seq_puts(m, "level:\t\tunreadable\n");
 	} else {
 		if (tp_features.mixer_no_level_control)
-			seq_printf(m, "level:\t\tunsupported\n");
+			seq_puts(m, "level:\t\tunsupported\n");
 		else
 			seq_printf(m, "level:\t\t%d\n",
 					status & TP_EC_AUDIO_LVL_MSK);
@@ -7121,9 +7121,9 @@ static int volume_read(struct seq_file *m)
 				onoff(status, TP_EC_AUDIO_MUTESW));
 
 		if (volume_control_allowed) {
-			seq_printf(m, "commands:\tunmute, mute\n");
+			seq_puts(m, "commands:\tunmute, mute\n");
 			if (!tp_features.mixer_no_level_control) {
-				seq_printf(m,
+				seq_puts(m,
 					       "commands:\tup, down\n");
 				seq_printf(m,
 					       "commands:\tlevel <level>"
@@ -8336,40 +8336,40 @@ static int fan_read(struct seq_file *m)
 
 		if (status & TP_EC_FAN_FULLSPEED)
 			/* Disengaged mode takes precedence */
-			seq_printf(m, "level:\t\tdisengaged\n");
+			seq_puts(m, "level:\t\tdisengaged\n");
 		else if (status & TP_EC_FAN_AUTO)
-			seq_printf(m, "level:\t\tauto\n");
+			seq_puts(m, "level:\t\tauto\n");
 		else
 			seq_printf(m, "level:\t\t%d\n", status);
 		break;
 
 	case TPACPI_FAN_NONE:
 	default:
-		seq_printf(m, "status:\t\tnot supported\n");
+		seq_puts(m, "status:\t\tnot supported\n");
 	}
 
 	if (fan_control_commands & TPACPI_FAN_CMD_LEVEL) {
-		seq_printf(m, "commands:\tlevel <level>");
+		seq_puts(m, "commands:\tlevel <level>");
 
 		switch (fan_control_access_mode) {
 		case TPACPI_FAN_WR_ACPI_SFAN:
-			seq_printf(m, " (<level> is 0-7)\n");
+			seq_puts(m, " (<level> is 0-7)\n");
 			break;
 
 		default:
-			seq_printf(m, " (<level> is 0-7, "
+			seq_puts(m, " (<level> is 0-7, "
 				       "auto, disengaged, full-speed)\n");
 			break;
 		}
 	}
 
 	if (fan_control_commands & TPACPI_FAN_CMD_ENABLE)
-		seq_printf(m, "commands:\tenable, disable\n"
+		seq_puts(m, "commands:\tenable, disable\n"
 			       "commands:\twatchdog <timeout> (<timeout> "
 			       "is 0 (off), 1-120 (seconds))\n");
 
 	if (fan_control_commands & TPACPI_FAN_CMD_SPEED)
-		seq_printf(m, "commands:\tspeed <speed>"
+		seq_puts(m, "commands:\tspeed <speed>"
 			       " (<speed> is 0-65535)\n");
 
 	return 0;
Signature · 1 line
1.8.1.2
#5 lore raw

PATCH 5/11 driver: thinkpad_acpi: add blank line after declaration

This commit fixes the "Missing a blank line after declarations" checkpatch warning.

---
 drivers/platform/x86/thinkpad_acpi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/platform/x86/thinkpad_acpi.c +8 -0
index 33fa7fc..f846d79 100644
@@ -571,6 +571,7 @@ static int acpi_evalf(acpi_handle handle,
 	va_start(ap, fmt);
 	while (*fmt) {
 		char c = *(fmt++);
+
 		switch (c) {
 		case 'd':	/* int */
 			in_objs[params.count].integer.value = va_arg(ap, int);
@@ -696,6 +697,7 @@ static acpi_status __init tpacpi_acpi_handle_locate_callback(acpi_handle handle,
 			u32 level, void *context, void **return_value)
 {
 	struct acpi_device *dev;
+
 	if (!strcmp(context, "video")) {
 		if (acpi_bus_get_device(handle, &dev))
 			return AE_OK;
@@ -2839,6 +2841,7 @@ static ssize_t hotkey_radio_sw_show(struct device *dev,
 			   char *buf)
 {
 	int res;
+
 	res = hotkey_get_wlsw();
 	if (res < 0)
 		return res;
@@ -2866,6 +2869,7 @@ static ssize_t hotkey_tablet_mode_show(struct device *dev,
 			   char *buf)
 {
 	int res, s;
+
 	res = hotkey_get_tablet_mode(&s);
 	if (res < 0)
 		return res;
@@ -5490,6 +5494,7 @@ static int led_read(struct seq_file *m)
 	if (led_supported == TPACPI_LED_570) {
 		/* 570 */
 		int i, status;
+
 		for (i = 0; i < 8; i++) {
 			status = led_get_status(i);
 			if (status < 0)
@@ -6423,6 +6428,7 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
 							 &props);
 	if (IS_ERR(ibm_backlight_device)) {
 		int rc = PTR_ERR(ibm_backlight_device);
+
 		ibm_backlight_device = NULL;
 		pr_err("Could not register backlight device\n");
 		return rc;
@@ -8564,6 +8570,7 @@ static int mute_led_init(struct ibm_init_struct *iibm)
 
 	for (i = 0; i < TPACPI_LED_MAX; i++) {
 		struct tp_led_table *t = &led_tables[i];
+
 		if (ACPI_SUCCESS(acpi_get_handle(hkey_handle, t->name, &temp)))
 			mute_led_on_off(t, false);
 		else
@@ -8586,6 +8593,7 @@ static void mute_led_resume(void)
 
 	for (i = 0; i < TPACPI_LED_MAX; i++) {
 		struct tp_led_table *t = &led_tables[i];
+
 		if (t->state >= 0)
 			mute_led_on_off(t, t->state);
 	}
Signature · 1 line
1.8.1.2
#6 lore raw

PATCH 6/11 driver: thinkpad_acpi: remove unnecessary spaces

This commit fixes the "Unnecessary space before function pointer arguments" checkpatch warnings.

---
 drivers/platform/x86/thinkpad_acpi.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +8 -8
index f846d79..940f83b 100644
@@ -258,7 +258,7 @@ struct tp_acpi_drv_struct {
 	const struct acpi_device_id *hid;
 	struct acpi_driver *driver;
 
-	void (*notify) (struct ibm_struct *, u32);
+	void (*notify)(struct ibm_struct *, u32);
 	acpi_handle *handle;
 	u32 type;
 	struct acpi_device *device;
@@ -267,12 +267,12 @@ struct tp_acpi_drv_struct {
 struct ibm_struct {
 	char *name;
 
-	int (*read) (struct seq_file *);
-	int (*write) (char *);
-	void (*exit) (void);
-	void (*resume) (void);
-	void (*suspend) (void);
-	void (*shutdown) (void);
+	int (*read)(struct seq_file *);
+	int (*write)(char *);
+	void (*exit)(void);
+	void (*resume)(void);
+	void (*suspend)(void);
+	void (*shutdown)(void);
 
 	struct list_head all_drivers;
 
@@ -290,7 +290,7 @@ struct ibm_struct {
 struct ibm_init_struct {
 	char param[32];
 
-	int (*init) (struct ibm_init_struct *);
+	int (*init)(struct ibm_init_struct *);
 	umode_t base_procfs_mode;
 	struct ibm_struct *data;
 };
Signature · 1 line
1.8.1.2
#7 lore raw

PATCH 7/11 driver: thinkpad_acpi: remove not necessary {} braces

This commit fixes the "braces {} are not necessary for any arm of this statement" checkpatch warning.

---
 drivers/platform/x86/thinkpad_acpi.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +10 -11
index 940f83b..eba72e7 100644
@@ -5013,11 +5013,11 @@ static int light_write(char *buf)
 		return -ENODEV;
 
 	while ((cmd = next_cmd(&buf))) {
-		if (strlencmp(cmd, "on") == 0) {
+		if (strlencmp(cmd, "on") == 0)
 			newstatus = 1;
-		} else if (strlencmp(cmd, "off") == 0) {
+		else if (strlencmp(cmd, "off") == 0)
 			newstatus = 0;
-		} else
+		else
 			return -EINVAL;
 	}
 
@@ -5527,15 +5527,14 @@ static int led_write(char *buf)
 				tpacpi_leds[led].led < 0)
 			return -ENODEV;
 
-		if (strstr(cmd, "off")) {
+		if (strstr(cmd, "off"))
 			s = TPACPI_LED_OFF;
-		} else if (strstr(cmd, "on")) {
+		else if (strstr(cmd, "on"))
 			s = TPACPI_LED_ON;
-		} else if (strstr(cmd, "blink")) {
+		else if (strstr(cmd, "blink"))
 			s = TPACPI_LED_BLINK;
-		} else {
+		else
 			return -EINVAL;
-		}
 
 		rc = led_set_status(led, s);
 		if (rc < 0)
@@ -7878,11 +7877,11 @@ static ssize_t fan_pwm1_enable_show(struct device *dev,
 	if (res)
 		return res;
 
-	if (status & TP_EC_FAN_FULLSPEED) {
+	if (status & TP_EC_FAN_FULLSPEED)
 		mode = 0;
-	} else if (status & TP_EC_FAN_AUTO) {
+	else if (status & TP_EC_FAN_AUTO)
 		mode = 2;
-	} else
+	else
 		mode = 1;
 
 	return snprintf(buf, PAGE_SIZE, "%d\n", mode);
Signature · 1 line
1.8.1.2
#8 lore raw

PATCH 8/11 driver: thinkpad_acpi: replace printk with pr_debug

This commit fixes the "Prefer [subsystem eg: netdev]_dbg([subsystem] dev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG" checkpath warning.

---
 drivers/platform/x86/thinkpad_acpi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -3
index eba72e7..8631981 100644
@@ -389,7 +389,7 @@ static bool tpacpi_uwb_emulstate;
 #define dbg_printk(a_dbg_level, format, arg...)				\
 do {									\
 	if (dbg_level & (a_dbg_level))					\
-		printk(KERN_DEBUG pr_fmt("%s: " format),		\
+		pr_debug(pr_fmt("%s: " format),		\
 		       __func__, ##arg);				\
 } while (0)
 
@@ -404,7 +404,7 @@ static inline const char *str_supported(int is_supported) { return ""; }
 
 static void tpacpi_log_usertask(const char * const what)
 {
-	printk(KERN_DEBUG pr_fmt("%s: access by process with PID %d\n"),
+	pr_debug(pr_fmt("%s: access by process with PID %d\n"),
 	       what, task_tgid_vnr(current));
 }
 
@@ -412,7 +412,7 @@ static void tpacpi_log_usertask(const char * const what)
 do {									\
 	if (unlikely((dbg_level & TPACPI_DBG_DISCLOSETASK) &&		\
 		     (tpacpi_lifecycle == TPACPI_LIFE_RUNNING))) {	\
-		printk(KERN_DEBUG pr_fmt("%s: PID %d: " format),	\
+		pr_debug(pr_fmt("%s: PID %d: " format),	\
 		       what, task_tgid_vnr(current), ## arg);		\
 	}								\
 } while (0)
Signature · 1 line
1.8.1.2
#9 lore raw

PATCH 9/11 driver: thinkpad_acpi: replace simple_strtoul with kstrtoul

This commit fixes the "simple_strtoul is obsolete, use kstrtoul instead" checkpatch warning.

---
 drivers/platform/x86/thinkpad_acpi.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +8 -6
index 8631981..9456e3f 100644
@@ -1067,14 +1067,16 @@ static void delete_attr_set(struct attribute_set *s, struct kobject *kobj)
 static int parse_strtoul(const char *buf,
 		unsigned long max, unsigned long *value)
 {
-	char *endp;
+	int error = 0;
 
-	*value = simple_strtoul(skip_spaces(buf), &endp, 0);
-	endp = skip_spaces(endp);
-	if (*endp || *value > max)
-		return -EINVAL;
+	error = kstrtoul(skip_spaces(buf), 0, &(*value));
+	if (error)
+		goto out;
 
-	return 0;
+	if (*value > max)
+		error = -EINVAL;
+out:
+	return error;
 }
 
 static void tpacpi_disable_brightness_delay(void)
Signature · 1 line
1.8.1.2
#10 lore raw

PATCH 10/11 driver: thinkpad_acpi: fix minor checkpatch warnings

This commit fixes the following checkpatch warnings:
- Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
- __packed is preferred over __attribute__((packed))
- static const char * array should probably be static const char * const

---
 drivers/platform/x86/thinkpad_acpi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +4 -4
index 9456e3f..14da752 100644
@@ -82,7 +82,7 @@
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/initval.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 /* ThinkPad CMOS commands */
 #define TP_CMOS_VOLUME_DOWN	0
@@ -999,7 +999,7 @@ struct attribute_set {
 struct attribute_set_obj {
 	struct attribute_set s;
 	struct attribute *a;
-} __attribute__((packed));
+} __packed;
 
 static struct attribute_set *create_attr_set(unsigned int max_members,
 						const char *name)
@@ -1131,7 +1131,7 @@ enum tpacpi_rfk_id {
 	TPACPI_RFK_SW_MAX
 };
 
-static const char *tpacpi_rfkill_names[] = {
+static const char * const tpacpi_rfkill_names[] = {
 	[TPACPI_RFK_BLUETOOTH_SW_ID] = "bluetooth",
 	[TPACPI_RFK_WWAN_SW_ID] = "wwan",
 	[TPACPI_RFK_UWB_SW_ID] = "uwb",
@@ -2098,7 +2098,7 @@ static int hotkey_mask_get(void)
 	return 0;
 }
 
-void static hotkey_mask_warn_incomplete_mask(void)
+static void hotkey_mask_warn_incomplete_mask(void)
 {
 	/* log only what the user can fix... */
 	const u32 wantedmask = hotkey_driver_mask &
Signature · 1 line
1.8.1.2
#11 lore raw

PATCH 11/11 driver: thinkpad_acpi: remove spaces at the beginning

This commit fixes the "please, no spaces at the start of a line" checkpatch warning.

---
 drivers/platform/x86/thinkpad_acpi.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +12 -13
index 14da752..4593328 100644
@@ -1953,19 +1953,18 @@ enum {	/* NVRAM to ACPI HKEY group map */
 
 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
 struct tp_nvram_state {
-       u16 thinkpad_toggle:1;
-       u16 zoom_toggle:1;
-       u16 display_toggle:1;
-       u16 thinklight_toggle:1;
-       u16 hibernate_toggle:1;
-       u16 displayexp_toggle:1;
-       u16 display_state:1;
-       u16 brightness_toggle:1;
-       u16 volume_toggle:1;
-       u16 mute:1;
-
-       u8 brightness_level;
-       u8 volume_level;
+	u16 thinkpad_toggle:1;
+	u16 zoom_toggle:1;
+	u16 display_toggle:1;
+	u16 thinklight_toggle:1;
+	u16 hibernate_toggle:1;
+	u16 displayexp_toggle:1;
+	u16 display_state:1;
+	u16 brightness_toggle:1;
+	u16 volume_toggle:1;
+	u16 mute:1;
+	u8 brightness_level;
+	u8 volume_level;
 };
 
 /* kthread for the hotkey poller */
Signature · 1 line
1.8.1.2