diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 23:58:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 23:58:09 -0500 |
commit | 2a7d2b96d5cba7568139d9ab157a0e97ab32440f (patch) | |
tree | ad029d8cc7b7068b7250e914360ec6315fdfa114 /drivers/i2c/i2c-core.c | |
parent | e3c4877de8b9d93bd47b6ee88eb594b1c1e10da5 (diff) | |
parent | b67bfe0d42cac56c512dd5da4b1b347a23f4b70a (diff) |
Merge branch 'akpm' (final batch from Andrew)
Merge third patch-bumb from Andrew Morton:
"This wraps me up for -rc1.
- Lots of misc stuff and things which were deferred/missed from
patchbombings 1 & 2.
- ocfs2 things
- lib/scatterlist
- hfsplus
- fatfs
- documentation
- signals
- procfs
- lockdep
- coredump
- seqfile core
- kexec
- Tejun's large IDR tree reworkings
- ipmi
- partitions
- nbd
- random() things
- kfifo
- tools/testing/selftests updates
- Sasha's large and pointless hlist cleanup"
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (163 commits)
hlist: drop the node parameter from iterators
kcmp: make it depend on CHECKPOINT_RESTORE
selftests: add a simple doc
tools/testing/selftests/Makefile: rearrange targets
selftests/efivarfs: add create-read test
selftests/efivarfs: add empty file creation test
selftests: add tests for efivarfs
kfifo: fix kfifo_alloc() and kfifo_init()
kfifo: move kfifo.c from kernel/ to lib/
arch Kconfig: centralise CONFIG_ARCH_NO_VIRT_TO_BUS
w1: add support for DS2413 Dual Channel Addressable Switch
memstick: move the dereference below the NULL test
drivers/pps/clients/pps-gpio.c: use devm_kzalloc
Documentation/DMA-API-HOWTO.txt: fix typo
include/linux/eventfd.h: fix incorrect filename is a comment
mtd: mtd_stresstest: use prandom_bytes()
mtd: mtd_subpagetest: convert to use prandom library
mtd: mtd_speedtest: use prandom_bytes
mtd: mtd_pagetest: convert to use prandom library
mtd: mtd_oobtest: convert to use prandom library
...
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 66a30f7ac882..991d38daa87d 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -935,25 +935,17 @@ out_list: | |||
935 | */ | 935 | */ |
936 | int i2c_add_adapter(struct i2c_adapter *adapter) | 936 | int i2c_add_adapter(struct i2c_adapter *adapter) |
937 | { | 937 | { |
938 | int id, res = 0; | 938 | int id; |
939 | |||
940 | retry: | ||
941 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) | ||
942 | return -ENOMEM; | ||
943 | 939 | ||
944 | mutex_lock(&core_lock); | 940 | mutex_lock(&core_lock); |
945 | /* "above" here means "above or equal to", sigh */ | 941 | id = idr_alloc(&i2c_adapter_idr, adapter, |
946 | res = idr_get_new_above(&i2c_adapter_idr, adapter, | 942 | __i2c_first_dynamic_bus_num, 0, GFP_KERNEL); |
947 | __i2c_first_dynamic_bus_num, &id); | ||
948 | mutex_unlock(&core_lock); | 943 | mutex_unlock(&core_lock); |
949 | 944 | if (id < 0) | |
950 | if (res < 0) { | 945 | return id; |
951 | if (res == -EAGAIN) | ||
952 | goto retry; | ||
953 | return res; | ||
954 | } | ||
955 | 946 | ||
956 | adapter->nr = id; | 947 | adapter->nr = id; |
948 | |||
957 | return i2c_register_adapter(adapter); | 949 | return i2c_register_adapter(adapter); |
958 | } | 950 | } |
959 | EXPORT_SYMBOL(i2c_add_adapter); | 951 | EXPORT_SYMBOL(i2c_add_adapter); |
@@ -984,33 +976,17 @@ EXPORT_SYMBOL(i2c_add_adapter); | |||
984 | int i2c_add_numbered_adapter(struct i2c_adapter *adap) | 976 | int i2c_add_numbered_adapter(struct i2c_adapter *adap) |
985 | { | 977 | { |
986 | int id; | 978 | int id; |
987 | int status; | ||
988 | 979 | ||
989 | if (adap->nr == -1) /* -1 means dynamically assign bus id */ | 980 | if (adap->nr == -1) /* -1 means dynamically assign bus id */ |
990 | return i2c_add_adapter(adap); | 981 | return i2c_add_adapter(adap); |
991 | if (adap->nr & ~MAX_IDR_MASK) | ||
992 | return -EINVAL; | ||
993 | |||
994 | retry: | ||
995 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) | ||
996 | return -ENOMEM; | ||
997 | 982 | ||
998 | mutex_lock(&core_lock); | 983 | mutex_lock(&core_lock); |
999 | /* "above" here means "above or equal to", sigh; | 984 | id = idr_alloc(&i2c_adapter_idr, adap, adap->nr, adap->nr + 1, |
1000 | * we need the "equal to" result to force the result | 985 | GFP_KERNEL); |
1001 | */ | ||
1002 | status = idr_get_new_above(&i2c_adapter_idr, adap, adap->nr, &id); | ||
1003 | if (status == 0 && id != adap->nr) { | ||
1004 | status = -EBUSY; | ||
1005 | idr_remove(&i2c_adapter_idr, id); | ||
1006 | } | ||
1007 | mutex_unlock(&core_lock); | 986 | mutex_unlock(&core_lock); |
1008 | if (status == -EAGAIN) | 987 | if (id < 0) |
1009 | goto retry; | 988 | return id == -ENOSPC ? -EBUSY : id; |
1010 | 989 | return i2c_register_adapter(adap); | |
1011 | if (status == 0) | ||
1012 | status = i2c_register_adapter(adap); | ||
1013 | return status; | ||
1014 | } | 990 | } |
1015 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); | 991 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); |
1016 | 992 | ||