dp_aux_bridge.c 2.4 KB

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