Lines Matching defs:ac97_ctrl
61 ac97_codec_find(struct ac97_controller *ac97_ctrl, unsigned int codec_num)
66 return ac97_ctrl->codecs[codec_num];
70 ac97_of_get_child_device(struct ac97_controller *ac97_ctrl, int idx,
80 for_each_child_of_node(ac97_ctrl->parent->of_node, node) {
93 struct ac97_controller *ac97_ctrl;
96 ac97_ctrl = adev->ac97_ctrl;
97 ac97_ctrl->codecs[adev->num] = NULL;
102 static int ac97_codec_add(struct ac97_controller *ac97_ctrl, int idx,
111 ac97_ctrl->codecs[idx] = codec;
115 codec->dev.parent = &ac97_ctrl->adap;
117 codec->ac97_ctrl = ac97_ctrl;
120 dev_set_name(&codec->dev, "%s:%u", dev_name(ac97_ctrl->parent), idx);
121 codec->dev.of_node = ac97_of_get_child_device(ac97_ctrl, idx,
154 static int ac97_bus_scan(struct ac97_controller *ac97_ctrl)
160 if (ac97_codec_find(ac97_ctrl, i))
162 if (!(ac97_ctrl->slots_available & BIT(i)))
164 vendor_id = snd_ac97_bus_scan_one(ac97_ctrl, i);
168 ret = ac97_codec_add(ac97_ctrl, i, vendor_id);
175 static int ac97_bus_reset(struct ac97_controller *ac97_ctrl)
177 ac97_ctrl->ops->reset(ac97_ctrl);
222 struct ac97_controller *ac97_ctrl = adev->ac97_ctrl;
224 return ac97_ctrl->codecs_pdata[adev->num];
228 static void ac97_ctrl_codecs_unregister(struct ac97_controller *ac97_ctrl)
233 if (ac97_ctrl->codecs[i]) {
234 ac97_ctrl->codecs[i]->ac97_ctrl = &ac97_unbound_ctrl;
235 device_unregister(&ac97_ctrl->codecs[i]->dev);
243 struct ac97_controller *ac97_ctrl;
246 ac97_ctrl = to_ac97_controller(dev);
247 ac97_ctrl->ops->reset(ac97_ctrl);
257 struct ac97_controller *ac97_ctrl;
263 ac97_ctrl = to_ac97_controller(dev);
264 ac97_ctrl->ops->warm_reset(ac97_ctrl);
286 static void ac97_del_adapter(struct ac97_controller *ac97_ctrl)
289 ac97_ctrl_codecs_unregister(ac97_ctrl);
290 list_del(&ac97_ctrl->controllers);
293 device_unregister(&ac97_ctrl->adap);
298 struct ac97_controller *ac97_ctrl;
300 ac97_ctrl = to_ac97_controller(dev);
301 idr_remove(&ac97_adapter_idr, ac97_ctrl->nr);
302 dev_dbg(&ac97_ctrl->adap, "adapter unregistered by %s\n",
303 dev_name(ac97_ctrl->parent));
311 static int ac97_add_adapter(struct ac97_controller *ac97_ctrl)
316 ret = idr_alloc(&ac97_adapter_idr, ac97_ctrl, 0, 0, GFP_KERNEL);
317 ac97_ctrl->nr = ret;
319 dev_set_name(&ac97_ctrl->adap, "ac97-%d", ret);
320 ac97_ctrl->adap.type = &ac97_adapter_type;
321 ac97_ctrl->adap.parent = ac97_ctrl->parent;
322 ret = device_register(&ac97_ctrl->adap);
324 put_device(&ac97_ctrl->adap);
327 list_add(&ac97_ctrl->controllers, &ac97_controllers);
331 dev_dbg(&ac97_ctrl->adap, "adapter registered by %s\n",
332 dev_name(ac97_ctrl->parent));
352 struct ac97_controller *ac97_ctrl;
355 ac97_ctrl = kzalloc(sizeof(*ac97_ctrl), GFP_KERNEL);
356 if (!ac97_ctrl)
360 ac97_ctrl->codecs_pdata[i] = codecs_pdata[i];
362 ac97_ctrl->ops = ops;
363 ac97_ctrl->slots_available = slots_available;
364 ac97_ctrl->parent = dev;
365 ret = ac97_add_adapter(ac97_ctrl);
369 ac97_bus_reset(ac97_ctrl);
370 ac97_bus_scan(ac97_ctrl);
372 return ac97_ctrl;
374 kfree(ac97_ctrl);
381 * @ac97_ctrl: the device previously provided to ac97_controller_register()
384 void snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl)
386 ac97_del_adapter(ac97_ctrl);