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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-torvalds' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

Here are some fixes to the pin control system that has accumulated since
-rc1. Mainly Tony Lindgren fixed the module load/unload logic and the
rest are minor fixes and documentation.

* 'for-torvalds' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
pinctrl: add checks for empty function names
pinctrl: fix pinmux_hog_maps when ctrl_dev_name is not set
pinctrl: fix some pinmux typos
pinctrl: free debugfs entries when unloading a pinmux driver
pinctrl: unbreak error messages
Documentation/pinctrl: fix a few syntax errors in code examples
pinctrl: fix pinconf_pins_show iteration

+95 -74
+8 -9
Documentation/pinctrl.txt
··· 857 857 858 858 ... 859 859 { 860 - .name "2bit" 860 + .name = "2bit" 861 861 .ctrl_dev_name = "pinctrl-foo", 862 862 .function = "mmc0", 863 863 .group = "mmc0_1_grp", 864 864 .dev_name = "foo-mmc.0", 865 865 }, 866 866 { 867 - .name "4bit" 867 + .name = "4bit" 868 868 .ctrl_dev_name = "pinctrl-foo", 869 869 .function = "mmc0", 870 870 .group = "mmc0_1_grp", 871 871 .dev_name = "foo-mmc.0", 872 872 }, 873 873 { 874 - .name "4bit" 874 + .name = "4bit" 875 875 .ctrl_dev_name = "pinctrl-foo", 876 876 .function = "mmc0", 877 877 .group = "mmc0_2_grp", 878 878 .dev_name = "foo-mmc.0", 879 879 }, 880 880 { 881 - .name "8bit" 881 + .name = "8bit" 882 882 .ctrl_dev_name = "pinctrl-foo", 883 - .function = "mmc0", 884 883 .group = "mmc0_1_grp", 885 884 .dev_name = "foo-mmc.0", 886 885 }, 887 886 { 888 - .name "8bit" 887 + .name = "8bit" 889 888 .ctrl_dev_name = "pinctrl-foo", 890 889 .function = "mmc0", 891 890 .group = "mmc0_2_grp", 892 891 .dev_name = "foo-mmc.0", 893 892 }, 894 893 { 895 - .name "8bit" 894 + .name = "8bit" 896 895 .ctrl_dev_name = "pinctrl-foo", 897 896 .function = "mmc0", 898 897 .group = "mmc0_3_grp", ··· 994 995 like this: 995 996 996 997 { 997 - .name "POWERMAP" 998 + .name = "POWERMAP" 998 999 .ctrl_dev_name = "pinctrl-foo", 999 1000 .function = "power_func", 1000 1001 .hog_on_boot = true, ··· 1024 1025 1025 1026 foo_switch() 1026 1027 { 1027 - struct pinmux pmx; 1028 + struct pinmux *pmx; 1028 1029 1029 1030 /* Enable on position A */ 1030 1031 pmx = pinmux_get(&device, "spi0-pos-A");
+33 -21
drivers/pinctrl/core.c
··· 510 510 511 511 static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) 512 512 { 513 - static struct dentry *device_root; 513 + struct dentry *device_root; 514 514 515 515 device_root = debugfs_create_dir(dev_name(pctldev->dev), 516 516 debugfs_root); 517 + pctldev->device_root = device_root; 518 + 517 519 if (IS_ERR(device_root) || !device_root) { 518 520 pr_warn("failed to create debugfs directory for %s\n", 519 521 dev_name(pctldev->dev)); ··· 529 527 device_root, pctldev, &pinctrl_gpioranges_ops); 530 528 pinmux_init_device_debugfs(device_root, pctldev); 531 529 pinconf_init_device_debugfs(device_root, pctldev); 530 + } 531 + 532 + static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev) 533 + { 534 + debugfs_remove_recursive(pctldev->device_root); 532 535 } 533 536 534 537 static void pinctrl_init_debugfs(void) ··· 560 553 { 561 554 } 562 555 556 + static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev) 557 + { 558 + } 559 + 563 560 #endif 564 561 565 562 /** ··· 583 572 if (pctldesc->name == NULL) 584 573 return NULL; 585 574 586 - /* If we're implementing pinmuxing, check the ops for sanity */ 587 - if (pctldesc->pmxops) { 588 - ret = pinmux_check_ops(pctldesc->pmxops); 589 - if (ret) { 590 - pr_err("%s pinmux ops lacks necessary functions\n", 591 - pctldesc->name); 592 - return NULL; 593 - } 594 - } 595 - 596 - /* If we're implementing pinconfig, check the ops for sanity */ 597 - if (pctldesc->confops) { 598 - ret = pinconf_check_ops(pctldesc->confops); 599 - if (ret) { 600 - pr_err("%s pin config ops lacks necessary functions\n", 601 - pctldesc->name); 602 - return NULL; 603 - } 604 - } 605 - 606 575 pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL); 607 576 if (pctldev == NULL) 608 577 return NULL; ··· 596 605 INIT_LIST_HEAD(&pctldev->gpio_ranges); 597 606 mutex_init(&pctldev->gpio_ranges_lock); 598 607 pctldev->dev = dev; 608 + 609 + /* If we're implementing pinmuxing, check the ops for sanity */ 610 + if (pctldesc->pmxops) { 611 + ret = pinmux_check_ops(pctldev); 612 + if (ret) { 613 + pr_err("%s pinmux ops lacks necessary functions\n", 614 + pctldesc->name); 615 + goto out_err; 616 + } 617 + } 618 + 619 + /* If we're implementing pinconfig, check the ops for sanity */ 620 + if (pctldesc->confops) { 621 + ret = pinconf_check_ops(pctldev); 622 + if (ret) { 623 + pr_err("%s pin config ops lacks necessary functions\n", 624 + pctldesc->name); 625 + goto out_err; 626 + } 627 + } 599 628 600 629 /* Register all the pins */ 601 630 pr_debug("try to register %d pins on %s...\n", ··· 652 641 if (pctldev == NULL) 653 642 return; 654 643 644 + pinctrl_remove_device_debugfs(pctldev); 655 645 pinmux_unhog_maps(pctldev); 656 646 /* TODO: check that no pinmuxes are still active? */ 657 647 mutex_lock(&pinctrldev_list_mutex);
+3
drivers/pinctrl/core.h
··· 41 41 struct device *dev; 42 42 struct module *owner; 43 43 void *driver_data; 44 + #ifdef CONFIG_DEBUG_FS 45 + struct dentry *device_root; 46 + #endif 44 47 #ifdef CONFIG_PINMUX 45 48 struct mutex pinmux_hogs_lock; 46 49 struct list_head pinmux_hogs;
+4 -2
drivers/pinctrl/pinconf.c
··· 205 205 } 206 206 EXPORT_SYMBOL(pin_config_group_set); 207 207 208 - int pinconf_check_ops(const struct pinconf_ops *ops) 208 + int pinconf_check_ops(struct pinctrl_dev *pctldev) 209 209 { 210 + const struct pinconf_ops *ops = pctldev->desc->confops; 211 + 210 212 /* We must be able to read out pin status */ 211 213 if (!ops->pin_config_get && !ops->pin_config_group_get) 212 214 return -EINVAL; ··· 238 236 seq_puts(s, "Format: pin (name): pinmux setting array\n"); 239 237 240 238 /* The pin number can be retrived from the pin controller descriptor */ 241 - for (i = 0; pin < pctldev->desc->npins; i++) { 239 + for (i = 0; i < pctldev->desc->npins; i++) { 242 240 struct pin_desc *desc; 243 241 244 242 pin = pctldev->desc->pins[i].number;
+2 -2
drivers/pinctrl/pinconf.h
··· 13 13 14 14 #ifdef CONFIG_PINCONF 15 15 16 - int pinconf_check_ops(const struct pinconf_ops *ops); 16 + int pinconf_check_ops(struct pinctrl_dev *pctldev); 17 17 void pinconf_init_device_debugfs(struct dentry *devroot, 18 18 struct pinctrl_dev *pctldev); 19 19 int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin, ··· 23 23 24 24 #else 25 25 26 - static inline int pinconf_check_ops(const struct pinconf_ops *ops) 26 + static inline int pinconf_check_ops(struct pinctrl_dev *pctldev) 27 27 { 28 28 return 0; 29 29 }
+43 -38
drivers/pinctrl/pinmux.c
··· 53 53 * @dev: the device using this pinmux 54 54 * @usecount: the number of active users of this mux setting, used to keep 55 55 * track of nested use cases 56 - * @pins: an array of discrete physical pins used in this mapping, taken 57 - * from the global pin enumeration space (copied from pinmux map) 58 - * @num_pins: the number of pins in this mapping array, i.e. the number of 59 - * elements in .pins so we can iterate over that array (copied from 60 - * pinmux map) 61 56 * @pctldev: pin control device handling this pinmux 62 57 * @func_selector: the function selector for the pinmux device handling 63 58 * this pinmux ··· 147 152 status = 0; 148 153 149 154 if (status) 150 - dev_err(pctldev->dev, "->request on device %s failed " 151 - "for pin %d\n", 155 + dev_err(pctldev->dev, "->request on device %s failed for pin %d\n", 152 156 pctldev->desc->name, pin); 153 157 out_free_pin: 154 158 if (status) { ··· 349 355 /* First sanity check the new mapping */ 350 356 for (i = 0; i < num_maps; i++) { 351 357 if (!maps[i].name) { 352 - pr_err("failed to register map %d: " 353 - "no map name given\n", i); 358 + pr_err("failed to register map %d: no map name given\n", 359 + i); 354 360 return -EINVAL; 355 361 } 356 362 357 363 if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) { 358 - pr_err("failed to register map %s (%d): " 359 - "no pin control device given\n", 364 + pr_err("failed to register map %s (%d): no pin control device given\n", 360 365 maps[i].name, i); 361 366 return -EINVAL; 362 367 } 363 368 364 369 if (!maps[i].function) { 365 - pr_err("failed to register map %s (%d): " 366 - "no function ID given\n", maps[i].name, i); 370 + pr_err("failed to register map %s (%d): no function ID given\n", 371 + maps[i].name, i); 367 372 return -EINVAL; 368 373 } 369 374 ··· 404 411 } 405 412 406 413 /** 407 - * acquire_pins() - acquire all the pins for a certain funcion on a pinmux 414 + * acquire_pins() - acquire all the pins for a certain function on a pinmux 408 415 * @pctldev: the device to take the pins on 409 416 * @func_selector: the function selector to acquire the pins for 410 417 * @group_selector: the group selector containing the pins to acquire ··· 435 442 ret = pin_request(pctldev, pins[i], func, NULL); 436 443 if (ret) { 437 444 dev_err(pctldev->dev, 438 - "could not get pin %d for function %s " 439 - "on device %s - conflicting mux mappings?\n", 445 + "could not get pin %d for function %s on device %s - conflicting mux mappings?\n", 440 446 pins[i], func ? : "(undefined)", 441 447 pinctrl_dev_get_name(pctldev)); 442 448 /* On error release all taken pins */ ··· 450 458 451 459 /** 452 460 * release_pins() - release pins taken by earlier acquirement 453 - * @pctldev: the device to free the pinx on 461 + * @pctldev: the device to free the pins on 454 462 * @group_selector: the group selector containing the pins to free 455 463 */ 456 464 static void release_pins(struct pinctrl_dev *pctldev, ··· 465 473 ret = pctlops->get_group_pins(pctldev, group_selector, 466 474 &pins, &num_pins); 467 475 if (ret) { 468 - dev_err(pctldev->dev, "could not get pins to release for " 469 - "group selector %d\n", 476 + dev_err(pctldev->dev, "could not get pins to release for group selector %d\n", 470 477 group_selector); 471 478 return; 472 479 } ··· 517 526 ret = pinctrl_get_group_selector(pctldev, groups[0]); 518 527 if (ret < 0) { 519 528 dev_err(pctldev->dev, 520 - "function %s wants group %s but the pin " 521 - "controller does not seem to have that group\n", 529 + "function %s wants group %s but the pin controller does not seem to have that group\n", 522 530 pmxops->get_function_name(pctldev, func_selector), 523 531 groups[0]); 524 532 return ret; ··· 525 535 526 536 if (num_groups > 1) 527 537 dev_dbg(pctldev->dev, 528 - "function %s support more than one group, " 529 - "default-selecting first group %s (%d)\n", 538 + "function %s support more than one group, default-selecting first group %s (%d)\n", 530 539 pmxops->get_function_name(pctldev, func_selector), 531 540 groups[0], 532 541 ret); ··· 617 628 618 629 if (pmx->pctldev && pmx->pctldev != pctldev) { 619 630 dev_err(pctldev->dev, 620 - "different pin control devices given for device %s, " 621 - "function %s\n", 622 - devname, 623 - map->function); 631 + "different pin control devices given for device %s, function %s\n", 632 + devname, map->function); 624 633 return -EINVAL; 625 634 } 626 635 pmx->dev = dev; ··· 682 695 */ 683 696 struct pinmux *pinmux_get(struct device *dev, const char *name) 684 697 { 685 - 686 698 struct pinmux_map const *map = NULL; 687 699 struct pinctrl_dev *pctldev = NULL; 688 700 const char *devname = NULL; ··· 731 745 else if (map->ctrl_dev_name) 732 746 devname = map->ctrl_dev_name; 733 747 734 - pr_warning("could not find a pinctrl device for pinmux " 735 - "function %s, fishy, they shall all have one\n", 748 + pr_warning("could not find a pinctrl device for pinmux function %s, fishy, they shall all have one\n", 736 749 map->function); 737 750 pr_warning("given pinctrl device name: %s", 738 751 devname ? devname : "UNDEFINED"); ··· 889 904 } 890 905 EXPORT_SYMBOL_GPL(pinmux_disable); 891 906 892 - int pinmux_check_ops(const struct pinmux_ops *ops) 907 + int pinmux_check_ops(struct pinctrl_dev *pctldev) 893 908 { 909 + const struct pinmux_ops *ops = pctldev->desc->pmxops; 910 + unsigned selector = 0; 911 + 894 912 /* Check that we implement required operations */ 895 913 if (!ops->list_functions || 896 914 !ops->get_function_name || ··· 901 913 !ops->enable || 902 914 !ops->disable) 903 915 return -EINVAL; 916 + 917 + /* Check that all functions registered have names */ 918 + while (ops->list_functions(pctldev, selector) >= 0) { 919 + const char *fname = ops->get_function_name(pctldev, 920 + selector); 921 + if (!fname) { 922 + pr_err("pinmux ops has no name for function%u\n", 923 + selector); 924 + return -EINVAL; 925 + } 926 + selector++; 927 + } 904 928 905 929 return 0; 906 930 } ··· 932 932 * without any problems, so then we can hog pinmuxes for 933 933 * all devices that just want a static pin mux at this point. 934 934 */ 935 - dev_err(pctldev->dev, "map %s wants to hog a non-system " 936 - "pinmux, this is not going to work\n", map->name); 935 + dev_err(pctldev->dev, "map %s wants to hog a non-system pinmux, this is not going to work\n", 936 + map->name); 937 937 return -EINVAL; 938 938 } 939 939 ··· 993 993 for (i = 0; i < pinmux_maps_num; i++) { 994 994 struct pinmux_map const *map = &pinmux_maps[i]; 995 995 996 - if (((map->ctrl_dev == dev) || 997 - !strcmp(map->ctrl_dev_name, devname)) && 998 - map->hog_on_boot) { 996 + if (!map->hog_on_boot) 997 + continue; 998 + 999 + if ((map->ctrl_dev == dev) || 1000 + (map->ctrl_dev_name && 1001 + !strcmp(map->ctrl_dev_name, devname))) { 999 1002 /* OK time to hog! */ 1000 1003 ret = pinmux_hog_map(pctldev, map); 1001 1004 if (ret) ··· 1125 1122 1126 1123 seq_printf(s, "device: %s function: %s (%u),", 1127 1124 pinctrl_dev_get_name(pmx->pctldev), 1128 - pmxops->get_function_name(pctldev, pmx->func_selector), 1125 + pmxops->get_function_name(pctldev, 1126 + pmx->func_selector), 1129 1127 pmx->func_selector); 1130 1128 1131 1129 seq_printf(s, " groups: ["); 1132 1130 list_for_each_entry(grp, &pmx->groups, node) { 1133 1131 seq_printf(s, " %s (%u)", 1134 - pctlops->get_group_name(pctldev, grp->group_selector), 1132 + pctlops->get_group_name(pctldev, 1133 + grp->group_selector), 1135 1134 grp->group_selector); 1136 1135 } 1137 1136 seq_printf(s, " ]");
+2 -2
drivers/pinctrl/pinmux.h
··· 12 12 */ 13 13 #ifdef CONFIG_PINMUX 14 14 15 - int pinmux_check_ops(const struct pinmux_ops *ops); 15 + int pinmux_check_ops(struct pinctrl_dev *pctldev); 16 16 void pinmux_init_device_debugfs(struct dentry *devroot, 17 17 struct pinctrl_dev *pctldev); 18 18 void pinmux_init_debugfs(struct dentry *subsys_root); ··· 21 21 22 22 #else 23 23 24 - static inline int pinmux_check_ops(const struct pinmux_ops *ops) 24 + static inline int pinmux_check_ops(struct pinctrl_dev *pctldev) 25 25 { 26 26 return 0; 27 27 }