Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
66d20816
Commit
66d20816
authored
May 18, 2004
by
Faik Uygur
Committed by
Greg Kroah-Hartman
May 18, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] I2C: use idr_get_new to allocate a bus id in drivers/i2c/i2c-core.c
parent
1487e210
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c
+17
-4
No files found.
drivers/i2c/i2c-core.c
View file @
66d20816
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/idr.h>
#include <linux/seq_file.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
...
@@ -35,6 +36,7 @@
...
@@ -35,6 +36,7 @@
static
LIST_HEAD
(
adapters
);
static
LIST_HEAD
(
adapters
);
static
LIST_HEAD
(
drivers
);
static
LIST_HEAD
(
drivers
);
static
DECLARE_MUTEX
(
core_lists
);
static
DECLARE_MUTEX
(
core_lists
);
static
DEFINE_IDR
(
i2c_adapter_idr
);
int
i2c_device_probe
(
struct
device
*
dev
)
int
i2c_device_probe
(
struct
device
*
dev
)
{
{
...
@@ -113,13 +115,19 @@ static struct device_attribute dev_attr_client_name = {
...
@@ -113,13 +115,19 @@ static struct device_attribute dev_attr_client_name = {
*/
*/
int
i2c_add_adapter
(
struct
i2c_adapter
*
adap
)
int
i2c_add_adapter
(
struct
i2c_adapter
*
adap
)
{
{
static
int
nr
=
0
;
int
id
,
res
=
0
;
struct
list_head
*
item
;
struct
list_head
*
item
;
struct
i2c_driver
*
driver
;
struct
i2c_driver
*
driver
;
down
(
&
core_lists
);
down
(
&
core_lists
);
adap
->
nr
=
nr
++
;
if
(
idr_pre_get
(
&
i2c_adapter_idr
,
GFP_KERNEL
)
==
0
)
{
res
=
-
ENOMEM
;
goto
out_unlock
;
}
id
=
idr_get_new
(
&
i2c_adapter_idr
,
NULL
);
adap
->
nr
=
id
&
MAX_ID_MASK
;
init_MUTEX
(
&
adap
->
bus_lock
);
init_MUTEX
(
&
adap
->
bus_lock
);
init_MUTEX
(
&
adap
->
clist_lock
);
init_MUTEX
(
&
adap
->
clist_lock
);
list_add_tail
(
&
adap
->
list
,
&
adapters
);
list_add_tail
(
&
adap
->
list
,
&
adapters
);
...
@@ -151,10 +159,12 @@ int i2c_add_adapter(struct i2c_adapter *adap)
...
@@ -151,10 +159,12 @@ int i2c_add_adapter(struct i2c_adapter *adap)
/* We ignore the return code; if it fails, too bad */
/* We ignore the return code; if it fails, too bad */
driver
->
attach_adapter
(
adap
);
driver
->
attach_adapter
(
adap
);
}
}
up
(
&
core_lists
);
dev_dbg
(
&
adap
->
dev
,
"registered as adapter #%d
\n
"
,
adap
->
nr
);
dev_dbg
(
&
adap
->
dev
,
"registered as adapter #%d
\n
"
,
adap
->
nr
);
return
0
;
out_unlock:
up
(
&
core_lists
);
return
res
;
}
}
...
@@ -208,6 +218,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
...
@@ -208,6 +218,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
wait_for_completion
(
&
adap
->
dev_released
);
wait_for_completion
(
&
adap
->
dev_released
);
wait_for_completion
(
&
adap
->
class_dev_released
);
wait_for_completion
(
&
adap
->
class_dev_released
);
/* free dynamically allocated bus id */
idr_remove
(
&
i2c_adapter_idr
,
adap
->
nr
);
dev_dbg
(
&
adap
->
dev
,
"adapter unregistered
\n
"
);
dev_dbg
(
&
adap
->
dev
,
"adapter unregistered
\n
"
);
out_unlock:
out_unlock:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment