aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2011-07-25 11:49:43 -0400
committerJean Delvare <khali@endymion.delvare>2011-07-25 11:49:43 -0400
commit488bf314bf219c66922305a1a320950efa86662f (patch)
tree84337cff8d57af18311129495f7cac4979845c55 /drivers/i2c/i2c-core.c
parent3fea5df41df685de53aa985678ad7a9b2d6b3bb5 (diff)
i2c: Allow i2c_add_numbered_adapter() to assign a bus id
Currently, if an i2c bus driver supports both static and dynamic bus ids, it needs to choose between calling i2c_add_numbered_adapter() and i2c_add_adapter(). This patch makes i2c_add_numbered_adapter() redirect to i2c_add_adapter() if the requested bus id is -1. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 9a58994ff7ea..131079a3e292 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -925,6 +925,9 @@ EXPORT_SYMBOL(i2c_add_adapter);
925 * or otherwise built in to the system's mainboard, and where i2c_board_info 925 * or otherwise built in to the system's mainboard, and where i2c_board_info
926 * is used to properly configure I2C devices. 926 * is used to properly configure I2C devices.
927 * 927 *
928 * If the requested bus number is set to -1, then this function will behave
929 * identically to i2c_add_adapter, and will dynamically assign a bus number.
930 *
928 * If no devices have pre-been declared for this bus, then be sure to 931 * If no devices have pre-been declared for this bus, then be sure to
929 * register the adapter before any dynamically allocated ones. Otherwise 932 * register the adapter before any dynamically allocated ones. Otherwise
930 * the required bus ID may not be available. 933 * the required bus ID may not be available.
@@ -940,6 +943,8 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap)
940 int id; 943 int id;
941 int status; 944 int status;
942 945
946 if (adap->nr == -1) /* -1 means dynamically assign bus id */
947 return i2c_add_adapter(adap);
943 if (adap->nr & ~MAX_ID_MASK) 948 if (adap->nr & ~MAX_ID_MASK)
944 return -EINVAL; 949 return -EINVAL;
945 950