@@ -2106,47 +2106,39 @@ static int tegra_pcie_get_regulators(struct tegra_pcie *pcie, u32 lane_mask)
2106
2106
static int tegra_pcie_parse_dt (struct tegra_pcie * pcie )
2107
2107
{
2108
2108
struct device * dev = pcie -> dev ;
2109
- struct device_node * np = dev -> of_node , * port ;
2109
+ struct device_node * np = dev -> of_node ;
2110
2110
const struct tegra_pcie_soc * soc = pcie -> soc ;
2111
2111
u32 lanes = 0 , mask = 0 ;
2112
2112
unsigned int lane = 0 ;
2113
2113
int err ;
2114
2114
2115
2115
/* parse root ports */
2116
- for_each_child_of_node (np , port ) {
2116
+ for_each_child_of_node_scoped (np , port ) {
2117
2117
struct tegra_pcie_port * rp ;
2118
2118
unsigned int index ;
2119
2119
u32 value ;
2120
2120
char * label ;
2121
2121
2122
2122
err = of_pci_get_devfn (port );
2123
- if (err < 0 ) {
2124
- dev_err (dev , "failed to parse address: %d\n" , err );
2125
- goto err_node_put ;
2126
- }
2123
+ if (err < 0 )
2124
+ return dev_err_probe (dev , err , "failed to parse address\n" );
2127
2125
2128
2126
index = PCI_SLOT (err );
2129
2127
2130
- if (index < 1 || index > soc -> num_ports ) {
2131
- dev_err (dev , "invalid port number: %d\n" , index );
2132
- err = - EINVAL ;
2133
- goto err_node_put ;
2134
- }
2128
+ if (index < 1 || index > soc -> num_ports )
2129
+ return dev_err_probe (dev , - EINVAL ,
2130
+ "invalid port number: %d\n" , index );
2135
2131
2136
2132
index -- ;
2137
2133
2138
2134
err = of_property_read_u32 (port , "nvidia,num-lanes" , & value );
2139
- if (err < 0 ) {
2140
- dev_err (dev , "failed to parse # of lanes: %d\n" ,
2141
- err );
2142
- goto err_node_put ;
2143
- }
2135
+ if (err < 0 )
2136
+ return dev_err_probe (dev , err ,
2137
+ "failed to parse # of lanes\n" );
2144
2138
2145
- if (value > 16 ) {
2146
- dev_err (dev , "invalid # of lanes: %u\n" , value );
2147
- err = - EINVAL ;
2148
- goto err_node_put ;
2149
- }
2139
+ if (value > 16 )
2140
+ return dev_err_probe (dev , - EINVAL ,
2141
+ "invalid # of lanes: %u\n" , value );
2150
2142
2151
2143
lanes |= value << (index << 3 );
2152
2144
@@ -2159,16 +2151,12 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
2159
2151
lane += value ;
2160
2152
2161
2153
rp = devm_kzalloc (dev , sizeof (* rp ), GFP_KERNEL );
2162
- if (!rp ) {
2163
- err = - ENOMEM ;
2164
- goto err_node_put ;
2165
- }
2154
+ if (!rp )
2155
+ return - ENOMEM ;
2166
2156
2167
2157
err = of_address_to_resource (port , 0 , & rp -> regs );
2168
- if (err < 0 ) {
2169
- dev_err (dev , "failed to parse address: %d\n" , err );
2170
- goto err_node_put ;
2171
- }
2158
+ if (err < 0 )
2159
+ return dev_err_probe (dev , err , "failed to parse address\n" );
2172
2160
2173
2161
INIT_LIST_HEAD (& rp -> list );
2174
2162
rp -> index = index ;
@@ -2177,16 +2165,12 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
2177
2165
rp -> np = port ;
2178
2166
2179
2167
rp -> base = devm_pci_remap_cfg_resource (dev , & rp -> regs );
2180
- if (IS_ERR (rp -> base )) {
2181
- err = PTR_ERR (rp -> base );
2182
- goto err_node_put ;
2183
- }
2168
+ if (IS_ERR (rp -> base ))
2169
+ return PTR_ERR (rp -> base );
2184
2170
2185
2171
label = devm_kasprintf (dev , GFP_KERNEL , "pex-reset-%u" , index );
2186
- if (!label ) {
2187
- err = - ENOMEM ;
2188
- goto err_node_put ;
2189
- }
2172
+ if (!label )
2173
+ return - ENOMEM ;
2190
2174
2191
2175
/*
2192
2176
* Returns -ENOENT if reset-gpios property is not populated
@@ -2199,34 +2183,26 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
2199
2183
GPIOD_OUT_LOW ,
2200
2184
label );
2201
2185
if (IS_ERR (rp -> reset_gpio )) {
2202
- if (PTR_ERR (rp -> reset_gpio ) == - ENOENT ) {
2186
+ if (PTR_ERR (rp -> reset_gpio ) == - ENOENT )
2203
2187
rp -> reset_gpio = NULL ;
2204
- } else {
2205
- dev_err (dev , "failed to get reset GPIO: %ld\n" ,
2206
- PTR_ERR (rp -> reset_gpio ));
2207
- err = PTR_ERR (rp -> reset_gpio );
2208
- goto err_node_put ;
2209
- }
2188
+ else
2189
+ return dev_err_probe (dev , PTR_ERR (rp -> reset_gpio ),
2190
+ "failed to get reset GPIO\n" );
2210
2191
}
2211
2192
2212
2193
list_add_tail (& rp -> list , & pcie -> ports );
2213
2194
}
2214
2195
2215
2196
err = tegra_pcie_get_xbar_config (pcie , lanes , & pcie -> xbar_config );
2216
- if (err < 0 ) {
2217
- dev_err (dev , "invalid lane configuration\n" );
2218
- return err ;
2219
- }
2197
+ if (err < 0 )
2198
+ return dev_err_probe (dev , err ,
2199
+ "invalid lane configuration\n" );
2220
2200
2221
2201
err = tegra_pcie_get_regulators (pcie , mask );
2222
2202
if (err < 0 )
2223
2203
return err ;
2224
2204
2225
2205
return 0 ;
2226
-
2227
- err_node_put :
2228
- of_node_put (port );
2229
- return err ;
2230
2206
}
2231
2207
2232
2208
/*
0 commit comments