iwlwifi: move register access lock into transport

Move the reg_lock that protects HW register access
into the transport implementation. Locking is no
longer exposed, but handled internally in grab and
release NIC access. This simplifies the users.

Signed-off-by: Lilach Edelstein <lilach.edelstein@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
diff --git a/drivers/net/wireless/iwlwifi/iwl-test.c b/drivers/net/wireless/iwlwifi/iwl-test.c
index d06fc55..ce0c67b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-test.c
+++ b/drivers/net/wireless/iwlwifi/iwl-test.c
@@ -466,9 +466,7 @@
 	/* Hard-coded periphery absolute address */
 	if (IWL_ABS_PRPH_START <= addr &&
 	    addr < IWL_ABS_PRPH_START + PRPH_END) {
-			spin_lock_irqsave(&trans->reg_lock, flags);
-			if (!iwl_trans_grab_nic_access(trans, false)) {
-				spin_unlock_irqrestore(&trans->reg_lock, flags);
+			if (!iwl_trans_grab_nic_access(trans, false, &flags)) {
 				return -EIO;
 			}
 			iwl_write32(trans, HBUS_TARG_PRPH_RADDR,
@@ -476,8 +474,7 @@
 			for (i = 0; i < size; i += 4)
 				*(u32 *)(tst->mem.addr + i) =
 					iwl_read32(trans, HBUS_TARG_PRPH_RDAT);
-			iwl_trans_release_nic_access(trans);
-			spin_unlock_irqrestore(&trans->reg_lock, flags);
+			iwl_trans_release_nic_access(trans, &flags);
 	} else { /* target memory (SRAM) */
 		iwl_trans_read_mem(trans, addr, tst->mem.addr,
 				   tst->mem.size / 4);
@@ -506,19 +503,13 @@
 		/* Periphery writes can be 1-3 bytes long, or DWORDs */
 		if (size < 4) {
 			memcpy(&val, buf, size);
-			spin_lock_irqsave(&trans->reg_lock, flags);
-			if (!iwl_trans_grab_nic_access(trans, false)) {
-				spin_unlock_irqrestore(&trans->reg_lock, flags);
+			if (!iwl_trans_grab_nic_access(trans, false, &flags))
 					return -EIO;
-			}
 			iwl_write32(trans, HBUS_TARG_PRPH_WADDR,
 				    (addr & 0x0000FFFF) |
 				    ((size - 1) << 24));
 			iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val);
-			iwl_trans_release_nic_access(trans);
-			/* needed after consecutive writes w/o read */
-			mmiowb();
-			spin_unlock_irqrestore(&trans->reg_lock, flags);
+			iwl_trans_release_nic_access(trans, &flags);
 		} else {
 			if (size % 4)
 				return -EINVAL;