lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <59887497-9d86-5c4d-40e3-1e5ac7c0a77a@linux.intel.com>
Date:   Wed, 31 Jul 2019 10:51:17 -0500
From:   Richard Gong <richard.gong@...ux.intel.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org,
        Dmitry Torokhov <dmitry.torokhov@...il.com>
Subject: Re: [PATCH v2 01/10] driver core: add dev_groups to all drivers


Hi Greg,

On 7/31/19 7:43 AM, Greg Kroah-Hartman wrote:
> From: Dmitry Torokhov <dmitry.torokhov@...il.com>
> 
> Add the ability for the driver core to create and remove a list of
> attribute groups automatically when the device is bound/unbound from a
> specific driver.
> 
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>

Tested-by: Richard Gong <richard.gong@...ux.intel.com>

> ---
>   drivers/base/dd.c      | 14 ++++++++++++++
>   include/linux/device.h |  3 +++
>   2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 994a90747420..d811e60610d3 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -554,9 +554,16 @@ static int really_probe(struct device *dev, struct device_driver *drv)
>   			goto probe_failed;
>   	}
>   
> +	if (device_add_groups(dev, drv->dev_groups)) {
> +		dev_err(dev, "device_add_groups() failed\n");
> +		goto dev_groups_failed;
> +	}
> +
>   	if (test_remove) {
>   		test_remove = false;
>   
> +		device_remove_groups(dev, drv->dev_groups);
> +
>   		if (dev->bus->remove)
>   			dev->bus->remove(dev);
>   		else if (drv->remove)
> @@ -584,6 +591,11 @@ static int really_probe(struct device *dev, struct device_driver *drv)
>   		 drv->bus->name, __func__, dev_name(dev), drv->name);
>   	goto done;
>   
> +dev_groups_failed:
> +	if (dev->bus->remove)
> +		dev->bus->remove(dev);
> +	else if (drv->remove)
> +		drv->remove(dev);
>   probe_failed:
>   	if (dev->bus)
>   		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
> @@ -1114,6 +1126,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
>   
>   		pm_runtime_put_sync(dev);
>   
> +		device_remove_groups(dev, drv->dev_groups);
> +
>   		if (dev->bus && dev->bus->remove)
>   			dev->bus->remove(dev);
>   		else if (drv->remove)
> diff --git a/include/linux/device.h b/include/linux/device.h
> index c330b75c6c57..98c00b71b598 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -262,6 +262,8 @@ enum probe_type {
>    * @resume:	Called to bring a device from sleep mode.
>    * @groups:	Default attributes that get created by the driver core
>    *		automatically.
> + * @dev_groups:	Additional attributes attached to device instance once the
> + *		it is bound to the driver.
>    * @pm:		Power management operations of the device which matched
>    *		this driver.
>    * @coredump:	Called when sysfs entry is written to. The device driver
> @@ -296,6 +298,7 @@ struct device_driver {
>   	int (*suspend) (struct device *dev, pm_message_t state);
>   	int (*resume) (struct device *dev);
>   	const struct attribute_group **groups;
> +	const struct attribute_group **dev_groups;
>   
>   	const struct dev_pm_ops *pm;
>   	void (*coredump) (struct device *dev);
> 

Regards,
Richard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ