mirror of https://gitee.com/openkylin/linux.git
gpio: mockup: group code by logic
Keep GPIO chip callbacks, event trigger callbacks and mockup chip setup code visibly separated. We're mostly good - just need to move the line naming routine below. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
5b7908c024
commit
1cea4734f9
|
@ -123,29 +123,6 @@ static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset)
|
||||||
return chip->lines[offset].dir;
|
return chip->lines[offset].dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gpio_mockup_name_lines(struct device *dev,
|
|
||||||
struct gpio_mockup_chip *chip)
|
|
||||||
{
|
|
||||||
struct gpio_chip *gc = &chip->gc;
|
|
||||||
char **names;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL);
|
|
||||||
if (!names)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
for (i = 0; i < gc->ngpio; i++) {
|
|
||||||
names[i] = devm_kasprintf(dev, GFP_KERNEL,
|
|
||||||
"%s-%d", gc->label, i);
|
|
||||||
if (!names[i])
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
gc->names = (const char *const *)names;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset)
|
static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset)
|
||||||
{
|
{
|
||||||
struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
|
struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
|
||||||
|
@ -238,6 +215,29 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
|
||||||
dev_err(dev, "error creating debugfs directory\n");
|
dev_err(dev, "error creating debugfs directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int gpio_mockup_name_lines(struct device *dev,
|
||||||
|
struct gpio_mockup_chip *chip)
|
||||||
|
{
|
||||||
|
struct gpio_chip *gc = &chip->gc;
|
||||||
|
char **names;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL);
|
||||||
|
if (!names)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
for (i = 0; i < gc->ngpio; i++) {
|
||||||
|
names[i] = devm_kasprintf(dev, GFP_KERNEL,
|
||||||
|
"%s-%d", gc->label, i);
|
||||||
|
if (!names[i])
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
gc->names = (const char *const *)names;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int gpio_mockup_probe(struct platform_device *pdev)
|
static int gpio_mockup_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct gpio_mockup_platform_data *pdata;
|
struct gpio_mockup_platform_data *pdata;
|
||||||
|
|
Loading…
Reference in New Issue