// i can do it better .. 
int switch_cmd(FILE *fd, struct opt options) {

	int ret; 

	switch(options.act) {
		
		case CUSTOM: 
			ret = custom_cmd(fd, options.custom_cmd); 
			break;

		case READ:
			ret = rw_cmd(fd, options);
			break;

		case WRITE:
			ret = rw_cmd(fd, options); 
			break;

		case SEARCH:
			ret = search_cmd(fd, options); 
			break;

		case LIST:
			ret = list_cmd(fd);
			break;

		case INFO:
			ret = info_cmd(fd);
			break;
	}

	return ret;
}
Exemple #2
0
/** @brief Write arbitrary transceiver register
 *
 * The address should be of the form 0xAB. The span parameter is used
 * to expand the address into the IDT native register address form of
 * 0xXAB where X is the correct span number on the targeted device.
 *
 * @param f the device context
 * @param span the span we wish to write to
 * @param address the register to write to
 * @param data the 8-bit data to write
 * @return an fblib_err representing success or failure
 */
fblib_err
writeidt (libfb_t * f, unsigned char span, uint8_t address, uint8_t data)
{
    uint8_t buffer[2];

    buffer[0] = address;
    buffer[1] = data;

    return custom_cmd (f, DOOF_CMD_IDT_WRITE_REG, span, buffer, 2);
}