driver-hashbusteravalon.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2014 Luke Dashjr
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. */
  9. #include "config.h"
  10. #include <stdbool.h>
  11. #include <stdlib.h>
  12. #include "deviceapi.h"
  13. #include "driver-klondike.h"
  14. #include "logging.h"
  15. #include "lowlevel.h"
  16. BFG_REGISTER_DRIVER(hashbusteravalon_drv)
  17. static
  18. bool hashbusteravalon_lowl_match(const struct lowlevel_device_info * const info)
  19. {
  20. if (!lowlevel_match_id(info, &lowl_usb, 0xfa05, 0x0001))
  21. return false;
  22. return (info->manufacturer && strstr(info->manufacturer, "HashBuster"));
  23. }
  24. static
  25. bool hashbusteravalon_lowl_probe(const struct lowlevel_device_info * const info)
  26. {
  27. struct klondike_info * const klninfo = malloc(sizeof(*klninfo));
  28. if (unlikely(!klninfo))
  29. applogr(false, LOG_ERR, "%s: Failed to malloc klninfo", __func__);
  30. *klninfo = (struct klondike_info){
  31. .clock = 2425,
  32. .max_work_count = 0x20,
  33. .old_work_ms = 30000,
  34. .reply_wait_time = 5,
  35. };
  36. return klondike_lowl_probe_custom(info, &hashbusteravalon_drv, klninfo);
  37. }
  38. static void hashbusteravalon_drv_init()
  39. {
  40. hashbusteravalon_drv = klondike_drv;
  41. hashbusteravalon_drv.dname = "hashbusteravalon";
  42. hashbusteravalon_drv.name = "HBA";
  43. hashbusteravalon_drv.lowl_match = hashbusteravalon_lowl_match;
  44. hashbusteravalon_drv.lowl_probe = hashbusteravalon_lowl_probe;
  45. }
  46. struct device_drv hashbusteravalon_drv = {
  47. .drv_init = hashbusteravalon_drv_init,
  48. };