-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 53248 b: refs/heads/master c: 9c1600e h: refs/heads/master v: v3
- Loading branch information
David Brownell
authored and
Jean Delvare
committed
May 1, 2007
1 parent
2f024ad
commit 991b7d4
Showing
8 changed files
with
277 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 4298cfc3eb6110df989f784be516c6340c597a66 | ||
refs/heads/master: 9c1600eda42e52796f49b36cf15b9debcfd09bea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* i2c-boardinfo.h - collect pre-declarations of I2C devices | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/i2c.h> | ||
|
||
#include "i2c-core.h" | ||
|
||
|
||
/* These symbols are exported ONLY FOR the i2c core. | ||
* No other users will be supported. | ||
*/ | ||
DEFINE_MUTEX(__i2c_board_lock); | ||
EXPORT_SYMBOL_GPL(__i2c_board_lock); | ||
|
||
LIST_HEAD(__i2c_board_list); | ||
EXPORT_SYMBOL_GPL(__i2c_board_list); | ||
|
||
int __i2c_first_dynamic_bus_num; | ||
EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num); | ||
|
||
|
||
/** | ||
* i2c_register_board_info - statically declare I2C devices | ||
* @busnum: identifies the bus to which these devices belong | ||
* @info: vector of i2c device descriptors | ||
* @len: how many descriptors in the vector; may be zero to reserve | ||
* the specified bus number. | ||
* | ||
* Systems using the Linux I2C driver stack can declare tables of board info | ||
* while they initialize. This should be done in board-specific init code | ||
* near arch_initcall() time, or equivalent, before any I2C adapter driver is | ||
* registered. For example, mainboard init code could define several devices, | ||
* as could the init code for each daughtercard in a board stack. | ||
* | ||
* The I2C devices will be created later, after the adapter for the relevant | ||
* bus has been registered. After that moment, standard driver model tools | ||
* are used to bind "new style" I2C drivers to the devices. The bus number | ||
* for any device declared using this routine is not available for dynamic | ||
* allocation. | ||
* | ||
* The board info passed can safely be __initdata, but be careful of embedded | ||
* pointers (for platform_data, functions, etc) since that won't be copied. | ||
*/ | ||
int __init | ||
i2c_register_board_info(int busnum, | ||
struct i2c_board_info const *info, unsigned len) | ||
{ | ||
int status; | ||
|
||
mutex_lock(&__i2c_board_lock); | ||
|
||
/* dynamic bus numbers will be assigned after the last static one */ | ||
if (busnum >= __i2c_first_dynamic_bus_num) | ||
__i2c_first_dynamic_bus_num = busnum + 1; | ||
|
||
for (status = 0; len; len--, info++) { | ||
struct i2c_devinfo *devinfo; | ||
|
||
devinfo = kzalloc(sizeof(*devinfo), GFP_KERNEL); | ||
if (!devinfo) { | ||
pr_debug("i2c-core: can't register boardinfo!\n"); | ||
status = -ENOMEM; | ||
break; | ||
} | ||
|
||
devinfo->busnum = busnum; | ||
devinfo->board_info = *info; | ||
list_add_tail(&devinfo->list, &__i2c_board_list); | ||
} | ||
|
||
mutex_unlock(&__i2c_board_lock); | ||
|
||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* i2c-core.h - interfaces internal to the I2C framework | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
struct i2c_devinfo { | ||
struct list_head list; | ||
int busnum; | ||
struct i2c_board_info board_info; | ||
}; | ||
|
||
/* board_lock protects board_list and first_dynamic_bus_num. | ||
* only i2c core components are allowed to use these symbols. | ||
*/ | ||
extern struct mutex __i2c_board_lock; | ||
extern struct list_head __i2c_board_list; | ||
extern int __i2c_first_dynamic_bus_num; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters