/** * ismt_desc_dump() - dump the contents of a descriptor for debug purposes * @priv: iSMT private data */ static void ismt_desc_dump(struct ismt_priv *priv) { struct device *dev = &priv->pci_dev->dev; struct ismt_desc *desc = &priv->hw[priv->head]; dev_dbg(dev, "Dump of the descriptor struct: 0x%X\n", priv->head); __ismt_desc_dump(dev, desc); }
/** * ismt_process_desc() - handle the completion of the descriptor * @desc: the iSMT hardware descriptor * @data: data buffer from the upper layer * @priv: ismt_priv struct holding our dma buffer * @size: SMBus transaction type * @read_write: flag to indicate if this is a read or write */ static int ismt_process_desc(const struct ismt_desc *desc, union i2c_smbus_data *data, struct ismt_priv *priv, int size, char read_write) { u8 *dma_buffer = priv->dma_buffer; dev_dbg(&priv->pci_dev->dev, "Processing completed descriptor\n"); __ismt_desc_dump(&priv->pci_dev->dev, desc); if (desc->status & ISMT_DESC_SCS) { if (read_write == I2C_SMBUS_WRITE && size != I2C_SMBUS_PROC_CALL) return 0; switch (size) { case I2C_SMBUS_BYTE: case I2C_SMBUS_BYTE_DATA: data->byte = dma_buffer[0]; break; case I2C_SMBUS_WORD_DATA: case I2C_SMBUS_PROC_CALL: data->word = dma_buffer[0] | (dma_buffer[1] << 8); break; case I2C_SMBUS_BLOCK_DATA: if (desc->rxbytes != dma_buffer[0] + 1) return -EMSGSIZE; memcpy(data->block, dma_buffer, desc->rxbytes); break; case I2C_SMBUS_I2C_BLOCK_DATA: memcpy(&data->block[1], dma_buffer, desc->rxbytes); data->block[0] = desc->rxbytes; break; } return 0; } if (likely(desc->status & ISMT_DESC_NAK)) return -ENXIO; if (desc->status & ISMT_DESC_CRC) return -EBADMSG; if (desc->status & ISMT_DESC_COL) return -EAGAIN; if (desc->status & ISMT_DESC_LPR) return -EPROTO; if (desc->status & (ISMT_DESC_DLTO | ISMT_DESC_CLTO)) return -ETIMEDOUT; return -EIO; }