選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

job.c 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /****************************************************************************
  40. *
  41. * Helper methods
  42. *
  43. * These functions are designed to be used as methods in the
  44. * job_interface_operations table.
  45. *
  46. */
  47. void ignore_job_done ( struct job_interface *job __unused, int rc __unused ) {
  48. /* Nothing to do */
  49. }
  50. void ignore_job_kill ( struct job_interface *job __unused ) {
  51. /* Nothing to do */
  52. }
  53. void ignore_job_progress ( struct job_interface *job __unused,
  54. struct job_progress *progress ) {
  55. memset ( progress, 0, sizeof ( *progress ) );
  56. }
  57. /** Null job control interface operations */
  58. struct job_interface_operations null_job_ops = {
  59. .done = ignore_job_done,
  60. .kill = ignore_job_kill,
  61. .progress = ignore_job_progress,
  62. };
  63. /**
  64. * Null job control interface
  65. *
  66. * This is the interface to which job control interfaces are connected
  67. * when unplugged. It will never generate messages, and will silently
  68. * absorb all received messages.
  69. */
  70. struct job_interface null_job = {
  71. .intf = {
  72. .dest = &null_job.intf,
  73. .refcnt = NULL,
  74. },
  75. .op = &null_job_ops,
  76. };