/* zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list @fsf_req: request to be processed @sbtype: SBALE flags @sg: scatter-gather list @max_sbals: upper bound for number of SBALs to be used Returns: number of bytes, or error (negativ)  */
int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, unsigned long sbtype, struct scatterlist *sg, int max_sbals)
/* zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list @fsf_req: request to be processed @sbtype: SBALE flags @sg: scatter-gather list @max_sbals: upper bound for number of SBALs to be used Returns: number of bytes, or error (negativ)  */
int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, unsigned long sbtype, struct scatterlist *sg, int max_sbals)
{
	struct qdio_buffer_element *sbale;
	int retval, bytes = 0;
	zfcp_qdio_sbal_limit(qdio, q_req, max_sbals);
	sbale = zfcp_qdio_sbale_req(qdio, q_req);
	sbale->flags |= sbtype;
	for (; sg; sg = sg_next(sg)) {
		retval = zfcp_qdio_fill_sbals(qdio, q_req, sbtype,
					      sg_virt(sg), sg->length);
		if (retval < 0)
			return retval;
		bytes += sg->length;
	}
	sbale = zfcp_qdio_sbale_curr(qdio, q_req);
	sbale->flags |= SBAL_FLAGS_LAST_ENTRY;
	return bytes;
}