Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
via_aux.c
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Florian Tobias Schandinat <[email protected]>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation;
7  * either version 2, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
11  * the implied warranty of MERCHANTABILITY or FITNESS FOR
12  * A PARTICULAR PURPOSE.See the GNU General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc.,
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20 /*
21  * infrastructure for devices connected via I2C
22  */
23 
24 #include <linux/slab.h>
25 #include "via_aux.h"
26 
27 
29 {
30  struct via_aux_bus *bus;
31 
32  if (!adap)
33  return NULL;
34 
35  bus = kmalloc(sizeof(*bus), GFP_KERNEL);
36  if (!bus)
37  return NULL;
38 
39  bus->adap = adap;
40  INIT_LIST_HEAD(&bus->drivers);
41 
42  via_aux_edid_probe(bus);
51 
52  return bus;
53 }
54 
56 {
57  struct via_aux_drv *pos, *n;
58 
59  if (!bus)
60  return;
61 
62  list_for_each_entry_safe(pos, n, &bus->drivers, chain) {
63  if (pos->cleanup)
64  pos->cleanup(pos);
65 
66  list_del(&pos->chain);
67  kfree(pos->data);
68  kfree(pos);
69  }
70 
71  kfree(bus);
72 }
73 
75 {
76  struct via_aux_drv *pos;
77  const struct fb_videomode *mode = NULL;
78 
79  if (!bus)
80  return NULL;
81 
82  list_for_each_entry(pos, &bus->drivers, chain) {
83  if (pos->get_preferred_mode)
84  mode = pos->get_preferred_mode(pos);
85  }
86 
87  return mode;
88 }