* Re: [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
@ 2022-02-16 18:08 Guenter Roeck
2022-02-16 18:23 ` Eugene Shalygin
0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2022-02-16 18:08 UTC (permalink / raw)
To: Eugene Shalygin; +Cc: Jean Delvare, linux-hwmon, linux-kernel
On Wed, Feb 16, 2022 at 06:15:32PM +0100, Eugene Shalygin wrote:
> Merge configure_sensor_setup() into probe().
>
> Changes:
> - v2: add local struct device *dev = &pdev->dev;
> - v3: initialize dev at declaration
> - v4: fix checkpatch warning
> Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com>
$ scripts/checkpatch.pl --strict asus-ec
WARNING: braces {} are not necessary for single statement blocks
#55: FILE: drivers/hwmon/asus-ec-sensors.c:607:
+ if (!board_sensors) {
return -ENODEV;
}
CHECK: Alignment should match open parenthesis
#60: FILE: drivers/hwmon/asus-ec-sensors.c:612:
+ ec_data = devm_kzalloc(dev, sizeof(struct ec_sensors_data),
+ GFP_KERNEL);
WARNING: braces {} are not necessary for single statement blocks
#61: FILE: drivers/hwmon/asus-ec-sensors.c:613:
+ if (!ec_data) {
+ return -ENOMEM;
+ }
total: 0 errors, 2 warnings, 1 checks, 61 lines checked
> ---
> drivers/hwmon/asus-ec-sensors.c | 38 ++++++++++++++-------------------
> 1 file changed, 16 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
> index bfac08a5dc57..ef887168df20 100644
> --- a/drivers/hwmon/asus-ec-sensors.c
> +++ b/drivers/hwmon/asus-ec-sensors.c
> @@ -589,23 +589,33 @@ get_board_sensors(const struct device *dev)
> return (unsigned long)dmi_entry->driver_data;
> }
>
> -static int __init configure_sensor_setup(struct device *dev)
> +static int __init asus_ec_probe(struct platform_device *pdev)
> {
> - struct ec_sensors_data *ec_data = dev_get_drvdata(dev);
> + const struct hwmon_channel_info **ptr_asus_ec_ci;
> int nr_count[hwmon_max] = { 0 }, nr_types = 0;
> - struct device *hwdev;
> struct hwmon_channel_info *asus_ec_hwmon_chan;
> - const struct hwmon_channel_info **ptr_asus_ec_ci;
> const struct hwmon_chip_info *chip_info;
> + struct device *dev = &pdev->dev;
> + struct ec_sensors_data *ec_data;
> const struct ec_sensor_info *si;
> enum hwmon_sensor_types type;
> + unsigned long board_sensors;
> + struct device *hwdev;
> unsigned int i;
>
> - ec_data->board_sensors = get_board_sensors(dev);
> - if (!ec_data->board_sensors) {
> + board_sensors = get_board_sensors(dev);
> + if (!board_sensors) {
> return -ENODEV;
> }
>
> + ec_data = devm_kzalloc(dev, sizeof(struct ec_sensors_data),
> + GFP_KERNEL);
> + if (!ec_data) {
> + return -ENOMEM;
> + }
> +
> + dev_set_drvdata(dev, ec_data);
> + ec_data->board_sensors = board_sensors;
> ec_data->nr_sensors = board_sensors_count(ec_data->board_sensors);
> ec_data->sensors = devm_kcalloc(dev, ec_data->nr_sensors,
> sizeof(struct ec_sensor), GFP_KERNEL);
> @@ -666,22 +676,6 @@ static int __init configure_sensor_setup(struct device *dev)
> return PTR_ERR_OR_ZERO(hwdev);
> }
>
> -static int __init asus_ec_probe(struct platform_device *pdev)
> -{
> - struct ec_sensors_data *state;
> - int status = 0;
> -
> - state = devm_kzalloc(&pdev->dev, sizeof(struct ec_sensors_data),
> - GFP_KERNEL);
> -
> - if (!state) {
> - return -ENOMEM;
> - }
> -
> - dev_set_drvdata(&pdev->dev, state);
> - status = configure_sensor_setup(&pdev->dev);
> - return status;
> -}
>
> static const struct acpi_device_id acpi_ec_ids[] = {
> /* Embedded Controller Device */
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
2022-02-16 18:08 [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions Guenter Roeck
@ 2022-02-16 18:23 ` Eugene Shalygin
2022-02-16 18:49 ` Guenter Roeck
0 siblings, 1 reply; 7+ messages in thread
From: Eugene Shalygin @ 2022-02-16 18:23 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Jean Delvare, linux-hwmon, Linux Kernel Mailing List
On Wed, 16 Feb 2022 at 19:08, Guenter Roeck <linux@roeck-us.net> wrote:
> $ scripts/checkpatch.pl --strict asus-ec
So, contributors have to use the --strict option?
> WARNING: braces {} are not necessary for single statement blocks
The file is full of such braces, because I like them and it is only a
warning. How should I proceed with them?
Regards,
Eugene
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
2022-02-16 18:23 ` Eugene Shalygin
@ 2022-02-16 18:49 ` Guenter Roeck
2022-02-16 19:00 ` Eugene Shalygin
0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2022-02-16 18:49 UTC (permalink / raw)
To: Eugene Shalygin; +Cc: Jean Delvare, linux-hwmon, Linux Kernel Mailing List
On 2/16/22 10:23, Eugene Shalygin wrote:
> On Wed, 16 Feb 2022 at 19:08, Guenter Roeck <linux@roeck-us.net> wrote:
>> $ scripts/checkpatch.pl --strict asus-ec
>
> So, contributors have to use the --strict option?
>
>> WARNING: braces {} are not necessary for single statement blocks
>
> The file is full of such braces, because I like them and it is only a
> warning. How should I proceed with them?
>
Warnings are also seen without --strict; that only adds the CHECK messages.
You should follow Linux kernel coding style when you write kernel code,
not your personal preferences. Also please consider reading
Documentation/hwmon/submitting-patches.rst, which specifically says
* Please run your patch through 'checkpatch --strict'. There should be no
errors, no warnings, and few if any check messages. If there are any
messages, please be prepared to explain.
* If your patch generates checkpatch errors, warnings, or check messages,
please refrain from explanations such as "I prefer that coding style".
Keep in mind that each unnecessary message helps hiding a real problem,
and a consistent coding style makes it easier for others to understand
and review the code.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
2022-02-16 18:49 ` Guenter Roeck
@ 2022-02-16 19:00 ` Eugene Shalygin
2022-02-16 19:13 ` Guenter Roeck
0 siblings, 1 reply; 7+ messages in thread
From: Eugene Shalygin @ 2022-02-16 19:00 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Jean Delvare, linux-hwmon, Linux Kernel Mailing List
On Wed, 16 Feb 2022 at 19:49, Guenter Roeck <linux@roeck-us.net> wrote:
> * If your patch generates checkpatch errors, warnings, or check messages,
> please refrain from explanations such as "I prefer that coding style".
> Keep in mind that each unnecessary message helps hiding a real problem,
> and a consistent coding style makes it easier for others to understand
> and review the code.
Yes, of course. My question is what do I do with 6 other braces single
statement if's now?
Thanks,
Eugene
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
2022-02-16 19:00 ` Eugene Shalygin
@ 2022-02-16 19:13 ` Guenter Roeck
2022-02-16 19:17 ` Eugene Shalygin
0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2022-02-16 19:13 UTC (permalink / raw)
To: Eugene Shalygin; +Cc: Jean Delvare, linux-hwmon, Linux Kernel Mailing List
On 2/16/22 11:00, Eugene Shalygin wrote:
> On Wed, 16 Feb 2022 at 19:49, Guenter Roeck <linux@roeck-us.net> wrote:
>
>> * If your patch generates checkpatch errors, warnings, or check messages,
>> please refrain from explanations such as "I prefer that coding style".
>> Keep in mind that each unnecessary message helps hiding a real problem,
>> and a consistent coding style makes it easier for others to understand
>> and review the code.
>
> Yes, of course. My question is what do I do with 6 other braces single
> statement if's now?
>
Nothing as part of this patch. My fault for not bringing this up earlier,
but that is no reason to not clean up the code while touching it.
You _could_ submit a separate patch fixing everything reported by
checkpatch, but that is up to you.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
2022-02-16 19:13 ` Guenter Roeck
@ 2022-02-16 19:17 ` Eugene Shalygin
0 siblings, 0 replies; 7+ messages in thread
From: Eugene Shalygin @ 2022-02-16 19:17 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Jean Delvare, linux-hwmon, Linux Kernel Mailing List
On Wed, 16 Feb 2022 at 20:13, Guenter Roeck <linux@roeck-us.net> wrote:
> Nothing as part of this patch. My fault for not bringing this up earlier,
> but that is no reason to not clean up the code while touching it.
>
> You _could_ submit a separate patch fixing everything reported by
> checkpatch, but that is up to you.
OK, thank you!
Eugene
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
@ 2022-02-16 17:15 Eugene Shalygin
0 siblings, 0 replies; 7+ messages in thread
From: Eugene Shalygin @ 2022-02-16 17:15 UTC (permalink / raw)
Cc: Eugene Shalygin, Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel
Merge configure_sensor_setup() into probe().
Changes:
- v2: add local struct device *dev = &pdev->dev;
- v3: initialize dev at declaration
- v4: fix checkpatch warning
Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com>
---
drivers/hwmon/asus-ec-sensors.c | 38 ++++++++++++++-------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index bfac08a5dc57..ef887168df20 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -589,23 +589,33 @@ get_board_sensors(const struct device *dev)
return (unsigned long)dmi_entry->driver_data;
}
-static int __init configure_sensor_setup(struct device *dev)
+static int __init asus_ec_probe(struct platform_device *pdev)
{
- struct ec_sensors_data *ec_data = dev_get_drvdata(dev);
+ const struct hwmon_channel_info **ptr_asus_ec_ci;
int nr_count[hwmon_max] = { 0 }, nr_types = 0;
- struct device *hwdev;
struct hwmon_channel_info *asus_ec_hwmon_chan;
- const struct hwmon_channel_info **ptr_asus_ec_ci;
const struct hwmon_chip_info *chip_info;
+ struct device *dev = &pdev->dev;
+ struct ec_sensors_data *ec_data;
const struct ec_sensor_info *si;
enum hwmon_sensor_types type;
+ unsigned long board_sensors;
+ struct device *hwdev;
unsigned int i;
- ec_data->board_sensors = get_board_sensors(dev);
- if (!ec_data->board_sensors) {
+ board_sensors = get_board_sensors(dev);
+ if (!board_sensors) {
return -ENODEV;
}
+ ec_data = devm_kzalloc(dev, sizeof(struct ec_sensors_data),
+ GFP_KERNEL);
+ if (!ec_data) {
+ return -ENOMEM;
+ }
+
+ dev_set_drvdata(dev, ec_data);
+ ec_data->board_sensors = board_sensors;
ec_data->nr_sensors = board_sensors_count(ec_data->board_sensors);
ec_data->sensors = devm_kcalloc(dev, ec_data->nr_sensors,
sizeof(struct ec_sensor), GFP_KERNEL);
@@ -666,22 +676,6 @@ static int __init configure_sensor_setup(struct device *dev)
return PTR_ERR_OR_ZERO(hwdev);
}
-static int __init asus_ec_probe(struct platform_device *pdev)
-{
- struct ec_sensors_data *state;
- int status = 0;
-
- state = devm_kzalloc(&pdev->dev, sizeof(struct ec_sensors_data),
- GFP_KERNEL);
-
- if (!state) {
- return -ENOMEM;
- }
-
- dev_set_drvdata(&pdev->dev, state);
- status = configure_sensor_setup(&pdev->dev);
- return status;
-}
static const struct acpi_device_id acpi_ec_ids[] = {
/* Embedded Controller Device */
--
2.35.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-02-16 19:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 18:08 [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions Guenter Roeck
2022-02-16 18:23 ` Eugene Shalygin
2022-02-16 18:49 ` Guenter Roeck
2022-02-16 19:00 ` Eugene Shalygin
2022-02-16 19:13 ` Guenter Roeck
2022-02-16 19:17 ` Eugene Shalygin
-- strict thread matches above, loose matches on Subject: below --
2022-02-16 17:15 Eugene Shalygin
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).