mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	gpiolib: of: change of_find_gpio() to accept device node
In preparation of switching all OF-based GPIO lookups to go through of_find_gpio() let's change it to accept device node as its argument as we do not always have access to device structure. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
		
							parent
							
								
									8dab99c9ea
								
							
						
					
					
						commit
						07445ae1c2
					
				
					 3 changed files with 8 additions and 8 deletions
				
			
		| 
						 | 
					@ -605,7 +605,7 @@ static const of_find_gpio_quirk of_find_gpio_quirks[] = {
 | 
				
			||||||
	NULL
 | 
						NULL
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 | 
					struct gpio_desc *of_find_gpio(struct device_node *np, const char *con_id,
 | 
				
			||||||
			       unsigned int idx, unsigned long *flags)
 | 
								       unsigned int idx, unsigned long *flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char prop_name[32]; /* 32 is max size of property name */
 | 
						char prop_name[32]; /* 32 is max size of property name */
 | 
				
			||||||
| 
						 | 
					@ -623,8 +623,7 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 | 
				
			||||||
			snprintf(prop_name, sizeof(prop_name), "%s",
 | 
								snprintf(prop_name, sizeof(prop_name), "%s",
 | 
				
			||||||
				 gpio_suffixes[i]);
 | 
									 gpio_suffixes[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
 | 
							desc = of_get_named_gpiod_flags(np, prop_name, idx, &of_flags);
 | 
				
			||||||
						&of_flags);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!gpiod_not_found(desc))
 | 
							if (!gpiod_not_found(desc))
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -632,7 +631,7 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Properly named GPIO was not found, try workarounds */
 | 
						/* Properly named GPIO was not found, try workarounds */
 | 
				
			||||||
	for (q = of_find_gpio_quirks; gpiod_not_found(desc) && *q; q++)
 | 
						for (q = of_find_gpio_quirks; gpiod_not_found(desc) && *q; q++)
 | 
				
			||||||
		desc = (*q)(dev->of_node, con_id, idx, &of_flags);
 | 
							desc = (*q)(np, con_id, idx, &of_flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (IS_ERR(desc))
 | 
						if (IS_ERR(desc))
 | 
				
			||||||
		return desc;
 | 
							return desc;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@ struct gpio_chip;
 | 
				
			||||||
enum of_gpio_flags;
 | 
					enum of_gpio_flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_OF_GPIO
 | 
					#ifdef CONFIG_OF_GPIO
 | 
				
			||||||
struct gpio_desc *of_find_gpio(struct device *dev,
 | 
					struct gpio_desc *of_find_gpio(struct device_node *np,
 | 
				
			||||||
			       const char *con_id,
 | 
								       const char *con_id,
 | 
				
			||||||
			       unsigned int idx,
 | 
								       unsigned int idx,
 | 
				
			||||||
			       unsigned long *lookupflags);
 | 
								       unsigned long *lookupflags);
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,7 @@ void of_gpiochip_remove(struct gpio_chip *gc);
 | 
				
			||||||
int of_gpio_get_count(struct device *dev, const char *con_id);
 | 
					int of_gpio_get_count(struct device *dev, const char *con_id);
 | 
				
			||||||
void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
 | 
					void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static inline struct gpio_desc *of_find_gpio(struct device *dev,
 | 
					static inline struct gpio_desc *of_find_gpio(struct device_node *np,
 | 
				
			||||||
					     const char *con_id,
 | 
										     const char *con_id,
 | 
				
			||||||
					     unsigned int idx,
 | 
										     unsigned int idx,
 | 
				
			||||||
					     unsigned long *lookupflags)
 | 
										     unsigned long *lookupflags)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4122,14 +4122,15 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	/* Maybe we have a device name, maybe not */
 | 
						/* Maybe we have a device name, maybe not */
 | 
				
			||||||
	const char *devname = dev ? dev_name(dev) : "?";
 | 
						const char *devname = dev ? dev_name(dev) : "?";
 | 
				
			||||||
	const struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL;
 | 
						struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
 | 
						dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Using device tree? */
 | 
						/* Using device tree? */
 | 
				
			||||||
	if (is_of_node(fwnode)) {
 | 
						if (is_of_node(fwnode)) {
 | 
				
			||||||
		dev_dbg(dev, "using device tree for GPIO lookup\n");
 | 
							dev_dbg(dev, "using device tree for GPIO lookup\n");
 | 
				
			||||||
		desc = of_find_gpio(dev, con_id, idx, &lookupflags);
 | 
							desc = of_find_gpio(to_of_node(fwnode),
 | 
				
			||||||
 | 
									    con_id, idx, &lookupflags);
 | 
				
			||||||
	} else if (is_acpi_node(fwnode)) {
 | 
						} else if (is_acpi_node(fwnode)) {
 | 
				
			||||||
		dev_dbg(dev, "using ACPI for GPIO lookup\n");
 | 
							dev_dbg(dev, "using ACPI for GPIO lookup\n");
 | 
				
			||||||
		desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags);
 | 
							desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue