Skip to content

Commit

Permalink
staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels
Browse files Browse the repository at this point in the history
Instead of using a custom function to return desired name for gpio
use the default assigned one and concat it '-bankN' suffix using
devm_kasprintf kernel function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Sergio Paracuellos authored and Greg Kroah-Hartman committed Jul 6, 2018
1 parent 24186cc commit ff19ad2
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions drivers/staging/mt7621-gpio/gpio-mt7621.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,6 @@ static struct irq_chip mediatek_gpio_irq_chip = {
.irq_set_type = mediatek_gpio_irq_type,
};

static inline const char * const mediatek_gpio_bank_name(int bank)
{
static const char * const bank_names[] = {
"mt7621-bank0", "mt7621-bank1", "mt7621-bank2",
};

return bank_names[bank];
}

static int
mediatek_gpio_xlate(struct gpio_chip *chip,
const struct of_phandle_args *spec, u32 *flags)
Expand Down Expand Up @@ -251,7 +242,8 @@ mediatek_gpio_bank_probe(struct platform_device *pdev,

rg->chip.of_gpio_n_cells = 2;
rg->chip.of_xlate = mediatek_gpio_xlate;
rg->chip.label = mediatek_gpio_bank_name(rg->bank);
rg->chip.label = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-bank%d",
dev_name(&pdev->dev), bank);

ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio);
if (ret < 0) {
Expand Down

0 comments on commit ff19ad2

Please sign in to comment.