Skip to content

Commit

Permalink
gpio-button-hotplug: sync upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Jan 27, 2025
1 parent 19978f1 commit 171cb58
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ struct gpio_keys_button_dev {

struct device *dev;
struct gpio_keys_platform_data *pdata;
struct gpio_keys_button_data data[0];
struct gpio_keys_button_data data[];
};

static void gpio_keys_polled_queue_work(struct gpio_keys_button_dev *bdev)
Expand Down Expand Up @@ -373,7 +373,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
if (!node)
return NULL;

nbuttons = of_get_child_count(node);
nbuttons = of_get_available_child_count(node);
if (nbuttons == 0)
return ERR_PTR(-EINVAL);

Expand All @@ -388,7 +388,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
pdata->rep = !!of_get_property(node, "autorepeat", NULL);
of_property_read_u32(node, "poll-interval", &pdata->poll_interval);

for_each_child_of_node(node, pp) {
for_each_available_child_of_node(node, pp) {
button = (struct gpio_keys_button *)(&pdata->buttons[i++]);

if (of_property_read_u32(pp, "linux,code", &button->code)) {
Expand Down Expand Up @@ -525,10 +525,9 @@ static int gpio_keys_button_probe(struct platform_device *pdev,
button->active_low ? GPIOF_ACTIVE_LOW :
0), desc);
if (error) {
if (error != -EPROBE_DEFER) {
dev_err(dev, "unable to claim gpio %d, err=%d\n",
button->gpio, error);
}
dev_err_probe(dev, error,
"unable to claim gpio %d",
button->gpio);
goto out;
}

Expand Down Expand Up @@ -679,7 +678,11 @@ static void gpio_keys_irq_close(struct gpio_keys_button_dev *bdev)
}
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(6,11,0)
static int gpio_keys_remove(struct platform_device *pdev)
#else
static void gpio_keys_remove(struct platform_device *pdev)
#endif
{
struct gpio_keys_button_dev *bdev = platform_get_drvdata(pdev);

Expand All @@ -690,29 +693,25 @@ static int gpio_keys_remove(struct platform_device *pdev)
else
gpio_keys_irq_close(bdev);

#if LINUX_VERSION_CODE < KERNEL_VERSION(6,11,0)
return 0;
#endif
}

static struct platform_driver gpio_keys_driver = {
.probe = gpio_keys_probe,
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,12,0)
.remove = gpio_keys_remove,
#endif
.driver = {
.name = "gpio-keys",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(gpio_keys_of_match),
},
};

static struct platform_driver gpio_keys_polled_driver = {
.probe = gpio_keys_polled_probe,
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,12,0)
.remove = gpio_keys_remove,
#endif
.driver = {
.name = "gpio-keys-polled",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(gpio_keys_polled_of_match),
},
};
Expand Down

0 comments on commit 171cb58

Please sign in to comment.