drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / scsi / fnic / vnic_cq_copy.h
blob1b198ee59dd60c2bdc384fd03e30d96c3a539244
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright 2008 Cisco Systems, Inc. All rights reserved.
4 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 */
6 #ifndef _VNIC_CQ_COPY_H_
7 #define _VNIC_CQ_COPY_H_
9 #include "fcpio.h"
11 static inline unsigned int vnic_cq_copy_service(
12 struct vnic_cq *cq,
13 int (*q_service)(struct vnic_dev *vdev,
14 unsigned int index,
15 struct fcpio_fw_req *desc),
16 unsigned int work_to_do)
19 struct fcpio_fw_req *desc;
20 unsigned int work_done = 0;
21 u8 color;
23 desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
24 cq->ring.desc_size * cq->to_clean);
25 fcpio_color_dec(desc, &color);
27 while (color != cq->last_color) {
29 if ((*q_service)(cq->vdev, cq->index, desc))
30 break;
32 cq->to_clean++;
33 if (cq->to_clean == cq->ring.desc_count) {
34 cq->to_clean = 0;
35 cq->last_color = cq->last_color ? 0 : 1;
38 desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
39 cq->ring.desc_size * cq->to_clean);
40 fcpio_color_dec(desc, &color);
42 work_done++;
43 if (work_done >= work_to_do)
44 break;
47 return work_done;
50 #endif /* _VNIC_CQ_COPY_H_ */