| .. | .. |
|---|
| 51 | 51 | static int get_latch_status(struct hotplug_slot *slot, u8 *value); |
|---|
| 52 | 52 | static int get_adapter_status(struct hotplug_slot *slot, u8 *value); |
|---|
| 53 | 53 | |
|---|
| 54 | | -static struct hotplug_slot_ops shpchp_hotplug_slot_ops = { |
|---|
| 54 | +static const struct hotplug_slot_ops shpchp_hotplug_slot_ops = { |
|---|
| 55 | 55 | .set_attention_status = set_attention_status, |
|---|
| 56 | 56 | .enable_slot = enable_slot, |
|---|
| 57 | 57 | .disable_slot = disable_slot, |
|---|
| .. | .. |
|---|
| 65 | 65 | { |
|---|
| 66 | 66 | struct slot *slot; |
|---|
| 67 | 67 | struct hotplug_slot *hotplug_slot; |
|---|
| 68 | | - struct hotplug_slot_info *info; |
|---|
| 69 | 68 | char name[SLOT_NAME_SIZE]; |
|---|
| 70 | 69 | int retval; |
|---|
| 71 | 70 | int i; |
|---|
| .. | .. |
|---|
| 77 | 76 | goto error; |
|---|
| 78 | 77 | } |
|---|
| 79 | 78 | |
|---|
| 80 | | - hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
|---|
| 81 | | - if (!hotplug_slot) { |
|---|
| 82 | | - retval = -ENOMEM; |
|---|
| 83 | | - goto error_slot; |
|---|
| 84 | | - } |
|---|
| 85 | | - slot->hotplug_slot = hotplug_slot; |
|---|
| 86 | | - |
|---|
| 87 | | - info = kzalloc(sizeof(*info), GFP_KERNEL); |
|---|
| 88 | | - if (!info) { |
|---|
| 89 | | - retval = -ENOMEM; |
|---|
| 90 | | - goto error_hpslot; |
|---|
| 91 | | - } |
|---|
| 92 | | - hotplug_slot->info = info; |
|---|
| 79 | + hotplug_slot = &slot->hotplug_slot; |
|---|
| 93 | 80 | |
|---|
| 94 | 81 | slot->hp_slot = i; |
|---|
| 95 | 82 | slot->ctrl = ctrl; |
|---|
| .. | .. |
|---|
| 101 | 88 | slot->wq = alloc_workqueue("shpchp-%d", 0, 0, slot->number); |
|---|
| 102 | 89 | if (!slot->wq) { |
|---|
| 103 | 90 | retval = -ENOMEM; |
|---|
| 104 | | - goto error_info; |
|---|
| 91 | + goto error_slot; |
|---|
| 105 | 92 | } |
|---|
| 106 | 93 | |
|---|
| 107 | 94 | mutex_init(&slot->lock); |
|---|
| 108 | 95 | INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work); |
|---|
| 109 | 96 | |
|---|
| 110 | 97 | /* register this slot with the hotplug pci core */ |
|---|
| 111 | | - hotplug_slot->private = slot; |
|---|
| 112 | 98 | snprintf(name, SLOT_NAME_SIZE, "%d", slot->number); |
|---|
| 113 | 99 | hotplug_slot->ops = &shpchp_hotplug_slot_ops; |
|---|
| 114 | 100 | |
|---|
| .. | .. |
|---|
| 116 | 102 | pci_domain_nr(ctrl->pci_dev->subordinate), |
|---|
| 117 | 103 | slot->bus, slot->device, slot->hp_slot, slot->number, |
|---|
| 118 | 104 | ctrl->slot_device_offset); |
|---|
| 119 | | - retval = pci_hp_register(slot->hotplug_slot, |
|---|
| 105 | + retval = pci_hp_register(hotplug_slot, |
|---|
| 120 | 106 | ctrl->pci_dev->subordinate, slot->device, name); |
|---|
| 121 | 107 | if (retval) { |
|---|
| 122 | 108 | ctrl_err(ctrl, "pci_hp_register failed with error %d\n", |
|---|
| .. | .. |
|---|
| 124 | 110 | goto error_slotwq; |
|---|
| 125 | 111 | } |
|---|
| 126 | 112 | |
|---|
| 127 | | - get_power_status(hotplug_slot, &info->power_status); |
|---|
| 128 | | - get_attention_status(hotplug_slot, &info->attention_status); |
|---|
| 129 | | - get_latch_status(hotplug_slot, &info->latch_status); |
|---|
| 130 | | - get_adapter_status(hotplug_slot, &info->adapter_status); |
|---|
| 113 | + get_power_status(hotplug_slot, &slot->pwr_save); |
|---|
| 114 | + get_attention_status(hotplug_slot, &slot->attention_save); |
|---|
| 115 | + get_latch_status(hotplug_slot, &slot->latch_save); |
|---|
| 116 | + get_adapter_status(hotplug_slot, &slot->presence_save); |
|---|
| 131 | 117 | |
|---|
| 132 | 118 | list_add(&slot->slot_list, &ctrl->slot_list); |
|---|
| 133 | 119 | } |
|---|
| .. | .. |
|---|
| 135 | 121 | return 0; |
|---|
| 136 | 122 | error_slotwq: |
|---|
| 137 | 123 | destroy_workqueue(slot->wq); |
|---|
| 138 | | -error_info: |
|---|
| 139 | | - kfree(info); |
|---|
| 140 | | -error_hpslot: |
|---|
| 141 | | - kfree(hotplug_slot); |
|---|
| 142 | 124 | error_slot: |
|---|
| 143 | 125 | kfree(slot); |
|---|
| 144 | 126 | error: |
|---|
| .. | .. |
|---|
| 153 | 135 | list_del(&slot->slot_list); |
|---|
| 154 | 136 | cancel_delayed_work(&slot->work); |
|---|
| 155 | 137 | destroy_workqueue(slot->wq); |
|---|
| 156 | | - pci_hp_deregister(slot->hotplug_slot); |
|---|
| 157 | | - kfree(slot->hotplug_slot->info); |
|---|
| 158 | | - kfree(slot->hotplug_slot); |
|---|
| 138 | + pci_hp_deregister(&slot->hotplug_slot); |
|---|
| 159 | 139 | kfree(slot); |
|---|
| 160 | 140 | } |
|---|
| 161 | 141 | } |
|---|
| .. | .. |
|---|
| 170 | 150 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
|---|
| 171 | 151 | __func__, slot_name(slot)); |
|---|
| 172 | 152 | |
|---|
| 173 | | - hotplug_slot->info->attention_status = status; |
|---|
| 153 | + slot->attention_save = status; |
|---|
| 174 | 154 | slot->hpc_ops->set_attention_status(slot, status); |
|---|
| 175 | 155 | |
|---|
| 176 | 156 | return 0; |
|---|
| .. | .. |
|---|
| 206 | 186 | |
|---|
| 207 | 187 | retval = slot->hpc_ops->get_power_status(slot, value); |
|---|
| 208 | 188 | if (retval < 0) |
|---|
| 209 | | - *value = hotplug_slot->info->power_status; |
|---|
| 189 | + *value = slot->pwr_save; |
|---|
| 210 | 190 | |
|---|
| 211 | 191 | return 0; |
|---|
| 212 | 192 | } |
|---|
| .. | .. |
|---|
| 221 | 201 | |
|---|
| 222 | 202 | retval = slot->hpc_ops->get_attention_status(slot, value); |
|---|
| 223 | 203 | if (retval < 0) |
|---|
| 224 | | - *value = hotplug_slot->info->attention_status; |
|---|
| 204 | + *value = slot->attention_save; |
|---|
| 225 | 205 | |
|---|
| 226 | 206 | return 0; |
|---|
| 227 | 207 | } |
|---|
| .. | .. |
|---|
| 236 | 216 | |
|---|
| 237 | 217 | retval = slot->hpc_ops->get_latch_status(slot, value); |
|---|
| 238 | 218 | if (retval < 0) |
|---|
| 239 | | - *value = hotplug_slot->info->latch_status; |
|---|
| 219 | + *value = slot->latch_save; |
|---|
| 240 | 220 | |
|---|
| 241 | 221 | return 0; |
|---|
| 242 | 222 | } |
|---|
| .. | .. |
|---|
| 251 | 231 | |
|---|
| 252 | 232 | retval = slot->hpc_ops->get_adapter_status(slot, value); |
|---|
| 253 | 233 | if (retval < 0) |
|---|
| 254 | | - *value = hotplug_slot->info->adapter_status; |
|---|
| 234 | + *value = slot->presence_save; |
|---|
| 255 | 235 | |
|---|
| 256 | 236 | return 0; |
|---|
| 257 | 237 | } |
|---|