[PATCH V2 2/4] USB: UHCI: Use ACCESS_ONCE rather than using a full compiler barrier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch (as1462) updates the special accessor functions defined in
uhci-hcd.h.  Rather than using a full compiler barrier, all we really
need is the ACCESS_ONCE() mechanism, because the idea is to prevent
the compiler from caching a value that can change at any time.

Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
---
Update for V2 of patch series:
Added this patch from Alan Stern.
---
 drivers/usb/host/uhci-hcd.h |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 31f110f..20a8949 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -168,12 +168,7 @@ struct uhci_qh {
  * We need a special accessor for the element pointer because it is
  * subject to asynchronous updates by the controller.
  */
-static inline __le32 qh_element(struct uhci_qh *qh) {
-	__le32 element = qh->element;
-
-	barrier();
-	return element;
-}
+#define qh_element(qh)		ACCESS_ONCE((qh)->element)
 
 #define LINK_TO_QH(qh)		(UHCI_PTR_QH | cpu_to_le32((qh)->dma_handle))
 
@@ -263,12 +258,7 @@ struct uhci_td {
  * We need a special accessor for the control/status word because it is
  * subject to asynchronous updates by the controller.
  */
-static inline u32 td_status(struct uhci_td *td) {
-	__le32 status = td->status;
-
-	barrier();
-	return le32_to_cpu(status);
-}
+#define td_status(td)		le32_to_cpu(ACCESS_ONCE((td)->status))
 
 #define LINK_TO_TD(td)		(cpu_to_le32((td)->dma_handle))
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux