kernel: bump 6.1 to 6.1.71
[openwrt/staging/stintel.git] / target / linux / generic / backport-6.1 / 828-v6.4-0003-of-Rename-of_modalias_node.patch
1 From 673aa1ed1c9b6710bf24e3f0957d85e2f46c77db Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Tue, 4 Apr 2023 18:21:16 +0100
4 Subject: [PATCH] of: Rename of_modalias_node()
5
6 This helper does not produce a real modalias, but tries to get the
7 "product" compatible part of the "vendor,product" compatibles only. It
8 is far from creating a purely useful modalias string and does not seem
9 to be used like that directly anyway, so let's try to give this helper a
10 more meaningful name before moving there a real modalias helper (already
11 existing under of/device.c).
12
13 Also update the various documentations to refer to the strings as
14 "aliases" rather than "modaliases" which has a real meaning in the Linux
15 kernel.
16
17 There is no functional change.
18
19 Cc: Rafael J. Wysocki <rafael@kernel.org>
20 Cc: Len Brown <lenb@kernel.org>
21 Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
22 Cc: Maxime Ripard <mripard@kernel.org>
23 Cc: Thomas Zimmermann <tzimmermann@suse.de>
24 Cc: Sebastian Reichel <sre@kernel.org>
25 Cc: Wolfram Sang <wsa@kernel.org>
26 Cc: Mark Brown <broonie@kernel.org>
27 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
28 Reviewed-by: Rob Herring <robh@kernel.org>
29 Acked-by: Mark Brown <broonie@kernel.org>
30 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
31 Acked-by: Sebastian Reichel <sre@kernel.org>
32 Link: https://lore.kernel.org/r/20230404172148.82422-9-srinivas.kandagatla@linaro.org
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34 ---
35 drivers/acpi/bus.c | 7 ++++---
36 drivers/gpu/drm/drm_mipi_dsi.c | 2 +-
37 drivers/hsi/hsi_core.c | 2 +-
38 drivers/i2c/busses/i2c-powermac.c | 2 +-
39 drivers/i2c/i2c-core-of.c | 2 +-
40 drivers/of/base.c | 18 +++++++++++-------
41 drivers/spi/spi.c | 4 ++--
42 include/linux/of.h | 3 ++-
43 8 files changed, 23 insertions(+), 17 deletions(-)
44
45 --- a/drivers/acpi/bus.c
46 +++ b/drivers/acpi/bus.c
47 @@ -806,9 +806,10 @@ static bool acpi_of_modalias(struct acpi
48 * @modalias: Pointer to buffer that modalias value will be copied into
49 * @len: Length of modalias buffer
50 *
51 - * This is a counterpart of of_modalias_node() for struct acpi_device objects.
52 - * If there is a compatible string for @adev, it will be copied to @modalias
53 - * with the vendor prefix stripped; otherwise, @default_id will be used.
54 + * This is a counterpart of of_alias_from_compatible() for struct acpi_device
55 + * objects. If there is a compatible string for @adev, it will be copied to
56 + * @modalias with the vendor prefix stripped; otherwise, @default_id will be
57 + * used.
58 */
59 void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
60 char *modalias, size_t len)
61 --- a/drivers/gpu/drm/drm_mipi_dsi.c
62 +++ b/drivers/gpu/drm/drm_mipi_dsi.c
63 @@ -160,7 +160,7 @@ of_mipi_dsi_device_add(struct mipi_dsi_h
64 int ret;
65 u32 reg;
66
67 - if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
68 + if (of_alias_from_compatible(node, info.type, sizeof(info.type)) < 0) {
69 drm_err(host, "modalias failure on %pOF\n", node);
70 return ERR_PTR(-EINVAL);
71 }
72 --- a/drivers/hsi/hsi_core.c
73 +++ b/drivers/hsi/hsi_core.c
74 @@ -207,7 +207,7 @@ static void hsi_add_client_from_dt(struc
75 if (!cl)
76 return;
77
78 - err = of_modalias_node(client, name, sizeof(name));
79 + err = of_alias_from_compatible(client, name, sizeof(name));
80 if (err)
81 goto err;
82
83 --- a/drivers/i2c/busses/i2c-powermac.c
84 +++ b/drivers/i2c/busses/i2c-powermac.c
85 @@ -284,7 +284,7 @@ static bool i2c_powermac_get_type(struct
86 */
87
88 /* First try proper modalias */
89 - if (of_modalias_node(node, tmp, sizeof(tmp)) >= 0) {
90 + if (of_alias_from_compatible(node, tmp, sizeof(tmp)) >= 0) {
91 snprintf(type, type_size, "MAC,%s", tmp);
92 return true;
93 }
94 --- a/drivers/i2c/i2c-core-of.c
95 +++ b/drivers/i2c/i2c-core-of.c
96 @@ -27,7 +27,7 @@ int of_i2c_get_board_info(struct device
97
98 memset(info, 0, sizeof(*info));
99
100 - if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) {
101 + if (of_alias_from_compatible(node, info->type, sizeof(info->type)) < 0) {
102 dev_err(dev, "of_i2c: modalias failure on %pOF\n", node);
103 return -EINVAL;
104 }
105 --- a/drivers/of/base.c
106 +++ b/drivers/of/base.c
107 @@ -1208,19 +1208,23 @@ struct device_node *of_find_matching_nod
108 EXPORT_SYMBOL(of_find_matching_node_and_match);
109
110 /**
111 - * of_modalias_node - Lookup appropriate modalias for a device node
112 + * of_alias_from_compatible - Lookup appropriate alias for a device node
113 + * depending on compatible
114 * @node: pointer to a device tree node
115 - * @modalias: Pointer to buffer that modalias value will be copied into
116 - * @len: Length of modalias value
117 + * @alias: Pointer to buffer that alias value will be copied into
118 + * @len: Length of alias value
119 *
120 * Based on the value of the compatible property, this routine will attempt
121 - * to choose an appropriate modalias value for a particular device tree node.
122 + * to choose an appropriate alias value for a particular device tree node.
123 * It does this by stripping the manufacturer prefix (as delimited by a ',')
124 * from the first entry in the compatible list property.
125 *
126 + * Note: The matching on just the "product" side of the compatible is a relic
127 + * from I2C and SPI. Please do not add any new user.
128 + *
129 * Return: This routine returns 0 on success, <0 on failure.
130 */
131 -int of_modalias_node(struct device_node *node, char *modalias, int len)
132 +int of_alias_from_compatible(const struct device_node *node, char *alias, int len)
133 {
134 const char *compatible, *p;
135 int cplen;
136 @@ -1229,10 +1233,10 @@ int of_modalias_node(struct device_node
137 if (!compatible || strlen(compatible) > cplen)
138 return -ENODEV;
139 p = strchr(compatible, ',');
140 - strscpy(modalias, p ? p + 1 : compatible, len);
141 + strscpy(alias, p ? p + 1 : compatible, len);
142 return 0;
143 }
144 -EXPORT_SYMBOL_GPL(of_modalias_node);
145 +EXPORT_SYMBOL_GPL(of_alias_from_compatible);
146
147 /**
148 * of_find_node_by_phandle - Find a node given a phandle
149 --- a/drivers/spi/spi.c
150 +++ b/drivers/spi/spi.c
151 @@ -2326,8 +2326,8 @@ of_register_spi_device(struct spi_contro
152 }
153
154 /* Select device driver */
155 - rc = of_modalias_node(nc, spi->modalias,
156 - sizeof(spi->modalias));
157 + rc = of_alias_from_compatible(nc, spi->modalias,
158 + sizeof(spi->modalias));
159 if (rc < 0) {
160 dev_err(&ctlr->dev, "cannot find modalias for %pOF\n", nc);
161 goto err_out;
162 --- a/include/linux/of.h
163 +++ b/include/linux/of.h
164 @@ -362,7 +362,8 @@ extern int of_n_addr_cells(struct device
165 extern int of_n_size_cells(struct device_node *np);
166 extern const struct of_device_id *of_match_node(
167 const struct of_device_id *matches, const struct device_node *node);
168 -extern int of_modalias_node(struct device_node *node, char *modalias, int len);
169 +extern int of_alias_from_compatible(const struct device_node *node, char *alias,
170 + int len);
171 extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
172 extern int __of_parse_phandle_with_args(const struct device_node *np,
173 const char *list_name, const char *cells_name, int cell_count,