drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / scsi / snic / vnic_cq_fw.h
blobd74954bc70e3ce14f2295b7f6937ed3dee553640
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
4 #ifndef _VNIC_CQ_FW_H_
5 #define _VNIC_CQ_FW_H_
7 #include "snic_fwint.h"
9 static inline unsigned int
10 vnic_cq_fw_service(struct vnic_cq *cq,
11 int (*q_service)(struct vnic_dev *vdev,
12 unsigned int index,
13 struct snic_fw_req *desc),
14 unsigned int work_to_do)
17 struct snic_fw_req *desc;
18 unsigned int work_done = 0;
19 u8 color;
21 desc = (struct snic_fw_req *)((u8 *)cq->ring.descs +
22 cq->ring.desc_size * cq->to_clean);
23 snic_color_dec(desc, &color);
25 while (color != cq->last_color) {
27 if ((*q_service)(cq->vdev, cq->index, desc))
28 break;
30 cq->to_clean++;
31 if (cq->to_clean == cq->ring.desc_count) {
32 cq->to_clean = 0;
33 cq->last_color = cq->last_color ? 0 : 1;
36 desc = (struct snic_fw_req *)((u8 *)cq->ring.descs +
37 cq->ring.desc_size * cq->to_clean);
38 snic_color_dec(desc, &color);
40 work_done++;
41 if (work_done >= work_to_do)
42 break;
45 return work_done;
48 #endif /* _VNIC_CQ_FW_H_ */