Lines Matching +full:step +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0-only
3 * ntpfw.c - Firmware helper functions for Neofidelity codecs
16 u8 step; member
34 buf_magic = be32_to_cpu(header->magic); in ntpfw_verify()
48 dev_err(dev, "Failed to load firmware: chunk size too big\n"); in ntpfw_verify_chunk()
52 if (chunk->step != 2 && chunk->step != 5) { in ntpfw_verify_chunk()
53 dev_err(dev, "Failed to load firmware: invalid chunk step: %d\n", chunk->step); in ntpfw_verify_chunk()
57 chunk_size = be16_to_cpu(chunk->length); in ntpfw_verify_chunk()
63 if (chunk_size % chunk->step) { in ntpfw_verify_chunk()
64 dev_err(dev, "Failed to load firmware: chunk length and step mismatch\n"); in ntpfw_verify_chunk()
75 size_t length = be16_to_cpu(chunk->length); in ntpfw_send_chunk()
77 for (i = 0; i < length; i += chunk->step) { in ntpfw_send_chunk()
78 ret = i2c_master_send(i2c, &chunk->data[i], chunk->step); in ntpfw_send_chunk()
79 if (ret != chunk->step) { in ntpfw_send_chunk()
80 dev_err(&i2c->dev, "I2C send failed: %d\n", ret); in ntpfw_send_chunk()
81 return ret < 0 ? ret : -EIO; in ntpfw_send_chunk()
90 struct device *dev = &i2c->dev; in ntpfw_load()
104 if (!ntpfw_verify(dev, fw->data, fw->size, magic)) { in ntpfw_load()
105 ret = -EINVAL; in ntpfw_load()
109 data = fw->data + sizeof(struct ntpfw_header); in ntpfw_load()
110 leftover = fw->size - sizeof(struct ntpfw_header); in ntpfw_load()
116 ret = -EINVAL; in ntpfw_load()
124 data += be16_to_cpu(chunk->length) + sizeof(*chunk); in ntpfw_load()
125 leftover -= be16_to_cpu(chunk->length) + sizeof(*chunk); in ntpfw_load()