Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc9d5033

Browse files
hadessgregkh
authored andcommitted
USB: Make it possible to "subclass" usb_device_driver
The kernel currenly has only 2 usb_device_drivers, one generic one, onethat completely replaces the generic one to make USB devices usable overa network.Use the newly exported generic driver functions when a driver declaresto want them run, in addition to its own code. This makes it possible towrite drivers that extend the generic USB driver.Note that this patch is not enough for another driver to automaticallyget selected.Signed-off-by: Bastien Nocera <hadess@hadess.net>Acked-by: Alan Stern <stern@rowland.harvard.edu>Link:https://lore.kernel.org/r/20191016093933.693-3-hadess@hadess.netSigned-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parentef0f7d1 commitc9d5033

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

‎drivers/usb/core/driver.c‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,16 @@ static int usb_probe_device(struct device *dev)
261261
*/
262262
if (!udriver->supports_autosuspend)
263263
error=usb_autoresume_device(udev);
264+
if (error)
265+
returnerror;
264266

265-
if (!error)
266-
error=udriver->probe(udev);
267+
if (udriver->generic_subclass)
268+
error=usb_generic_driver_probe(udev);
269+
if (error)
270+
returnerror;
271+
272+
error=udriver->probe(udev);
273+
/* TODO: fallback to generic driver in case of error */
267274
returnerror;
268275
}
269276

@@ -273,7 +280,10 @@ static int usb_unbind_device(struct device *dev)
273280
structusb_device*udev=to_usb_device(dev);
274281
structusb_device_driver*udriver=to_usb_device_driver(dev->driver);
275282

276-
udriver->disconnect(udev);
283+
if (udriver->disconnect)
284+
udriver->disconnect(udev);
285+
if (udriver->generic_subclass)
286+
usb_generic_driver_disconnect(udev);
277287
if (!udriver->supports_autosuspend)
278288
usb_autosuspend_device(udev);
279289
return0;
@@ -1149,7 +1159,10 @@ static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
11491159
udev->do_remote_wakeup=0;
11501160
udriver=&usb_generic_driver;
11511161
}
1152-
status=udriver->suspend(udev,msg);
1162+
if (udriver->suspend)
1163+
status=udriver->suspend(udev,msg);
1164+
if (status==0&&udriver->generic_subclass)
1165+
status=usb_generic_driver_suspend(udev,msg);
11531166

11541167
done:
11551168
dev_vdbg(&udev->dev,"%s: status %d\n",__func__,status);
@@ -1181,7 +1194,10 @@ static int usb_resume_device(struct usb_device *udev, pm_message_t msg)
11811194
udev->reset_resume=1;
11821195

11831196
udriver=to_usb_device_driver(udev->dev.driver);
1184-
status=udriver->resume(udev,msg);
1197+
if (udriver->generic_subclass)
1198+
status=usb_generic_driver_resume(udev,msg);
1199+
if (status==0&&udriver->resume)
1200+
status=udriver->resume(udev,msg);
11851201

11861202
done:
11871203
dev_vdbg(&udev->dev,"%s: status %d\n",__func__,status);

‎include/linux/usb.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,9 @@ struct usb_driver {
12281228
* @drvwrap: Driver-model core structure wrapper.
12291229
* @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
12301230
*for devices bound to this driver.
1231+
* @generic_subclass: if set to 1, the generic USB driver's probe, disconnect,
1232+
*resume and suspend functions will be called in addition to the driver's
1233+
*own, so this part of the setup does not need to be replicated.
12311234
*
12321235
* USB drivers must provide all the fields listed above except drvwrap.
12331236
*/
@@ -1242,6 +1245,7 @@ struct usb_device_driver {
12421245
conststructattribute_group**dev_groups;
12431246
structusbdrv_wrapdrvwrap;
12441247
unsignedintsupports_autosuspend:1;
1248+
unsignedintgeneric_subclass:1;
12451249
};
12461250
#defineto_usb_device_driver(d) container_of(d, struct usb_device_driver, \
12471251
drvwrap.driver)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp