diff options
Diffstat (limited to 'drivers/gpio/gpio-generic.c')
| -rw-r--r-- | drivers/gpio/gpio-generic.c | 29 | 
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index d2196bf7384..fea8c82bb8f 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -139,7 +139,7 @@ static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)  {  	struct bgpio_chip *bgc = to_bgpio_chip(gc); -	return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio); +	return !!(bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio));  }  static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) @@ -388,6 +388,14 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc,  	return 0;  } +static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin) +{ +	if (gpio_pin < chip->ngpio) +		return 0; + +	return -EINVAL; +} +  int bgpio_remove(struct bgpio_chip *bgc)  {  	return gpiochip_remove(&bgc->gc); @@ -413,6 +421,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,  	bgc->gc.label = dev_name(dev);  	bgc->gc.base = -1;  	bgc->gc.ngpio = bgc->bits; +	bgc->gc.request = bgpio_request;  	ret = bgpio_setup_io(bgc, dat, set, clr);  	if (ret) @@ -488,7 +497,7 @@ static int bgpio_pdev_probe(struct platform_device *pdev)  	void __iomem *dirout;  	void __iomem *dirin;  	unsigned long sz; -	unsigned long flags = 0; +	unsigned long flags = pdev->id_entry->driver_data;  	int err;  	struct bgpio_chip *bgc;  	struct bgpio_pdata *pdata = dev_get_platdata(dev); @@ -519,9 +528,6 @@ static int bgpio_pdev_probe(struct platform_device *pdev)  	if (err)  		return err; -	if (!strcmp(platform_get_device_id(pdev)->name, "basic-mmio-gpio-be")) -		flags |= BGPIOF_BIG_ENDIAN; -  	bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL);  	if (!bgc)  		return -ENOMEM; @@ -531,6 +537,8 @@ static int bgpio_pdev_probe(struct platform_device *pdev)  		return err;  	if (pdata) { +		if (pdata->label) +			bgc->gc.label = pdata->label;  		bgc->gc.base = pdata->base;  		if (pdata->ngpio > 0)  			bgc->gc.ngpio = pdata->ngpio; @@ -549,9 +557,14 @@ static int bgpio_pdev_remove(struct platform_device *pdev)  }  static const struct platform_device_id bgpio_id_table[] = { -	{ "basic-mmio-gpio", }, -	{ "basic-mmio-gpio-be", }, -	{}, +	{ +		.name		= "basic-mmio-gpio", +		.driver_data	= 0, +	}, { +		.name		= "basic-mmio-gpio-be", +		.driver_data	= BGPIOF_BIG_ENDIAN, +	}, +	{ }  };  MODULE_DEVICE_TABLE(platform, bgpio_id_table);  | 
