Skip to content

Commit

Permalink
ARM: pxa: PalmTE2: Use gpio arrays in backlight init
Browse files Browse the repository at this point in the history
Use gpio_request_array() / gpio_free_array() in backlight init and exit
functions. This makes the code cleaner and less error prone.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
  • Loading branch information
Marek Vasut authored and Eric Miao committed Mar 16, 2011
1 parent a5abba9 commit 7428fff
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions arch/arm/mach-pxa/palmte2.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,14 @@ static struct platform_device palmte2_pxa_keys = {
/******************************************************************************
* Backlight
******************************************************************************/
static struct gpio palmte_bl_gpios[] = {
{ GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
{ GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
};

static int palmte2_backlight_init(struct device *dev)
{
int ret;

ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
if (ret)
goto err;
ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
if (ret)
goto err2;
ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
if (ret)
goto err2;
ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
if (ret)
goto err3;

return 0;
err3:
gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
err2:
gpio_free(GPIO_NR_PALMTE2_BL_POWER);
err:
return ret;
return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
}

static int palmte2_backlight_notify(struct device *dev, int brightness)
Expand All @@ -171,8 +155,7 @@ static int palmte2_backlight_notify(struct device *dev, int brightness)

static void palmte2_backlight_exit(struct device *dev)
{
gpio_free(GPIO_NR_PALMTE2_BL_POWER);
gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
}

static struct platform_pwm_backlight_data palmte2_backlight_data = {
Expand Down

0 comments on commit 7428fff

Please sign in to comment.