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: <9a2d29f3-3e8b-4851-b481-cc72cd804ea6@kylinos.cn>
Date: Fri, 28 Feb 2025 17:28:56 +0800
From: Pei Xiao <xiaopei01@...inos.cn>
To: xiaopeitux@...mail.com, gregkh@...uxfoundation.org,
 linux-kernel@...r.kernel.org, andriy.shevchenko@...ux.intel.com
Subject: Re: [PATCH] driver core: Split devres APIs to device/devres.h


在 2025/2/28 17:18, xiaopeitux@...mail.com 写道:
> From: Pei Xiao <xiaopei01@...inos.cn>
>
> Since a21cad931276 ("driver core: Split devres APIs to
> device/devres.h"),but some APIs like 'devm_alloc_percpu' didn't move to
> devres.h. we should also move it.
sorry, I forgot to modify the subject. This is an RFC.
> Signed-off-by: Pei Xiao <xiaopei01@...inos.cn>
> ---
>  include/linux/device.h        | 60 -----------------------------------
>  include/linux/device/devres.h | 58 +++++++++++++++++++++++++++++++++
>  2 files changed, 58 insertions(+), 60 deletions(-)
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index ec330af24151..ab383a9bbc17 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -281,63 +281,6 @@ int __must_check device_create_bin_file(struct device *dev,
>  void device_remove_bin_file(struct device *dev,
>  			    const struct bin_attribute *attr);
>  
> -/* allows to add/remove a custom action to devres stack */
> -int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
> -
> -/**
> - * devm_remove_action() - removes previously added custom action
> - * @dev: Device that owns the action
> - * @action: Function implementing the action
> - * @data: Pointer to data passed to @action implementation
> - *
> - * Removes instance of @action previously added by devm_add_action().
> - * Both action and data should match one of the existing entries.
> - */
> -static inline
> -void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
> -{
> -	WARN_ON(devm_remove_action_nowarn(dev, action, data));
> -}
> -
> -void devm_release_action(struct device *dev, void (*action)(void *), void *data);
> -
> -int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
> -#define devm_add_action(dev, action, data) \
> -	__devm_add_action(dev, action, data, #action)
> -
> -static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
> -					     void *data, const char *name)
> -{
> -	int ret;
> -
> -	ret = __devm_add_action(dev, action, data, name);
> -	if (ret)
> -		action(data);
> -
> -	return ret;
> -}
> -#define devm_add_action_or_reset(dev, action, data) \
> -	__devm_add_action_or_reset(dev, action, data, #action)
> -
> -/**
> - * devm_alloc_percpu - Resource-managed alloc_percpu
> - * @dev: Device to allocate per-cpu memory for
> - * @type: Type to allocate per-cpu memory for
> - *
> - * Managed alloc_percpu. Per-cpu memory allocated with this function is
> - * automatically freed on driver detach.
> - *
> - * RETURNS:
> - * Pointer to allocated memory on success, NULL on failure.
> - */
> -#define devm_alloc_percpu(dev, type)      \
> -	((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \
> -						      __alignof__(type)))
> -
> -void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
> -				   size_t align);
> -void devm_free_percpu(struct device *dev, void __percpu *pdata);
> -
>  struct device_dma_parameters {
>  	/*
>  	 * a low level driver may set these to teach IOMMU code about
> @@ -1163,9 +1106,6 @@ static inline void device_remove_group(struct device *dev,
>  	device_remove_groups(dev, groups);
>  }
>  
> -int __must_check devm_device_add_group(struct device *dev,
> -				       const struct attribute_group *grp);
> -
>  /*
>   * get_device - atomically increment the reference count for the device.
>   *
> diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
> index 9b49f9915850..8f93f7388dc1 100644
> --- a/include/linux/device/devres.h
> +++ b/include/linux/device/devres.h
> @@ -126,4 +126,62 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
>  
>  #endif
>  
> +/* allows to add/remove a custom action to devres stack */
> +int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
> +
> +/**
> + * devm_remove_action() - removes previously added custom action
> + * @dev: Device that owns the action
> + * @action: Function implementing the action
> + * @data: Pointer to data passed to @action implementation
> + *
> + * Removes instance of @action previously added by devm_add_action().
> + * Both action and data should match one of the existing entries.
> + */
> +static inline
> +void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
> +{
> +	WARN_ON(devm_remove_action_nowarn(dev, action, data));
> +}
> +
> +void devm_release_action(struct device *dev, void (*action)(void *), void *data);
> +
> +int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
> +#define devm_add_action(dev, action, data) \
> +	__devm_add_action(dev, action, data, #action)
> +
> +static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
> +					     void *data, const char *name)
> +{
> +	int ret;
> +
> +	ret = __devm_add_action(dev, action, data, name);
> +	if (ret)
> +		action(data);
> +
> +	return ret;
> +}
> +#define devm_add_action_or_reset(dev, action, data) \
> +	__devm_add_action_or_reset(dev, action, data, #action)
> +
> +/**
> + * devm_alloc_percpu - Resource-managed alloc_percpu
> + * @dev: Device to allocate per-cpu memory for
> + * @type: Type to allocate per-cpu memory for
> + *
> + * Managed alloc_percpu. Per-cpu memory allocated with this function is
> + * automatically freed on driver detach.
> + *
> + * RETURNS:
> + * Pointer to allocated memory on success, NULL on failure.
> + */
> +#define devm_alloc_percpu(dev, type)      \
> +	((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \
> +						      __alignof__(type)))
> +
> +void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
> +				   size_t align);
> +void devm_free_percpu(struct device *dev, void __percpu *pdata);
> +int __must_check devm_device_add_group(struct device *dev,
> +				       const struct attribute_group *grp);
>  #endif /* _DEVICE_DEVRES_H_ */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ