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.

mmc: Merge the immutable mux branch into next

The mux branch contains updates to the mux core along with some
corresponding changes for a couple of consumer drivers, including an mmc
driver. Let's merge it into the next branch to get it tested and queued for
the next release.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

+307 -92
+6
Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
··· 106 106 iommus: 107 107 maxItems: 1 108 108 109 + mux-states: 110 + description: 111 + mux controller node to route the SD/SDIO/eMMC signals from SoC to cards. 112 + maxItems: 1 113 + 109 114 power-domains: 110 115 maxItems: 1 111 116 ··· 280 275 max-frequency = <195000000>; 281 276 power-domains = <&sysc R8A7790_PD_ALWAYS_ON>; 282 277 resets = <&cpg 314>; 278 + mux-states = <&mux 0>; 283 279 }; 284 280 285 281 sdhi1: mmc@ee120000 {
+5 -19
drivers/i2c/busses/i2c-omap.c
··· 1453 1453 (1000 * omap->speed / 8); 1454 1454 } 1455 1455 1456 - if (of_property_present(node, "mux-states")) { 1457 - struct mux_state *mux_state; 1458 - 1459 - mux_state = devm_mux_state_get(&pdev->dev, NULL); 1460 - if (IS_ERR(mux_state)) { 1461 - r = PTR_ERR(mux_state); 1462 - dev_dbg(&pdev->dev, "failed to get I2C mux: %d\n", r); 1463 - goto err_put_pm; 1464 - } 1465 - omap->mux_state = mux_state; 1466 - r = mux_state_select(omap->mux_state); 1467 - if (r) { 1468 - dev_err(&pdev->dev, "failed to select I2C mux: %d\n", r); 1469 - goto err_put_pm; 1470 - } 1456 + omap->mux_state = devm_mux_state_get_optional_selected(&pdev->dev, NULL); 1457 + if (IS_ERR(omap->mux_state)) { 1458 + r = PTR_ERR(omap->mux_state); 1459 + goto err_put_pm; 1471 1460 } 1472 1461 1473 1462 /* reset ASAP, clearing any IRQs */ 1474 1463 r = omap_i2c_init(omap); 1475 1464 if (r) 1476 - goto err_mux_state_deselect; 1465 + goto err_put_pm; 1477 1466 1478 1467 if (omap->rev < OMAP_I2C_OMAP1_REV_2) 1479 1468 r = devm_request_irq(&pdev->dev, omap->irq, omap_i2c_omap1_isr, ··· 1504 1515 1505 1516 err_unuse_clocks: 1506 1517 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); 1507 - err_mux_state_deselect: 1508 - if (omap->mux_state) 1509 - mux_state_deselect(omap->mux_state); 1510 1518 err_put_pm: 1511 1519 pm_runtime_put_sync(omap->dev); 1512 1520 err_disable_pm:
+6
drivers/mmc/host/renesas_sdhi_core.c
··· 26 26 #include <linux/mmc/mmc.h> 27 27 #include <linux/mmc/slot-gpio.h> 28 28 #include <linux/module.h> 29 + #include <linux/mux/consumer.h> 29 30 #include <linux/pinctrl/consumer.h> 30 31 #include <linux/pinctrl/pinctrl-state.h> 31 32 #include <linux/platform_data/tmio.h> ··· 1063 1062 struct regulator_dev *rdev; 1064 1063 struct renesas_sdhi_dma *dma_priv; 1065 1064 struct device *dev = &pdev->dev; 1065 + struct mux_state *mux_state; 1066 1066 struct tmio_mmc_host *host; 1067 1067 struct renesas_sdhi *priv; 1068 1068 int num_irqs, irq, ret, i; ··· 1117 1115 priv->pins_uhs = pinctrl_lookup_state(priv->pinctrl, 1118 1116 "state_uhs"); 1119 1117 } 1118 + 1119 + mux_state = devm_mux_state_get_optional_selected(&pdev->dev, NULL); 1120 + if (IS_ERR(mux_state)) 1121 + return PTR_ERR(mux_state); 1120 1122 1121 1123 host = tmio_mmc_host_alloc(pdev, mmc_data); 1122 1124 if (IS_ERR(host))
+15 -2
drivers/mux/Kconfig
··· 4 4 # 5 5 6 6 config MULTIPLEXER 7 - tristate 7 + bool 8 + 9 + config MUX_CORE 10 + bool "Generic Multiplexer Support" 11 + select MULTIPLEXER 12 + help 13 + This framework is designed to abstract multiplexer handling for 14 + devices via various GPIO-, MMIO/Regmap or specific multiplexer 15 + controller chips. 16 + 17 + If unsure, say no. 18 + 19 + if MULTIPLEXER 8 20 9 21 menu "Multiplexer drivers" 10 - depends on MULTIPLEXER 11 22 12 23 config MUX_ADG792A 13 24 tristate "Analog Devices ADG792A/ADG792G Multiplexers" ··· 71 60 be called mux-mmio. 72 61 73 62 endmenu 63 + 64 + endif # MULTIPLEXER
+169 -29
drivers/mux/core.c
··· 46 46 .name = "mux", 47 47 }; 48 48 49 + /** 50 + * struct devm_mux_state_state - Tracks managed resources for mux-state objects. 51 + * @mstate: Pointer to a mux state. 52 + * @exit: An optional callback to execute before free. 53 + */ 54 + struct devm_mux_state_state { 55 + struct mux_state *mstate; 56 + int (*exit)(struct mux_state *mstate); 57 + }; 58 + 49 59 static DEFINE_IDA(mux_ida); 50 60 51 61 static int __init mux_init(void) ··· 526 516 return dev ? to_mux_chip(dev) : NULL; 527 517 } 528 518 529 - /* 519 + /** 530 520 * mux_get() - Get the mux-control for a device. 531 521 * @dev: The device that needs a mux-control. 532 522 * @mux_name: The name identifying the mux-control. 533 523 * @state: Pointer to where the requested state is returned, or NULL when 534 524 * the required multiplexer states are handled by other means. 525 + * @optional: Whether to return NULL and silence errors when mux doesn't exist. 535 526 * 536 - * Return: A pointer to the mux-control, or an ERR_PTR with a negative errno. 527 + * Return: Pointer to the mux-control on success, an ERR_PTR with a negative 528 + * errno on error, or NULL if optional is true and mux doesn't exist. 537 529 */ 538 530 static struct mux_control *mux_get(struct device *dev, const char *mux_name, 539 - unsigned int *state) 531 + unsigned int *state, bool optional) 540 532 { 541 533 struct device_node *np = dev->of_node; 542 534 struct of_phandle_args args; ··· 554 542 else 555 543 index = of_property_match_string(np, "mux-control-names", 556 544 mux_name); 557 - if (index < 0) { 545 + if (index < 0 && optional) { 546 + return NULL; 547 + } else if (index < 0) { 558 548 dev_err(dev, "mux controller '%s' not found\n", 559 549 mux_name); 560 550 return ERR_PTR(index); ··· 572 558 "mux-controls", "#mux-control-cells", 573 559 index, &args); 574 560 if (ret) { 561 + if (optional && ret == -ENOENT) 562 + return NULL; 563 + 575 564 dev_err(dev, "%pOF: failed to get mux-%s %s(%i)\n", 576 - np, state ? "state" : "control", mux_name ?: "", index); 565 + np, state ? "state" : "control", 566 + mux_name ?: "", index); 577 567 return ERR_PTR(ret); 578 568 } 579 569 ··· 635 617 */ 636 618 struct mux_control *mux_control_get(struct device *dev, const char *mux_name) 637 619 { 638 - return mux_get(dev, mux_name, NULL); 620 + struct mux_control *mux = mux_get(dev, mux_name, NULL, false); 621 + 622 + if (!mux) 623 + return ERR_PTR(-ENOENT); 624 + 625 + return mux; 639 626 } 640 627 EXPORT_SYMBOL_GPL(mux_control_get); 628 + 629 + /** 630 + * mux_control_get_optional() - Get the optional mux-control for a device. 631 + * @dev: The device that needs a mux-control. 632 + * @mux_name: The name identifying the mux-control. 633 + * 634 + * Return: Pointer to the mux-control on success, an ERR_PTR with a negative 635 + * errno on error, or NULL if mux doesn't exist. 636 + */ 637 + struct mux_control *mux_control_get_optional(struct device *dev, const char *mux_name) 638 + { 639 + return mux_get(dev, mux_name, NULL, true); 640 + } 641 + EXPORT_SYMBOL_GPL(mux_control_get_optional); 641 642 642 643 /** 643 644 * mux_control_put() - Put away the mux-control for good. ··· 707 670 } 708 671 EXPORT_SYMBOL_GPL(devm_mux_control_get); 709 672 710 - /* 673 + /** 711 674 * mux_state_get() - Get the mux-state for a device. 712 675 * @dev: The device that needs a mux-state. 713 676 * @mux_name: The name identifying the mux-state. 677 + * @optional: Whether to return NULL and silence errors when mux doesn't exist. 714 678 * 715 - * Return: A pointer to the mux-state, or an ERR_PTR with a negative errno. 679 + * Return: Pointer to the mux-state on success, an ERR_PTR with a negative 680 + * errno on error, or NULL if optional is true and mux doesn't exist. 716 681 */ 717 - static struct mux_state *mux_state_get(struct device *dev, const char *mux_name) 682 + static struct mux_state *mux_state_get(struct device *dev, const char *mux_name, bool optional) 718 683 { 719 684 struct mux_state *mstate; 720 685 ··· 724 685 if (!mstate) 725 686 return ERR_PTR(-ENOMEM); 726 687 727 - mstate->mux = mux_get(dev, mux_name, &mstate->state); 688 + mstate->mux = mux_get(dev, mux_name, &mstate->state, optional); 728 689 if (IS_ERR(mstate->mux)) { 729 690 int err = PTR_ERR(mstate->mux); 730 691 731 692 kfree(mstate); 732 693 return ERR_PTR(err); 694 + } else if (!mstate->mux) { 695 + kfree(mstate); 696 + return optional ? NULL : ERR_PTR(-ENOENT); 733 697 } 734 698 735 699 return mstate; ··· 752 710 753 711 static void devm_mux_state_release(struct device *dev, void *res) 754 712 { 755 - struct mux_state *mstate = *(struct mux_state **)res; 713 + struct devm_mux_state_state *devm_state = res; 756 714 715 + if (devm_state->exit) 716 + devm_state->exit(devm_state->mstate); 717 + 718 + mux_state_put(devm_state->mstate); 719 + } 720 + 721 + /** 722 + * __devm_mux_state_get() - Get the optional mux-state for a device, 723 + * with resource management. 724 + * @dev: The device that needs a mux-state. 725 + * @mux_name: The name identifying the mux-state. 726 + * @optional: Whether to return NULL and silence errors when mux doesn't exist. 727 + * @init: Optional function pointer for mux-state object initialisation. 728 + * @exit: Optional function pointer for mux-state object cleanup on release. 729 + * 730 + * Return: Pointer to the mux-state on success, an ERR_PTR with a negative 731 + * errno on error, or NULL if optional is true and mux doesn't exist. 732 + */ 733 + static struct mux_state *__devm_mux_state_get(struct device *dev, const char *mux_name, 734 + bool optional, 735 + int (*init)(struct mux_state *mstate), 736 + int (*exit)(struct mux_state *mstate)) 737 + { 738 + struct devm_mux_state_state *devm_state; 739 + struct mux_state *mstate; 740 + int ret; 741 + 742 + mstate = mux_state_get(dev, mux_name, optional); 743 + if (IS_ERR(mstate)) 744 + return ERR_CAST(mstate); 745 + else if (optional && !mstate) 746 + return NULL; 747 + else if (!mstate) 748 + return ERR_PTR(-ENOENT); 749 + 750 + devm_state = devres_alloc(devm_mux_state_release, sizeof(*devm_state), GFP_KERNEL); 751 + if (!devm_state) { 752 + ret = -ENOMEM; 753 + goto err_devres_alloc; 754 + } 755 + 756 + if (init) { 757 + ret = init(mstate); 758 + if (ret) 759 + goto err_mux_state_init; 760 + } 761 + 762 + devm_state->mstate = mstate; 763 + devm_state->exit = exit; 764 + devres_add(dev, devm_state); 765 + 766 + return mstate; 767 + 768 + err_mux_state_init: 769 + devres_free(devm_state); 770 + err_devres_alloc: 757 771 mux_state_put(mstate); 772 + return ERR_PTR(ret); 758 773 } 759 774 760 775 /** ··· 821 722 * @mux_name: The name identifying the mux-control. 822 723 * 823 724 * Return: Pointer to the mux-state, or an ERR_PTR with a negative errno. 725 + * 726 + * The mux-state will automatically be freed on release. 824 727 */ 825 - struct mux_state *devm_mux_state_get(struct device *dev, 826 - const char *mux_name) 728 + struct mux_state *devm_mux_state_get(struct device *dev, const char *mux_name) 827 729 { 828 - struct mux_state **ptr, *mstate; 829 - 830 - ptr = devres_alloc(devm_mux_state_release, sizeof(*ptr), GFP_KERNEL); 831 - if (!ptr) 832 - return ERR_PTR(-ENOMEM); 833 - 834 - mstate = mux_state_get(dev, mux_name); 835 - if (IS_ERR(mstate)) { 836 - devres_free(ptr); 837 - return mstate; 838 - } 839 - 840 - *ptr = mstate; 841 - devres_add(dev, ptr); 842 - 843 - return mstate; 730 + return __devm_mux_state_get(dev, mux_name, false, NULL, NULL); 844 731 } 845 732 EXPORT_SYMBOL_GPL(devm_mux_state_get); 733 + 734 + /** 735 + * devm_mux_state_get_optional() - Get the optional mux-state for a device, 736 + * with resource management. 737 + * @dev: The device that needs a mux-state. 738 + * @mux_name: The name identifying the mux-state. 739 + * 740 + * Return: Pointer to the mux-state on success, an ERR_PTR with a negative 741 + * errno on error, or NULL if mux doesn't exist. 742 + * 743 + * The mux-state will automatically be freed on release. 744 + */ 745 + struct mux_state *devm_mux_state_get_optional(struct device *dev, const char *mux_name) 746 + { 747 + return __devm_mux_state_get(dev, mux_name, true, NULL, NULL); 748 + } 749 + EXPORT_SYMBOL_GPL(devm_mux_state_get_optional); 750 + 751 + /** 752 + * devm_mux_state_get_selected() - Get the mux-state for a device, with 753 + * resource management. 754 + * @dev: The device that needs a mux-state. 755 + * @mux_name: The name identifying the mux-state. 756 + * 757 + * Return: Pointer to the mux-state, or an ERR_PTR with a negative errno. 758 + * 759 + * The returned mux-state (if valid) is already selected. 760 + * 761 + * The mux-state will automatically be deselected and freed on release. 762 + */ 763 + struct mux_state *devm_mux_state_get_selected(struct device *dev, const char *mux_name) 764 + { 765 + return __devm_mux_state_get(dev, mux_name, false, mux_state_select, mux_state_deselect); 766 + } 767 + EXPORT_SYMBOL_GPL(devm_mux_state_get_selected); 768 + 769 + /** 770 + * devm_mux_state_get_optional_selected() - Get the optional mux-state for 771 + * a device, with resource management. 772 + * @dev: The device that needs a mux-state. 773 + * @mux_name: The name identifying the mux-state. 774 + * 775 + * Return: Pointer to the mux-state on success, an ERR_PTR with a negative 776 + * errno on error, or NULL if mux doesn't exist. 777 + * 778 + * The returned mux-state (if valid) is already selected. 779 + * 780 + * The mux-state will automatically be deselected and freed on release. 781 + */ 782 + struct mux_state *devm_mux_state_get_optional_selected(struct device *dev, 783 + const char *mux_name) 784 + { 785 + return __devm_mux_state_get(dev, mux_name, true, mux_state_select, mux_state_deselect); 786 + } 787 + EXPORT_SYMBOL_GPL(devm_mux_state_get_optional_selected); 846 788 847 789 /* 848 790 * Using subsys_initcall instead of module_init here to try to ensure - for
-10
drivers/phy/phy-can-transceiver.c
··· 126 126 }; 127 127 MODULE_DEVICE_TABLE(of, can_transceiver_phy_ids); 128 128 129 - /* Temporary wrapper until the multiplexer subsystem supports optional muxes */ 130 - static inline struct mux_state * 131 - devm_mux_state_get_optional(struct device *dev, const char *mux_name) 132 - { 133 - if (!of_property_present(dev->of_node, "mux-states")) 134 - return NULL; 135 - 136 - return devm_mux_state_get(dev, mux_name); 137 - } 138 - 139 129 static struct phy *can_transceiver_phy_xlate(struct device *dev, 140 130 const struct of_phandle_args *args) 141 131 {
+2 -28
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 939 939 return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable); 940 940 } 941 941 942 - /* Temporary wrapper until the multiplexer subsystem supports optional muxes */ 943 - static inline struct mux_state * 944 - devm_mux_state_get_optional(struct device *dev, const char *mux_name) 945 - { 946 - if (!of_property_present(dev->of_node, "mux-states")) 947 - return NULL; 948 - 949 - return devm_mux_state_get(dev, mux_name); 950 - } 951 - 952 - static void rcar_gen3_phy_mux_state_deselect(void *data) 953 - { 954 - mux_state_deselect(data); 955 - } 956 - 957 942 static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) 958 943 { 959 944 struct device *dev = &pdev->dev; ··· 1021 1036 phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]); 1022 1037 } 1023 1038 1024 - mux_state = devm_mux_state_get_optional(dev, NULL); 1039 + mux_state = devm_mux_state_get_optional_selected(dev, NULL); 1025 1040 if (IS_ERR(mux_state)) 1026 - return PTR_ERR(mux_state); 1027 - if (mux_state) { 1028 - ret = mux_state_select(mux_state); 1029 - if (ret) 1030 - return dev_err_probe(dev, ret, "Failed to select USB mux\n"); 1031 - 1032 - ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect, 1033 - mux_state); 1034 - if (ret) 1035 - return dev_err_probe(dev, ret, 1036 - "Failed to register USB mux state deselect\n"); 1037 - } 1041 + return dev_err_probe(dev, PTR_ERR(mux_state), "Failed to get USB mux\n"); 1038 1042 1039 1043 if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) { 1040 1044 ret = rcar_gen3_phy_usb2_vbus_regulator_register(channel);
+104 -4
include/linux/mux/consumer.h
··· 16 16 struct mux_control; 17 17 struct mux_state; 18 18 19 + #if IS_ENABLED(CONFIG_MULTIPLEXER) 20 + 19 21 unsigned int mux_control_states(struct mux_control *mux); 20 22 int __must_check mux_control_select_delay(struct mux_control *mux, 21 23 unsigned int state, ··· 56 54 int mux_state_deselect(struct mux_state *mstate); 57 55 58 56 struct mux_control *mux_control_get(struct device *dev, const char *mux_name); 57 + struct mux_control *mux_control_get_optional(struct device *dev, const char *mux_name); 59 58 void mux_control_put(struct mux_control *mux); 60 59 61 - struct mux_control *devm_mux_control_get(struct device *dev, 62 - const char *mux_name); 63 - struct mux_state *devm_mux_state_get(struct device *dev, 64 - const char *mux_name); 60 + struct mux_control *devm_mux_control_get(struct device *dev, const char *mux_name); 61 + struct mux_state *devm_mux_state_get(struct device *dev, const char *mux_name); 62 + struct mux_state *devm_mux_state_get_optional(struct device *dev, const char *mux_name); 63 + struct mux_state *devm_mux_state_get_selected(struct device *dev, const char *mux_name); 64 + struct mux_state *devm_mux_state_get_optional_selected(struct device *dev, const char *mux_name); 65 + 66 + #else 67 + 68 + static inline unsigned int mux_control_states(struct mux_control *mux) 69 + { 70 + return 0; 71 + } 72 + static inline int __must_check mux_control_select_delay(struct mux_control *mux, 73 + unsigned int state, unsigned int delay_us) 74 + { 75 + return -EOPNOTSUPP; 76 + } 77 + static inline int __must_check mux_state_select_delay(struct mux_state *mstate, 78 + unsigned int delay_us) 79 + { 80 + return -EOPNOTSUPP; 81 + } 82 + static inline int __must_check mux_control_try_select_delay(struct mux_control *mux, 83 + unsigned int state, 84 + unsigned int delay_us) 85 + { 86 + return -EOPNOTSUPP; 87 + } 88 + static inline int __must_check mux_state_try_select_delay(struct mux_state *mstate, 89 + unsigned int delay_us) 90 + { 91 + return -EOPNOTSUPP; 92 + } 93 + 94 + static inline int __must_check mux_control_select(struct mux_control *mux, 95 + unsigned int state) 96 + { 97 + return -EOPNOTSUPP; 98 + } 99 + 100 + static inline int __must_check mux_state_select(struct mux_state *mstate) 101 + { 102 + return -EOPNOTSUPP; 103 + } 104 + 105 + static inline int __must_check mux_control_try_select(struct mux_control *mux, 106 + unsigned int state) 107 + { 108 + return -EOPNOTSUPP; 109 + } 110 + 111 + static inline int __must_check mux_state_try_select(struct mux_state *mstate) 112 + { 113 + return -EOPNOTSUPP; 114 + } 115 + 116 + static inline int mux_control_deselect(struct mux_control *mux) 117 + { 118 + return -EOPNOTSUPP; 119 + } 120 + static inline int mux_state_deselect(struct mux_state *mstate) 121 + { 122 + return -EOPNOTSUPP; 123 + } 124 + 125 + static inline struct mux_control *mux_control_get(struct device *dev, const char *mux_name) 126 + { 127 + return ERR_PTR(-EOPNOTSUPP); 128 + } 129 + static inline struct mux_control *mux_control_get_optional(struct device *dev, 130 + const char *mux_name) 131 + { 132 + return NULL; 133 + } 134 + static inline void mux_control_put(struct mux_control *mux) {} 135 + 136 + static inline struct mux_control *devm_mux_control_get(struct device *dev, const char *mux_name) 137 + { 138 + return ERR_PTR(-EOPNOTSUPP); 139 + } 140 + static inline struct mux_state *devm_mux_state_get(struct device *dev, const char *mux_name) 141 + { 142 + return ERR_PTR(-EOPNOTSUPP); 143 + } 144 + static inline struct mux_state *devm_mux_state_get_optional(struct device *dev, 145 + const char *mux_name) 146 + { 147 + return NULL; 148 + } 149 + static inline struct mux_state *devm_mux_state_get_selected(struct device *dev, 150 + const char *mux_name) 151 + { 152 + return ERR_PTR(-EOPNOTSUPP); 153 + } 154 + static inline struct mux_state *devm_mux_state_get_optional_selected(struct device *dev, 155 + const char *mux_name) 156 + { 157 + return NULL; 158 + } 159 + 160 + #endif /* CONFIG_MULTIPLEXER */ 65 161 66 162 #endif /* _LINUX_MUX_CONSUMER_H */