Lines Matching +full:slot +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0+
40 /* these are the names for the IBM ACPI pseudo-device */
44 #define hpslot_to_sun(A) (to_slot(A)->sun)
46 /* union apci_descriptor - allows access to the
67 } slot; member
74 /* struct notification - keeps info about the device
82 static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status);
83 static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status);
88 char *buffer, loff_t pos, size_t size);
112 * ibm_slot_from_id - workaround for bad ibm hardware
113 * @id: the slot number that linux refers to the slot by
115 * Description: This method returns the aCPI slot descriptor
116 * corresponding to the Linux slot number. This descriptor
117 * has info about the aPCI slot id and attention status.
122 int ind = 0, size; in ibm_slot_from_id() local
126 size = ibm_get_table_from_acpi(&table); in ibm_slot_from_id()
127 if (size < 0) in ibm_slot_from_id()
130 if (memcmp(des->header.sig, "aPCI", 4) != 0) in ibm_slot_from_id()
133 des = (union apci_descriptor *)&table[ind += des->header.len]; in ibm_slot_from_id()
134 while (ind < size && (des->generic.type != 0x82 || in ibm_slot_from_id()
135 des->slot.slot_num != id)) { in ibm_slot_from_id()
136 des = (union apci_descriptor *)&table[ind += des->generic.len]; in ibm_slot_from_id()
139 if (ind < size && des->slot.slot_num == id) in ibm_slot_from_id()
153 * ibm_set_attention_status - callback method to set the attention LED
154 * @slot: the hotplug_slot to work with
160 static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) in ibm_set_attention_status() argument
167 int id = hpslot_to_sun(slot); in ibm_set_attention_status()
171 pr_err("APLS null ACPI descriptor for slot %d\n", id); in ibm_set_attention_status()
172 return -ENODEV; in ibm_set_attention_status()
175 pr_debug("%s: set slot %d (%d) attention status to %d\n", __func__, in ibm_set_attention_status()
176 ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, in ibm_set_attention_status()
180 args[0].integer.value = ibm_slot->slot.slot_id; in ibm_set_attention_status()
189 return -ENODEV; in ibm_set_attention_status()
192 return -ERANGE; in ibm_set_attention_status()
198 * ibm_get_attention_status - callback method to get attention LED status
199 * @slot: the hotplug_slot to work with
207 * slot descriptor to read the status from that.
209 static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status) in ibm_get_attention_status() argument
212 int id = hpslot_to_sun(slot); in ibm_get_attention_status()
216 pr_err("APLS null ACPI descriptor for slot %d\n", id); in ibm_get_attention_status()
217 return -ENODEV; in ibm_get_attention_status()
220 if (ibm_slot->slot.attn & 0xa0 || ibm_slot->slot.status[1] & 0x08) in ibm_get_attention_status()
225 pr_debug("%s: get slot %d (%d) attention status is %d\n", __func__, in ibm_get_attention_status()
226 ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, in ibm_get_attention_status()
234 * ibm_handle_events - listens for ACPI events for the IBM37D0 device
244 * ID comes first and then the slot number that caused it. We report
248 * only re-enable the interrupt that causes this event AFTER this method
261 acpi_bus_generate_netlink_event(note->device->pnp.device_class, in ibm_handle_events()
262 dev_name(&note->device->dev), in ibm_handle_events()
263 note->event, detail); in ibm_handle_events()
265 note->event = event; in ibm_handle_events()
269 * ibm_get_table_from_acpi - reads the APLS buffer from ACPI
277 * the size of the table and returns that without filling
280 * Returns < 0 on error or the size of the table on success.
288 int i, size = -EIO; in ibm_get_table_from_acpi() local
293 return -ENODEV; in ibm_get_table_from_acpi()
298 (package->type != ACPI_TYPE_PACKAGE) || in ibm_get_table_from_acpi()
299 !(package->package.elements)) { in ibm_get_table_from_acpi()
304 for (size = 0, i = 0; i < package->package.count; i++) { in ibm_get_table_from_acpi()
305 if (package->package.elements[i].type != ACPI_TYPE_BUFFER) { in ibm_get_table_from_acpi()
309 size += package->package.elements[i].buffer.length; in ibm_get_table_from_acpi()
315 lbuf = kzalloc(size, GFP_KERNEL); in ibm_get_table_from_acpi()
316 pr_debug("%s: element count: %i, ASL table size: %i, &table = 0x%p\n", in ibm_get_table_from_acpi()
317 __func__, package->package.count, size, lbuf); in ibm_get_table_from_acpi()
322 size = -ENOMEM; in ibm_get_table_from_acpi()
326 size = 0; in ibm_get_table_from_acpi()
327 for (i = 0; i < package->package.count; i++) { in ibm_get_table_from_acpi()
328 memcpy(&lbuf[size], in ibm_get_table_from_acpi()
329 package->package.elements[i].buffer.pointer, in ibm_get_table_from_acpi()
330 package->package.elements[i].buffer.length); in ibm_get_table_from_acpi()
331 size += package->package.elements[i].buffer.length; in ibm_get_table_from_acpi()
336 return size; in ibm_get_table_from_acpi()
340 * ibm_read_apci_table - callback for the sysfs apci_table file
346 * @size: the number of bytes requested
357 char *buffer, loff_t pos, size_t size) in ibm_read_apci_table() argument
359 int bytes_read = -EINVAL; in ibm_read_apci_table()
362 pr_debug("%s: pos = %d, size = %zd\n", __func__, (int)pos, size); in ibm_read_apci_table()
366 if (bytes_read > 0 && bytes_read <= size) in ibm_read_apci_table()
374 * ibm_find_acpi_device - callback to find our ACPI device
381 * to find our device. When this method returns non-zero
402 if (current_status && (info->valid & ACPI_VALID_HID) && in ibm_find_acpi_device()
403 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) || in ibm_find_acpi_device()
404 !strcmp(info->hardware_id.string, IBM_HARDWARE_ID2))) { in ibm_find_acpi_device()
406 info->hardware_id.string, handle); in ibm_find_acpi_device()
408 /* returning non-zero causes the search to stop in ibm_find_acpi_device()
424 struct kobject *sysdir = &pci_slots_kset->kobj; in ibm_acpiphp_init()
432 retval = -ENODEV; in ibm_acpiphp_init()
439 retval = -ENODEV; in ibm_acpiphp_init()
443 retval = -ENODEV; in ibm_acpiphp_init()
454 retval = -EBUSY; in ibm_acpiphp_init()
458 ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL); in ibm_acpiphp_init()
472 struct kobject *sysdir = &pci_slots_kset->kobj; in ibm_acpiphp_exit()