Commit 094614fc authored by Stefan Richter's avatar Stefan Richter

firewire: sbp2: fix status reception

Per SBP-2 clause 5.3, a target shall store 8...32 bytes of status
information.  Trailing zeros after the first 8 bytes don't need to be
stored, they are implicit.  Fix the status write handler to clear all
unwritten status data.
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 85cb9b68
...@@ -425,19 +425,20 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request, ...@@ -425,19 +425,20 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request,
struct sbp2_logical_unit *lu = callback_data; struct sbp2_logical_unit *lu = callback_data;
struct sbp2_orb *orb; struct sbp2_orb *orb;
struct sbp2_status status; struct sbp2_status status;
size_t header_size;
unsigned long flags; unsigned long flags;
if (tcode != TCODE_WRITE_BLOCK_REQUEST || if (tcode != TCODE_WRITE_BLOCK_REQUEST ||
length == 0 || length > sizeof(status)) { length < 8 || length > sizeof(status)) {
fw_send_response(card, request, RCODE_TYPE_ERROR); fw_send_response(card, request, RCODE_TYPE_ERROR);
return; return;
} }
header_size = min(length, 2 * sizeof(u32)); status.status = be32_to_cpup(payload);
fw_memcpy_from_be32(&status, payload, header_size); status.orb_low = be32_to_cpup(payload + 4);
if (length > header_size) memset(status.data, 0, sizeof(status.data));
memcpy(status.data, payload + 8, length - header_size); if (length > 8)
memcpy(status.data, payload + 8, length - 8);
if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) { if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) {
fw_notify("non-orb related status write, not handled\n"); fw_notify("non-orb related status write, not handled\n");
fw_send_response(card, request, RCODE_COMPLETE); fw_send_response(card, request, RCODE_COMPLETE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment