/* Writes up to 4 bytes of data to the serial flash. The location of the write needs to be specified prior to calling this by issuing the appropriate commands to the serial flash.  */
static int sf1_write(struct adapter *adapter, unsigned int byte_cnt, int cont, u32 val)
/* Writes up to 4 bytes of data to the serial flash. The location of the write needs to be specified prior to calling this by issuing the appropriate commands to the serial flash.  */
static int sf1_write(struct adapter *adapter, unsigned int byte_cnt, int cont, u32 val)
{
	if (!byte_cnt || byte_cnt > 4)
		return -EINVAL;
	if (t3_read_reg(adapter, A_SF_OP) & F_BUSY)
		return -EBUSY;
	t3_write_reg(adapter, A_SF_DATA, val);
	t3_write_reg(adapter, A_SF_OP,
		     V_CONT(cont) | V_BYTECNT(byte_cnt - 1) | V_OP(1));
	return t3_wait_op_done(adapter, A_SF_OP, F_BUSY, 0, SF_ATTEMPTS, 10);
}