ACPI: don't duplicate input events on netlink
[firefly-linux-kernel-4.4.55.git] / drivers / pci / hotplug / acpiphp_ibm.c
index bd40aee10e16442b585ee374fc01ef2df476798a..360902476bad6ef753143ca33f6694f97300a33d 100644 (file)
@@ -106,7 +106,8 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status);
 static void ibm_handle_events(acpi_handle handle, u32 event, void *context);
 static int ibm_get_table_from_acpi(char **bufp);
 static ssize_t ibm_read_apci_table(struct kobject *kobj,
-               char *buffer, loff_t pos, size_t size);
+                                  struct bin_attribute *bin_attr,
+                                  char *buffer, loff_t pos, size_t size);
 static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
                u32 lvl, void *context, void **rv);
 static int __init ibm_acpiphp_init(void);
@@ -117,7 +118,6 @@ static struct notification ibm_note;
 static struct bin_attribute ibm_apci_table_attr = {
            .attr = {
                    .name = "apci_table",
-                   .owner = THIS_MODULE,
                    .mode = S_IRUGO,
            },
            .read = ibm_read_apci_table,
@@ -268,6 +268,9 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
        if (subevent == 0x80) {
                dbg("%s: generationg bus event\n", __FUNCTION__);
                acpi_bus_generate_event(note->device, note->event, detail);
+               acpi_bus_generate_netlink_event(note->device->pnp.device_class,
+                                                 note->device->dev.bus_id,
+                                                 note->event, detail);
        } else
                note->event = event;
 }
@@ -319,13 +322,12 @@ static int ibm_get_table_from_acpi(char **bufp)
        if (bufp == NULL)
                goto read_table_done;
 
-       lbuf = kmalloc(size, GFP_KERNEL);
+       lbuf = kzalloc(size, GFP_KERNEL);
        dbg("%s: element count: %i, ASL table size: %i, &table = 0x%p\n",
                        __FUNCTION__, package->package.count, size, lbuf);
 
        if (lbuf) {
                *bufp = lbuf;
-               memset(lbuf, 0, size);
        } else {
                size = -ENOMEM;
                goto read_table_done;
@@ -359,7 +361,8 @@ read_table_done:
  * our solution is to only allow reading the table in all at once
  **/
 static ssize_t ibm_read_apci_table(struct kobject *kobj,
-               char *buffer, loff_t pos, size_t size)
+                                  struct bin_attribute *bin_attr,
+                                  char *buffer, loff_t pos, size_t size)
 {
        int bytes_read = -EINVAL;
        char *table = NULL;
@@ -425,7 +428,7 @@ static int __init ibm_acpiphp_init(void)
        int retval = 0;
        acpi_status status;
        struct acpi_device *device;
-       struct kobject *sysdir = &pci_hotplug_slots_subsys.kset.kobj;
+       struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
 
        dbg("%s\n", __FUNCTION__);
 
@@ -472,7 +475,7 @@ init_return:
 static void __exit ibm_acpiphp_exit(void)
 {
        acpi_status status;
-       struct kobject *sysdir = &pci_hotplug_slots_subsys.kset.kobj;
+       struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
 
        dbg("%s\n", __FUNCTION__);