]> www.infradead.org Git - users/jedix/linux-maple.git/commit
staging: gpib: change return type of t1_delay function to report errors
authorRodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
Tue, 25 Feb 2025 01:44:05 +0000 (22:44 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Mar 2025 14:07:50 +0000 (07:07 -0700)
commited3751860e6ca5f4f3bb8db3006e607460b047cd
tree64e45cc6f3b5679b9534e3aa4702058121cdc64a
parent97d83d292ba10313aec366141d24c24eeaa3cb7a
staging: gpib: change return type of t1_delay function to report errors

The current code returns "unsigned int" and it doesn't handle errors
correctly if it happens during ioctl call for t1 delay configuration.

The ni_usb_t1_delay(), from NI, is the only function returning -1
at this point. The caller, t1_delay_ioctl(), doesn't check for errors
and sets board->t1_nano_sec to -1 and returns success.
The board->t1_nano_sec value is also used in ni_usb_setup_t1_delay()
besides the ioctl call and a value of -1 is treated as being above 1100ns.
It may or may not have a noticeable effect, but it's obviously not right
considering the content of ni_usb_setup_t1_delay().

Typical delays are in the 200-2000 range, but definitely not more
than INT_MAX so we can fix this code by changing the return type to int
and adding a check for errors. While we're at it, lets change the error
code in ni_usb_t1_delay() from -1 and instead propagate the error from
ni_usb_write_registers().

Fixes: 4e127de14fa7 ("staging: gpib: Add National Instruments USB GPIB driver")
Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
Link: https://lore.kernel.org/r/20250225014811.77995-1-rodrigo.gobbi.7@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 files changed:
drivers/staging/gpib/agilent_82350b/agilent_82350b.c
drivers/staging/gpib/agilent_82357a/agilent_82357a.c
drivers/staging/gpib/cb7210/cb7210.c
drivers/staging/gpib/cec/cec_gpib.c
drivers/staging/gpib/common/gpib_os.c
drivers/staging/gpib/eastwood/fluke_gpib.c
drivers/staging/gpib/fmh_gpib/fmh_gpib.c
drivers/staging/gpib/gpio/gpib_bitbang.c
drivers/staging/gpib/hp_82335/hp82335.c
drivers/staging/gpib/hp_82341/hp_82341.c
drivers/staging/gpib/include/gpib_types.h
drivers/staging/gpib/include/nec7210.h
drivers/staging/gpib/ines/ines.h
drivers/staging/gpib/ines/ines_gpib.c
drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
drivers/staging/gpib/nec7210/nec7210.c
drivers/staging/gpib/ni_usb/ni_usb_gpib.c
drivers/staging/gpib/pc2/pc2_gpib.c
drivers/staging/gpib/tnt4882/tnt4882_gpib.c