* [PATCH 0/2] staging: gpib: Handle device clear and trigger
@ 2025-09-28 11:33 Dave Penkler
2025-09-28 11:33 ` [PATCH 1/2] staging: gpib: Fix sending clear and trigger events Dave Penkler
2025-09-28 11:33 ` [PATCH 2/2] staging: gpib: Return -EINTR on device clear Dave Penkler
0 siblings, 2 replies; 3+ messages in thread
From: Dave Penkler @ 2025-09-28 11:33 UTC (permalink / raw)
To: gregkh, linux-staging, linux-kernel; +Cc: Dave Penkler
This patch series addresses the handling of device clear and trigger
commands sent from the controller when the board is operating in
device mode.
Patch1: Send device clear and trigger events
Patch2: Return -EINTR when ATN is set on read when a device clear
command is issued.
Dave Penkler (2):
staging: gpib: Fix sending clear and trigger events
staging: gpib: Return -EINTR on device clear
drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 1/2] staging: gpib: Fix sending clear and trigger events
2025-09-28 11:33 [PATCH 0/2] staging: gpib: Handle device clear and trigger Dave Penkler
@ 2025-09-28 11:33 ` Dave Penkler
2025-09-28 11:33 ` [PATCH 2/2] staging: gpib: Return -EINTR on device clear Dave Penkler
1 sibling, 0 replies; 3+ messages in thread
From: Dave Penkler @ 2025-09-28 11:33 UTC (permalink / raw)
To: gregkh, linux-staging, linux-kernel; +Cc: Dave Penkler
This driver was not sending device clear or trigger events when the
board entered the DCAS or DTAS state respectively in device mode.
DCAS is the Device Clear Active State which is entered on receiving a
selective device clear message (SDC) or universal device clear message
(DCL) from the controller in charge.
DTAS is the Device Trigger Active State which is entered on receiving
a group execute trigger (GET) message from the controller.
In order for an application, implementing a particular device, to
detect when one of these states is entered the driver needs to send
the appropriate event.
Send the appropriate gpib_event when DCAS or DTAS is set in the
reported status word. This sets the DCAS or DTAS bits in the board's
status word which can be monitored by the application.
Fixes: 4e127de14fa7 ("staging: gpib: Add National Instruments USB GPIB driver")
Tested-by: Dave Penkler <dpenkler@gmail.com>
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
---
drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
index 4dec87d12687..ea44a766fda2 100644
--- a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
+++ b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
@@ -327,7 +327,10 @@ static void ni_usb_soft_update_status(struct gpib_board *board, unsigned int ni_
board->status &= ~clear_mask;
board->status &= ~ni_usb_ibsta_mask;
board->status |= ni_usb_ibsta & ni_usb_ibsta_mask;
- // FIXME should generate events on DTAS and DCAS
+ if (ni_usb_ibsta & DCAS)
+ push_gpib_event(board, EVENT_DEV_CLR);
+ if (ni_usb_ibsta & DTAS)
+ push_gpib_event(board, EVENT_DEV_TRG);
spin_lock_irqsave(&board->spinlock, flags);
/* remove set status bits from monitored set why ?***/
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] staging: gpib: Return -EINTR on device clear
2025-09-28 11:33 [PATCH 0/2] staging: gpib: Handle device clear and trigger Dave Penkler
2025-09-28 11:33 ` [PATCH 1/2] staging: gpib: Fix sending clear and trigger events Dave Penkler
@ 2025-09-28 11:33 ` Dave Penkler
1 sibling, 0 replies; 3+ messages in thread
From: Dave Penkler @ 2025-09-28 11:33 UTC (permalink / raw)
To: gregkh, linux-staging, linux-kernel; +Cc: Dave Penkler
When the ATN (Attention) line is asserted during a read we get a
NIUSB_ATN_STATE_ERROR during a read. For the controller to send a
device clear it asserts ATN. Normally this is an error but in the case
of a device clear it should be regarded as an interrupt.
Return -EINTR when the Device Clear Active State (DCAS) is entered
else signal an error with dev_dbg with status instead of just dev_err.
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
---
drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
index ea44a766fda2..1f8412de9fa3 100644
--- a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
+++ b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
@@ -697,8 +697,12 @@ static int ni_usb_read(struct gpib_board *board, u8 *buffer, size_t length,
*/
break;
case NIUSB_ATN_STATE_ERROR:
- retval = -EIO;
- dev_err(&usb_dev->dev, "read when ATN set\n");
+ if (status.ibsta & DCAS) {
+ retval = -EINTR;
+ } else {
+ retval = -EIO;
+ dev_dbg(&usb_dev->dev, "read when ATN set stat: 0x%06x\n", status.ibsta);
+ }
break;
case NIUSB_ADDRESSING_ERROR:
retval = -EIO;
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-28 11:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-28 11:33 [PATCH 0/2] staging: gpib: Handle device clear and trigger Dave Penkler
2025-09-28 11:33 ` [PATCH 1/2] staging: gpib: Fix sending clear and trigger events Dave Penkler
2025-09-28 11:33 ` [PATCH 2/2] staging: gpib: Return -EINTR on device clear Dave Penkler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).