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 v2 1/2] virt: vbox: Add check for device_create_file
Date: Thu, 1 Sep 2022 12:20:03 +0200 [thread overview]
Message-ID: <172c819f-911f-245b-1f33-da34386f8872@redhat.com> (raw)
In-Reply-To: <20220901101649.3499848-1-jiasheng@iscas.ac.cn>
Hi,
On 9/1/22 12:16, Jiasheng Jiang wrote:
> On Thu, Sep 01, 2022 at 05:39:46PM +0800, Greg KH wrote:
>>> - device_create_file(dev, &dev_attr_host_version);
>>> - device_create_file(dev, &dev_attr_host_features);
>>> +
>>> + ret = device_create_file(gdev->dev, &dev_attr_host_features);
>>> + if (ret)
>>> + goto err_unregister_misc_device_user;
>>> + ret = device_create_file(gdev->dev, &dev_attr_host_version);
>>> + if (ret)
>>> + goto err_remove_file_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,
>>> @@ -399,6 +404,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
>>>
>>> return 0;
>>>
>>> +err_remove_file_features:
>>> + device_remove_file(gdev->dev, &dev_attr_host_features);
>> Please make a patch series that is linked together, the one you just did
>> was not properly threaded at all (hint, use git send-email).
>>
>> And again, this is not the correct way to solve this issue, use a
>> default attribute group for the driver instead. No driver should ever
>> be adding or removing files individually like this.
>
> Need I use the group to replace the individually removal in
> vbg_pci_remove() too?
The idea is to do a change similar to this one:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?id=4b0133533e82af25d6aaf9d0c7b2a5af388feb74
Setting the driver's .dev_groups field will automatically
add the attributes when probe() succeeds and they will
also automatically be removed before the driver's remove()
function gets called.
So after this change you can remove both the manual add
calls from probe() as well as remove the remove calls
from vbg_pci_remove().
Regards,
Hans
next prev parent reply other threads:[~2022-09-01 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 10:16 Jiasheng Jiang
2022-09-01 10:20 ` Hans de Goede [this message]
2022-09-01 10:24 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2022-09-01 9:17 Jiasheng Jiang
2022-09-01 9:39 ` Greg KH
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=172c819f-911f-245b-1f33-da34386f8872@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®