diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-07-13 16:23:51 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-07-13 16:23:51 -0400 |
commit | 327309e899662b482c58cf25f574513d38b5788c (patch) | |
tree | 069de438aa0e92dd9b6ba28e6b207e2cd07151a5 /drivers/i2c/i2c-core.c | |
parent | 0c168775709faa74c1b87f1e61046e0c51ade7f3 (diff) | |
parent | c32511e2718618f0b53479eb36e07439aa363a74 (diff) |
Merge upstream 2.6.13-rc3 into ieee80211 branch of netdev-2.6.
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 51ce268998cd..4fd4f52c8e9b 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -156,7 +156,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
156 | goto out_unlock; | 156 | goto out_unlock; |
157 | } | 157 | } |
158 | 158 | ||
159 | res = idr_get_new(&i2c_adapter_idr, NULL, &id); | 159 | res = idr_get_new(&i2c_adapter_idr, adap, &id); |
160 | if (res < 0) { | 160 | if (res < 0) { |
161 | if (res == -EAGAIN) | 161 | if (res == -EAGAIN) |
162 | res = -ENOMEM; | 162 | res = -ENOMEM; |
@@ -765,20 +765,15 @@ int i2c_adapter_id(struct i2c_adapter *adap) | |||
765 | 765 | ||
766 | struct i2c_adapter* i2c_get_adapter(int id) | 766 | struct i2c_adapter* i2c_get_adapter(int id) |
767 | { | 767 | { |
768 | struct list_head *item; | ||
769 | struct i2c_adapter *adapter; | 768 | struct i2c_adapter *adapter; |
770 | 769 | ||
771 | down(&core_lists); | 770 | down(&core_lists); |
772 | list_for_each(item,&adapters) { | 771 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); |
773 | adapter = list_entry(item, struct i2c_adapter, list); | 772 | if (adapter && !try_module_get(adapter->owner)) |
774 | if (id == adapter->nr && | 773 | adapter = NULL; |
775 | try_module_get(adapter->owner)) { | 774 | |
776 | up(&core_lists); | ||
777 | return adapter; | ||
778 | } | ||
779 | } | ||
780 | up(&core_lists); | 775 | up(&core_lists); |
781 | return NULL; | 776 | return adapter; |
782 | } | 777 | } |
783 | 778 | ||
784 | void i2c_put_adapter(struct i2c_adapter *adap) | 779 | void i2c_put_adapter(struct i2c_adapter *adap) |