Skip to contentSkip to conversation

IR driver for USB-UIRT device

PATCH Superseded Sean Young 4 participants 9 messages Jun 10, 2021 – Jun 18, 2021

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
author maintainer
#6 lore raw

PATCH v4 2/2 USB: serial: blacklist USB-UIRT when driver is selected

In reply to Sean Young

The USB-UIRT device has its own driver, so blacklist the fdti driver from using it if the driver has been enabled.

---
 drivers/usb/serial/ftdi_sio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/serial/ftdi_sio.c +4 -2
index 369ef140df78..2e9a9076a38d 100644
@@ -106,7 +106,7 @@ static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = {
 	.probe	= ftdi_NDI_device_setup,
 };
 
-static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
+static __maybe_unused const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
 	.port_probe = ftdi_USB_UIRT_setup,
 };
 
@@ -568,8 +568,10 @@ static const struct usb_device_id id_table_combined[] = {
 	{ USB_DEVICE(OCT_VID, OCT_DK201_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
+#if !IS_ENABLED(CONFIG_IR_UIRT)
 	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
+#endif
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
@@ -2281,7 +2283,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 /* Setup for the USB-UIRT device, which requires hardwired
  * baudrate (38400 gets mapped to 312500) */
 /* Called from usbserial:serial_probe */
-static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
+static __maybe_unused void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
 {
 	priv->flags |= ASYNC_SPD_CUST;
 	priv->custom_divisor = 77;
Signature · 1 line
2.31.1

Sean Young

author maintainer
#0 lore raw

v4 cover IR driver for USB-UIRT device

This is a new rc-core driver for the USB-UIRT which you can see here
http://www.usbuirt.com/

This device is supported in lirc, via the usb serial kernel driver. This driver is both for rc-core, which means it can use kernel/BPF decoding ec. Also this implement is superior because it can:
- support learning mode
- setting transmit carrier
- larger transmits using streaming tx command

Changes since v3:
- Review comments from Johan Hovold
- Do not move the ftdi_sio.h file an copy FTDI_* definitions instead

Changes since v2:
- Fixed race condition is disconnect
- Removed superfluous kmalloc in short tx

Changes since v1:
- Review comments from Oliver Neukum
- Simplified wideband read function

Sean Young (2):
media: rc: new driver for USB-UIRT device
USB: serial: blacklist USB-UIRT when driver is selected

 drivers/media/rc/Kconfig      |  11 +
 drivers/media/rc/Makefile     |   1 +
 drivers/media/rc/uirt.c       | 740 ++++++++++++++++++++++++++++++++++
 drivers/usb/serial/ftdi_sio.c |   6 +-
 4 files changed, 756 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/rc/uirt.c
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH v4 1/2 media: rc: new driver for USB-UIRT device

This device uses an ftdi usb serial port, so this driver has a tiny amount of usb ftdi code. It would be preferable to connect this driver via serdev or line-discipline, but unfortunately neither support hotplugging yet.

See http://www.usbuirt.com/

---
 drivers/media/rc/Kconfig  |  11 +
 drivers/media/rc/Makefile |   1 +
 drivers/media/rc/uirt.c   | 740 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 752 insertions(+)
 create mode 100644 drivers/media/rc/uirt.c
drivers/media/rc/Kconfig +11 -0
index d0a8326b75c2..cb1a2c65f920 100644
@@ -471,6 +471,17 @@ config IR_TOY
 	   To compile this driver as a module, choose M here: the module will be
 	   called ir_toy.
 
+config IR_UIRT
+	tristate "USB-UIRT"
+	depends on RC_CORE
+	depends on USB_ARCH_HAS_HCD
+	help
+	   Say Y here if you want to use the USB-UIRT. See
+	   http://www.usbuirt.com/
+
+	   To compile this driver as a module, choose M here: the module will be
+	   called uirt.
+
 endif #RC_DEVICES
 
 endif #RC_CORE
drivers/media/rc/Makefile +1 -0
index 692e9b6b203f..068036698747 100644
@@ -50,3 +50,4 @@ obj-$(CONFIG_IR_SIR) += sir_ir.o
 obj-$(CONFIG_IR_MTK) += mtk-cir.o
 obj-$(CONFIG_RC_XBOX_DVD) += xbox_remote.o
 obj-$(CONFIG_IR_TOY) += ir_toy.o
+obj-$(CONFIG_IR_UIRT) += uirt.o
drivers/media/rc/uirt.c new file +740 -0

740 lines not on this page · raw message

Signature · 1 line
2.31.1
#7 lore raw

Re: [PATCH v4 2/2] USB: serial: blacklist USB-UIRT when driver is selected

In reply to Sean Young
Quoted 13 lines · Sean Young

The USB-UIRT device has its own driver, so blacklist the fdti driver from using it if the driver has been enabled.

---
 drivers/usb/serial/ftdi_sio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/serial/ftdi_sio.c +0 -0
index 369ef140df78..2e9a9076a38d 100644

drivers/usb/serial/ftdi_sio.c static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = { · line 109

Quoted 5 lines
drivers/usb/serial/ftdi_sio.c +1 -1
@@ -106,7 +106,7 @@ static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = {
 	.probe	= ftdi_NDI_device_setup,
 };
 
-static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
+static __maybe_unused const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {

Why make this change?

Quoted 15 lines
drivers/usb/serial/ftdi_sio.c +2 -0
 	.port_probe = ftdi_USB_UIRT_setup,
 };
 
@@ -568,8 +568,10 @@ static const struct usb_device_id id_table_combined[] = {
 	{ USB_DEVICE(OCT_VID, OCT_DK201_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
+#if !IS_ENABLED(CONFIG_IR_UIRT)
 	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
+#endif
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },

drivers/usb/serial/ftdi_sio.c static int ftdi_sio_port_probe(struct usb_serial_port *port) · line 2286

Quoted 5 lines
drivers/usb/serial/ftdi_sio.c +1 -1
@@ -2281,7 +2283,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 /* Setup for the USB-UIRT device, which requires hardwired
  * baudrate (38400 gets mapped to 312500) */
 /* Called from usbserial:serial_probe */
-static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
+static __maybe_unused void ftdi_USB_UIRT_setup(struct ftdi_private *priv)

Again, why this change here?

thanks,

greg k-h

author maintainer
#8 lore raw

Re: [PATCH v4 2/2] USB: serial: blacklist USB-UIRT when driver is selected

Quoted 17 lines · Greg Kroah-Hartman
Quoted 16 lines · Sean Young

The USB-UIRT device has its own driver, so blacklist the fdti driver from using it if the driver has been enabled.

---
 drivers/usb/serial/ftdi_sio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/serial/ftdi_sio.c +0 -0
index 369ef140df78..2e9a9076a38d 100644
@@ -106,7 +106,7 @@ static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = {
 	.probe	= ftdi_NDI_device_setup,
 };
 
Quoted 4 lines

drivers/usb/serial/ftdi_sio.c static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = { · line 109

Quoted 2 lines
drivers/usb/serial/ftdi_sio.c +1 -1
-static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
+static __maybe_unused const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {

Why make this change?

If CONFIG_IR_UIRT is enabled, then this struct is not used. This generates a warning when compiling with W=1 (clang or gcc):

CC [M] drivers/usb/serial/ftdi_sio.o
drivers/usb/serial/ftdi_sio.c:109:36: warning: ‘ftdi_USB_UIRT_quirk’ defined but not used [-Wunused-const-variable=]

  109 | static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
      |                                    ^~~~~~~~~~~~~~~~~~~
Quoted 15 lines
Quoted 15 lines
drivers/usb/serial/ftdi_sio.c +2 -0
 	.port_probe = ftdi_USB_UIRT_setup,
 };
 
@@ -568,8 +568,10 @@ static const struct usb_device_id id_table_combined[] = {
 	{ USB_DEVICE(OCT_VID, OCT_DK201_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
+#if !IS_ENABLED(CONFIG_IR_UIRT)
 	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
+#endif
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
Quoted 8 lines

drivers/usb/serial/ftdi_sio.c static int ftdi_sio_port_probe(struct usb_serial_port *port) · line 2286

Quoted 6 lines
drivers/usb/serial/ftdi_sio.c +1 -1
@@ -2281,7 +2283,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 /* Setup for the USB-UIRT device, which requires hardwired
  * baudrate (38400 gets mapped to 312500) */
 /* Called from usbserial:serial_probe */
-static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
+static __maybe_unused void ftdi_USB_UIRT_setup(struct ftdi_private *priv)

Again, why this change here?

Same again.

Thanks for reviewing.

Sean

#2 lore raw

Re: [PATCH v4 1/2] media: rc: new driver for USB-UIRT device

In reply to Sean Young
I love your patch! Perhaps something to improve:

Hi Sean,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on usb-serial/usb-next usb/usb-testing peter.chen-usb/for-usb-next v5.13-rc6 next-20210617] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135
base:   git://linuxtv.org/media_tree.git master
config: powerpc64-randconfig-r012-20210617 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/17d3a0332baecb0359e05e8ae755478c7a1a4468
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135 git checkout 17d3a0332baecb0359e05e8ae755478c7a1a4468
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from drivers/media/rc/uirt.c:11:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:5:
In file included from include/linux/list.h:9:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]

   #define __lwsync()      __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
           ^
   <built-in>:310:9: note: previous definition is here
   #define __lwsync __builtin_ppc_lwsync
           ^
>> drivers/media/rc/uirt.c:639:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!urb)
               ^~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:639:2: note: remove the 'if' if its condition is always false
           if (!urb)
           ^~~~~~~~~
   drivers/media/rc/uirt.c:630:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!urb)
               ^~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:630:2: note: remove the 'if' if its condition is always false
           if (!urb)
           ^~~~~~~~~
   drivers/media/rc/uirt.c:626:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!rc)
               ^~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:626:2: note: remove the 'if' if its condition is always false
           if (!rc)
           ^~~~~~~~
   drivers/media/rc/uirt.c:622:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!uirt->out)
               ^~~~~~~~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:622:2: note: remove the 'if' if its condition is always false
           if (!uirt->out)
           ^~~~~~~~~~~~~~~
   drivers/media/rc/uirt.c:618:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!uirt->in)
               ^~~~~~~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:618:2: note: remove the 'if' if its condition is always false
           if (!uirt->in)
           ^~~~~~~~~~~~~~
   drivers/media/rc/uirt.c:604:15: note: initialize the variable 'err' to silence this warning
           int pipe, err;
                        ^
                         = 0

6 warnings generated.

vim +639 drivers/media/rc/uirt.c

594
595 static int uirt_probe(struct usb_interface *intf,
596 const struct usb_device_id *id)
597 {
598 struct usb_device *usbdev = interface_to_usbdev(intf);
599 struct usb_endpoint_descriptor *ep_in;
600 struct usb_endpoint_descriptor *ep_out;
601 struct uirt *uirt;
602 struct rc_dev *rc;
603 struct urb *urb;
604 int pipe, err;
605
606 if (usb_find_common_endpoints(intf->cur_altsetting, &ep_in, &ep_out, NULL, NULL) ||
607 usb_endpoint_maxp(ep_in) != MAX_PACKET ||
608 usb_endpoint_maxp(ep_out) != MAX_PACKET) {
609 dev_err(&intf->dev, "required endpoints not found\n");
610 return -ENODEV;
611 }
612
613 uirt = kzalloc(sizeof(*uirt), GFP_KERNEL);
614 if (!uirt)
615 return -ENOMEM;
616
617 uirt->in = kmalloc(MAX_PACKET, GFP_KERNEL);
618 if (!uirt->in)
619 goto free_uirt;
620
621 uirt->out = kmalloc(MAX_PACKET, GFP_KERNEL);
622 if (!uirt->out)
623 goto free_uirt;
624
625 rc = rc_allocate_device(RC_DRIVER_IR_RAW);
626 if (!rc)
627 goto free_uirt;
628
629 urb = usb_alloc_urb(0, GFP_KERNEL);
630 if (!urb)
631 goto free_rcdev;
632
633 pipe = usb_rcvbulkpipe(usbdev, ep_in->bEndpointAddress);
634 usb_fill_bulk_urb(urb, usbdev, pipe, uirt->in, MAX_PACKET,
635 uirt_in_callback, uirt);
636 uirt->urb_in = urb;
637
638 urb = usb_alloc_urb(0, GFP_KERNEL);

 > 639		if (!urb)

640 goto free_rcdev;
641
642 pipe = usb_sndbulkpipe(usbdev, ep_out->bEndpointAddress);
643 usb_fill_bulk_urb(urb, usbdev, pipe, uirt->out, MAX_PACKET,
644 uirt_out_callback, uirt);
645
646 uirt->dev = &intf->dev;
647 uirt->usbdev = usbdev;
648 uirt->rc = rc;
649 uirt->urb_out = urb;
650 uirt->rx_state = RX_STATE_INTERSPACE_HIGH;
651
652 err = usb_submit_urb(uirt->urb_in, GFP_KERNEL);
653 if (err != 0) {
654 dev_err(uirt->dev, "failed to submit read urb: %d\n", err);
655 goto free_rcdev;
656 }
657
658 err = init_ftdi(usbdev);
659 if (err) {
660 dev_err(uirt->dev, "failed to setup ftdi: %d\n", err);
661 goto kill_urbs;
662 }
663
664 err = uirt_setup(uirt);
665 if (err)
666 goto kill_urbs;
667
668 usb_make_path(usbdev, uirt->phys, sizeof(uirt->phys));
669
670 rc->device_name = "USB-UIRT";
671 rc->driver_name = KBUILD_MODNAME;
672 rc->input_phys = uirt->phys;
673 usb_to_input_id(usbdev, &rc->input_id);
674 rc->dev.parent = &intf->dev;
675 rc->priv = uirt;
676 rc->tx_ir = uirt_tx;
677 rc->s_tx_carrier = uirt_set_tx_carrier;
678 rc->s_learning_mode = uirt_set_rx_wideband;
679 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
680 rc->map_name = RC_MAP_RC6_MCE;
681 rc->rx_resolution = UNIT_US;
682 rc->timeout = IR_TIMEOUT;
683
684 uirt_set_tx_carrier(rc, 38000);
685
686 err = rc_register_device(rc);
687 if (err)
688 goto kill_urbs;
689
690 usb_set_intfdata(intf, uirt);
691
692 return 0;
693
694 kill_urbs:
695 usb_kill_urb(uirt->urb_in);
696 usb_kill_urb(uirt->urb_out);
697 free_rcdev:
698 usb_free_urb(uirt->urb_in);
699 usb_free_urb(uirt->urb_out);
700 rc_free_device(rc);
701 free_uirt:
702 kfree(uirt->in);
703 kfree(uirt->out);
704 kfree(uirt);
705 return err;
706 }
707

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author maintainer
#3 lore raw

Re: [PATCH v4 1/2] media: rc: new driver for USB-UIRT device

Quoted 44 lines · kernel test robot

Hi Sean,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on usb-serial/usb-next usb/usb-testing peter.chen-usb/for-usb-next v5.13-rc6 next-20210617] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135
base:   git://linuxtv.org/media_tree.git master
config: powerpc64-randconfig-r012-20210617 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/17d3a0332baecb0359e05e8ae755478c7a1a4468
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135 git checkout 17d3a0332baecb0359e05e8ae755478c7a1a4468
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from drivers/media/rc/uirt.c:11:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:5:
In file included from include/linux/list.h:9:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:

   In file included from arch/powerpc/include/asm/bitops.h:62:
   arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
   #define __lwsync()      __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
           ^
   <built-in>:310:9: note: previous definition is here
   #define __lwsync __builtin_ppc_lwsync
           ^
Quoted 5 lines
Quoted 1 line
Quoted 1 line

drivers/media/rc/uirt.c:639:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

           if (!urb)
               ^~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;

This is interesting. clang is right here, there are error paths where err is not initialized. gcc-11.1 does not pick this up for some reason. The error path should be an immediate dominator so it shouldn't be complicated to detect.

I'll send out a v5 with this issue fixed.

Sean

Quoted 167 lines
                  ^~~
   drivers/media/rc/uirt.c:639:2: note: remove the 'if' if its condition is always false
           if (!urb)
           ^~~~~~~~~
   drivers/media/rc/uirt.c:630:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!urb)
               ^~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:630:2: note: remove the 'if' if its condition is always false
           if (!urb)
           ^~~~~~~~~
   drivers/media/rc/uirt.c:626:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!rc)
               ^~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:626:2: note: remove the 'if' if its condition is always false
           if (!rc)
           ^~~~~~~~
   drivers/media/rc/uirt.c:622:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!uirt->out)
               ^~~~~~~~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:622:2: note: remove the 'if' if its condition is always false
           if (!uirt->out)
           ^~~~~~~~~~~~~~~
   drivers/media/rc/uirt.c:618:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!uirt->in)
               ^~~~~~~~~
   drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/media/rc/uirt.c:618:2: note: remove the 'if' if its condition is always false
           if (!uirt->in)
           ^~~~~~~~~~~~~~
   drivers/media/rc/uirt.c:604:15: note: initialize the variable 'err' to silence this warning
           int pipe, err;
                        ^
                         = 0

6 warnings generated.

vim +639 drivers/media/rc/uirt.c

   594	
   595	static int uirt_probe(struct usb_interface *intf,
   596			      const struct usb_device_id *id)
   597	{
   598		struct usb_device *usbdev = interface_to_usbdev(intf);
   599		struct usb_endpoint_descriptor *ep_in;
   600		struct usb_endpoint_descriptor *ep_out;
   601		struct uirt *uirt;
   602		struct rc_dev *rc;
   603		struct urb *urb;
   604		int pipe, err;
   605	
   606		if (usb_find_common_endpoints(intf->cur_altsetting, &ep_in, &ep_out, NULL, NULL) ||
   607		    usb_endpoint_maxp(ep_in) != MAX_PACKET ||
   608		    usb_endpoint_maxp(ep_out) != MAX_PACKET) {
   609			dev_err(&intf->dev, "required endpoints not found\n");
   610			return -ENODEV;
   611		}
   612	
   613		uirt = kzalloc(sizeof(*uirt), GFP_KERNEL);
   614		if (!uirt)
   615			return -ENOMEM;
   616	
   617		uirt->in = kmalloc(MAX_PACKET, GFP_KERNEL);
   618		if (!uirt->in)
   619			goto free_uirt;
   620	
   621		uirt->out = kmalloc(MAX_PACKET, GFP_KERNEL);
   622		if (!uirt->out)
   623			goto free_uirt;
   624	
   625		rc = rc_allocate_device(RC_DRIVER_IR_RAW);
   626		if (!rc)
   627			goto free_uirt;
   628	
   629		urb = usb_alloc_urb(0, GFP_KERNEL);
   630		if (!urb)
   631			goto free_rcdev;
   632	
   633		pipe = usb_rcvbulkpipe(usbdev, ep_in->bEndpointAddress);
   634		usb_fill_bulk_urb(urb, usbdev, pipe, uirt->in, MAX_PACKET,
   635				  uirt_in_callback, uirt);
   636		uirt->urb_in = urb;
   637	
   638		urb = usb_alloc_urb(0, GFP_KERNEL);
Quoted 1 line

639 if (!urb)

   640			goto free_rcdev;
   641	
   642		pipe = usb_sndbulkpipe(usbdev, ep_out->bEndpointAddress);
   643		usb_fill_bulk_urb(urb, usbdev, pipe, uirt->out, MAX_PACKET,
   644				  uirt_out_callback, uirt);
   645	
   646		uirt->dev = &intf->dev;
   647		uirt->usbdev = usbdev;
   648		uirt->rc = rc;
   649		uirt->urb_out = urb;
   650		uirt->rx_state = RX_STATE_INTERSPACE_HIGH;
   651	
   652		err = usb_submit_urb(uirt->urb_in, GFP_KERNEL);
   653		if (err != 0) {
   654			dev_err(uirt->dev, "failed to submit read urb: %d\n", err);
   655			goto free_rcdev;
   656		}
   657	
   658		err = init_ftdi(usbdev);
   659		if (err) {
   660			dev_err(uirt->dev, "failed to setup ftdi: %d\n", err);
   661			goto kill_urbs;
   662		}
   663	
   664		err = uirt_setup(uirt);
   665		if (err)
   666			goto kill_urbs;
   667	
   668		usb_make_path(usbdev, uirt->phys, sizeof(uirt->phys));
   669	
   670		rc->device_name = "USB-UIRT";
   671		rc->driver_name = KBUILD_MODNAME;
   672		rc->input_phys = uirt->phys;
   673		usb_to_input_id(usbdev, &rc->input_id);
   674		rc->dev.parent = &intf->dev;
   675		rc->priv = uirt;
   676		rc->tx_ir = uirt_tx;
   677		rc->s_tx_carrier = uirt_set_tx_carrier;
   678		rc->s_learning_mode = uirt_set_rx_wideband;
   679		rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
   680		rc->map_name = RC_MAP_RC6_MCE;
   681		rc->rx_resolution = UNIT_US;
   682		rc->timeout = IR_TIMEOUT;
   683	
   684		uirt_set_tx_carrier(rc, 38000);
   685	
   686		err = rc_register_device(rc);
   687		if (err)
   688			goto kill_urbs;
   689	
   690		usb_set_intfdata(intf, uirt);
   691	
   692		return 0;
   693	
   694	kill_urbs:
   695		usb_kill_urb(uirt->urb_in);
   696		usb_kill_urb(uirt->urb_out);
   697	free_rcdev:
   698		usb_free_urb(uirt->urb_in);
   699		usb_free_urb(uirt->urb_out);
   700		rc_free_device(rc);
   701	free_uirt:
   702		kfree(uirt->in);
   703		kfree(uirt->out);
   704		kfree(uirt);
   705		return err;
   706	}
   707	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#4 lore raw

Re: [PATCH v4 1/2] media: rc: new driver for USB-UIRT device

Quoted 46 lines · Sean Young
Quoted 45 lines · kernel test robot

Hi Sean,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on usb-serial/usb-next usb/usb-testing peter.chen-usb/for-usb-next v5.13-rc6 next-20210617] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135
base:   git://linuxtv.org/media_tree.git master
config: powerpc64-randconfig-r012-20210617 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/17d3a0332baecb0359e05e8ae755478c7a1a4468
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135 git checkout 17d3a0332baecb0359e05e8ae755478c7a1a4468
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from drivers/media/rc/uirt.c:11:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:5:
In file included from include/linux/list.h:9:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:310:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^

Quoted 1 line
Quoted 1 line

drivers/media/rc/uirt.c:639:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

Quoted 8 lines
Quoted 4 lines
            if (!urb)
                ^~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;

This is interesting. clang is right here, there are error paths where err is not initialized. gcc-11.1 does not pick this up for some reason. The error path should be an immediate dominator so it shouldn't be complicated to detect.

The reason GCC does not warn about this is due to commit 78a5255ffb6a ("Stop the ad-hoc games with -Wno-maybe-initialized"), which disables the GCC version of this warning except with W=2, which very few people use. You could use 'KCFLAGS=-Wmaybe-uninitialized' to try and see the same warning.

Cheers,
Nathan

Quoted 173 lines

I'll send out a v5 with this issue fixed.

Sean

Quoted 167 lines
                   ^~~
    drivers/media/rc/uirt.c:639:2: note: remove the 'if' if its condition is always false
            if (!urb)
            ^~~~~~~~~
    drivers/media/rc/uirt.c:630:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!urb)
                ^~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:630:2: note: remove the 'if' if its condition is always false
            if (!urb)
            ^~~~~~~~~
    drivers/media/rc/uirt.c:626:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!rc)
                ^~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:626:2: note: remove the 'if' if its condition is always false
            if (!rc)
            ^~~~~~~~
    drivers/media/rc/uirt.c:622:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!uirt->out)
                ^~~~~~~~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:622:2: note: remove the 'if' if its condition is always false
            if (!uirt->out)
            ^~~~~~~~~~~~~~~
    drivers/media/rc/uirt.c:618:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!uirt->in)
                ^~~~~~~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:618:2: note: remove the 'if' if its condition is always false
            if (!uirt->in)
            ^~~~~~~~~~~~~~
    drivers/media/rc/uirt.c:604:15: note: initialize the variable 'err' to silence this warning
            int pipe, err;
                         ^
                          = 0
    6 warnings generated.

vim +639 drivers/media/rc/uirt.c

    594	
    595	static int uirt_probe(struct usb_interface *intf,
    596			      const struct usb_device_id *id)
    597	{
    598		struct usb_device *usbdev = interface_to_usbdev(intf);
    599		struct usb_endpoint_descriptor *ep_in;
    600		struct usb_endpoint_descriptor *ep_out;
    601		struct uirt *uirt;
    602		struct rc_dev *rc;
    603		struct urb *urb;
    604		int pipe, err;
    605	
    606		if (usb_find_common_endpoints(intf->cur_altsetting, &ep_in, &ep_out, NULL, NULL) ||
    607		    usb_endpoint_maxp(ep_in) != MAX_PACKET ||
    608		    usb_endpoint_maxp(ep_out) != MAX_PACKET) {
    609			dev_err(&intf->dev, "required endpoints not found\n");
    610			return -ENODEV;
    611		}
    612	
    613		uirt = kzalloc(sizeof(*uirt), GFP_KERNEL);
    614		if (!uirt)
    615			return -ENOMEM;
    616	
    617		uirt->in = kmalloc(MAX_PACKET, GFP_KERNEL);
    618		if (!uirt->in)
    619			goto free_uirt;
    620	
    621		uirt->out = kmalloc(MAX_PACKET, GFP_KERNEL);
    622		if (!uirt->out)
    623			goto free_uirt;
    624	
    625		rc = rc_allocate_device(RC_DRIVER_IR_RAW);
    626		if (!rc)
    627			goto free_uirt;
    628	
    629		urb = usb_alloc_urb(0, GFP_KERNEL);
    630		if (!urb)
    631			goto free_rcdev;
    632	
    633		pipe = usb_rcvbulkpipe(usbdev, ep_in->bEndpointAddress);
    634		usb_fill_bulk_urb(urb, usbdev, pipe, uirt->in, MAX_PACKET,
    635				  uirt_in_callback, uirt);
    636		uirt->urb_in = urb;
    637	
    638		urb = usb_alloc_urb(0, GFP_KERNEL);
Quoted 1 line

639 if (!urb)

    640			goto free_rcdev;
    641	
    642		pipe = usb_sndbulkpipe(usbdev, ep_out->bEndpointAddress);
    643		usb_fill_bulk_urb(urb, usbdev, pipe, uirt->out, MAX_PACKET,
    644				  uirt_out_callback, uirt);
    645	
    646		uirt->dev = &intf->dev;
    647		uirt->usbdev = usbdev;
    648		uirt->rc = rc;
    649		uirt->urb_out = urb;
    650		uirt->rx_state = RX_STATE_INTERSPACE_HIGH;
    651	
    652		err = usb_submit_urb(uirt->urb_in, GFP_KERNEL);
    653		if (err != 0) {
    654			dev_err(uirt->dev, "failed to submit read urb: %d\n", err);
    655			goto free_rcdev;
    656		}
    657	
    658		err = init_ftdi(usbdev);
    659		if (err) {
    660			dev_err(uirt->dev, "failed to setup ftdi: %d\n", err);
    661			goto kill_urbs;
    662		}
    663	
    664		err = uirt_setup(uirt);
    665		if (err)
    666			goto kill_urbs;
    667	
    668		usb_make_path(usbdev, uirt->phys, sizeof(uirt->phys));
    669	
    670		rc->device_name = "USB-UIRT";
    671		rc->driver_name = KBUILD_MODNAME;
    672		rc->input_phys = uirt->phys;
    673		usb_to_input_id(usbdev, &rc->input_id);
    674		rc->dev.parent = &intf->dev;
    675		rc->priv = uirt;
    676		rc->tx_ir = uirt_tx;
    677		rc->s_tx_carrier = uirt_set_tx_carrier;
    678		rc->s_learning_mode = uirt_set_rx_wideband;
    679		rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
    680		rc->map_name = RC_MAP_RC6_MCE;
    681		rc->rx_resolution = UNIT_US;
    682		rc->timeout = IR_TIMEOUT;
    683	
    684		uirt_set_tx_carrier(rc, 38000);
    685	
    686		err = rc_register_device(rc);
    687		if (err)
    688			goto kill_urbs;
    689	
    690		usb_set_intfdata(intf, uirt);
    691	
    692		return 0;
    693	
    694	kill_urbs:
    695		usb_kill_urb(uirt->urb_in);
    696		usb_kill_urb(uirt->urb_out);
    697	free_rcdev:
    698		usb_free_urb(uirt->urb_in);
    699		usb_free_urb(uirt->urb_out);
    700		rc_free_device(rc);
    701	free_uirt:
    702		kfree(uirt->in);
    703		kfree(uirt->out);
    704		kfree(uirt);
    705		return err;
    706	}
    707	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author maintainer
#5 lore raw

Re: [PATCH v4 1/2] media: rc: new driver for USB-UIRT device

Quoted 52 lines · Nathan Chancellor
Quoted 51 lines · Sean Young
Quoted 49 lines · kernel test robot

Hi Sean,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on usb-serial/usb-next usb/usb-testing peter.chen-usb/for-usb-next v5.13-rc6 next-20210617] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135
base:   git://linuxtv.org/media_tree.git master
config: powerpc64-randconfig-r012-20210617 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/17d3a0332baecb0359e05e8ae755478c7a1a4468
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sean-Young/IR-driver-for-USB-UIRT-device/20210616-182135 git checkout 17d3a0332baecb0359e05e8ae755478c7a1a4468
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from drivers/media/rc/uirt.c:11:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:5:
In file included from include/linux/list.h:9:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:310:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^

Quoted 1 line
Quoted 1 line

drivers/media/rc/uirt.c:639:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

            if (!urb)
                ^~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
Quoted 8 lines
Quoted 3 lines

This is interesting. clang is right here, there are error paths where err is not initialized. gcc-11.1 does not pick this up for some reason. The error path should be an immediate dominator so it shouldn't be complicated to detect.

The reason GCC does not warn about this is due to commit 78a5255ffb6a ("Stop the ad-hoc games with -Wno-maybe-initialized"), which disables the GCC version of this warning except with W=2, which very few people use. You could use 'KCFLAGS=-Wmaybe-uninitialized' to try and see the same warning.

You're right, this is exactly the issue here. When running with W=2 or KCFLAGS=-Wmaybe-uninitialized you do get the warning.

There are paths where err are initialized, so gcc correctly says:

warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Thanks,

Sean

Quoted 177 lines

Cheers,
Nathan

Quoted 173 lines

I'll send out a v5 with this issue fixed.

Sean

Quoted 167 lines
                   ^~~
    drivers/media/rc/uirt.c:639:2: note: remove the 'if' if its condition is always false
            if (!urb)
            ^~~~~~~~~
    drivers/media/rc/uirt.c:630:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!urb)
                ^~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:630:2: note: remove the 'if' if its condition is always false
            if (!urb)
            ^~~~~~~~~
    drivers/media/rc/uirt.c:626:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!rc)
                ^~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:626:2: note: remove the 'if' if its condition is always false
            if (!rc)
            ^~~~~~~~
    drivers/media/rc/uirt.c:622:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!uirt->out)
                ^~~~~~~~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:622:2: note: remove the 'if' if its condition is always false
            if (!uirt->out)
            ^~~~~~~~~~~~~~~
    drivers/media/rc/uirt.c:618:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (!uirt->in)
                ^~~~~~~~~
    drivers/media/rc/uirt.c:705:9: note: uninitialized use occurs here
            return err;
                   ^~~
    drivers/media/rc/uirt.c:618:2: note: remove the 'if' if its condition is always false
            if (!uirt->in)
            ^~~~~~~~~~~~~~
    drivers/media/rc/uirt.c:604:15: note: initialize the variable 'err' to silence this warning
            int pipe, err;
                         ^
                          = 0
    6 warnings generated.

vim +639 drivers/media/rc/uirt.c

    594	
    595	static int uirt_probe(struct usb_interface *intf,
    596			      const struct usb_device_id *id)
    597	{
    598		struct usb_device *usbdev = interface_to_usbdev(intf);
    599		struct usb_endpoint_descriptor *ep_in;
    600		struct usb_endpoint_descriptor *ep_out;
    601		struct uirt *uirt;
    602		struct rc_dev *rc;
    603		struct urb *urb;
    604		int pipe, err;
    605	
    606		if (usb_find_common_endpoints(intf->cur_altsetting, &ep_in, &ep_out, NULL, NULL) ||
    607		    usb_endpoint_maxp(ep_in) != MAX_PACKET ||
    608		    usb_endpoint_maxp(ep_out) != MAX_PACKET) {
    609			dev_err(&intf->dev, "required endpoints not found\n");
    610			return -ENODEV;
    611		}
    612	
    613		uirt = kzalloc(sizeof(*uirt), GFP_KERNEL);
    614		if (!uirt)
    615			return -ENOMEM;
    616	
    617		uirt->in = kmalloc(MAX_PACKET, GFP_KERNEL);
    618		if (!uirt->in)
    619			goto free_uirt;
    620	
    621		uirt->out = kmalloc(MAX_PACKET, GFP_KERNEL);
    622		if (!uirt->out)
    623			goto free_uirt;
    624	
    625		rc = rc_allocate_device(RC_DRIVER_IR_RAW);
    626		if (!rc)
    627			goto free_uirt;
    628	
    629		urb = usb_alloc_urb(0, GFP_KERNEL);
    630		if (!urb)
    631			goto free_rcdev;
    632	
    633		pipe = usb_rcvbulkpipe(usbdev, ep_in->bEndpointAddress);
    634		usb_fill_bulk_urb(urb, usbdev, pipe, uirt->in, MAX_PACKET,
    635				  uirt_in_callback, uirt);
    636		uirt->urb_in = urb;
    637	
    638		urb = usb_alloc_urb(0, GFP_KERNEL);
Quoted 1 line

639 if (!urb)

    640			goto free_rcdev;
    641	
    642		pipe = usb_sndbulkpipe(usbdev, ep_out->bEndpointAddress);
    643		usb_fill_bulk_urb(urb, usbdev, pipe, uirt->out, MAX_PACKET,
    644				  uirt_out_callback, uirt);
    645	
    646		uirt->dev = &intf->dev;
    647		uirt->usbdev = usbdev;
    648		uirt->rc = rc;
    649		uirt->urb_out = urb;
    650		uirt->rx_state = RX_STATE_INTERSPACE_HIGH;
    651	
    652		err = usb_submit_urb(uirt->urb_in, GFP_KERNEL);
    653		if (err != 0) {
    654			dev_err(uirt->dev, "failed to submit read urb: %d\n", err);
    655			goto free_rcdev;
    656		}
    657	
    658		err = init_ftdi(usbdev);
    659		if (err) {
    660			dev_err(uirt->dev, "failed to setup ftdi: %d\n", err);
    661			goto kill_urbs;
    662		}
    663	
    664		err = uirt_setup(uirt);
    665		if (err)
    666			goto kill_urbs;
    667	
    668		usb_make_path(usbdev, uirt->phys, sizeof(uirt->phys));
    669	
    670		rc->device_name = "USB-UIRT";
    671		rc->driver_name = KBUILD_MODNAME;
    672		rc->input_phys = uirt->phys;
    673		usb_to_input_id(usbdev, &rc->input_id);
    674		rc->dev.parent = &intf->dev;
    675		rc->priv = uirt;
    676		rc->tx_ir = uirt_tx;
    677		rc->s_tx_carrier = uirt_set_tx_carrier;
    678		rc->s_learning_mode = uirt_set_rx_wideband;
    679		rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
    680		rc->map_name = RC_MAP_RC6_MCE;
    681		rc->rx_resolution = UNIT_US;
    682		rc->timeout = IR_TIMEOUT;
    683	
    684		uirt_set_tx_carrier(rc, 38000);
    685	
    686		err = rc_register_device(rc);
    687		if (err)
    688			goto kill_urbs;
    689	
    690		usb_set_intfdata(intf, uirt);
    691	
    692		return 0;
    693	
    694	kill_urbs:
    695		usb_kill_urb(uirt->urb_in);
    696		usb_kill_urb(uirt->urb_out);
    697	free_rcdev:
    698		usb_free_urb(uirt->urb_in);
    699		usb_free_urb(uirt->urb_out);
    700		rc_free_device(rc);
    701	free_uirt:
    702		kfree(uirt->in);
    703		kfree(uirt->out);
    704		kfree(uirt);
    705		return err;
    706	}
    707	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org