Don't print a misleading header length mismatch error if the i2c call returns an error. Instead just return the error code without any error message.
Unified · Split
| @@ -122,7 +122,9 @@ static int nxp_nci_i2c_fw_read(struct nxp_nci_i2c_phy *phy, · 121 unmodified lines | ||
| 122 | 122 | skb_put_data(*skb, &header, NXP_NCI_FW_HDR_LEN); |
| 123 | 123 | |
| 124 | 124 | r = i2c_master_recv(client, skb_put(*skb, frame_len), frame_len); |
| 125 | − if (r != frame_len) { | |
| 125 | + if (r < 0) { | |
| 126 | + goto fw_read_exit_free_skb; | |
| 127 | + } else if (r != frame_len) { | |
| 126 | 128 | nfc_err(&client->dev, |
| 127 | 129 | "Invalid frame length: %u (expected %zu)\n", |
| 128 | 130 | r, frame_len); |
| @@ -166,7 +168,9 @@ static int nxp_nci_i2c_nci_read(struct nxp_nci_i2c_phy *phy, · 37 unmodified lines | ||
| 166 | 168 | return 0; |
| 167 | 169 | |
| 168 | 170 | r = i2c_master_recv(client, skb_put(*skb, header.plen), header.plen); |
| 169 | − if (r != header.plen) { | |
| 171 | + if (r < 0) { | |
| 172 | + goto nci_read_exit_free_skb; | |
| 173 | + } else if (r != header.plen) { | |
| 170 | 174 | nfc_err(&client->dev, |
| 171 | 175 | "Invalid frame payload length: %u (expected %u)\n", |
| 172 | 176 | r, header.plen); |