All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: W_Armin@gmx.de
Cc: hdegoede@redhat.com, linux-hwmon@vger.kernel.org, jdelvare@suse.com
Subject: Re: [PATCH v2 4/4] hwmon: (sch56xx-common) Simplify sch56xx_device_add
Date: Mon, 10 May 2021 08:36:43 -0700	[thread overview]
Message-ID: <20210510153643.GD3212231@roeck-us.net> (raw)
In-Reply-To: <20210508131457.12780-5-W_Armin@gmx.de>

On Sat, May 08, 2021 at 03:14:57PM +0200, W_Armin@gmx.de wrote:
> From: Armin Wolf <W_Armin@gmx.de>
> 
> Use platform_device_register_simple() instead of
> manually calling platform_device_alloc()/platform_device_add().
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/sch56xx-common.c | 27 ++++-----------------------
>  1 file changed, 4 insertions(+), 23 deletions(-)
> 
> --
> 2.20.1
> 
> diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
> index 180801f80118..5307fda73e70 100644
> --- a/drivers/hwmon/sch56xx-common.c
> +++ b/drivers/hwmon/sch56xx-common.c
> @@ -506,37 +506,18 @@ static int __init sch56xx_device_add(int address, const char *name)
>  	struct resource res = {
>  		.start	= address,
>  		.end	= address + REGION_LENGTH - 1,
> +		.name	= name,
>  		.flags	= IORESOURCE_IO,
>  	};
>  	int err;
> 
> -	sch56xx_pdev = platform_device_alloc(name, address);
> -	if (!sch56xx_pdev)
> -		return -ENOMEM;
> -
> -	res.name = sch56xx_pdev->name;
>  	err = acpi_check_resource_conflict(&res);
>  	if (err)
> -		goto exit_device_put;
> -
> -	err = platform_device_add_resources(sch56xx_pdev, &res, 1);
> -	if (err) {
> -		pr_err("Device resource addition failed\n");
> -		goto exit_device_put;
> -	}
> -
> -	err = platform_device_add(sch56xx_pdev);
> -	if (err) {
> -		pr_err("Device addition failed\n");
> -		goto exit_device_put;
> -	}
> -
> -	return 0;
> +		return err;
> 
> -exit_device_put:
> -	platform_device_put(sch56xx_pdev);
> +	sch56xx_pdev = platform_device_register_simple(name, -1, &res, 1);
> 
> -	return err;
> +	return PTR_ERR_OR_ZERO(sch56xx_pdev);
>  }
> 
>  static int __init sch56xx_init(void)

  reply	other threads:[~2021-05-10 15:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-08 13:14 [PATCH v2 0/4] hwmon: (sch56xx) Use devres for watchdog and platform_device_register_simple() W_Armin
2021-05-08 13:14 ` [PATCH v2 1/4] hwmon: (sch56xx) Use devres functions for watchdog W_Armin
2021-05-10 15:34   ` Guenter Roeck
2021-05-08 13:14 ` [PATCH v2 2/4] hwmon: (sch56xx-common) Use strscpy W_Armin
2021-05-10 15:35   ` Guenter Roeck
2021-05-08 13:14 ` [PATCH v2 3/4] hwmon: (sch56xx-common) Use helper function W_Armin
2021-05-10 15:36   ` Guenter Roeck
2021-05-08 13:14 ` [PATCH v2 4/4] hwmon: (sch56xx-common) Simplify sch56xx_device_add W_Armin
2021-05-10 15:36   ` Guenter Roeck [this message]
2021-05-08 13:38 ` [PATCH v2 0/4] hwmon: (sch56xx) Use devres for watchdog and platform_device_register_simple() Hans de Goede

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=20210510153643.GD3212231@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=W_Armin@gmx.de \
    --cc=hdegoede@redhat.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.