You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

job.c 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
  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 as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. FILE_LICENCE ( GPL2_OR_LATER );
  19. #include <string.h>
  20. #include <errno.h>
  21. #include <gpxe/job.h>
  22. /** @file
  23. *
  24. * Job control interfaces
  25. *
  26. */
  27. void job_done ( struct job_interface *job, int rc ) {
  28. struct job_interface *dest = job_get_dest ( job );
  29. job_unplug ( job );
  30. dest->op->done ( dest, rc );
  31. job_put ( dest );
  32. }
  33. void job_kill ( struct job_interface *job ) {
  34. struct job_interface *dest = job_get_dest ( job );
  35. job_unplug ( job );
  36. dest->op->kill ( dest );
  37. job_put ( dest );
  38. }
  39. void job_progress ( struct job_interface *job,
  40. struct job_progress *progress ) {
  41. struct job_interface *dest = job_get_dest ( job );
  42. dest->op->progress ( dest, progress );
  43. job_put ( dest );
  44. }
  45. /****************************************************************************
  46. *
  47. * Helper methods
  48. *
  49. * These functions are designed to be used as methods in the
  50. * job_interface_operations table.
  51. *
  52. */
  53. void ignore_job_done ( struct job_interface *job __unused, int rc __unused ) {
  54. /* Nothing to do */
  55. }
  56. void ignore_job_kill ( struct job_interface *job __unused ) {
  57. /* Nothing to do */
  58. }
  59. void ignore_job_progress ( struct job_interface *job __unused,
  60. struct job_progress *progress ) {
  61. memset ( progress, 0, sizeof ( *progress ) );
  62. }
  63. /** Null job control interface operations */
  64. struct job_interface_operations null_job_ops = {
  65. .done = ignore_job_done,
  66. .kill = ignore_job_kill,
  67. .progress = ignore_job_progress,
  68. };
  69. /**
  70. * Null job control interface
  71. *
  72. * This is the interface to which job control interfaces are connected
  73. * when unplugged. It will never generate messages, and will silently
  74. * absorb all received messages.
  75. */
  76. struct job_interface null_job = {
  77. .intf = {
  78. .dest = &null_job.intf,
  79. .refcnt = NULL,
  80. },
  81. .op = &null_job_ops,
  82. };