* [RFC] usb: r8152: interface driver before device driver
@ 2024-01-04 10:37 Oliver Neukum
2024-01-04 10:44 ` Greg KH
2024-01-04 12:00 ` Bjørn Mork
0 siblings, 2 replies; 4+ messages in thread
From: Oliver Neukum @ 2024-01-04 10:37 UTC (permalink / raw)
To: bjorn, linux-usb; +Cc: Oliver Neukum
The r8152 interface driver is preferred over the generic
class driver because it provides more features. Hence
we now have a device driver that switches the configuration.
That device driver is sensible only if an interface driver
for the selected configuration exists.
However, the initialization for this module first reisters
the device driver and after that the interface driver.
That screws up error handling. Both registrations return
error codes. That means that the registration of the
device driver can currently work, but the interface
driver can fail.
In that case we switch the devices to a configuration
we have no driver for. That must not happen. The easiest
fix is to register the interface driver first and
bail out if that fails. That way if the device driver
fails, nothing needs to be undone.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
---
drivers/net/usb/r8152.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 9bf2140fd0a1..e856ef83cef0 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -10117,10 +10117,13 @@ static int __init rtl8152_driver_init(void)
{
int ret;
- ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
+ ret = usb_register(&rtl8152_driver);
if (ret)
return ret;
- return usb_register(&rtl8152_driver);
+
+ ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
+ return ret;
+
}
static void __exit rtl8152_driver_exit(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [RFC] usb: r8152: interface driver before device driver 2024-01-04 10:37 [RFC] usb: r8152: interface driver before device driver Oliver Neukum @ 2024-01-04 10:44 ` Greg KH 2024-01-04 12:00 ` Bjørn Mork 1 sibling, 0 replies; 4+ messages in thread From: Greg KH @ 2024-01-04 10:44 UTC (permalink / raw) To: Oliver Neukum; +Cc: bjorn, linux-usb On Thu, Jan 04, 2024 at 11:37:59AM +0100, Oliver Neukum wrote: > The r8152 interface driver is preferred over the generic > class driver because it provides more features. Hence > we now have a device driver that switches the configuration. > > That device driver is sensible only if an interface driver > for the selected configuration exists. > However, the initialization for this module first reisters > the device driver and after that the interface driver. > That screws up error handling. Both registrations return > error codes. That means that the registration of the > device driver can currently work, but the interface > driver can fail. > In that case we switch the devices to a configuration > we have no driver for. That must not happen. The easiest > fix is to register the interface driver first and > bail out if that fails. That way if the device driver > fails, nothing needs to be undone. > > Signed-off-by: Oliver Neukum <oneukum@suse.com> > Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection") > --- > drivers/net/usb/r8152.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c > index 9bf2140fd0a1..e856ef83cef0 100644 > --- a/drivers/net/usb/r8152.c > +++ b/drivers/net/usb/r8152.c > @@ -10117,10 +10117,13 @@ static int __init rtl8152_driver_init(void) > { > int ret; > > - ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE); > + ret = usb_register(&rtl8152_driver); > if (ret) > return ret; > - return usb_register(&rtl8152_driver); > + > + ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE); > + return ret; > + > } > > static void __exit rtl8152_driver_exit(void) > -- > 2.43.0 > > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] usb: r8152: interface driver before device driver 2024-01-04 10:37 [RFC] usb: r8152: interface driver before device driver Oliver Neukum 2024-01-04 10:44 ` Greg KH @ 2024-01-04 12:00 ` Bjørn Mork 2024-01-04 12:18 ` Oliver Neukum 1 sibling, 1 reply; 4+ messages in thread From: Bjørn Mork @ 2024-01-04 12:00 UTC (permalink / raw) To: Oliver Neukum; +Cc: linux-usb Oliver Neukum <oneukum@suse.com> writes: > The r8152 interface driver is preferred over the generic > class driver because it provides more features. Hence > we now have a device driver that switches the configuration. > > That device driver is sensible only if an interface driver > for the selected configuration exists. > However, the initialization for this module first reisters > the device driver and after that the interface driver. > That screws up error handling. Both registrations return > error codes. That means that the registration of the > device driver can currently work, but the interface > driver can fail. > In that case we switch the devices to a configuration > we have no driver for. That must not happen. The easiest > fix is to register the interface driver first and > bail out if that fails. That way if the device driver > fails, nothing needs to be undone. Yup. Switching this around makes sense. > + ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE); > + return ret; > + Why not return usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE); ? Bjørn ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] usb: r8152: interface driver before device driver 2024-01-04 12:00 ` Bjørn Mork @ 2024-01-04 12:18 ` Oliver Neukum 0 siblings, 0 replies; 4+ messages in thread From: Oliver Neukum @ 2024-01-04 12:18 UTC (permalink / raw) To: Bjørn Mork, Oliver Neukum; +Cc: linux-usb On 04.01.24 13:00, Bjørn Mork wrote: > Oliver Neukum <oneukum@suse.com> writes: > Why not > return usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE); > ? To be blunt, I did not want to edit more to get to a marginally shorter, but inconsistent function. Regards Oliver ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-04 12:18 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-01-04 10:37 [RFC] usb: r8152: interface driver before device driver Oliver Neukum 2024-01-04 10:44 ` Greg KH 2024-01-04 12:00 ` Bjørn Mork 2024-01-04 12:18 ` Oliver Neukum
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox