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

pinctrl: single: Use generic parser and #pinctrl-cells for pinctrl-single,bits

We can now use generic parser and keep things compatible with the
old binding.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Tony Lindgren and committed by
Linus Walleij
22d5127e 4622215f

+24 -24
+24 -24
drivers/pinctrl/pinctrl-single.c
··· 35 35 #include "pinconf.h" 36 36 37 37 #define DRIVER_NAME "pinctrl-single" 38 - #define PCS_MUX_BITS_NAME "pinctrl-single,bits" 39 38 #define PCS_OFF_DISABLED ~0U 40 39 41 40 /** ··· 1215 1216 return res; 1216 1217 } 1217 1218 1218 - #define PARAMS_FOR_BITS_PER_MUX 3 1219 - 1220 1219 static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, 1221 1220 struct device_node *np, 1222 1221 struct pinctrl_map **map, 1223 1222 unsigned *num_maps, 1224 1223 const char **pgnames) 1225 1224 { 1225 + const char *name = "pinctrl-single,pins"; 1226 1226 struct pcs_func_vals *vals; 1227 - const __be32 *mux; 1228 - int size, rows, *pins, index = 0, found = 0, res = -ENOMEM; 1227 + int rows, *pins, found = 0, res = -ENOMEM, i; 1229 1228 int npins_in_row; 1230 1229 struct pcs_function *function; 1231 1230 1232 - mux = of_get_property(np, PCS_MUX_BITS_NAME, &size); 1231 + rows = pinctrl_count_index_with_args(np, name); 1232 + if (rows == -EINVAL) 1233 + return rows; 1233 1234 1234 - if (!mux) { 1235 - dev_err(pcs->dev, "no valid property for %s\n", np->name); 1236 - return -EINVAL; 1237 - } 1238 - 1239 - if (size < (sizeof(*mux) * PARAMS_FOR_BITS_PER_MUX)) { 1240 - dev_err(pcs->dev, "bad data for %s\n", np->name); 1241 - return -EINVAL; 1242 - } 1243 - 1244 - /* Number of elements in array */ 1245 - size /= sizeof(*mux); 1246 - 1247 - rows = size / PARAMS_FOR_BITS_PER_MUX; 1248 1235 npins_in_row = pcs->width / pcs->bits_per_pin; 1249 1236 1250 1237 vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row, ··· 1243 1258 if (!pins) 1244 1259 goto free_vals; 1245 1260 1246 - while (index < size) { 1261 + for (i = 0; i < rows; i++) { 1262 + struct of_phandle_args pinctrl_spec; 1247 1263 unsigned offset, val; 1248 1264 unsigned mask, bit_pos, val_pos, mask_pos, submask; 1249 1265 unsigned pin_num_from_lsb; 1250 1266 int pin; 1251 1267 1252 - offset = be32_to_cpup(mux + index++); 1253 - val = be32_to_cpup(mux + index++); 1254 - mask = be32_to_cpup(mux + index++); 1268 + res = pinctrl_parse_index_with_args(np, name, i, &pinctrl_spec); 1269 + if (res) 1270 + return res; 1271 + 1272 + if (pinctrl_spec.args_count < 3) { 1273 + dev_err(pcs->dev, "invalid args_count for spec: %i\n", 1274 + pinctrl_spec.args_count); 1275 + break; 1276 + } 1277 + 1278 + /* Index plus two value cells */ 1279 + offset = pinctrl_spec.args[0]; 1280 + val = pinctrl_spec.args[1]; 1281 + mask = pinctrl_spec.args[2]; 1282 + 1283 + dev_dbg(pcs->dev, "%s index: 0x%x value: 0x%x mask: 0x%x\n", 1284 + pinctrl_spec.np->name, offset, val, mask); 1255 1285 1256 1286 /* Parse pins in each row from LSB */ 1257 1287 while (mask) {