mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Eugene Shalygin <eugene.shalygin@gmail.com>
Cc: Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] hwmon: (asus-ec-sensors) merge setup functions
Date: Wed, 16 Feb 2022 10:08:22 -0800	[thread overview]
Message-ID: <20220216180822.GA3300192@roeck-us.net> (raw)

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
> 

             reply	other threads:[~2022-02-16 18:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 18:08 Guenter Roeck [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220216180822.GA3300192@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=eugene.shalygin@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®