public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Lucas Magasweran <lucas.magasweran@ieee.org>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: hwmon: (core) check parent dev != NULL when chip != NULL
Date: Tue, 8 May 2018 15:16:07 -0700	[thread overview]
Message-ID: <20180508221607.GA7176@roeck-us.net> (raw)
In-Reply-To: <1525779813-25716-2-git-send-email-lucas.magasweran@ieee.org>

On Tue, May 08, 2018 at 04:43:33AM -0700, Lucas Magasweran wrote:
> hwmon_device_register_with_info() registration API requires a
> non-NULL parent device when chip is non-NULL.
> 
> This commit adds a check and documents this requirement.
> 
> Signed-off-by: Lucas Magasweran <lucas.magasweran@ieee.org>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  Documentation/hwmon/hwmon-kernel-api.txt | 3 ++-
>  drivers/hwmon/hwmon.c                    | 3 +++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/hwmon/hwmon-kernel-api.txt b/Documentation/hwmon/hwmon-kernel-api.txt
> index 53a8066..eb7a78a 100644
> --- a/Documentation/hwmon/hwmon-kernel-api.txt
> +++ b/Documentation/hwmon/hwmon-kernel-api.txt
> @@ -71,7 +71,8 @@ hwmon_device_register_with_info is the most comprehensive and preferred means
>  to register a hardware monitoring device. It creates the standard sysfs
>  attributes in the hardware monitoring core, letting the driver focus on reading
>  from and writing to the chip instead of having to bother with sysfs attributes.
> -Its parameters are described in more detail below.
> +The parent device parameter cannot be NULL with non-NULL chip info. Its
> +parameters are described in more detail below.
>  
>  devm_hwmon_device_register_with_info is similar to
>  hwmon_device_register_with_info. However, it is device managed, meaning the
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index 32083e4..e88c019 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -698,6 +698,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
>  	if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))
>  		return ERR_PTR(-EINVAL);
>  
> +	if (chip && !dev)
> +		return ERR_PTR(-EINVAL);
> +
>  	return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);
>  }
>  EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);

      reply	other threads:[~2018-05-08 22:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04 22:22 hwmon_device_register_with_info registration API issue Lucas Magasweran
2018-05-04 22:39 ` Guenter Roeck
2018-05-08 11:43   ` [PATCH] hwmon: (core) check parent dev != NULL when chip != NULL Lucas Magasweran
2018-05-08 11:43     ` Lucas Magasweran
2018-05-08 22:16       ` Guenter Roeck [this message]

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=20180508221607.GA7176@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=lucas.magasweran@ieee.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