Lines Matching +full:a +full:- +full:h

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * bound to a master device.
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/types.h>
15 #include <linux/slab.h>
17 #include "videocodec.h"
39 struct codec_list *h = codeclist_top; in videocodec_attach() local
41 struct attached_list *a, *ptr; in videocodec_attach() local
53 master->name, master->flags, master->magic); in videocodec_attach()
55 if (!h) { in videocodec_attach()
60 while (h) { in videocodec_attach()
63 if ((master->flags & h->codec->flags) == master->flags) { in videocodec_attach()
64 zrdev_dbg(zr, "%s: try '%s'\n", __func__, h->codec->name); in videocodec_attach()
66 codec = kmemdup(h->codec, sizeof(struct videocodec), GFP_KERNEL); in videocodec_attach()
70 res = strlen(codec->name); in videocodec_attach()
71 snprintf(codec->name + res, sizeof(codec->name) - res, "[%d]", h->attached); in videocodec_attach()
72 codec->master_data = master; in videocodec_attach()
73 res = codec->setup(codec); in videocodec_attach()
75 zrdev_dbg(zr, "%s: '%s'\n", __func__, codec->name); in videocodec_attach()
79 ptr->codec = codec; in videocodec_attach()
81 a = h->list; in videocodec_attach()
82 if (!a) { in videocodec_attach()
83 h->list = ptr; in videocodec_attach()
86 while (a->next) in videocodec_attach()
87 a = a->next; // find end in videocodec_attach()
88 a->next = ptr; in videocodec_attach()
90 h->codec->name); in videocodec_attach()
93 h->attached += 1; in videocodec_attach()
98 h = h->next; in videocodec_attach()
111 struct codec_list *h = codeclist_top; in videocodec_detach() local
113 struct attached_list *a, *prev; in videocodec_detach() local
118 return -EINVAL; in videocodec_detach()
124 codec->name, codec->type, codec->flags, codec->magic); in videocodec_detach()
126 if (!h) { in videocodec_detach()
128 return -ENXIO; in videocodec_detach()
131 while (h) { in videocodec_detach()
132 a = h->list; in videocodec_detach()
134 while (a) { in videocodec_detach()
135 if (codec == a->codec) { in videocodec_detach()
136 res = a->codec->unset(a->codec); in videocodec_detach()
139 a->codec->name); in videocodec_detach()
140 a->codec->master_data = NULL; in videocodec_detach()
142 zrdev_err(zr, "%s: '%s'\n", __func__, a->codec->name); in videocodec_detach()
143 a->codec->master_data = NULL; in videocodec_detach()
146 h->list = a->next; in videocodec_detach()
149 prev->next = a->next; in videocodec_detach()
152 kfree(a->codec); in videocodec_detach()
153 kfree(a); in videocodec_detach()
154 h->attached -= 1; in videocodec_detach()
157 prev = a; in videocodec_detach()
158 a = a->next; in videocodec_detach()
160 h = h->next; in videocodec_detach()
164 return -EINVAL; in videocodec_detach()
169 struct codec_list *ptr, *h = codeclist_top; in videocodec_register() local
174 return -EINVAL; in videocodec_register()
181 codec->name, codec->type, codec->flags, codec->magic); in videocodec_register()
185 return -ENOMEM; in videocodec_register()
186 ptr->codec = codec; in videocodec_register()
188 if (!h) { in videocodec_register()
192 while (h->next) in videocodec_register()
193 h = h->next; // find the end in videocodec_register()
194 h->next = ptr; in videocodec_register()
196 h->codec->name); in videocodec_register()
204 struct codec_list *prev = NULL, *h = codeclist_top; in videocodec_unregister() local
209 return -EINVAL; in videocodec_unregister()
216 codec->name, codec->type, codec->flags, codec->magic); in videocodec_unregister()
218 if (!h) { in videocodec_unregister()
220 return -ENXIO; in videocodec_unregister()
223 while (h) { in videocodec_unregister()
224 if (codec == h->codec) { in videocodec_unregister()
225 if (h->attached) { in videocodec_unregister()
227 h->codec->name); in videocodec_unregister()
228 return -EBUSY; in videocodec_unregister()
231 h->codec->name); in videocodec_unregister()
233 codeclist_top = h->next; in videocodec_unregister()
237 prev->next = h->next; in videocodec_unregister()
241 kfree(h); in videocodec_unregister()
244 prev = h; in videocodec_unregister()
245 h = h->next; in videocodec_unregister()
249 return -EINVAL; in videocodec_unregister()
254 struct codec_list *h = codeclist_top; in videocodec_debugfs_show() local
255 struct attached_list *a; in videocodec_debugfs_show() local
260 while (h) { in videocodec_debugfs_show()
262 h->codec->name, h->codec->type, in videocodec_debugfs_show()
263 h->codec->flags, h->codec->magic); in videocodec_debugfs_show()
264 a = h->list; in videocodec_debugfs_show()
265 while (a) { in videocodec_debugfs_show()
267 a->codec->master_data->name, in videocodec_debugfs_show()
268 a->codec->master_data->type, in videocodec_debugfs_show()
269 a->codec->master_data->flags, in videocodec_debugfs_show()
270 a->codec->master_data->magic, in videocodec_debugfs_show()
271 a->codec->name); in videocodec_debugfs_show()
272 a = a->next; in videocodec_debugfs_show()
274 h = h->next; in videocodec_debugfs_show()