Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of: Rename of_modalias_node()

This helper does not produce a real modalias, but tries to get the
"product" compatible part of the "vendor,product" compatibles only. It
is far from creating a purely useful modalias string and does not seem
to be used like that directly anyway, so let's try to give this helper a
more meaningful name before moving there a real modalias helper (already
existing under of/device.c).

Also update the various documentations to refer to the strings as
"aliases" rather than "modaliases" which has a real meaning in the Linux
kernel.

There is no functional change.

Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Wolfram Sang <wsa@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Acked-by: Sebastian Reichel <sre@kernel.org>
Link: https://lore.kernel.org/r/20230404172148.82422-9-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Miquel Raynal and committed by
Greg Kroah-Hartman
673aa1ed 5c3d15e1

+23 -17
+4 -3
drivers/acpi/bus.c
··· 817 817 * @modalias: Pointer to buffer that modalias value will be copied into 818 818 * @len: Length of modalias buffer 819 819 * 820 - * This is a counterpart of of_modalias_node() for struct acpi_device objects. 821 - * If there is a compatible string for @adev, it will be copied to @modalias 822 - * with the vendor prefix stripped; otherwise, @default_id will be used. 820 + * This is a counterpart of of_alias_from_compatible() for struct acpi_device 821 + * objects. If there is a compatible string for @adev, it will be copied to 822 + * @modalias with the vendor prefix stripped; otherwise, @default_id will be 823 + * used. 823 824 */ 824 825 void acpi_set_modalias(struct acpi_device *adev, const char *default_id, 825 826 char *modalias, size_t len)
+1 -1
drivers/gpu/drm/drm_mipi_dsi.c
··· 160 160 int ret; 161 161 u32 reg; 162 162 163 - if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) { 163 + if (of_alias_from_compatible(node, info.type, sizeof(info.type)) < 0) { 164 164 drm_err(host, "modalias failure on %pOF\n", node); 165 165 return ERR_PTR(-EINVAL); 166 166 }
+1 -1
drivers/hsi/hsi_core.c
··· 207 207 if (!cl) 208 208 return; 209 209 210 - err = of_modalias_node(client, name, sizeof(name)); 210 + err = of_alias_from_compatible(client, name, sizeof(name)); 211 211 if (err) 212 212 goto err; 213 213
+1 -1
drivers/i2c/busses/i2c-powermac.c
··· 284 284 */ 285 285 286 286 /* First try proper modalias */ 287 - if (of_modalias_node(node, tmp, sizeof(tmp)) >= 0) { 287 + if (of_alias_from_compatible(node, tmp, sizeof(tmp)) >= 0) { 288 288 snprintf(type, type_size, "MAC,%s", tmp); 289 289 return true; 290 290 }
+1 -1
drivers/i2c/i2c-core-of.c
··· 27 27 28 28 memset(info, 0, sizeof(*info)); 29 29 30 - if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) { 30 + if (of_alias_from_compatible(node, info->type, sizeof(info->type)) < 0) { 31 31 dev_err(dev, "of_i2c: modalias failure on %pOF\n", node); 32 32 return -EINVAL; 33 33 }
+11 -7
drivers/of/base.c
··· 1208 1208 EXPORT_SYMBOL(of_find_matching_node_and_match); 1209 1209 1210 1210 /** 1211 - * of_modalias_node - Lookup appropriate modalias for a device node 1211 + * of_alias_from_compatible - Lookup appropriate alias for a device node 1212 + * depending on compatible 1212 1213 * @node: pointer to a device tree node 1213 - * @modalias: Pointer to buffer that modalias value will be copied into 1214 - * @len: Length of modalias value 1214 + * @alias: Pointer to buffer that alias value will be copied into 1215 + * @len: Length of alias value 1215 1216 * 1216 1217 * Based on the value of the compatible property, this routine will attempt 1217 - * to choose an appropriate modalias value for a particular device tree node. 1218 + * to choose an appropriate alias value for a particular device tree node. 1218 1219 * It does this by stripping the manufacturer prefix (as delimited by a ',') 1219 1220 * from the first entry in the compatible list property. 1220 1221 * 1222 + * Note: The matching on just the "product" side of the compatible is a relic 1223 + * from I2C and SPI. Please do not add any new user. 1224 + * 1221 1225 * Return: This routine returns 0 on success, <0 on failure. 1222 1226 */ 1223 - int of_modalias_node(struct device_node *node, char *modalias, int len) 1227 + int of_alias_from_compatible(const struct device_node *node, char *alias, int len) 1224 1228 { 1225 1229 const char *compatible, *p; 1226 1230 int cplen; ··· 1233 1229 if (!compatible || strlen(compatible) > cplen) 1234 1230 return -ENODEV; 1235 1231 p = strchr(compatible, ','); 1236 - strscpy(modalias, p ? p + 1 : compatible, len); 1232 + strscpy(alias, p ? p + 1 : compatible, len); 1237 1233 return 0; 1238 1234 } 1239 - EXPORT_SYMBOL_GPL(of_modalias_node); 1235 + EXPORT_SYMBOL_GPL(of_alias_from_compatible); 1240 1236 1241 1237 /** 1242 1238 * of_find_node_by_phandle - Find a node given a phandle
+2 -2
drivers/spi/spi.c
··· 2354 2354 } 2355 2355 2356 2356 /* Select device driver */ 2357 - rc = of_modalias_node(nc, spi->modalias, 2358 - sizeof(spi->modalias)); 2357 + rc = of_alias_from_compatible(nc, spi->modalias, 2358 + sizeof(spi->modalias)); 2359 2359 if (rc < 0) { 2360 2360 dev_err(&ctlr->dev, "cannot find modalias for %pOF\n", nc); 2361 2361 goto err_out;
+2 -1
include/linux/of.h
··· 373 373 extern int of_n_size_cells(struct device_node *np); 374 374 extern const struct of_device_id *of_match_node( 375 375 const struct of_device_id *matches, const struct device_node *node); 376 - extern int of_modalias_node(struct device_node *node, char *modalias, int len); 376 + extern int of_alias_from_compatible(const struct device_node *node, char *alias, 377 + int len); 377 378 extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args); 378 379 extern int __of_parse_phandle_with_args(const struct device_node *np, 379 380 const char *list_name, const char *cells_name, int cell_count,