drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / drivers / video / fbdev / via / via_aux.c
blob902191dddbeba5278f864c27cb04044edde75c69
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
4 */
5 /*
6 * infrastructure for devices connected via I2C
7 */
9 #include <linux/slab.h>
10 #include "via_aux.h"
13 struct via_aux_bus *via_aux_probe(struct i2c_adapter *adap)
15 struct via_aux_bus *bus;
17 if (!adap)
18 return NULL;
20 bus = kmalloc(sizeof(*bus), GFP_KERNEL);
21 if (!bus)
22 return NULL;
24 bus->adap = adap;
25 INIT_LIST_HEAD(&bus->drivers);
27 via_aux_edid_probe(bus);
28 via_aux_vt1636_probe(bus);
29 via_aux_vt1632_probe(bus);
30 via_aux_vt1631_probe(bus);
31 via_aux_vt1625_probe(bus);
32 via_aux_vt1622_probe(bus);
33 via_aux_vt1621_probe(bus);
34 via_aux_sii164_probe(bus);
35 via_aux_ch7301_probe(bus);
37 return bus;
40 void via_aux_free(struct via_aux_bus *bus)
42 struct via_aux_drv *pos, *n;
44 if (!bus)
45 return;
47 list_for_each_entry_safe(pos, n, &bus->drivers, chain) {
48 if (pos->cleanup)
49 pos->cleanup(pos);
51 list_del(&pos->chain);
52 kfree(pos->data);
53 kfree(pos);
56 kfree(bus);
59 const struct fb_videomode *via_aux_get_preferred_mode(struct via_aux_bus *bus)
61 struct via_aux_drv *pos;
62 const struct fb_videomode *mode = NULL;
64 if (!bus)
65 return NULL;
67 list_for_each_entry(pos, &bus->drivers, chain) {
68 if (pos->get_preferred_mode)
69 mode = pos->get_preferred_mode(pos);
72 return mode;