public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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,
	Dave Penkler <dpenkler@gmail.com>
Subject: [PATCH 9/9] Correct check for max secondary address
Date: Fri,  1 Nov 2024 18:47:05 +0100	[thread overview]
Message-ID: <20241101174705.12682-10-dpenkler@gmail.com> (raw)
In-Reply-To: <20241101174705.12682-1-dpenkler@gmail.com>

  GPIB secondary addresses can be between 0 and 31 inclusive
  unlike primary addresses where address 31 is used for UNT and UNL

Signed-off-by: Dave Penkler <dpenkler@gmail.com>
---
 drivers/staging/gpib/common/gpib_os.c | 3 +--
 drivers/staging/gpib/common/iblib.c   | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gpib/common/gpib_os.c b/drivers/staging/gpib/common/gpib_os.c
index c0b774a831a6..65ab190ac68e 100644
--- a/drivers/staging/gpib/common/gpib_os.c
+++ b/drivers/staging/gpib/common/gpib_os.c
@@ -525,7 +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 +537,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 > 30 || sad > 31) {
 		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..5678e8bd709b 100644
--- a/drivers/staging/gpib/common/iblib.c
+++ b/drivers/staging/gpib/common/iblib.c
@@ -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 > 31) {
+		pr_err("gpib: invalid secondary address %i, must be 0-31\n", addr);
 		return -1;
 	}
 	board->sad = addr;
-- 
2.46.2


  parent reply	other threads:[~2024-11-01 17:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-01 17:46 [PATCH 0/9] Patch set for gpib staging drivers Dave Penkler
2024-11-01 17:46 ` [PATCH 1/9] Fix buffer overflow in ni_usb_init Dave Penkler
2024-11-01 19:46   ` Dan Carpenter
2024-11-01 17:46 ` [PATCH 2/9] Replace custom debug with dev_dbg Dave Penkler
2024-11-01 17:46 ` [PATCH 3/9] Update messaging and usb_device refs in ni_usb Dave Penkler
2024-11-01 19:48   ` Dan Carpenter
2024-11-01 17:47 ` [PATCH 4/9] Update messaging and usb_device refs in agilent_usb Dave Penkler
2024-11-01 17:47 ` [PATCH 5/9] Remove GPIB_DEBUG reference and update messaging Dave Penkler
2024-11-01 17:47 ` [PATCH 6/9] Use dev_xxx for messaging Dave Penkler
2024-11-01 17:47 ` [PATCH 7/9] Fix Kconfig Dave Penkler
2024-11-01 19:51   ` Dan Carpenter
2024-11-01 20:03     ` Dan Carpenter
2024-11-01 17:47 ` [PATCH 8/9] Rationalize lookup tables Dave Penkler
2024-11-01 19:55   ` Dan Carpenter
2024-11-01 17:47 ` Dave Penkler [this message]
2024-11-01 19:59   ` [PATCH 9/9] Correct check for max secondary address Dan Carpenter
2024-11-02  0:51 ` [PATCH 0/9] Patch set for gpib staging drivers Greg KH

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=20241101174705.12682-10-dpenkler@gmail.com \
    --to=dpenkler@gmail.com \
    --cc=arnd@arndb.de \
    --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