@@ -71,6 +71,17 @@ static int smbus_i2c_event(I2CSlave *s, enum i2c_event event)
{
SMBusDevice *dev = SMBUS_DEVICE(s);
+ if (event == I2C_START_SEND || event == I2C_START_RECV) {
+ /* Allow the device to NAK the start event. */
+ SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev);
+
+ if (sc->event) {
+ int rv = sc->event(dev, event);
+ if (rv)
+ return rv;
+ }
+ }
+
switch (event) {
case I2C_START_SEND:
switch (dev->mode) {
@@ -39,6 +39,8 @@ typedef struct SMBusDeviceClass
{
I2CSlaveClass parent_class;
int (*init)(SMBusDevice *dev);
+ /* Allow the device to get start and stop events so they can NAK them. */
+ int (*event)(SMBusDevice *dev, enum i2c_event event);
void (*quick_cmd)(SMBusDevice *dev, uint8_t read);
void (*send_byte)(SMBusDevice *dev, uint8_t val);
uint8_t (*receive_byte)(SMBusDevice *dev);