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
564dd8f4
Commit
564dd8f4
authored
Sep 26, 2002
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converted PCI to use the driver core's hotplug call.
parent
fddb48b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
45 deletions
+64
-45
drivers/pci/hotplug.c
drivers/pci/hotplug.c
+55
-43
drivers/pci/pci-driver.c
drivers/pci/pci-driver.c
+4
-2
drivers/pci/pci.h
drivers/pci/pci.h
+5
-0
No files found.
drivers/pci/hotplug.c
View file @
564dd8f4
#include <linux/pci.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/module.h>
#include
<linux/kmod.h>
/* for hotplug_path */
#include
"pci.h"
#ifndef FALSE
#define FALSE (0)
#define TRUE (!FALSE)
#endif
#ifdef CONFIG_HOTPLUG
#ifdef CONFIG_HOTPLUG
static
void
run_sbin_hotplug
(
struct
pci_dev
*
pdev
,
int
insert
)
int
pci_hotplug
(
struct
device
*
dev
,
char
**
envp
,
int
num_envp
,
char
*
buffer
,
int
buffer_size
)
{
{
int
i
;
struct
pci_dev
*
pdev
;
char
*
argv
[
3
],
*
envp
[
8
];
char
*
scratch
;
char
id
[
20
],
sub_id
[
24
],
bus_id
[
24
],
class_id
[
20
];
int
i
=
0
;
int
length
=
0
;
if
(
!
hotplug_path
[
0
])
return
;
if
(
!
dev
)
return
-
ENODEV
;
sprintf
(
class_id
,
"PCI_CLASS=%04X"
,
pdev
->
class
);
sprintf
(
id
,
"PCI_ID=%04X:%04X"
,
pdev
->
vendor
,
pdev
->
device
);
pdev
=
to_pci_dev
(
dev
);
sprintf
(
sub_id
,
"PCI_SUBSYS_ID=%04X:%04X"
,
pdev
->
subsystem_vendor
,
pdev
->
subsystem_device
);
if
(
!
pdev
)
sprintf
(
bus_id
,
"PCI_SLOT_NAME=%s"
,
pdev
->
slot_name
);
return
-
ENODEV
;
i
=
0
;
scratch
=
buffer
;
argv
[
i
++
]
=
hotplug_path
;
argv
[
i
++
]
=
"pci"
;
/* stuff we want to pass to /sbin/hotplug */
argv
[
i
]
=
0
;
envp
[
i
++
]
=
scratch
;
length
+=
snprintf
(
scratch
,
buffer_size
-
length
,
"PCI_CLASS=%04X"
,
i
=
0
;
pdev
->
class
);
/* minimal command environment */
if
((
buffer_size
-
length
<=
0
)
||
(
i
>=
num_envp
))
envp
[
i
++
]
=
"HOME=/"
;
return
-
ENOMEM
;
envp
[
i
++
]
=
"PATH=/sbin:/bin:/usr/sbin:/usr/bin"
;
++
length
;
scratch
+=
length
;
/* other stuff we want to pass to /sbin/hotplug */
envp
[
i
++
]
=
class_id
;
envp
[
i
++
]
=
scratch
;
envp
[
i
++
]
=
id
;
length
+=
snprintf
(
scratch
,
buffer_size
-
length
,
"PCI_ID=%04X:%04X"
,
envp
[
i
++
]
=
sub_id
;
pdev
->
vendor
,
pdev
->
device
);
envp
[
i
++
]
=
bus_id
;
if
((
buffer_size
-
length
<=
0
)
||
(
i
>=
num_envp
))
if
(
insert
)
return
-
ENOMEM
;
envp
[
i
++
]
=
"ACTION=add"
;
++
length
;
else
scratch
+=
length
;
envp
[
i
++
]
=
"ACTION=remove"
;
envp
[
i
++
]
=
scratch
;
length
+=
snprintf
(
scratch
,
buffer_size
-
length
,
"PCI_SUBSYS_ID=%04X:%04X"
,
pdev
->
subsystem_vendor
,
pdev
->
subsystem_device
);
if
((
buffer_size
-
length
<=
0
)
||
(
i
>=
num_envp
))
return
-
ENOMEM
;
++
length
;
scratch
+=
length
;
envp
[
i
++
]
=
scratch
;
length
+=
snprintf
(
scratch
,
buffer_size
-
length
,
"PCI_SLOT_NAME=%s"
,
pdev
->
slot_name
);
if
((
buffer_size
-
length
<=
0
)
||
(
i
>=
num_envp
))
return
-
ENOMEM
;
envp
[
i
]
=
0
;
envp
[
i
]
=
0
;
call_usermodehelper
(
argv
[
0
],
argv
,
envp
)
;
return
0
;
}
}
#else
#else
static
void
run_sbin_hotplug
(
struct
pci_dev
*
pdev
,
int
insert
)
{
}
int
pci_hotplug
(
struct
device
*
dev
,
char
**
envp
,
int
num_envp
,
char
*
buffer
,
int
buffer_size
)
{
return
-
ENODEV
;
}
#endif
#endif
/**
/**
...
@@ -66,8 +82,6 @@ pci_insert_device(struct pci_dev *dev, struct pci_bus *bus)
...
@@ -66,8 +82,6 @@ pci_insert_device(struct pci_dev *dev, struct pci_bus *bus)
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
pci_proc_attach_device
(
dev
);
pci_proc_attach_device
(
dev
);
#endif
#endif
/* notify userspace of new hotplug device */
run_sbin_hotplug
(
dev
,
TRUE
);
}
}
static
void
static
void
...
@@ -99,8 +113,6 @@ pci_remove_device(struct pci_dev *dev)
...
@@ -99,8 +113,6 @@ pci_remove_device(struct pci_dev *dev)
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
pci_proc_detach_device
(
dev
);
pci_proc_detach_device
(
dev
);
#endif
#endif
/* notify userspace of hotplug device removal */
run_sbin_hotplug
(
dev
,
FALSE
);
}
}
#ifdef CONFIG_HOTPLUG
#ifdef CONFIG_HOTPLUG
...
...
drivers/pci/pci-driver.c
View file @
564dd8f4
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include <linux/pci.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/init.h>
#include "pci.h"
/*
/*
* Registration of PCI drivers and handling of hot-pluggable devices.
* Registration of PCI drivers and handling of hot-pluggable devices.
...
@@ -201,6 +202,7 @@ static int pci_bus_match(struct device * dev, struct device_driver * drv)
...
@@ -201,6 +202,7 @@ static int pci_bus_match(struct device * dev, struct device_driver * drv)
struct
bus_type
pci_bus_type
=
{
struct
bus_type
pci_bus_type
=
{
name:
"pci"
,
name:
"pci"
,
match:
pci_bus_match
,
match:
pci_bus_match
,
hotplug:
pci_hotplug
,
};
};
static
int
__init
pci_driver_init
(
void
)
static
int
__init
pci_driver_init
(
void
)
...
...
drivers/pci/pci.h
0 → 100644
View file @
564dd8f4
/* Functions internal to the PCI core code */
extern
int
pci_hotplug
(
struct
device
*
dev
,
char
**
envp
,
int
num_envp
,
char
*
buffer
,
int
buffer_size
);
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