aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-29 10:27:34 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-12-06 19:05:50 -0500
commite3f02c5228c4b600abf6ca243301176f25553bd5 (patch)
treea3b5372f137fb8396ffe036e4c0c3cabea06b838 /drivers/usb
parent9c5ad36d987a1b06f6b0b9dc7bc61a45d277455d (diff)
ACPI / bind: Rework struct acpi_bus_type
Replace the .find_device function pointer in struct acpi_bus_type with a new one, .find_companion, that is supposed to point to a function returning struct acpi_device pointer (instead of an int) and takes one argument (instead of two). This way the role of this callback is more clear and the implementation of it can be more straightforward. Update all of the users of struct acpi_bus_type (PCI, PNP/ACPI and USB) to reflect the structure change. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Lan Tianyu <tianyu.lan@intel.com> # for USB/ACPI
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/usb-acpi.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 11c656976cb5..f0155a39aaa3 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -126,7 +126,7 @@ out:
126 return ret; 126 return ret;
127} 127}
128 128
129static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) 129static struct acpi_device *usb_acpi_find_companion(struct device *dev)
130{ 130{
131 struct usb_device *udev; 131 struct usb_device *udev;
132 acpi_handle *parent_handle; 132 acpi_handle *parent_handle;
@@ -168,16 +168,15 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
168 break; 168 break;
169 } 169 }
170 170
171 return -ENODEV; 171 return NULL;
172 } 172 }
173 173
174 /* root hub's parent is the usb hcd. */ 174 /* root hub's parent is the usb hcd. */
175 parent_handle = ACPI_HANDLE(dev->parent); 175 return acpi_find_child_device(ACPI_COMPANION(dev->parent),
176 *handle = acpi_get_child(parent_handle, udev->portnum); 176 udev->portnum, false);
177 if (!*handle)
178 return -ENODEV;
179 return 0;
180 } else if (is_usb_port(dev)) { 177 } else if (is_usb_port(dev)) {
178 struct acpi_device *adev = NULL;
179
181 sscanf(dev_name(dev), "port%d", &port_num); 180 sscanf(dev_name(dev), "port%d", &port_num);
182 /* Get the struct usb_device point of port's hub */ 181 /* Get the struct usb_device point of port's hub */
183 udev = to_usb_device(dev->parent->parent); 182 udev = to_usb_device(dev->parent->parent);
@@ -193,26 +192,27 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
193 192
194 raw_port_num = usb_hcd_find_raw_port_number(hcd, 193 raw_port_num = usb_hcd_find_raw_port_number(hcd,
195 port_num); 194 port_num);
196 *handle = acpi_get_child(ACPI_HANDLE(&udev->dev), 195 adev = acpi_find_child_device(ACPI_COMPANION(&udev->dev),
197 raw_port_num); 196 raw_port_num, false);
198 if (!*handle) 197 if (!adev)
199 return -ENODEV; 198 return NULL;
200 } else { 199 } else {
201 parent_handle = 200 parent_handle =
202 usb_get_hub_port_acpi_handle(udev->parent, 201 usb_get_hub_port_acpi_handle(udev->parent,
203 udev->portnum); 202 udev->portnum);
204 if (!parent_handle) 203 if (!parent_handle)
205 return -ENODEV; 204 return NULL;
206 205
207 *handle = acpi_get_child(parent_handle, port_num); 206 acpi_bus_get_device(parent_handle, &adev);
208 if (!*handle) 207 adev = acpi_find_child_device(adev, port_num, false);
209 return -ENODEV; 208 if (!adev)
209 return NULL;
210 } 210 }
211 usb_acpi_check_port_connect_type(udev, *handle, port_num); 211 usb_acpi_check_port_connect_type(udev, adev->handle, port_num);
212 } else 212 return adev;
213 return -ENODEV; 213 }
214 214
215 return 0; 215 return NULL;
216} 216}
217 217
218static bool usb_acpi_bus_match(struct device *dev) 218static bool usb_acpi_bus_match(struct device *dev)
@@ -223,7 +223,7 @@ static bool usb_acpi_bus_match(struct device *dev)
223static struct acpi_bus_type usb_acpi_bus = { 223static struct acpi_bus_type usb_acpi_bus = {
224 .name = "USB", 224 .name = "USB",
225 .match = usb_acpi_bus_match, 225 .match = usb_acpi_bus_match,
226 .find_device = usb_acpi_find_device, 226 .find_companion = usb_acpi_find_companion,
227}; 227};
228 228
229int usb_acpi_register(void) 229int usb_acpi_register(void)