dp_aux_bridge.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. /*
  15. * Copyright (c) 2014 Samsung Electronics Co., Ltd
  16. *
  17. * Permission is hereby granted, free of charge, to any person obtaining a
  18. * copy of this software and associated documentation files (the "Software"),
  19. * to deal in the Software without restriction, including without limitation
  20. * the rights to use, copy, modify, merge, publish, distribute, sub license,
  21. * and/or sell copies of the Software, and to permit persons to whom the
  22. * Software is furnished to do so, subject to the following conditions:
  23. *
  24. * The above copyright notice and this permission notice (including the
  25. * next paragraph) shall be included in all copies or substantial portions
  26. * of the Software.
  27. *
  28. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  29. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  30. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  31. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  33. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  34. * DEALINGS IN THE SOFTWARE.
  35. */
  36. #include "dp_aux_bridge.h"
  37. static DEFINE_MUTEX(dp_aux_bridge_lock);
  38. static LIST_HEAD(du_aux_bridge_list);
  39. int dp_aux_add_bridge(struct dp_aux_bridge *bridge)
  40. {
  41. mutex_lock(&dp_aux_bridge_lock);
  42. list_add_tail(&bridge->head, &du_aux_bridge_list);
  43. mutex_unlock(&dp_aux_bridge_lock);
  44. return 0;
  45. }
  46. #ifdef CONFIG_OF
  47. struct dp_aux_bridge *of_dp_aux_find_bridge(struct device_node *np)
  48. {
  49. struct dp_aux_bridge *bridge;
  50. mutex_lock(&dp_aux_bridge_lock);
  51. list_for_each_entry(bridge, &du_aux_bridge_list, head) {
  52. if (bridge->of_node == np) {
  53. mutex_unlock(&dp_aux_bridge_lock);
  54. return bridge;
  55. }
  56. }
  57. mutex_unlock(&dp_aux_bridge_lock);
  58. return NULL;
  59. }
  60. #endif