diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2005-08-18 00:33:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-09 14:24:19 -0400 |
commit | 7bcf5c0e7fd9ab4ddb9e24d7e91bda2ac23e5678 (patch) | |
tree | 56c4e59dd09f2db0845b5851cffbf579cc86ff05 /drivers/pci | |
parent | 2fd9d74b35efa9823f1f7d34cb421e2b9eee9650 (diff) |
[PATCH] PCI: move pci core to use add_hotplug_env_var()
This fixes a bug in the environment variables for all PCI device hotplug calls.
Thanks to Kay Sievers for pointing out the problem.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug.c | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c index b844bc972324..10444988a10b 100644 --- a/drivers/pci/hotplug.c +++ b/drivers/pci/hotplug.c | |||
@@ -20,46 +20,35 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, | |||
20 | 20 | ||
21 | scratch = buffer; | 21 | scratch = buffer; |
22 | 22 | ||
23 | /* stuff we want to pass to /sbin/hotplug */ | 23 | |
24 | envp[i++] = scratch; | 24 | if (add_hotplug_env_var(envp, num_envp, &i, |
25 | length += scnprintf (scratch, buffer_size - length, "PCI_CLASS=%04X", | 25 | buffer, buffer_size, &length, |
26 | pdev->class); | 26 | "PCI_CLASS=%04X", pdev->class)) |
27 | if ((buffer_size - length <= 0) || (i >= num_envp)) | ||
28 | return -ENOMEM; | 27 | return -ENOMEM; |
29 | ++length; | ||
30 | scratch += length; | ||
31 | 28 | ||
32 | envp[i++] = scratch; | 29 | if (add_hotplug_env_var(envp, num_envp, &i, |
33 | length += scnprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X", | 30 | buffer, buffer_size, &length, |
34 | pdev->vendor, pdev->device); | 31 | "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) |
35 | if ((buffer_size - length <= 0) || (i >= num_envp)) | ||
36 | return -ENOMEM; | 32 | return -ENOMEM; |
37 | ++length; | ||
38 | scratch += length; | ||
39 | 33 | ||
40 | envp[i++] = scratch; | 34 | if (add_hotplug_env_var(envp, num_envp, &i, |
41 | length += scnprintf (scratch, buffer_size - length, | 35 | buffer, buffer_size, &length, |
42 | "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, | 36 | "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, |
43 | pdev->subsystem_device); | 37 | pdev->subsystem_device)) |
44 | if ((buffer_size - length <= 0) || (i >= num_envp)) | ||
45 | return -ENOMEM; | 38 | return -ENOMEM; |
46 | ++length; | ||
47 | scratch += length; | ||
48 | 39 | ||
49 | envp[i++] = scratch; | 40 | if (add_hotplug_env_var(envp, num_envp, &i, |
50 | length += scnprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s", | 41 | buffer, buffer_size, &length, |
51 | pci_name(pdev)); | 42 | "PCI_SLOT_NAME=%s", pci_name(pdev))) |
52 | if ((buffer_size - length <= 0) || (i >= num_envp)) | ||
53 | return -ENOMEM; | 43 | return -ENOMEM; |
54 | 44 | ||
55 | envp[i++] = scratch; | 45 | if (add_hotplug_env_var(envp, num_envp, &i, |
56 | length += scnprintf (scratch, buffer_size - length, | 46 | buffer, buffer_size, &length, |
57 | "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", | 47 | "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", |
58 | pdev->vendor, pdev->device, | 48 | pdev->vendor, pdev->device, |
59 | pdev->subsystem_vendor, pdev->subsystem_device, | 49 | pdev->subsystem_vendor, pdev->subsystem_device, |
60 | (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), | 50 | (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), |
61 | (u8)(pdev->class)); | 51 | (u8)(pdev->class))) |
62 | if ((buffer_size - length <= 0) || (i >= num_envp)) | ||
63 | return -ENOMEM; | 52 | return -ENOMEM; |
64 | 53 | ||
65 | envp[i] = NULL; | 54 | envp[i] = NULL; |