trio.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2012 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. /*
  15. * Implementation of trio gxio calls.
  16. */
  17. #include <linux/errno.h>
  18. #include <linux/io.h>
  19. #include <linux/module.h>
  20. #include <gxio/trio.h>
  21. #include <gxio/iorpc_globals.h>
  22. #include <gxio/iorpc_trio.h>
  23. #include <gxio/kiorpc.h>
  24. int gxio_trio_init(gxio_trio_context_t *context, unsigned int trio_index)
  25. {
  26. char file[32];
  27. int fd;
  28. snprintf(file, sizeof(file), "trio/%d/iorpc", trio_index);
  29. fd = hv_dev_open((HV_VirtAddr) file, 0);
  30. if (fd < 0) {
  31. context->fd = -1;
  32. if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
  33. return fd;
  34. else
  35. return -ENODEV;
  36. }
  37. context->fd = fd;
  38. return 0;
  39. }
  40. EXPORT_SYMBOL_GPL(gxio_trio_init);