/* CLI command to read and display a device register.  */
int32_t ad7124_8pmdz_reg_read(struct ad7124_8pmdz_dev *dev, uint8_t *arg)
/* CLI command to read and display a device register.  */
int32_t ad7124_8pmdz_reg_read(struct ad7124_8pmdz_dev *dev, uint8_t *arg)
{
	uint8_t reg_addr;
	int32_t ret;
	uint8_t buff[50];
	reg_addr = strtol((char *)arg, NULL, 16);
	if (reg_addr >= AD7124_REG_NO)
		return cli_write_string(dev->cli_handler,
					(uint8_t*)"Wrong register address.\n");
	ret = ad7124_read_register(dev->ad7124_handler,
				   &dev->ad7124_handler->regs[reg_addr]);
	if(ret != SUCCESS)
		return cli_write_string(dev->cli_handler,
					(uint8_t*)"SPI read error.\n");
	sprintf((char *)buff, "Register 0x%s value is: 0x%.6lx\n\r",
		arg, dev->ad7124_handler->regs[reg_addr].value);
	return cli_write_string(dev->cli_handler, buff);
}