diff options
| author | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
| commit | 1ac731c529cd4d6adbce134754b51ff7d822b145 (patch) | |
| tree | 143ab3f35ca5f3b69f583c84e6964b17139c2ec1 /drivers/of/device.c | |
| parent | 07b4c950f27bef0362dc6ad7ee713aab61d58149 (diff) | |
| parent | 54116d442e001e1b6bd482122043b1870998a1f3 (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.6 merge window.
Diffstat (limited to 'drivers/of/device.c')
| -rw-r--r-- | drivers/of/device.c | 75 | 
1 files changed, 8 insertions, 67 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c index 955bfb3d1a83..0f00f1b80708 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -1,5 +1,4 @@  // SPDX-License-Identifier: GPL-2.0 -#include <linux/string.h>  #include <linux/kernel.h>  #include <linux/of.h>  #include <linux/of_device.h> @@ -9,7 +8,6 @@  #include <linux/dma-direct.h> /* for bus_dma_region */  #include <linux/dma-map-ops.h>  #include <linux/init.h> -#include <linux/module.h>  #include <linux/mod_devicetable.h>  #include <linux/slab.h>  #include <linux/platform_device.h> @@ -248,68 +246,6 @@ const void *of_device_get_match_data(const struct device *dev)  }  EXPORT_SYMBOL(of_device_get_match_data); -static ssize_t of_device_get_modalias(const struct device *dev, char *str, ssize_t len) -{ -	const char *compat; -	char *c; -	struct property *p; -	ssize_t csize; -	ssize_t tsize; - -	if ((!dev) || (!dev->of_node) || dev->of_node_reused) -		return -ENODEV; - -	/* Name & Type */ -	/* %p eats all alphanum characters, so %c must be used here */ -	csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T', -			 of_node_get_device_type(dev->of_node)); -	tsize = csize; -	len -= csize; -	if (str) -		str += csize; - -	of_property_for_each_string(dev->of_node, "compatible", p, compat) { -		csize = strlen(compat) + 1; -		tsize += csize; -		if (csize > len) -			continue; - -		csize = snprintf(str, len, "C%s", compat); -		for (c = str; c; ) { -			c = strchr(c, ' '); -			if (c) -				*c++ = '_'; -		} -		len -= csize; -		str += csize; -	} - -	return tsize; -} - -int of_device_request_module(struct device *dev) -{ -	char *str; -	ssize_t size; -	int ret; - -	size = of_device_get_modalias(dev, NULL, 0); -	if (size < 0) -		return size; - -	str = kmalloc(size + 1, GFP_KERNEL); -	if (!str) -		return -ENOMEM; - -	of_device_get_modalias(dev, str, size); -	str[size] = '\0'; -	ret = request_module(str); -	kfree(str); - -	return ret; -} -EXPORT_SYMBOL_GPL(of_device_request_module); -  /**   * of_device_modalias - Fill buffer with newline terminated modalias string   * @dev:	Calling device @@ -318,7 +254,12 @@ EXPORT_SYMBOL_GPL(of_device_request_module);   */  ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)  { -	ssize_t sl = of_device_get_modalias(dev, str, len - 2); +	ssize_t sl; + +	if (!dev || !dev->of_node || dev->of_node_reused) +		return -ENODEV; + +	sl = of_modalias(dev->of_node, str, len - 2);  	if (sl < 0)  		return sl;  	if (sl > len - 2) @@ -383,8 +324,8 @@ int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *  	if (add_uevent_var(env, "MODALIAS="))  		return -ENOMEM; -	sl = of_device_get_modalias(dev, &env->buf[env->buflen-1], -				    sizeof(env->buf) - env->buflen); +	sl = of_modalias(dev->of_node, &env->buf[env->buflen-1], +			 sizeof(env->buf) - env->buflen);  	if (sl < 0)  		return sl;  	if (sl >= (sizeof(env->buf) - env->buflen))  |