Skip to content

Commit 4e51947

Browse files
committed
Merge branch 'pci/ctrl/mvebu'
- Switch to the gpiod API so we can make of_get_named_gpio_flags() private (Dmitry Torokhov) * pci/ctrl/mvebu: PCI: mvebu: Switch to using gpiod API
2 parents 0454c6c + 76007cc commit 4e51947

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

drivers/pci/controller/pci-mvebu.c

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
#include <linux/bitfield.h>
1212
#include <linux/clk.h>
1313
#include <linux/delay.h>
14-
#include <linux/gpio.h>
14+
#include <linux/gpio/consumer.h>
1515
#include <linux/init.h>
16+
#include <linux/irqchip/chained_irq.h>
1617
#include <linux/mbus.h>
1718
#include <linux/slab.h>
1819
#include <linux/platform_device.h>
1920
#include <linux/of_address.h>
2021
#include <linux/of_irq.h>
21-
#include <linux/of_gpio.h>
2222
#include <linux/of_pci.h>
2323
#include <linux/of_platform.h>
2424

@@ -1261,9 +1261,8 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
12611261
struct mvebu_pcie_port *port, struct device_node *child)
12621262
{
12631263
struct device *dev = &pcie->pdev->dev;
1264-
enum of_gpio_flags flags;
12651264
u32 slot_power_limit;
1266-
int reset_gpio, ret;
1265+
int ret;
12671266
u32 num_lanes;
12681267

12691268
port->pcie = pcie;
@@ -1327,40 +1326,24 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
13271326
port->name, child);
13281327
}
13291328

1330-
reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags);
1331-
if (reset_gpio == -EPROBE_DEFER) {
1332-
ret = reset_gpio;
1329+
port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
1330+
port->name);
1331+
if (!port->reset_name) {
1332+
ret = -ENOMEM;
13331333
goto err;
13341334
}
13351335

1336-
if (gpio_is_valid(reset_gpio)) {
1337-
unsigned long gpio_flags;
1338-
1339-
port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
1340-
port->name);
1341-
if (!port->reset_name) {
1342-
ret = -ENOMEM;
1336+
port->reset_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(child),
1337+
"reset", GPIOD_OUT_HIGH,
1338+
port->name);
1339+
ret = PTR_ERR_OR_ZERO(port->reset_gpio);
1340+
if (ret) {
1341+
if (ret != -ENOENT)
13431342
goto err;
1344-
}
1345-
1346-
if (flags & OF_GPIO_ACTIVE_LOW) {
1347-
dev_info(dev, "%pOF: reset gpio is active low\n",
1348-
child);
1349-
gpio_flags = GPIOF_ACTIVE_LOW |
1350-
GPIOF_OUT_INIT_LOW;
1351-
} else {
1352-
gpio_flags = GPIOF_OUT_INIT_HIGH;
1353-
}
1354-
1355-
ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags,
1356-
port->reset_name);
1357-
if (ret) {
1358-
if (ret == -EPROBE_DEFER)
1359-
goto err;
1360-
goto skip;
1361-
}
1362-
1363-
port->reset_gpio = gpio_to_desc(reset_gpio);
1343+
/* reset gpio is optional */
1344+
port->reset_gpio = NULL;
1345+
devm_kfree(dev, port->reset_name);
1346+
port->reset_name = NULL;
13641347
}
13651348

13661349
slot_power_limit = of_pci_get_slot_power_limit(child,

0 commit comments

Comments
 (0)