mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>, gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] virt: vbox: convert to use dev_groups
Date: Thu, 1 Sep 2022 16:48:54 +0200	[thread overview]
Message-ID: <22b3904d-380c-a628-2f62-d108139f09e2@redhat.com> (raw)
In-Reply-To: <20220901144610.3550300-1-jiasheng@iscas.ac.cn>

Hi,

On 9/1/22 16:46, Jiasheng Jiang wrote:
> The driver core supports the ability to handle the creation and removal
> of device-specific sysfs files in a race-free manner. Moreover, it can
> guarantee the success of creation. Therefore, it should be better to
> convert to use dev_groups.
> 
> Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
> Change log:
> 
> v2-> v3:
> 
> 1. Switch to use an attribute group.
> 
> v1 -> v2:
> 
> 1. Use gdev->dev instead of dev.
> 2. Remove file when creation failed.
> ---
>  drivers/virt/vboxguest/vboxguest_linux.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> index 4ccfd30c2a30..6fc81347ae72 100644
> --- a/drivers/virt/vboxguest/vboxguest_linux.c
> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> @@ -270,6 +270,13 @@ static ssize_t host_features_show(struct device *dev,
>  static DEVICE_ATTR_RO(host_version);
>  static DEVICE_ATTR_RO(host_features);
>  
> +static struct attribute *vbg_pci_attrs[] = {
> +	&dev_attr_host_version.attr,
> +	&dev_attr_host_features.attr,
> +	NULL,
> +};
> +ATTRIBUTE_GROUPS(vbg_pci);
> +
>  /**
>   * Does the PCI detection and init of the device.
>   *
> @@ -390,8 +397,6 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>  	}
>  
>  	pci_set_drvdata(pci, gdev);
> -	device_create_file(dev, &dev_attr_host_version);
> -	device_create_file(dev, &dev_attr_host_features);
>  
>  	vbg_info("vboxguest: misc device minor %d, IRQ %d, I/O port %x, MMIO at %pap (size %pap)\n",
>  		 gdev->misc_device.minor, pci->irq, gdev->io_port,
> @@ -422,8 +427,6 @@ static void vbg_pci_remove(struct pci_dev *pci)
>  	mutex_unlock(&vbg_gdev_mutex);
>  
>  	free_irq(pci->irq, gdev);
> -	device_remove_file(gdev->dev, &dev_attr_host_features);
> -	device_remove_file(gdev->dev, &dev_attr_host_version);
>  	misc_deregister(&gdev->misc_device_user);
>  	misc_deregister(&gdev->misc_device);
>  	vbg_core_exit(gdev);
> @@ -488,6 +491,7 @@ MODULE_DEVICE_TABLE(pci,  vbg_pci_ids);
>  
>  static struct pci_driver vbg_pci_driver = {
>  	.name		= DEVICE_NAME,
> +	.dev_groups	= vbg_pci_groups,
>  	.id_table	= vbg_pci_ids,
>  	.probe		= vbg_pci_probe,
>  	.remove		= vbg_pci_remove,


      reply	other threads:[~2022-09-01 14:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01 14:46 Jiasheng Jiang
2022-09-01 14:48 ` Hans de Goede [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=22b3904d-380c-a628-2f62-d108139f09e2@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiasheng@iscas.ac.cn \
    --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®