Allow writing multiple bytes to the I²C device

This commit is contained in:
Richard Hughes 2021-06-24 10:39:19 +01:00
parent 046e81e844
commit 8ae988dda8
3 changed files with 50 additions and 0 deletions

View File

@ -226,6 +226,44 @@ fu_i2c_device_read (FuI2cDevice *self, guint8 *data, GError **error)
return fu_udev_device_pread_full (FU_UDEV_DEVICE (self), 0x0, data, 0x1, error);
}
/**
* fu_i2c_device_write_full:
* @self: a #FuI2cDevice
* @buf: (out): data
* @bufsz: size of @data
* @error: (nullable): optional return location for an error
*
* Write multiple bytes to the I²C device.
*
* Returns: %TRUE for success
*
* Since: 1.6.2
**/
gboolean
fu_i2c_device_write_full (FuI2cDevice *self, const guint8 *buf, gsize bufsz, GError **error)
{
return fu_udev_device_pwrite_full (FU_UDEV_DEVICE (self), 0x0, buf, bufsz, error);
}
/**
* fu_i2c_device_read_full:
* @self: a #FuI2cDevice
* @buf: (out): data
* @bufsz: size of @data
* @error: (nullable): optional return location for an error
*
* Read multiple bytes from the I²C device.
*
* Returns: %TRUE for success
*
* Since: 1.6.2
**/
gboolean
fu_i2c_device_read_full (FuI2cDevice *self, guint8 *buf, gsize bufsz, GError **error)
{
return fu_udev_device_pread_full (FU_UDEV_DEVICE (self), 0x0, buf, bufsz, error);
}
static void
fu_i2c_device_init (FuI2cDevice *self)
{

View File

@ -30,3 +30,13 @@ gboolean fu_i2c_device_write (FuI2cDevice *self,
guint8 data,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean fu_i2c_device_read_full (FuI2cDevice *self,
guint8 *buf,
gsize bufsz,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean fu_i2c_device_write_full (FuI2cDevice *self,
const guint8 *buf,
gsize bufsz,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;

View File

@ -828,6 +828,8 @@ LIBFWUPDPLUGIN_1.6.2 {
fu_device_register_private_flag;
fu_device_remove_private_flag;
fu_device_set_private_flags;
fu_i2c_device_read_full;
fu_i2c_device_set_bus_number;
fu_i2c_device_write_full;
local: *;
} LIBFWUPDPLUGIN_1.6.1;