public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Kirti Wankhede <kwankhede@nvidia.com>,
	Christoph Hellwig <hch@infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers: core: remove device_link argument from class_compat_[create|remove]_link
Date: Mon, 13 Jan 2025 17:10:01 -0500	[thread overview]
Message-ID: <20250113171001.4e5d4e9a.alex.williamson@redhat.com> (raw)
In-Reply-To: <db49131d-fd79-4f23-93f2-0ab541a345fa@gmail.com>

On Thu, 19 Dec 2024 22:48:17 +0100
Heiner Kallweit <hkallweit1@gmail.com> wrote:

> After 7e722083fcc3 ("i2c: Remove I2C_COMPAT config symbol and related
> code") there's no caller left passing a non-null device_link argument.
> So remove this argument to simplify the code.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/base/class.c          | 31 +++----------------------------
>  drivers/vfio/mdev/mdev_core.c |  4 ++--
>  include/linux/device/class.h  |  6 ++----
>  3 files changed, 7 insertions(+), 34 deletions(-)

Tested-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>

> 
> diff --git a/drivers/base/class.c b/drivers/base/class.c
> index 582b5a02a..40805f905 100644
> --- a/drivers/base/class.c
> +++ b/drivers/base/class.c
> @@ -594,30 +594,10 @@ EXPORT_SYMBOL_GPL(class_compat_unregister);
>   *			      a bus device
>   * @cls: the compatibility class
>   * @dev: the target bus device
> - * @device_link: an optional device to which a "device" link should be created
>   */
> -int class_compat_create_link(struct class_compat *cls, struct device *dev,
> -			     struct device *device_link)
> +int class_compat_create_link(struct class_compat *cls, struct device *dev)
>  {
> -	int error;
> -
> -	error = sysfs_create_link(cls->kobj, &dev->kobj, dev_name(dev));
> -	if (error)
> -		return error;
> -
> -	/*
> -	 * Optionally add a "device" link (typically to the parent), as a
> -	 * class device would have one and we want to provide as much
> -	 * backwards compatibility as possible.
> -	 */
> -	if (device_link) {
> -		error = sysfs_create_link(&dev->kobj, &device_link->kobj,
> -					  "device");
> -		if (error)
> -			sysfs_remove_link(cls->kobj, dev_name(dev));
> -	}
> -
> -	return error;
> +	return sysfs_create_link(cls->kobj, &dev->kobj, dev_name(dev));
>  }
>  EXPORT_SYMBOL_GPL(class_compat_create_link);
>  
> @@ -626,14 +606,9 @@ EXPORT_SYMBOL_GPL(class_compat_create_link);
>   *			      a bus device
>   * @cls: the compatibility class
>   * @dev: the target bus device
> - * @device_link: an optional device to which a "device" link was previously
> - * 		 created
>   */
> -void class_compat_remove_link(struct class_compat *cls, struct device *dev,
> -			      struct device *device_link)
> +void class_compat_remove_link(struct class_compat *cls, struct device *dev)
>  {
> -	if (device_link)
> -		sysfs_remove_link(&dev->kobj, "device");
>  	sysfs_remove_link(cls->kobj, dev_name(dev));
>  }
>  EXPORT_SYMBOL_GPL(class_compat_remove_link);
> diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
> index ed4737de4..f2e686f8f 100644
> --- a/drivers/vfio/mdev/mdev_core.c
> +++ b/drivers/vfio/mdev/mdev_core.c
> @@ -76,7 +76,7 @@ int mdev_register_parent(struct mdev_parent *parent, struct device *dev,
>  	if (ret)
>  		return ret;
>  
> -	ret = class_compat_create_link(mdev_bus_compat_class, dev, NULL);
> +	ret = class_compat_create_link(mdev_bus_compat_class, dev);
>  	if (ret)
>  		dev_warn(dev, "Failed to create compatibility class link\n");
>  
> @@ -98,7 +98,7 @@ void mdev_unregister_parent(struct mdev_parent *parent)
>  	dev_info(parent->dev, "MDEV: Unregistering\n");
>  
>  	down_write(&parent->unreg_sem);
> -	class_compat_remove_link(mdev_bus_compat_class, parent->dev, NULL);
> +	class_compat_remove_link(mdev_bus_compat_class, parent->dev);
>  	device_for_each_child(parent->dev, NULL, mdev_device_remove_cb);
>  	parent_remove_sysfs_files(parent);
>  	up_write(&parent->unreg_sem);
> diff --git a/include/linux/device/class.h b/include/linux/device/class.h
> index 518c9c83d..4c1e6cf50 100644
> --- a/include/linux/device/class.h
> +++ b/include/linux/device/class.h
> @@ -82,10 +82,8 @@ bool class_is_registered(const struct class *class);
>  struct class_compat;
>  struct class_compat *class_compat_register(const char *name);
>  void class_compat_unregister(struct class_compat *cls);
> -int class_compat_create_link(struct class_compat *cls, struct device *dev,
> -			     struct device *device_link);
> -void class_compat_remove_link(struct class_compat *cls, struct device *dev,
> -			      struct device *device_link);
> +int class_compat_create_link(struct class_compat *cls, struct device *dev);
> +void class_compat_remove_link(struct class_compat *cls, struct device *dev);
>  
>  void class_dev_iter_init(struct class_dev_iter *iter, const struct class *class,
>  			 const struct device *start, const struct device_type *type);


      reply	other threads:[~2025-01-13 22:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-19 21:48 [PATCH] drivers: core: remove device_link argument from class_compat_[create|remove]_link Heiner Kallweit
2025-01-13 22:10 ` Alex Williamson [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=20250113171001.4e5d4e9a.alex.williamson@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=hkallweit1@gmail.com \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@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