mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
PCI: kirin: Add dev struct for of_device_get_match_data()
Bean reported thata622435fbe
("PCI: kirin: Prefer of_device_get_match_data()") broke kirin_pcie_probe() because it assumed match data of 0 was a failure when in fact, it meant the match data was "(void *)PCIE_KIRIN_INTERNAL_PHY". Therefore, probing of "hisilicon,kirin960-pcie" devices failed with -EINVAL and an "OF data missing" message. Add a struct kirin_pcie_data to encode the PHY type. Then the result of of_device_get_match_data() should always be a non-NULL pointer to a struct kirin_pcie_data that contains the PHY type. Fixes:a622435fbe
("PCI: kirin: Prefer of_device_get_match_data()") Link: https://lore.kernel.org/r/20220202162659.GA12603@bhelgaas Link: https://lore.kernel.org/r/20220201215941.1203155-1-huobean@gmail.com Reported-by: Bean Huo <beanhuo@micron.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
053ca37c87
commit
7dd3876205
@ -756,22 +756,28 @@ static int __exit kirin_pcie_remove(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct kirin_pcie_data {
|
||||
enum pcie_kirin_phy_type phy_type;
|
||||
};
|
||||
|
||||
static const struct kirin_pcie_data kirin_960_data = {
|
||||
.phy_type = PCIE_KIRIN_INTERNAL_PHY,
|
||||
};
|
||||
|
||||
static const struct kirin_pcie_data kirin_970_data = {
|
||||
.phy_type = PCIE_KIRIN_EXTERNAL_PHY,
|
||||
};
|
||||
|
||||
static const struct of_device_id kirin_pcie_match[] = {
|
||||
{
|
||||
.compatible = "hisilicon,kirin960-pcie",
|
||||
.data = (void *)PCIE_KIRIN_INTERNAL_PHY
|
||||
},
|
||||
{
|
||||
.compatible = "hisilicon,kirin970-pcie",
|
||||
.data = (void *)PCIE_KIRIN_EXTERNAL_PHY
|
||||
},
|
||||
{ .compatible = "hisilicon,kirin960-pcie", .data = &kirin_960_data },
|
||||
{ .compatible = "hisilicon,kirin970-pcie", .data = &kirin_970_data },
|
||||
{},
|
||||
};
|
||||
|
||||
static int kirin_pcie_probe(struct platform_device *pdev)
|
||||
{
|
||||
enum pcie_kirin_phy_type phy_type;
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct kirin_pcie_data *data;
|
||||
struct kirin_pcie *kirin_pcie;
|
||||
struct dw_pcie *pci;
|
||||
int ret;
|
||||
@ -781,13 +787,12 @@ static int kirin_pcie_probe(struct platform_device *pdev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
phy_type = (long)of_device_get_match_data(dev);
|
||||
if (!phy_type) {
|
||||
data = of_device_get_match_data(dev);
|
||||
if (!data) {
|
||||
dev_err(dev, "OF data missing\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL);
|
||||
if (!kirin_pcie)
|
||||
return -ENOMEM;
|
||||
@ -800,7 +805,7 @@ static int kirin_pcie_probe(struct platform_device *pdev)
|
||||
pci->ops = &kirin_dw_pcie_ops;
|
||||
pci->pp.ops = &kirin_pcie_host_ops;
|
||||
kirin_pcie->pci = pci;
|
||||
kirin_pcie->type = phy_type;
|
||||
kirin_pcie->type = data->phy_type;
|
||||
|
||||
ret = kirin_pcie_get_resource(kirin_pcie, pdev);
|
||||
if (ret)
|
||||
|
Loading…
Reference in New Issue
Block a user