* PGP Signed by an unknown key
On Thu, Nov 24, 2016 at 12:23:56PM +0530, Laxman Dewangan wrote:
On Tuesday 22 November 2016 11:25 PM, Thierry Reding wrote:It's common practice to embed the struct gpio_chip within a driver-
+static inline struct tegra_gpio *to_tegra_gpio(struct gpio_chip *chip)You dont need this as gpiochip_get_data(chip); can provide the required
+{
+ return container_of(chip, struct tegra_gpio, gpio);
+}
driver specific data.
specific structure, and it's equally common to use a container_of() to
get at the embedding structure.
This has nothing to do with the device tree binding. What the device+ gpio->gpio.parent = &pdev->dev;Our DT binding does not say this. We assume that we have 8 gpios per port.
+
+ gpio->gpio.get_direction = tegra186_gpio_get_direction;
+ gpio->gpio.direction_input = tegra186_gpio_direction_input;
+ gpio->gpio.direction_output = tegra186_gpio_direction_output;
+ gpio->gpio.get = tegra186_gpio_get,
+ gpio->gpio.set = tegra186_gpio_set;
+ gpio->gpio.to_irq = tegra186_gpio_to_irq;
+
+ gpio->gpio.base = -1;
+
+ for (i = 0; i < gpio->soc->num_ports; i++)
+ gpio->gpio.ngpio += gpio->soc->ports[i].pins;
+
so this will not work at all.
tree binding defines is the indices to use to obtain a given GPIO within
a given port. What numbering the driver uses internally is completely up
to the driver implementation.
Oh, and the above works just fine.