2163
2164static struct qla_work_evt *
2165qla2x00_alloc_work(struct scsi_qla_host *ha, enum qla_work_type type,
2166 int locked)
2167{
2168 struct qla_work_evt *e;
2169
2170 e = kzalloc(sizeof(struct qla_work_evt), locked ? GFP_ATOMIC:
2171 GFP_KERNEL);
2172 if (!e)
2173 return NULL;
2174
2175 INIT_LIST_HEAD(&e->list);
2176 e->type = type;
2177 e->flags = QLA_EVT_FLAG_FREE;
2178 return e;
2179}
2180
2181static int
2182qla2x00_post_work(struct scsi_qla_host *ha, struct qla_work_evt *e, int locked)
2183{
2184 unsigned long uninitialized_var(flags);
2185 scsi_qla_host_t *pha = to_qla_parent(ha);
2186
2187 if (!locked)
2188 spin_lock_irqsave(&pha->hardware_lock, flags);
2189 list_add_tail(&e->list, &ha->work_list);
2190 qla2xxx_wake_dpc(ha);
2191 if (!locked)
2192 spin_unlock_irqrestore(&pha->hardware_lock, flags);
2193 return QLA_SUCCESS;
2194}
2195
2196int
2197qla2x00_post_aen_work(struct scsi_qla_host *ha, enum fc_host_event_code code,
2198 u32 data)
2199{
2200 struct qla_work_evt *e;
2201
2202 e = qla2x00_alloc_work(ha, QLA_EVT_AEN, 1);
2203 if (!e)