Merge tag 'v5.2' into next
[platform/kernel/linux-rpi.git] / drivers / input / keyboard / gpio_keys_polled.c
index 1eafe6b..465eecf 100644 (file)
@@ -165,6 +165,8 @@ gpio_keys_polled_get_devtree_pdata(struct device *dev)
        pdata->rep = device_property_present(dev, "autorepeat");
        device_property_read_u32(dev, "poll-interval", &pdata->poll_interval);
 
+       device_property_read_string(dev, "label", &pdata->name);
+
        device_for_each_child_node(dev, child) {
                if (fwnode_property_read_u32(child, "linux,code",
                                             &button->code)) {
@@ -232,7 +234,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
        struct gpio_keys_polled_dev *bdev;
        struct input_polled_dev *poll_dev;
        struct input_dev *input;
-       size_t size;
        int error;
        int i;
 
@@ -247,9 +248,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       size = sizeof(struct gpio_keys_polled_dev) +
-                       pdata->nbuttons * sizeof(struct gpio_keys_button_data);
-       bdev = devm_kzalloc(dev, size, GFP_KERNEL);
+       bdev = devm_kzalloc(dev, struct_size(bdev, data, pdata->nbuttons),
+                           GFP_KERNEL);
        if (!bdev) {
                dev_err(dev, "no memory for private data\n");
                return -ENOMEM;
@@ -269,7 +269,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 
        input = poll_dev->input;
 
-       input->name = pdev->name;
+       input->name = pdata->name ?: pdev->name;
        input->phys = DRV_NAME"/input0";
 
        input->id.bustype = BUS_HOST;