On Fri, Jul 31, 2015 at 01:55:07AM -0500, Peter E. Berger wrote: > From: "Peter E. Berger" <pberger@xxxxxxxxxxx> > +static int check_fw_sanity(struct edgeport_serial *serial, > + const struct firmware *fw) > +{ > + u16 length_total; > + u8 checksum = 0; > + int pos; > + struct device *dev = &serial->serial->interface->dev; > + struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data; > + > + if (fw->size < sizeof(struct edgeport_fw_hdr)) { > + dev_err(dev, "incomplete fw header\n"); > + return -EINVAL; > + } > + > + length_total = le16_to_cpu(fw_hdr->length) + > + sizeof(struct edgeport_fw_hdr); > + > + if (fw->size != length_total) { > + dev_err(dev, "bad fw size (expected: %u, got: %zu)\n", > + length_total, fw->size); > + return -EINVAL; > + } > + > + for (pos = sizeof(struct edgeport_fw_hdr); pos < fw->size; ++pos) > + checksum = (checksum + fw->data[pos]) & 0xFF; I simplified this to checksum += fw->data[pos]; before applying. Thanks, Johan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html