* [PATCH 0/6] ACPI: Fine-tuning for some function implementations
@ 2017-04-18 16:48 SF Markus Elfring
2017-04-18 16:50 ` [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps() SF Markus Elfring
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-18 16:48 UTC (permalink / raw)
To: linux-acpi, Borislav Petkov, Chun-Yi Lee, Colin Ian King,
Dan Williams, Len Brown, Linda Knippers, Rafael J. Wysocki,
Tony Luck, Vishal Verma, Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 18:28:18 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (6):
fan: Use devm_kcalloc() in acpi_fan_get_fps()
fan: Delete error messages for a failed memory allocation in two functions
nfit: Use devm_kcalloc() in nfit_mem_dcr_init()
einj: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show()
battery: Replace 16 seq_printf() calls by seq_puts()
proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show()
drivers/acpi/apei/einj.c | 25 +++++++++++++------------
drivers/acpi/battery.c | 34 +++++++++++++++++-----------------
drivers/acpi/fan.c | 9 +++------
drivers/acpi/nfit/core.c | 8 +++++---
drivers/acpi/proc.c | 4 ++--
5 files changed, 40 insertions(+), 40 deletions(-)
--
2.12.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps()
2017-04-18 16:48 [PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring
@ 2017-04-18 16:50 ` SF Markus Elfring
2017-04-18 16:51 ` [PATCH 2/6] ACPI-fan: Delete error messages for a failed memory allocation in two functions SF Markus Elfring
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-18 16:50 UTC (permalink / raw)
To: linux-acpi, Borislav Petkov, Chun-Yi Lee, Colin Ian King,
Dan Williams, Len Brown, Linda Knippers, Rafael J. Wysocki,
Tony Luck, Vishal Verma, Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:00:39 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/fan.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 6cf4988206f2..92878c7c523b 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -298,8 +298,7 @@ static int acpi_fan_get_fps(struct acpi_device *device)
}
fan->fps_count = obj->package.count - 1; /* minus revision field */
- fan->fps = devm_kzalloc(&device->dev,
- fan->fps_count * sizeof(struct acpi_fan_fps),
+ fan->fps = devm_kcalloc(&device->dev, fan->fps_count, sizeof(*fan->fps),
GFP_KERNEL);
if (!fan->fps) {
dev_err(&device->dev, "Not enough memory\n");
--
2.12.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] ACPI-fan: Delete error messages for a failed memory allocation in two functions
2017-04-18 16:48 [PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring
2017-04-18 16:50 ` [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps() SF Markus Elfring
@ 2017-04-18 16:51 ` SF Markus Elfring
2017-04-18 16:53 ` [PATCH 3/6] ACPI-nfit: Use devm_kcalloc() in nfit_mem_dcr_init() SF Markus Elfring
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-18 16:51 UTC (permalink / raw)
To: linux-acpi, Borislav Petkov, Chun-Yi Lee, Colin Ian King,
Dan Williams, Len Brown, Linda Knippers, Rafael J. Wysocki,
Tony Luck, Vishal Verma, Zhang Rui
Cc: LKML, kernel-janitors, Wolfram Sang
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:10:40 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: Possible unnecessary 'out of memory' message
Thus remove such statements here.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/fan.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 92878c7c523b..daa8f28a4b0e 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -301,7 +301,6 @@ static int acpi_fan_get_fps(struct acpi_device *device)
fan->fps = devm_kcalloc(&device->dev, fan->fps_count, sizeof(*fan->fps),
GFP_KERNEL);
if (!fan->fps) {
- dev_err(&device->dev, "Not enough memory\n");
status = -ENOMEM;
goto err;
}
@@ -334,10 +333,9 @@ static int acpi_fan_probe(struct platform_device *pdev)
char *name;
fan = devm_kzalloc(&pdev->dev, sizeof(*fan), GFP_KERNEL);
- if (!fan) {
- dev_err(&device->dev, "No memory for fan\n");
+ if (!fan)
return -ENOMEM;
- }
+
device->driver_data = fan;
platform_set_drvdata(pdev, fan);
--
2.12.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] ACPI-nfit: Use devm_kcalloc() in nfit_mem_dcr_init()
2017-04-18 16:48 [PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring
2017-04-18 16:50 ` [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps() SF Markus Elfring
2017-04-18 16:51 ` [PATCH 2/6] ACPI-fan: Delete error messages for a failed memory allocation in two functions SF Markus Elfring
@ 2017-04-18 16:53 ` SF Markus Elfring
2017-04-18 16:54 ` [PATCH 4/6] ACPI-APEI-EINJ: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show() SF Markus Elfring
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-18 16:53 UTC (permalink / raw)
To: linux-acpi, Borislav Petkov, Chun-Yi Lee, Colin Ian King,
Dan Williams, Len Brown, Linda Knippers, Rafael J. Wysocki,
Tony Luck, Vishal Verma, Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:30:15 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/nfit/core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 462e77272272..1aa625dc424a 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -809,9 +809,11 @@ static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
continue;
nfit_mem->nfit_flush = nfit_flush;
flush = nfit_flush->flush;
- nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev,
- flush->hint_count
- * sizeof(struct resource), GFP_KERNEL);
+ nfit_mem->flush_wpq
+ = devm_kcalloc(acpi_desc->dev,
+ flush->hint_count,
+ sizeof(*nfit_mem->flush_wpq),
+ GFP_KERNEL);
if (!nfit_mem->flush_wpq)
return -ENOMEM;
for (i = 0; i < flush->hint_count; i++) {
--
2.12.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] ACPI-APEI-EINJ: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show()
2017-04-18 16:48 [PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-04-18 16:53 ` [PATCH 3/6] ACPI-nfit: Use devm_kcalloc() in nfit_mem_dcr_init() SF Markus Elfring
@ 2017-04-18 16:54 ` SF Markus Elfring
2017-04-18 16:55 ` [PATCH 5/6] ACPI-battery: Replace 16 seq_printf() calls by seq_puts() SF Markus Elfring
2017-04-18 16:56 ` [PATCH 6/6] ACPI-proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show() SF Markus Elfring
5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-18 16:54 UTC (permalink / raw)
To: linux-acpi, Borislav Petkov, Chun-Yi Lee, Colin Ian King,
Dan Williams, Len Brown, Linda Knippers, Rafael J. Wysocki,
Tony Luck, Vishal Verma, Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:50:12 +0200
Strings which did not contain data format specifications should be put
into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/apei/einj.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index ec50c32ea3da..b2bb7c764cdb 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -580,29 +580,30 @@ static int available_error_type_show(struct seq_file *m, void *v)
if (rc)
return rc;
if (available_error_type & 0x0001)
- seq_printf(m, "0x00000001\tProcessor Correctable\n");
+ seq_puts(m, "0x00000001\tProcessor Correctable\n");
if (available_error_type & 0x0002)
- seq_printf(m, "0x00000002\tProcessor Uncorrectable non-fatal\n");
+ seq_puts(m, "0x00000002\tProcessor Uncorrectable non-fatal\n");
if (available_error_type & 0x0004)
- seq_printf(m, "0x00000004\tProcessor Uncorrectable fatal\n");
+ seq_puts(m, "0x00000004\tProcessor Uncorrectable fatal\n");
if (available_error_type & 0x0008)
- seq_printf(m, "0x00000008\tMemory Correctable\n");
+ seq_puts(m, "0x00000008\tMemory Correctable\n");
if (available_error_type & 0x0010)
- seq_printf(m, "0x00000010\tMemory Uncorrectable non-fatal\n");
+ seq_puts(m, "0x00000010\tMemory Uncorrectable non-fatal\n");
if (available_error_type & 0x0020)
- seq_printf(m, "0x00000020\tMemory Uncorrectable fatal\n");
+ seq_puts(m, "0x00000020\tMemory Uncorrectable fatal\n");
if (available_error_type & 0x0040)
- seq_printf(m, "0x00000040\tPCI Express Correctable\n");
+ seq_puts(m, "0x00000040\tPCI Express Correctable\n");
if (available_error_type & 0x0080)
- seq_printf(m, "0x00000080\tPCI Express Uncorrectable non-fatal\n");
+ seq_puts(m,
+ "0x00000080\tPCI Express Uncorrectable non-fatal\n");
if (available_error_type & 0x0100)
- seq_printf(m, "0x00000100\tPCI Express Uncorrectable fatal\n");
+ seq_puts(m, "0x00000100\tPCI Express Uncorrectable fatal\n");
if (available_error_type & 0x0200)
- seq_printf(m, "0x00000200\tPlatform Correctable\n");
+ seq_puts(m, "0x00000200\tPlatform Correctable\n");
if (available_error_type & 0x0400)
- seq_printf(m, "0x00000400\tPlatform Uncorrectable non-fatal\n");
+ seq_puts(m, "0x00000400\tPlatform Uncorrectable non-fatal\n");
if (available_error_type & 0x0800)
- seq_printf(m, "0x00000800\tPlatform Uncorrectable fatal\n");
+ seq_puts(m, "0x00000800\tPlatform Uncorrectable fatal\n");
return 0;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] ACPI-battery: Replace 16 seq_printf() calls by seq_puts()
2017-04-18 16:48 [PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring
` (3 preceding siblings ...)
2017-04-18 16:54 ` [PATCH 4/6] ACPI-APEI-EINJ: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show() SF Markus Elfring
@ 2017-04-18 16:55 ` SF Markus Elfring
2017-04-18 16:56 ` [PATCH 6/6] ACPI-proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show() SF Markus Elfring
5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-18 16:55 UTC (permalink / raw)
To: linux-acpi, Borislav Petkov, Chun-Yi Lee, Colin Ian King,
Dan Williams, Len Brown, Linda Knippers, Rafael J. Wysocki,
Tony Luck, Vishal Verma, Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 18:04:22 +0200
Strings which did not contain data format specifications should be put
into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/battery.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 4ef1e4624b2b..d217e1c18b42 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -825,14 +825,14 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
if (!acpi_battery_present(battery))
goto end;
if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "design capacity: unknown\n");
+ seq_puts(seq, "design capacity: unknown\n");
else
seq_printf(seq, "design capacity: %d %sh\n",
battery->design_capacity,
acpi_battery_units(battery));
if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "last full capacity: unknown\n");
+ seq_puts(seq, "last full capacity: unknown\n");
else
seq_printf(seq, "last full capacity: %d %sh\n",
battery->full_charge_capacity,
@@ -842,7 +842,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
(!battery->technology)?"non-":"");
if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "design voltage: unknown\n");
+ seq_puts(seq, "design voltage: unknown\n");
else
seq_printf(seq, "design voltage: %d mV\n",
battery->design_voltage);
@@ -865,7 +865,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
seq_printf(seq, "OEM info: %s\n", battery->oem_info);
end:
if (result)
- seq_printf(seq, "ERROR: Unable to read battery info\n");
+ seq_puts(seq, "ERROR: Unable to read battery info\n");
return result;
}
@@ -884,34 +884,34 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)
seq_printf(seq, "capacity state: %s\n",
(battery->state & 0x04) ? "critical" : "ok");
if ((battery->state & 0x01) && (battery->state & 0x02))
- seq_printf(seq,
- "charging state: charging/discharging\n");
+ seq_puts(seq,
+ "charging state: charging/discharging\n");
else if (battery->state & 0x01)
- seq_printf(seq, "charging state: discharging\n");
+ seq_puts(seq, "charging state: discharging\n");
else if (battery->state & 0x02)
- seq_printf(seq, "charging state: charging\n");
+ seq_puts(seq, "charging state: charging\n");
else
- seq_printf(seq, "charging state: charged\n");
+ seq_puts(seq, "charging state: charged\n");
if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "present rate: unknown\n");
+ seq_puts(seq, "present rate: unknown\n");
else
seq_printf(seq, "present rate: %d %s\n",
battery->rate_now, acpi_battery_units(battery));
if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "remaining capacity: unknown\n");
+ seq_puts(seq, "remaining capacity: unknown\n");
else
seq_printf(seq, "remaining capacity: %d %sh\n",
battery->capacity_now, acpi_battery_units(battery));
if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "present voltage: unknown\n");
+ seq_puts(seq, "present voltage: unknown\n");
else
seq_printf(seq, "present voltage: %d mV\n",
battery->voltage_now);
end:
if (result)
- seq_printf(seq, "ERROR: Unable to read battery state\n");
+ seq_puts(seq, "ERROR: Unable to read battery state\n");
return result;
}
@@ -924,18 +924,18 @@ static int acpi_battery_print_alarm(struct seq_file *seq, int result)
goto end;
if (!acpi_battery_present(battery)) {
- seq_printf(seq, "present: no\n");
+ seq_puts(seq, "present: no\n");
goto end;
}
- seq_printf(seq, "alarm: ");
+ seq_puts(seq, "alarm: ");
if (!battery->alarm)
- seq_printf(seq, "unsupported\n");
+ seq_puts(seq, "unsupported\n");
else
seq_printf(seq, "%u %sh\n", battery->alarm,
acpi_battery_units(battery));
end:
if (result)
- seq_printf(seq, "ERROR: Unable to read battery alarm\n");
+ seq_puts(seq, "ERROR: Unable to read battery alarm\n");
return result;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] ACPI-proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show()
2017-04-18 16:48 [PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring
` (4 preceding siblings ...)
2017-04-18 16:55 ` [PATCH 5/6] ACPI-battery: Replace 16 seq_printf() calls by seq_puts() SF Markus Elfring
@ 2017-04-18 16:56 ` SF Markus Elfring
5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-18 16:56 UTC (permalink / raw)
To: linux-acpi, Borislav Petkov, Chun-Yi Lee, Colin Ian King,
Dan Williams, Len Brown, Linda Knippers, Rafael J. Wysocki,
Tony Luck, Vishal Verma, Zhang Rui
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 18:13:55 +0200
Strings which did not contain data format specifications should be put
into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/proc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index a34669cc823b..f17d5eb29609 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -23,7 +23,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
{
struct list_head *node, *next;
- seq_printf(seq, "Device\tS-state\t Status Sysfs node\n");
+ seq_puts(seq, "Device\tS-state\t Status Sysfs node\n");
mutex_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
@@ -55,7 +55,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
if (&entry->node !=
dev->physical_node_list.next)
- seq_printf(seq, "\t\t");
+ seq_puts(seq, "\t\t");
seq_printf(seq, "%c%-8s %s:%s\n",
dev->wakeup.flags.run_wake ? '*' : ' ',
--
2.12.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-04-18 16:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-18 16:48 [PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring
2017-04-18 16:50 ` [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps() SF Markus Elfring
2017-04-18 16:51 ` [PATCH 2/6] ACPI-fan: Delete error messages for a failed memory allocation in two functions SF Markus Elfring
2017-04-18 16:53 ` [PATCH 3/6] ACPI-nfit: Use devm_kcalloc() in nfit_mem_dcr_init() SF Markus Elfring
2017-04-18 16:54 ` [PATCH 4/6] ACPI-APEI-EINJ: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show() SF Markus Elfring
2017-04-18 16:55 ` [PATCH 5/6] ACPI-battery: Replace 16 seq_printf() calls by seq_puts() SF Markus Elfring
2017-04-18 16:56 ` [PATCH 6/6] ACPI-proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show() SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).