mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pei Xiao <xiaopei01@kylinos.cn>
To: xiaopeitux@foxmail.com, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com
Subject: Re: [PATCH] driver core: Split devres APIs to device/devres.h
Date: Fri, 28 Feb 2025 17:28:56 +0800	[thread overview]
Message-ID: <9a2d29f3-3e8b-4851-b481-cc72cd804ea6@kylinos.cn> (raw)
In-Reply-To: <tencent_66CF9C91EB4A4417F70E9511649A57DEC906@qq.com>


在 2025/2/28 17:18, xiaopeitux@foxmail.com 写道:
> From: Pei Xiao <xiaopei01@kylinos.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@kylinos.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_ */

  reply	other threads:[~2025-02-28  9:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28  9:18 xiaopeitux
2025-02-28  9:28 ` Pei Xiao [this message]
2025-02-28 12:43   ` Andy Shevchenko
2025-02-28 12:41 ` Andy Shevchenko
2025-03-01 11:42 ` kernel test robot

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=9a2d29f3-3e8b-4851-b481-cc72cd804ea6@kylinos.cn \
    --to=xiaopei01@kylinos.cn \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiaopeitux@foxmail.com \
    /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®