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
Kirill Smelkov
linux
Commits
32619107
Commit
32619107
authored
Aug 14, 2003
by
Greg Kroah-Hartman
Committed by
Tom Rini
Aug 14, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
I2C: add adapter and client name files as the driver core no longer provides them.
parent
b1802b51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c
+28
-0
No files found.
drivers/i2c/i2c-core.c
View file @
32619107
...
@@ -79,12 +79,36 @@ static struct class i2c_adapter_class = {
...
@@ -79,12 +79,36 @@ static struct class i2c_adapter_class = {
.
release
=
&
i2c_adapter_class_dev_release
,
.
release
=
&
i2c_adapter_class_dev_release
,
};
};
static
ssize_t
show_adapter_name
(
struct
device
*
dev
,
char
*
buf
)
{
struct
i2c_adapter
*
adap
=
dev_to_i2c_adapter
(
dev
);
return
sprintf
(
buf
,
"%s
\n
"
,
adap
->
name
);
}
static
DEVICE_ATTR
(
name
,
S_IRUGO
,
show_adapter_name
,
NULL
);
static
void
i2c_client_release
(
struct
device
*
dev
)
static
void
i2c_client_release
(
struct
device
*
dev
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
complete
(
&
client
->
released
);
complete
(
&
client
->
released
);
}
}
static
ssize_t
show_client_name
(
struct
device
*
dev
,
char
*
buf
)
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
return
sprintf
(
buf
,
"%s
\n
"
,
client
->
name
);
}
/*
* We can't use the DEVICE_ATTR() macro here as we want the same filename for a
* different type of a device. So beware if the DEVICE_ATTR() macro ever
* changes, this definition will also have to change.
*/
static
struct
device_attribute
dev_attr_client_name
=
{
.
attr
=
{.
name
=
"name"
,
.
mode
=
S_IRUGO
,
.
owner
=
THIS_MODULE
},
.
show
=
&
show_client_name
,
};
/* ---------------------------------------------------
/* ---------------------------------------------------
* registering functions
* registering functions
...
@@ -120,6 +144,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
...
@@ -120,6 +144,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
adap
->
dev
.
driver
=
&
i2c_adapter_driver
;
adap
->
dev
.
driver
=
&
i2c_adapter_driver
;
adap
->
dev
.
release
=
&
i2c_adapter_dev_release
;
adap
->
dev
.
release
=
&
i2c_adapter_dev_release
;
device_register
(
&
adap
->
dev
);
device_register
(
&
adap
->
dev
);
device_create_file
(
&
adap
->
dev
,
&
dev_attr_name
);
/* Add this adapter to the i2c_adapter class */
/* Add this adapter to the i2c_adapter class */
memset
(
&
adap
->
class_dev
,
0x00
,
sizeof
(
struct
class_device
));
memset
(
&
adap
->
class_dev
,
0x00
,
sizeof
(
struct
class_device
));
...
@@ -184,6 +209,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
...
@@ -184,6 +209,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
init_completion
(
&
adap
->
dev_released
);
init_completion
(
&
adap
->
dev_released
);
init_completion
(
&
adap
->
class_dev_released
);
init_completion
(
&
adap
->
class_dev_released
);
class_device_unregister
(
&
adap
->
class_dev
);
class_device_unregister
(
&
adap
->
class_dev
);
device_remove_file
(
&
adap
->
dev
,
&
dev_attr_name
);
device_unregister
(
&
adap
->
dev
);
device_unregister
(
&
adap
->
dev
);
list_del
(
&
adap
->
list
);
list_del
(
&
adap
->
list
);
...
@@ -361,6 +387,7 @@ int i2c_attach_client(struct i2c_client *client)
...
@@ -361,6 +387,7 @@ int i2c_attach_client(struct i2c_client *client)
"%d-%04x"
,
i2c_adapter_id
(
adapter
),
client
->
addr
);
"%d-%04x"
,
i2c_adapter_id
(
adapter
),
client
->
addr
);
printk
(
"registering %s
\n
"
,
client
->
dev
.
bus_id
);
printk
(
"registering %s
\n
"
,
client
->
dev
.
bus_id
);
device_register
(
&
client
->
dev
);
device_register
(
&
client
->
dev
);
device_create_file
(
&
client
->
dev
,
&
dev_attr_client_name
);
return
0
;
return
0
;
}
}
...
@@ -387,6 +414,7 @@ int i2c_detach_client(struct i2c_client *client)
...
@@ -387,6 +414,7 @@ int i2c_detach_client(struct i2c_client *client)
down
(
&
adapter
->
clist_lock
);
down
(
&
adapter
->
clist_lock
);
list_del
(
&
client
->
list
);
list_del
(
&
client
->
list
);
init_completion
(
&
client
->
released
);
init_completion
(
&
client
->
released
);
device_remove_file
(
&
client
->
dev
,
&
dev_attr_client_name
);
device_unregister
(
&
client
->
dev
);
device_unregister
(
&
client
->
dev
);
up
(
&
adapter
->
clist_lock
);
up
(
&
adapter
->
clist_lock
);
wait_for_completion
(
&
client
->
released
);
wait_for_completion
(
&
client
->
released
);
...
...
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