return pf->flags & I40E_FLAG_TC_MQPRIO;
 }
 
+/**
+ * i40e_hw_to_pf - get pf pointer from the hardware structure
+ * @hw: pointer to the device HW structure
+ **/
+static inline struct i40e_pf *i40e_hw_to_pf(struct i40e_hw *hw)
+{
+       return container_of(hw, struct i40e_pf, hw);
+}
+
+struct device *i40e_hw_to_dev(struct i40e_hw *hw);
+
 #endif /* _I40E_H_ */
 
        }
 }
 
+/**
+ * i40e_hw_to_dev - get device pointer from the hardware structure
+ * @hw: pointer to the device HW structure
+ **/
+struct device *i40e_hw_to_dev(struct i40e_hw *hw)
+{
+       struct i40e_pf *pf = i40e_hw_to_pf(hw);
+
+       return &pf->pdev->dev;
+}
+
 /**
  * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code
  * @hw:   pointer to the HW structure
 int i40e_allocate_dma_mem_d(struct i40e_hw *hw, struct i40e_dma_mem *mem,
                            u64 size, u32 alignment)
 {
-       struct i40e_pf *pf = (struct i40e_pf *)hw->back;
+       struct i40e_pf *pf = i40e_hw_to_pf(hw);
 
        mem->size = ALIGN(size, alignment);
        mem->va = dma_alloc_coherent(&pf->pdev->dev, mem->size, &mem->pa,
  **/
 int i40e_free_dma_mem_d(struct i40e_hw *hw, struct i40e_dma_mem *mem)
 {
-       struct i40e_pf *pf = (struct i40e_pf *)hw->back;
+       struct i40e_pf *pf = i40e_hw_to_pf(hw);
 
        dma_free_coherent(&pf->pdev->dev, mem->size, mem->va, mem->pa);
        mem->va = NULL;
  **/
 static inline void i40e_set_subsystem_device_id(struct i40e_hw *hw)
 {
-       struct pci_dev *pdev = ((struct i40e_pf *)hw->back)->pdev;
+       struct i40e_pf *pf = i40e_hw_to_pf(hw);
 
-       hw->subsystem_device_id = pdev->subsystem_device ?
-               pdev->subsystem_device :
+       hw->subsystem_device_id = pf->pdev->subsystem_device ?
+               pf->pdev->subsystem_device :
                (ushort)(rd32(hw, I40E_PFPCI_SUBSYSID) & USHRT_MAX);
 }
 
        set_bit(__I40E_DOWN, pf->state);
 
        hw = &pf->hw;
-       hw->back = pf;
 
        pf->ioremap_len = min_t(int, pci_resource_len(pdev, 0),
                                I40E_MAX_CSR_SPACE);
 
  * actual OS primitives
  */
 
-#define hw_dbg(hw, S, A...)                                                    \
-do {                                                                           \
-       dev_dbg(&((struct i40e_pf *)hw->back)->pdev->dev, S, ##A);              \
-} while (0)
+struct i40e_hw;
+struct device *i40e_hw_to_dev(struct i40e_hw *hw);
+
+#define hw_dbg(hw, S, A...) dev_dbg(i40e_hw_to_dev(hw), S, ##A)
 
 #define wr32(a, reg, value)    writel((value), ((a)->hw_addr + (reg)))
 #define rd32(a, reg)           readl((a)->hw_addr + (reg))