What about a little helper like this: ?

static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len,
                void *id, off_t *off)
{
        struct nvme_ns_identifier_hdr hdr = {
                .nidt   = type,
                .nidl   = len,
        };
        u16 status;

        status = nvmet_copy_to_sgl(req, *off, &hdr, sizeof(hdr));
        if (status)
                return status;
        *off += sizeof(hdr);

        status = nvmet_copy_to_sgl(req, off, id, len);
        if (status)
                return status;
        *off += len;

        return 0;
}

Reply via email to