From: Dave Penkler <dpenkler@gmail.com>
To: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org, arnd@arndb.de,
dan.carpenter@linaro.org, Dave Penkler <dpenkler@gmail.com>
Subject: [PATCH 11/11] staging: gpib: Correct check for max secondary address
Date: Sun, 3 Nov 2024 22:26:17 +0100 [thread overview]
Message-ID: <20241103212617.13076-12-dpenkler@gmail.com> (raw)
In-Reply-To: <20241103212617.13076-1-dpenkler@gmail.com>
GPIB secondary addresses can be between 0 and 31 inclusive
unlike primary addresses where address 31 is not a valid device
address. When 31 is used as a primary talk address it
forms the UNT (Untalk) command and when used as a listener address it
forms the UNL (Unlisten) commmand.
The library was incorrectly not allowing a secondary address
with a value of 31 to be used.
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
---
drivers/staging/gpib/common/gpib_os.c | 4 +---
drivers/staging/gpib/common/iblib.c | 6 +++---
drivers/staging/gpib/common/ibsys.h | 3 +++
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/gpib/common/gpib_os.c b/drivers/staging/gpib/common/gpib_os.c
index e84097ac8f69..0285180ae1f0 100644
--- a/drivers/staging/gpib/common/gpib_os.c
+++ b/drivers/staging/gpib/common/gpib_os.c
@@ -525,8 +525,6 @@ int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout)
* SPD and UNT are sent at the completion of the poll.
*/
-static const int gpib_addr_max = 30; /* max address for primary/secondary gpib addresses */
-
int dvrsp(gpib_board_t *board, unsigned int pad, int sad,
unsigned int usec_timeout, uint8_t *result)
{
@@ -538,7 +536,7 @@ int dvrsp(gpib_board_t *board, unsigned int pad, int sad,
return -1;
}
- if (pad > gpib_addr_max || sad > gpib_addr_max) {
+ if (pad > MAX_GPIB_PRIMARY_ADDRESS || sad > MAX_GPIB_SECONDARY_ADDRESS) {
pr_err("gpib: bad address for serial poll");
return -1;
}
diff --git a/drivers/staging/gpib/common/iblib.c b/drivers/staging/gpib/common/iblib.c
index fc57e760c144..db1911cc1b26 100644
--- a/drivers/staging/gpib/common/iblib.c
+++ b/drivers/staging/gpib/common/iblib.c
@@ -479,7 +479,7 @@ int ibsre(gpib_board_t *board, int enable)
*/
int ibpad(gpib_board_t *board, unsigned int addr)
{
- if (addr > 30) {
+ if (addr > MAX_GPIB_PRIMARY_ADDRESS) {
pr_err("gpib: invalid primary address %u\n", addr);
return -1;
}
@@ -498,8 +498,8 @@ int ibpad(gpib_board_t *board, unsigned int addr)
*/
int ibsad(gpib_board_t *board, int addr)
{
- if (addr > 30) {
- pr_err("gpib: invalid secondary address %i, must be 0-30\n", addr);
+ if (addr > MAX_GPIB_SECONDARY_ADDRESS) {
+ pr_err("gpib: invalid secondary address %i\n", addr);
return -1;
}
board->sad = addr;
diff --git a/drivers/staging/gpib/common/ibsys.h b/drivers/staging/gpib/common/ibsys.h
index b78ca5ea4da1..da20971e9c7e 100644
--- a/drivers/staging/gpib/common/ibsys.h
+++ b/drivers/staging/gpib/common/ibsys.h
@@ -16,6 +16,9 @@
#include <asm/irq.h>
#include <asm/dma.h>
+#define MAX_GPIB_PRIMARY_ADDRESS 30
+#define MAX_GPIB_SECONDARY_ADDRESS 31
+
int gpib_allocate_board(gpib_board_t *board);
void gpib_deallocate_board(gpib_board_t *board);
--
2.46.2
next prev parent reply other threads:[~2024-11-03 21:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-03 21:26 [PATCH v2 00/11] staging: gpib: Patch set for gpib staging drivers Dave Penkler
2024-11-03 21:26 ` [PATCH 01/11] staging: gpib: Fix buffer overflow in ni_usb_init Dave Penkler
2024-11-03 21:26 ` [PATCH 02/11] staging: gpib: Replace custom debug with dev_dbg Dave Penkler
2024-11-03 21:26 ` [PATCH 03/11] staging: gpib: Update messaging and usb_device refs in ni_usb Dave Penkler
2024-11-03 21:26 ` [PATCH 04/11] staging: gpib: Update messaging and usb_device refs in agilent_usb Dave Penkler
2024-11-04 8:42 ` Dan Carpenter
2024-11-03 21:26 ` [PATCH 05/11] staging: gpib: Remove GPIB_DEBUG reference and update messaging Dave Penkler
2024-11-04 8:43 ` Dan Carpenter
2024-11-03 21:26 ` [PATCH 06/11] staging: gpib: Use dev_xxx for messaging Dave Penkler
2024-11-03 21:26 ` [PATCH 07/11] staging: gpib: Fix Kconfig Dave Penkler
2024-11-03 21:26 ` [PATCH 08/11] staging: gpib: Remove unneeded lookup table Dave Penkler
2024-11-03 21:26 ` [PATCH 09/11] staging: gpib: Remove GPIO14 and GPIO15 lines in lookup tables Dave Penkler
2024-11-03 21:26 ` [PATCH 10/11] staging: gpib: Re-order the " Dave Penkler
2024-11-04 8:36 ` Dan Carpenter
2024-11-03 21:26 ` Dave Penkler [this message]
2024-11-04 8:09 ` [PATCH 11/11] staging: gpib: Correct check for max secondary address Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241103212617.13076-12-dpenkler@gmail.com \
--to=dpenkler@gmail.com \
--cc=arnd@arndb.de \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome