Skip to content

Commit 87c7193

Browse files
committed
Merge branch 'pci/driver-cleanup'
- Use of_device_get_match_data(), not of_match_device(), when we only need the device data in altera, artpec6, cadence, designware-plat, dra7xx, keystone, kirin (Fan Fei) - Drop pointless of_device_get_match_data() cast in j721e (Bjorn Helgaas) - Drop redundant struct device * from j721e since struct cdns_pcie already has one (Bjorn Helgaas) - Rename driver structs to *_pcie in intel-gw, iproc, ls-gen4, mediatek-gen3, microchip, mt7621, rcar-gen2, tegra194, uniphier, xgene, xilinx, xilinx-cpm for consistency across drivers (Fan Fei) - Fix invalid address space conversions in hisi, spear13xx (Bjorn Helgaas) * pci/driver-cleanup: PCI: spear13xx: Avoid invalid address space conversions PCI: hisi: Avoid invalid address space conversions PCI: xilinx-cpm: Rename xilinx_cpm_pcie_port to xilinx_cpm_pcie PCI: xilinx: Rename xilinx_pcie_port to xilinx_pcie PCI: xgene: Rename xgene_pcie_port to xgene_pcie PCI: uniphier: Rename uniphier_pcie_priv to uniphier_pcie PCI: tegra194: Rename tegra_pcie_dw to tegra194_pcie PCI: rcar-gen2: Rename rcar_pci_priv to rcar_pci PCI: mt7621: Rename mt7621_pci_ to mt7621_pcie_ PCI: microchip: Rename mc_port to mc_pcie PCI: mediatek-gen3: Rename mtk_pcie_port to mtk_gen3_pcie PCI: ls-gen4: Rename ls_pcie_g4 to ls_g4_pcie PCI: iproc: Rename iproc_pcie_pltfm_ to iproc_pltfm_pcie_ PCI: iproc: Rename iproc_pcie_bcma_ to iproc_bcma_pcie_ PCI: intel-gw: Rename intel_pcie_port to intel_pcie PCI: j721e: Drop redundant struct device * PCI: j721e: Drop pointless of_device_get_match_data() cast PCI: kirin: Prefer of_device_get_match_data() PCI: keystone: Prefer of_device_get_match_data() PCI: dra7xx: Prefer of_device_get_match_data() PCI: designware-plat: Prefer of_device_get_match_data() PCI: cadence: Prefer of_device_get_match_data() PCI: artpec6: Prefer of_device_get_match_data() PCI: altera: Prefer of_device_get_match_data() # Conflicts: # drivers/pci/controller/pcie-mt7621.c
2 parents f5d3ca6 + 73a0c2b commit 87c7193

23 files changed

+755
-756
lines changed

drivers/pci/controller/cadence/pci-j721e.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ enum link_status {
5151
#define MAX_LANES 2
5252

5353
struct j721e_pcie {
54-
struct device *dev;
54+
struct cdns_pcie *cdns_pcie;
5555
struct clk *refclk;
5656
u32 mode;
5757
u32 num_lanes;
58-
struct cdns_pcie *cdns_pcie;
5958
void __iomem *user_cfg_base;
6059
void __iomem *intd_cfg_base;
6160
u32 linkdown_irq_regfield;
@@ -99,7 +98,7 @@ static inline void j721e_pcie_intd_writel(struct j721e_pcie *pcie, u32 offset,
9998
static irqreturn_t j721e_pcie_link_irq_handler(int irq, void *priv)
10099
{
101100
struct j721e_pcie *pcie = priv;
102-
struct device *dev = pcie->dev;
101+
struct device *dev = pcie->cdns_pcie->dev;
103102
u32 reg;
104103

105104
reg = j721e_pcie_intd_readl(pcie, STATUS_REG_SYS_2);
@@ -165,7 +164,7 @@ static const struct cdns_pcie_ops j721e_pcie_ops = {
165164
static int j721e_pcie_set_mode(struct j721e_pcie *pcie, struct regmap *syscon,
166165
unsigned int offset)
167166
{
168-
struct device *dev = pcie->dev;
167+
struct device *dev = pcie->cdns_pcie->dev;
169168
u32 mask = J721E_MODE_RC;
170169
u32 mode = pcie->mode;
171170
u32 val = 0;
@@ -184,7 +183,7 @@ static int j721e_pcie_set_mode(struct j721e_pcie *pcie, struct regmap *syscon,
184183
static int j721e_pcie_set_link_speed(struct j721e_pcie *pcie,
185184
struct regmap *syscon, unsigned int offset)
186185
{
187-
struct device *dev = pcie->dev;
186+
struct device *dev = pcie->cdns_pcie->dev;
188187
struct device_node *np = dev->of_node;
189188
int link_speed;
190189
u32 val = 0;
@@ -205,7 +204,7 @@ static int j721e_pcie_set_link_speed(struct j721e_pcie *pcie,
205204
static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie,
206205
struct regmap *syscon, unsigned int offset)
207206
{
208-
struct device *dev = pcie->dev;
207+
struct device *dev = pcie->cdns_pcie->dev;
209208
u32 lanes = pcie->num_lanes;
210209
u32 val = 0;
211210
int ret;
@@ -220,7 +219,7 @@ static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie,
220219

221220
static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
222221
{
223-
struct device *dev = pcie->dev;
222+
struct device *dev = pcie->cdns_pcie->dev;
224223
struct device_node *node = dev->of_node;
225224
struct of_phandle_args args;
226225
unsigned int offset = 0;
@@ -354,7 +353,7 @@ static int j721e_pcie_probe(struct platform_device *pdev)
354353
struct device *dev = &pdev->dev;
355354
struct device_node *node = dev->of_node;
356355
struct pci_host_bridge *bridge;
357-
struct j721e_pcie_data *data;
356+
const struct j721e_pcie_data *data;
358357
struct cdns_pcie *cdns_pcie;
359358
struct j721e_pcie *pcie;
360359
struct cdns_pcie_rc *rc;
@@ -367,7 +366,7 @@ static int j721e_pcie_probe(struct platform_device *pdev)
367366
int ret;
368367
int irq;
369368

370-
data = (struct j721e_pcie_data *)of_device_get_match_data(dev);
369+
data = of_device_get_match_data(dev);
371370
if (!data)
372371
return -EINVAL;
373372

@@ -377,7 +376,6 @@ static int j721e_pcie_probe(struct platform_device *pdev)
377376
if (!pcie)
378377
return -ENOMEM;
379378

380-
pcie->dev = dev;
381379
pcie->mode = mode;
382380
pcie->linkdown_irq_regfield = data->linkdown_irq_regfield;
383381

drivers/pci/controller/cadence/pcie-cadence-plat.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev)
4545
{
4646
const struct cdns_plat_pcie_of_data *data;
4747
struct cdns_plat_pcie *cdns_plat_pcie;
48-
const struct of_device_id *match;
4948
struct device *dev = &pdev->dev;
5049
struct pci_host_bridge *bridge;
5150
struct cdns_pcie_ep *ep;
@@ -54,11 +53,10 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev)
5453
bool is_rc;
5554
int ret;
5655

57-
match = of_match_device(cdns_plat_pcie_of_match, dev);
58-
if (!match)
56+
data = of_device_get_match_data(dev);
57+
if (!data)
5958
return -EINVAL;
6059

61-
data = (struct cdns_plat_pcie_of_data *)match->data;
6260
is_rc = data->is_rc;
6361

6462
pr_debug(" Started %s with is_rc: %d\n", __func__, is_rc);

drivers/pci/controller/dwc/pci-dra7xx.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,16 +697,14 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
697697
struct device_node *np = dev->of_node;
698698
char name[10];
699699
struct gpio_desc *reset;
700-
const struct of_device_id *match;
701700
const struct dra7xx_pcie_of_data *data;
702701
enum dw_pcie_device_mode mode;
703702
u32 b1co_mode_sel_mask;
704703

705-
match = of_match_device(of_match_ptr(of_dra7xx_pcie_match), dev);
706-
if (!match)
704+
data = of_device_get_match_data(dev);
705+
if (!data)
707706
return -EINVAL;
708707

709-
data = (struct dra7xx_pcie_of_data *)match->data;
710708
mode = (enum dw_pcie_device_mode)data->mode;
711709
b1co_mode_sel_mask = data->b1co_mode_sel_mask;
712710

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev)
11081108
struct device *dev = &pdev->dev;
11091109
struct device_node *np = dev->of_node;
11101110
const struct ks_pcie_of_data *data;
1111-
const struct of_device_id *match;
11121111
enum dw_pcie_device_mode mode;
11131112
struct dw_pcie *pci;
11141113
struct keystone_pcie *ks_pcie;
@@ -1125,8 +1124,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev)
11251124
int irq;
11261125
int i;
11271126

1128-
match = of_match_device(of_match_ptr(ks_pcie_of_match), dev);
1129-
data = (struct ks_pcie_of_data *)match->data;
1127+
data = of_device_get_match_data(dev);
11301128
if (!data)
11311129
return -EINVAL;
11321130

drivers/pci/controller/dwc/pcie-artpec6.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,17 +380,15 @@ static int artpec6_pcie_probe(struct platform_device *pdev)
380380
struct dw_pcie *pci;
381381
struct artpec6_pcie *artpec6_pcie;
382382
int ret;
383-
const struct of_device_id *match;
384383
const struct artpec_pcie_of_data *data;
385384
enum artpec_pcie_variants variant;
386385
enum dw_pcie_device_mode mode;
387386
u32 val;
388387

389-
match = of_match_device(artpec6_pcie_of_match, dev);
390-
if (!match)
388+
data = of_device_get_match_data(dev);
389+
if (!data)
391390
return -EINVAL;
392391

393-
data = (struct artpec_pcie_of_data *)match->data;
394392
variant = (enum artpec_pcie_variants)data->variant;
395393
mode = (enum dw_pcie_device_mode)data->mode;
396394

drivers/pci/controller/dwc/pcie-designware-plat.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,13 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
122122
struct dw_plat_pcie *dw_plat_pcie;
123123
struct dw_pcie *pci;
124124
int ret;
125-
const struct of_device_id *match;
126125
const struct dw_plat_pcie_of_data *data;
127126
enum dw_pcie_device_mode mode;
128127

129-
match = of_match_device(dw_plat_pcie_of_match, dev);
130-
if (!match)
128+
data = of_device_get_match_data(dev);
129+
if (!data)
131130
return -EINVAL;
132131

133-
data = (struct dw_plat_pcie_of_data *)match->data;
134132
mode = (enum dw_pcie_device_mode)data->mode;
135133

136134
dw_plat_pcie = devm_kzalloc(dev, sizeof(*dw_plat_pcie), GFP_KERNEL);

drivers/pci/controller/dwc/pcie-hisi.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
#if defined(CONFIG_PCI_HISI) || (defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS))
2020

21+
struct hisi_pcie {
22+
void __iomem *reg_base;
23+
};
24+
2125
static int hisi_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
2226
int size, u32 *val)
2327
{
@@ -58,10 +62,10 @@ static void __iomem *hisi_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
5862
int where)
5963
{
6064
struct pci_config_window *cfg = bus->sysdata;
61-
void __iomem *reg_base = cfg->priv;
65+
struct hisi_pcie *pcie = cfg->priv;
6266

6367
if (bus->number == cfg->busr.start)
64-
return reg_base + where;
68+
return pcie->reg_base + where;
6569
else
6670
return pci_ecam_map_bus(bus, devfn, where);
6771
}
@@ -71,12 +75,16 @@ static void __iomem *hisi_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
7175
static int hisi_pcie_init(struct pci_config_window *cfg)
7276
{
7377
struct device *dev = cfg->parent;
78+
struct hisi_pcie *pcie;
7479
struct acpi_device *adev = to_acpi_device(dev);
7580
struct acpi_pci_root *root = acpi_driver_data(adev);
7681
struct resource *res;
77-
void __iomem *reg_base;
7882
int ret;
7983

84+
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
85+
if (!pcie)
86+
return -ENOMEM;
87+
8088
/*
8189
* Retrieve RC base and size from a HISI0081 device with _UID
8290
* matching our segment.
@@ -91,11 +99,11 @@ static int hisi_pcie_init(struct pci_config_window *cfg)
9199
return -ENOMEM;
92100
}
93101

94-
reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res));
95-
if (!reg_base)
102+
pcie->reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res));
103+
if (!pcie->reg_base)
96104
return -ENOMEM;
97105

98-
cfg->priv = reg_base;
106+
cfg->priv = pcie;
99107
return 0;
100108
}
101109

@@ -115,21 +123,25 @@ const struct pci_ecam_ops hisi_pcie_ops = {
115123
static int hisi_pcie_platform_init(struct pci_config_window *cfg)
116124
{
117125
struct device *dev = cfg->parent;
126+
struct hisi_pcie *pcie;
118127
struct platform_device *pdev = to_platform_device(dev);
119128
struct resource *res;
120-
void __iomem *reg_base;
129+
130+
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
131+
if (!pcie)
132+
return -ENOMEM;
121133

122134
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
123135
if (!res) {
124136
dev_err(dev, "missing \"reg[1]\"property\n");
125137
return -EINVAL;
126138
}
127139

128-
reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res));
129-
if (!reg_base)
140+
pcie->reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res));
141+
if (!pcie->reg_base)
130142
return -ENOMEM;
131143

132-
cfg->priv = reg_base;
144+
cfg->priv = pcie;
133145
return 0;
134146
}
135147

0 commit comments

Comments
 (0)