/* It's not possible to write a single byte to u-blox. * Write all bytes in a loop until there are 6 or less bytes left. If * there are exactly 6 bytes left, the last write would be only a byte. * In this case, do 4+2 bytes writes instead of 5+1. Otherwise, do the * last 2 to 5 bytes write.
*/ while (size - offset > ICE_GNSS_UBX_WRITE_BYTES + 1) {
err = ice_aq_write_i2c(hw, link_topo, ICE_GNSS_UBX_I2C_BUS_ADDR,
cpu_to_le16(buf[offset]),
ICE_MAX_I2C_WRITE_BYTES,
&buf[offset + 1], NULL); if (err) goto err_out;
offset += ICE_GNSS_UBX_WRITE_BYTES;
}
/* Single byte would be written. Write 4 bytes instead of 5. */ if (size - offset == ICE_GNSS_UBX_WRITE_BYTES + 1) {
err = ice_aq_write_i2c(hw, link_topo, ICE_GNSS_UBX_I2C_BUS_ADDR,
cpu_to_le16(buf[offset]),
ICE_MAX_I2C_WRITE_BYTES - 1,
&buf[offset + 1], NULL); if (err) goto err_out;
offset += ICE_GNSS_UBX_WRITE_BYTES - 1;
}
/* Do the last write, 2 to 5 bytes. */
err = ice_aq_write_i2c(hw, link_topo, ICE_GNSS_UBX_I2C_BUS_ADDR,
cpu_to_le16(buf[offset]), size - offset - 1,
&buf[offset + 1], NULL); if (err) goto err_out;
/** * ice_gnss_write - Write to GNSS device * @gdev: pointer to the gnss device struct * @buf: pointer to the user data * @count: size of the buffer to be sent to the GNSS device * * Return: * * number of written bytes - success * * negative - error code
*/ staticint
ice_gnss_write(struct gnss_device *gdev, constunsignedchar *buf,
size_t count)
{ struct ice_pf *pf = gnss_get_drvdata(gdev); struct gnss_serial *gnss;
/* We cannot write a single byte using our I2C implementation. */ if (count <= 1 || count > ICE_GNSS_TTY_WRITE_BUF) return -EINVAL;
if (!pf) return -EFAULT;
if (!test_bit(ICE_FLAG_GNSS, pf->flags)) return -EFAULT;
gnss = pf->gnss_serial; if (!gnss) return -ENODEV;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet am 2026-06-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.