iomap_copy.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * This file is free software; you can redistribute it and/or modify
  3. * it under the terms of version 2 of the GNU General Public License
  4. * as published by the Free Software Foundation.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License
  12. * along with this program; if not, write to the Free Software Foundation,
  13. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  14. */
  15. #include <linux/export.h>
  16. #include <linux/io.h>
  17. /**
  18. * __ioread64_copy - copy data from MMIO space, in 64-bit units
  19. * @to: destination (must be 64-bit aligned)
  20. * @from: source, in MMIO space (must be 64-bit aligned)
  21. * @count: number of 64-bit quantities to copy
  22. *
  23. * Copy data from MMIO space to kernel space, in units of 32 or 64 bits at a
  24. * time. Order of access is not guaranteed, nor is a memory barrier
  25. * performed afterwards.
  26. */
  27. void __ioread64_copy(void *to, const void __iomem *from, size_t count)
  28. {
  29. #ifdef CONFIG_64BIT
  30. u64 *dst = to;
  31. const u64 __iomem *src = from;
  32. const u64 __iomem *end = src + count;
  33. while (src < end)
  34. *dst++ = __raw_readq(src++);
  35. #else
  36. __ioread32_copy(to, from, count * 2);
  37. #endif
  38. }
  39. EXPORT_SYMBOL_GPL(__ioread64_copy);