summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/pnp/isapnp/core.c1
-rw-r--r--drivers/staging/gpib/Kconfig5
-rw-r--r--drivers/staging/gpib/agilent_82350b/agilent_82350b.c260
-rw-r--r--drivers/staging/gpib/agilent_82350b/agilent_82350b.h50
-rw-r--r--drivers/staging/gpib/agilent_82357a/agilent_82357a.c527
-rw-r--r--drivers/staging/gpib/cb7210/Makefile1
-rw-r--r--drivers/staging/gpib/cb7210/cb7210.c287
-rw-r--r--drivers/staging/gpib/cb7210/cb7210.h45
-rw-r--r--drivers/staging/gpib/cec/cec.h29
-rw-r--r--drivers/staging/gpib/cec/cec_gpib.c96
-rw-r--r--drivers/staging/gpib/common/gpib_os.c328
-rw-r--r--drivers/staging/gpib/common/iblib.c167
-rw-r--r--drivers/staging/gpib/common/ibsys.h14
-rw-r--r--drivers/staging/gpib/eastwood/fluke_gpib.c204
-rw-r--r--drivers/staging/gpib/fmh_gpib/fmh_gpib.c280
-rw-r--r--drivers/staging/gpib/gpio/gpib_bitbang.c138
-rw-r--r--drivers/staging/gpib/hp_82335/hp82335.c83
-rw-r--r--drivers/staging/gpib/hp_82335/hp82335.h30
-rw-r--r--drivers/staging/gpib/hp_82341/hp_82341.c161
-rw-r--r--drivers/staging/gpib/hp_82341/hp_82341.h40
-rw-r--r--drivers/staging/gpib/include/gpibP.h10
-rw-r--r--drivers/staging/gpib/include/gpib_proto.h58
-rw-r--r--drivers/staging/gpib/include/gpib_types.h58
-rw-r--r--drivers/staging/gpib/include/nec7210.h60
-rw-r--r--drivers/staging/gpib/include/tms9914.h52
-rw-r--r--drivers/staging/gpib/ines/Makefile1
-rw-r--r--drivers/staging/gpib/ines/ines.h54
-rw-r--r--drivers/staging/gpib/ines/ines_gpib.c240
-rw-r--r--drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c363
-rw-r--r--drivers/staging/gpib/nec7210/nec7210.c147
-rw-r--r--drivers/staging/gpib/ni_usb/ni_usb_gpib.c611
-rw-r--r--drivers/staging/gpib/pc2/pc2_gpib.c352
-rw-r--r--drivers/staging/gpib/tms9914/tms9914.c117
-rw-r--r--drivers/staging/gpib/tnt4882/Makefile1
-rw-r--r--drivers/staging/gpib/tnt4882/mite.c17
-rw-r--r--drivers/staging/gpib/tnt4882/tnt4882_gpib.c964
-rw-r--r--drivers/staging/gpib/uapi/gpib_user.h29
-rw-r--r--drivers/staging/rtl8723bs/Kconfig1
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ap.c96
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_com.c3
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_intf.h27
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_hal.h1
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_io.h92
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_mp.h341
-rw-r--r--drivers/staging/rtl8723bs/os_dep/os_intfs.c2
-rw-r--r--drivers/staging/sm750fb/ddk750_chip.c2
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c2
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c127
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c65
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h2
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c14
51 files changed, 2728 insertions, 3927 deletions
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index c43d8ad02529..d2ff76e74a05 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -843,6 +843,7 @@ EXPORT_SYMBOL(isapnp_protocol);
EXPORT_SYMBOL(isapnp_present);
EXPORT_SYMBOL(isapnp_cfg_begin);
EXPORT_SYMBOL(isapnp_cfg_end);
+EXPORT_SYMBOL(isapnp_read_byte);
EXPORT_SYMBOL(isapnp_write_byte);
static int isapnp_get_resources(struct pnp_dev *dev)
diff --git a/drivers/staging/gpib/Kconfig b/drivers/staging/gpib/Kconfig
index 81510db3072e..aa01538d5beb 100644
--- a/drivers/staging/gpib/Kconfig
+++ b/drivers/staging/gpib/Kconfig
@@ -50,7 +50,6 @@ config GPIB_CEC_PCI
tristate "CEC PCI board"
depends on PCI
depends on HAS_IOPORT
- depends on !X86_PAE
select GPIB_COMMON
select GPIB_NEC7210
help
@@ -64,7 +63,6 @@ config GPIB_NI_PCI_ISA
tristate "NI PCI/ISA compatible boards"
depends on ISA_BUS || PCI || PCMCIA
depends on HAS_IOPORT
- depends on !X86_PAE
depends on PCMCIA || !PCMCIA
depends on HAS_IOPORT_MAP
select GPIB_COMMON
@@ -90,7 +88,6 @@ config GPIB_CB7210
tristate "Measurement Computing compatible boards"
depends on HAS_IOPORT
depends on ISA_BUS || PCI || PCMCIA
- depends on !X86_PAE
depends on PCMCIA || !PCMCIA
select GPIB_COMMON
select GPIB_NEC7210
@@ -169,7 +166,6 @@ config GPIB_HP82341
tristate "HP82341x"
select GPIB_COMMON
select GPIB_TMS9914
- depends on BROKEN
depends on ISA_BUS || EISA
help
GPIB driver for HP82341 A/B/C/D boards
@@ -182,7 +178,6 @@ config GPIB_INES
depends on PCI || ISA_BUS || PCMCIA
depends on PCMCIA || !PCMCIA
depends on HAS_IOPORT
- depends on !X86_PAE
select GPIB_COMMON
select GPIB_NEC7210
help
diff --git a/drivers/staging/gpib/agilent_82350b/agilent_82350b.c b/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
index 3f4f95b7fe34..445b9380ff98 100644
--- a/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
+++ b/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
@@ -4,6 +4,10 @@
* copyright : (C) 2002, 2004 by Frank Mori Hess *
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "agilent_82350b.h"
#include <linux/delay.h>
#include <linux/ioport.h>
@@ -20,8 +24,14 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB driver for Agilent 82350b");
-int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read)
+static int read_transfer_counter(struct agilent_82350b_priv *a_priv);
+static unsigned short read_and_clear_event_status(struct gpib_board *board);
+static void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count);
+static int agilent_82350b_write(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int send_eoi, size_t *bytes_written);
+
+static int agilent_82350b_accel_read(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int *end, size_t *bytes_read)
{
struct agilent_82350b_priv *a_priv = board->private_data;
@@ -48,9 +58,6 @@ int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t lengt
retval = tms9914_read(board, tms_priv, buffer, 1, end, &num_bytes);
*bytes_read += num_bytes;
- if (retval < 0)
- dev_err(board->gpib_dev, "%s: tms9914_read failed retval=%i\n",
- driver_name, retval);
if (retval < 0 || *end)
return retval;
++buffer;
@@ -66,10 +73,7 @@ int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t lengt
int j;
int count;
- if (num_fifo_bytes - i < agilent_82350b_fifo_size)
- block_size = num_fifo_bytes - i;
- else
- block_size = agilent_82350b_fifo_size;
+ block_size = min(num_fifo_bytes - i, agilent_82350b_fifo_size);
set_transfer_counter(a_priv, block_size);
writeb(ENABLE_TI_TO_SRAM | DIRECTION_GPIB_TO_HOST,
a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG);
@@ -86,7 +90,6 @@ int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t lengt
test_bit(DEV_CLEAR_BN, &tms_priv->state) ||
test_bit(TIMO_NUM, &board->status));
if (retval) {
- dev_dbg(board->gpib_dev, "%s: read wait interrupted\n", driver_name);
retval = -ERESTARTSYS;
break;
}
@@ -100,13 +103,10 @@ int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t lengt
*end = 1;
}
if (test_bit(TIMO_NUM, &board->status)) {
- dev_err(board->gpib_dev, "%s: read timed out\n", driver_name);
retval = -ETIMEDOUT;
break;
}
if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) {
- dev_err(board->gpib_dev, "%s: device clear interrupted read\n",
- driver_name);
retval = -EINTR;
break;
}
@@ -130,30 +130,24 @@ int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t lengt
return 0;
}
-static int translate_wait_return_value(gpib_board_t *board, int retval)
+static int translate_wait_return_value(struct gpib_board *board, int retval)
{
struct agilent_82350b_priv *a_priv = board->private_data;
struct tms9914_priv *tms_priv = &a_priv->tms9914_priv;
- if (retval) {
- dev_err(board->gpib_dev, "%s: write wait interrupted\n", driver_name);
+ if (retval)
return -ERESTARTSYS;
- }
- if (test_bit(TIMO_NUM, &board->status)) {
- dev_err(board->gpib_dev, "%s: write timed out\n", driver_name);
+ if (test_bit(TIMO_NUM, &board->status))
return -ETIMEDOUT;
- }
- if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) {
- dev_err(board->gpib_dev, "%s: device clear interrupted write\n", driver_name);
+ if (test_bit(DEV_CLEAR_BN, &tms_priv->state))
return -EINTR;
- }
return 0;
}
-int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
-
+static int agilent_82350b_accel_write(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int send_eoi,
+ size_t *bytes_written)
{
struct agilent_82350b_priv *a_priv = board->private_data;
struct tms9914_priv *tms_priv = &a_priv->tms9914_priv;
@@ -174,10 +168,8 @@ int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t leng
event_status = read_and_clear_event_status(board);
- //pr_info("ag_ac_wr: event status 0x%x tms state 0x%lx\n", event_status, tms_priv->state);
-
#ifdef EXPERIMENTAL
- pr_info("ag_ac_wr: wait for previous BO to complete if any\n");
+ // wait for previous BO to complete if any
retval = wait_event_interruptible(board->wait,
test_bit(DEV_CLEAR_BN, &tms_priv->state) ||
test_bit(WRITE_READY_BN, &tms_priv->state) ||
@@ -188,22 +180,16 @@ int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t leng
return retval;
#endif
- //pr_info("ag_ac_wr: sending first byte\n");
retval = agilent_82350b_write(board, buffer, 1, 0, &num_bytes);
*bytes_written += num_bytes;
if (retval < 0)
return retval;
- //pr_info("ag_ac_wr: %ld bytes eoi %d tms state 0x%lx\n",length, send_eoi, tms_priv->state);
-
write_byte(tms_priv, tms_priv->imr0_bits & ~HR_BOIE, IMR0);
for (i = 1; i < fifotransferlength;) {
clear_bit(WRITE_READY_BN, &tms_priv->state);
- if (fifotransferlength - i < agilent_82350b_fifo_size)
- block_size = fifotransferlength - i;
- else
- block_size = agilent_82350b_fifo_size;
+ block_size = min(fifotransferlength - i, agilent_82350b_fifo_size);
set_transfer_counter(a_priv, block_size);
for (j = 0; j < block_size; ++j, ++i) {
// load data into board's sram
@@ -211,13 +197,8 @@ int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t leng
}
writeb(ENABLE_TI_TO_SRAM, a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG);
- //pr_info("ag_ac_wr: send block: %d bytes tms 0x%lx\n", block_size,
- // tms_priv->state);
-
- if (agilent_82350b_fifo_is_halted(a_priv)) {
+ if (agilent_82350b_fifo_is_halted(a_priv))
writeb(RESTART_STREAM_BIT, a_priv->gpib_base + STREAM_STATUS_REG);
- // pr_info("ag_ac_wr: needed restart\n");
- }
retval = wait_event_interruptible(board->wait,
((event_status =
@@ -227,7 +208,6 @@ int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t leng
test_bit(TIMO_NUM, &board->status));
writeb(0, a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG);
num_bytes = block_size - read_transfer_counter(a_priv);
- //pr_info("ag_ac_wr: sent %ld bytes tms 0x%lx\n", num_bytes, tms_priv->state);
*bytes_written += num_bytes;
retval = translate_wait_return_value(board, retval);
@@ -239,9 +219,6 @@ int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t leng
return retval;
if (send_eoi) {
- //pr_info("ag_ac_wr: sending last byte with eoi byte no: %d\n",
- // fifotransferlength+1);
-
retval = agilent_82350b_write(board, buffer + fifotransferlength, 1, send_eoi,
&num_bytes);
*bytes_written += num_bytes;
@@ -251,8 +228,7 @@ int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t leng
return 0;
}
-unsigned short read_and_clear_event_status(gpib_board_t *board)
-
+static unsigned short read_and_clear_event_status(struct gpib_board *board)
{
struct agilent_82350b_priv *a_priv = board->private_data;
unsigned long flags;
@@ -265,12 +241,12 @@ unsigned short read_and_clear_event_status(gpib_board_t *board)
return status;
}
-irqreturn_t agilent_82350b_interrupt(int irq, void *arg)
+static irqreturn_t agilent_82350b_interrupt(int irq, void *arg)
{
int tms9914_status1 = 0, tms9914_status2 = 0;
int event_status;
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct agilent_82350b_priv *a_priv = board->private_data;
unsigned long flags;
irqreturn_t retval = IRQ_NONE;
@@ -286,7 +262,6 @@ irqreturn_t agilent_82350b_interrupt(int irq, void *arg)
tms9914_interrupt_have_status(board, &a_priv->tms9914_priv, tms9914_status1,
tms9914_status2);
}
-//pr_info("event_status=0x%x s1 %x s2 %x\n", event_status,tms9914_status1,tms9914_status2);
//write-clear status bits
if (event_status & (BUFFER_END_STATUS_BIT | TERM_COUNT_STATUS_BIT)) {
writeb(event_status & (BUFFER_END_STATUS_BIT | TERM_COUNT_STATUS_BIT),
@@ -298,12 +273,9 @@ irqreturn_t agilent_82350b_interrupt(int irq, void *arg)
return retval;
}
-void agilent_82350b_detach(gpib_board_t *board);
-
-const char *driver_name = "agilent_82350b";
-
-int read_transfer_counter(struct agilent_82350b_priv *a_priv)
+static void agilent_82350b_detach(struct gpib_board *board);
+static int read_transfer_counter(struct agilent_82350b_priv *a_priv)
{
int lo, mid, value;
@@ -314,8 +286,7 @@ int read_transfer_counter(struct agilent_82350b_priv *a_priv)
return value;
}
-void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count)
-
+static void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count)
{
int complement = -count;
@@ -326,17 +297,16 @@ void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count)
}
// wrappers for interface functions
-int agilent_82350b_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read)
-
+static int agilent_82350b_read(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int *end, size_t *bytes_read)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_read(board, &priv->tms9914_priv, buffer, length, end, bytes_read);
}
-int agilent_82350b_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
+static int agilent_82350b_write(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int send_eoi, size_t *bytes_written)
{
struct agilent_82350b_priv *priv = board->private_data;
@@ -344,8 +314,8 @@ int agilent_82350b_write(gpib_board_t *board, uint8_t *buffer, size_t length, in
return tms9914_write(board, &priv->tms9914_priv, buffer, length, send_eoi, bytes_written);
}
-int agilent_82350b_command(gpib_board_t *board, uint8_t *buffer, size_t length,
- size_t *bytes_written)
+static int agilent_82350b_command(struct gpib_board *board, uint8_t *buffer,
+ size_t length, size_t *bytes_written)
{
struct agilent_82350b_priv *priv = board->private_data;
@@ -353,7 +323,7 @@ int agilent_82350b_command(gpib_board_t *board, uint8_t *buffer, size_t length,
return tms9914_command(board, &priv->tms9914_priv, buffer, length, bytes_written);
}
-int agilent_82350b_take_control(gpib_board_t *board, int synchronous)
+static int agilent_82350b_take_control(struct gpib_board *board, int synchronous)
{
struct agilent_82350b_priv *priv = board->private_data;
@@ -361,7 +331,7 @@ int agilent_82350b_take_control(gpib_board_t *board, int synchronous)
return tms9914_take_control_workaround(board, &priv->tms9914_priv, synchronous);
}
-int agilent_82350b_go_to_standby(gpib_board_t *board)
+static int agilent_82350b_go_to_standby(struct gpib_board *board)
{
struct agilent_82350b_priv *priv = board->private_data;
@@ -369,7 +339,8 @@ int agilent_82350b_go_to_standby(gpib_board_t *board)
return tms9914_go_to_standby(board, &priv->tms9914_priv);
}
-void agilent_82350b_request_system_control(gpib_board_t *board, int request_control)
+static void agilent_82350b_request_system_control(struct gpib_board *board,
+ int request_control)
{
struct agilent_82350b_priv *a_priv = board->private_data;
@@ -387,7 +358,7 @@ void agilent_82350b_request_system_control(gpib_board_t *board, int request_cont
tms9914_request_system_control(board, &a_priv->tms9914_priv, request_control);
}
-void agilent_82350b_interface_clear(gpib_board_t *board, int assert)
+static void agilent_82350b_interface_clear(struct gpib_board *board, int assert)
{
struct agilent_82350b_priv *priv = board->private_data;
@@ -395,104 +366,96 @@ void agilent_82350b_interface_clear(gpib_board_t *board, int assert)
tms9914_interface_clear(board, &priv->tms9914_priv, assert);
}
-void agilent_82350b_remote_enable(gpib_board_t *board, int enable)
-
+static void agilent_82350b_remote_enable(struct gpib_board *board, int enable)
{
struct agilent_82350b_priv *priv = board->private_data;
tms9914_remote_enable(board, &priv->tms9914_priv, enable);
}
-int agilent_82350b_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
-
+static int agilent_82350b_enable_eos(struct gpib_board *board, uint8_t eos_byte,
+ int compare_8_bits)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_enable_eos(board, &priv->tms9914_priv, eos_byte, compare_8_bits);
}
-void agilent_82350b_disable_eos(gpib_board_t *board)
-
+static void agilent_82350b_disable_eos(struct gpib_board *board)
{
struct agilent_82350b_priv *priv = board->private_data;
tms9914_disable_eos(board, &priv->tms9914_priv);
}
-unsigned int agilent_82350b_update_status(gpib_board_t *board, unsigned int clear_mask)
-
+static unsigned int agilent_82350b_update_status(struct gpib_board *board,
+ unsigned int clear_mask)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_update_status(board, &priv->tms9914_priv, clear_mask);
}
-int agilent_82350b_primary_address(gpib_board_t *board, unsigned int address)
-
+static int agilent_82350b_primary_address(struct gpib_board *board,
+ unsigned int address)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_primary_address(board, &priv->tms9914_priv, address);
}
-int agilent_82350b_secondary_address(gpib_board_t *board, unsigned int address, int enable)
-
+static int agilent_82350b_secondary_address(struct gpib_board *board,
+ unsigned int address, int enable)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_secondary_address(board, &priv->tms9914_priv, address, enable);
}
-int agilent_82350b_parallel_poll(gpib_board_t *board, uint8_t *result)
-
+static int agilent_82350b_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_parallel_poll(board, &priv->tms9914_priv, result);
}
-void agilent_82350b_parallel_poll_configure(gpib_board_t *board, uint8_t config)
-
+static void agilent_82350b_parallel_poll_configure(struct gpib_board *board,
+ uint8_t config)
{
struct agilent_82350b_priv *priv = board->private_data;
tms9914_parallel_poll_configure(board, &priv->tms9914_priv, config);
}
-void agilent_82350b_parallel_poll_response(gpib_board_t *board, int ist)
-
+static void agilent_82350b_parallel_poll_response(struct gpib_board *board, int ist)
{
struct agilent_82350b_priv *priv = board->private_data;
tms9914_parallel_poll_response(board, &priv->tms9914_priv, ist);
}
-void agilent_82350b_serial_poll_response(gpib_board_t *board, uint8_t status)
-
+static void agilent_82350b_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct agilent_82350b_priv *priv = board->private_data;
tms9914_serial_poll_response(board, &priv->tms9914_priv, status);
}
-uint8_t agilent_82350b_serial_poll_status(gpib_board_t *board)
-
+static uint8_t agilent_82350b_serial_poll_status(struct gpib_board *board)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_serial_poll_status(board, &priv->tms9914_priv);
}
-int agilent_82350b_line_status(const gpib_board_t *board)
-
+static int agilent_82350b_line_status(const struct gpib_board *board)
{
struct agilent_82350b_priv *priv = board->private_data;
return tms9914_line_status(board, &priv->tms9914_priv);
}
-unsigned int agilent_82350b_t1_delay(gpib_board_t *board, unsigned int nanosec)
-
+static int agilent_82350b_t1_delay(struct gpib_board *board, unsigned int nanosec)
{
struct agilent_82350b_priv *a_priv = board->private_data;
static const int nanosec_per_clock = 30;
@@ -507,16 +470,14 @@ unsigned int agilent_82350b_t1_delay(gpib_board_t *board, unsigned int nanosec)
return value * nanosec_per_clock;
}
-void agilent_82350b_return_to_local(gpib_board_t *board)
-
+static void agilent_82350b_return_to_local(struct gpib_board *board)
{
struct agilent_82350b_priv *priv = board->private_data;
tms9914_return_to_local(board, &priv->tms9914_priv);
}
-int agilent_82350b_allocate_private(gpib_board_t *board)
-
+static int agilent_82350b_allocate_private(struct gpib_board *board)
{
board->private_data = kzalloc(sizeof(struct agilent_82350b_priv), GFP_KERNEL);
if (!board->private_data)
@@ -524,15 +485,14 @@ int agilent_82350b_allocate_private(gpib_board_t *board)
return 0;
}
-void agilent_82350b_free_private(gpib_board_t *board)
-
+static void agilent_82350b_free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
}
-static int init_82350a_hardware(gpib_board_t *board, const gpib_board_config_t *config)
-
+static int init_82350a_hardware(struct gpib_board *board,
+ const gpib_board_config_t *config)
{
struct agilent_82350b_priv *a_priv = board->private_data;
static const unsigned int firmware_length = 5302;
@@ -557,11 +517,10 @@ static int init_82350a_hardware(gpib_board_t *board, const gpib_board_config_t *
return 0;
// need to programme borg
if (!config->init_data || config->init_data_length != firmware_length) {
- dev_err(board->gpib_dev, "%s: the 82350A board requires firmware after powering on.\n",
- driver_name);
+ dev_err(board->gpib_dev, "the 82350A board requires firmware after powering on.\n");
return -EIO;
}
- dev_info(board->gpib_dev, "%s: Loading firmware...\n", driver_name);
+ dev_dbg(board->gpib_dev, "Loading firmware...\n");
// tickle the borg
writel(plx_cntrl_static_bits | PLX9050_USER3_DATA_BIT,
@@ -580,7 +539,7 @@ static int init_82350a_hardware(gpib_board_t *board, const gpib_board_config_t *
usleep_range(10, 20);
}
if (j == timeout) {
- dev_err(board->gpib_dev, "%s: timed out loading firmware.\n", driver_name);
+ dev_err(board->gpib_dev, "timed out loading firmware.\n");
return -ETIMEDOUT;
}
writeb(firmware_data[i], a_priv->gpib_base + CONFIG_DATA_REG);
@@ -591,15 +550,14 @@ static int init_82350a_hardware(gpib_board_t *board, const gpib_board_config_t *
usleep_range(10, 20);
}
if (j == timeout) {
- dev_err(board->gpib_dev, "%s: timed out waiting for firmware load to complete.\n",
- driver_name);
+ dev_err(board->gpib_dev, "timed out waiting for firmware load to complete.\n");
return -ETIMEDOUT;
}
- dev_info(board->gpib_dev, "%s: ...done.\n", driver_name);
+ dev_dbg(board->gpib_dev, " ...done.\n");
return 0;
}
-static int test_sram(gpib_board_t *board)
+static int test_sram(struct gpib_board *board)
{
struct agilent_82350b_priv *a_priv = board->private_data;
@@ -617,19 +575,19 @@ static int test_sram(gpib_board_t *board)
unsigned int read_value = readb(a_priv->sram_base + i);
if ((i & byte_mask) != read_value) {
- dev_err(board->gpib_dev, "%s: SRAM test failed at %d wanted %d got %d\n",
- driver_name, i, (i & byte_mask), read_value);
+ dev_err(board->gpib_dev, "SRAM test failed at %d wanted %d got %d\n",
+ i, (i & byte_mask), read_value);
return -EIO;
}
if (need_resched())
schedule();
}
- dev_info(board->gpib_dev, "%s: SRAM test passed 0x%x bytes checked\n",
- driver_name, sram_length);
+ dev_dbg(board->gpib_dev, "SRAM test passed 0x%x bytes checked\n", sram_length);
return 0;
}
-static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_config_t *config,
+static int agilent_82350b_generic_attach(struct gpib_board *board,
+ const gpib_board_config_t *config,
int use_fifos)
{
@@ -653,14 +611,14 @@ static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_c
PCI_DEVICE_ID_82350B, NULL);
if (a_priv->pci_device) {
a_priv->model = MODEL_82350B;
- dev_info(board->gpib_dev, "%s: Agilent 82350B board found\n", driver_name);
+ dev_dbg(board->gpib_dev, "Agilent 82350B board found\n");
} else {
a_priv->pci_device = gpib_pci_get_device(config, PCI_VENDOR_ID_AGILENT,
PCI_DEVICE_ID_82351A, NULL);
if (a_priv->pci_device) {
a_priv->model = MODEL_82351A;
- dev_info(board->gpib_dev, "%s: Agilent 82351B board found\n", driver_name);
+ dev_dbg(board->gpib_dev, "Agilent 82351B board found\n");
} else {
a_priv->pci_device = gpib_pci_get_subsys(config, PCI_VENDOR_ID_PLX,
@@ -670,46 +628,40 @@ static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_c
a_priv->pci_device);
if (a_priv->pci_device) {
a_priv->model = MODEL_82350A;
- dev_info(board->gpib_dev, "%s: HP/Agilent 82350A board found\n",
- driver_name);
+ dev_dbg(board->gpib_dev, "HP/Agilent 82350A board found\n");
} else {
- dev_err(board->gpib_dev, "%s: no 82350/82351 board found\n",
- driver_name);
+ dev_err(board->gpib_dev, "no 82350/82351 board found\n");
return -ENODEV;
}
}
}
if (pci_enable_device(a_priv->pci_device)) {
- dev_err(board->gpib_dev, "%s: error enabling pci device\n", driver_name);
+ dev_err(board->gpib_dev, "error enabling pci device\n");
return -EIO;
}
- if (pci_request_regions(a_priv->pci_device, driver_name))
- return -EIO;
+ if (pci_request_regions(a_priv->pci_device, DRV_NAME))
+ return -ENOMEM;
switch (a_priv->model) {
case MODEL_82350A:
a_priv->plx_base = ioremap(pci_resource_start(a_priv->pci_device, PLX_MEM_REGION),
pci_resource_len(a_priv->pci_device, PLX_MEM_REGION));
- dev_dbg(board->gpib_dev, "%s: plx base address remapped to 0x%p\n",
- driver_name, a_priv->plx_base);
+ dev_dbg(board->gpib_dev, "plx base address remapped to 0x%p\n", a_priv->plx_base);
a_priv->gpib_base = ioremap(pci_resource_start(a_priv->pci_device,
GPIB_82350A_REGION),
pci_resource_len(a_priv->pci_device,
GPIB_82350A_REGION));
- dev_dbg(board->gpib_dev, "%s: gpib base address remapped to 0x%p\n",
- driver_name, a_priv->gpib_base);
+ dev_dbg(board->gpib_dev, "chip base address remapped to 0x%p\n", a_priv->gpib_base);
tms_priv->mmiobase = a_priv->gpib_base + TMS9914_BASE_REG;
a_priv->sram_base = ioremap(pci_resource_start(a_priv->pci_device,
SRAM_82350A_REGION),
pci_resource_len(a_priv->pci_device,
SRAM_82350A_REGION));
- dev_dbg(board->gpib_dev, "%s: sram base address remapped to 0x%p\n",
- driver_name, a_priv->sram_base);
+ dev_dbg(board->gpib_dev, "sram base address remapped to 0x%p\n", a_priv->sram_base);
a_priv->borg_base = ioremap(pci_resource_start(a_priv->pci_device,
BORG_82350A_REGION),
pci_resource_len(a_priv->pci_device,
BORG_82350A_REGION));
- dev_dbg(board->gpib_dev, "%s: borg base address remapped to 0x%p\n",
- driver_name, a_priv->borg_base);
+ dev_dbg(board->gpib_dev, "borg base address remapped to 0x%p\n", a_priv->borg_base);
retval = init_82350a_hardware(board, config);
if (retval < 0)
@@ -719,21 +671,18 @@ static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_c
case MODEL_82351A:
a_priv->gpib_base = ioremap(pci_resource_start(a_priv->pci_device, GPIB_REGION),
pci_resource_len(a_priv->pci_device, GPIB_REGION));
- dev_dbg(board->gpib_dev, "%s: gpib base address remapped to 0x%p\n",
- driver_name, a_priv->gpib_base);
+ dev_dbg(board->gpib_dev, "chip base address remapped to 0x%p\n", a_priv->gpib_base);
tms_priv->mmiobase = a_priv->gpib_base + TMS9914_BASE_REG;
a_priv->sram_base = ioremap(pci_resource_start(a_priv->pci_device, SRAM_REGION),
pci_resource_len(a_priv->pci_device, SRAM_REGION));
- dev_dbg(board->gpib_dev, "%s: sram base address remapped to 0x%p\n",
- driver_name, a_priv->sram_base);
+ dev_dbg(board->gpib_dev, "sram base address remapped to 0x%p\n", a_priv->sram_base);
a_priv->misc_base = ioremap(pci_resource_start(a_priv->pci_device, MISC_REGION),
pci_resource_len(a_priv->pci_device, MISC_REGION));
- dev_dbg(board->gpib_dev, "%s: misc base address remapped to 0x%p\n",
- driver_name, a_priv->misc_base);
+ dev_dbg(board->gpib_dev, "misc base address remapped to 0x%p\n", a_priv->misc_base);
break;
default:
- pr_err("%s: invalid board\n", driver_name);
- return -1;
+ dev_err(board->gpib_dev, "invalid board\n");
+ return -ENODEV;
}
retval = test_sram(board);
@@ -741,12 +690,12 @@ static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_c
return retval;
if (request_irq(a_priv->pci_device->irq, agilent_82350b_interrupt,
- IRQF_SHARED, driver_name, board)) {
- pr_err("%s: can't request IRQ %d\n", driver_name, a_priv->pci_device->irq);
+ IRQF_SHARED, DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "failed to obtain irq %d\n", a_priv->pci_device->irq);
return -EIO;
}
a_priv->irq = a_priv->pci_device->irq;
- dev_dbg(board->gpib_dev, "%s: IRQ %d\n", driver_name, a_priv->irq);
+ dev_dbg(board->gpib_dev, " IRQ %d\n", a_priv->irq);
writeb(0, a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG);
a_priv->card_mode_bits = ENABLE_PCI_IRQ_BIT;
@@ -780,20 +729,19 @@ static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_c
return 0;
}
-int agilent_82350b_unaccel_attach(gpib_board_t *board, const gpib_board_config_t *config)
-
+static int agilent_82350b_unaccel_attach(struct gpib_board *board,
+ const gpib_board_config_t *config)
{
return agilent_82350b_generic_attach(board, config, 0);
}
-int agilent_82350b_accel_attach(gpib_board_t *board, const gpib_board_config_t *config)
-
+static int agilent_82350b_accel_attach(struct gpib_board *board,
+ const gpib_board_config_t *config)
{
return agilent_82350b_generic_attach(board, config, 1);
}
-void agilent_82350b_detach(gpib_board_t *board)
-
+static void agilent_82350b_detach(struct gpib_board *board)
{
struct agilent_82350b_priv *a_priv = board->private_data;
struct tms9914_priv *tms_priv;
@@ -848,6 +796,7 @@ static gpib_interface_t agilent_82350b_unaccel_interface = {
.primary_address = agilent_82350b_primary_address,
.secondary_address = agilent_82350b_secondary_address,
.serial_poll_response = agilent_82350b_serial_poll_response,
+ .serial_poll_status = agilent_82350b_serial_poll_status,
.t1_delay = agilent_82350b_t1_delay,
.return_to_local = agilent_82350b_return_to_local,
};
@@ -875,6 +824,7 @@ static gpib_interface_t agilent_82350b_interface = {
.primary_address = agilent_82350b_primary_address,
.secondary_address = agilent_82350b_secondary_address,
.serial_poll_response = agilent_82350b_serial_poll_response,
+ .serial_poll_status = agilent_82350b_serial_poll_status,
.t1_delay = agilent_82350b_t1_delay,
.return_to_local = agilent_82350b_return_to_local,
};
@@ -895,31 +845,30 @@ static const struct pci_device_id agilent_82350b_pci_table[] = {
MODULE_DEVICE_TABLE(pci, agilent_82350b_pci_table);
static struct pci_driver agilent_82350b_pci_driver = {
- .name = "agilent_82350b",
+ .name = DRV_NAME,
.id_table = agilent_82350b_pci_table,
.probe = &agilent_82350b_pci_probe
};
static int __init agilent_82350b_init_module(void)
-
{
int result;
result = pci_register_driver(&agilent_82350b_pci_driver);
if (result) {
- pr_err("agilent_82350b: pci_register_driver failed: error = %d\n", result);
+ pr_err("pci_register_driver failed: error = %d\n", result);
return result;
}
result = gpib_register_driver(&agilent_82350b_unaccel_interface, THIS_MODULE);
if (result) {
- pr_err("agilent_82350b: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_unaccel;
}
result = gpib_register_driver(&agilent_82350b_interface, THIS_MODULE);
if (result) {
- pr_err("agilent_82350b: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_interface;
}
@@ -934,7 +883,6 @@ err_unaccel:
}
static void __exit agilent_82350b_exit_module(void)
-
{
gpib_unregister_driver(&agilent_82350b_interface);
gpib_unregister_driver(&agilent_82350b_unaccel_interface);
diff --git a/drivers/staging/gpib/agilent_82350b/agilent_82350b.h b/drivers/staging/gpib/agilent_82350b/agilent_82350b.h
index 32b322113c10..1573230c619d 100644
--- a/drivers/staging/gpib/agilent_82350b/agilent_82350b.h
+++ b/drivers/staging/gpib/agilent_82350b/agilent_82350b.h
@@ -57,56 +57,6 @@ struct agilent_82350b_priv {
bool using_fifos;
};
-// driver name
-extern const char *driver_name;
-
-// init functions
-
-int agilent_82350b_unaccel_attach(gpib_board_t *board, const gpib_board_config_t *config);
-int agilent_82350b_accel_attach(gpib_board_t *board, const gpib_board_config_t *config);
-
-// interface functions
-int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read);
-int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written);
-int agilent_82350b_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read);
-int agilent_82350b_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written);
-int agilent_82350b_command(gpib_board_t *board, uint8_t *buffer, size_t length,
- size_t *bytes_written);
-int agilent_82350b_take_control(gpib_board_t *board, int synchronous);
-int agilent_82350b_go_to_standby(gpib_board_t *board);
-void agilent_82350b_request_system_control(gpib_board_t *board, int request_control);
-void agilent_82350b_interface_clear(gpib_board_t *board, int assert);
-void agilent_82350b_remote_enable(gpib_board_t *board, int enable);
-int agilent_82350b_enable_eos(gpib_board_t *board, uint8_t eos_byte, int
- compare_8_bits);
-void agilent_82350b_disable_eos(gpib_board_t *board);
-unsigned int agilent_82350b_update_status(gpib_board_t *board, unsigned int clear_mask);
-int agilent_82350b_primary_address(gpib_board_t *board, unsigned int address);
-int agilent_82350b_secondary_address(gpib_board_t *board, unsigned int address, int
- enable);
-int agilent_82350b_parallel_poll(gpib_board_t *board, uint8_t *result);
-void agilent_82350b_parallel_poll_configure(gpib_board_t *board, uint8_t config);
-void agilent_82350b_parallel_poll_response(gpib_board_t *board, int ist);
-void agilent_82350b_serial_poll_response(gpib_board_t *board, uint8_t status);
-void agilent_82350b_return_to_local(gpib_board_t *board);
-uint8_t agilent_82350b_serial_poll_status(gpib_board_t *board);
-int agilent_82350b_line_status(const gpib_board_t *board);
-unsigned int agilent_82350b_t1_delay(gpib_board_t *board, unsigned int nanosec);
-
-// interrupt service routines
-irqreturn_t agilent_82350b_interrupt(int irq, void *arg);
-
-// utility functions
-int agilent_82350b_allocate_private(gpib_board_t *board);
-void agilent_82350b_free_private(gpib_board_t *board);
-unsigned short read_and_clear_event_status(gpib_board_t *board);
-int read_transfer_counter(struct agilent_82350b_priv *a_priv);
-void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count);
-
//registers
enum agilent_82350b_gpib_registers
diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
index 69f0e490d401..67bf125645c0 100644
--- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
+++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
@@ -7,6 +7,10 @@
#define _GNU_SOURCE
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -21,9 +25,10 @@ MODULE_DESCRIPTION("GPIB driver for Agilent 82357A/B usb adapters");
static struct usb_interface *agilent_82357a_driver_interfaces[MAX_NUM_82357A_INTERFACES];
static DEFINE_MUTEX(agilent_82357a_hotplug_lock); // protect board insertion and removal
-static unsigned int agilent_82357a_update_status(gpib_board_t *board, unsigned int clear_mask);
+static unsigned int agilent_82357a_update_status(struct gpib_board *board,
+ unsigned int clear_mask);
-static int agilent_82357a_take_control_internal(gpib_board_t *board, int synchronous);
+static int agilent_82357a_take_control_internal(struct gpib_board *board, int synchronous);
static void agilent_82357a_bulk_complete(struct urb *urb)
{
@@ -79,14 +84,12 @@ static int agilent_82357a_send_bulk_msg(struct agilent_82357a_priv *a_priv, void
retval = usb_submit_urb(a_priv->bulk_urb, GFP_KERNEL);
if (retval) {
- dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to submit bulk out urb, retval=%i\n", retval);
mutex_unlock(&a_priv->bulk_alloc_lock);
goto cleanup;
}
mutex_unlock(&a_priv->bulk_alloc_lock);
if (down_interruptible(&context->complete)) {
- dev_err(&usb_dev->dev, "%s: interrupted\n", __func__);
retval = -ERESTARTSYS;
goto cleanup;
}
@@ -149,14 +152,12 @@ static int agilent_82357a_receive_bulk_msg(struct agilent_82357a_priv *a_priv, v
retval = usb_submit_urb(a_priv->bulk_urb, GFP_KERNEL);
if (retval) {
- dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to submit bulk in urb, retval=%i\n", retval);
mutex_unlock(&a_priv->bulk_alloc_lock);
goto cleanup;
}
mutex_unlock(&a_priv->bulk_alloc_lock);
if (down_interruptible(&context->complete)) {
- dev_err(&usb_dev->dev, "%s: interrupted\n", __func__);
retval = -ERESTARTSYS;
goto cleanup;
}
@@ -205,7 +206,6 @@ static int agilent_82357a_receive_control_msg(struct agilent_82357a_priv *a_priv
static void agilent_82357a_dump_raw_block(const u8 *raw_data, int length)
{
- pr_info("hex block dump\n");
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 8, 1, raw_data, length, true);
}
@@ -225,7 +225,7 @@ static int agilent_82357a_write_registers(struct agilent_82357a_priv *a_priv,
static const int max_writes = 31;
if (num_writes > max_writes) {
- dev_err(&usb_dev->dev, "%s: bug! num_writes=%i too large\n", __func__, num_writes);
+ dev_err(&usb_dev->dev, "bug! num_writes=%i too large\n", num_writes);
return -EIO;
}
out_data_length = num_writes * bytes_per_write + header_length;
@@ -239,8 +239,7 @@ static int agilent_82357a_write_registers(struct agilent_82357a_priv *a_priv,
out_data[i++] = writes[j].address;
out_data[i++] = writes[j].value;
}
- if (i > out_data_length)
- dev_err(&usb_dev->dev, "%s: bug! buffer overrun\n", __func__);
+
retval = mutex_lock_interruptible(&a_priv->bulk_transfer_lock);
if (retval) {
kfree(out_data);
@@ -249,8 +248,8 @@ static int agilent_82357a_write_registers(struct agilent_82357a_priv *a_priv,
retval = agilent_82357a_send_bulk_msg(a_priv, out_data, i, &bytes_written, 1000);
kfree(out_data);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
mutex_unlock(&a_priv->bulk_transfer_lock);
return retval;
}
@@ -265,20 +264,19 @@ static int agilent_82357a_write_registers(struct agilent_82357a_priv *a_priv,
mutex_unlock(&a_priv->bulk_transfer_lock);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
agilent_82357a_dump_raw_block(in_data, bytes_read);
kfree(in_data);
return -EIO;
}
if (in_data[0] != (0xff & ~DATA_PIPE_CMD_WR_REGS)) {
- dev_err(&usb_dev->dev, "%s: error, bulk command=0x%x != ~DATA_PIPE_CMD_WR_REGS\n",
- __func__, in_data[0]);
+ dev_err(&usb_dev->dev, "bulk command=0x%x != ~DATA_PIPE_CMD_WR_REGS\n", in_data[0]);
return -EIO;
}
if (in_data[1]) {
- dev_err(&usb_dev->dev, "%s: nonzero error code 0x%x in DATA_PIPE_CMD_WR_REGS response\n",
- __func__, in_data[1]);
+ dev_err(&usb_dev->dev, "nonzero error code 0x%x in DATA_PIPE_CMD_WR_REGS response\n",
+ in_data[1]);
return -EIO;
}
kfree(in_data);
@@ -299,9 +297,10 @@ static int agilent_82357a_read_registers(struct agilent_82357a_priv *a_priv,
static const int header_length = 2;
static const int max_reads = 62;
- if (num_reads > max_reads)
- dev_err(&usb_dev->dev, "%s: bug! num_reads=%i too large\n", __func__, num_reads);
-
+ if (num_reads > max_reads) {
+ dev_err(&usb_dev->dev, "bug! num_reads=%i too large\n", num_reads);
+ return -EIO;
+ }
out_data_length = num_reads + header_length;
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
@@ -311,8 +310,7 @@ static int agilent_82357a_read_registers(struct agilent_82357a_priv *a_priv,
out_data[i++] = num_reads;
for (j = 0; j < num_reads; j++)
out_data[i++] = reads[j].address;
- if (i > out_data_length)
- dev_err(&usb_dev->dev, "%s: bug! buffer overrun\n", __func__);
+
if (blocking) {
retval = mutex_lock_interruptible(&a_priv->bulk_transfer_lock);
if (retval) {
@@ -329,8 +327,8 @@ static int agilent_82357a_read_registers(struct agilent_82357a_priv *a_priv,
retval = agilent_82357a_send_bulk_msg(a_priv, out_data, i, &bytes_written, 1000);
kfree(out_data);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
mutex_unlock(&a_priv->bulk_transfer_lock);
return retval;
}
@@ -345,21 +343,20 @@ static int agilent_82357a_read_registers(struct agilent_82357a_priv *a_priv,
mutex_unlock(&a_priv->bulk_transfer_lock);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
agilent_82357a_dump_raw_block(in_data, bytes_read);
kfree(in_data);
return -EIO;
}
i = 0;
if (in_data[i++] != (0xff & ~DATA_PIPE_CMD_RD_REGS)) {
- dev_err(&usb_dev->dev, "%s: error, bulk command=0x%x != ~DATA_PIPE_CMD_RD_REGS\n",
- __func__, in_data[0]);
+ dev_err(&usb_dev->dev, "bulk command=0x%x != ~DATA_PIPE_CMD_RD_REGS\n", in_data[0]);
return -EIO;
}
if (in_data[i++]) {
- dev_err(&usb_dev->dev, "%s: nonzero error code 0x%x in DATA_PIPE_CMD_RD_REGS response\n",
- __func__, in_data[1]);
+ dev_err(&usb_dev->dev, "nonzero error code 0x%x in DATA_PIPE_CMD_RD_REGS response\n",
+ in_data[1]);
return -EIO;
}
for (j = 0; j < num_reads; j++)
@@ -390,14 +387,13 @@ static int agilent_82357a_abort(struct agilent_82357a_priv *a_priv, int flush)
wIndex, status_data,
status_data_len, 100);
if (receive_control_retval < 0) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_control_msg() returned %i\n",
- __func__, receive_control_retval);
+ dev_err(&usb_dev->dev, "82357a_receive_control_msg() returned %i\n",
+ receive_control_retval);
retval = -EIO;
goto cleanup;
}
if (status_data[0] != (~XFER_ABORT & 0xff)) {
- dev_err(&usb_dev->dev, "%s: error, major code=0x%x != ~XFER_ABORT\n",
- __func__, status_data[0]);
+ dev_err(&usb_dev->dev, "major code=0x%x != ~XFER_ABORT\n", status_data[0]);
retval = -EIO;
goto cleanup;
}
@@ -413,8 +409,7 @@ static int agilent_82357a_abort(struct agilent_82357a_priv *a_priv, int flush)
fallthrough;
case UGP_ERR_FLUSHING_ALREADY:
default:
- dev_err(&usb_dev->dev, "%s: abort returned error code=0x%x\n",
- __func__, status_data[1]);
+ dev_err(&usb_dev->dev, "abort returned error code=0x%x\n", status_data[1]);
retval = -EIO;
break;
}
@@ -425,15 +420,15 @@ cleanup:
}
// interface functions
-int agilent_82357a_command(gpib_board_t *board, uint8_t *buffer, size_t length,
+int agilent_82357a_command(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *bytes_written);
-static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
+static int agilent_82357a_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
size_t *nbytes)
{
int retval;
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
int out_data_length, in_data_length;
int bytes_written, bytes_read;
@@ -444,6 +439,10 @@ static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t leng
*nbytes = 0;
*end = 0;
+
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
out_data_length = 0x9;
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
@@ -469,8 +468,8 @@ static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t leng
retval = agilent_82357a_send_bulk_msg(a_priv, out_data, i, &bytes_written, msec_timeout);
kfree(out_data);
if (retval || bytes_written != i) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
mutex_unlock(&a_priv->bulk_transfer_lock);
if (retval < 0)
return retval;
@@ -501,19 +500,19 @@ static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t leng
&extra_bytes_read, 100);
bytes_read += extra_bytes_read;
if (extra_bytes_retval) {
- dev_err(&usb_dev->dev, "%s: extra_bytes_retval=%i, bytes_read=%i\n",
- __func__, extra_bytes_retval, bytes_read);
+ dev_err(&usb_dev->dev, "extra_bytes_retval=%i, bytes_read=%i\n",
+ extra_bytes_retval, bytes_read);
agilent_82357a_abort(a_priv, 0);
}
} else if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
agilent_82357a_abort(a_priv, 0);
}
mutex_unlock(&a_priv->bulk_transfer_lock);
if (bytes_read > length + 1) {
bytes_read = length + 1;
- pr_warn("%s: bytes_read > length? truncating", __func__);
+ dev_warn(&usb_dev->dev, "bytes_read > length? truncating");
}
if (bytes_read >= 1) {
@@ -535,12 +534,14 @@ static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t leng
return retval;
}
-static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_commands, int send_eoi, size_t *bytes_written)
+static ssize_t agilent_82357a_generic_write(struct gpib_board *board,
+ uint8_t *buffer, size_t length,
+ int send_commands, int send_eoi,
+ size_t *bytes_written)
{
int retval;
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data = NULL;
u8 *status_data = NULL;
int out_data_length;
@@ -551,6 +552,10 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
struct agilent_82357a_register_pairlet read_reg;
*bytes_written = 0;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
out_data_length = length + 0x8;
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
@@ -584,8 +589,8 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
kfree(out_data);
if (retval || raw_bytes_written != i) {
agilent_82357a_abort(a_priv, 0);
- dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, raw_bytes_written=%i, i=%i\n",
- __func__, retval, raw_bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, raw_bytes_written=%i, i=%i\n",
+ retval, raw_bytes_written, i);
mutex_unlock(&a_priv->bulk_transfer_lock);
if (retval < 0)
return retval;
@@ -597,7 +602,7 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
&a_priv->interrupt_flags) ||
test_bit(TIMO_NUM, &board->status));
if (retval) {
- dev_err(&usb_dev->dev, "%s: wait write complete interrupted\n", __func__);
+ dev_dbg(&usb_dev->dev, "wait write complete interrupted\n");
agilent_82357a_abort(a_priv, 0);
mutex_unlock(&a_priv->bulk_transfer_lock);
return -ERESTARTSYS;
@@ -614,8 +619,7 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
read_reg.address = BSR;
retval = agilent_82357a_read_registers(a_priv, &read_reg, 1, 1);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "read_registers() returned error\n");
return -ETIMEDOUT;
}
@@ -632,8 +636,7 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
read_reg.address = ADSR;
retval = agilent_82357a_read_registers(a_priv, &read_reg, 1, 1);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "read_registers() returned error\n");
return -ETIMEDOUT;
}
adsr = read_reg.value;
@@ -659,8 +662,7 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
100);
mutex_unlock(&a_priv->bulk_transfer_lock);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_control_msg() returned %i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "receive_control_msg() returned %i\n", retval);
kfree(status_data);
return -EIO;
}
@@ -673,19 +675,19 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
return 0;
}
-static int agilent_82357a_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written)
+static int agilent_82357a_write(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int send_eoi, size_t *bytes_written)
{
return agilent_82357a_generic_write(board, buffer, length, 0, send_eoi, bytes_written);
}
-int agilent_82357a_command(gpib_board_t *board, uint8_t *buffer, size_t length,
+int agilent_82357a_command(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *bytes_written)
{
return agilent_82357a_generic_write(board, buffer, length, 1, 0, bytes_written);
}
-int agilent_82357a_take_control_internal(gpib_board_t *board, int synchronous)
+int agilent_82357a_take_control_internal(struct gpib_board *board, int synchronous)
{
struct agilent_82357a_priv *a_priv = board->private_data;
struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
@@ -699,17 +701,20 @@ int agilent_82357a_take_control_internal(gpib_board_t *board, int synchronous)
write.value = AUX_TCA;
retval = agilent_82357a_write_registers(a_priv, &write, 1);
if (retval)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return retval;
}
-static int agilent_82357a_take_control(gpib_board_t *board, int synchronous)
+static int agilent_82357a_take_control(struct gpib_board *board, int synchronous)
{
+ struct agilent_82357a_priv *a_priv = board->private_data;
const int timeout = 10;
int i;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+
/* It looks like the 9914 does not handle tcs properly.
* See comment above tms9914_take_control_workaround() in
* drivers/gpib/tms9914/tms9914_aux.c
@@ -730,31 +735,39 @@ static int agilent_82357a_take_control(gpib_board_t *board, int synchronous)
return 0;
}
-static int agilent_82357a_go_to_standby(gpib_board_t *board)
+static int agilent_82357a_go_to_standby(struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet write;
int retval;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
write.address = AUXCR;
write.value = AUX_GTS;
retval = agilent_82357a_write_registers(a_priv, &write, 1);
if (retval)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return 0;
}
//FIXME should change prototype to return int
-static void agilent_82357a_request_system_control(gpib_board_t *board, int request_control)
+static void agilent_82357a_request_system_control(struct gpib_board *board,
+ int request_control)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet writes[2];
int retval;
int i = 0;
+ if (!a_priv->bus_interface)
+ return; // -ENODEV;
+
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
/* 82357B needs bit to be set in 9914 AUXCR register */
writes[i].address = AUXCR;
if (request_control) {
@@ -771,18 +784,21 @@ static void agilent_82357a_request_system_control(gpib_board_t *board, int reque
++i;
retval = agilent_82357a_write_registers(a_priv, writes, i);
if (retval)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return;// retval;
}
-static void agilent_82357a_interface_clear(gpib_board_t *board, int assert)
+static void agilent_82357a_interface_clear(struct gpib_board *board, int assert)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet write;
int retval;
+ if (!a_priv->bus_interface)
+ return; // -ENODEV;
+
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
write.address = AUXCR;
write.value = AUX_SIC;
if (assert) {
@@ -791,56 +807,64 @@ static void agilent_82357a_interface_clear(gpib_board_t *board, int assert)
}
retval = agilent_82357a_write_registers(a_priv, &write, 1);
if (retval)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
}
-static void agilent_82357a_remote_enable(gpib_board_t *board, int enable)
+static void agilent_82357a_remote_enable(struct gpib_board *board, int enable)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet write;
int retval;
+ if (!a_priv->bus_interface)
+ return; //-ENODEV;
+
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
write.address = AUXCR;
write.value = AUX_SRE;
if (enable)
write.value |= AUX_CS;
retval = agilent_82357a_write_registers(a_priv, &write, 1);
if (retval)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
a_priv->ren_state = enable;
return;// 0;
}
-static int agilent_82357a_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int agilent_82357a_enable_eos(struct gpib_board *board, uint8_t eos_byte,
+ int compare_8_bits)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- if (compare_8_bits == 0) {
- pr_warn("%s: hardware only supports 8-bit EOS compare", __func__);
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+ if (compare_8_bits == 0)
return -EOPNOTSUPP;
- }
+
a_priv->eos_char = eos_byte;
a_priv->eos_mode = REOS | BIN;
return 0;
}
-static void agilent_82357a_disable_eos(gpib_board_t *board)
+static void agilent_82357a_disable_eos(struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv = board->private_data;
a_priv->eos_mode &= ~REOS;
}
-static unsigned int agilent_82357a_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int agilent_82357a_update_status(struct gpib_board *board,
+ unsigned int clear_mask)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet address_status, bus_status;
int retval;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
board->status &= ~clear_mask;
if (a_priv->is_cic)
set_bit(CIC_NUM, &board->status);
@@ -850,8 +874,7 @@ static unsigned int agilent_82357a_update_status(gpib_board_t *board, unsigned i
retval = agilent_82357a_read_registers(a_priv, &address_status, 1, 0);
if (retval) {
if (retval != -EAGAIN)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "read_registers() returned error\n");
return board->status;
}
// check for remote/local
@@ -883,8 +906,7 @@ static unsigned int agilent_82357a_update_status(gpib_board_t *board, unsigned i
retval = agilent_82357a_read_registers(a_priv, &bus_status, 1, 0);
if (retval) {
if (retval != -EAGAIN)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "read_registers() returned error\n");
return board->status;
}
if (bus_status.value & BSR_SRQ_BIT)
@@ -895,40 +917,46 @@ static unsigned int agilent_82357a_update_status(gpib_board_t *board, unsigned i
return board->status;
}
-static int agilent_82357a_primary_address(gpib_board_t *board, unsigned int address)
+static int agilent_82357a_primary_address(struct gpib_board *board, unsigned int address)
{
struct agilent_82357a_priv *a_priv = board->private_data;
struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
struct agilent_82357a_register_pairlet write;
int retval;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
// put primary address in address0
write.address = ADR;
write.value = address & ADDRESS_MASK;
retval = agilent_82357a_write_registers(a_priv, &write, 1);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return retval;
}
return retval;
}
-static int agilent_82357a_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int agilent_82357a_secondary_address(struct gpib_board *board,
+ unsigned int address, int enable)
{
if (enable)
- pr_warn("%s: warning: assigning a secondary address not supported\n", __func__);
- return -EOPNOTSUPP;
+ return -EOPNOTSUPP;
+ return 0;
}
-static int agilent_82357a_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int agilent_82357a_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet writes[2];
struct agilent_82357a_register_pairlet read;
int retval;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
// execute parallel poll
writes[0].address = AUXCR;
writes[0].value = AUX_CS | AUX_RPP;
@@ -936,16 +964,14 @@ static int agilent_82357a_parallel_poll(gpib_board_t *board, uint8_t *result)
writes[1].value = a_priv->hw_control_bits & ~NOT_PARALLEL_POLL;
retval = agilent_82357a_write_registers(a_priv, writes, 2);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return retval;
}
udelay(2); //silly, since usb write will take way longer
read.address = CPTR;
retval = agilent_82357a_read_registers(a_priv, &read, 1, 1);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "read_registers() returned error\n");
return retval;
}
*result = read.value;
@@ -956,75 +982,76 @@ static int agilent_82357a_parallel_poll(gpib_board_t *board, uint8_t *result)
writes[1].value = AUX_RPP;
retval = agilent_82357a_write_registers(a_priv, writes, 2);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return retval;
}
return 0;
}
-static void agilent_82357a_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void agilent_82357a_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
//board can only be system controller
return;// 0;
}
-static void agilent_82357a_parallel_poll_response(gpib_board_t *board, int ist)
+static void agilent_82357a_parallel_poll_response(struct gpib_board *board, int ist)
{
//board can only be system controller
return;// 0;
}
-static void agilent_82357a_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void agilent_82357a_serial_poll_response(struct gpib_board *board, uint8_t status)
{
//board can only be system controller
return;// 0;
}
-static uint8_t agilent_82357a_serial_poll_status(gpib_board_t *board)
+static uint8_t agilent_82357a_serial_poll_status(struct gpib_board *board)
{
//board can only be system controller
return 0;
}
-static void agilent_82357a_return_to_local(gpib_board_t *board)
+static void agilent_82357a_return_to_local(struct gpib_board *board)
{
//board can only be system controller
return;// 0;
}
-static int agilent_82357a_line_status(const gpib_board_t *board)
+static int agilent_82357a_line_status(const struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet bus_status;
int retval;
- int status = ValidALL;
+ int status = VALID_ALL;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
bus_status.address = BSR;
retval = agilent_82357a_read_registers(a_priv, &bus_status, 1, 0);
if (retval) {
if (retval != -EAGAIN)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "read_registers() returned error\n");
return retval;
}
if (bus_status.value & BSR_REN_BIT)
- status |= BusREN;
+ status |= BUS_REN;
if (bus_status.value & BSR_IFC_BIT)
- status |= BusIFC;
+ status |= BUS_IFC;
if (bus_status.value & BSR_SRQ_BIT)
- status |= BusSRQ;
+ status |= BUS_SRQ;
if (bus_status.value & BSR_EOI_BIT)
- status |= BusEOI;
+ status |= BUS_EOI;
if (bus_status.value & BSR_NRFD_BIT)
- status |= BusNRFD;
+ status |= BUS_NRFD;
if (bus_status.value & BSR_NDAC_BIT)
- status |= BusNDAC;
+ status |= BUS_NDAC;
if (bus_status.value & BSR_DAV_BIT)
- status |= BusDAV;
+ status |= BUS_DAV;
if (bus_status.value & BSR_ATN_BIT)
- status |= BusATN;
+ status |= BUS_ATN;
return status;
}
@@ -1044,25 +1071,27 @@ static unsigned short nanosec_to_fast_talker_bits(unsigned int *nanosec)
return bits;
}
-static unsigned int agilent_82357a_t1_delay(gpib_board_t *board, unsigned int nanosec)
+static int agilent_82357a_t1_delay(struct gpib_board *board, unsigned int nanosec)
{
struct agilent_82357a_priv *a_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
+ struct usb_device *usb_dev;
struct agilent_82357a_register_pairlet write;
int retval;
+ if (!a_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(a_priv->bus_interface);
write.address = FAST_TALKER_T1;
write.value = nanosec_to_fast_talker_bits(&nanosec);
retval = agilent_82357a_write_registers(a_priv, &write, 1);
if (retval)
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return nanosec;
}
static void agilent_82357a_interrupt_complete(struct urb *urb)
{
- gpib_board_t *board = urb->context;
+ struct gpib_board *board = urb->context;
struct agilent_82357a_priv *a_priv = board->private_data;
struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
int retval;
@@ -1081,7 +1110,7 @@ static void agilent_82357a_interrupt_complete(struct urb *urb)
default: /* other error, resubmit */
retval = usb_submit_urb(a_priv->interrupt_urb, GFP_ATOMIC);
if (retval)
- dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__);
+ dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n");
return;
}
@@ -1097,10 +1126,10 @@ static void agilent_82357a_interrupt_complete(struct urb *urb)
retval = usb_submit_urb(a_priv->interrupt_urb, GFP_ATOMIC);
if (retval)
- dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__);
+ dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n");
}
-static int agilent_82357a_setup_urbs(gpib_board_t *board)
+static int agilent_82357a_setup_urbs(struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv = board->private_data;
struct usb_device *usb_dev;
@@ -1133,8 +1162,7 @@ static int agilent_82357a_setup_urbs(gpib_board_t *board)
if (retval) {
usb_free_urb(a_priv->interrupt_urb);
a_priv->interrupt_urb = NULL;
- dev_err(&usb_dev->dev, "%s: failed to submit first interrupt urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to submit first interrupt urb, retval=%i\n", retval);
goto setup_exit;
}
mutex_unlock(&a_priv->interrupt_alloc_lock);
@@ -1165,7 +1193,7 @@ static void agilent_82357a_release_urbs(struct agilent_82357a_priv *a_priv)
}
}
-static int agilent_82357a_allocate_private(gpib_board_t *board)
+static int agilent_82357a_allocate_private(struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv;
@@ -1180,112 +1208,82 @@ static int agilent_82357a_allocate_private(gpib_board_t *board)
return 0;
}
-static void agilent_82357a_free_private(gpib_board_t *board)
+static void agilent_82357a_free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
-
}
-static int agilent_82357a_init(gpib_board_t *board)
+#define INIT_NUM_REG_WRITES 18
+static int agilent_82357a_init(struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv = board->private_data;
struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
struct agilent_82357a_register_pairlet hw_control;
- struct agilent_82357a_register_pairlet writes[0x20];
+ struct agilent_82357a_register_pairlet writes[INIT_NUM_REG_WRITES];
int retval;
- int i;
unsigned int nanosec;
- i = 0;
- writes[i].address = LED_CONTROL;
- writes[i].value = FAIL_LED_ON;
- ++i;
- writes[i].address = RESET_TO_POWERUP;
- writes[i].value = RESET_SPACEBALL;
- ++i;
- retval = agilent_82357a_write_registers(a_priv, writes, i);
+ writes[0].address = LED_CONTROL;
+ writes[0].value = FAIL_LED_ON;
+ writes[1].address = RESET_TO_POWERUP;
+ writes[1].value = RESET_SPACEBALL;
+ retval = agilent_82357a_write_registers(a_priv, writes, 2);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return -EIO;
}
set_current_state(TASK_INTERRUPTIBLE);
if (schedule_timeout(usec_to_jiffies(2000)))
return -ERESTARTSYS;
- i = 0;
- writes[i].address = AUXCR;
- writes[i].value = AUX_NBAF;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_HLDE;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_TON;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_LON;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_RSV2;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_INVAL;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_RPP;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_STDL;
- ++i;
- writes[i].address = AUXCR;
- writes[i].value = AUX_VSTDL;
- ++i;
- writes[i].address = FAST_TALKER_T1;
+ writes[0].address = AUXCR;
+ writes[0].value = AUX_NBAF;
+ writes[1].address = AUXCR;
+ writes[1].value = AUX_HLDE;
+ writes[2].address = AUXCR;
+ writes[2].value = AUX_TON;
+ writes[3].address = AUXCR;
+ writes[3].value = AUX_LON;
+ writes[4].address = AUXCR;
+ writes[4].value = AUX_RSV2;
+ writes[5].address = AUXCR;
+ writes[5].value = AUX_INVAL;
+ writes[6].address = AUXCR;
+ writes[6].value = AUX_RPP;
+ writes[7].address = AUXCR;
+ writes[7].value = AUX_STDL;
+ writes[8].address = AUXCR;
+ writes[8].value = AUX_VSTDL;
+ writes[9].address = FAST_TALKER_T1;
nanosec = board->t1_nano_sec;
- writes[i].value = nanosec_to_fast_talker_bits(&nanosec);
+ writes[9].value = nanosec_to_fast_talker_bits(&nanosec);
board->t1_nano_sec = nanosec;
- ++i;
- writes[i].address = ADR;
- writes[i].value = board->pad & ADDRESS_MASK;
- ++i;
- writes[i].address = PPR;
- writes[i].value = 0;
- ++i;
- writes[i].address = SPMR;
- writes[i].value = 0;
- ++i;
- writes[i].address = PROTOCOL_CONTROL;
- writes[i].value = WRITE_COMPLETE_INTERRUPT_EN;
- ++i;
- writes[i].address = IMR0;
- writes[i].value = HR_BOIE | HR_BIIE;
- ++i;
- writes[i].address = IMR1;
- writes[i].value = HR_SRQIE;
- ++i;
+ writes[10].address = ADR;
+ writes[10].value = board->pad & ADDRESS_MASK;
+ writes[11].address = PPR;
+ writes[11].value = 0;
+ writes[12].address = SPMR;
+ writes[12].value = 0;
+ writes[13].address = PROTOCOL_CONTROL;
+ writes[13].value = WRITE_COMPLETE_INTERRUPT_EN;
+ writes[14].address = IMR0;
+ writes[14].value = HR_BOIE | HR_BIIE;
+ writes[15].address = IMR1;
+ writes[15].value = HR_SRQIE;
// turn off reset state
- writes[i].address = AUXCR;
- writes[i].value = AUX_CHIP_RESET;
- ++i;
- writes[i].address = LED_CONTROL;
- writes[i].value = FIRMWARE_LED_CONTROL;
- ++i;
- if (i > ARRAY_SIZE(writes)) {
- dev_err(&usb_dev->dev, "%s: bug! writes[] overflow\n", __func__);
- return -EFAULT;
- }
- retval = agilent_82357a_write_registers(a_priv, writes, i);
+ writes[16].address = AUXCR;
+ writes[16].value = AUX_CHIP_RESET;
+ writes[17].address = LED_CONTROL;
+ writes[17].value = FIRMWARE_LED_CONTROL;
+ retval = agilent_82357a_write_registers(a_priv, writes, INIT_NUM_REG_WRITES);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return -EIO;
}
hw_control.address = HW_CONTROL;
retval = agilent_82357a_read_registers(a_priv, &hw_control, 1, 1);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "read_registers() returned error\n");
return -EIO;
}
a_priv->hw_control_bits = (hw_control.value & ~0x7) | NOT_TI_RESET | NOT_PARALLEL_POLL;
@@ -1307,7 +1305,7 @@ static inline int agilent_82357a_device_match(struct usb_interface *interface,
return 1;
}
-static int agilent_82357a_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int agilent_82357a_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
int retval;
int i;
@@ -1336,7 +1334,7 @@ static int agilent_82357a_attach(gpib_board_t *board, const gpib_board_config_t
}
if (i == MAX_NUM_82357A_INTERFACES) {
dev_err(board->gpib_dev,
- "No Agilent 82357 gpib adapters found, have you loaded its firmware?\n");
+ "No supported adapters found, have you loaded its firmware?\n");
retval = -ENODEV;
goto attach_fail;
}
@@ -1372,8 +1370,7 @@ static int agilent_82357a_attach(gpib_board_t *board, const gpib_board_config_t
goto attach_fail;
}
- dev_info(&usb_dev->dev,
- "bus %d dev num %d attached to gpib minor %d, agilent usb interface %i\n",
+ dev_info(&usb_dev->dev, "bus %d dev num %d attached to gpib%d, interface %i\n",
usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
mutex_unlock(&agilent_82357a_hotplug_lock);
return retval;
@@ -1384,49 +1381,36 @@ attach_fail:
return retval;
}
-static int agilent_82357a_go_idle(gpib_board_t *board)
+static int agilent_82357a_go_idle(struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv = board->private_data;
struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface);
struct agilent_82357a_register_pairlet writes[0x20];
int retval;
- int i;
- i = 0;
// turn on tms9914 reset state
- writes[i].address = AUXCR;
- writes[i].value = AUX_CS | AUX_CHIP_RESET;
- ++i;
+ writes[0].address = AUXCR;
+ writes[0].value = AUX_CS | AUX_CHIP_RESET;
a_priv->hw_control_bits &= ~NOT_TI_RESET;
- writes[i].address = HW_CONTROL;
- writes[i].value = a_priv->hw_control_bits;
- ++i;
- writes[i].address = PROTOCOL_CONTROL;
- writes[i].value = 0;
- ++i;
- writes[i].address = IMR0;
- writes[i].value = 0;
- ++i;
- writes[i].address = IMR1;
- writes[i].value = 0;
- ++i;
- writes[i].address = LED_CONTROL;
- writes[i].value = 0;
- ++i;
- if (i > ARRAY_SIZE(writes)) {
- dev_err(&usb_dev->dev, "%s: bug! writes[] overflow\n", __func__);
- return -EFAULT;
- }
- retval = agilent_82357a_write_registers(a_priv, writes, i);
+ writes[1].address = HW_CONTROL;
+ writes[1].value = a_priv->hw_control_bits;
+ writes[2].address = PROTOCOL_CONTROL;
+ writes[2].value = 0;
+ writes[3].address = IMR0;
+ writes[3].value = 0;
+ writes[4].address = IMR1;
+ writes[4].value = 0;
+ writes[5].address = LED_CONTROL;
+ writes[5].value = 0;
+ retval = agilent_82357a_write_registers(a_priv, writes, 6);
if (retval) {
- dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n",
- __func__);
+ dev_err(&usb_dev->dev, "write_registers() returned error\n");
return -EIO;
}
return 0;
}
-static void agilent_82357a_detach(gpib_board_t *board)
+static void agilent_82357a_detach(struct gpib_board *board)
{
struct agilent_82357a_priv *a_priv;
@@ -1445,7 +1429,6 @@ static void agilent_82357a_detach(gpib_board_t *board)
agilent_82357a_release_urbs(a_priv);
agilent_82357a_free_private(board);
}
- dev_info(board->gpib_dev, "%s: detached\n", __func__);
mutex_unlock(&agilent_82357a_hotplug_lock);
}
@@ -1510,8 +1493,7 @@ static int agilent_82357a_driver_probe(struct usb_interface *interface,
if (i == MAX_NUM_82357A_INTERFACES) {
usb_put_dev(usb_dev);
mutex_unlock(&agilent_82357a_hotplug_lock);
- dev_err(&usb_dev->dev, "%s: out of space in agilent_82357a_driver_interfaces[]\n",
- __func__);
+ dev_err(&usb_dev->dev, "out of space in agilent_82357a_driver_interfaces[]\n");
return -1;
}
path = kmalloc(path_length, GFP_KERNEL);
@@ -1536,7 +1518,7 @@ static void agilent_82357a_driver_disconnect(struct usb_interface *interface)
for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i) {
if (agilent_82357a_driver_interfaces[i] == interface) {
- gpib_board_t *board = usb_get_intfdata(interface);
+ struct gpib_board *board = usb_get_intfdata(interface);
if (board) {
struct agilent_82357a_priv *a_priv = board->private_data;
@@ -1552,13 +1534,12 @@ static void agilent_82357a_driver_disconnect(struct usb_interface *interface)
mutex_unlock(&a_priv->control_alloc_lock);
}
}
- dev_dbg(&usb_dev->dev, "nulled agilent_82357a_driver_interfaces[%i]\n", i);
agilent_82357a_driver_interfaces[i] = NULL;
break;
}
}
if (i == MAX_NUM_82357A_INTERFACES)
- dev_err(&usb_dev->dev, "unable to find interface in agilent_82357a_driver_interfaces[]? bug?\n");
+ dev_err(&usb_dev->dev, "unable to find interface - bug?\n");
usb_put_dev(usb_dev);
mutex_unlock(&agilent_82357a_hotplug_lock);
@@ -1573,7 +1554,7 @@ static int agilent_82357a_driver_suspend(struct usb_interface *interface, pm_mes
for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i) {
if (agilent_82357a_driver_interfaces[i] == interface) {
- gpib_board_t *board = usb_get_intfdata(interface);
+ struct gpib_board *board = usb_get_intfdata(interface);
if (board) {
struct agilent_82357a_priv *a_priv = board->private_data;
@@ -1583,18 +1564,18 @@ static int agilent_82357a_driver_suspend(struct usb_interface *interface, pm_mes
agilent_82357a_abort(a_priv, 0);
retval = agilent_82357a_go_idle(board);
if (retval) {
- dev_err(&usb_dev->dev, "%s: failed to go idle, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to go idle, retval=%i\n",
+ retval);
mutex_unlock(&agilent_82357a_hotplug_lock);
return retval;
}
mutex_lock(&a_priv->interrupt_alloc_lock);
agilent_82357a_cleanup_urbs(a_priv);
mutex_unlock(&a_priv->interrupt_alloc_lock);
- dev_info(&usb_dev->dev,
- "bus %d dev num %d gpib minor %d, agilent usb interface %i suspended\n",
- usb_dev->bus->busnum, usb_dev->devnum,
- board->minor, i);
+ dev_dbg(&usb_dev->dev,
+ "bus %d dev num %d gpib %d, interface %i suspended\n",
+ usb_dev->bus->busnum, usb_dev->devnum,
+ board->minor, i);
}
}
break;
@@ -1609,7 +1590,7 @@ static int agilent_82357a_driver_suspend(struct usb_interface *interface, pm_mes
static int agilent_82357a_driver_resume(struct usb_interface *interface)
{
struct usb_device *usb_dev = interface_to_usbdev(interface);
- gpib_board_t *board;
+ struct gpib_board *board;
int i, retval;
mutex_lock(&agilent_82357a_hotplug_lock);
@@ -1631,8 +1612,8 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)
mutex_lock(&a_priv->interrupt_alloc_lock);
retval = usb_submit_urb(a_priv->interrupt_urb, GFP_KERNEL);
if (retval) {
- dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to resubmit interrupt urb in resume, retval=%i\n",
+ retval);
mutex_unlock(&a_priv->interrupt_alloc_lock);
mutex_unlock(&agilent_82357a_hotplug_lock);
return retval;
@@ -1655,9 +1636,9 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)
// assert/unassert REN
agilent_82357a_remote_enable(board, a_priv->ren_state);
- dev_info(&usb_dev->dev,
- "bus %d dev num %d gpib minor %d, agilent usb interface %i resumed\n",
- usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
+ dev_dbg(&usb_dev->dev,
+ "bus %d dev num %d gpib%d, interface %i resumed\n",
+ usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
}
resume_exit:
@@ -1667,7 +1648,7 @@ resume_exit:
}
static struct usb_driver agilent_82357a_bus_driver = {
- .name = "agilent_82357a_gpib",
+ .name = DRV_NAME,
.probe = agilent_82357a_driver_probe,
.disconnect = agilent_82357a_driver_disconnect,
.suspend = agilent_82357a_driver_suspend,
@@ -1680,19 +1661,18 @@ static int __init agilent_82357a_init_module(void)
int i;
int ret;
- pr_info("agilent_82357a_gpib driver loading");
for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i)
agilent_82357a_driver_interfaces[i] = NULL;
ret = usb_register(&agilent_82357a_bus_driver);
if (ret) {
- pr_err("agilent_82357a: usb_register failed: error = %d\n", ret);
+ pr_err("usb_register failed: error = %d\n", ret);
return ret;
}
ret = gpib_register_driver(&agilent_82357a_gpib_interface, THIS_MODULE);
if (ret) {
- pr_err("agilent_82357a: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
usb_deregister(&agilent_82357a_bus_driver);
return ret;
}
@@ -1702,7 +1682,6 @@ static int __init agilent_82357a_init_module(void)
static void __exit agilent_82357a_exit_module(void)
{
- pr_info("agilent_82357a_gpib driver unloading");
gpib_unregister_driver(&agilent_82357a_gpib_interface);
usb_deregister(&agilent_82357a_bus_driver);
}
diff --git a/drivers/staging/gpib/cb7210/Makefile b/drivers/staging/gpib/cb7210/Makefile
index cda0725d6487..d239ae80b415 100644
--- a/drivers/staging/gpib/cb7210/Makefile
+++ b/drivers/staging/gpib/cb7210/Makefile
@@ -1,4 +1,3 @@
-ccflags-$(CONFIG_GPIB_PCMCIA) := -DGPIB_PCMCIA
obj-$(CONFIG_GPIB_CB7210) += cb7210.o
diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
index 4d22f647a453..6b22a33a8c4f 100644
--- a/drivers/staging/gpib/cb7210/cb7210.c
+++ b/drivers/staging/gpib/cb7210/cb7210.c
@@ -5,6 +5,10 @@
* copyright : (C) 2001, 2002 by Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "cb7210.h"
#include <linux/ioport.h>
#include <linux/sched.h>
@@ -23,7 +27,10 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB driver Measurement Computing boards using cb7210.2 and cbi488.2");
-static inline int have_fifo_word(const struct cb7210_priv *cb_priv)
+static int cb7210_read(struct gpib_board *board, uint8_t *buffer, size_t length,
+ int *end, size_t *bytes_read);
+
+ static inline int have_fifo_word(const struct cb7210_priv *cb_priv)
{
if (((cb7210_read_byte(cb_priv, HS_STATUS)) &
(HS_RX_MSB_NOT_EMPTY | HS_RX_LSB_NOT_EMPTY)) ==
@@ -33,7 +40,7 @@ static inline int have_fifo_word(const struct cb7210_priv *cb_priv)
return 0;
}
-static inline void input_fifo_enable(gpib_board_t *board, int enable)
+static inline void input_fifo_enable(struct gpib_board *board, int enable)
{
struct cb7210_priv *cb_priv = board->private_data;
struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv;
@@ -69,7 +76,7 @@ static inline void input_fifo_enable(gpib_board_t *board, int enable)
spin_unlock_irqrestore(&board->spinlock, flags);
}
-static int fifo_read(gpib_board_t *board, struct cb7210_priv *cb_priv, uint8_t *buffer,
+static int fifo_read(struct gpib_board *board, struct cb7210_priv *cb_priv, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
ssize_t retval = 0;
@@ -80,12 +87,12 @@ static int fifo_read(gpib_board_t *board, struct cb7210_priv *cb_priv, uint8_t *
*bytes_read = 0;
if (cb_priv->fifo_iobase == 0) {
- pr_err("cb7210: fifo iobase is zero!\n");
+ dev_err(board->gpib_dev, "fifo iobase is zero!\n");
return -EIO;
}
*end = 0;
if (length <= cb7210_fifo_size) {
- pr_err("cb7210: bug! %s with length < fifo size\n", __func__);
+ dev_err(board->gpib_dev, " bug! fifo read length < fifo size\n");
return -EINVAL;
}
@@ -100,7 +107,6 @@ static int fifo_read(gpib_board_t *board, struct cb7210_priv *cb_priv, uint8_t *
test_bit(RECEIVED_END_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_warn("cb7210: fifo half full wait interrupted\n");
retval = -ERESTARTSYS;
nec7210_set_reg_bits(nec_priv, IMR2, HR_DMAI, 0);
break;
@@ -150,7 +156,6 @@ static int fifo_read(gpib_board_t *board, struct cb7210_priv *cb_priv, uint8_t *
test_bit(RECEIVED_END_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_warn("cb7210: fifo half full wait interrupted\n");
retval = -ERESTARTSYS;
}
if (test_bit(TIMO_NUM, &board->status))
@@ -165,8 +170,8 @@ static int fifo_read(gpib_board_t *board, struct cb7210_priv *cb_priv, uint8_t *
return retval;
}
-int cb7210_accel_read(gpib_board_t *board, uint8_t *buffer,
- size_t length, int *end, size_t *bytes_read)
+static int cb7210_accel_read(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int *end, size_t *bytes_read)
{
ssize_t retval;
struct cb7210_priv *cb_priv = board->private_data;
@@ -185,7 +190,6 @@ int cb7210_accel_read(gpib_board_t *board, uint8_t *buffer,
test_bit(READ_READY_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_warn("cb7210: read ready wait interrupted\n");
return -ERESTARTSYS;
}
if (test_bit(TIMO_NUM, &board->status))
@@ -225,7 +229,7 @@ static int output_fifo_empty(const struct cb7210_priv *cb_priv)
return 0;
}
-static inline void output_fifo_enable(gpib_board_t *board, int enable)
+static inline void output_fifo_enable(struct gpib_board *board, int enable)
{
struct cb7210_priv *cb_priv = board->private_data;
struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv;
@@ -260,7 +264,8 @@ static inline void output_fifo_enable(gpib_board_t *board, int enable)
spin_unlock_irqrestore(&board->spinlock, flags);
}
-static int fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int fifo_write(struct gpib_board *board, uint8_t *buffer, size_t length,
+ size_t *bytes_written)
{
size_t count = 0;
ssize_t retval = 0;
@@ -271,7 +276,7 @@ static int fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, size_
*bytes_written = 0;
if (cb_priv->fifo_iobase == 0) {
- pr_err("cb7210: fifo iobase is zero!\n");
+ dev_err(board->gpib_dev, "fifo iobase is zero!\n");
return -EINVAL;
}
if (length == 0)
@@ -290,7 +295,6 @@ static int fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, size_
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(BUS_ERROR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_warn("cb7210: fifo wait interrupted\n");
retval = -ERESTARTSYS;
break;
}
@@ -306,7 +310,7 @@ static int fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, size_
if (num_bytes + count > length)
num_bytes = length - count;
if (num_bytes % cb7210_fifo_width) {
- pr_err("cb7210: bug! %s with odd number of bytes\n", __func__);
+ dev_err(board->gpib_dev, " bug! fifo write with odd number of bytes\n");
retval = -EINVAL;
break;
}
@@ -331,7 +335,6 @@ static int fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, size_
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(BUS_ERROR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_err("cb7210: wait for last byte interrupted\n");
retval = -ERESTARTSYS;
}
if (test_bit(TIMO_NUM, &board->status))
@@ -347,8 +350,8 @@ static int fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, size_
return retval;
}
-int cb7210_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
+static int cb7210_accel_write(struct gpib_board *board, uint8_t *buffer,
+ size_t length, int send_eoi, size_t *bytes_written)
{
struct cb7210_priv *cb_priv = board->private_data;
struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv;
@@ -375,39 +378,37 @@ int cb7210_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int
return retval;
}
-int cb7210_line_status(const gpib_board_t *board)
+static int cb7210_line_status(const struct gpib_board *board)
{
- int status = ValidALL;
+ int status = VALID_ALL;
int bsr_bits;
struct cb7210_priv *cb_priv;
- struct nec7210_priv *nec_priv;
cb_priv = board->private_data;
- nec_priv = &cb_priv->nec7210_priv;
bsr_bits = cb7210_paged_read_byte(cb_priv, BUS_STATUS, BUS_STATUS_PAGE);
if ((bsr_bits & BSR_REN_BIT) == 0)
- status |= BusREN;
+ status |= BUS_REN;
if ((bsr_bits & BSR_IFC_BIT) == 0)
- status |= BusIFC;
+ status |= BUS_IFC;
if ((bsr_bits & BSR_SRQ_BIT) == 0)
- status |= BusSRQ;
+ status |= BUS_SRQ;
if ((bsr_bits & BSR_EOI_BIT) == 0)
- status |= BusEOI;
+ status |= BUS_EOI;
if ((bsr_bits & BSR_NRFD_BIT) == 0)
- status |= BusNRFD;
+ status |= BUS_NRFD;
if ((bsr_bits & BSR_NDAC_BIT) == 0)
- status |= BusNDAC;
+ status |= BUS_NDAC;
if ((bsr_bits & BSR_DAV_BIT) == 0)
- status |= BusDAV;
+ status |= BUS_DAV;
if ((bsr_bits & BSR_ATN_BIT) == 0)
- status |= BusATN;
+ status |= BUS_ATN;
return status;
}
-unsigned int cb7210_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int cb7210_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct cb7210_priv *cb_priv = board->private_data;
struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv;
@@ -424,16 +425,16 @@ unsigned int cb7210_t1_delay(gpib_board_t *board, unsigned int nano_sec)
return retval;
}
-irqreturn_t cb7210_locked_internal_interrupt(gpib_board_t *board);
+static irqreturn_t cb7210_locked_internal_interrupt(struct gpib_board *board);
/*
* GPIB interrupt service routines
*/
-irqreturn_t cb_pci_interrupt(int irq, void *arg)
+static irqreturn_t cb_pci_interrupt(int irq, void *arg)
{
int bits;
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct cb7210_priv *priv = board->private_data;
// first task check if this is really our interrupt in a shared irq environment
@@ -462,7 +463,7 @@ irqreturn_t cb_pci_interrupt(int irq, void *arg)
return cb7210_locked_internal_interrupt(arg);
}
-irqreturn_t cb7210_internal_interrupt(gpib_board_t *board)
+static irqreturn_t cb7210_internal_interrupt(struct gpib_board *board)
{
int hs_status, status1, status2;
struct cb7210_priv *priv = board->private_data;
@@ -479,7 +480,7 @@ irqreturn_t cb7210_internal_interrupt(gpib_board_t *board)
status2 = read_byte(nec_priv, ISR2);
nec7210_interrupt_have_status(board, nec_priv, status1, status2);
- dev_dbg(board->gpib_dev, "cb7210: status 0x%x, mode 0x%x\n", hs_status, priv->hs_mode_bits);
+ dev_dbg(board->gpib_dev, "status 0x%x, mode 0x%x\n", hs_status, priv->hs_mode_bits);
clear_bits = 0;
@@ -516,7 +517,7 @@ irqreturn_t cb7210_internal_interrupt(gpib_board_t *board)
return IRQ_HANDLED;
}
-irqreturn_t cb7210_locked_internal_interrupt(gpib_board_t *board)
+static irqreturn_t cb7210_locked_internal_interrupt(struct gpib_board *board)
{
unsigned long flags;
irqreturn_t retval;
@@ -527,55 +528,57 @@ irqreturn_t cb7210_locked_internal_interrupt(gpib_board_t *board)
return retval;
}
-irqreturn_t cb7210_interrupt(int irq, void *arg)
+static irqreturn_t cb7210_interrupt(int irq, void *arg)
{
return cb7210_internal_interrupt(arg);
}
-static int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config);
+static int cb_pci_attach(struct gpib_board *board, const gpib_board_config_t *config);
+static int cb_isa_attach(struct gpib_board *board, const gpib_board_config_t *config);
-static void cb_pci_detach(gpib_board_t *board);
-static void cb_isa_detach(gpib_board_t *board);
+static void cb_pci_detach(struct gpib_board *board);
+static void cb_isa_detach(struct gpib_board *board);
// wrappers for interface functions
-int cb7210_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read)
+static int cb7210_read(struct gpib_board *board, uint8_t *buffer, size_t length,
+ int *end, size_t *bytes_read)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read);
}
-int cb7210_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written)
+static int cb7210_write(struct gpib_board *board, uint8_t *buffer, size_t length,
+ int send_eoi, size_t *bytes_written)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
}
-int cb7210_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int cb7210_command(struct gpib_board *board, uint8_t *buffer, size_t length,
+ size_t *bytes_written)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
}
-int cb7210_take_control(gpib_board_t *board, int synchronous)
+static int cb7210_take_control(struct gpib_board *board, int synchronous)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
}
-int cb7210_go_to_standby(gpib_board_t *board)
+static int cb7210_go_to_standby(struct gpib_board *board)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-void cb7210_request_system_control(gpib_board_t *board, int request_control)
+static void cb7210_request_system_control(struct gpib_board *board, int request_control)
{
struct cb7210_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -589,91 +592,91 @@ void cb7210_request_system_control(gpib_board_t *board, int request_control)
nec7210_request_system_control(board, nec_priv, request_control);
}
-void cb7210_interface_clear(gpib_board_t *board, int assert)
+static void cb7210_interface_clear(struct gpib_board *board, int assert)
{
struct cb7210_priv *priv = board->private_data;
nec7210_interface_clear(board, &priv->nec7210_priv, assert);
}
-void cb7210_remote_enable(gpib_board_t *board, int enable)
+static void cb7210_remote_enable(struct gpib_board *board, int enable)
{
struct cb7210_priv *priv = board->private_data;
nec7210_remote_enable(board, &priv->nec7210_priv, enable);
}
-int cb7210_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int cb7210_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
}
-void cb7210_disable_eos(gpib_board_t *board)
+static void cb7210_disable_eos(struct gpib_board *board)
{
struct cb7210_priv *priv = board->private_data;
nec7210_disable_eos(board, &priv->nec7210_priv);
}
-unsigned int cb7210_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int cb7210_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_update_status(board, &priv->nec7210_priv, clear_mask);
}
-int cb7210_primary_address(gpib_board_t *board, unsigned int address)
+static int cb7210_primary_address(struct gpib_board *board, unsigned int address)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_primary_address(board, &priv->nec7210_priv, address);
}
-int cb7210_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int cb7210_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
}
-int cb7210_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int cb7210_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_parallel_poll(board, &priv->nec7210_priv, result);
}
-void cb7210_parallel_poll_configure(gpib_board_t *board, uint8_t configuration)
+static void cb7210_parallel_poll_configure(struct gpib_board *board, uint8_t configuration)
{
struct cb7210_priv *priv = board->private_data;
nec7210_parallel_poll_configure(board, &priv->nec7210_priv, configuration);
}
-void cb7210_parallel_poll_response(gpib_board_t *board, int ist)
+static void cb7210_parallel_poll_response(struct gpib_board *board, int ist)
{
struct cb7210_priv *priv = board->private_data;
nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist);
}
-void cb7210_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void cb7210_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct cb7210_priv *priv = board->private_data;
nec7210_serial_poll_response(board, &priv->nec7210_priv, status);
}
-uint8_t cb7210_serial_poll_status(gpib_board_t *board)
+static uint8_t cb7210_serial_poll_status(struct gpib_board *board)
{
struct cb7210_priv *priv = board->private_data;
return nec7210_serial_poll_status(board, &priv->nec7210_priv);
}
-void cb7210_return_to_local(gpib_board_t *board)
+static void cb7210_return_to_local(struct gpib_board *board)
{
struct cb7210_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -849,27 +852,27 @@ static gpib_interface_t cb_isa_accel_interface = {
.return_to_local = cb7210_return_to_local,
};
-static int cb7210_allocate_private(gpib_board_t *board)
+static int cb7210_allocate_private(struct gpib_board *board)
{
struct cb7210_priv *priv;
board->private_data = kmalloc(sizeof(struct cb7210_priv), GFP_KERNEL);
if (!board->private_data)
- return -1;
+ return -ENOMEM;
priv = board->private_data;
memset(priv, 0, sizeof(struct cb7210_priv));
init_nec7210_private(&priv->nec7210_priv);
return 0;
}
-void cb7210_generic_detach(gpib_board_t *board)
+static void cb7210_generic_detach(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
}
// generic part of attach functions shared by all cb7210 boards
-int cb7210_generic_attach(gpib_board_t *board)
+static int cb7210_generic_attach(struct gpib_board *board)
{
struct cb7210_priv *cb_priv;
struct nec7210_priv *nec_priv;
@@ -887,7 +890,7 @@ int cb7210_generic_attach(gpib_board_t *board)
return 0;
}
-int cb7210_init(struct cb7210_priv *cb_priv, gpib_board_t *board)
+static int cb7210_init(struct cb7210_priv *cb_priv, struct gpib_board *board)
{
struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv;
@@ -917,13 +920,13 @@ int cb7210_init(struct cb7210_priv *cb_priv, gpib_board_t *board)
/* poll so we can detect assertion of ATN */
if (gpib_request_pseudo_irq(board, cb_pci_interrupt)) {
- pr_err("pc2_gpib: failed to allocate pseudo_irq\n");
+ pr_err("failed to allocate pseudo_irq\n");
return -1;
}
return 0;
}
-int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int cb_pci_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct cb7210_priv *cb_priv;
struct nec7210_priv *nec_priv;
@@ -957,17 +960,17 @@ int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
}
}
if (!cb_priv->pci_device) {
- pr_warn("cb7210: no supported boards found.\n");
- return -1;
+ dev_err(board->gpib_dev, "no supported boards found.\n");
+ return -ENODEV;
}
if (pci_enable_device(cb_priv->pci_device)) {
- pr_err("cb7210: error enabling pci device\n");
- return -1;
+ dev_err(board->gpib_dev, "error enabling pci device\n");
+ return -EIO;
}
- if (pci_request_regions(cb_priv->pci_device, "cb7210"))
- return -1;
+ if (pci_request_regions(cb_priv->pci_device, DRV_NAME))
+ return -EBUSY;
switch (cb_priv->pci_chip) {
case PCI_CHIP_AMCC_S5933:
cb_priv->amcc_iobase = pci_resource_start(cb_priv->pci_device, 0);
@@ -979,13 +982,14 @@ int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
cb_priv->fifo_iobase = nec_priv->iobase;
break;
default:
- pr_err("cb7210: bug! unhandled pci_chip=%i\n", cb_priv->pci_chip);
+ dev_err(board->gpib_dev, "bug! unhandled pci_chip=%i\n", cb_priv->pci_chip);
return -EIO;
}
isr_flags |= IRQF_SHARED;
- if (request_irq(cb_priv->pci_device->irq, cb_pci_interrupt, isr_flags, "cb7210", board)) {
- pr_err("cb7210: can't request IRQ %d\n", cb_priv->pci_device->irq);
- return -1;
+ if (request_irq(cb_priv->pci_device->irq, cb_pci_interrupt, isr_flags, DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "can't request IRQ %d\n",
+ cb_priv->pci_device->irq);
+ return -EBUSY;
}
cb_priv->irq = cb_priv->pci_device->irq;
@@ -1004,7 +1008,7 @@ int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
return cb7210_init(cb_priv, board);
}
-void cb_pci_detach(gpib_board_t *board)
+static void cb_pci_detach(struct gpib_board *board)
{
struct cb7210_priv *cb_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1027,7 +1031,7 @@ void cb_pci_detach(gpib_board_t *board)
cb7210_generic_detach(board);
}
-int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int cb_isa_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
int isr_flags = 0;
struct cb7210_priv *cb_priv;
@@ -1040,20 +1044,22 @@ int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
return retval;
cb_priv = board->private_data;
nec_priv = &cb_priv->nec7210_priv;
- if (!request_region(config->ibbase, cb7210_iosize, "cb7210")) {
- pr_err("gpib: ioports starting at 0x%x are already in use\n", config->ibbase);
- return -EIO;
+ if (!request_region(config->ibbase, cb7210_iosize, DRV_NAME)) {
+ dev_err(board->gpib_dev, "ioports starting at 0x%x are already in use\n",
+ config->ibbase);
+ return -EBUSY;
}
nec_priv->iobase = config->ibbase;
cb_priv->fifo_iobase = nec7210_iobase(cb_priv);
bits = irq_bits(config->ibirq);
if (bits == 0)
- pr_err("board incapable of using irq %i, try 2-5, 7, 10, or 11\n", config->ibirq);
+ dev_err(board->gpib_dev, "board incapable of using irq %i, try 2-5, 7, 10, or 11\n",
+ config->ibirq);
// install interrupt handler
- if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, "cb7210", board)) {
- pr_err("gpib: can't request IRQ %d\n", config->ibirq);
+ if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", config->ibirq);
return -EBUSY;
}
cb_priv->irq = config->ibirq;
@@ -1061,7 +1067,7 @@ int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
return cb7210_init(cb_priv, board);
}
-void cb_isa_detach(gpib_board_t *board)
+static void cb_isa_detach(struct gpib_board *board)
{
struct cb7210_priv *cb_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1093,7 +1099,7 @@ static const struct pci_device_id cb7210_pci_table[] = {
MODULE_DEVICE_TABLE(pci, cb7210_pci_table);
static struct pci_driver cb7210_pci_driver = {
- .name = "cb7210",
+ .name = DRV_NAME,
.id_table = cb7210_pci_table,
.probe = &cb7210_pci_probe
};
@@ -1106,7 +1112,7 @@ static struct pci_driver cb7210_pci_driver = {
* pcmcia skeleton example (presumably David Hinds)
***************************************************************************/
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
#include <linux/kernel.h>
#include <linux/ptrace.h>
@@ -1117,23 +1123,6 @@ static struct pci_driver cb7210_pci_driver = {
#include <pcmcia/ds.h>
/*
- * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
- * you do not define PCMCIA_DEBUG at all, all the debug code will be
- * left out. If you compile with PCMCIA_DEBUG=0, the debug code will
- * be present but disabled -- but it can then be enabled for specific
- * modules at load time with a 'pc_debug=#' option to insmod.
- */
-
-#define PCMCIA_DEBUG 1
-
-#ifdef PCMCIA_DEBUG
-static int pc_debug = PCMCIA_DEBUG;
-#define DEBUG(n, args...) do {if (pc_debug > (n)) pr_debug(args); } while (0)
-#else
-#define DEBUG(args...)
-#endif
-
-/*
* The event() function is this driver's Card Services event handler.
* It will be called by Card Services when an appropriate card status
* event is received. The config() and release() entry points are
@@ -1144,8 +1133,8 @@ static int pc_debug = PCMCIA_DEBUG;
static int cb_gpib_config(struct pcmcia_device *link);
static void cb_gpib_release(struct pcmcia_device *link);
-static int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static void cb_pcmcia_detach(gpib_board_t *board);
+static int cb_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config);
+static void cb_pcmcia_detach(struct gpib_board *board);
/*
* A linked list of "instances" of the gpib device. Each actual
@@ -1178,7 +1167,7 @@ static struct pcmcia_device *curr_dev;
struct local_info {
struct pcmcia_device *p_dev;
- gpib_board_t *dev;
+ struct gpib_board *dev;
};
/*
@@ -1197,8 +1186,6 @@ static int cb_gpib_probe(struct pcmcia_device *link)
// int ret, i;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
-
/* Allocate space for private device-specific data */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
@@ -1236,9 +1223,7 @@ static int cb_gpib_probe(struct pcmcia_device *link)
static void cb_gpib_remove(struct pcmcia_device *link)
{
struct local_info *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
-
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
if (info->dev)
cb_pcmcia_detach(info->dev);
@@ -1267,7 +1252,6 @@ static int cb_gpib_config(struct pcmcia_device *link)
handle = link;
dev = link->priv;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
retval = pcmcia_loop_config(link, &cb_gpib_config_iteration, NULL);
if (retval) {
@@ -1276,8 +1260,6 @@ static int cb_gpib_config(struct pcmcia_device *link)
return -ENODEV;
}
- DEBUG(0, "gpib_cs: manufacturer: 0x%x card: 0x%x\n", link->manf_id, link->card_id);
-
/*
* This actually configures the PCMCIA socket -- setting up
* the I/O windows and the interrupt mapping.
@@ -1289,7 +1271,6 @@ static int cb_gpib_config(struct pcmcia_device *link)
return -ENODEV;
}
- pr_info("gpib device loaded\n");
return 0;
} /* gpib_config */
@@ -1301,18 +1282,16 @@ static int cb_gpib_config(struct pcmcia_device *link)
static void cb_gpib_release(struct pcmcia_device *link)
{
- DEBUG(0, "%s(0x%p)\n", __func__, link);
pcmcia_disable_device(link);
}
static int cb_gpib_suspend(struct pcmcia_device *link)
{
//struct local_info *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
if (link->open)
- pr_warn("Device still open ???\n");
+ dev_warn(&link->dev, "Device still open\n");
//netif_device_detach(dev);
return 0;
@@ -1321,12 +1300,10 @@ static int cb_gpib_suspend(struct pcmcia_device *link)
static int cb_gpib_resume(struct pcmcia_device *link)
{
//struct local_info *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
/*if (link->open) {
* ni_gpib_probe(dev); / really?
- * printk("Gpib resumed ???\n");
* //netif_device_attach(dev);
*
*/
@@ -1342,8 +1319,8 @@ static struct pcmcia_device_id cb_pcmcia_ids[] = {
MODULE_DEVICE_TABLE(pcmcia, cb_pcmcia_ids);
static struct pcmcia_driver cb_gpib_cs_driver = {
+ .name = "cb_gpib_cs",
.owner = THIS_MODULE,
- .drv = { .name = "cb_gpib_cs", },
.id_table = cb_pcmcia_ids,
.probe = cb_gpib_probe,
.remove = cb_gpib_remove,
@@ -1351,9 +1328,8 @@ static struct pcmcia_driver cb_gpib_cs_driver = {
.resume = cb_gpib_resume,
};
-void cb_pcmcia_cleanup_module(void)
+static void cb_pcmcia_cleanup_module(void)
{
- DEBUG(0, "cb_gpib_cs: unloading\n");
pcmcia_unregister_driver(&cb_gpib_cs_driver);
}
@@ -1441,15 +1417,15 @@ static gpib_interface_t cb_pcmcia_accel_interface = {
.return_to_local = cb7210_return_to_local,
};
-int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int cb_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct cb7210_priv *cb_priv;
struct nec7210_priv *nec_priv;
int retval;
if (!curr_dev) {
- pr_err("no cb pcmcia cards found\n");
- return -1;
+ dev_err(board->gpib_dev, "no cb pcmcia cards found\n");
+ return -ENODEV;
}
retval = cb7210_generic_attach(board);
@@ -1460,25 +1436,24 @@ int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
nec_priv = &cb_priv->nec7210_priv;
if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
- "cb7210")) {
- pr_err("gpib: ioports starting at 0x%lx are already in use\n",
- (unsigned long)curr_dev->resource[0]->start);
- return -EIO;
+ DRV_NAME)) {
+ dev_err(board->gpib_dev, "ioports starting at 0x%lx are already in use\n",
+ (unsigned long)curr_dev->resource[0]->start);
+ return -EBUSY;
}
nec_priv->iobase = curr_dev->resource[0]->start;
cb_priv->fifo_iobase = curr_dev->resource[0]->start;
- if (request_irq(curr_dev->irq, cb7210_interrupt, IRQF_SHARED,
- "cb7210", board)) {
- pr_err("cb7210: failed to request IRQ %d\n", curr_dev->irq);
- return -1;
+ if (request_irq(curr_dev->irq, cb7210_interrupt, IRQF_SHARED, DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "failed to request IRQ %d\n", curr_dev->irq);
+ return -EBUSY;
}
cb_priv->irq = curr_dev->irq;
return cb7210_init(cb_priv, board);
}
-void cb_pcmcia_detach(gpib_board_t *board)
+static void cb_pcmcia_detach(struct gpib_board *board)
{
struct cb7210_priv *cb_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1496,7 +1471,7 @@ void cb_pcmcia_detach(gpib_board_t *board)
cb7210_generic_detach(board);
}
-#endif /* GPIB_PCMCIA */
+#endif /* CONFIG_GPIB_PCMCIA */
static int __init cb7210_init_module(void)
{
@@ -1504,75 +1479,75 @@ static int __init cb7210_init_module(void)
ret = pci_register_driver(&cb7210_pci_driver);
if (ret) {
- pr_err("cb7210: pci_register_driver failed: error = %d\n", ret);
+ pr_err("pci_register_driver failed: error = %d\n", ret);
return ret;
}
ret = gpib_register_driver(&cb_pci_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pci;
}
ret = gpib_register_driver(&cb_isa_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_isa;
}
ret = gpib_register_driver(&cb_pci_accel_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pci_accel;
}
ret = gpib_register_driver(&cb_pci_unaccel_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pci_unaccel;
}
ret = gpib_register_driver(&cb_isa_accel_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_isa_accel;
}
ret = gpib_register_driver(&cb_isa_unaccel_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_isa_unaccel;
}
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
ret = gpib_register_driver(&cb_pcmcia_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pcmcia;
}
ret = gpib_register_driver(&cb_pcmcia_accel_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pcmcia_accel;
}
ret = gpib_register_driver(&cb_pcmcia_unaccel_interface, THIS_MODULE);
if (ret) {
- pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pcmcia_unaccel;
}
ret = pcmcia_register_driver(&cb_gpib_cs_driver);
if (ret) {
- pr_err("cb7210: pcmcia_register_driver failed: error = %d\n", ret);
+ pr_err("pcmcia_register_driver failed: error = %d\n", ret);
goto err_pcmcia_driver;
}
#endif
return 0;
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
err_pcmcia_driver:
gpib_unregister_driver(&cb_pcmcia_unaccel_interface);
err_pcmcia_unaccel:
@@ -1606,7 +1581,7 @@ static void __exit cb7210_exit_module(void)
gpib_unregister_driver(&cb_pci_unaccel_interface);
gpib_unregister_driver(&cb_isa_accel_interface);
gpib_unregister_driver(&cb_isa_unaccel_interface);
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
gpib_unregister_driver(&cb_pcmcia_interface);
gpib_unregister_driver(&cb_pcmcia_accel_interface);
gpib_unregister_driver(&cb_pcmcia_unaccel_interface);
diff --git a/drivers/staging/gpib/cb7210/cb7210.h b/drivers/staging/gpib/cb7210/cb7210.h
index d56cd905cc8c..2108fe7a8ce5 100644
--- a/drivers/staging/gpib/cb7210/cb7210.h
+++ b/drivers/staging/gpib/cb7210/cb7210.h
@@ -36,51 +36,6 @@ struct cb7210_priv {
unsigned in_fifo_half_full : 1;
};
-// interrupt service routines
-irqreturn_t cb_pci_interrupt(int irq, void *arg);
-irqreturn_t cb7210_interrupt(int irq, void *arg);
-irqreturn_t cb7210_internal_interrupt(gpib_board_t *board);
-
-// interface functions
-int cb7210_read(gpib_board_t *board, uint8_t *buffer, size_t length,
- int *end, size_t *bytes_read);
-int cb7210_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
- int *end, size_t *bytes_read);
-int cb7210_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written);
-int cb7210_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written);
-int cb7210_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written);
-int cb7210_take_control(gpib_board_t *board, int synchronous);
-int cb7210_go_to_standby(gpib_board_t *board);
-void cb7210_request_system_control(gpib_board_t *board, int request_control);
-void cb7210_interface_clear(gpib_board_t *board, int assert);
-void cb7210_remote_enable(gpib_board_t *board, int enable);
-int cb7210_enable_eos(gpib_board_t *board, uint8_t eos_byte,
- int compare_8_bits);
-void cb7210_disable_eos(gpib_board_t *board);
-unsigned int cb7210_update_status(gpib_board_t *board, unsigned int clear_mask);
-int cb7210_primary_address(gpib_board_t *board, unsigned int address);
-int cb7210_secondary_address(gpib_board_t *board, unsigned int address,
- int enable);
-int cb7210_parallel_poll(gpib_board_t *board, uint8_t *result);
-void cb7210_serial_poll_response(gpib_board_t *board, uint8_t status);
-uint8_t cb7210_serial_poll_status(gpib_board_t *board);
-void cb7210_parallel_poll_configure(gpib_board_t *board, uint8_t configuration);
-void cb7210_parallel_poll_response(gpib_board_t *board, int ist);
-int cb7210_line_status(const gpib_board_t *board);
-unsigned int cb7210_t1_delay(gpib_board_t *board, unsigned int nano_sec);
-void cb7210_return_to_local(gpib_board_t *board);
-
-// utility functions
-void cb7210_generic_detach(gpib_board_t *board);
-int cb7210_generic_attach(gpib_board_t *board);
-int cb7210_init(struct cb7210_priv *priv, gpib_board_t *board);
-
-// pcmcia init/cleanup
-int cb_pcmcia_init_module(void);
-void cb_pcmcia_cleanup_module(void);
-
// pci-gpib register offset
static const int cb7210_reg_offset = 1;
diff --git a/drivers/staging/gpib/cec/cec.h b/drivers/staging/gpib/cec/cec.h
index 040ca70ed708..3ce2869c7429 100644
--- a/drivers/staging/gpib/cec/cec.h
+++ b/drivers/staging/gpib/cec/cec.h
@@ -16,34 +16,5 @@ struct cec_priv {
unsigned int irq;
};
-// interface functions
-int cec_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read);
-int cec_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written);
-int cec_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written);
-int cec_take_control(gpib_board_t *board, int synchronous);
-int cec_go_to_standby(gpib_board_t *board);
-void cec_request_system_control(gpib_board_t *board, int request_control);
-void cec_interface_clear(gpib_board_t *board, int assert);
-void cec_remote_enable(gpib_board_t *board, int enable);
-int cec_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits);
-void cec_disable_eos(gpib_board_t *board);
-unsigned int cec_update_status(gpib_board_t *board, unsigned int clear_mask);
-int cec_primary_address(gpib_board_t *board, unsigned int address);
-int cec_secondary_address(gpib_board_t *board, unsigned int address, int enable);
-int cec_parallel_poll(gpib_board_t *board, uint8_t *result);
-void cec_parallel_poll_configure(gpib_board_t *board, uint8_t configuration);
-void cec_parallel_poll_response(gpib_board_t *board, int ist);
-void cec_serial_poll_response(gpib_board_t *board, uint8_t status);
-void cec_return_to_local(gpib_board_t *board);
-
-// interrupt service routines
-irqreturn_t cec_interrupt(int irq, void *arg);
-
-// utility functions
-void cec_free_private(gpib_board_t *board);
-int cec_generic_attach(gpib_board_t *board);
-void cec_init(struct cec_priv *priv, const gpib_board_t *board);
-
// offset between consecutive nec7210 registers
static const int cec_reg_offset = 1;
diff --git a/drivers/staging/gpib/cec/cec_gpib.c b/drivers/staging/gpib/cec/cec_gpib.c
index d056cd1d6b3e..a822fa428cd0 100644
--- a/drivers/staging/gpib/cec/cec_gpib.c
+++ b/drivers/staging/gpib/cec/cec_gpib.c
@@ -4,6 +4,10 @@
* copyright : (C) 2002 by Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "cec.h"
#include <linux/pci.h>
#include <linux/io.h>
@@ -19,9 +23,9 @@ MODULE_DESCRIPTION("GPIB driver for CEC PCI and PCMCIA boards");
* GPIB interrupt service routines
*/
-irqreturn_t cec_interrupt(int irq, void *arg)
+static irqreturn_t cec_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct cec_priv *priv = board->private_data;
unsigned long flags;
irqreturn_t retval;
@@ -36,146 +40,148 @@ irqreturn_t cec_interrupt(int irq, void *arg)
#define CEC_DEV_ID 0x5cec
#define CEC_SUBID 0x9050
-static int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config);
+static int cec_pci_attach(struct gpib_board *board, const gpib_board_config_t *config);
-static void cec_pci_detach(gpib_board_t *board);
+static void cec_pci_detach(struct gpib_board *board);
// wrappers for interface functions
-int cec_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read)
+static int cec_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
+ size_t *bytes_read)
{
struct cec_priv *priv = board->private_data;
return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read);
}
-int cec_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
+static int cec_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
+ size_t *bytes_written)
{
struct cec_priv *priv = board->private_data;
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
}
-int cec_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int cec_command(struct gpib_board *board, uint8_t *buffer,
+ size_t length, size_t *bytes_written)
{
struct cec_priv *priv = board->private_data;
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
}
-int cec_take_control(gpib_board_t *board, int synchronous)
+static int cec_take_control(struct gpib_board *board, int synchronous)
{
struct cec_priv *priv = board->private_data;
return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
}
-int cec_go_to_standby(gpib_board_t *board)
+static int cec_go_to_standby(struct gpib_board *board)
{
struct cec_priv *priv = board->private_data;
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-void cec_request_system_control(gpib_board_t *board, int request_control)
+static void cec_request_system_control(struct gpib_board *board, int request_control)
{
struct cec_priv *priv = board->private_data;
nec7210_request_system_control(board, &priv->nec7210_priv, request_control);
}
-void cec_interface_clear(gpib_board_t *board, int assert)
+static void cec_interface_clear(struct gpib_board *board, int assert)
{
struct cec_priv *priv = board->private_data;
nec7210_interface_clear(board, &priv->nec7210_priv, assert);
}
-void cec_remote_enable(gpib_board_t *board, int enable)
+static void cec_remote_enable(struct gpib_board *board, int enable)
{
struct cec_priv *priv = board->private_data;
nec7210_remote_enable(board, &priv->nec7210_priv, enable);
}
-int cec_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int cec_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct cec_priv *priv = board->private_data;
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
}
-void cec_disable_eos(gpib_board_t *board)
+static void cec_disable_eos(struct gpib_board *board)
{
struct cec_priv *priv = board->private_data;
nec7210_disable_eos(board, &priv->nec7210_priv);
}
-unsigned int cec_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int cec_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct cec_priv *priv = board->private_data;
return nec7210_update_status(board, &priv->nec7210_priv, clear_mask);
}
-int cec_primary_address(gpib_board_t *board, unsigned int address)
+static int cec_primary_address(struct gpib_board *board, unsigned int address)
{
struct cec_priv *priv = board->private_data;
return nec7210_primary_address(board, &priv->nec7210_priv, address);
}
-int cec_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int cec_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct cec_priv *priv = board->private_data;
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
}
-int cec_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int cec_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct cec_priv *priv = board->private_data;
return nec7210_parallel_poll(board, &priv->nec7210_priv, result);
}
-void cec_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void cec_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
struct cec_priv *priv = board->private_data;
nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config);
}
-void cec_parallel_poll_response(gpib_board_t *board, int ist)
+static void cec_parallel_poll_response(struct gpib_board *board, int ist)
{
struct cec_priv *priv = board->private_data;
nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist);
}
-void cec_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void cec_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct cec_priv *priv = board->private_data;
nec7210_serial_poll_response(board, &priv->nec7210_priv, status);
}
-static uint8_t cec_serial_poll_status(gpib_board_t *board)
+static uint8_t cec_serial_poll_status(struct gpib_board *board)
{
struct cec_priv *priv = board->private_data;
return nec7210_serial_poll_status(board, &priv->nec7210_priv);
}
-static unsigned int cec_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int cec_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct cec_priv *priv = board->private_data;
return nec7210_t1_delay(board, &priv->nec7210_priv, nano_sec);
}
-void cec_return_to_local(gpib_board_t *board)
+static void cec_return_to_local(struct gpib_board *board)
{
struct cec_priv *priv = board->private_data;
@@ -210,7 +216,7 @@ static gpib_interface_t cec_pci_interface = {
.return_to_local = cec_return_to_local,
};
-static int cec_allocate_private(gpib_board_t *board)
+static int cec_allocate_private(struct gpib_board *board)
{
struct cec_priv *priv;
@@ -223,13 +229,13 @@ static int cec_allocate_private(gpib_board_t *board)
return 0;
}
-void cec_free_private(gpib_board_t *board)
+static void cec_free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
}
-int cec_generic_attach(gpib_board_t *board)
+static int cec_generic_attach(struct gpib_board *board)
{
struct cec_priv *cec_priv;
struct nec7210_priv *nec_priv;
@@ -247,7 +253,7 @@ int cec_generic_attach(gpib_board_t *board)
return 0;
}
-void cec_init(struct cec_priv *cec_priv, const gpib_board_t *board)
+static void cec_init(struct cec_priv *cec_priv, const struct gpib_board *board)
{
struct nec7210_priv *nec_priv = &cec_priv->nec7210_priv;
@@ -259,7 +265,7 @@ void cec_init(struct cec_priv *cec_priv, const gpib_board_t *board)
nec7210_board_online(nec_priv, board);
}
-int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int cec_pci_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct cec_priv *cec_priv;
struct nec7210_priv *nec_priv;
@@ -283,31 +289,29 @@ int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
break;
}
if (!cec_priv->pci_device) {
- pr_err("gpib: no cec PCI board found\n");
- return -1;
+ dev_err(board->gpib_dev, "no cec PCI board found\n");
+ return -ENODEV;
}
if (pci_enable_device(cec_priv->pci_device)) {
- pr_err("error enabling pci device\n");
- return -1;
+ dev_err(board->gpib_dev, "error enabling pci device\n");
+ return -EIO;
}
if (pci_request_regions(cec_priv->pci_device, "cec-gpib"))
- return -1;
+ return -EBUSY;
cec_priv->plx_iobase = pci_resource_start(cec_priv->pci_device, 1);
- pr_info(" plx9050 base address 0x%lx\n", cec_priv->plx_iobase);
- nec_priv->iobase = pci_resource_start(cec_priv->pci_device, 3);
- pr_info(" nec7210 base address 0x%x\n", nec_priv->iobase);
+ nec_priv->iobase = pci_resource_start(cec_priv->pci_device, 3);
isr_flags |= IRQF_SHARED;
- if (request_irq(cec_priv->pci_device->irq, cec_interrupt, isr_flags, "pci-gpib", board)) {
- pr_err("gpib: can't request IRQ %d\n", cec_priv->pci_device->irq);
- return -1;
+ if (request_irq(cec_priv->pci_device->irq, cec_interrupt, isr_flags, DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", cec_priv->pci_device->irq);
+ return -EBUSY;
}
cec_priv->irq = cec_priv->pci_device->irq;
if (gpib_request_pseudo_irq(board, cec_interrupt)) {
- pr_err("cec: failed to allocate pseudo irq\n");
+ dev_err(board->gpib_dev, "failed to allocate pseudo irq\n");
return -1;
}
cec_init(cec_priv, board);
@@ -319,7 +323,7 @@ int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-void cec_pci_detach(gpib_board_t *board)
+static void cec_pci_detach(struct gpib_board *board)
{
struct cec_priv *cec_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -354,7 +358,7 @@ static const struct pci_device_id cec_pci_table[] = {
MODULE_DEVICE_TABLE(pci, cec_pci_table);
static struct pci_driver cec_pci_driver = {
- .name = "cec_gpib",
+ .name = DRV_NAME,
.id_table = cec_pci_table,
.probe = &cec_pci_probe
};
@@ -365,13 +369,13 @@ static int __init cec_init_module(void)
result = pci_register_driver(&cec_pci_driver);
if (result) {
- pr_err("cec_gpib: pci_register_driver failed: error = %d\n", result);
+ pr_err("pci_register_driver failed: error = %d\n", result);
return result;
}
result = gpib_register_driver(&cec_pci_interface, THIS_MODULE);
if (result) {
- pr_err("cec_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
return result;
}
diff --git a/drivers/staging/gpib/common/gpib_os.c b/drivers/staging/gpib/common/gpib_os.c
index 4901e660242e..cb77fe0a4b9a 100644
--- a/drivers/staging/gpib/common/gpib_os.c
+++ b/drivers/staging/gpib/common/gpib_os.c
@@ -5,6 +5,9 @@
***************************************************************************
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+
#include "ibsys.h"
#include <linux/module.h>
#include <linux/wait.h>
@@ -23,53 +26,53 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB base support");
MODULE_ALIAS_CHARDEV_MAJOR(GPIB_CODE);
-static int board_type_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, unsigned long arg);
-static int read_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
+static int board_type_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, unsigned long arg);
+static int read_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board,
unsigned long arg);
-static int write_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
+static int write_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board,
unsigned long arg);
-static int command_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
+static int command_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board,
unsigned long arg);
-static int open_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg);
-static int close_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg);
-static int serial_poll_ioctl(gpib_board_t *board, unsigned long arg);
-static int wait_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, unsigned long arg);
-static int parallel_poll_ioctl(gpib_board_t *board, unsigned long arg);
-static int online_ioctl(gpib_board_t *board, unsigned long arg);
-static int remote_enable_ioctl(gpib_board_t *board, unsigned long arg);
-static int take_control_ioctl(gpib_board_t *board, unsigned long arg);
-static int line_status_ioctl(gpib_board_t *board, unsigned long arg);
-static int pad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int open_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg);
+static int close_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg);
+static int serial_poll_ioctl(struct gpib_board *board, unsigned long arg);
+static int wait_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, unsigned long arg);
+static int parallel_poll_ioctl(struct gpib_board *board, unsigned long arg);
+static int online_ioctl(struct gpib_board *board, unsigned long arg);
+static int remote_enable_ioctl(struct gpib_board *board, unsigned long arg);
+static int take_control_ioctl(struct gpib_board *board, unsigned long arg);
+static int line_status_ioctl(struct gpib_board *board, unsigned long arg);
+static int pad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg);
-static int sad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int sad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg);
-static int eos_ioctl(gpib_board_t *board, unsigned long arg);
-static int request_service_ioctl(gpib_board_t *board, unsigned long arg);
-static int request_service2_ioctl(gpib_board_t *board, unsigned long arg);
+static int eos_ioctl(struct gpib_board *board, unsigned long arg);
+static int request_service_ioctl(struct gpib_board *board, unsigned long arg);
+static int request_service2_ioctl(struct gpib_board *board, unsigned long arg);
static int iobase_ioctl(gpib_board_config_t *config, unsigned long arg);
static int irq_ioctl(gpib_board_config_t *config, unsigned long arg);
static int dma_ioctl(gpib_board_config_t *config, unsigned long arg);
-static int autospoll_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int autospoll_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg);
-static int mutex_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int mutex_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg);
-static int timeout_ioctl(gpib_board_t *board, unsigned long arg);
-static int status_bytes_ioctl(gpib_board_t *board, unsigned long arg);
-static int board_info_ioctl(const gpib_board_t *board, unsigned long arg);
-static int ppc_ioctl(gpib_board_t *board, unsigned long arg);
-static int set_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg);
-static int get_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg);
-static int query_board_rsv_ioctl(gpib_board_t *board, unsigned long arg);
-static int interface_clear_ioctl(gpib_board_t *board, unsigned long arg);
+static int timeout_ioctl(struct gpib_board *board, unsigned long arg);
+static int status_bytes_ioctl(struct gpib_board *board, unsigned long arg);
+static int board_info_ioctl(const struct gpib_board *board, unsigned long arg);
+static int ppc_ioctl(struct gpib_board *board, unsigned long arg);
+static int set_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg);
+static int get_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg);
+static int query_board_rsv_ioctl(struct gpib_board *board, unsigned long arg);
+static int interface_clear_ioctl(struct gpib_board *board, unsigned long arg);
static int select_pci_ioctl(gpib_board_config_t *config, unsigned long arg);
static int select_device_path_ioctl(gpib_board_config_t *config, unsigned long arg);
-static int event_ioctl(gpib_board_t *board, unsigned long arg);
-static int request_system_control_ioctl(gpib_board_t *board, unsigned long arg);
-static int t1_delay_ioctl(gpib_board_t *board, unsigned long arg);
+static int event_ioctl(struct gpib_board *board, unsigned long arg);
+static int request_system_control_ioctl(struct gpib_board *board, unsigned long arg);
+static int t1_delay_ioctl(struct gpib_board *board, unsigned long arg);
-static int cleanup_open_devices(gpib_file_private_t *file_priv, gpib_board_t *board);
+static int cleanup_open_devices(gpib_file_private_t *file_priv, struct gpib_board *board);
-static int pop_gpib_event_nolock(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type);
+static int pop_gpib_event_nolock(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type);
/*
* Timer functions
@@ -79,18 +82,18 @@ static int pop_gpib_event_nolock(gpib_board_t *board, gpib_event_queue_t *queue,
static void watchdog_timeout(struct timer_list *t)
{
- gpib_board_t *board = from_timer(board, t, timer);
+ struct gpib_board *board = from_timer(board, t, timer);
set_bit(TIMO_NUM, &board->status);
wake_up_interruptible(&board->wait);
}
/* install timer interrupt handler */
-void os_start_timer(gpib_board_t *board, unsigned int usec_timeout)
+void os_start_timer(struct gpib_board *board, unsigned int usec_timeout)
/* Starts the timeout task */
{
if (timer_pending(&board->timer)) {
- pr_err("gpib: bug! timer already running?\n");
+ dev_err(board->gpib_dev, "bug! timer already running?\n");
return;
}
clear_bit(TIMO_NUM, &board->status);
@@ -102,14 +105,14 @@ void os_start_timer(gpib_board_t *board, unsigned int usec_timeout)
}
}
-void os_remove_timer(gpib_board_t *board)
+void os_remove_timer(struct gpib_board *board)
/* Removes the timeout task */
{
if (timer_pending(&board->timer))
del_timer_sync(&board->timer);
}
-int io_timed_out(gpib_board_t *board)
+int io_timed_out(struct gpib_board *board)
{
if (test_bit(TIMO_NUM, &board->status))
return 1;
@@ -137,10 +140,10 @@ static void pseudo_irq_handler(struct timer_list *t)
mod_timer(&pseudo_irq->timer, jiffies + pseudo_irq_period());
}
-int gpib_request_pseudo_irq(gpib_board_t *board, irqreturn_t (*handler)(int, void *))
+int gpib_request_pseudo_irq(struct gpib_board *board, irqreturn_t (*handler)(int, void *))
{
if (timer_pending(&board->pseudo_irq.timer) || board->pseudo_irq.handler) {
- pr_err("gpib: only one pseudo interrupt per board allowed\n");
+ dev_err(board->gpib_dev, "only one pseudo interrupt per board allowed\n");
return -1;
}
@@ -156,7 +159,7 @@ int gpib_request_pseudo_irq(gpib_board_t *board, irqreturn_t (*handler)(int, voi
}
EXPORT_SYMBOL(gpib_request_pseudo_irq);
-void gpib_free_pseudo_irq(gpib_board_t *board)
+void gpib_free_pseudo_irq(struct gpib_board *board)
{
atomic_set(&board->pseudo_irq.active, 0);
@@ -175,7 +178,7 @@ unsigned int num_status_bytes(const gpib_status_queue_t *dev)
}
// push status byte onto back of status byte fifo
-int push_status_byte(gpib_board_t *board, gpib_status_queue_t *device, u8 poll_byte)
+int push_status_byte(struct gpib_board *board, gpib_status_queue_t *device, u8 poll_byte)
{
struct list_head *head = &device->status_bytes;
status_byte_t *status;
@@ -209,7 +212,7 @@ int push_status_byte(gpib_board_t *board, gpib_status_queue_t *device, u8 poll_b
}
// pop status byte from front of status byte fifo
-int pop_status_byte(gpib_board_t *board, gpib_status_queue_t *device, u8 *poll_byte)
+int pop_status_byte(struct gpib_board *board, gpib_status_queue_t *device, u8 *poll_byte)
{
struct list_head *head = &device->status_bytes;
struct list_head *front = head->next;
@@ -240,7 +243,7 @@ int pop_status_byte(gpib_board_t *board, gpib_status_queue_t *device, u8 *poll_b
return 0;
}
-gpib_status_queue_t *get_gpib_status_queue(gpib_board_t *board, unsigned int pad, int sad)
+gpib_status_queue_t *get_gpib_status_queue(struct gpib_board *board, unsigned int pad, int sad)
{
gpib_status_queue_t *device;
struct list_head *list_ptr;
@@ -255,13 +258,11 @@ gpib_status_queue_t *get_gpib_status_queue(gpib_board_t *board, unsigned int pad
return NULL;
}
-int get_serial_poll_byte(gpib_board_t *board, unsigned int pad, int sad, unsigned int usec_timeout,
+int get_serial_poll_byte(struct gpib_board *board, unsigned int pad, int sad, unsigned int usec_timeout,
uint8_t *poll_byte)
{
gpib_status_queue_t *device;
- dev_dbg(board->gpib_dev, "%s:()\n", __func__);
-
device = get_gpib_status_queue(board, pad, sad);
if (num_status_bytes(device))
return pop_status_byte(board, device, poll_byte);
@@ -269,11 +270,10 @@ int get_serial_poll_byte(gpib_board_t *board, unsigned int pad, int sad, unsigne
return dvrsp(board, pad, sad, usec_timeout, poll_byte);
}
-int autopoll_all_devices(gpib_board_t *board)
+int autopoll_all_devices(struct gpib_board *board)
{
int retval;
- dev_dbg(board->gpib_dev, "entering %s()\n", __func__);
if (mutex_lock_interruptible(&board->user_mutex))
return -ERESTARTSYS;
if (mutex_lock_interruptible(&board->big_gpib_mutex)) {
@@ -290,7 +290,7 @@ int autopoll_all_devices(gpib_board_t *board)
return retval;
}
- dev_dbg(board->gpib_dev, "%s complete\n", __func__);
+ dev_dbg(board->gpib_dev, "complete\n");
/* need to wake wait queue in case someone is
* waiting on RQS
*/
@@ -301,15 +301,13 @@ int autopoll_all_devices(gpib_board_t *board)
return retval;
}
-static int setup_serial_poll(gpib_board_t *board, unsigned int usec_timeout)
+static int setup_serial_poll(struct gpib_board *board, unsigned int usec_timeout)
{
u8 cmd_string[8];
int i;
size_t bytes_written;
int ret;
- dev_dbg(board->gpib_dev, "entering %s()\n", __func__);
-
os_start_timer(board, usec_timeout);
ret = ibcac(board, 1, 1);
if (ret < 0) {
@@ -326,7 +324,7 @@ static int setup_serial_poll(gpib_board_t *board, unsigned int usec_timeout)
ret = board->interface->command(board, cmd_string, i, &bytes_written);
if (ret < 0 || bytes_written < i) {
- pr_err("gpib: failed to setup serial poll\n");
+ dev_dbg(board->gpib_dev, "failed to setup serial poll\n");
os_remove_timer(board);
return -EIO;
}
@@ -335,7 +333,7 @@ static int setup_serial_poll(gpib_board_t *board, unsigned int usec_timeout)
return 0;
}
-static int read_serial_poll_byte(gpib_board_t *board, unsigned int pad,
+static int read_serial_poll_byte(struct gpib_board *board, unsigned int pad,
int sad, unsigned int usec_timeout, uint8_t *result)
{
u8 cmd_string[8];
@@ -344,7 +342,7 @@ static int read_serial_poll_byte(gpib_board_t *board, unsigned int pad,
int i;
size_t nbytes;
- dev_dbg(board->gpib_dev, "entering %s(), pad=%i sad=%i\n", __func__, pad, sad);
+ dev_dbg(board->gpib_dev, "entering pad=%i sad=%i\n", pad, sad);
os_start_timer(board, usec_timeout);
ret = ibcac(board, 1, 1);
@@ -361,7 +359,7 @@ static int read_serial_poll_byte(gpib_board_t *board, unsigned int pad,
ret = board->interface->command(board, cmd_string, i, &nbytes);
if (ret < 0 || nbytes < i) {
- pr_err("gpib: failed to setup serial poll\n");
+ dev_err(board->gpib_dev, "failed to setup serial poll\n");
os_remove_timer(board);
return -EIO;
}
@@ -371,7 +369,7 @@ static int read_serial_poll_byte(gpib_board_t *board, unsigned int pad,
// read poll result
ret = board->interface->read(board, result, 1, &end_flag, &nbytes);
if (ret < 0 || nbytes < 1) {
- pr_err("gpib: serial poll failed\n");
+ dev_err(board->gpib_dev, "serial poll failed\n");
os_remove_timer(board);
return -EIO;
}
@@ -380,14 +378,12 @@ static int read_serial_poll_byte(gpib_board_t *board, unsigned int pad,
return 0;
}
-static int cleanup_serial_poll(gpib_board_t *board, unsigned int usec_timeout)
+static int cleanup_serial_poll(struct gpib_board *board, unsigned int usec_timeout)
{
u8 cmd_string[8];
int ret;
size_t bytes_written;
- dev_dbg(board->gpib_dev, "entering %s()\n", __func__);
-
os_start_timer(board, usec_timeout);
ret = ibcac(board, 1, 1);
if (ret < 0) {
@@ -399,7 +395,7 @@ static int cleanup_serial_poll(gpib_board_t *board, unsigned int usec_timeout)
cmd_string[1] = UNT;
ret = board->interface->command(board, cmd_string, 2, &bytes_written);
if (ret < 0 || bytes_written < 2) {
- pr_err("gpib: failed to disable serial poll\n");
+ dev_err(board->gpib_dev, "failed to disable serial poll\n");
os_remove_timer(board);
return -EIO;
}
@@ -408,7 +404,7 @@ static int cleanup_serial_poll(gpib_board_t *board, unsigned int usec_timeout)
return 0;
}
-static int serial_poll_single(gpib_board_t *board, unsigned int pad, int sad,
+static int serial_poll_single(struct gpib_board *board, unsigned int pad, int sad,
unsigned int usec_timeout, uint8_t *result)
{
int retval, cleanup_retval;
@@ -426,7 +422,7 @@ static int serial_poll_single(gpib_board_t *board, unsigned int pad, int sad,
return 0;
}
-int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout)
+int serial_poll_all(struct gpib_board *board, unsigned int usec_timeout)
{
int retval = 0;
struct list_head *cur;
@@ -435,8 +431,6 @@ int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout)
u8 result;
unsigned int num_bytes = 0;
- dev_dbg(board->gpib_dev, "entering %s()\n", __func__);
-
head = &board->device_list;
if (head->next == head)
return 0;
@@ -475,19 +469,19 @@ int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout)
* SPD and UNT are sent at the completion of the poll.
*/
-int dvrsp(gpib_board_t *board, unsigned int pad, int sad,
+int dvrsp(struct gpib_board *board, unsigned int pad, int sad,
unsigned int usec_timeout, uint8_t *result)
{
int status = ibstatus(board);
int retval;
if ((status & CIC) == 0) {
- pr_err("gpib: not CIC during serial poll\n");
+ dev_err(board->gpib_dev, "not CIC during serial poll\n");
return -1;
}
if (pad > MAX_GPIB_PRIMARY_ADDRESS || sad > MAX_GPIB_SECONDARY_ADDRESS || sad < -1) {
- pr_err("gpib: bad address for serial poll");
+ dev_err(board->gpib_dev, "bad address for serial poll");
return -1;
}
@@ -527,7 +521,7 @@ static int init_gpib_file_private(gpib_file_private_t *priv)
int ibopen(struct inode *inode, struct file *filep)
{
unsigned int minor = iminor(inode);
- gpib_board_t *board;
+ struct gpib_board *board;
gpib_file_private_t *priv;
if (minor >= GPIB_MAX_NUM_BOARDS) {
@@ -544,20 +538,16 @@ int ibopen(struct inode *inode, struct file *filep)
priv = filep->private_data;
init_gpib_file_private((gpib_file_private_t *)filep->private_data);
- dev_dbg(board->gpib_dev, "pid %i, gpib: opening minor %d\n", current->pid, minor);
-
if (board->use_count == 0) {
int retval;
retval = request_module("gpib%i", minor);
- if (retval) {
- dev_dbg(board->gpib_dev, "pid %i, gpib: request module returned %i\n",
- current->pid, retval);
- }
+ if (retval)
+ dev_dbg(board->gpib_dev, "request module returned %i\n", retval);
}
if (board->interface) {
if (!try_module_get(board->provider_module)) {
- pr_err("gpib: try_module_get() failed\n");
+ dev_err(board->gpib_dev, "try_module_get() failed\n");
return -EIO;
}
board->use_count++;
@@ -569,7 +559,7 @@ int ibopen(struct inode *inode, struct file *filep)
int ibclose(struct inode *inode, struct file *filep)
{
unsigned int minor = iminor(inode);
- gpib_board_t *board;
+ struct gpib_board *board;
gpib_file_private_t *priv = filep->private_data;
gpib_descriptor_t *desc;
@@ -580,21 +570,19 @@ int ibclose(struct inode *inode, struct file *filep)
board = &board_array[minor];
- dev_dbg(board->gpib_dev, "pid %i, closing minor %d\n", current->pid, minor);
-
if (priv) {
desc = handle_to_descriptor(priv, 0);
if (desc) {
if (desc->autopoll_enabled) {
- dev_dbg(board->gpib_dev, "pid %i, decrementing autospollers\n",
- current->pid);
+ dev_dbg(board->gpib_dev, "decrementing autospollers\n");
if (board->autospollers > 0)
board->autospollers--;
else
- pr_err("gpib: Attempt to decrement zero autospollers\n");
+ dev_err(board->gpib_dev,
+ "Attempt to decrement zero autospollers\n");
}
} else {
- pr_err("gpib: Unexpected null gpib_descriptor\n");
+ dev_err(board->gpib_dev, "Unexpected null gpib_descriptor\n");
}
cleanup_open_devices(priv, board);
@@ -617,7 +605,7 @@ int ibclose(struct inode *inode, struct file *filep)
long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
unsigned int minor = iminor(filep->f_path.dentry->d_inode);
- gpib_board_t *board;
+ struct gpib_board *board;
gpib_file_private_t *file_priv = filep->private_data;
long retval = -ENOTTY;
@@ -630,8 +618,8 @@ long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg)
if (mutex_lock_interruptible(&board->big_gpib_mutex))
return -ERESTARTSYS;
- dev_dbg(board->gpib_dev, "pid %i, ioctl %d, interface=%s, use=%d, onl=%d\n",
- current->pid, cmd & 0xff,
+ dev_dbg(board->gpib_dev, "ioctl %d, interface=%s, use=%d, onl=%d\n",
+ cmd & 0xff,
board->interface ? board->interface->name : "",
board->use_count,
board->online);
@@ -647,13 +635,13 @@ long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg)
break;
}
if (!board->interface) {
- pr_err("gpib: no gpib board configured on /dev/gpib%i\n", minor);
+ dev_err(board->gpib_dev, "no gpib board configured\n");
retval = -ENODEV;
goto done;
}
if (file_priv->got_module == 0) {
if (!try_module_get(board->provider_module)) {
- pr_err("gpib: try_module_get() failed\n");
+ dev_err(board->gpib_dev, "try_module_get() failed\n");
retval = -EIO;
goto done;
}
@@ -699,8 +687,6 @@ long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg)
}
if (!board->online) {
- pr_err("gpib: ioctl %i invalid for offline board\n",
- cmd & 0xff);
retval = -EINVAL;
goto done;
}
@@ -737,8 +723,6 @@ long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg)
spin_lock(&board->locking_pid_spinlock);
if (current->pid != board->locking_pid) {
spin_unlock(&board->locking_pid_spinlock);
- pr_err("gpib: need to hold board lock to perform ioctl %i\n",
- cmd & 0xff);
retval = -EPERM;
goto done;
}
@@ -822,7 +806,7 @@ done:
return retval;
}
-static int board_type_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, unsigned long arg)
+static int board_type_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, unsigned long arg)
{
struct list_head *list_ptr;
board_type_ioctl_t cmd;
@@ -830,10 +814,8 @@ static int board_type_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (board->online) {
- pr_err("gpib: can't change board type while board is online.\n");
+ if (board->online)
return -EBUSY;
- }
retval = copy_from_user(&cmd, (void __user *)arg, sizeof(board_type_ioctl_t));
if (retval)
@@ -875,7 +857,7 @@ static int board_type_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
return -EINVAL;
}
-static int read_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
+static int read_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board,
unsigned long arg)
{
read_write_ioctl_t read_cmd;
@@ -951,7 +933,7 @@ static int read_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
}
static int command_ioctl(gpib_file_private_t *file_priv,
- gpib_board_t *board, unsigned long arg)
+ struct gpib_board *board, unsigned long arg)
{
read_write_ioctl_t cmd;
u8 __user *userbuf;
@@ -1034,7 +1016,7 @@ static int command_ioctl(gpib_file_private_t *file_priv,
return retval;
}
-static int write_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
+static int write_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board,
unsigned long arg)
{
read_write_ioctl_t write_cmd;
@@ -1105,7 +1087,7 @@ static int write_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
return retval;
}
-static int status_bytes_ioctl(gpib_board_t *board, unsigned long arg)
+static int status_bytes_ioctl(struct gpib_board *board, unsigned long arg)
{
gpib_status_queue_t *device;
spoll_bytes_ioctl_t cmd;
@@ -1128,7 +1110,7 @@ static int status_bytes_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int increment_open_device_count(gpib_board_t *board, struct list_head *head,
+static int increment_open_device_count(struct gpib_board *board, struct list_head *head,
unsigned int pad, int sad)
{
struct list_head *list_ptr;
@@ -1140,8 +1122,8 @@ static int increment_open_device_count(gpib_board_t *board, struct list_head *he
for (list_ptr = head->next; list_ptr != head; list_ptr = list_ptr->next) {
device = list_entry(list_ptr, gpib_status_queue_t, list);
if (gpib_address_equal(device->pad, device->sad, pad, sad)) {
- dev_dbg(board->gpib_dev, "pid %i, incrementing open count for pad %i, sad %i\n",
- current->pid, device->pad, device->sad);
+ dev_dbg(board->gpib_dev, "incrementing open count for pad %i, sad %i\n",
+ device->pad, device->sad);
device->reference_count++;
return 0;
}
@@ -1158,13 +1140,12 @@ static int increment_open_device_count(gpib_board_t *board, struct list_head *he
list_add(&device->list, head);
- dev_dbg(board->gpib_dev, "pid %i, opened pad %i, sad %i\n",
- current->pid, device->pad, device->sad);
+ dev_dbg(board->gpib_dev, "opened pad %i, sad %i\n", device->pad, device->sad);
return 0;
}
-static int subtract_open_device_count(gpib_board_t *board, struct list_head *head,
+static int subtract_open_device_count(struct gpib_board *board, struct list_head *head,
unsigned int pad, int sad, unsigned int count)
{
gpib_status_queue_t *device;
@@ -1173,33 +1154,33 @@ static int subtract_open_device_count(gpib_board_t *board, struct list_head *hea
for (list_ptr = head->next; list_ptr != head; list_ptr = list_ptr->next) {
device = list_entry(list_ptr, gpib_status_queue_t, list);
if (gpib_address_equal(device->pad, device->sad, pad, sad)) {
- dev_dbg(board->gpib_dev, "pid %i, decrementing open count for pad %i, sad %i\n",
- current->pid, device->pad, device->sad);
+ dev_dbg(board->gpib_dev, "decrementing open count for pad %i, sad %i\n",
+ device->pad, device->sad);
if (count > device->reference_count) {
- pr_err("gpib: bug! in %s()\n", __func__);
+ dev_err(board->gpib_dev, "bug! in %s()\n", __func__);
return -EINVAL;
}
device->reference_count -= count;
if (device->reference_count == 0) {
- dev_dbg(board->gpib_dev, "pid %i, closing pad %i, sad %i\n",
- current->pid, device->pad, device->sad);
+ dev_dbg(board->gpib_dev, "closing pad %i, sad %i\n",
+ device->pad, device->sad);
list_del(list_ptr);
kfree(device);
}
return 0;
}
}
- pr_err("gpib: bug! tried to close address that was never opened!\n");
+ dev_err(board->gpib_dev, "bug! tried to close address that was never opened!\n");
return -EINVAL;
}
-static inline int decrement_open_device_count(gpib_board_t *board, struct list_head *head,
+static inline int decrement_open_device_count(struct gpib_board *board, struct list_head *head,
unsigned int pad, int sad)
{
return subtract_open_device_count(board, head, pad, sad, 1);
}
-static int cleanup_open_devices(gpib_file_private_t *file_priv, gpib_board_t *board)
+static int cleanup_open_devices(gpib_file_private_t *file_priv, struct gpib_board *board)
{
int retval = 0;
int i;
@@ -1224,7 +1205,7 @@ static int cleanup_open_devices(gpib_file_private_t *file_priv, gpib_board_t *bo
return 0;
}
-static int open_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg)
+static int open_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg)
{
open_dev_ioctl_t open_dev_cmd;
int retval;
@@ -1274,7 +1255,7 @@ static int open_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long
return 0;
}
-static int close_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg)
+static int close_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg)
{
close_dev_ioctl_t cmd;
gpib_file_private_t *file_priv = filep->private_data;
@@ -1301,13 +1282,11 @@ static int close_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned lon
return 0;
}
-static int serial_poll_ioctl(gpib_board_t *board, unsigned long arg)
+static int serial_poll_ioctl(struct gpib_board *board, unsigned long arg)
{
serial_poll_ioctl_t serial_cmd;
int retval;
- dev_dbg(board->gpib_dev, "pid %i, entering %s()\n", current->pid, __func__);
-
retval = copy_from_user(&serial_cmd, (void __user *)arg, sizeof(serial_cmd));
if (retval)
return -EFAULT;
@@ -1324,7 +1303,7 @@ static int serial_poll_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int wait_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
+static int wait_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board,
unsigned long arg)
{
wait_ioctl_t wait_cmd;
@@ -1351,7 +1330,7 @@ static int wait_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board,
return 0;
}
-static int parallel_poll_ioctl(gpib_board_t *board, unsigned long arg)
+static int parallel_poll_ioctl(struct gpib_board *board, unsigned long arg)
{
u8 poll_byte;
int retval;
@@ -1367,7 +1346,7 @@ static int parallel_poll_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int online_ioctl(gpib_board_t *board, unsigned long arg)
+static int online_ioctl(struct gpib_board *board, unsigned long arg)
{
online_ioctl_t online_cmd;
int retval;
@@ -1411,7 +1390,7 @@ static int online_ioctl(gpib_board_t *board, unsigned long arg)
return retval;
}
-static int remote_enable_ioctl(gpib_board_t *board, unsigned long arg)
+static int remote_enable_ioctl(struct gpib_board *board, unsigned long arg)
{
int enable;
int retval;
@@ -1423,7 +1402,7 @@ static int remote_enable_ioctl(gpib_board_t *board, unsigned long arg)
return ibsre(board, enable);
}
-static int take_control_ioctl(gpib_board_t *board, unsigned long arg)
+static int take_control_ioctl(struct gpib_board *board, unsigned long arg)
{
int synchronous;
int retval;
@@ -1435,7 +1414,7 @@ static int take_control_ioctl(gpib_board_t *board, unsigned long arg)
return ibcac(board, synchronous, 1);
}
-static int line_status_ioctl(gpib_board_t *board, unsigned long arg)
+static int line_status_ioctl(struct gpib_board *board, unsigned long arg)
{
short lines;
int retval;
@@ -1451,7 +1430,7 @@ static int line_status_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int pad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int pad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg)
{
pad_ioctl_t cmd;
@@ -1487,7 +1466,7 @@ static int pad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
return 0;
}
-static int sad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int sad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg)
{
sad_ioctl_t cmd;
@@ -1522,7 +1501,7 @@ static int sad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
return 0;
}
-static int eos_ioctl(gpib_board_t *board, unsigned long arg)
+static int eos_ioctl(struct gpib_board *board, unsigned long arg)
{
eos_ioctl_t eos_cmd;
int retval;
@@ -1534,7 +1513,7 @@ static int eos_ioctl(gpib_board_t *board, unsigned long arg)
return ibeos(board, eos_cmd.eos, eos_cmd.eos_flags);
}
-static int request_service_ioctl(gpib_board_t *board, unsigned long arg)
+static int request_service_ioctl(struct gpib_board *board, unsigned long arg)
{
u8 status_byte;
int retval;
@@ -1546,7 +1525,7 @@ static int request_service_ioctl(gpib_board_t *board, unsigned long arg)
return ibrsv2(board, status_byte, status_byte & request_service_bit);
}
-static int request_service2_ioctl(gpib_board_t *board, unsigned long arg)
+static int request_service2_ioctl(struct gpib_board *board, unsigned long arg)
{
request_service2_t request_service2_cmd;
int retval;
@@ -1613,7 +1592,7 @@ static int dma_ioctl(gpib_board_config_t *config, unsigned long arg)
return 0;
}
-static int autospoll_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int autospoll_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg)
{
autospoll_ioctl_t enable;
@@ -1639,18 +1618,19 @@ static int autospoll_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
board->autospollers--;
retval = 0;
} else {
- pr_err("gpib: tried to set number of autospollers negative\n");
+ dev_err(board->gpib_dev,
+ "tried to set number of autospollers negative\n");
retval = -EINVAL;
}
} else {
- pr_err("gpib: autopoll disable requested before enable\n");
+ dev_err(board->gpib_dev, "autopoll disable requested before enable\n");
retval = -EINVAL;
}
}
return retval;
}
-static int mutex_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
+static int mutex_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv,
unsigned long arg)
{
int retval, lock_mutex;
@@ -1661,10 +1641,8 @@ static int mutex_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
if (lock_mutex) {
retval = mutex_lock_interruptible(&board->user_mutex);
- if (retval) {
- pr_warn("gpib: ioctl interrupted while waiting on lock\n");
+ if (retval)
return -ERESTARTSYS;
- }
spin_lock(&board->locking_pid_spinlock);
board->locking_pid = current->pid;
@@ -1672,13 +1650,12 @@ static int mutex_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
atomic_set(&file_priv->holding_mutex, 1);
- dev_dbg(board->gpib_dev, "pid %i, locked board %d mutex\n",
- current->pid, board->minor);
+ dev_dbg(board->gpib_dev, "locked board mutex\n");
} else {
spin_lock(&board->locking_pid_spinlock);
if (current->pid != board->locking_pid) {
- pr_err("gpib: bug! pid %i tried to release mutex held by pid %i\n",
- current->pid, board->locking_pid);
+ dev_err(board->gpib_dev, "bug! pid %i tried to release mutex held by pid %i\n",
+ current->pid, board->locking_pid);
spin_unlock(&board->locking_pid_spinlock);
return -EPERM;
}
@@ -1688,13 +1665,12 @@ static int mutex_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv,
atomic_set(&file_priv->holding_mutex, 0);
mutex_unlock(&board->user_mutex);
- dev_dbg(board->gpib_dev, "pid %i, unlocked board %i mutex\n",
- current->pid, board->minor);
+ dev_dbg(board->gpib_dev, "unlocked board mutex\n");
}
return 0;
}
-static int timeout_ioctl(gpib_board_t *board, unsigned long arg)
+static int timeout_ioctl(struct gpib_board *board, unsigned long arg)
{
unsigned int timeout;
int retval;
@@ -1704,12 +1680,12 @@ static int timeout_ioctl(gpib_board_t *board, unsigned long arg)
return -EFAULT;
board->usec_timeout = timeout;
- dev_dbg(board->gpib_dev, "pid %i, timeout set to %i usec\n", current->pid, timeout);
+ dev_dbg(board->gpib_dev, "timeout set to %i usec\n", timeout);
return 0;
}
-static int ppc_ioctl(gpib_board_t *board, unsigned long arg)
+static int ppc_ioctl(struct gpib_board *board, unsigned long arg)
{
ppoll_config_ioctl_t cmd;
int retval;
@@ -1735,7 +1711,7 @@ static int ppc_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int set_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg)
+static int set_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg)
{
local_ppoll_mode_ioctl_t cmd;
int retval;
@@ -1744,17 +1720,15 @@ static int set_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg)
if (retval)
return -EFAULT;
- if (!board->interface->local_parallel_poll_mode) {
- pr_warn("gpib: local/remote parallel poll mode not supported by driver.");
- return -EIO;
- }
+ if (!board->interface->local_parallel_poll_mode)
+ return -ENOENT;
board->local_ppoll_mode = cmd != 0;
board->interface->local_parallel_poll_mode(board, board->local_ppoll_mode);
return 0;
}
-static int get_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg)
+static int get_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg)
{
local_ppoll_mode_ioctl_t cmd;
int retval;
@@ -1767,7 +1741,7 @@ static int get_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int query_board_rsv_ioctl(gpib_board_t *board, unsigned long arg)
+static int query_board_rsv_ioctl(struct gpib_board *board, unsigned long arg)
{
int status;
int retval;
@@ -1781,7 +1755,7 @@ static int query_board_rsv_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int board_info_ioctl(const gpib_board_t *board, unsigned long arg)
+static int board_info_ioctl(const struct gpib_board *board, unsigned long arg)
{
board_info_ioctl_t info;
int retval;
@@ -1804,7 +1778,7 @@ static int board_info_ioctl(const gpib_board_t *board, unsigned long arg)
return 0;
}
-static int interface_clear_ioctl(gpib_board_t *board, unsigned long arg)
+static int interface_clear_ioctl(struct gpib_board *board, unsigned long arg)
{
unsigned int usec_duration;
int retval;
@@ -1867,7 +1841,7 @@ unsigned int num_gpib_events(const gpib_event_queue_t *queue)
return queue->num_events;
}
-static int push_gpib_event_nolock(gpib_board_t *board, short event_type)
+static int push_gpib_event_nolock(struct gpib_board *board, short event_type)
{
gpib_event_queue_t *queue = &board->event_queue;
struct list_head *head = &queue->event_head;
@@ -1887,7 +1861,7 @@ static int push_gpib_event_nolock(gpib_board_t *board, short event_type)
event = kmalloc(sizeof(gpib_event_t), GFP_ATOMIC);
if (!event) {
queue->dropped_event = 1;
- pr_err("gpib: failed to allocate memory for event\n");
+ dev_err(board->gpib_dev, "failed to allocate memory for event\n");
return -ENOMEM;
}
@@ -1905,7 +1879,7 @@ static int push_gpib_event_nolock(gpib_board_t *board, short event_type)
}
// push event onto back of event queue
-int push_gpib_event(gpib_board_t *board, short event_type)
+int push_gpib_event(struct gpib_board *board, short event_type)
{
unsigned long flags;
int retval;
@@ -1923,7 +1897,7 @@ int push_gpib_event(gpib_board_t *board, short event_type)
}
EXPORT_SYMBOL(push_gpib_event);
-static int pop_gpib_event_nolock(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type)
+static int pop_gpib_event_nolock(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type)
{
struct list_head *head = &queue->event_head;
struct list_head *front = head->next;
@@ -1957,7 +1931,7 @@ static int pop_gpib_event_nolock(gpib_board_t *board, gpib_event_queue_t *queue,
}
// pop event from front of event queue
-int pop_gpib_event(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type)
+int pop_gpib_event(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type)
{
unsigned long flags;
int retval;
@@ -1968,7 +1942,7 @@ int pop_gpib_event(gpib_board_t *board, gpib_event_queue_t *queue, short *event_
return retval;
}
-static int event_ioctl(gpib_board_t *board, unsigned long arg)
+static int event_ioctl(struct gpib_board *board, unsigned long arg)
{
event_ioctl_t user_event;
int retval;
@@ -1987,7 +1961,7 @@ static int event_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int request_system_control_ioctl(gpib_board_t *board, unsigned long arg)
+static int request_system_control_ioctl(struct gpib_board *board, unsigned long arg)
{
rsc_ioctl_t request_control;
int retval;
@@ -2001,16 +1975,14 @@ static int request_system_control_ioctl(gpib_board_t *board, unsigned long arg)
return 0;
}
-static int t1_delay_ioctl(gpib_board_t *board, unsigned long arg)
+static int t1_delay_ioctl(struct gpib_board *board, unsigned long arg)
{
t1_delay_ioctl_t cmd;
unsigned int delay;
int retval;
- if (!board->interface->t1_delay) {
- pr_warn("gpib: t1 delay not implemented in driver!\n");
- return -EIO;
- }
+ if (!board->interface->t1_delay)
+ return -ENOENT;
retval = copy_from_user(&cmd, (void __user *)arg, sizeof(cmd));
if (retval)
@@ -2018,8 +1990,11 @@ static int t1_delay_ioctl(gpib_board_t *board, unsigned long arg)
delay = cmd;
- board->t1_nano_sec = board->interface->t1_delay(board, delay);
+ retval = board->interface->t1_delay(board, delay);
+ if (retval < 0)
+ return retval;
+ board->t1_nano_sec = retval;
return 0;
}
@@ -2032,7 +2007,7 @@ static const struct file_operations ib_fops = {
.release = &ibclose,
};
-gpib_board_t board_array[GPIB_MAX_NUM_BOARDS];
+struct gpib_board board_array[GPIB_MAX_NUM_BOARDS];
LIST_HEAD(registered_drivers);
@@ -2067,7 +2042,7 @@ void gpib_unregister_driver(gpib_interface_t *interface)
struct list_head *list_ptr;
for (i = 0; i < GPIB_MAX_NUM_BOARDS; i++) {
- gpib_board_t *board = &board_array[i];
+ struct gpib_board *board = &board_array[i];
if (board->interface == interface) {
if (board->use_count > 0)
@@ -2087,7 +2062,6 @@ void gpib_unregister_driver(gpib_interface_t *interface)
kfree(entry);
}
}
- pr_info("gpib: unregistered %s interface\n", interface->name);
}
EXPORT_SYMBOL(gpib_unregister_driver);
@@ -2098,7 +2072,7 @@ static void init_gpib_board_config(gpib_board_config_t *config)
config->pci_slot = -1;
}
-void init_gpib_board(gpib_board_t *board)
+void init_gpib_board(struct gpib_board *board)
{
board->interface = NULL;
board->provider_module = NULL;
@@ -2133,7 +2107,7 @@ void init_gpib_board(gpib_board_t *board)
board->local_ppoll_mode = 0;
}
-int gpib_allocate_board(gpib_board_t *board)
+int gpib_allocate_board(struct gpib_board *board)
{
if (!board->buffer) {
board->buffer_length = 0x4000;
@@ -2146,7 +2120,7 @@ int gpib_allocate_board(gpib_board_t *board)
return 0;
}
-void gpib_deallocate_board(gpib_board_t *board)
+void gpib_deallocate_board(struct gpib_board *board)
{
short dummy;
@@ -2159,7 +2133,7 @@ void gpib_deallocate_board(gpib_board_t *board)
pop_gpib_event(board, &board->event_queue, &dummy);
}
-static void init_board_array(gpib_board_t *board_array, unsigned int length)
+static void init_board_array(struct gpib_board *board_array, unsigned int length)
{
int i;
@@ -2184,7 +2158,7 @@ static int __init gpib_common_init_module(void)
{
int i;
- pr_info("Linux-GPIB core driver\n");
+ pr_info("GPIB core driver\n");
init_board_array(board_array, GPIB_MAX_NUM_BOARDS);
if (register_chrdev(GPIB_CODE, "gpib", &ib_fops)) {
pr_err("gpib: can't get major %d\n", GPIB_CODE);
diff --git a/drivers/staging/gpib/common/iblib.c b/drivers/staging/gpib/common/iblib.c
index 5f6fa135f505..6cca8a49e839 100644
--- a/drivers/staging/gpib/common/iblib.c
+++ b/drivers/staging/gpib/common/iblib.c
@@ -4,6 +4,8 @@
* copyright : (C) 2001, 2002 by Frank Mori Hess
***************************************************************************/
+#define dev_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include "ibsys.h"
#include <linux/delay.h>
#include <linux/kthread.h>
@@ -19,15 +21,13 @@
* If fallback_to_async is non-zero, try to take control asynchronously
* if synchronous attempt fails.
*/
-int ibcac(gpib_board_t *board, int sync, int fallback_to_async)
+int ibcac(struct gpib_board *board, int sync, int fallback_to_async)
{
int status = ibstatus(board);
int retval;
- if ((status & CIC) == 0) {
- pr_err("gpib: not CIC during %s()\n", __func__);
- return -1;
- }
+ if ((status & CIC) == 0)
+ return -EINVAL;
if (status & ATN)
return 0;
@@ -61,7 +61,7 @@ int ibcac(gpib_board_t *board, int sync, int fallback_to_async)
* set the skip_check_for_command_acceptors flag in their
* gpib_interface_struct to avoid useless overhead.
*/
-static int check_for_command_acceptors(gpib_board_t *board)
+static int check_for_command_acceptors(struct gpib_board *board)
{
int lines;
@@ -76,15 +76,8 @@ static int check_for_command_acceptors(gpib_board_t *board)
if (lines < 0)
return lines;
- if (lines & ValidATN) {
- if ((lines & BusATN) == 0) {
- pr_err("gpib: ATN not asserted in %s()?", __func__);
- return 0;
- }
- }
-
- if ((lines & ValidNRFD) && (lines & ValidNDAC)) {
- if ((lines & BusNRFD) == 0 && (lines & BusNDAC) == 0)
+ if ((lines & VALID_NRFD) && (lines & VALID_NDAC)) {
+ if ((lines & BUS_NRFD) == 0 && (lines & BUS_NDAC) == 0)
return -ENOTCONN;
}
@@ -103,7 +96,7 @@ static int check_for_command_acceptors(gpib_board_t *board)
* must be called to initialize the GPIB and enable
* the interface to leave the controller idle state.
*/
-int ibcmd(gpib_board_t *board, uint8_t *buf, size_t length, size_t *bytes_written)
+int ibcmd(struct gpib_board *board, uint8_t *buf, size_t length, size_t *bytes_written)
{
ssize_t ret = 0;
int status;
@@ -112,10 +105,8 @@ int ibcmd(gpib_board_t *board, uint8_t *buf, size_t length, size_t *bytes_writte
status = ibstatus(board);
- if ((status & CIC) == 0) {
- pr_err("gpib: cannot send command when not controller-in-charge\n");
- return -EIO;
- }
+ if ((status & CIC) == 0)
+ return -EINVAL;
os_start_timer(board, board->usec_timeout);
@@ -140,26 +131,22 @@ int ibcmd(gpib_board_t *board, uint8_t *buf, size_t length, size_t *bytes_writte
* active state, i.e., turn ATN off.
*/
-int ibgts(gpib_board_t *board)
+int ibgts(struct gpib_board *board)
{
int status = ibstatus(board);
int retval;
- if ((status & CIC) == 0) {
- pr_err("gpib: not CIC during %s()\n", __func__);
- return -1;
- }
+ if ((status & CIC) == 0)
+ return -EINVAL;
retval = board->interface->go_to_standby(board); /* go to standby */
- if (retval < 0)
- pr_err("gpib: error while going to standby\n");
board->interface->update_status(board, 0);
return retval;
}
-static int autospoll_wait_should_wake_up(gpib_board_t *board)
+static int autospoll_wait_should_wake_up(struct gpib_board *board)
{
int retval;
@@ -175,7 +162,7 @@ static int autospoll_wait_should_wake_up(gpib_board_t *board)
static int autospoll_thread(void *board_void)
{
- gpib_board_t *board = board_void;
+ struct gpib_board *board = board_void;
int retval = 0;
dev_dbg(board->gpib_dev, "entering autospoll thread\n");
@@ -200,20 +187,19 @@ static int autospoll_thread(void *board_void)
retval = autopoll_all_devices(board);
module_put(board->provider_module);
} else {
- pr_err("gpib%i: %s: try_module_get() failed!\n", board->minor, __func__);
+ dev_err(board->gpib_dev, "try_module_get() failed!\n");
}
if (retval <= 0) {
- pr_err("gpib%i: %s: stuck SRQ\n", board->minor, __func__);
+ dev_err(board->gpib_dev, "stuck SRQ\n");
atomic_set(&board->stuck_srq, 1); // XXX could be better
set_bit(SRQI_NUM, &board->status);
}
}
- pr_info("gpib%i: exiting autospoll thread\n", board->minor);
return retval;
}
-int ibonline(gpib_board_t *board)
+int ibonline(struct gpib_board *board)
{
int retval;
@@ -230,7 +216,6 @@ int ibonline(gpib_board_t *board)
retval = board->interface->attach(board, &board->config);
if (retval < 0) {
board->interface->detach(board);
- pr_err("gpib: interface attach failed\n");
return retval;
}
/* nios2nommu on 2.6.11 uclinux kernel has weird problems
@@ -241,19 +226,19 @@ int ibonline(gpib_board_t *board)
"gpib%d_autospoll_kthread", board->minor);
retval = IS_ERR(board->autospoll_task);
if (retval) {
- pr_err("gpib: failed to create autospoll thread\n");
+ dev_err(board->gpib_dev, "failed to create autospoll thread\n");
board->interface->detach(board);
return retval;
}
#endif
board->online = 1;
- dev_dbg(board->gpib_dev, "gpib: board online\n");
+ dev_dbg(board->gpib_dev, "board online\n");
return 0;
}
/* XXX need to make sure board is generally not in use (grab board lock?) */
-int iboffline(gpib_board_t *board)
+int iboffline(struct gpib_board *board)
{
int retval;
@@ -265,14 +250,14 @@ int iboffline(gpib_board_t *board)
if (board->autospoll_task && !IS_ERR(board->autospoll_task)) {
retval = kthread_stop(board->autospoll_task);
if (retval)
- pr_err("gpib: kthread_stop returned %i\n", retval);
+ dev_err(board->gpib_dev, "kthread_stop returned %i\n", retval);
board->autospoll_task = NULL;
}
board->interface->detach(board);
gpib_deallocate_board(board);
board->online = 0;
- dev_dbg(board->gpib_dev, "gpib: board offline\n");
+ dev_dbg(board->gpib_dev, "board offline\n");
return 0;
}
@@ -285,7 +270,7 @@ int iboffline(gpib_board_t *board)
* Next LSB (bits 8-15) - STATUS lines mask (lines that are currently set).
*
*/
-int iblines(const gpib_board_t *board, short *lines)
+int iblines(const struct gpib_board *board, short *lines)
{
int retval;
@@ -312,7 +297,7 @@ int iblines(const gpib_board_t *board, short *lines)
* calling ibcmd.
*/
-int ibrd(gpib_board_t *board, uint8_t *buf, size_t length, int *end_flag, size_t *nbytes)
+int ibrd(struct gpib_board *board, uint8_t *buf, size_t length, int *end_flag, size_t *nbytes)
{
ssize_t ret = 0;
int retval;
@@ -320,10 +305,8 @@ int ibrd(gpib_board_t *board, uint8_t *buf, size_t length, int *end_flag, size_t
*nbytes = 0;
*end_flag = 0;
- if (length == 0) {
- pr_warn("gpib: %s() called with zero length?\n", __func__);
+ if (length == 0)
return 0;
- }
if (board->master) {
retval = ibgts(board);
@@ -338,10 +321,9 @@ int ibrd(gpib_board_t *board, uint8_t *buf, size_t length, int *end_flag, size_t
do {
ret = board->interface->read(board, buf, length - *nbytes, end_flag, &bytes_read);
- if (ret < 0) {
- pr_err("gpib read error\n");
+ if (ret < 0)
goto ibrd_out;
- }
+
buf += bytes_read;
*nbytes += bytes_read;
if (need_resched())
@@ -361,7 +343,7 @@ ibrd_out:
* 1. Prior to conducting the poll the interface is placed
* in the controller active state.
*/
-int ibrpp(gpib_board_t *board, uint8_t *result)
+int ibrpp(struct gpib_board *board, uint8_t *result)
{
int retval = 0;
@@ -370,15 +352,13 @@ int ibrpp(gpib_board_t *board, uint8_t *result)
if (retval)
return -1;
- if (board->interface->parallel_poll(board, result)) {
- pr_err("gpib: parallel poll failed\n");
- retval = -1;
- }
+ retval = board->interface->parallel_poll(board, result);
+
os_remove_timer(board);
return retval;
}
-int ibppc(gpib_board_t *board, uint8_t configuration)
+int ibppc(struct gpib_board *board, uint8_t configuration)
{
configuration &= 0x1f;
board->interface->parallel_poll_configure(board, configuration);
@@ -387,15 +367,13 @@ int ibppc(gpib_board_t *board, uint8_t configuration)
return 0;
}
-int ibrsv2(gpib_board_t *board, uint8_t status_byte, int new_reason_for_service)
+int ibrsv2(struct gpib_board *board, uint8_t status_byte, int new_reason_for_service)
{
int board_status = ibstatus(board);
const unsigned int MSS = status_byte & request_service_bit;
- if ((board_status & CIC)) {
- pr_err("gpib: interface requested service while CIC\n");
+ if ((board_status & CIC))
return -EINVAL;
- }
if (MSS == 0 && new_reason_for_service)
return -EINVAL;
@@ -422,21 +400,17 @@ int ibrsv2(gpib_board_t *board, uint8_t status_byte, int new_reason_for_service)
* ibcmd in order to initialize the bus and enable the
* interface to leave the controller idle state.
*/
-int ibsic(gpib_board_t *board, unsigned int usec_duration)
+int ibsic(struct gpib_board *board, unsigned int usec_duration)
{
- if (board->master == 0) {
- pr_err("gpib: tried to assert IFC when not system controller\n");
- return -1;
- }
+ if (board->master == 0)
+ return -EINVAL;
if (usec_duration < 100)
usec_duration = 100;
- if (usec_duration > 1000) {
+ if (usec_duration > 1000)
usec_duration = 1000;
- pr_warn("gpib: warning, shortening long udelay\n");
- }
- dev_dbg(board->gpib_dev, "sending interface clear\n");
+ dev_dbg(board->gpib_dev, "sending interface clear, delay = %ius\n", usec_duration);
board->interface->interface_clear(board, 1);
udelay(usec_duration);
board->interface->interface_clear(board, 0);
@@ -444,26 +418,22 @@ int ibsic(gpib_board_t *board, unsigned int usec_duration)
return 0;
}
-void ibrsc(gpib_board_t *board, int request_control)
+ /* FIXME make int */
+void ibrsc(struct gpib_board *board, int request_control)
{
board->master = request_control != 0;
- if (!board->interface->request_system_control) {
- pr_err("gpib: bug! driver does not implement request_system_control()\n");
- return;
- }
- board->interface->request_system_control(board, request_control);
+ if (board->interface->request_system_control)
+ board->interface->request_system_control(board, request_control);
}
/*
* IBSRE
* Send REN true if v is non-zero or false if v is zero.
*/
-int ibsre(gpib_board_t *board, int enable)
+int ibsre(struct gpib_board *board, int enable)
{
- if (board->master == 0) {
- pr_err("gpib: tried to set REN when not system controller\n");
- return -1;
- }
+ if (board->master == 0)
+ return -EINVAL;
board->interface->remote_enable(board, enable); /* set or clear REN */
if (!enable)
@@ -477,12 +447,11 @@ int ibsre(gpib_board_t *board, int enable)
* change the GPIB address of the interface board. The address
* must be 0 through 30. ibonl resets the address to PAD.
*/
-int ibpad(gpib_board_t *board, unsigned int addr)
+int ibpad(struct gpib_board *board, unsigned int addr)
{
- if (addr > MAX_GPIB_PRIMARY_ADDRESS) {
- pr_err("gpib: invalid primary address %u\n", addr);
- return -1;
- }
+ if (addr > MAX_GPIB_PRIMARY_ADDRESS)
+ return -EINVAL;
+
board->pad = addr;
if (board->online)
board->interface->primary_address(board, board->pad);
@@ -496,12 +465,10 @@ int ibpad(gpib_board_t *board, unsigned int addr)
* The address must be 0 through 30, or negative disables. ibonl resets the
* address to SAD.
*/
-int ibsad(gpib_board_t *board, int addr)
+int ibsad(struct gpib_board *board, int addr)
{
- if (addr > MAX_GPIB_SECONDARY_ADDRESS) {
- pr_err("gpib: invalid secondary address %i\n", addr);
- return -1;
- }
+ if (addr > MAX_GPIB_SECONDARY_ADDRESS)
+ return -EINVAL;
board->sad = addr;
if (board->online) {
if (board->sad >= 0)
@@ -519,14 +486,12 @@ int ibsad(gpib_board_t *board, int addr)
* Set the end-of-string modes for I/O operations to v.
*
*/
-int ibeos(gpib_board_t *board, int eos, int eosflags)
+int ibeos(struct gpib_board *board, int eos, int eosflags)
{
int retval;
- if (eosflags & ~EOS_MASK) {
- pr_err("bad EOS modes\n");
+ if (eosflags & ~EOS_MASK)
return -EINVAL;
- }
if (eosflags & REOS) {
retval = board->interface->enable_eos(board, eos, eosflags & BIN);
} else {
@@ -536,12 +501,12 @@ int ibeos(gpib_board_t *board, int eos, int eosflags)
return retval;
}
-int ibstatus(gpib_board_t *board)
+int ibstatus(struct gpib_board *board)
{
return general_ibstatus(board, NULL, 0, 0, NULL);
}
-int general_ibstatus(gpib_board_t *board, const gpib_status_queue_t *device,
+int general_ibstatus(struct gpib_board *board, const gpib_status_queue_t *device,
int clear_mask, int set_mask, gpib_descriptor_t *desc)
{
int status = 0;
@@ -555,8 +520,8 @@ int general_ibstatus(gpib_board_t *board, const gpib_status_queue_t *device,
status &= ~TIMO;
/* get real SRQI status if we can */
if (iblines(board, &line_status) == 0) {
- if ((line_status & ValidSRQ)) {
- if ((line_status & BusSRQ))
+ if ((line_status & VALID_SRQ)) {
+ if ((line_status & BUS_SRQ))
status |= SRQI;
else
status &= ~SRQI;
@@ -587,7 +552,7 @@ int general_ibstatus(gpib_board_t *board, const gpib_status_queue_t *device,
}
struct wait_info {
- gpib_board_t *board;
+ struct gpib_board *board;
struct timer_list timer;
int timed_out;
unsigned long usec_timeout;
@@ -611,7 +576,7 @@ static void init_wait_info(struct wait_info *winfo)
static int wait_satisfied(struct wait_info *winfo, gpib_status_queue_t *status_queue,
int wait_mask, int *status, gpib_descriptor_t *desc)
{
- gpib_board_t *board = winfo->board;
+ struct gpib_board *board = winfo->board;
int temp_status;
if (mutex_lock_interruptible(&board->big_gpib_mutex))
@@ -657,7 +622,7 @@ static void remove_wait_timer(struct wait_info *winfo)
* If the mask is 0 then
* no condition is waited for.
*/
-int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask,
+int ibwait(struct gpib_board *board, int wait_mask, int clear_mask, int set_mask,
int *status, unsigned long usec_timeout, gpib_descriptor_t *desc)
{
int retval = 0;
@@ -712,15 +677,13 @@ int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask,
* well as the interface board itself must be
* addressed by calling ibcmd.
*/
-int ibwrt(gpib_board_t *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written)
+int ibwrt(struct gpib_board *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written)
{
int ret = 0;
int retval;
- if (cnt == 0) {
- pr_warn("gpib: %s() called with zero length?\n", __func__);
+ if (cnt == 0)
return 0;
- }
if (board->master) {
retval = ibgts(board);
diff --git a/drivers/staging/gpib/common/ibsys.h b/drivers/staging/gpib/common/ibsys.h
index da20971e9c7e..19960af809c2 100644
--- a/drivers/staging/gpib/common/ibsys.h
+++ b/drivers/staging/gpib/common/ibsys.h
@@ -19,13 +19,13 @@
#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);
+int gpib_allocate_board(struct gpib_board *board);
+void gpib_deallocate_board(struct gpib_board *board);
unsigned int num_status_bytes(const gpib_status_queue_t *dev);
-int push_status_byte(gpib_board_t *board, gpib_status_queue_t *device, uint8_t poll_byte);
-int pop_status_byte(gpib_board_t *board, gpib_status_queue_t *device, uint8_t *poll_byte);
-gpib_status_queue_t *get_gpib_status_queue(gpib_board_t *board, unsigned int pad, int sad);
-int get_serial_poll_byte(gpib_board_t *board, unsigned int pad, int sad,
+int push_status_byte(struct gpib_board *board, gpib_status_queue_t *device, uint8_t poll_byte);
+int pop_status_byte(struct gpib_board *board, gpib_status_queue_t *device, uint8_t *poll_byte);
+gpib_status_queue_t *get_gpib_status_queue(struct gpib_board *board, unsigned int pad, int sad);
+int get_serial_poll_byte(struct gpib_board *board, unsigned int pad, int sad,
unsigned int usec_timeout, uint8_t *poll_byte);
-int autopoll_all_devices(gpib_board_t *board);
+int autopoll_all_devices(struct gpib_board *board);
diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
index 0304c5de4ccd..a6b1ac169f94 100644
--- a/drivers/staging/gpib/eastwood/fluke_gpib.c
+++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
@@ -7,6 +7,10 @@
* copyright: (C) 2006, 2010, 2015 Fluke Corporation
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "fluke_gpib.h"
#include "gpibP.h"
@@ -20,11 +24,11 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB Driver for Fluke cda devices");
-static int fluke_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config);
-static int fluke_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config);
-static void fluke_detach(gpib_board_t *board);
-static int fluke_config_dma(gpib_board_t *board, int output);
-static irqreturn_t fluke_gpib_internal_interrupt(gpib_board_t *board);
+static int fluke_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config);
+static int fluke_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config);
+static void fluke_detach(struct gpib_board *board);
+static int fluke_config_dma(struct gpib_board *board, int output);
+static irqreturn_t fluke_gpib_internal_interrupt(struct gpib_board *board);
static struct platform_device *fluke_gpib_pdev;
@@ -50,7 +54,7 @@ static void fluke_locking_write_byte(struct nec7210_priv *nec_priv, uint8_t byte
}
// wrappers for interface functions
-static int fluke_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
+static int fluke_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
size_t *bytes_read)
{
struct fluke_priv *priv = board->private_data;
@@ -58,7 +62,7 @@ static int fluke_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *
return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read);
}
-static int fluke_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fluke_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
struct fluke_priv *priv = board->private_data;
@@ -66,28 +70,29 @@ static int fluke_write(gpib_board_t *board, uint8_t *buffer, size_t length,
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
}
-static int fluke_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int fluke_command(struct gpib_board *board, uint8_t *buffer,
+ size_t length, size_t *bytes_written)
{
struct fluke_priv *priv = board->private_data;
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
}
-static int fluke_take_control(gpib_board_t *board, int synchronous)
+static int fluke_take_control(struct gpib_board *board, int synchronous)
{
struct fluke_priv *priv = board->private_data;
return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
}
-static int fluke_go_to_standby(gpib_board_t *board)
+static int fluke_go_to_standby(struct gpib_board *board)
{
struct fluke_priv *priv = board->private_data;
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-static void fluke_request_system_control(gpib_board_t *board, int request_control)
+static void fluke_request_system_control(struct gpib_board *board, int request_control)
{
struct fluke_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -95,91 +100,91 @@ static void fluke_request_system_control(gpib_board_t *board, int request_contro
nec7210_request_system_control(board, nec_priv, request_control);
}
-static void fluke_interface_clear(gpib_board_t *board, int assert)
+static void fluke_interface_clear(struct gpib_board *board, int assert)
{
struct fluke_priv *priv = board->private_data;
nec7210_interface_clear(board, &priv->nec7210_priv, assert);
}
-static void fluke_remote_enable(gpib_board_t *board, int enable)
+static void fluke_remote_enable(struct gpib_board *board, int enable)
{
struct fluke_priv *priv = board->private_data;
nec7210_remote_enable(board, &priv->nec7210_priv, enable);
}
-static int fluke_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int fluke_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct fluke_priv *priv = board->private_data;
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
}
-static void fluke_disable_eos(gpib_board_t *board)
+static void fluke_disable_eos(struct gpib_board *board)
{
struct fluke_priv *priv = board->private_data;
nec7210_disable_eos(board, &priv->nec7210_priv);
}
-static unsigned int fluke_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int fluke_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct fluke_priv *priv = board->private_data;
return nec7210_update_status(board, &priv->nec7210_priv, clear_mask);
}
-static int fluke_primary_address(gpib_board_t *board, unsigned int address)
+static int fluke_primary_address(struct gpib_board *board, unsigned int address)
{
struct fluke_priv *priv = board->private_data;
return nec7210_primary_address(board, &priv->nec7210_priv, address);
}
-static int fluke_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int fluke_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct fluke_priv *priv = board->private_data;
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
}
-static int fluke_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int fluke_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct fluke_priv *priv = board->private_data;
return nec7210_parallel_poll(board, &priv->nec7210_priv, result);
}
-static void fluke_parallel_poll_configure(gpib_board_t *board, uint8_t configuration)
+static void fluke_parallel_poll_configure(struct gpib_board *board, uint8_t configuration)
{
struct fluke_priv *priv = board->private_data;
nec7210_parallel_poll_configure(board, &priv->nec7210_priv, configuration);
}
-static void fluke_parallel_poll_response(gpib_board_t *board, int ist)
+static void fluke_parallel_poll_response(struct gpib_board *board, int ist)
{
struct fluke_priv *priv = board->private_data;
nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist);
}
-static void fluke_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void fluke_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct fluke_priv *priv = board->private_data;
nec7210_serial_poll_response(board, &priv->nec7210_priv, status);
}
-static uint8_t fluke_serial_poll_status(gpib_board_t *board)
+static uint8_t fluke_serial_poll_status(struct gpib_board *board)
{
struct fluke_priv *priv = board->private_data;
return nec7210_serial_poll_status(board, &priv->nec7210_priv);
}
-static void fluke_return_to_local(gpib_board_t *board)
+static void fluke_return_to_local(struct gpib_board *board)
{
struct fluke_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -189,39 +194,37 @@ static void fluke_return_to_local(gpib_board_t *board)
write_byte(nec_priv, AUX_RTL, AUXMR);
}
-static int fluke_line_status(const gpib_board_t *board)
+static int fluke_line_status(const struct gpib_board *board)
{
- int status = ValidALL;
+ int status = VALID_ALL;
int bsr_bits;
struct fluke_priv *e_priv;
- struct nec7210_priv *nec_priv;
e_priv = board->private_data;
- nec_priv = &e_priv->nec7210_priv;
bsr_bits = fluke_paged_read_byte(e_priv, BUS_STATUS, BUS_STATUS_PAGE);
if ((bsr_bits & BSR_REN_BIT) == 0)
- status |= BusREN;
+ status |= BUS_REN;
if ((bsr_bits & BSR_IFC_BIT) == 0)
- status |= BusIFC;
+ status |= BUS_IFC;
if ((bsr_bits & BSR_SRQ_BIT) == 0)
- status |= BusSRQ;
+ status |= BUS_SRQ;
if ((bsr_bits & BSR_EOI_BIT) == 0)
- status |= BusEOI;
+ status |= BUS_EOI;
if ((bsr_bits & BSR_NRFD_BIT) == 0)
- status |= BusNRFD;
+ status |= BUS_NRFD;
if ((bsr_bits & BSR_NDAC_BIT) == 0)
- status |= BusNDAC;
+ status |= BUS_NDAC;
if ((bsr_bits & BSR_DAV_BIT) == 0)
- status |= BusDAV;
+ status |= BUS_DAV;
if ((bsr_bits & BSR_ATN_BIT) == 0)
- status |= BusATN;
+ status |= BUS_ATN;
return status;
}
-static unsigned int fluke_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int fluke_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct fluke_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -238,7 +241,7 @@ static unsigned int fluke_t1_delay(gpib_board_t *board, unsigned int nano_sec)
return retval;
}
-static int lacs_or_read_ready(gpib_board_t *board)
+static int lacs_or_read_ready(struct gpib_board *board)
{
const struct fluke_priv *e_priv = board->private_data;
const struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -254,7 +257,7 @@ static int lacs_or_read_ready(gpib_board_t *board)
/* Wait until it is possible for a read to do something useful. This
* is not essential, it only exists to prevent RFD holdoff from being released pointlessly.
*/
-static int wait_for_read(gpib_board_t *board)
+static int wait_for_read(struct gpib_board *board)
{
struct fluke_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -263,9 +266,9 @@ static int wait_for_read(gpib_board_t *board)
if (wait_event_interruptible(board->wait,
lacs_or_read_ready(board) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
+ test_bit(TIMO_NUM, &board->status)))
retval = -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state))
@@ -311,34 +314,30 @@ static int source_handshake_is_sids_or_sgns(struct fluke_priv *e_priv)
* If the chip is SGNS it is probably waiting for a a byte to
* be written to it.
*/
-static int wait_for_data_out_ready(gpib_board_t *board)
+static int wait_for_data_out_ready(struct gpib_board *board)
{
struct fluke_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
int retval = 0;
-// printk("%s: enter\n", __FUNCTION__);
if (wait_event_interruptible(board->wait,
(test_bit(TACS_NUM, &board->status) &&
source_handshake_is_sgns(e_priv)) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
+ test_bit(TIMO_NUM, &board->status)))
retval = -ERESTARTSYS;
- }
if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state))
retval = -EINTR;
-// printk("%s: exit, retval=%i\n", __FUNCTION__, retval);
return retval;
}
-static int wait_for_sids_or_sgns(gpib_board_t *board)
+static int wait_for_sids_or_sgns(struct gpib_board *board)
{
struct fluke_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
int retval = 0;
-// printk("%s: enter\n", __FUNCTION__);
if (wait_event_interruptible(board->wait,
source_handshake_is_sids_or_sgns(e_priv) ||
@@ -350,19 +349,17 @@ static int wait_for_sids_or_sgns(gpib_board_t *board)
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state))
retval = -EINTR;
-// printk("%s: exit, retval=%i\n", __FUNCTION__, retval);
return retval;
}
static void fluke_dma_callback(void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct fluke_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
unsigned long flags;
spin_lock_irqsave(&board->spinlock, flags);
-// printk("%s: enter\n", __FUNCTION__);
nec7210_set_reg_bits(nec_priv, IMR1, HR_DOIE | HR_DIIE, HR_DOIE | HR_DIIE);
wake_up_interruptible(&board->wait);
@@ -370,11 +367,11 @@ static void fluke_dma_callback(void *arg)
fluke_gpib_internal_interrupt(board);
clear_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state);
clear_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state);
-// printk("%s: exit\n", __FUNCTION__);
+
spin_unlock_irqrestore(&board->spinlock, flags);
}
-static int fluke_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fluke_dma_write(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *bytes_written)
{
struct fluke_priv *e_priv = board->private_data;
@@ -385,7 +382,7 @@ static int fluke_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length,
struct dma_async_tx_descriptor *tx_desc;
*bytes_written = 0;
-// printk("%s: enter\n", __FUNCTION__);
+
if (WARN_ON_ONCE(length > e_priv->dma_buffer_size))
return -EFAULT;
dmaengine_terminate_all(e_priv->dma_channel);
@@ -403,7 +400,7 @@ static int fluke_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length,
tx_desc = dmaengine_prep_slave_single(e_priv->dma_channel, address, length, DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!tx_desc) {
- pr_err("fluke_gpib: failed to allocate dma transmit descriptor\n");
+ dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n");
retval = -ENOMEM;
goto cleanup;
}
@@ -419,10 +416,8 @@ static int fluke_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length,
clear_bit(WRITE_READY_BN, &nec_priv->state);
set_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state);
- // printk("%s: in spin lock\n", __FUNCTION__);
spin_unlock_irqrestore(&board->spinlock, flags);
-// printk("%s: waiting for write.\n", __FUNCTION__);
// suspend until message is sent
if (wait_event_interruptible(board->wait,
((readl(e_priv->write_transfer_counter) &
@@ -430,7 +425,6 @@ static int fluke_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length,
test_bit(BUS_ERROR_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted!\n");
retval = -ERESTARTSYS;
}
if (test_bit(TIMO_NUM, &board->status))
@@ -459,11 +453,10 @@ static int fluke_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length,
cleanup:
dma_unmap_single(board->dev, address, length, DMA_TO_DEVICE);
-// printk("%s: exit, retval=%d\n", __FUNCTION__, retval);
return retval;
}
-static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fluke_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
struct fluke_priv *e_priv = board->private_data;
@@ -474,7 +467,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
size_t dma_remainder = remainder;
if (!e_priv->dma_channel) {
- pr_err("fluke_gpib: No dma channel available, cannot do accel write.");
+ dev_err(board->gpib_dev, "No dma channel available, cannot do accel write.");
return -ENXIO;
}
@@ -486,7 +479,6 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
if (send_eoi)
--dma_remainder;
-// printk("%s: entering while loop\n", __FUNCTION__);
while (dma_remainder > 0) {
size_t num_bytes;
@@ -512,7 +504,7 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
//handle sending of last byte with eoi
if (send_eoi) {
size_t num_bytes;
- // printk("%s: handling last byte\n", __FUNCTION__);
+
if (WARN_ON_ONCE(remainder != 1))
return -EFAULT;
@@ -533,7 +525,6 @@ static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length
return retval;
remainder -= num_bytes;
}
-// printk("%s: bytes send=%i\n", __FUNCTION__, (int)(length - remainder));
return 0;
}
@@ -544,7 +535,7 @@ static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
result = dmaengine_pause(chan);
if (result < 0) {
- pr_err("fluke_gpib: dma pause failed?\n");
+ pr_err("dma pause failed?\n");
return result;
}
dmaengine_tx_status(chan, cookie, &state);
@@ -553,7 +544,7 @@ static int fluke_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
return state.residue;
}
-static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
+static int fluke_dma_read(struct gpib_board *board, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
struct fluke_priv *e_priv = board->private_data;
@@ -567,10 +558,6 @@ static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
int i;
static const int timeout = 10;
- // printk("%s: enter, bus_address=0x%x, length=%i\n", __FUNCTION__,
- // (unsigned)bus_address,
- // (int)length);
-
*bytes_read = 0;
*end = 0;
if (length == 0)
@@ -589,7 +576,7 @@ static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
bus_address, length, DMA_DEV_TO_MEM,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!tx_desc) {
- pr_err("fluke_gpib: failed to allocate dma transmit descriptor\n");
+ dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n");
dma_unmap_single(NULL, bus_address, length, DMA_FROM_DEVICE);
return -EIO;
}
@@ -608,14 +595,12 @@ static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
clear_bit(READ_READY_BN, &nec_priv->state);
spin_unlock_irqrestore(&board->spinlock, flags);
-// printk("waiting for data transfer.\n");
// wait for data to transfer
if (wait_event_interruptible(board->wait,
test_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state) == 0 ||
test_bit(RECEIVED_END_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_warn("fluke: dma read wait interrupted\n");
retval = -ERESTARTSYS;
}
if (test_bit(TIMO_NUM, &board->status))
@@ -672,7 +657,7 @@ static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer,
return retval;
}
-static int fluke_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fluke_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length,
int *end, size_t *bytes_read)
{
struct fluke_priv *e_priv = board->private_data;
@@ -682,10 +667,6 @@ static int fluke_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
int retval = 0;
size_t dma_nbytes;
-/* printk("%s: enter, buffer=0x%p, length=%i\n", __FUNCTION__,
- * buffer, (int)length);
- * printk("\t dma_buffer=0x%p\n", e_priv->dma_buffer);
- */
*end = 0;
*bytes_read = 0;
@@ -699,7 +680,6 @@ static int fluke_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
nec7210_release_rfd_holdoff(board, nec_priv);
-// printk("%s: entering while loop\n", __FUNCTION__);
while (remain > 0) {
transfer_size = (e_priv->dma_buffer_size < remain) ?
e_priv->dma_buffer_size : remain;
@@ -709,14 +689,12 @@ static int fluke_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
*bytes_read += dma_nbytes;
if (*end)
break;
- if (retval < 0) {
-// printk("%s: early exit, retval=%i\n", __FUNCTION__, (int)retval);
+ if (retval < 0)
return retval;
- }
if (need_resched())
schedule();
}
-// printk("%s: exit, retval=%i\n", __FUNCTION__, (int)retval);
+
return retval;
}
@@ -809,7 +787,7 @@ static gpib_interface_t fluke_interface = {
.return_to_local = fluke_return_to_local,
};
-irqreturn_t fluke_gpib_internal_interrupt(gpib_board_t *board)
+irqreturn_t fluke_gpib_internal_interrupt(struct gpib_board *board)
{
int status0, status1, status2;
struct fluke_priv *priv = board->private_data;
@@ -830,13 +808,6 @@ irqreturn_t fluke_gpib_internal_interrupt(gpib_board_t *board)
if (nec7210_interrupt_have_status(board, nec_priv, status1, status2) == IRQ_HANDLED)
retval = IRQ_HANDLED;
-/*
- * if((status1 & nec_priv->reg_bits[IMR1]) ||
- * (status2 & (nec_priv->reg_bits[IMR2] & IMR2_ENABLE_INTR_MASK)))
- * {
- * printk("fluke: status1 0x%x, status2 0x%x\n", status1, status2);
- * }
- */
if (read_byte(nec_priv, ADR0) & DATA_IN_STATUS) {
if (test_bit(RFD_HOLDOFF_BN, &nec_priv->state))
@@ -853,7 +824,7 @@ irqreturn_t fluke_gpib_internal_interrupt(gpib_board_t *board)
static irqreturn_t fluke_gpib_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
unsigned long flags;
irqreturn_t retval;
@@ -863,7 +834,7 @@ static irqreturn_t fluke_gpib_interrupt(int irq, void *arg)
return retval;
}
-static int fluke_allocate_private(gpib_board_t *board)
+static int fluke_allocate_private(struct gpib_board *board)
{
struct fluke_priv *priv;
@@ -880,7 +851,7 @@ static int fluke_allocate_private(gpib_board_t *board)
return 0;
}
-static void fluke_generic_detach(gpib_board_t *board)
+static void fluke_generic_detach(struct gpib_board *board)
{
if (board->private_data) {
struct fluke_priv *e_priv = board->private_data;
@@ -892,7 +863,7 @@ static void fluke_generic_detach(gpib_board_t *board)
}
// generic part of attach functions shared by all cb7210 boards
-static int fluke_generic_attach(gpib_board_t *board)
+static int fluke_generic_attach(struct gpib_board *board)
{
struct fluke_priv *e_priv;
struct nec7210_priv *nec_priv;
@@ -912,7 +883,7 @@ static int fluke_generic_attach(gpib_board_t *board)
return 0;
}
-static int fluke_config_dma(gpib_board_t *board, int output)
+static int fluke_config_dma(struct gpib_board *board, int output)
{
struct fluke_priv *e_priv = board->private_data;
struct dma_slave_config config;
@@ -937,7 +908,7 @@ static int fluke_config_dma(gpib_board_t *board, int output)
return dmaengine_slave_config(e_priv->dma_channel, &config);
}
-static int fluke_init(struct fluke_priv *e_priv, gpib_board_t *board, int handshake_mode)
+static int fluke_init(struct fluke_priv *e_priv, struct gpib_board *board, int handshake_mode)
{
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -954,7 +925,7 @@ static int fluke_init(struct fluke_priv *e_priv, gpib_board_t *board, int handsh
/* poll so we can detect ATN changes */
if (gpib_request_pseudo_irq(board, fluke_gpib_interrupt)) {
- pr_err("fluke_gpib: failed to allocate pseudo_irq\n");
+ dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n");
return -EINVAL;
}
@@ -972,7 +943,7 @@ static bool gpib_dma_channel_filter(struct dma_chan *chan, void *filter_param)
return chan->chan_id == 0;
}
-static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *config,
+static int fluke_attach_impl(struct gpib_board *board, const gpib_board_config_t *config,
unsigned int handshake_mode)
{
struct fluke_priv *e_priv;
@@ -984,7 +955,7 @@ static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *con
dma_cap_mask_t dma_cap;
if (!fluke_gpib_pdev) {
- pr_err("No gpib platform device was found, attach failed.\n");
+ dev_err(board->gpib_dev, "No fluke device was found, attach failed.\n");
return -ENODEV;
}
@@ -999,7 +970,7 @@ static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *con
res = platform_get_resource(fluke_gpib_pdev, IORESOURCE_MEM, 0);
if (!res) {
- dev_err(&fluke_gpib_pdev->dev, "Unable to locate mmio resource for cb7210 gpib\n");
+ dev_err(&fluke_gpib_pdev->dev, "Unable to locate mmio resource\n");
return -ENODEV;
}
@@ -1012,10 +983,7 @@ static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *con
e_priv->gpib_iomem_res = res;
nec_priv->mmiobase = ioremap(e_priv->gpib_iomem_res->start,
- resource_size(e_priv->gpib_iomem_res));
- pr_info("gpib: mmiobase %llx remapped to %p, length=%d\n",
- (u64)e_priv->gpib_iomem_res->start,
- nec_priv->mmiobase, (int)resource_size(e_priv->gpib_iomem_res));
+ resource_size(e_priv->gpib_iomem_res));
if (!nec_priv->mmiobase) {
dev_err(&fluke_gpib_pdev->dev, "Could not map I/O memory\n");
return -ENOMEM;
@@ -1050,19 +1018,14 @@ static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *con
e_priv->write_transfer_counter = ioremap(e_priv->write_transfer_counter_res->start,
resource_size(e_priv->write_transfer_counter_res));
- pr_info("gpib: write transfer counter %lx remapped to %p, length=%d\n",
- (unsigned long)e_priv->write_transfer_counter_res->start,
- e_priv->write_transfer_counter,
- (int)resource_size(e_priv->write_transfer_counter_res));
if (!e_priv->write_transfer_counter) {
dev_err(&fluke_gpib_pdev->dev, "Could not map I/O memory\n");
return -ENOMEM;
}
irq = platform_get_irq(fluke_gpib_pdev, 0);
- pr_info("gpib: irq %d\n", irq);
if (irq < 0) {
- dev_err(&fluke_gpib_pdev->dev, "fluke_gpib: request for IRQ failed\n");
+ dev_err(&fluke_gpib_pdev->dev, "failed to obtain IRQ\n");
return -EBUSY;
}
retval = request_irq(irq, fluke_gpib_interrupt, isr_flags, fluke_gpib_pdev->name, board);
@@ -1078,7 +1041,7 @@ static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *con
dma_cap_set(DMA_SLAVE, dma_cap);
e_priv->dma_channel = dma_request_channel(dma_cap, gpib_dma_channel_filter, NULL);
if (!e_priv->dma_channel) {
- pr_err("fluke_gpib: failed to allocate a dma channel.\n");
+ dev_err(board->gpib_dev, "failed to allocate a dma channel.\n");
// we don't error out here because unaccel interface will still
// work without dma
}
@@ -1086,17 +1049,17 @@ static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *con
return fluke_init(e_priv, board, handshake_mode);
}
-int fluke_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config)
+int fluke_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config)
{
return fluke_attach_impl(board, config, HR_HLDA);
}
-int fluke_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config)
+int fluke_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config)
{
return fluke_attach_impl(board, config, HR_HLDE);
}
-void fluke_detach(gpib_board_t *board)
+void fluke_detach(struct gpib_board *board)
{
struct fluke_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1142,8 +1105,7 @@ MODULE_DEVICE_TABLE(of, fluke_gpib_of_match);
static struct platform_driver fluke_gpib_platform_driver = {
.driver = {
- .name = "fluke_gpib",
- .owner = THIS_MODULE,
+ .name = DRV_NAME,
.of_match_table = fluke_gpib_of_match,
},
.probe = &fluke_gpib_probe
@@ -1155,25 +1117,25 @@ static int __init fluke_init_module(void)
result = platform_driver_register(&fluke_gpib_platform_driver);
if (result) {
- pr_err("fluke_gpib: platform_driver_register failed: error = %d\n", result);
+ pr_err("platform_driver_register failed: error = %d\n", result);
return result;
}
result = gpib_register_driver(&fluke_unaccel_interface, THIS_MODULE);
if (result) {
- pr_err("fluke_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_unaccel;
}
result = gpib_register_driver(&fluke_hybrid_interface, THIS_MODULE);
if (result) {
- pr_err("fluke_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_hybrid;
}
result = gpib_register_driver(&fluke_interface, THIS_MODULE);
if (result) {
- pr_err("fluke_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_interface;
}
diff --git a/drivers/staging/gpib/fmh_gpib/fmh_gpib.c b/drivers/staging/gpib/fmh_gpib/fmh_gpib.c
index f950e7cdd8f8..53f4b3fccc3c 100644
--- a/drivers/staging/gpib/fmh_gpib/fmh_gpib.c
+++ b/drivers/staging/gpib/fmh_gpib/fmh_gpib.c
@@ -12,6 +12,10 @@
* (C) 2017 Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "fmh_gpib.h"
#include "gpibP.h"
@@ -28,19 +32,21 @@ MODULE_DESCRIPTION("GPIB Driver for fmh_gpib_core");
MODULE_AUTHOR("Frank Mori Hess <fmh6jj@gmail.com>");
static irqreturn_t fmh_gpib_interrupt(int irq, void *arg);
-static int fmh_gpib_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config);
-static int fmh_gpib_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config);
-static void fmh_gpib_detach(gpib_board_t *board);
-static int fmh_gpib_pci_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config);
-static int fmh_gpib_pci_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config);
-static void fmh_gpib_pci_detach(gpib_board_t *board);
-static int fmh_gpib_config_dma(gpib_board_t *board, int output);
-static irqreturn_t fmh_gpib_internal_interrupt(gpib_board_t *board);
+static int fmh_gpib_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config);
+static int fmh_gpib_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config);
+static void fmh_gpib_detach(struct gpib_board *board);
+static int fmh_gpib_pci_attach_holdoff_all(struct gpib_board *board,
+ const gpib_board_config_t *config);
+static int fmh_gpib_pci_attach_holdoff_end(struct gpib_board *board,
+ const gpib_board_config_t *config);
+static void fmh_gpib_pci_detach(struct gpib_board *board);
+static int fmh_gpib_config_dma(struct gpib_board *board, int output);
+static irqreturn_t fmh_gpib_internal_interrupt(struct gpib_board *board);
static struct platform_driver fmh_gpib_platform_driver;
static struct pci_driver fmh_gpib_pci_driver;
// wrappers for interface functions
-static int fmh_gpib_read(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fmh_gpib_read(struct gpib_board *board, uint8_t *buffer, size_t length,
int *end, size_t *bytes_read)
{
struct fmh_priv *priv = board->private_data;
@@ -48,7 +54,7 @@ static int fmh_gpib_read(gpib_board_t *board, uint8_t *buffer, size_t length,
return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read);
}
-static int fmh_gpib_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fmh_gpib_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
struct fmh_priv *priv = board->private_data;
@@ -56,7 +62,7 @@ static int fmh_gpib_write(gpib_board_t *board, uint8_t *buffer, size_t length,
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
}
-static int fmh_gpib_command(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fmh_gpib_command(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *bytes_written)
{
struct fmh_priv *priv = board->private_data;
@@ -64,21 +70,21 @@ static int fmh_gpib_command(gpib_board_t *board, uint8_t *buffer, size_t length,
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
}
-static int fmh_gpib_take_control(gpib_board_t *board, int synchronous)
+static int fmh_gpib_take_control(struct gpib_board *board, int synchronous)
{
struct fmh_priv *priv = board->private_data;
return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
}
-static int fmh_gpib_go_to_standby(gpib_board_t *board)
+static int fmh_gpib_go_to_standby(struct gpib_board *board)
{
struct fmh_priv *priv = board->private_data;
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-static void fmh_gpib_request_system_control(gpib_board_t *board, int request_control)
+static void fmh_gpib_request_system_control(struct gpib_board *board, int request_control)
{
struct fmh_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -86,77 +92,77 @@ static void fmh_gpib_request_system_control(gpib_board_t *board, int request_con
nec7210_request_system_control(board, nec_priv, request_control);
}
-static void fmh_gpib_interface_clear(gpib_board_t *board, int assert)
+static void fmh_gpib_interface_clear(struct gpib_board *board, int assert)
{
struct fmh_priv *priv = board->private_data;
nec7210_interface_clear(board, &priv->nec7210_priv, assert);
}
-static void fmh_gpib_remote_enable(gpib_board_t *board, int enable)
+static void fmh_gpib_remote_enable(struct gpib_board *board, int enable)
{
struct fmh_priv *priv = board->private_data;
nec7210_remote_enable(board, &priv->nec7210_priv, enable);
}
-static int fmh_gpib_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int fmh_gpib_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct fmh_priv *priv = board->private_data;
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
}
-static void fmh_gpib_disable_eos(gpib_board_t *board)
+static void fmh_gpib_disable_eos(struct gpib_board *board)
{
struct fmh_priv *priv = board->private_data;
nec7210_disable_eos(board, &priv->nec7210_priv);
}
-static unsigned int fmh_gpib_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int fmh_gpib_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct fmh_priv *priv = board->private_data;
return nec7210_update_status(board, &priv->nec7210_priv, clear_mask);
}
-static int fmh_gpib_primary_address(gpib_board_t *board, unsigned int address)
+static int fmh_gpib_primary_address(struct gpib_board *board, unsigned int address)
{
struct fmh_priv *priv = board->private_data;
return nec7210_primary_address(board, &priv->nec7210_priv, address);
}
-static int fmh_gpib_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int fmh_gpib_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct fmh_priv *priv = board->private_data;
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
}
-static int fmh_gpib_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int fmh_gpib_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct fmh_priv *priv = board->private_data;
return nec7210_parallel_poll(board, &priv->nec7210_priv, result);
}
-static void fmh_gpib_parallel_poll_configure(gpib_board_t *board, uint8_t configuration)
+static void fmh_gpib_parallel_poll_configure(struct gpib_board *board, uint8_t configuration)
{
struct fmh_priv *priv = board->private_data;
nec7210_parallel_poll_configure(board, &priv->nec7210_priv, configuration);
}
-static void fmh_gpib_parallel_poll_response(gpib_board_t *board, int ist)
+static void fmh_gpib_parallel_poll_response(struct gpib_board *board, int ist)
{
struct fmh_priv *priv = board->private_data;
nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist);
}
-static void fmh_gpib_local_parallel_poll_mode(gpib_board_t *board, int local)
+static void fmh_gpib_local_parallel_poll_mode(struct gpib_board *board, int local)
{
struct fmh_priv *priv = board->private_data;
@@ -171,7 +177,7 @@ static void fmh_gpib_local_parallel_poll_mode(gpib_board_t *board, int local)
}
}
-static void fmh_gpib_serial_poll_response2(gpib_board_t *board, uint8_t status,
+static void fmh_gpib_serial_poll_response2(struct gpib_board *board, uint8_t status,
int new_reason_for_service)
{
struct fmh_priv *priv = board->private_data;
@@ -206,14 +212,14 @@ static void fmh_gpib_serial_poll_response2(gpib_board_t *board, uint8_t status,
spin_unlock_irqrestore(&board->spinlock, flags);
}
-static uint8_t fmh_gpib_serial_poll_status(gpib_board_t *board)
+static uint8_t fmh_gpib_serial_poll_status(struct gpib_board *board)
{
struct fmh_priv *priv = board->private_data;
return nec7210_serial_poll_status(board, &priv->nec7210_priv);
}
-static void fmh_gpib_return_to_local(gpib_board_t *board)
+static void fmh_gpib_return_to_local(struct gpib_board *board)
{
struct fmh_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -223,9 +229,9 @@ static void fmh_gpib_return_to_local(gpib_board_t *board)
write_byte(nec_priv, AUX_RTL, AUXMR);
}
-static int fmh_gpib_line_status(const gpib_board_t *board)
+static int fmh_gpib_line_status(const struct gpib_board *board)
{
- int status = ValidALL;
+ int status = VALID_ALL;
int bsr_bits;
struct fmh_priv *e_priv;
struct nec7210_priv *nec_priv;
@@ -236,26 +242,26 @@ static int fmh_gpib_line_status(const gpib_board_t *board)
bsr_bits = read_byte(nec_priv, BUS_STATUS_REG);
if ((bsr_bits & BSR_REN_BIT) == 0)
- status |= BusREN;
+ status |= BUS_REN;
if ((bsr_bits & BSR_IFC_BIT) == 0)
- status |= BusIFC;
+ status |= BUS_IFC;
if ((bsr_bits & BSR_SRQ_BIT) == 0)
- status |= BusSRQ;
+ status |= BUS_SRQ;
if ((bsr_bits & BSR_EOI_BIT) == 0)
- status |= BusEOI;
+ status |= BUS_EOI;
if ((bsr_bits & BSR_NRFD_BIT) == 0)
- status |= BusNRFD;
+ status |= BUS_NRFD;
if ((bsr_bits & BSR_NDAC_BIT) == 0)
- status |= BusNDAC;
+ status |= BUS_NDAC;
if ((bsr_bits & BSR_DAV_BIT) == 0)
- status |= BusDAV;
+ status |= BUS_DAV;
if ((bsr_bits & BSR_ATN_BIT) == 0)
- status |= BusATN;
+ status |= BUS_ATN;
return status;
}
-static unsigned int fmh_gpib_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int fmh_gpib_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -272,7 +278,7 @@ static unsigned int fmh_gpib_t1_delay(gpib_board_t *board, unsigned int nano_sec
return retval;
}
-static int lacs_or_read_ready(gpib_board_t *board)
+static int lacs_or_read_ready(struct gpib_board *board)
{
const struct fmh_priv *e_priv = board->private_data;
const struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -287,7 +293,7 @@ static int lacs_or_read_ready(gpib_board_t *board)
return retval;
}
-static int wait_for_read(gpib_board_t *board)
+static int wait_for_read(struct gpib_board *board)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -306,7 +312,7 @@ static int wait_for_read(gpib_board_t *board)
return retval;
}
-static int wait_for_rx_fifo_half_full_or_end(gpib_board_t *board)
+static int wait_for_rx_fifo_half_full_or_end(struct gpib_board *board)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
@@ -329,12 +335,11 @@ static int wait_for_rx_fifo_half_full_or_end(gpib_board_t *board)
/* Wait until the gpib chip is ready to accept a data out byte.
*/
-static int wait_for_data_out_ready(gpib_board_t *board)
+static int wait_for_data_out_ready(struct gpib_board *board)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
int retval = 0;
-// printk("%s: enter\n", __FUNCTION__);
if (wait_event_interruptible(board->wait,
(test_bit(TACS_NUM, &board->status) &&
@@ -348,19 +353,18 @@ static int wait_for_data_out_ready(gpib_board_t *board)
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state))
retval = -EINTR;
-// printk("%s: exit, retval=%i\n", __FUNCTION__, retval);
+
return retval;
}
static void fmh_gpib_dma_callback(void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
unsigned long flags;
spin_lock_irqsave(&board->spinlock, flags);
-// printk("%s: enter\n", __FUNCTION__);
nec7210_set_reg_bits(nec_priv, IMR1, HR_DOIE | HR_DIIE, HR_DOIE | HR_DIIE);
wake_up_interruptible(&board->wait);
@@ -370,7 +374,6 @@ static void fmh_gpib_dma_callback(void *arg)
clear_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state);
clear_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state);
- // printk("%s: exit\n", __FUNCTION__);
spin_unlock_irqrestore(&board->spinlock, flags);
}
@@ -388,7 +391,7 @@ static int fmh_gpib_all_bytes_are_sent(struct fmh_priv *e_priv)
return 1;
}
-static int fmh_gpib_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fmh_gpib_dma_write(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *bytes_written)
{
struct fmh_priv *e_priv = board->private_data;
@@ -399,14 +402,13 @@ static int fmh_gpib_dma_write(gpib_board_t *board, uint8_t *buffer, size_t lengt
struct dma_async_tx_descriptor *tx_desc;
*bytes_written = 0;
-// printk("%s: enter\n", __FUNCTION__);
if (WARN_ON_ONCE(length > e_priv->dma_buffer_size))
return -EFAULT;
dmaengine_terminate_all(e_priv->dma_channel);
memcpy(e_priv->dma_buffer, buffer, length);
address = dma_map_single(board->dev, e_priv->dma_buffer, length, DMA_TO_DEVICE);
if (dma_mapping_error(board->dev, address))
- pr_err("dma mapping error in dma write!\n");
+ dev_err(board->gpib_dev, "dma mapping error in dma write!\n");
/* program dma controller */
retval = fmh_gpib_config_dma(board, 1);
if (retval)
@@ -415,7 +417,7 @@ static int fmh_gpib_dma_write(gpib_board_t *board, uint8_t *buffer, size_t lengt
tx_desc = dmaengine_prep_slave_single(e_priv->dma_channel, address, length, DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!tx_desc) {
- pr_err("fmh_gpib_gpib: failed to allocate dma transmit descriptor\n");
+ dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n");
retval = -ENOMEM;
goto cleanup;
}
@@ -432,19 +434,17 @@ static int fmh_gpib_dma_write(gpib_board_t *board, uint8_t *buffer, size_t lengt
dma_async_issue_pending(e_priv->dma_channel);
clear_bit(WRITE_READY_BN, &nec_priv->state);
set_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state);
-// printk("%s: in spin lock\n", __FUNCTION__);
+
spin_unlock_irqrestore(&board->spinlock, flags);
-// printk("%s: waiting for write.\n", __FUNCTION__);
// suspend until message is sent
if (wait_event_interruptible(board->wait,
fmh_gpib_all_bytes_are_sent(e_priv) ||
test_bit(BUS_ERROR_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted!\n");
+ test_bit(TIMO_NUM, &board->status)))
retval = -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state))
@@ -464,16 +464,12 @@ static int fmh_gpib_dma_write(gpib_board_t *board, uint8_t *buffer, size_t lengt
fifo_xfer_counter_mask);
if (WARN_ON_ONCE(*bytes_written > length))
return -EFAULT;
- /* printk("length=%i, *bytes_written=%i, residue=%i, retval=%i\n",
- * length, *bytes_written, get_dma_residue(e_priv->dma_channel), retval);
- */
cleanup:
dma_unmap_single(board->dev, address, length, DMA_TO_DEVICE);
-// printk("%s: exit, retval=%d\n", __FUNCTION__, retval);
return retval;
}
-static int fmh_gpib_accel_write(gpib_board_t *board, uint8_t *buffer,
+static int fmh_gpib_accel_write(struct gpib_board *board, uint8_t *buffer,
size_t length, int send_eoi, size_t *bytes_written)
{
struct fmh_priv *e_priv = board->private_data;
@@ -484,7 +480,7 @@ static int fmh_gpib_accel_write(gpib_board_t *board, uint8_t *buffer,
size_t dma_remainder = remainder;
if (!e_priv->dma_channel) {
- pr_err("fmh_gpib_gpib: No dma channel available, cannot do accel write.");
+ dev_err(board->gpib_dev, "No dma channel available, cannot do accel write.");
return -ENXIO;
}
@@ -498,7 +494,6 @@ static int fmh_gpib_accel_write(gpib_board_t *board, uint8_t *buffer,
if (send_eoi)
--dma_remainder;
-// printk("%s: entering while loop\n", __FUNCTION__);
while (dma_remainder > 0) {
size_t num_bytes;
@@ -524,7 +519,7 @@ static int fmh_gpib_accel_write(gpib_board_t *board, uint8_t *buffer,
//handle sending of last byte with eoi
if (send_eoi) {
size_t num_bytes;
- // printk("%s: handling last byte\n", __FUNCTION__);
+
if (WARN_ON_ONCE(remainder != 1))
return -EFAULT;
@@ -545,7 +540,6 @@ static int fmh_gpib_accel_write(gpib_board_t *board, uint8_t *buffer,
return retval;
remainder -= num_bytes;
}
-// printk("%s: bytes send=%i\n", __FUNCTION__, (int)(length - remainder));
return 0;
}
@@ -556,7 +550,7 @@ static int fmh_gpib_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
result = dmaengine_pause(chan);
if (result < 0) {
- pr_err("fmh_gpib_gpib: dma pause failed?\n");
+ pr_err("dma pause failed?\n");
return result;
}
dmaengine_tx_status(chan, cookie, &state);
@@ -565,12 +559,11 @@ static int fmh_gpib_get_dma_residue(struct dma_chan *chan, dma_cookie_t cookie)
return state.residue;
}
-static int wait_for_tx_fifo_half_empty(gpib_board_t *board)
+static int wait_for_tx_fifo_half_empty(struct gpib_board *board)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
int retval = 0;
-// printk("%s: enter\n", __FUNCTION__);
if (wait_event_interruptible(board->wait,
(test_bit(TACS_NUM, &board->status) &&
@@ -584,14 +577,14 @@ static int wait_for_tx_fifo_half_empty(gpib_board_t *board)
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state))
retval = -EINTR;
-// printk("%s: exit, retval=%i\n", __FUNCTION__, retval);
+
return retval;
}
/* supports writing a chunk of data whose length must fit into the hardware'd xfer counter,
* called in a loop by fmh_gpib_fifo_write()
*/
-static int fmh_gpib_fifo_write_countable(gpib_board_t *board, uint8_t *buffer,
+static int fmh_gpib_fifo_write_countable(struct gpib_board *board, uint8_t *buffer,
size_t length, int send_eoi, size_t *bytes_written)
{
struct fmh_priv *e_priv = board->private_data;
@@ -600,7 +593,6 @@ static int fmh_gpib_fifo_write_countable(gpib_board_t *board, uint8_t *buffer,
unsigned int remainder;
*bytes_written = 0;
-// printk("%s: enter\n", __FUNCTION__);
if (WARN_ON_ONCE(length > fifo_xfer_counter_mask))
return -EFAULT;
@@ -635,10 +627,9 @@ static int fmh_gpib_fifo_write_countable(gpib_board_t *board, uint8_t *buffer,
fmh_gpib_all_bytes_are_sent(e_priv) ||
test_bit(BUS_ERROR_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted!\n");
+ test_bit(TIMO_NUM, &board->status)))
retval = -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state))
@@ -655,15 +646,11 @@ cleanup:
fifo_xfer_counter_mask);
if (WARN_ON_ONCE(*bytes_written > length))
return -EFAULT;
- /* printk("length=%i, *bytes_written=%i, residue=%i, retval=%i\n",
- * length, *bytes_written, get_dma_residue(e_priv->dma_channel), retval);
- */
-// printk("%s: exit, retval=%d\n", __FUNCTION__, retval);
return retval;
}
-static int fmh_gpib_fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fmh_gpib_fifo_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
struct fmh_priv *e_priv = board->private_data;
@@ -678,8 +665,6 @@ static int fmh_gpib_fifo_write(gpib_board_t *board, uint8_t *buffer, size_t leng
clear_bit(DEV_CLEAR_BN, &nec_priv->state); // XXX FIXME
-// printk("%s: entering while loop\n", __FUNCTION__);
-
while (remainder > 0) {
size_t num_bytes;
int last_pass;
@@ -708,11 +693,11 @@ static int fmh_gpib_fifo_write(gpib_board_t *board, uint8_t *buffer, size_t leng
if (need_resched())
schedule();
}
-// printk("%s: bytes send=%i\n", __FUNCTION__, (int)(length - remainder));
+
return retval;
}
-static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer,
+static int fmh_gpib_dma_read(struct gpib_board *board, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
struct fmh_priv *e_priv = board->private_data;
@@ -725,10 +710,6 @@ static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer,
struct dma_async_tx_descriptor *tx_desc;
dma_cookie_t dma_cookie;
- // printk("%s: enter, bus_address=0x%x, length=%i\n", __FUNCTION__,
- //(unsigned)bus_address,
-// (int)length);
-
*bytes_read = 0;
*end = 0;
if (length == 0)
@@ -737,7 +718,7 @@ static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer,
bus_address = dma_map_single(board->dev, e_priv->dma_buffer,
length, DMA_FROM_DEVICE);
if (dma_mapping_error(board->dev, bus_address))
- pr_err("dma mapping error in dma read!");
+ dev_err(board->gpib_dev, "dma mapping error in dma read!");
/* program dma controller */
retval = fmh_gpib_config_dma(board, 0);
@@ -749,7 +730,7 @@ static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer,
length, DMA_DEV_TO_MEM,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!tx_desc) {
- pr_err("fmh_gpib_gpib: failed to allocate dma transmit descriptor\n");
+ dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n");
dma_unmap_single(board->dev, bus_address, length, DMA_FROM_DEVICE);
return -EIO;
}
@@ -769,7 +750,7 @@ static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer,
set_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state);
spin_unlock_irqrestore(&board->spinlock, flags);
-// printk("waiting for data transfer.\n");
+
// wait for data to transfer
wait_retval = wait_event_interruptible(board->wait,
test_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state)
@@ -777,10 +758,9 @@ static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer,
test_bit(RECEIVED_END_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status));
- if (wait_retval) {
- pr_warn("fmh_gpib: dma read wait interrupted\n");
+ if (wait_retval)
retval = -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
if (test_bit(DEV_CLEAR_BN, &nec_priv->state))
@@ -825,13 +805,11 @@ static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer,
*end = 1;
}
spin_unlock_irqrestore(&board->spinlock, flags);
-// printk("\tbytes_read=%i, residue=%i, end=%i, retval=%i, wait_retval=%i\n",
-// *bytes_read, residue, *end, retval, wait_retval);
return retval;
}
-static void fmh_gpib_release_rfd_holdoff(gpib_board_t *board, struct fmh_priv *e_priv)
+static void fmh_gpib_release_rfd_holdoff(struct gpib_board *board, struct fmh_priv *e_priv)
{
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
unsigned int ext_status_1;
@@ -868,7 +846,7 @@ static void fmh_gpib_release_rfd_holdoff(gpib_board_t *board, struct fmh_priv *e
spin_unlock_irqrestore(&board->spinlock, flags);
}
-static int fmh_gpib_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fmh_gpib_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length,
int *end, size_t *bytes_read)
{
struct fmh_priv *e_priv = board->private_data;
@@ -918,17 +896,13 @@ static int fmh_gpib_accel_read(gpib_board_t *board, uint8_t *buffer, size_t leng
/* Read a chunk of data whose length is within the limits of the hardware's
* xfer counter. Called in a loop from fmh_gpib_fifo_read().
*/
-static int fmh_gpib_fifo_read_countable(gpib_board_t *board, uint8_t *buffer,
+static int fmh_gpib_fifo_read_countable(struct gpib_board *board, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
int retval = 0;
- // printk("%s: enter, bus_address=0x%x, length=%i\n", __FUNCTION__,
- // (unsigned)bus_address,
-// (int)length);
-
*bytes_read = 0;
*end = 0;
if (length == 0)
@@ -977,13 +951,10 @@ cleanup:
*end = 1;
}
-// printk("\tbytes_read=%i, end=%i, retval=%i, wait_retval=%i\n",
-// *bytes_read, *end, retval, wait_retval);
-
return retval;
}
-static int fmh_gpib_fifo_read(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int fmh_gpib_fifo_read(struct gpib_board *board, uint8_t *buffer, size_t length,
int *end, size_t *bytes_read)
{
struct fmh_priv *e_priv = board->private_data;
@@ -1152,7 +1123,7 @@ static gpib_interface_t fmh_gpib_pci_unaccel_interface = {
.return_to_local = fmh_gpib_return_to_local,
};
-irqreturn_t fmh_gpib_internal_interrupt(gpib_board_t *board)
+irqreturn_t fmh_gpib_internal_interrupt(struct gpib_board *board)
{
unsigned int status0, status1, status2, ext_status_1, fifo_status;
struct fmh_priv *priv = board->private_data;
@@ -1242,7 +1213,7 @@ irqreturn_t fmh_gpib_internal_interrupt(gpib_board_t *board)
irqreturn_t fmh_gpib_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
unsigned long flags;
irqreturn_t retval;
@@ -1252,7 +1223,7 @@ irqreturn_t fmh_gpib_interrupt(int irq, void *arg)
return retval;
}
-static int fmh_gpib_allocate_private(gpib_board_t *board)
+static int fmh_gpib_allocate_private(struct gpib_board *board)
{
struct fmh_priv *priv;
@@ -1269,7 +1240,7 @@ static int fmh_gpib_allocate_private(gpib_board_t *board)
return 0;
}
-static void fmh_gpib_generic_detach(gpib_board_t *board)
+static void fmh_gpib_generic_detach(struct gpib_board *board)
{
if (board->private_data) {
struct fmh_priv *e_priv = board->private_data;
@@ -1283,7 +1254,7 @@ static void fmh_gpib_generic_detach(gpib_board_t *board)
}
// generic part of attach functions
-static int fmh_gpib_generic_attach(gpib_board_t *board)
+static int fmh_gpib_generic_attach(struct gpib_board *board)
{
struct fmh_priv *e_priv;
struct nec7210_priv *nec_priv;
@@ -1303,7 +1274,7 @@ static int fmh_gpib_generic_attach(gpib_board_t *board)
return 0;
}
-static int fmh_gpib_config_dma(gpib_board_t *board, int output)
+static int fmh_gpib_config_dma(struct gpib_board *board, int output)
{
struct fmh_priv *e_priv = board->private_data;
struct dma_slave_config config;
@@ -1333,7 +1304,7 @@ static int fmh_gpib_config_dma(gpib_board_t *board, int output)
return dmaengine_slave_config(e_priv->dma_channel, &config);
}
-static int fmh_gpib_init(struct fmh_priv *e_priv, gpib_board_t *board, int handshake_mode)
+static int fmh_gpib_init(struct fmh_priv *e_priv, struct gpib_board *board, int handshake_mode)
{
struct nec7210_priv *nec_priv = &e_priv->nec7210_priv;
unsigned long flags;
@@ -1376,11 +1347,11 @@ static int fmh_gpib_device_match(struct device *dev, const void *data)
if (config->serial_number)
return 0;
- dev_notice(dev, "matched: %s\n", of_node_full_name(dev_of_node((dev))));
+ dev_dbg(dev, "matched: %s\n", of_node_full_name(dev_of_node((dev))));
return 1;
}
-static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t *config,
+static int fmh_gpib_attach_impl(struct gpib_board *board, const gpib_board_config_t *config,
unsigned int handshake_mode, int acquire_dma)
{
struct fmh_priv *e_priv;
@@ -1393,7 +1364,7 @@ static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t *
board->dev = driver_find_device(&fmh_gpib_platform_driver.driver,
NULL, (const void *)config, &fmh_gpib_device_match);
if (!board->dev) {
- pr_err("No matching fmh_gpib_core device was found, attach failed.");
+ dev_err(board->gpib_dev, "No matching fmh_gpib_core device was found, attach failed.");
return -ENODEV;
}
// currently only used to mark the device as already attached
@@ -1409,7 +1380,7 @@ static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t *
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpib_control_status");
if (!res) {
- dev_err(board->dev, "Unable to locate mmio resource for cb7210 gpib\n");
+ dev_err(board->dev, "Unable to locate mmio resource\n");
return -ENODEV;
}
@@ -1422,13 +1393,13 @@ static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t *
e_priv->gpib_iomem_res = res;
nec_priv->mmiobase = ioremap(e_priv->gpib_iomem_res->start,
- resource_size(e_priv->gpib_iomem_res));
+ resource_size(e_priv->gpib_iomem_res));
if (!nec_priv->mmiobase) {
- dev_err(board->dev, "Could not map I/O memory for gpib\n");
+ dev_err(board->dev, "Could not map I/O memory\n");
return -ENOMEM;
}
- dev_info(board->dev, "iobase %pr remapped to %p\n",
- e_priv->gpib_iomem_res, nec_priv->mmiobase);
+ dev_dbg(board->dev, "iobase %pr remapped to %p\n",
+ e_priv->gpib_iomem_res, nec_priv->mmiobase);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma_fifos");
if (!res) {
@@ -1448,14 +1419,13 @@ static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t *
dev_err(board->dev, "Could not map I/O memory for fifos\n");
return -ENOMEM;
}
- dev_info(board->dev, "dma fifos 0x%lx remapped to %p, length=%ld\n",
- (unsigned long)e_priv->dma_port_res->start, e_priv->fifo_base,
- (unsigned long)resource_size(e_priv->dma_port_res));
+ dev_dbg(board->dev, "dma fifos 0x%lx remapped to %p, length=%ld\n",
+ (unsigned long)e_priv->dma_port_res->start, e_priv->fifo_base,
+ (unsigned long)resource_size(e_priv->dma_port_res));
irq = platform_get_irq(pdev, 0);
- pr_info("gpib: irq %d\n", irq);
if (irq < 0) {
- dev_err(board->dev, "fmh_gpib_gpib: request for IRQ failed\n");
+ dev_err(board->dev, "request for IRQ failed\n");
return -EBUSY;
}
retval = request_irq(irq, fmh_gpib_interrupt, IRQF_SHARED, pdev->name, board);
@@ -1484,17 +1454,17 @@ static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t *
return fmh_gpib_init(e_priv, board, handshake_mode);
}
-int fmh_gpib_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config)
+int fmh_gpib_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config)
{
return fmh_gpib_attach_impl(board, config, HR_HLDA, 0);
}
-int fmh_gpib_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config)
+int fmh_gpib_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config)
{
return fmh_gpib_attach_impl(board, config, HR_HLDE, 1);
}
-void fmh_gpib_detach(gpib_board_t *board)
+void fmh_gpib_detach(struct gpib_board *board)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1527,7 +1497,7 @@ void fmh_gpib_detach(gpib_board_t *board)
fmh_gpib_generic_detach(board);
}
-static int fmh_gpib_pci_attach_impl(gpib_board_t *board, const gpib_board_config_t *config,
+static int fmh_gpib_pci_attach_impl(struct gpib_board *board, const gpib_board_config_t *config,
unsigned int handshake_mode)
{
struct fmh_priv *e_priv;
@@ -1546,7 +1516,7 @@ static int fmh_gpib_pci_attach_impl(gpib_board_t *board, const gpib_board_config
pci_device = gpib_pci_get_device(config, BOGUS_PCI_VENDOR_ID_FLUKE,
BOGUS_PCI_DEVICE_ID_FLUKE_BLADERUNNER, NULL);
if (!pci_device) {
- pr_err("No matching fmh_gpib_core pci device was found, attach failed.");
+ dev_err(board->gpib_dev, "No matching fmh_gpib_core pci device was found, attach failed.");
return -ENODEV;
}
board->dev = &pci_device->dev;
@@ -1563,34 +1533,32 @@ static int fmh_gpib_pci_attach_impl(gpib_board_t *board, const gpib_board_config
return -EIO;
}
e_priv->gpib_iomem_res = &pci_device->resource[gpib_control_status_pci_resource_index];
- e_priv->dma_port_res = &pci_device->resource[gpib_fifo_pci_resource_index];
+ e_priv->dma_port_res = &pci_device->resource[gpib_fifo_pci_resource_index];
nec_priv->mmiobase = ioremap(pci_resource_start(pci_device,
- gpib_control_status_pci_resource_index),
- pci_resource_len(pci_device,
- gpib_control_status_pci_resource_index));
- dev_info(board->dev, "base address for gpib control/status registers remapped to 0x%p\n",
- nec_priv->mmiobase);
+ gpib_control_status_pci_resource_index),
+ pci_resource_len(pci_device,
+ gpib_control_status_pci_resource_index));
+ dev_dbg(board->dev, "base address for gpib control/status registers remapped to 0x%p\n",
+ nec_priv->mmiobase);
if (e_priv->dma_port_res->flags & IORESOURCE_MEM) {
e_priv->fifo_base = ioremap(pci_resource_start(pci_device,
gpib_fifo_pci_resource_index),
pci_resource_len(pci_device,
gpib_fifo_pci_resource_index));
- dev_info(board->dev, "base address for gpib fifo registers remapped to 0x%p\n",
- e_priv->fifo_base);
+ dev_dbg(board->dev, "base address for gpib fifo registers remapped to 0x%p\n",
+ e_priv->fifo_base);
} else {
e_priv->fifo_base = NULL;
- dev_info(board->dev, "hardware has no gpib fifo registers.\n");
+ dev_dbg(board->dev, "hardware has no gpib fifo registers.\n");
}
if (pci_device->irq) {
retval = request_irq(pci_device->irq, fmh_gpib_interrupt, IRQF_SHARED,
KBUILD_MODNAME, board);
if (retval) {
- dev_err(board->dev,
- "cannot register interrupt handler err=%d\n",
- retval);
+ dev_err(board->dev, "cannot register interrupt handler err=%d\n", retval);
return retval;
}
}
@@ -1602,12 +1570,12 @@ static int fmh_gpib_pci_attach_impl(gpib_board_t *board, const gpib_board_config
return fmh_gpib_init(e_priv, board, handshake_mode);
}
-int fmh_gpib_pci_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config)
+int fmh_gpib_pci_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config)
{
return fmh_gpib_pci_attach_impl(board, config, HR_HLDA);
}
-int fmh_gpib_pci_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config)
+int fmh_gpib_pci_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config)
{
int retval;
struct fmh_priv *e_priv;
@@ -1615,13 +1583,13 @@ int fmh_gpib_pci_attach_holdoff_end(gpib_board_t *board, const gpib_board_config
retval = fmh_gpib_pci_attach_impl(board, config, HR_HLDE);
e_priv = board->private_data;
if (retval == 0 && e_priv && e_priv->supports_fifo_interrupts == 0) {
- pr_err("fmh_gpib: your fmh_gpib_core does not appear to support fifo interrupts. Try the fmh_gpib_pci_unaccel board type instead.");
+ dev_err(board->gpib_dev, "your fmh_gpib_core does not appear to support fifo interrupts. Try the fmh_gpib_pci_unaccel board type instead.");
return -EIO;
}
return retval;
}
-void fmh_gpib_pci_detach(gpib_board_t *board)
+void fmh_gpib_pci_detach(struct gpib_board *board)
{
struct fmh_priv *e_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1662,7 +1630,7 @@ MODULE_DEVICE_TABLE(of, fmh_gpib_of_match);
static struct platform_driver fmh_gpib_platform_driver = {
.driver = {
- .name = "fmh_gpib",
+ .name = DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = fmh_gpib_of_match,
},
@@ -1681,7 +1649,7 @@ static const struct pci_device_id fmh_gpib_pci_match[] = {
MODULE_DEVICE_TABLE(pci, fmh_gpib_pci_match);
static struct pci_driver fmh_gpib_pci_driver = {
- .name = "fmh_gpib",
+ .name = DRV_NAME,
.id_table = fmh_gpib_pci_match,
.probe = &fmh_gpib_pci_probe
};
@@ -1692,37 +1660,37 @@ static int __init fmh_gpib_init_module(void)
result = platform_driver_register(&fmh_gpib_platform_driver);
if (result) {
- pr_err("fmh_gpib: platform_driver_register failed: error = %d\n", result);
+ pr_err("platform_driver_register failed: error = %d\n", result);
return result;
}
result = pci_register_driver(&fmh_gpib_pci_driver);
if (result) {
- pr_err("fmh_gpib: pci_register_driver failed: error = %d\n", result);
+ pr_err("pci_register_driver failed: error = %d\n", result);
goto err_pci_driver;
}
result = gpib_register_driver(&fmh_gpib_unaccel_interface, THIS_MODULE);
if (result) {
- pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_unaccel;
}
result = gpib_register_driver(&fmh_gpib_interface, THIS_MODULE);
if (result) {
- pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_interface;
}
result = gpib_register_driver(&fmh_gpib_pci_unaccel_interface, THIS_MODULE);
if (result) {
- pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_pci_unaccel;
}
result = gpib_register_driver(&fmh_gpib_pci_interface, THIS_MODULE);
if (result) {
- pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_pci;
}
diff --git a/drivers/staging/gpib/gpio/gpib_bitbang.c b/drivers/staging/gpib/gpio/gpib_bitbang.c
index 828c99ea613f..86bdd381472a 100644
--- a/drivers/staging/gpib/gpio/gpib_bitbang.c
+++ b/drivers/staging/gpib/gpio/gpib_bitbang.c
@@ -25,6 +25,8 @@
* device support (non master operation)
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
#define NAME KBUILD_MODNAME
#define ENABLE_IRQ(IRQ, TYPE) irq_set_irq_type(IRQ, TYPE)
@@ -41,7 +43,7 @@
*/
#define dbg_printk(level, frm, ...) \
do { if (debug >= (level)) \
- pr_info("%s:%s - " frm, NAME, __func__, ## __VA_ARGS__); } \
+ dev_dbg(board->gpib_dev, frm, ## __VA_ARGS__); } \
while (0)
#define LINVAL gpiod_get_value(DAV), \
@@ -316,13 +318,14 @@ struct bb_priv {
};
static inline long usec_diff(struct timespec64 *a, struct timespec64 *b);
-static void bb_buffer_print(unsigned char *buffer, size_t length, int cmd, int eoi);
+static void bb_buffer_print(struct gpib_board *board, unsigned char *buffer, size_t length,
+ int cmd, int eoi);
static void set_data_lines(u8 byte);
static u8 get_data_lines(void);
static void set_data_lines_input(void);
static void set_data_lines_output(void);
static inline int check_for_eos(struct bb_priv *priv, uint8_t byte);
-static void set_atn(struct bb_priv *priv, int atn_asserted);
+static void set_atn(struct gpib_board *board, int atn_asserted);
static inline void SET_DIR_WRITE(struct bb_priv *priv);
static inline void SET_DIR_READ(struct bb_priv *priv);
@@ -334,11 +337,7 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB helper functions for bitbanging I/O");
/**** global variables ****/
-#ifdef CONFIG_GPIB_DEBUG
-static int debug = 1;
-#else
static int debug;
-#endif
module_param(debug, int, 0644);
static char printable(char x)
@@ -354,7 +353,7 @@ static char printable(char x)
* *
***************************************************************************/
-static int bb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int bb_read(struct gpib_board *board, uint8_t *buffer, size_t length,
int *end, size_t *bytes_read)
{
struct bb_priv *priv = board->private_data;
@@ -426,7 +425,7 @@ read_end:
static irqreturn_t bb_DAV_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct bb_priv *priv = board->private_data;
int val;
unsigned long flags;
@@ -492,7 +491,7 @@ dav_exit:
* *
***************************************************************************/
-static int bb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int bb_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
unsigned long flags;
@@ -508,7 +507,7 @@ static int bb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
board, mutex_is_locked(&board->user_mutex), length);
if (debug > 1)
- bb_buffer_print(buffer, length, priv->cmd, send_eoi);
+ bb_buffer_print(board, buffer, length, priv->cmd, send_eoi);
priv->count = 0;
priv->phase = 300;
@@ -550,7 +549,6 @@ static int bb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
dbg_printk(1, "timeout after %zu/%zu at %d " LINFMT " eoi: %d\n",
priv->w_cnt, length, priv->phase, LINVAL, send_eoi);
} else {
- // dbg_printk(1,"written %zu\n", priv->w_cnt);
retval = priv->w_cnt;
}
} else {
@@ -582,7 +580,7 @@ write_end:
static irqreturn_t bb_NRFD_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct bb_priv *priv = board->private_data;
unsigned long flags;
int nrfd;
@@ -655,7 +653,7 @@ nrfd_exit:
static irqreturn_t bb_NDAC_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct bb_priv *priv = board->private_data;
unsigned long flags;
int ndac;
@@ -716,7 +714,7 @@ ndac_exit:
static irqreturn_t bb_SRQ_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
int val = gpiod_get_value(SRQ);
@@ -730,7 +728,7 @@ static irqreturn_t bb_SRQ_interrupt(int irq, void *arg)
return IRQ_HANDLED;
}
-static int bb_command(gpib_board_t *board, uint8_t *buffer,
+static int bb_command(struct gpib_board *board, uint8_t *buffer,
size_t length, size_t *bytes_written)
{
size_t ret;
@@ -811,7 +809,8 @@ static char *cmd_string[32] = {
"CFE" // 0x1f
};
-static void bb_buffer_print(unsigned char *buffer, size_t length, int cmd, int eoi)
+static void bb_buffer_print(struct gpib_board *board, unsigned char *buffer, size_t length,
+ int cmd, int eoi)
{
int i;
@@ -843,11 +842,13 @@ static void bb_buffer_print(unsigned char *buffer, size_t length, int cmd, int e
* STATUS Management *
* *
***************************************************************************/
-static void set_atn(struct bb_priv *priv, int atn_asserted)
+static void set_atn(struct gpib_board *board, int atn_asserted)
{
+ struct bb_priv *priv = board->private_data;
+
if (priv->listener_state != listener_idle &&
priv->talker_state != talker_idle) {
- dbg_printk(0, "listener/talker state machine conflict\n");
+ dev_err(board->gpib_dev, "listener/talker state machine conflict\n");
}
if (atn_asserted) {
if (priv->listener_state == listener_active)
@@ -866,22 +867,22 @@ static void set_atn(struct bb_priv *priv, int atn_asserted)
priv->atn_asserted = atn_asserted;
}
-static int bb_take_control(gpib_board_t *board, int synchronous)
+static int bb_take_control(struct gpib_board *board, int synchronous)
{
dbg_printk(2, "%d\n", synchronous);
- set_atn(board->private_data, 1);
+ set_atn(board, 1);
set_bit(CIC_NUM, &board->status);
return 0;
}
-static int bb_go_to_standby(gpib_board_t *board)
+static int bb_go_to_standby(struct gpib_board *board)
{
dbg_printk(2, "\n");
- set_atn(board->private_data, 0);
+ set_atn(board, 0);
return 0;
}
-static void bb_request_system_control(gpib_board_t *board, int request_control)
+static void bb_request_system_control(struct gpib_board *board, int request_control)
{
dbg_printk(2, "%d\n", request_control);
if (request_control) {
@@ -893,7 +894,7 @@ static void bb_request_system_control(gpib_board_t *board, int request_control)
}
}
-static void bb_interface_clear(gpib_board_t *board, int assert)
+static void bb_interface_clear(struct gpib_board *board, int assert)
{
struct bb_priv *priv = board->private_data;
@@ -907,7 +908,7 @@ static void bb_interface_clear(gpib_board_t *board, int assert)
}
}
-static void bb_remote_enable(gpib_board_t *board, int enable)
+static void bb_remote_enable(struct gpib_board *board, int enable)
{
dbg_printk(2, "%d\n", enable);
if (enable) {
@@ -919,7 +920,7 @@ static void bb_remote_enable(gpib_board_t *board, int enable)
}
}
-static int bb_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int bb_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct bb_priv *priv = board->private_data;
@@ -932,7 +933,7 @@ static int bb_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bi
return 0;
}
-static void bb_disable_eos(gpib_board_t *board)
+static void bb_disable_eos(struct gpib_board *board)
{
struct bb_priv *priv = board->private_data;
@@ -940,7 +941,7 @@ static void bb_disable_eos(gpib_board_t *board)
priv->eos_flags &= ~REOS;
}
-static unsigned int bb_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int bb_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct bb_priv *priv = board->private_data;
@@ -971,14 +972,14 @@ static unsigned int bb_update_status(gpib_board_t *board, unsigned int clear_mas
return board->status;
}
-static int bb_primary_address(gpib_board_t *board, unsigned int address)
+static int bb_primary_address(struct gpib_board *board, unsigned int address)
{
dbg_printk(2, "%d\n", address);
board->pad = address;
return 0;
}
-static int bb_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int bb_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
dbg_printk(2, "%d %d\n", address, enable);
if (enable)
@@ -986,33 +987,29 @@ static int bb_secondary_address(gpib_board_t *board, unsigned int address, int e
return 0;
}
-static int bb_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int bb_parallel_poll(struct gpib_board *board, uint8_t *result)
{
- dbg_printk(1, "%s\n", "not implemented");
- return -EPERM;
+ return -ENOENT;
}
-static void bb_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void bb_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
- dbg_printk(1, "%s\n", "not implemented");
}
-static void bb_parallel_poll_response(gpib_board_t *board, int ist)
+static void bb_parallel_poll_response(struct gpib_board *board, int ist)
{
}
-static void bb_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void bb_serial_poll_response(struct gpib_board *board, uint8_t status)
{
- dbg_printk(1, "%s\n", "not implemented");
}
-static uint8_t bb_serial_poll_status(gpib_board_t *board)
+static uint8_t bb_serial_poll_status(struct gpib_board *board)
{
- dbg_printk(1, "%s\n", "not implemented");
- return 0; // -ENOSYS;
+ return 0; // -ENOENT;
}
-static unsigned int bb_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int bb_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct bb_priv *priv = board->private_data;
@@ -1028,33 +1025,30 @@ static unsigned int bb_t1_delay(gpib_board_t *board, unsigned int nano_sec)
return priv->t1_delay;
}
-static void bb_return_to_local(gpib_board_t *board)
+static void bb_return_to_local(struct gpib_board *board)
{
- dbg_printk(1, "%s\n", "not implemented");
}
-static int bb_line_status(const gpib_board_t *board)
+static int bb_line_status(const struct gpib_board *board)
{
- int line_status = ValidALL;
-
-// dbg_printk(1,"\n");
+ int line_status = VALID_ALL;
if (gpiod_get_value(REN) == 0)
- line_status |= BusREN;
+ line_status |= BUS_REN;
if (gpiod_get_value(IFC) == 0)
- line_status |= BusIFC;
+ line_status |= BUS_IFC;
if (gpiod_get_value(NDAC) == 0)
- line_status |= BusNDAC;
+ line_status |= BUS_NDAC;
if (gpiod_get_value(NRFD) == 0)
- line_status |= BusNRFD;
+ line_status |= BUS_NRFD;
if (gpiod_get_value(DAV) == 0)
- line_status |= BusDAV;
+ line_status |= BUS_DAV;
if (gpiod_get_value(EOI) == 0)
- line_status |= BusEOI;
+ line_status |= BUS_EOI;
if (gpiod_get_value(_ATN) == 0)
- line_status |= BusATN;
+ line_status |= BUS_ATN;
if (gpiod_get_value(SRQ) == 0)
- line_status |= BusSRQ;
+ line_status |= BUS_SRQ;
dbg_printk(2, "status lines: %4x\n", line_status);
@@ -1067,7 +1061,7 @@ static int bb_line_status(const gpib_board_t *board)
* *
***************************************************************************/
-static int allocate_private(gpib_board_t *board)
+static int allocate_private(struct gpib_board *board)
{
board->private_data = kzalloc(sizeof(struct bb_priv), GFP_KERNEL);
if (!board->private_data)
@@ -1075,13 +1069,13 @@ static int allocate_private(gpib_board_t *board)
return 0;
}
-static void free_private(gpib_board_t *board)
+static void free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
}
-static int bb_get_irq(gpib_board_t *board, char *name,
+static int bb_get_irq(struct gpib_board *board, char *name,
struct gpio_desc *gpio, int *irq,
irq_handler_t handler, irq_handler_t thread_fn, unsigned long flags)
{
@@ -1091,11 +1085,11 @@ static int bb_get_irq(gpib_board_t *board, char *name,
*irq = gpiod_to_irq(gpio);
dbg_printk(2, "IRQ %s: %d\n", name, *irq);
if (*irq < 0) {
- dbg_printk(0, "gpib: can't get IRQ for %s\n", name);
+ dev_err(board->gpib_dev, "can't get IRQ for %s\n", name);
return -1;
}
if (request_threaded_irq(*irq, handler, thread_fn, flags, name, board)) {
- dbg_printk(0, "gpib: can't request IRQ for %s %d\n", name, *irq);
+ dev_err(board->gpib_dev, "can't request IRQ for %s %d\n", name, *irq);
*irq = 0;
return -1;
}
@@ -1103,7 +1097,7 @@ static int bb_get_irq(gpib_board_t *board, char *name,
return 0;
}
-static void bb_free_irq(gpib_board_t *board, int *irq, char *name)
+static void bb_free_irq(struct gpib_board *board, int *irq, char *name)
{
if (*irq) {
free_irq(*irq, board);
@@ -1124,7 +1118,7 @@ static void release_gpios(void)
}
}
-static int allocate_gpios(gpib_board_t *board)
+static int allocate_gpios(struct gpib_board *board)
{
int j, retval = 0;
bool error = false;
@@ -1163,8 +1157,8 @@ try_again:
gpiod_add_lookup_table(lookup_table);
goto try_again;
}
- dbg_printk(0, "Unable to obtain gpio descriptor for pin %d error %ld\n",
- gpios_vector[j], PTR_ERR(desc));
+ dev_err(board->gpib_dev, "Unable to obtain gpio descriptor for pin %d error %ld\n",
+ gpios_vector[j], PTR_ERR(desc));
error = true;
break;
}
@@ -1182,7 +1176,7 @@ try_again:
return retval;
}
-static void bb_detach(gpib_board_t *board)
+static void bb_detach(struct gpib_board *board)
{
struct bb_priv *priv = board->private_data;
@@ -1212,7 +1206,7 @@ static void bb_detach(gpib_board_t *board)
free_private(board);
}
-static int bb_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int bb_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct bb_priv *priv;
int retval = 0;
@@ -1253,7 +1247,7 @@ static int bb_attach(gpib_board_t *board, const gpib_board_config_t *config)
gpios_vector[&(DC) - &all_descriptors[0]] = -1;
gpios_vector[&(ACT_LED) - &all_descriptors[0]] = -1;
} else {
- dbg_printk(0, "Unrecognized pin mapping.\n");
+ dev_err(board->gpib_dev, "Unrecognized pin map %s\n", pin_map);
goto bb_attach_fail;
}
dbg_printk(0, "Using pin map \"%s\" %s\n", pin_map, (sn7516x) ?
@@ -1344,19 +1338,15 @@ static int __init bb_init_module(void)
int result = gpib_register_driver(&bb_interface, THIS_MODULE);
if (result) {
- pr_err("gpib_bitbang: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
return result;
}
- dbg_printk(0, "module loaded with pin map \"%s\"%s\n",
- pin_map, (sn7516x_used) ? " and SN7516x driver support" : "");
return 0;
}
static void __exit bb_exit_module(void)
{
- dbg_printk(0, "module unloaded!");
-
gpib_unregister_driver(&bb_interface);
}
diff --git a/drivers/staging/gpib/hp_82335/hp82335.c b/drivers/staging/gpib/hp_82335/hp82335.c
index 700d1ba029d2..fd23b1cb80f9 100644
--- a/drivers/staging/gpib/hp_82335/hp82335.c
+++ b/drivers/staging/gpib/hp_82335/hp82335.c
@@ -8,6 +8,10 @@
* implement recovery from bus errors (if necessary)
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "hp82335.h"
#include <linux/io.h>
#include <linux/ioport.h>
@@ -20,153 +24,155 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB driver for HP 82335 interface cards");
-static int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config);
-
-static void hp82335_detach(gpib_board_t *board);
+static int hp82335_attach(struct gpib_board *board, const gpib_board_config_t *config);
+static void hp82335_detach(struct gpib_board *board);
+static irqreturn_t hp82335_interrupt(int irq, void *arg);
// wrappers for interface functions
-int hp82335_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read)
+static int hp82335_read(struct gpib_board *board, uint8_t *buffer, size_t length,
+ int *end, size_t *bytes_read)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_read(board, &priv->tms9914_priv, buffer, length, end, bytes_read);
}
-int hp82335_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
+static int hp82335_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
+ size_t *bytes_written)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_write(board, &priv->tms9914_priv, buffer, length, send_eoi, bytes_written);
}
-int hp82335_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int hp82335_command(struct gpib_board *board, uint8_t *buffer, size_t length,
+ size_t *bytes_written)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_command(board, &priv->tms9914_priv, buffer, length, bytes_written);
}
-int hp82335_take_control(gpib_board_t *board, int synchronous)
+static int hp82335_take_control(struct gpib_board *board, int synchronous)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_take_control(board, &priv->tms9914_priv, synchronous);
}
-int hp82335_go_to_standby(gpib_board_t *board)
+static int hp82335_go_to_standby(struct gpib_board *board)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_go_to_standby(board, &priv->tms9914_priv);
}
-void hp82335_request_system_control(gpib_board_t *board, int request_control)
+static void hp82335_request_system_control(struct gpib_board *board, int request_control)
{
struct hp82335_priv *priv = board->private_data;
tms9914_request_system_control(board, &priv->tms9914_priv, request_control);
}
-void hp82335_interface_clear(gpib_board_t *board, int assert)
+static void hp82335_interface_clear(struct gpib_board *board, int assert)
{
struct hp82335_priv *priv = board->private_data;
tms9914_interface_clear(board, &priv->tms9914_priv, assert);
}
-void hp82335_remote_enable(gpib_board_t *board, int enable)
+static void hp82335_remote_enable(struct gpib_board *board, int enable)
{
struct hp82335_priv *priv = board->private_data;
tms9914_remote_enable(board, &priv->tms9914_priv, enable);
}
-int hp82335_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int hp82335_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_enable_eos(board, &priv->tms9914_priv, eos_byte, compare_8_bits);
}
-void hp82335_disable_eos(gpib_board_t *board)
+static void hp82335_disable_eos(struct gpib_board *board)
{
struct hp82335_priv *priv = board->private_data;
tms9914_disable_eos(board, &priv->tms9914_priv);
}
-unsigned int hp82335_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int hp82335_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_update_status(board, &priv->tms9914_priv, clear_mask);
}
-int hp82335_primary_address(gpib_board_t *board, unsigned int address)
+static int hp82335_primary_address(struct gpib_board *board, unsigned int address)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_primary_address(board, &priv->tms9914_priv, address);
}
-int hp82335_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int hp82335_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_secondary_address(board, &priv->tms9914_priv, address, enable);
}
-int hp82335_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int hp82335_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_parallel_poll(board, &priv->tms9914_priv, result);
}
-void hp82335_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void hp82335_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
struct hp82335_priv *priv = board->private_data;
tms9914_parallel_poll_configure(board, &priv->tms9914_priv, config);
}
-void hp82335_parallel_poll_response(gpib_board_t *board, int ist)
+static void hp82335_parallel_poll_response(struct gpib_board *board, int ist)
{
struct hp82335_priv *priv = board->private_data;
tms9914_parallel_poll_response(board, &priv->tms9914_priv, ist);
}
-void hp82335_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void hp82335_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct hp82335_priv *priv = board->private_data;
tms9914_serial_poll_response(board, &priv->tms9914_priv, status);
}
-static uint8_t hp82335_serial_poll_status(gpib_board_t *board)
+static uint8_t hp82335_serial_poll_status(struct gpib_board *board)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_serial_poll_status(board, &priv->tms9914_priv);
}
-static int hp82335_line_status(const gpib_board_t *board)
+static int hp82335_line_status(const struct gpib_board *board)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_line_status(board, &priv->tms9914_priv);
}
-static unsigned int hp82335_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int hp82335_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct hp82335_priv *priv = board->private_data;
return tms9914_t1_delay(board, &priv->tms9914_priv, nano_sec);
}
-void hp82335_return_to_local(gpib_board_t *board)
+static void hp82335_return_to_local(struct gpib_board *board)
{
struct hp82335_priv *priv = board->private_data;
@@ -201,7 +207,7 @@ static gpib_interface_t hp82335_interface = {
.return_to_local = hp82335_return_to_local,
};
-int hp82335_allocate_private(gpib_board_t *board)
+static int hp82335_allocate_private(struct gpib_board *board)
{
board->private_data = kzalloc(sizeof(struct hp82335_priv), GFP_KERNEL);
if (!board->private_data)
@@ -209,7 +215,7 @@ int hp82335_allocate_private(gpib_board_t *board)
return 0;
}
-void hp82335_free_private(gpib_board_t *board)
+static void hp82335_free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
@@ -237,7 +243,7 @@ static void hp82335_clear_interrupt(struct hp82335_priv *hp_priv)
writeb(0, tms_priv->mmiobase + HPREG_INTR_CLEAR);
}
-int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int hp82335_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct hp82335_priv *hp_priv;
struct tms9914_priv *tms_priv;
@@ -272,26 +278,23 @@ int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config)
case 0xfc000:
break;
default:
- pr_err("hp82335: invalid base io address 0x%u\n", config->ibbase);
+ dev_err(board->gpib_dev, "invalid base io address 0x%x\n", config->ibbase);
return -EINVAL;
}
if (!request_mem_region(upper_iomem_base, hp82335_upper_iomem_size, "hp82335")) {
- pr_err("hp82335: failed to allocate io memory region 0x%lx-0x%lx\n",
- upper_iomem_base, upper_iomem_base + hp82335_upper_iomem_size - 1);
+ dev_err(board->gpib_dev, "failed to allocate io memory region 0x%lx-0x%lx\n",
+ upper_iomem_base, upper_iomem_base + hp82335_upper_iomem_size - 1);
return -EBUSY;
}
hp_priv->raw_iobase = upper_iomem_base;
tms_priv->mmiobase = ioremap(upper_iomem_base, hp82335_upper_iomem_size);
- pr_info("hp82335: upper half of 82335 iomem region 0x%lx remapped to 0x%p\n",
- hp_priv->raw_iobase, tms_priv->mmiobase);
- retval = request_irq(config->ibirq, hp82335_interrupt, 0, "hp82335", board);
+ retval = request_irq(config->ibirq, hp82335_interrupt, 0, DRV_NAME, board);
if (retval) {
- pr_err("hp82335: can't request IRQ %d\n", config->ibirq);
+ dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq);
return retval;
}
hp_priv->irq = config->ibirq;
- pr_info("hp82335: IRQ %d\n", config->ibirq);
tms9914_board_reset(tms_priv);
@@ -304,7 +307,7 @@ int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-void hp82335_detach(gpib_board_t *board)
+static void hp82335_detach(struct gpib_board *board)
{
struct hp82335_priv *hp_priv = board->private_data;
struct tms9914_priv *tms_priv;
@@ -329,7 +332,7 @@ static int __init hp82335_init_module(void)
int result = gpib_register_driver(&hp82335_interface, THIS_MODULE);
if (result) {
- pr_err("hp82335: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
return result;
}
@@ -348,10 +351,10 @@ module_exit(hp82335_exit_module);
* GPIB interrupt service routines
*/
-irqreturn_t hp82335_interrupt(int irq, void *arg)
+static irqreturn_t hp82335_interrupt(int irq, void *arg)
{
int status1, status2;
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct hp82335_priv *priv = board->private_data;
unsigned long flags;
irqreturn_t retval;
diff --git a/drivers/staging/gpib/hp_82335/hp82335.h b/drivers/staging/gpib/hp_82335/hp82335.h
index 4b185d7c5188..0c252a712ec9 100644
--- a/drivers/staging/gpib/hp_82335/hp82335.h
+++ b/drivers/staging/gpib/hp_82335/hp82335.h
@@ -17,36 +17,6 @@ struct hp82335_priv {
unsigned long raw_iobase;
};
-// interface functions
-int hp82335_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read);
-int hp82335_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written);
-int hp82335_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written);
-int hp82335_take_control(gpib_board_t *board, int synchronous);
-int hp82335_go_to_standby(gpib_board_t *board);
-void hp82335_request_system_control(gpib_board_t *board, int request_control);
-void hp82335_interface_clear(gpib_board_t *board, int assert);
-void hp82335_remote_enable(gpib_board_t *board, int enable);
-int hp82335_enable_eos(gpib_board_t *board, uint8_t eos_byte, int
- compare_8_bits);
-void hp82335_disable_eos(gpib_board_t *board);
-unsigned int hp82335_update_status(gpib_board_t *board, unsigned int clear_mask);
-int hp82335_primary_address(gpib_board_t *board, unsigned int address);
-int hp82335_secondary_address(gpib_board_t *board, unsigned int address, int
- enable);
-int hp82335_parallel_poll(gpib_board_t *board, uint8_t *result);
-void hp82335_parallel_poll_configure(gpib_board_t *board, uint8_t config);
-void hp82335_parallel_poll_response(gpib_board_t *board, int ist);
-void hp82335_serial_poll_response(gpib_board_t *board, uint8_t status);
-void hp82335_return_to_local(gpib_board_t *board);
-
-// interrupt service routines
-irqreturn_t hp82335_interrupt(int irq, void *arg);
-
-// utility functions
-int hp82335_allocate_private(gpib_board_t *board);
-void hp82335_free_private(gpib_board_t *board);
-
// size of io memory region used
static const int hp82335_rom_size = 0x2000;
static const int hp82335_upper_iomem_size = 0x2000;
diff --git a/drivers/staging/gpib/hp_82341/hp_82341.c b/drivers/staging/gpib/hp_82341/hp_82341.c
index 0ddae295912f..f52e673dc869 100644
--- a/drivers/staging/gpib/hp_82341/hp_82341.c
+++ b/drivers/staging/gpib/hp_82341/hp_82341.c
@@ -6,6 +6,10 @@
* copyright : (C) 2002, 2005 by Frank Mori Hess *
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "hp_82341.h"
#include <linux/delay.h>
#include <linux/ioport.h>
@@ -16,9 +20,17 @@
#include <linux/isapnp.h>
MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("GPIB driver for hp 82341a/b/c/d boards");
+
+static unsigned short read_and_clear_event_status(struct gpib_board *board);
+static void set_transfer_counter(struct hp_82341_priv *hp_priv, int count);
+static int read_transfer_counter(struct hp_82341_priv *hp_priv);
+static int hp_82341_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
+ size_t *bytes_written);
+static irqreturn_t hp_82341_interrupt(int irq, void *arg);
-int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read)
+static int hp_82341_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
+ size_t *bytes_read)
{
struct hp_82341_priv *hp_priv = board->private_data;
struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv;
@@ -50,7 +62,7 @@ int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int
retval = tms9914_read(board, tms_priv, buffer, 1, end, &num_bytes);
*bytes_read += num_bytes;
if (retval < 0)
- pr_err("tms9914_read failed retval=%i\n", retval);
+ dev_err(board->gpib_dev, "tms9914_read failed retval=%i\n", retval);
if (retval < 0 || *end)
return retval;
++buffer;
@@ -86,7 +98,6 @@ int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int
test_bit(DEV_CLEAR_BN, &tms_priv->state) ||
test_bit(TIMO_NUM, &board->status));
if (retval) {
- pr_warn("%s: read wait interrupted\n", __func__);
retval = -ERESTARTSYS;
break;
}
@@ -111,12 +122,10 @@ int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int
tms_priv->holdoff_active = 1;
}
if (test_bit(TIMO_NUM, &board->status)) {
- pr_debug("%s: minor %i: read timed out\n", __FILE__, board->minor);
retval = -ETIMEDOUT;
break;
}
if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) {
- pr_warn("%s: device clear interrupted read\n", __FILE__);
retval = -EINTR;
break;
}
@@ -138,7 +147,7 @@ int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int
return 0;
}
-static int restart_write_fifo(gpib_board_t *board, struct hp_82341_priv *hp_priv)
+static int restart_write_fifo(struct gpib_board *board, struct hp_82341_priv *hp_priv)
{
struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv;
@@ -149,7 +158,7 @@ static int restart_write_fifo(gpib_board_t *board, struct hp_82341_priv *hp_priv
//restart doesn't work if data holdoff is in effect
status = tms9914_line_status(board, tms_priv);
- if ((status & BusNRFD) == 0) {
+ if ((status & BUS_NRFD) == 0) {
outb(RESTART_STREAM_BIT, hp_priv->iobase[0] + STREAM_STATUS_REG);
return 0;
}
@@ -163,8 +172,8 @@ static int restart_write_fifo(gpib_board_t *board, struct hp_82341_priv *hp_priv
return 0;
}
-int hp_82341_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written)
+static int hp_82341_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length,
+ int send_eoi, size_t *bytes_written)
{
struct hp_82341_priv *hp_priv = board->private_data;
struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv;
@@ -204,7 +213,7 @@ int hp_82341_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
outb(ENABLE_TI_BUFFER_BIT, hp_priv->iobase[3] + BUFFER_CONTROL_REG);
retval = restart_write_fifo(board, hp_priv);
if (retval < 0) {
- pr_err("hp82341: failed to restart write stream\n");
+ dev_err(board->gpib_dev, "failed to restart write stream\n");
break;
}
retval = wait_event_interruptible(board->wait,
@@ -216,17 +225,14 @@ int hp_82341_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
outb(0, hp_priv->iobase[3] + BUFFER_CONTROL_REG);
*bytes_written += block_size - read_transfer_counter(hp_priv);
if (retval) {
- pr_warn("%s: write wait interrupted\n", __FILE__);
retval = -ERESTARTSYS;
break;
}
if (test_bit(TIMO_NUM, &board->status)) {
- pr_debug("%s: minor %i: write timed out\n", __FILE__, board->minor);
retval = -ETIMEDOUT;
break;
}
if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) {
- pr_warn("%s: device clear interrupted write\n", __FILE__);
retval = -EINTR;
break;
}
@@ -244,48 +250,50 @@ int hp_82341_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
return 0;
}
-static int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config);
+static int hp_82341_attach(struct gpib_board *board, const gpib_board_config_t *config);
-static void hp_82341_detach(gpib_board_t *board);
+static void hp_82341_detach(struct gpib_board *board);
// wrappers for interface functions
-int hp_82341_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read)
+static int hp_82341_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
+ size_t *bytes_read)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_read(board, &priv->tms9914_priv, buffer, length, end, bytes_read);
}
-int hp_82341_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
+static int hp_82341_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
+ size_t *bytes_written)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_write(board, &priv->tms9914_priv, buffer, length, send_eoi, bytes_written);
}
-int hp_82341_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int hp_82341_command(struct gpib_board *board, uint8_t *buffer, size_t length,
+ size_t *bytes_written)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_command(board, &priv->tms9914_priv, buffer, length, bytes_written);
}
-int hp_82341_take_control(gpib_board_t *board, int synchronous)
+static int hp_82341_take_control(struct gpib_board *board, int synchronous)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_take_control(board, &priv->tms9914_priv, synchronous);
}
-int hp_82341_go_to_standby(gpib_board_t *board)
+static int hp_82341_go_to_standby(struct gpib_board *board)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_go_to_standby(board, &priv->tms9914_priv);
}
-void hp_82341_request_system_control(gpib_board_t *board, int request_control)
+static void hp_82341_request_system_control(struct gpib_board *board, int request_control)
{
struct hp_82341_priv *priv = board->private_data;
@@ -297,105 +305,105 @@ void hp_82341_request_system_control(gpib_board_t *board, int request_control)
tms9914_request_system_control(board, &priv->tms9914_priv, request_control);
}
-void hp_82341_interface_clear(gpib_board_t *board, int assert)
+static void hp_82341_interface_clear(struct gpib_board *board, int assert)
{
struct hp_82341_priv *priv = board->private_data;
tms9914_interface_clear(board, &priv->tms9914_priv, assert);
}
-void hp_82341_remote_enable(gpib_board_t *board, int enable)
+static void hp_82341_remote_enable(struct gpib_board *board, int enable)
{
struct hp_82341_priv *priv = board->private_data;
tms9914_remote_enable(board, &priv->tms9914_priv, enable);
}
-int hp_82341_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int hp_82341_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_enable_eos(board, &priv->tms9914_priv, eos_byte, compare_8_bits);
}
-void hp_82341_disable_eos(gpib_board_t *board)
+static void hp_82341_disable_eos(struct gpib_board *board)
{
struct hp_82341_priv *priv = board->private_data;
tms9914_disable_eos(board, &priv->tms9914_priv);
}
-unsigned int hp_82341_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int hp_82341_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_update_status(board, &priv->tms9914_priv, clear_mask);
}
-int hp_82341_primary_address(gpib_board_t *board, unsigned int address)
+static int hp_82341_primary_address(struct gpib_board *board, unsigned int address)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_primary_address(board, &priv->tms9914_priv, address);
}
-int hp_82341_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int hp_82341_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_secondary_address(board, &priv->tms9914_priv, address, enable);
}
-int hp_82341_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int hp_82341_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_parallel_poll(board, &priv->tms9914_priv, result);
}
-void hp_82341_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void hp_82341_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
struct hp_82341_priv *priv = board->private_data;
tms9914_parallel_poll_configure(board, &priv->tms9914_priv, config);
}
-void hp_82341_parallel_poll_response(gpib_board_t *board, int ist)
+static void hp_82341_parallel_poll_response(struct gpib_board *board, int ist)
{
struct hp_82341_priv *priv = board->private_data;
tms9914_parallel_poll_response(board, &priv->tms9914_priv, ist);
}
-void hp_82341_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void hp_82341_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct hp_82341_priv *priv = board->private_data;
tms9914_serial_poll_response(board, &priv->tms9914_priv, status);
}
-static uint8_t hp_82341_serial_poll_status(gpib_board_t *board)
+static uint8_t hp_82341_serial_poll_status(struct gpib_board *board)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_serial_poll_status(board, &priv->tms9914_priv);
}
-static int hp_82341_line_status(const gpib_board_t *board)
+static int hp_82341_line_status(const struct gpib_board *board)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_line_status(board, &priv->tms9914_priv);
}
-static unsigned int hp_82341_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int hp_82341_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct hp_82341_priv *priv = board->private_data;
return tms9914_t1_delay(board, &priv->tms9914_priv, nano_sec);
}
-void hp_82341_return_to_local(gpib_board_t *board)
+static void hp_82341_return_to_local(struct gpib_board *board)
{
struct hp_82341_priv *priv = board->private_data;
@@ -457,7 +465,7 @@ static gpib_interface_t hp_82341_interface = {
.return_to_local = hp_82341_return_to_local,
};
-int hp_82341_allocate_private(gpib_board_t *board)
+static int hp_82341_allocate_private(struct gpib_board *board)
{
board->private_data = kzalloc(sizeof(struct hp_82341_priv), GFP_KERNEL);
if (!board->private_data)
@@ -465,7 +473,7 @@ int hp_82341_allocate_private(gpib_board_t *board)
return 0;
}
-void hp_82341_free_private(gpib_board_t *board)
+static void hp_82341_free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
@@ -486,21 +494,21 @@ static int hp_82341_find_isapnp_board(struct pnp_dev **dev)
*dev = pnp_find_dev(NULL, ISAPNP_VENDOR('H', 'W', 'P'),
ISAPNP_FUNCTION(0x1411), NULL);
if (!*dev || !(*dev)->card) {
- pr_err("hp_82341: failed to find isapnp board\n");
+ pr_err("failed to find isapnp board\n");
return -ENODEV;
}
if (pnp_device_attach(*dev) < 0) {
- pr_err("hp_82341: board already active, skipping\n");
+ pr_err("board already active, skipping\n");
return -EBUSY;
}
if (pnp_activate_dev(*dev) < 0) {
pnp_device_detach(*dev);
- pr_err("hp_82341: failed to activate() atgpib/tnt, aborting\n");
+ pr_err("failed to activate(), aborting\n");
return -EAGAIN;
}
if (!pnp_port_valid(*dev, 0) || !pnp_irq_valid(*dev, 0)) {
pnp_device_detach(*dev);
- pr_err("hp_82341: invalid port or irq for atgpib/tnt, aborting\n");
+ pr_err("invalid port or irq, aborting\n");
return -ENOMEM;
}
return 0;
@@ -521,7 +529,7 @@ static int xilinx_ready(struct hp_82341_priv *hp_priv)
else
return 0;
default:
- pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__);
+ pr_err("bug! unknown hw_version\n");
break;
}
return 0;
@@ -541,7 +549,7 @@ static int xilinx_done(struct hp_82341_priv *hp_priv)
else
return 0;
default:
- pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__);
+ pr_err("bug! unknown hw_version\n");
break;
}
return 0;
@@ -562,7 +570,7 @@ static int irq_valid(struct hp_82341_priv *hp_priv, int irq)
case 15:
return 1;
default:
- pr_err("hp_82341: invalid irq=%i for 82341C, irq must be 3, 5, 7, 9, 10, 11, 12, or 15.\n",
+ pr_err("invalid irq=%i for 82341C, irq must be 3, 5, 7, 9, 10, 11, 12, or 15.\n",
irq);
return 0;
}
@@ -570,7 +578,7 @@ static int irq_valid(struct hp_82341_priv *hp_priv, int irq)
case HW_VERSION_82341D:
return 1;
default:
- pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__);
+ pr_err("bug! unknown hw_version\n");
break;
}
return 0;
@@ -592,7 +600,7 @@ static int hp_82341_load_firmware_array(struct hp_82341_priv *hp_priv,
usleep_range(10, 15);
}
if (j == timeout) {
- pr_err("hp_82341: timed out waiting for Xilinx ready.\n");
+ pr_err("timed out waiting for Xilinx ready.\n");
return -ETIMEDOUT;
}
outb(firmware_data[i], hp_priv->iobase[0] + XILINX_DATA_REG);
@@ -605,7 +613,7 @@ static int hp_82341_load_firmware_array(struct hp_82341_priv *hp_priv,
usleep_range(10, 15);
}
if (j == timeout) {
- pr_err("hp_82341: timed out waiting for Xilinx done.\n");
+ pr_err("timed out waiting for Xilinx done.\n");
return -ETIMEDOUT;
}
return 0;
@@ -616,27 +624,27 @@ static int hp_82341_load_firmware(struct hp_82341_priv *hp_priv, const gpib_boar
if (config->init_data_length == 0) {
if (xilinx_done(hp_priv))
return 0;
- pr_err("hp_82341: board needs be initialized with firmware upload.\n"
+ pr_err("board needs be initialized with firmware upload.\n"
"\tUse the --init-data option of gpib_config.\n");
return -EINVAL;
}
switch (hp_priv->hw_version) {
case HW_VERSION_82341C:
if (config->init_data_length != hp_82341c_firmware_length) {
- pr_err("hp_82341: bad firmware length=%i for 82341c (expected %i).\n",
+ pr_err("bad firmware length=%i for 82341c (expected %i).\n",
config->init_data_length, hp_82341c_firmware_length);
return -EINVAL;
}
break;
case HW_VERSION_82341D:
if (config->init_data_length != hp_82341d_firmware_length) {
- pr_err("hp_82341: bad firmware length=%i for 82341d (expected %i).\n",
+ pr_err("bad firmware length=%i for 82341d (expected %i).\n",
config->init_data_length, hp_82341d_firmware_length);
return -EINVAL;
}
break;
default:
- pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__);
+ pr_err("bug! unknown hw_version\n");
break;
}
return hp_82341_load_firmware_array(hp_priv, config->init_data, config->init_data_length);
@@ -678,7 +686,7 @@ static int clear_xilinx(struct hp_82341_priv *hp_priv)
return 0;
}
-int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int hp_82341_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct hp_82341_priv *hp_priv;
struct tms9914_priv *tms_priv;
@@ -714,13 +722,12 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config)
hp_priv->hw_version = HW_VERSION_82341C;
hp_priv->io_region_offset = 0x400;
}
- pr_info("hp_82341: base io 0x%u\n", iobase);
for (i = 0; i < hp_82341_num_io_regions; ++i) {
start_addr = iobase + i * hp_priv->io_region_offset;
- if (!request_region(start_addr, hp_82341_region_iosize, "hp_82341")) {
- pr_err("hp_82341: failed to allocate io ports 0x%lx-0x%lx\n",
- start_addr,
- start_addr + hp_82341_region_iosize - 1);
+ if (!request_region(start_addr, hp_82341_region_iosize, DRV_NAME)) {
+ dev_err(board->gpib_dev, "failed to allocate io ports 0x%x-0x%x\n",
+ start_addr,
+ start_addr + hp_82341_region_iosize - 1);
return -EIO;
}
hp_priv->iobase[i] = start_addr;
@@ -730,7 +737,7 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config)
retval = isapnp_cfg_begin(hp_priv->pnp_dev->card->number,
hp_priv->pnp_dev->number);
if (retval < 0) {
- pr_err("hp_82341: isapnp_cfg_begin returned error\n");
+ dev_err(board->gpib_dev, "isapnp_cfg_begin returned error\n");
return retval;
}
isapnp_write_byte(PIO_DIRECTION_REG, HP_82341D_XILINX_READY_BIT |
@@ -746,12 +753,11 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config)
return retval;
if (irq_valid(hp_priv, irq) == 0)
return -EINVAL;
- if (request_irq(irq, hp_82341_interrupt, 0, "hp_82341", board)) {
- pr_err("hp_82341: failed to allocate IRQ %d\n", irq);
+ if (request_irq(irq, hp_82341_interrupt, 0, DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "failed to allocate IRQ %d\n", irq);
return -EIO;
}
hp_priv->irq = irq;
- pr_info("hp_82341: IRQ %d\n", irq);
hp_priv->config_control_bits &= ~IRQ_SELECT_MASK;
hp_priv->config_control_bits |= IRQ_SELECT_BITS(irq);
outb(hp_priv->config_control_bits, hp_priv->iobase[0] + CONFIG_CONTROL_STATUS_REG);
@@ -768,13 +774,11 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config)
hp_priv->iobase[0] + EVENT_STATUS_REG);
tms9914_online(board, tms_priv);
- pr_info("hp_82341: board id %x %x %x %x\n", inb(hp_priv->iobase[1] + ID0_REG),
- inb(hp_priv->iobase[1] + ID1_REG), inb(hp_priv->iobase[2] + ID2_REG),
- inb(hp_priv->iobase[2] + ID3_REG));
+
return 0;
}
-void hp_82341_detach(gpib_board_t *board)
+static void hp_82341_detach(struct gpib_board *board)
{
struct hp_82341_priv *hp_priv = board->private_data;
struct tms9914_priv *tms_priv;
@@ -799,11 +803,14 @@ void hp_82341_detach(gpib_board_t *board)
hp_82341_free_private(board);
}
+#if 0
+/* unused, will be needed when the driver is turned into a pnp_driver */
static const struct pnp_device_id hp_82341_pnp_table[] = {
{.id = "HWP1411"},
{.id = ""}
};
MODULE_DEVICE_TABLE(pnp, hp_82341_pnp_table);
+#endif
static int __init hp_82341_init_module(void)
{
@@ -811,13 +818,13 @@ static int __init hp_82341_init_module(void)
ret = gpib_register_driver(&hp_82341_unaccel_interface, THIS_MODULE);
if (ret) {
- pr_err("hp_82341: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
return ret;
}
ret = gpib_register_driver(&hp_82341_interface, THIS_MODULE);
if (ret) {
- pr_err("hp_82341: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
gpib_unregister_driver(&hp_82341_unaccel_interface);
return ret;
}
@@ -837,7 +844,7 @@ module_exit(hp_82341_exit_module);
/*
* GPIB interrupt service routines
*/
-unsigned short read_and_clear_event_status(gpib_board_t *board)
+static unsigned short read_and_clear_event_status(struct gpib_board *board)
{
struct hp_82341_priv *hp_priv = board->private_data;
unsigned long flags;
@@ -850,10 +857,10 @@ unsigned short read_and_clear_event_status(gpib_board_t *board)
return status;
}
-irqreturn_t hp_82341_interrupt(int irq, void *arg)
+static irqreturn_t hp_82341_interrupt(int irq, void *arg)
{
int status1, status2;
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct hp_82341_priv *hp_priv = board->private_data;
struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv;
unsigned long flags;
@@ -862,7 +869,6 @@ irqreturn_t hp_82341_interrupt(int irq, void *arg)
spin_lock_irqsave(&board->spinlock, flags);
event_status = inb(hp_priv->iobase[0] + EVENT_STATUS_REG);
-// printk("hp_82341: interrupt event_status=0x%x\n", event_status);
if (event_status & INTERRUPT_PENDING_EVENT_BIT)
retval = IRQ_HANDLED;
//write-clear status bits
@@ -877,15 +883,12 @@ irqreturn_t hp_82341_interrupt(int irq, void *arg)
status1 = read_byte(tms_priv, ISR0);
status2 = read_byte(tms_priv, ISR1);
tms9914_interrupt_have_status(board, tms_priv, status1, status2);
-/* printk("hp_82341: interrupt status1=0x%x status2=0x%x\n",
- * status1, status2);
- */
}
spin_unlock_irqrestore(&board->spinlock, flags);
return retval;
}
-int read_transfer_counter(struct hp_82341_priv *hp_priv)
+static int read_transfer_counter(struct hp_82341_priv *hp_priv)
{
int lo, mid, value;
@@ -896,7 +899,7 @@ int read_transfer_counter(struct hp_82341_priv *hp_priv)
return value;
}
-void set_transfer_counter(struct hp_82341_priv *hp_priv, int count)
+static void set_transfer_counter(struct hp_82341_priv *hp_priv, int count)
{
int complement = -count;
diff --git a/drivers/staging/gpib/hp_82341/hp_82341.h b/drivers/staging/gpib/hp_82341/hp_82341.h
index 0065ebd9747c..370a3d4576eb 100644
--- a/drivers/staging/gpib/hp_82341/hp_82341.h
+++ b/drivers/staging/gpib/hp_82341/hp_82341.h
@@ -26,42 +26,6 @@ struct hp_82341_priv {
enum hp_82341_hardware_version hw_version;
};
-
-// interface functions
-int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read);
-int hp_82341_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written);
-int hp_82341_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read);
-int hp_82341_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written);
-int hp_82341_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written);
-int hp_82341_take_control(gpib_board_t *board, int synchronous);
-int hp_82341_go_to_standby(gpib_board_t *board);
-void hp_82341_request_system_control(gpib_board_t *board, int request_control);
-void hp_82341_interface_clear(gpib_board_t *board, int assert);
-void hp_82341_remote_enable(gpib_board_t *board, int enable);
-int hp_82341_enable_eos(gpib_board_t *board, uint8_t eos_byte, int
- compare_8_bits);
-void hp_82341_disable_eos(gpib_board_t *board);
-unsigned int hp_82341_update_status(gpib_board_t *board, unsigned int clear_mask);
-int hp_82341_primary_address(gpib_board_t *board, unsigned int address);
-int hp_82341_secondary_address(gpib_board_t *board, unsigned int address, int
- enable);
-int hp_82341_parallel_poll(gpib_board_t *board, uint8_t *result);
-void hp_82341_parallel_poll_configure(gpib_board_t *board, uint8_t config);
-void hp_82341_parallel_poll_response(gpib_board_t *board, int ist);
-void hp_82341_serial_poll_response(gpib_board_t *board, uint8_t status);
-void hp_82341_return_to_local(gpib_board_t *board);
-
-// interrupt service routines
-irqreturn_t hp_82341_interrupt(int irq, void *arg);
-
-// utility functions
-int hp_82341_allocate_private(gpib_board_t *board);
-void hp_82341_free_private(gpib_board_t *board);
-
static const int hp_82341_region_iosize = 0x8;
static const int hp_82341_num_io_regions = 4;
static const int hp_82341_fifo_size = 0xffe;
@@ -199,7 +163,3 @@ enum hp_82341d_pnp_pio_bits {
HP_82341D_LEGACY_MODE_BIT = 0x4,
HP_82341D_NOT_PROG_BIT = 0x8, // clear to reinitialize xilinx
};
-
-unsigned short read_and_clear_event_status(gpib_board_t *board);
-int read_transfer_counter(struct hp_82341_priv *hp_priv);
-void set_transfer_counter(struct hp_82341_priv *hp_priv, int count);
diff --git a/drivers/staging/gpib/include/gpibP.h b/drivers/staging/gpib/include/gpibP.h
index d35fdd391f7e..0c71a038e444 100644
--- a/drivers/staging/gpib/include/gpibP.h
+++ b/drivers/staging/gpib/include/gpibP.h
@@ -26,13 +26,13 @@ struct pci_dev *gpib_pci_get_subsys(const gpib_board_config_t *config, unsigned
unsigned int device_id, unsigned int ss_vendor,
unsigned int ss_device, struct pci_dev *from);
unsigned int num_gpib_events(const gpib_event_queue_t *queue);
-int push_gpib_event(gpib_board_t *board, short event_type);
-int pop_gpib_event(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type);
-int gpib_request_pseudo_irq(gpib_board_t *board, irqreturn_t (*handler)(int, void *));
-void gpib_free_pseudo_irq(gpib_board_t *board);
+int push_gpib_event(struct gpib_board *board, short event_type);
+int pop_gpib_event(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type);
+int gpib_request_pseudo_irq(struct gpib_board *board, irqreturn_t (*handler)(int, void *));
+void gpib_free_pseudo_irq(struct gpib_board *board);
int gpib_match_device_path(struct device *dev, const char *device_path_in);
-extern gpib_board_t board_array[GPIB_MAX_NUM_BOARDS];
+extern struct gpib_board board_array[GPIB_MAX_NUM_BOARDS];
extern struct list_head registered_drivers;
diff --git a/drivers/staging/gpib/include/gpib_proto.h b/drivers/staging/gpib/include/gpib_proto.h
index 1499f954210b..2c7dfc02f517 100644
--- a/drivers/staging/gpib/include/gpib_proto.h
+++ b/drivers/staging/gpib/include/gpib_proto.h
@@ -10,11 +10,11 @@ int ibclose(struct inode *inode, struct file *file);
long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg);
int osInit(void);
void osReset(void);
-void os_start_timer(gpib_board_t *board, unsigned int usec_timeout);
-void os_remove_timer(gpib_board_t *board);
+void os_start_timer(struct gpib_board *board, unsigned int usec_timeout);
+void os_remove_timer(struct gpib_board *board);
void osSendEOI(void);
void osSendEOI(void);
-void init_gpib_board(gpib_board_t *board);
+void init_gpib_board(struct gpib_board *board);
static inline unsigned long usec_to_jiffies(unsigned int usec)
{
unsigned long usec_per_jiffy = 1000000 / HZ;
@@ -22,35 +22,35 @@ static inline unsigned long usec_to_jiffies(unsigned int usec)
return 1 + (usec + usec_per_jiffy - 1) / usec_per_jiffy;
};
-int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout);
+int serial_poll_all(struct gpib_board *board, unsigned int usec_timeout);
void init_gpib_descriptor(gpib_descriptor_t *desc);
-int dvrsp(gpib_board_t *board, unsigned int pad, int sad,
+int dvrsp(struct gpib_board *board, unsigned int pad, int sad,
unsigned int usec_timeout, uint8_t *result);
-int ibAPWait(gpib_board_t *board, int pad);
-int ibAPrsp(gpib_board_t *board, int padsad, char *spb);
-void ibAPE(gpib_board_t *board, int pad, int v);
-int ibcac(gpib_board_t *board, int sync, int fallback_to_async);
-int ibcmd(gpib_board_t *board, uint8_t *buf, size_t length, size_t *bytes_written);
-int ibgts(gpib_board_t *board);
-int ibonline(gpib_board_t *board);
-int iboffline(gpib_board_t *board);
-int iblines(const gpib_board_t *board, short *lines);
-int ibrd(gpib_board_t *board, uint8_t *buf, size_t length, int *end_flag, size_t *bytes_read);
-int ibrpp(gpib_board_t *board, uint8_t *buf);
-int ibrsv2(gpib_board_t *board, uint8_t status_byte, int new_reason_for_service);
-void ibrsc(gpib_board_t *board, int request_control);
-int ibsic(gpib_board_t *board, unsigned int usec_duration);
-int ibsre(gpib_board_t *board, int enable);
-int ibpad(gpib_board_t *board, unsigned int addr);
-int ibsad(gpib_board_t *board, int addr);
-int ibeos(gpib_board_t *board, int eos, int eosflags);
-int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask,
+int ibAPWait(struct gpib_board *board, int pad);
+int ibAPrsp(struct gpib_board *board, int padsad, char *spb);
+void ibAPE(struct gpib_board *board, int pad, int v);
+int ibcac(struct gpib_board *board, int sync, int fallback_to_async);
+int ibcmd(struct gpib_board *board, uint8_t *buf, size_t length, size_t *bytes_written);
+int ibgts(struct gpib_board *board);
+int ibonline(struct gpib_board *board);
+int iboffline(struct gpib_board *board);
+int iblines(const struct gpib_board *board, short *lines);
+int ibrd(struct gpib_board *board, uint8_t *buf, size_t length, int *end_flag, size_t *bytes_read);
+int ibrpp(struct gpib_board *board, uint8_t *buf);
+int ibrsv2(struct gpib_board *board, uint8_t status_byte, int new_reason_for_service);
+void ibrsc(struct gpib_board *board, int request_control);
+int ibsic(struct gpib_board *board, unsigned int usec_duration);
+int ibsre(struct gpib_board *board, int enable);
+int ibpad(struct gpib_board *board, unsigned int addr);
+int ibsad(struct gpib_board *board, int addr);
+int ibeos(struct gpib_board *board, int eos, int eosflags);
+int ibwait(struct gpib_board *board, int wait_mask, int clear_mask, int set_mask,
int *status, unsigned long usec_timeout, gpib_descriptor_t *desc);
-int ibwrt(gpib_board_t *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written);
-int ibstatus(gpib_board_t *board);
-int general_ibstatus(gpib_board_t *board, const gpib_status_queue_t *device,
+int ibwrt(struct gpib_board *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written);
+int ibstatus(struct gpib_board *board);
+int general_ibstatus(struct gpib_board *board, const gpib_status_queue_t *device,
int clear_mask, int set_mask, gpib_descriptor_t *desc);
-int io_timed_out(gpib_board_t *board);
-int ibppc(gpib_board_t *board, uint8_t configuration);
+int io_timed_out(struct gpib_board *board);
+int ibppc(struct gpib_board *board, uint8_t configuration);
#endif /* GPIB_PROTO_INCLUDED */
diff --git a/drivers/staging/gpib/include/gpib_types.h b/drivers/staging/gpib/include/gpib_types.h
index b41781a55a60..2d9b9be683f8 100644
--- a/drivers/staging/gpib/include/gpib_types.h
+++ b/drivers/staging/gpib/include/gpib_types.h
@@ -23,7 +23,7 @@
#include <linux/interrupt.h>
typedef struct gpib_interface_struct gpib_interface_t;
-typedef struct gpib_board_struct gpib_board_t;
+struct gpib_board;
/* config parameters that are only used by driver attach functions */
typedef struct {
@@ -55,9 +55,9 @@ struct gpib_interface_struct {
/* name of board */
char *name;
/* attach() initializes board and allocates resources */
- int (*attach)(gpib_board_t *board, const gpib_board_config_t *config);
+ int (*attach)(struct gpib_board *board, const gpib_board_config_t *config);
/* detach() shuts down board and frees resources */
- void (*detach)(gpib_board_t *board);
+ void (*detach)(struct gpib_board *board);
/* read() should read at most 'length' bytes from the bus into
* 'buffer'. It should return when it fills the buffer or
* encounters an END (EOI and or EOS if appropriate). It should set 'end'
@@ -68,19 +68,19 @@ struct gpib_interface_struct {
* return indicates error.
* nbytes returns number of bytes read
*/
- int (*read)(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
+ int (*read)(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
size_t *bytes_read);
/* write() should write 'length' bytes from buffer to the bus.
* If the boolean value send_eoi is nonzero, then EOI should
* be sent along with the last byte. Returns number of bytes
* written or negative value on error.
*/
- int (*write)(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
+ int (*write)(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
size_t *bytes_written);
/* command() writes the command bytes in 'buffer' to the bus
* Returns zero on success or negative value on error.
*/
- int (*command)(gpib_board_t *board, uint8_t *buffer, size_t length,
+ int (*command)(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *bytes_written);
/* Take control (assert ATN). If 'asyncronous' is nonzero, take
* control asyncronously (assert ATN immediately without waiting
@@ -88,54 +88,54 @@ struct gpib_interface_struct {
* until board becomes controller in charge. Returns zero no success,
* nonzero on error.
*/
- int (*take_control)(gpib_board_t *board, int asyncronous);
+ int (*take_control)(struct gpib_board *board, int asyncronous);
/* De-assert ATN. Returns zero on success, nonzer on error.
*/
- int (*go_to_standby)(gpib_board_t *board);
+ int (*go_to_standby)(struct gpib_board *board);
/* request/release control of the IFC and REN lines (system controller) */
- void (*request_system_control)(gpib_board_t *board, int request_control);
+ void (*request_system_control)(struct gpib_board *board, int request_control);
/* Asserts or de-asserts 'interface clear' (IFC) depending on
* boolean value of 'assert'
*/
- void (*interface_clear)(gpib_board_t *board, int assert);
+ void (*interface_clear)(struct gpib_board *board, int assert);
/* Sends remote enable command if 'enable' is nonzero, disables remote mode
* if 'enable' is zero
*/
- void (*remote_enable)(gpib_board_t *board, int enable);
+ void (*remote_enable)(struct gpib_board *board, int enable);
/* enable END for reads, when byte 'eos' is received. If
* 'compare_8_bits' is nonzero, then all 8 bits are compared
* with the eos bytes. Otherwise only the 7 least significant
* bits are compared.
*/
- int (*enable_eos)(gpib_board_t *board, uint8_t eos, int compare_8_bits);
+ int (*enable_eos)(struct gpib_board *board, uint8_t eos, int compare_8_bits);
/* disable END on eos byte (END on EOI only)*/
- void (*disable_eos)(gpib_board_t *board);
+ void (*disable_eos)(struct gpib_board *board);
/* configure parallel poll */
- void (*parallel_poll_configure)(gpib_board_t *board, uint8_t configuration);
+ void (*parallel_poll_configure)(struct gpib_board *board, uint8_t configuration);
/* conduct parallel poll */
- int (*parallel_poll)(gpib_board_t *board, uint8_t *result);
+ int (*parallel_poll)(struct gpib_board *board, uint8_t *result);
/* set/clear ist (individual status bit) */
- void (*parallel_poll_response)(gpib_board_t *board, int ist);
+ void (*parallel_poll_response)(struct gpib_board *board, int ist);
/* select local parallel poll configuration mode PP2 versus remote PP1 */
- void (*local_parallel_poll_mode)(gpib_board_t *board, int local);
+ void (*local_parallel_poll_mode)(struct gpib_board *board, int local);
/* Returns current status of the bus lines. Should be set to
* NULL if your board does not have the ability to query the
* state of the bus lines.
*/
- int (*line_status)(const gpib_board_t *board);
+ int (*line_status)(const struct gpib_board *board);
/* updates and returns the board's current status.
* The meaning of the bits are specified in gpib_user.h
* in the IBSTA section. The driver does not need to
* worry about setting the CMPL, END, TIMO, or ERR bits.
*/
- unsigned int (*update_status)(gpib_board_t *board, unsigned int clear_mask);
+ unsigned int (*update_status)(struct gpib_board *board, unsigned int clear_mask);
/* Sets primary address 0-30 for gpib interface card.
*/
- int (*primary_address)(gpib_board_t *board, unsigned int address);
+ int (*primary_address)(struct gpib_board *board, unsigned int address);
/* Sets and enables, or disables secondary address 0-30
* for gpib interface card.
*/
- int (*secondary_address)(gpib_board_t *board, unsigned int address,
+ int (*secondary_address)(struct gpib_board *board, unsigned int address,
int enable);
/* Sets the byte the board should send in response to a serial poll.
* This function should also start or stop requests for service via
@@ -149,7 +149,7 @@ struct gpib_interface_struct {
* by IEEE 488.2 section 11.3.3.4.3 "Allowed Coupled Control of
* STB, reqt, and reqf".
*/
- void (*serial_poll_response)(gpib_board_t *board, uint8_t status_byte);
+ void (*serial_poll_response)(struct gpib_board *board, uint8_t status_byte);
/* Sets the byte the board should send in response to a serial poll.
* This function should also request service via IEEE 488.2 reqt/reqf
* based on MSS (bit 6 of the status_byte) and new_reason_for_service.
@@ -164,15 +164,15 @@ struct gpib_interface_struct {
* If this method is left NULL by the driver, then the user library
* function ibrsv2 will not work.
*/
- void (*serial_poll_response2)(gpib_board_t *board, uint8_t status_byte,
+ void (*serial_poll_response2)(struct gpib_board *board, uint8_t status_byte,
int new_reason_for_service);
/* returns the byte the board will send in response to a serial poll.
*/
- uint8_t (*serial_poll_status)(gpib_board_t *board);
+ uint8_t (*serial_poll_status)(struct gpib_board *board);
/* adjust T1 delay */
- unsigned int (*t1_delay)(gpib_board_t *board, unsigned int nano_sec);
+ int (*t1_delay)(struct gpib_board *board, unsigned int nano_sec);
/* go to local mode */
- void (*return_to_local)(gpib_board_t *board);
+ void (*return_to_local)(struct gpib_board *board);
/* board does not support 7 bit eos comparisons */
unsigned no_7_bit_eos : 1;
/* skip check for listeners before trying to send command bytes */
@@ -198,7 +198,7 @@ static inline void init_event_queue(gpib_event_queue_t *queue)
struct gpib_pseudo_irq {
struct timer_list timer;
irqreturn_t (*handler)(int irq, void *arg);
- gpib_board_t *board;
+ struct gpib_board *board;
atomic_t active;
};
@@ -216,11 +216,11 @@ typedef struct gpib_interface_list_struct {
struct module *module;
} gpib_interface_list_t;
-/* One gpib_board_t is allocated for each physical board in the computer.
+/* One struct gpib_board is allocated for each physical board in the computer.
* It provides storage for variables local to each board, and interface
* functions for performing operations on the board
*/
-struct gpib_board_struct {
+struct gpib_board {
/* functions used by this board */
gpib_interface_t *interface;
/* Pointer to module whose use count we should increment when
diff --git a/drivers/staging/gpib/include/nec7210.h b/drivers/staging/gpib/include/nec7210.h
index ca998c4a84bf..069896456230 100644
--- a/drivers/staging/gpib/include/nec7210.h
+++ b/drivers/staging/gpib/include/nec7210.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+//* SPDX-License-Identifier: GPL-2.0 */
/***************************************************************************
* copyright : (C) 2002 by Frank Mori Hess
@@ -78,48 +78,48 @@ enum {
};
// interface functions
-int nec7210_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+int nec7210_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read);
-int nec7210_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+int nec7210_write(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length, int send_eoi, size_t *bytes_written);
-int nec7210_command(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+int nec7210_command(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length, size_t *bytes_written);
-int nec7210_take_control(gpib_board_t *board, struct nec7210_priv *priv, int syncronous);
-int nec7210_go_to_standby(gpib_board_t *board, struct nec7210_priv *priv);
-void nec7210_request_system_control(gpib_board_t *board,
+int nec7210_take_control(struct gpib_board *board, struct nec7210_priv *priv, int syncronous);
+int nec7210_go_to_standby(struct gpib_board *board, struct nec7210_priv *priv);
+void nec7210_request_system_control(struct gpib_board *board,
struct nec7210_priv *priv, int request_control);
-void nec7210_interface_clear(gpib_board_t *board, struct nec7210_priv *priv, int assert);
-void nec7210_remote_enable(gpib_board_t *board, struct nec7210_priv *priv, int enable);
-int nec7210_enable_eos(gpib_board_t *board, struct nec7210_priv *priv, uint8_t eos_bytes,
+void nec7210_interface_clear(struct gpib_board *board, struct nec7210_priv *priv, int assert);
+void nec7210_remote_enable(struct gpib_board *board, struct nec7210_priv *priv, int enable);
+int nec7210_enable_eos(struct gpib_board *board, struct nec7210_priv *priv, uint8_t eos_bytes,
int compare_8_bits);
-void nec7210_disable_eos(gpib_board_t *board, struct nec7210_priv *priv);
-unsigned int nec7210_update_status(gpib_board_t *board, struct nec7210_priv *priv,
+void nec7210_disable_eos(struct gpib_board *board, struct nec7210_priv *priv);
+unsigned int nec7210_update_status(struct gpib_board *board, struct nec7210_priv *priv,
unsigned int clear_mask);
-unsigned int nec7210_update_status_nolock(gpib_board_t *board, struct nec7210_priv *priv);
-int nec7210_primary_address(const gpib_board_t *board,
+unsigned int nec7210_update_status_nolock(struct gpib_board *board, struct nec7210_priv *priv);
+int nec7210_primary_address(const struct gpib_board *board,
struct nec7210_priv *priv, unsigned int address);
-int nec7210_secondary_address(const gpib_board_t *board, struct nec7210_priv *priv,
+int nec7210_secondary_address(const struct gpib_board *board, struct nec7210_priv *priv,
unsigned int address, int enable);
-int nec7210_parallel_poll(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *result);
-void nec7210_serial_poll_response(gpib_board_t *board, struct nec7210_priv *priv, uint8_t status);
-void nec7210_parallel_poll_configure(gpib_board_t *board,
+int nec7210_parallel_poll(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *result);
+void nec7210_serial_poll_response(struct gpib_board *board, struct nec7210_priv *priv, uint8_t status);
+void nec7210_parallel_poll_configure(struct gpib_board *board,
struct nec7210_priv *priv, unsigned int configuration);
-void nec7210_parallel_poll_response(gpib_board_t *board,
+void nec7210_parallel_poll_response(struct gpib_board *board,
struct nec7210_priv *priv, int ist);
-uint8_t nec7210_serial_poll_status(gpib_board_t *board,
+uint8_t nec7210_serial_poll_status(struct gpib_board *board,
struct nec7210_priv *priv);
-unsigned int nec7210_t1_delay(gpib_board_t *board,
- struct nec7210_priv *priv, unsigned int nano_sec);
-void nec7210_return_to_local(const gpib_board_t *board, struct nec7210_priv *priv);
+int nec7210_t1_delay(struct gpib_board *board,
+ struct nec7210_priv *priv, unsigned int nano_sec);
+void nec7210_return_to_local(const struct gpib_board *board, struct nec7210_priv *priv);
// utility functions
-void nec7210_board_reset(struct nec7210_priv *priv, const gpib_board_t *board);
-void nec7210_board_online(struct nec7210_priv *priv, const gpib_board_t *board);
+void nec7210_board_reset(struct nec7210_priv *priv, const struct gpib_board *board);
+void nec7210_board_online(struct nec7210_priv *priv, const struct gpib_board *board);
unsigned int nec7210_set_reg_bits(struct nec7210_priv *priv, unsigned int reg,
unsigned int mask, unsigned int bits);
-void nec7210_set_handshake_mode(gpib_board_t *board, struct nec7210_priv *priv, int mode);
-void nec7210_release_rfd_holdoff(gpib_board_t *board, struct nec7210_priv *priv);
-uint8_t nec7210_read_data_in(gpib_board_t *board, struct nec7210_priv *priv, int *end);
+void nec7210_set_handshake_mode(struct gpib_board *board, struct nec7210_priv *priv, int mode);
+void nec7210_release_rfd_holdoff(struct gpib_board *board, struct nec7210_priv *priv);
+uint8_t nec7210_read_data_in(struct gpib_board *board, struct nec7210_priv *priv, int *end);
// wrappers for io functions
uint8_t nec7210_ioport_read_byte(struct nec7210_priv *priv, unsigned int register_num);
@@ -134,8 +134,8 @@ void nec7210_locking_iomem_write_byte(struct nec7210_priv *priv, uint8_t data,
unsigned int register_num);
// interrupt service routine
-irqreturn_t nec7210_interrupt(gpib_board_t *board, struct nec7210_priv *priv);
-irqreturn_t nec7210_interrupt_have_status(gpib_board_t *board,
+irqreturn_t nec7210_interrupt(struct gpib_board *board, struct nec7210_priv *priv);
+irqreturn_t nec7210_interrupt_have_status(struct gpib_board *board,
struct nec7210_priv *priv, int status1, int status2);
#endif //_NEC7210_H
diff --git a/drivers/staging/gpib/include/tms9914.h b/drivers/staging/gpib/include/tms9914.h
index d8c8d1c9b131..424c95ad85c6 100644
--- a/drivers/staging/gpib/include/tms9914.h
+++ b/drivers/staging/gpib/include/tms9914.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+//* SPDX-License-Identifier: GPL-2.0 */
/***************************************************************************
* copyright : (C) 2002 by Frank Mori Hess
@@ -79,47 +79,47 @@ enum {
};
// interface functions
-int tms9914_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer,
+int tms9914_read(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read);
-int tms9914_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer,
+int tms9914_write(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer,
size_t length, int send_eoi, size_t *bytes_written);
-int tms9914_command(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer,
+int tms9914_command(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer,
size_t length, size_t *bytes_written);
-int tms9914_take_control(gpib_board_t *board, struct tms9914_priv *priv, int syncronous);
+int tms9914_take_control(struct gpib_board *board, struct tms9914_priv *priv, int syncronous);
/* alternate version of tms9914_take_control which works around buggy tcs
* implementation.
*/
-int tms9914_take_control_workaround(gpib_board_t *board, struct tms9914_priv *priv,
+int tms9914_take_control_workaround(struct gpib_board *board, struct tms9914_priv *priv,
int syncronous);
-int tms9914_go_to_standby(gpib_board_t *board, struct tms9914_priv *priv);
-void tms9914_request_system_control(gpib_board_t *board, struct tms9914_priv *priv,
+int tms9914_go_to_standby(struct gpib_board *board, struct tms9914_priv *priv);
+void tms9914_request_system_control(struct gpib_board *board, struct tms9914_priv *priv,
int request_control);
-void tms9914_interface_clear(gpib_board_t *board, struct tms9914_priv *priv, int assert);
-void tms9914_remote_enable(gpib_board_t *board, struct tms9914_priv *priv, int enable);
-int tms9914_enable_eos(gpib_board_t *board, struct tms9914_priv *priv, uint8_t eos_bytes,
+void tms9914_interface_clear(struct gpib_board *board, struct tms9914_priv *priv, int assert);
+void tms9914_remote_enable(struct gpib_board *board, struct tms9914_priv *priv, int enable);
+int tms9914_enable_eos(struct gpib_board *board, struct tms9914_priv *priv, uint8_t eos_bytes,
int compare_8_bits);
-void tms9914_disable_eos(gpib_board_t *board, struct tms9914_priv *priv);
-unsigned int tms9914_update_status(gpib_board_t *board, struct tms9914_priv *priv,
+void tms9914_disable_eos(struct gpib_board *board, struct tms9914_priv *priv);
+unsigned int tms9914_update_status(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int clear_mask);
-int tms9914_primary_address(gpib_board_t *board,
+int tms9914_primary_address(struct gpib_board *board,
struct tms9914_priv *priv, unsigned int address);
-int tms9914_secondary_address(gpib_board_t *board, struct tms9914_priv *priv,
+int tms9914_secondary_address(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int address, int enable);
-int tms9914_parallel_poll(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *result);
-void tms9914_parallel_poll_configure(gpib_board_t *board,
+int tms9914_parallel_poll(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *result);
+void tms9914_parallel_poll_configure(struct gpib_board *board,
struct tms9914_priv *priv, uint8_t config);
-void tms9914_parallel_poll_response(gpib_board_t *board,
+void tms9914_parallel_poll_response(struct gpib_board *board,
struct tms9914_priv *priv, int ist);
-void tms9914_serial_poll_response(gpib_board_t *board, struct tms9914_priv *priv, uint8_t status);
-uint8_t tms9914_serial_poll_status(gpib_board_t *board, struct tms9914_priv *priv);
-int tms9914_line_status(const gpib_board_t *board, struct tms9914_priv *priv);
-unsigned int tms9914_t1_delay(gpib_board_t *board, struct tms9914_priv *priv,
+void tms9914_serial_poll_response(struct gpib_board *board, struct tms9914_priv *priv, uint8_t status);
+uint8_t tms9914_serial_poll_status(struct gpib_board *board, struct tms9914_priv *priv);
+int tms9914_line_status(const struct gpib_board *board, struct tms9914_priv *priv);
+unsigned int tms9914_t1_delay(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int nano_sec);
-void tms9914_return_to_local(const gpib_board_t *board, struct tms9914_priv *priv);
+void tms9914_return_to_local(const struct gpib_board *board, struct tms9914_priv *priv);
// utility functions
void tms9914_board_reset(struct tms9914_priv *priv);
-void tms9914_online(gpib_board_t *board, struct tms9914_priv *priv);
+void tms9914_online(struct gpib_board *board, struct tms9914_priv *priv);
void tms9914_release_holdoff(struct tms9914_priv *priv);
void tms9914_set_holdoff_mode(struct tms9914_priv *priv, enum tms9914_holdoff_mode mode);
@@ -130,8 +130,8 @@ uint8_t tms9914_iomem_read_byte(struct tms9914_priv *priv, unsigned int register
void tms9914_iomem_write_byte(struct tms9914_priv *priv, uint8_t data, unsigned int register_num);
// interrupt service routine
-irqreturn_t tms9914_interrupt(gpib_board_t *board, struct tms9914_priv *priv);
-irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, struct tms9914_priv *priv,
+irqreturn_t tms9914_interrupt(struct gpib_board *board, struct tms9914_priv *priv);
+irqreturn_t tms9914_interrupt_have_status(struct gpib_board *board, struct tms9914_priv *priv,
int status1, int status2);
// tms9914 has 8 registers
diff --git a/drivers/staging/gpib/ines/Makefile b/drivers/staging/gpib/ines/Makefile
index 6b6e480fd811..88241f15ecea 100644
--- a/drivers/staging/gpib/ines/Makefile
+++ b/drivers/staging/gpib/ines/Makefile
@@ -1,4 +1,3 @@
-ccflags-$(CONFIG_GPIB_PCMCIA) := -DGPIB_PCMCIA
obj-$(CONFIG_GPIB_INES) += ines_gpib.o
diff --git a/drivers/staging/gpib/ines/ines.h b/drivers/staging/gpib/ines/ines.h
index 3918737fa21a..ff27f055a0ff 100644
--- a/drivers/staging/gpib/ines/ines.h
+++ b/drivers/staging/gpib/ines/ines.h
@@ -36,41 +36,41 @@ struct ines_priv {
};
// interface functions
-int ines_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read);
-int ines_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+int ines_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read);
+int ines_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written);
-int ines_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
+int ines_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length,
int *end, size_t *bytes_read);
-int ines_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+int ines_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written);
-int ines_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written);
-int ines_take_control(gpib_board_t *board, int synchronous);
-int ines_go_to_standby(gpib_board_t *board);
-void ines_request_system_control(gpib_board_t *board, int request_control);
-void ines_interface_clear(gpib_board_t *board, int assert);
-void ines_remote_enable(gpib_board_t *board, int enable);
-int ines_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits);
-void ines_disable_eos(gpib_board_t *board);
-unsigned int ines_update_status(gpib_board_t *board, unsigned int clear_mask);
-int ines_primary_address(gpib_board_t *board, unsigned int address);
-int ines_secondary_address(gpib_board_t *board, unsigned int address, int enable);
-int ines_parallel_poll(gpib_board_t *board, uint8_t *result);
-void ines_parallel_poll_configure(gpib_board_t *board, uint8_t config);
-void ines_parallel_poll_response(gpib_board_t *board, int ist);
-void ines_serial_poll_response(gpib_board_t *board, uint8_t status);
-uint8_t ines_serial_poll_status(gpib_board_t *board);
-int ines_line_status(const gpib_board_t *board);
-unsigned int ines_t1_delay(gpib_board_t *board, unsigned int nano_sec);
-void ines_return_to_local(gpib_board_t *board);
+int ines_command(struct gpib_board *board, uint8_t *buffer, size_t length, size_t *bytes_written);
+int ines_take_control(struct gpib_board *board, int synchronous);
+int ines_go_to_standby(struct gpib_board *board);
+void ines_request_system_control(struct gpib_board *board, int request_control);
+void ines_interface_clear(struct gpib_board *board, int assert);
+void ines_remote_enable(struct gpib_board *board, int enable);
+int ines_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits);
+void ines_disable_eos(struct gpib_board *board);
+unsigned int ines_update_status(struct gpib_board *board, unsigned int clear_mask);
+int ines_primary_address(struct gpib_board *board, unsigned int address);
+int ines_secondary_address(struct gpib_board *board, unsigned int address, int enable);
+int ines_parallel_poll(struct gpib_board *board, uint8_t *result);
+void ines_parallel_poll_configure(struct gpib_board *board, uint8_t config);
+void ines_parallel_poll_response(struct gpib_board *board, int ist);
+void ines_serial_poll_response(struct gpib_board *board, uint8_t status);
+uint8_t ines_serial_poll_status(struct gpib_board *board);
+int ines_line_status(const struct gpib_board *board);
+int ines_t1_delay(struct gpib_board *board, unsigned int nano_sec);
+void ines_return_to_local(struct gpib_board *board);
// interrupt service routines
irqreturn_t ines_pci_interrupt(int irq, void *arg);
-irqreturn_t ines_interrupt(gpib_board_t *board);
+irqreturn_t ines_interrupt(struct gpib_board *board);
// utility functions
-void ines_free_private(gpib_board_t *board);
-int ines_generic_attach(gpib_board_t *board);
-void ines_online(struct ines_priv *priv, const gpib_board_t *board, int use_accel);
+void ines_free_private(struct gpib_board *board);
+int ines_generic_attach(struct gpib_board *board);
+void ines_online(struct ines_priv *priv, const struct gpib_board *board, int use_accel);
void ines_set_xfer_counter(struct ines_priv *priv, unsigned int count);
/* inb/outb wrappers */
diff --git a/drivers/staging/gpib/ines/ines_gpib.c b/drivers/staging/gpib/ines/ines_gpib.c
index 22a05a287bce..d93eb05dab90 100644
--- a/drivers/staging/gpib/ines/ines_gpib.c
+++ b/drivers/staging/gpib/ines/ines_gpib.c
@@ -5,6 +5,10 @@
* (C) 2002 by Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include "ines.h"
#include <linux/pci.h>
@@ -21,34 +25,32 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB driver for Ines iGPIB 72010");
-int ines_line_status(const gpib_board_t *board)
+int ines_line_status(const struct gpib_board *board)
{
- int status = ValidALL;
+ int status = VALID_ALL;
int bcm_bits;
struct ines_priv *ines_priv;
- struct nec7210_priv *nec_priv;
ines_priv = board->private_data;
- nec_priv = &ines_priv->nec7210_priv;
bcm_bits = ines_inb(ines_priv, BUS_CONTROL_MONITOR);
if (bcm_bits & BCM_REN_BIT)
- status |= BusREN;
+ status |= BUS_REN;
if (bcm_bits & BCM_IFC_BIT)
- status |= BusIFC;
+ status |= BUS_IFC;
if (bcm_bits & BCM_SRQ_BIT)
- status |= BusSRQ;
+ status |= BUS_SRQ;
if (bcm_bits & BCM_EOI_BIT)
- status |= BusEOI;
+ status |= BUS_EOI;
if (bcm_bits & BCM_NRFD_BIT)
- status |= BusNRFD;
+ status |= BUS_NRFD;
if (bcm_bits & BCM_NDAC_BIT)
- status |= BusNDAC;
+ status |= BUS_NDAC;
if (bcm_bits & BCM_DAV_BIT)
- status |= BusDAV;
+ status |= BUS_DAV;
if (bcm_bits & BCM_ATN_BIT)
- status |= BusATN;
+ status |= BUS_ATN;
return status;
}
@@ -56,14 +58,14 @@ int ines_line_status(const gpib_board_t *board)
void ines_set_xfer_counter(struct ines_priv *priv, unsigned int count)
{
if (count > 0xffff) {
- pr_err("ines: bug! tried to set xfer counter > 0xffff\n");
+ pr_err("bug! tried to set xfer counter > 0xffff\n");
return;
}
ines_outb(priv, (count >> 8) & 0xff, XFER_COUNT_UPPER);
ines_outb(priv, count & 0xff, XFER_COUNT_LOWER);
}
-unsigned int ines_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+int ines_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct ines_priv *ines_priv = board->private_data;
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv;
@@ -93,7 +95,7 @@ static inline unsigned short num_in_fifo_bytes(struct ines_priv *ines_priv)
return ines_inb(ines_priv, IN_FIFO_COUNT);
}
-static ssize_t pio_read(gpib_board_t *board, struct ines_priv *ines_priv, uint8_t *buffer,
+static ssize_t pio_read(struct gpib_board *board, struct ines_priv *ines_priv, uint8_t *buffer,
size_t length, size_t *nbytes)
{
ssize_t retval = 0;
@@ -106,21 +108,18 @@ static ssize_t pio_read(gpib_board_t *board, struct ines_priv *ines_priv, uint8_
num_in_fifo_bytes(ines_priv) ||
test_bit(RECEIVED_END_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- pr_warn("gpib: pio read wait interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
return -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
return -ETIMEDOUT;
if (test_bit(DEV_CLEAR_BN, &nec_priv->state))
return -EINTR;
num_fifo_bytes = num_in_fifo_bytes(ines_priv);
- if (num_fifo_bytes + *nbytes > length) {
- pr_warn("ines: counter allowed %li extra byte(s)\n",
- (long)(num_fifo_bytes - (length - *nbytes)));
+ if (num_fifo_bytes + *nbytes > length)
num_fifo_bytes = length - *nbytes;
- }
+
for (i = 0; i < num_fifo_bytes; i++)
buffer[(*nbytes)++] = read_byte(nec_priv, DIR);
if (test_bit(RECEIVED_END_BN, &nec_priv->state) &&
@@ -134,7 +133,7 @@ static ssize_t pio_read(gpib_board_t *board, struct ines_priv *ines_priv, uint8_
return retval;
}
-int ines_accel_read(gpib_board_t *board, uint8_t *buffer,
+int ines_accel_read(struct gpib_board *board, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
ssize_t retval = 0;
@@ -191,7 +190,7 @@ static inline unsigned short num_out_fifo_bytes(struct ines_priv *ines_priv)
return ines_inb(ines_priv, OUT_FIFO_COUNT);
}
-static int ines_write_wait(gpib_board_t *board, struct ines_priv *ines_priv,
+static int ines_write_wait(struct gpib_board *board, struct ines_priv *ines_priv,
unsigned int fifo_threshold)
{
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv;
@@ -201,10 +200,9 @@ static int ines_write_wait(gpib_board_t *board, struct ines_priv *ines_priv,
num_out_fifo_bytes(ines_priv) < fifo_threshold ||
test_bit(BUS_ERROR_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
return -ERESTARTSYS;
- }
+
if (test_bit(BUS_ERROR_BN, &nec_priv->state))
return -EIO;
if (test_bit(DEV_CLEAR_BN, &nec_priv->state))
@@ -215,7 +213,7 @@ static int ines_write_wait(gpib_board_t *board, struct ines_priv *ines_priv,
return 0;
}
-int ines_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+int ines_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
size_t count = 0;
@@ -268,7 +266,7 @@ int ines_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
irqreturn_t ines_pci_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct ines_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -283,7 +281,7 @@ irqreturn_t ines_pci_interrupt(int irq, void *arg)
return ines_interrupt(board);
}
-irqreturn_t ines_interrupt(gpib_board_t *board)
+irqreturn_t ines_interrupt(struct gpib_board *board)
{
struct ines_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -301,7 +299,7 @@ irqreturn_t ines_interrupt(gpib_board_t *board)
wake++;
}
if (isr3_bits & FIFO_ERROR_BIT)
- pr_err("ines gpib: fifo error\n");
+ dev_err(board->gpib_dev, "fifo error\n");
if (isr3_bits & XFER_COUNT_BIT)
wake++;
@@ -315,12 +313,12 @@ irqreturn_t ines_interrupt(gpib_board_t *board)
return IRQ_HANDLED;
}
-static int ines_pci_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int ines_pci_accel_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int ines_isa_attach(gpib_board_t *board, const gpib_board_config_t *config);
+static int ines_pci_attach(struct gpib_board *board, const gpib_board_config_t *config);
+static int ines_pci_accel_attach(struct gpib_board *board, const gpib_board_config_t *config);
+static int ines_isa_attach(struct gpib_board *board, const gpib_board_config_t *config);
-static void ines_pci_detach(gpib_board_t *board);
-static void ines_isa_detach(gpib_board_t *board);
+static void ines_pci_detach(struct gpib_board *board);
+static void ines_isa_detach(struct gpib_board *board);
enum ines_pci_vendor_ids {
PCI_VENDOR_ID_INES_QUICKLOGIC = 0x16da
@@ -395,7 +393,8 @@ static struct ines_pci_id pci_ids[] = {
static const int num_pci_chips = ARRAY_SIZE(pci_ids);
// wrappers for interface functions
-int ines_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read)
+int ines_read(struct gpib_board *board, uint8_t *buffer, size_t length,
+ int *end, size_t *bytes_read)
{
struct ines_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -413,7 +412,7 @@ int ines_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, siz
return retval;
}
-int ines_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
+int ines_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
size_t *bytes_written)
{
struct ines_priv *priv = board->private_data;
@@ -421,119 +420,119 @@ int ines_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
}
-int ines_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+int ines_command(struct gpib_board *board, uint8_t *buffer, size_t length, size_t *bytes_written)
{
struct ines_priv *priv = board->private_data;
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
}
-int ines_take_control(gpib_board_t *board, int synchronous)
+int ines_take_control(struct gpib_board *board, int synchronous)
{
struct ines_priv *priv = board->private_data;
return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
}
-int ines_go_to_standby(gpib_board_t *board)
+int ines_go_to_standby(struct gpib_board *board)
{
struct ines_priv *priv = board->private_data;
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-void ines_request_system_control(gpib_board_t *board, int request_control)
+void ines_request_system_control(struct gpib_board *board, int request_control)
{
struct ines_priv *priv = board->private_data;
nec7210_request_system_control(board, &priv->nec7210_priv, request_control);
}
-void ines_interface_clear(gpib_board_t *board, int assert)
+void ines_interface_clear(struct gpib_board *board, int assert)
{
struct ines_priv *priv = board->private_data;
nec7210_interface_clear(board, &priv->nec7210_priv, assert);
}
-void ines_remote_enable(gpib_board_t *board, int enable)
+void ines_remote_enable(struct gpib_board *board, int enable)
{
struct ines_priv *priv = board->private_data;
nec7210_remote_enable(board, &priv->nec7210_priv, enable);
}
-int ines_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+int ines_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct ines_priv *priv = board->private_data;
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
}
-void ines_disable_eos(gpib_board_t *board)
+void ines_disable_eos(struct gpib_board *board)
{
struct ines_priv *priv = board->private_data;
nec7210_disable_eos(board, &priv->nec7210_priv);
}
-unsigned int ines_update_status(gpib_board_t *board, unsigned int clear_mask)
+unsigned int ines_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct ines_priv *priv = board->private_data;
return nec7210_update_status(board, &priv->nec7210_priv, clear_mask);
}
-int ines_primary_address(gpib_board_t *board, unsigned int address)
+int ines_primary_address(struct gpib_board *board, unsigned int address)
{
struct ines_priv *priv = board->private_data;
return nec7210_primary_address(board, &priv->nec7210_priv, address);
}
-int ines_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+int ines_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct ines_priv *priv = board->private_data;
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
}
-int ines_parallel_poll(gpib_board_t *board, uint8_t *result)
+int ines_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct ines_priv *priv = board->private_data;
return nec7210_parallel_poll(board, &priv->nec7210_priv, result);
}
-void ines_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+void ines_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
struct ines_priv *priv = board->private_data;
nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config);
}
-void ines_parallel_poll_response(gpib_board_t *board, int ist)
+void ines_parallel_poll_response(struct gpib_board *board, int ist)
{
struct ines_priv *priv = board->private_data;
nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist);
}
-void ines_serial_poll_response(gpib_board_t *board, uint8_t status)
+void ines_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct ines_priv *priv = board->private_data;
nec7210_serial_poll_response(board, &priv->nec7210_priv, status);
}
-uint8_t ines_serial_poll_status(gpib_board_t *board)
+uint8_t ines_serial_poll_status(struct gpib_board *board)
{
struct ines_priv *priv = board->private_data;
return nec7210_serial_poll_status(board, &priv->nec7210_priv);
}
-void ines_return_to_local(gpib_board_t *board)
+void ines_return_to_local(struct gpib_board *board)
{
struct ines_priv *priv = board->private_data;
@@ -652,7 +651,7 @@ static gpib_interface_t ines_isa_interface = {
.return_to_local = ines_return_to_local,
};
-static int ines_allocate_private(gpib_board_t *board)
+static int ines_allocate_private(struct gpib_board *board)
{
struct ines_priv *priv;
@@ -665,13 +664,13 @@ static int ines_allocate_private(gpib_board_t *board)
return 0;
}
-void ines_free_private(gpib_board_t *board)
+void ines_free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
}
-int ines_generic_attach(gpib_board_t *board)
+int ines_generic_attach(struct gpib_board *board)
{
struct ines_priv *ines_priv;
struct nec7210_priv *nec_priv;
@@ -691,7 +690,7 @@ int ines_generic_attach(gpib_board_t *board)
return 0;
}
-void ines_online(struct ines_priv *ines_priv, const gpib_board_t *board, int use_accel)
+void ines_online(struct ines_priv *ines_priv, const struct gpib_board *board, int use_accel)
{
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv;
@@ -725,7 +724,7 @@ void ines_online(struct ines_priv *ines_priv, const gpib_board_t *board, int use
nec7210_set_reg_bits(nec_priv, IMR1, HR_DOIE | HR_DIIE, 0);
}
-static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int ines_common_pci_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct ines_priv *ines_priv;
struct nec7210_priv *nec_priv;
@@ -769,16 +768,16 @@ static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t
} while (1);
}
if (!ines_priv->pci_device) {
- pr_err("gpib: could not find ines PCI board\n");
+ dev_err(board->gpib_dev, "could not find ines PCI board\n");
return -1;
}
if (pci_enable_device(ines_priv->pci_device)) {
- pr_err("error enabling pci device\n");
+ dev_err(board->gpib_dev, "error enabling pci device\n");
return -1;
}
- if (pci_request_regions(ines_priv->pci_device, "ines-gpib"))
+ if (pci_request_regions(ines_priv->pci_device, DRV_NAME))
return -1;
nec_priv->iobase = pci_resource_start(ines_priv->pci_device,
found_id.gpib_region);
@@ -797,7 +796,7 @@ static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t
case PCI_CHIP_QUICKLOGIC5030:
break;
default:
- pr_err("gpib: unspecified chip type? (bug)\n");
+ dev_err(board->gpib_dev, "unspecified chip type? (bug)\n");
nec_priv->iobase = 0;
pci_release_regions(ines_priv->pci_device);
return -1;
@@ -813,8 +812,8 @@ static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t
#endif
isr_flags |= IRQF_SHARED;
if (request_irq(ines_priv->pci_device->irq, ines_pci_interrupt, isr_flags,
- "pci-gpib", board)) {
- pr_err("gpib: can't request IRQ %d\n", ines_priv->pci_device->irq);
+ DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "can't request IRQ %d\n", ines_priv->pci_device->irq);
return -1;
}
ines_priv->irq = ines_priv->pci_device->irq;
@@ -846,14 +845,14 @@ static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t
case PCI_CHIP_QUICKLOGIC5030:
break;
default:
- pr_err("gpib: unspecified chip type? (bug)\n");
+ dev_err(board->gpib_dev, "unspecified chip type? (bug)\n");
return -1;
}
return 0;
}
-int ines_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
+int ines_pci_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct ines_priv *ines_priv;
int retval;
@@ -868,7 +867,7 @@ int ines_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-int ines_pci_accel_attach(gpib_board_t *board, const gpib_board_config_t *config)
+int ines_pci_accel_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct ines_priv *ines_priv;
int retval;
@@ -885,7 +884,7 @@ int ines_pci_accel_attach(gpib_board_t *board, const gpib_board_config_t *config
static const int ines_isa_iosize = 0x20;
-int ines_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
+int ines_isa_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct ines_priv *ines_priv;
struct nec7210_priv *nec_priv;
@@ -899,15 +898,16 @@ int ines_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
ines_priv = board->private_data;
nec_priv = &ines_priv->nec7210_priv;
- if (!request_region(config->ibbase, ines_isa_iosize, "ines_gpib")) {
- pr_err("ines_gpib: ioports at 0x%x already in use\n", config->ibbase);
- return -1;
+ if (!request_region(config->ibbase, ines_isa_iosize, DRV_NAME)) {
+ dev_err(board->gpib_dev, "ioports at 0x%x already in use\n",
+ config->ibbase);
+ return -EBUSY;
}
nec_priv->iobase = config->ibbase;
nec_priv->offset = 1;
nec7210_board_reset(nec_priv, board);
- if (request_irq(config->ibirq, ines_pci_interrupt, isr_flags, "ines_gpib", board)) {
- pr_err("ines_gpib: failed to allocate IRQ %d\n", config->ibirq);
+ if (request_irq(config->ibirq, ines_pci_interrupt, isr_flags, DRV_NAME, board)) {
+ dev_err(board->gpib_dev, "failed to allocate IRQ %d\n", config->ibirq);
return -1;
}
ines_priv->irq = config->ibirq;
@@ -915,7 +915,7 @@ int ines_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-void ines_pci_detach(gpib_board_t *board)
+void ines_pci_detach(struct gpib_board *board)
{
struct ines_priv *ines_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -949,7 +949,7 @@ void ines_pci_detach(gpib_board_t *board)
ines_free_private(board);
}
-void ines_isa_detach(gpib_board_t *board)
+void ines_isa_detach(struct gpib_board *board)
{
struct ines_priv *ines_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -977,7 +977,7 @@ static struct pci_driver ines_pci_driver = {
.probe = &ines_pci_probe
};
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
#include <linux/kernel.h>
#include <linux/ptrace.h>
@@ -988,13 +988,6 @@ static struct pci_driver ines_pci_driver = {
#include <pcmcia/ds.h>
#include <pcmcia/cisreg.h>
-#ifdef PCMCIA_DEBUG
-static int pc_debug = PCMCIA_DEBUG;
-#define DEBUG(n, args...) do {if (pc_debug > (n)) pr_debug(args)} while (0)
-#else
-#define DEBUG(args...)
-#endif
-
static const int ines_pcmcia_iosize = 0x20;
/* The event() function is this driver's Card Services event handler.
@@ -1007,11 +1000,11 @@ static const int ines_pcmcia_iosize = 0x20;
static int ines_gpib_config(struct pcmcia_device *link);
static void ines_gpib_release(struct pcmcia_device *link);
-static int ines_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int ines_pcmcia_accel_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static void ines_pcmcia_detach(gpib_board_t *board);
+static int ines_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config);
+static int ines_pcmcia_accel_attach(struct gpib_board *board, const gpib_board_config_t *config);
+static void ines_pcmcia_detach(struct gpib_board *board);
static irqreturn_t ines_pcmcia_interrupt(int irq, void *arg);
-static int ines_common_pcmcia_attach(gpib_board_t *board);
+static int ines_common_pcmcia_attach(struct gpib_board *board);
/*
* A linked list of "instances" of the gpib device. Each actual
* PCMCIA card corresponds to one device instance, and is described
@@ -1043,7 +1036,7 @@ static struct pcmcia_device *curr_dev;
struct local_info {
struct pcmcia_device *p_dev;
- gpib_board_t *dev;
+ struct gpib_board *dev;
u_short manfid;
u_short cardid;
};
@@ -1063,8 +1056,6 @@ static int ines_gpib_probe(struct pcmcia_device *link)
// int ret, i;
- DEBUG(0, "%s(0x%p)\n", __func__ link);
-
/* Allocate space for private device-specific data */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
@@ -1096,9 +1087,7 @@ static int ines_gpib_probe(struct pcmcia_device *link)
static void ines_gpib_remove(struct pcmcia_device *link)
{
struct local_info *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
-
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
if (info->dev)
ines_pcmcia_detach(info->dev);
@@ -1125,7 +1114,6 @@ static int ines_gpib_config(struct pcmcia_device *link)
void __iomem *virt;
dev = link->priv;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
retval = pcmcia_loop_config(link, &ines_gpib_config_iteration, NULL);
if (retval) {
@@ -1134,8 +1122,8 @@ static int ines_gpib_config(struct pcmcia_device *link)
return -ENODEV;
}
- pr_debug("ines_cs: manufacturer: 0x%x card: 0x%x\n",
- link->manf_id, link->card_id);
+ dev_dbg(&link->dev, "ines_cs: manufacturer: 0x%x card: 0x%x\n",
+ link->manf_id, link->card_id);
/* for the ines card we have to setup the configuration registers in
* attribute memory here
@@ -1167,7 +1155,6 @@ static int ines_gpib_config(struct pcmcia_device *link)
ines_gpib_release(link);
return -ENODEV;
}
- pr_info("ines gpib device loaded\n");
return 0;
} /* gpib_config */
@@ -1179,18 +1166,16 @@ static int ines_gpib_config(struct pcmcia_device *link)
static void ines_gpib_release(struct pcmcia_device *link)
{
- DEBUG(0, "%s(0x%p)\n", __func__, link);
pcmcia_disable_device(link);
} /* gpib_release */
static int ines_gpib_suspend(struct pcmcia_device *link)
{
//struct local_info *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
if (link->open)
- pr_err("Device still open ???\n");
+ dev_err(&link->dev, "Device still open\n");
//netif_device_detach(dev);
return 0;
@@ -1199,12 +1184,10 @@ static int ines_gpib_suspend(struct pcmcia_device *link)
static int ines_gpib_resume(struct pcmcia_device *link)
{
//struct local_info_t *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
/*if (link->open) {
* ni_gpib_probe(dev); / really?
- * printk("Gpib resumed ???\n");
* //netif_device_attach(dev);
*}
*/
@@ -1229,7 +1212,6 @@ static struct pcmcia_driver ines_gpib_cs_driver = {
void ines_pcmcia_cleanup_module(void)
{
- DEBUG(0, "ines_cs: unloading\n");
pcmcia_unregister_driver(&ines_gpib_cs_driver);
}
@@ -1319,19 +1301,19 @@ static gpib_interface_t ines_pcmcia_interface = {
irqreturn_t ines_pcmcia_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
return ines_interrupt(board);
}
-int ines_common_pcmcia_attach(gpib_board_t *board)
+int ines_common_pcmcia_attach(struct gpib_board *board)
{
struct ines_priv *ines_priv;
struct nec7210_priv *nec_priv;
int retval;
if (!curr_dev) {
- pr_err("no ines pcmcia cards found\n");
+ dev_err(board->gpib_dev, "no ines pcmcia cards found\n");
return -1;
}
@@ -1343,9 +1325,9 @@ int ines_common_pcmcia_attach(gpib_board_t *board)
nec_priv = &ines_priv->nec7210_priv;
if (!request_region(curr_dev->resource[0]->start,
- resource_size(curr_dev->resource[0]), "ines_gpib")) {
- pr_err("ines_gpib: ioports at 0x%lx already in use\n",
- (unsigned long)(curr_dev->resource[0]->start));
+ resource_size(curr_dev->resource[0]), DRV_NAME)) {
+ dev_err(board->gpib_dev, "ioports at 0x%lx already in use\n",
+ (unsigned long)(curr_dev->resource[0]->start));
return -1;
}
@@ -1355,7 +1337,7 @@ int ines_common_pcmcia_attach(gpib_board_t *board)
if (request_irq(curr_dev->irq, ines_pcmcia_interrupt, IRQF_SHARED,
"pcmcia-gpib", board)) {
- pr_err("gpib: can't request IRQ %d\n", curr_dev->irq);
+ dev_err(board->gpib_dev, "can't request IRQ %d\n", curr_dev->irq);
return -1;
}
ines_priv->irq = curr_dev->irq;
@@ -1363,7 +1345,7 @@ int ines_common_pcmcia_attach(gpib_board_t *board)
return 0;
}
-int ines_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
+int ines_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct ines_priv *ines_priv;
int retval;
@@ -1378,7 +1360,7 @@ int ines_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-int ines_pcmcia_accel_attach(gpib_board_t *board, const gpib_board_config_t *config)
+int ines_pcmcia_accel_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct ines_priv *ines_priv;
int retval;
@@ -1393,7 +1375,7 @@ int ines_pcmcia_accel_attach(gpib_board_t *board, const gpib_board_config_t *con
return 0;
}
-void ines_pcmcia_detach(gpib_board_t *board)
+void ines_pcmcia_detach(struct gpib_board *board)
{
struct ines_priv *ines_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1410,7 +1392,7 @@ void ines_pcmcia_detach(gpib_board_t *board)
ines_free_private(board);
}
-#endif /* GPIB_PCMCIA */
+#endif /* CONFIG_GPIB_PCMCIA */
static int __init ines_init_module(void)
{
@@ -1418,63 +1400,63 @@ static int __init ines_init_module(void)
ret = pci_register_driver(&ines_pci_driver);
if (ret) {
- pr_err("ines_gpib: pci_register_driver failed: error = %d\n", ret);
+ pr_err("pci_register_driver failed: error = %d\n", ret);
return ret;
}
ret = gpib_register_driver(&ines_pci_interface, THIS_MODULE);
if (ret) {
- pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pci;
}
ret = gpib_register_driver(&ines_pci_unaccel_interface, THIS_MODULE);
if (ret) {
- pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pci_unaccel;
}
ret = gpib_register_driver(&ines_pci_accel_interface, THIS_MODULE);
if (ret) {
- pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pci_accel;
}
ret = gpib_register_driver(&ines_isa_interface, THIS_MODULE);
if (ret) {
- pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_isa;
}
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
ret = gpib_register_driver(&ines_pcmcia_interface, THIS_MODULE);
if (ret) {
- pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pcmcia;
}
ret = gpib_register_driver(&ines_pcmcia_unaccel_interface, THIS_MODULE);
if (ret) {
- pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pcmcia_unaccel;
}
ret = gpib_register_driver(&ines_pcmcia_accel_interface, THIS_MODULE);
if (ret) {
- pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pcmcia_accel;
}
ret = pcmcia_register_driver(&ines_gpib_cs_driver);
if (ret) {
- pr_err("ines_gpib: pcmcia_register_driver failed: error = %d\n", ret);
+ pr_err("pcmcia_register_driver failed: error = %d\n", ret);
goto err_pcmcia_driver;
}
#endif
return 0;
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
err_pcmcia_driver:
gpib_unregister_driver(&ines_pcmcia_accel_interface);
err_pcmcia_accel:
diff --git a/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c b/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
index 85322af62c23..faf96e9cc4a1 100644
--- a/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
+++ b/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
@@ -8,6 +8,10 @@
* copyright : (C) 2011 Marcello Carla' *
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define NAME KBUILD_MODNAME
+
/* base module includes */
#include <linux/module.h>
@@ -31,8 +35,6 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB driver for LPVO usb devices");
-#define NAME "lpvo_usb_gpib"
-
/*
* Table of devices that work with this driver.
*
@@ -55,10 +57,11 @@ MODULE_DEVICE_TABLE(usb, skel_table);
/*
* *** Diagnostics and Debug ***
- *
+ * To enable the diagnostic and debug messages either compile with DEBUG set
+ * or control via the dynamic debug mechanisms.
* The module parameter "debug" controls the sending of debug messages to
- * syslog. By default it is set to 0 or 1 according to GPIB_CONFIG_KERNEL_DEBUG.
- * debug = 0: only register/deregister messages are generated
+ * syslog. By default it is set to 0
+ * debug = 0: only attach/detach messages are sent
* 1: every action is logged
* 2: extended logging; each single exchanged byte is documented
* (about twice the log volume of [1])
@@ -70,11 +73,15 @@ MODULE_DEVICE_TABLE(usb, skel_table);
static int debug;
module_param(debug, int, 0644);
-#define DIA_LOG(level, format, ...) \
+#define DIA_LOG(level, format, ...) \
do { if (debug >= (level)) \
- pr_alert("%s:%s - " format, NAME, __func__, ## __VA_ARGS__); } \
+ dev_dbg(board->gpib_dev, format, ## __VA_ARGS__); } \
while (0)
+#define WQT wait_queue_entry_t
+#define WQH head
+#define WQE entry
+
/* standard and extended command sets of the usb-gpib adapter */
#define USB_GPIB_ON "\nIB\n"
@@ -135,7 +142,7 @@ struct char_buf { /* used by one_char() routine */
};
struct usb_gpib_priv { /* private data to the device */
- u8 eos; /* eos character */
+ u8 eos; /* eos character */
short eos_flags; /* eos mode */
int timeout; /* current value for timeout */
void *dev; /* the usb device private data structure */
@@ -143,42 +150,23 @@ struct usb_gpib_priv { /* private data to the device */
#define GPIB_DEV (((struct usb_gpib_priv *)board->private_data)->dev)
-#define SHOW_STATUS(board) { \
- DIA_LOG(2, "# - board %p\n", board); \
- DIA_LOG(2, "# - buffer_length %d\n", board->buffer_length); \
- DIA_LOG(2, "# - status %lx\n", board->status); \
- DIA_LOG(2, "# - use_count %d\n", board->use_count); \
- DIA_LOG(2, "# - pad %x\n", board->pad); \
- DIA_LOG(2, "# - sad %x\n", board->sad); \
- DIA_LOG(2, "# - timeout %d\n", board->usec_timeout); \
- DIA_LOG(2, "# - ppc %d\n", board->parallel_poll_configuration); \
- DIA_LOG(2, "# - t1delay %d\n", board->t1_nano_sec); \
- DIA_LOG(2, "# - online %d\n", board->online); \
- DIA_LOG(2, "# - autopoll %d\n", board->autospollers); \
- DIA_LOG(2, "# - autopoll task %p\n", board->autospoll_task); \
- DIA_LOG(2, "# - minor %d\n", board->minor); \
- DIA_LOG(2, "# - master %d\n", board->master); \
- DIA_LOG(2, "# - list %d\n", board->ist); \
- }
-/*
- * n = 0;
- * list_for_each (l, &board->device_list) n++;
- * TTY_LOG ("%s:%s - devices in list %d\n", a, b, n);
- */
-
-/*
- * TTY_LOG - write a message to the current work terminal (if any)
- */
-
-#define TTY_LOG(format, ...) { \
- char buf[128]; \
- struct tty_struct *tty = get_current_tty(); \
- if (tty) { \
- snprintf(buf, 128, format, __VA_ARGS__); \
- tty->driver->ops->write(tty, buf, strlen(buf)); \
- tty->driver->ops->write(tty, "\r", 1); \
- } \
- }
+static void show_status(struct gpib_board *board)
+{
+ DIA_LOG(2, "# - buffer_length %d\n", board->buffer_length);
+ DIA_LOG(2, "# - status %lx\n", board->status);
+ DIA_LOG(2, "# - use_count %d\n", board->use_count);
+ DIA_LOG(2, "# - pad %x\n", board->pad);
+ DIA_LOG(2, "# - sad %x\n", board->sad);
+ DIA_LOG(2, "# - timeout %d\n", board->usec_timeout);
+ DIA_LOG(2, "# - ppc %d\n", board->parallel_poll_configuration);
+ DIA_LOG(2, "# - t1delay %d\n", board->t1_nano_sec);
+ DIA_LOG(2, "# - online %d\n", board->online);
+ DIA_LOG(2, "# - autopoll %d\n", board->autospollers);
+ DIA_LOG(2, "# - autopoll task %p\n", board->autospoll_task);
+ DIA_LOG(2, "# - minor %d\n", board->minor);
+ DIA_LOG(2, "# - master %d\n", board->master);
+ DIA_LOG(2, "# - list %d\n", board->ist);
+}
/*
* GLOBAL VARIABLES: required for
@@ -200,8 +188,8 @@ static struct mutex minors_lock; /* operations on usb_minors are to be prote
struct usb_skel;
static ssize_t skel_do_write(struct usb_skel *, const char *, size_t);
static ssize_t skel_do_read(struct usb_skel *, char *, size_t);
-static int skel_do_open(gpib_board_t *, int);
-static int skel_do_release(gpib_board_t *);
+static int skel_do_open(struct gpib_board *, int);
+static int skel_do_release(struct gpib_board *);
/*
* usec_diff : take difference in MICROsec between two 'timespec'
@@ -229,27 +217,7 @@ static inline int usec_diff(struct timespec64 *a, struct timespec64 *b)
static int write_loop(void *dev, char *msg, int leng)
{
-// int nchar = 0, val;
-
-// do {
-
return skel_do_write(dev, msg, leng);
-
-// if (val < 1) {
-// printk (KERN_ALERT "%s:%s - write error: %d %d/%d\n",
-// NAME, __func__, val, nchar, leng);
-// return -EIO;
-// }
-// nchar +=val;
-// } while (nchar < leng);
-// return leng;
-}
-
-static char printable(char x)
-{
- if (x < 32 || x > 126)
- return ' ';
- return x;
}
/**
@@ -257,15 +225,15 @@ static char printable(char x)
*
* @board: the gpib_board_struct data area for this gpib interface
* @msg: the byte sequence.
- * @leng the byte sequence length; can be given as zero and is
+ * @leng: the byte sequence length; can be given as zero and is
* computed automatically, but if 'msg' contains a zero byte,
* it has to be given explicitly.
*/
-static int send_command(gpib_board_t *board, char *msg, int leng)
+static int send_command(struct gpib_board *board, char *msg, int leng)
{
char buffer[64];
- int nchar, j;
+ int nchar;
int retval;
struct timespec64 before, after;
@@ -280,17 +248,10 @@ static int send_command(gpib_board_t *board, char *msg, int leng)
nchar = skel_do_read(GPIB_DEV, buffer, 64);
if (nchar < 0) {
- DIA_LOG(0, " return from read: %d\n", nchar);
+ dev_err(board->gpib_dev, " return from read: %d\n", nchar);
return nchar;
} else if (nchar != 1) {
- for (j = 0 ; j < leng ; j++) {
- DIA_LOG(0, " Irregular reply to command: %d %x %c\n",
- j, msg[j], printable(msg[j]));
- }
- for (j = 0 ; j < nchar ; j++) {
- DIA_LOG(0, " Irregular command reply: %d %x %c\n",
- j, buffer[j] & 0xff, printable(buffer[j]));
- }
+ dev_err(board->gpib_dev, " Irregular reply to command: %s\n", msg);
return -EIO;
}
ktime_get_real_ts64 (&after);
@@ -310,7 +271,7 @@ static int send_command(gpib_board_t *board, char *msg, int leng)
*
*/
-static int set_control_line(gpib_board_t *board, int line, int value)
+static int set_control_line(struct gpib_board *board, int line, int value)
{
char msg[] = USB_GPIB_SET_LINES;
int retval;
@@ -337,11 +298,11 @@ static int set_control_line(gpib_board_t *board, int line, int value)
/*
* one_char() - read one single byte from input buffer
*
- * @board: the gpib_board_struct data area for this gpib interface
- * @char_buf: the routine private data structure
+ * @board: the gpib_board_struct data area for this gpib interface
+ * @char_buf: the routine private data structure
*/
-static int one_char(gpib_board_t *board, struct char_buf *b)
+static int one_char(struct gpib_board *board, struct char_buf *b)
{
struct timespec64 before, after;
@@ -360,13 +321,7 @@ static int one_char(gpib_board_t *board, struct char_buf *b)
if (b->nchar > 0) {
DIA_LOG(2, "--> %x\n", b->inbuf[b->last - b->nchar]);
return b->inbuf[b->last - b->nchar--];
- } else if (b->nchar == 0) {
- dev_alert(board->gpib_dev, "%s:%s - read returned EOF\n", NAME, __func__);
- return -EIO;
}
- dev_alert(board->gpib_dev, "%s:%s - read error %d\n", NAME, __func__, b->nchar);
- TTY_LOG("\n *** %s *** Read Error - %s\n", NAME,
- "Reset the adapter with 'gpib_config'\n");
return -EIO;
}
@@ -381,7 +336,7 @@ static int one_char(gpib_board_t *board, struct char_buf *b)
* not supported.
*/
-static void set_timeout(gpib_board_t *board)
+static void set_timeout(struct gpib_board *board)
{
int n, val;
char command[sizeof(USB_GPIB_TTMO) + 6];
@@ -406,12 +361,10 @@ static void set_timeout(gpib_board_t *board)
val = send_command(board, command, 0);
}
- if (val != ACK) {
- dev_alert(board->gpib_dev, "%s:%s - error in timeout set: <%s>\n",
- NAME, __func__, command);
- } else {
+ if (val != ACK)
+ dev_err(board->gpib_dev, "error in timeout set: <%s>\n", command);
+ else
data->timeout = board->usec_timeout;
- }
}
/*
@@ -431,7 +384,7 @@ static void set_timeout(gpib_board_t *board)
* detach() will be called. Always.
*/
-static int usb_gpib_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int usb_gpib_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
int retval, j;
u32 base = config->ibbase;
@@ -451,8 +404,6 @@ static int usb_gpib_attach(gpib_board_t *board, const gpib_board_config_t *confi
if (config->device_path) {
/* if config->device_path given, try that first */
- dev_alert(board->gpib_dev, "%s:%s - Looking for device_path: %s\n",
- NAME, __func__, config->device_path);
for (j = 0 ; j < MAX_DEV ; j++) {
if ((assigned_usb_minors & 1 << j) == 0)
continue;
@@ -487,8 +438,7 @@ static int usb_gpib_attach(gpib_board_t *board, const gpib_board_config_t *confi
mutex_unlock(&minors_lock);
if (j == MAX_DEV) {
- dev_alert(board->gpib_dev, "%s:%s - Requested device is not registered.\n",
- NAME, __func__);
+ dev_err(board->gpib_dev, "Requested device is not registered.\n");
return -EIO;
}
@@ -501,13 +451,13 @@ static int usb_gpib_attach(gpib_board_t *board, const gpib_board_config_t *confi
DIA_LOG(1, "Skel open: %d\n", retval);
if (retval) {
- TTY_LOG("%s:%s - skel open failed.\n", NAME, __func__);
+ dev_err(board->gpib_dev, "skel open failed.\n");
kfree(board->private_data);
board->private_data = NULL;
return -ENODEV;
}
- SHOW_STATUS(board);
+ show_status(board);
retval = send_command(board, USB_GPIB_ON, 0);
DIA_LOG(1, "USB_GPIB_ON returns %x\n", retval);
@@ -541,8 +491,8 @@ static int usb_gpib_attach(gpib_board_t *board, const gpib_board_config_t *confi
if (retval != ACK)
return -EIO;
- SHOW_STATUS(board);
- TTY_LOG("Module '%s' has been sucesfully configured\n", NAME);
+ show_status(board);
+ DIA_LOG(0, "attached\n");
return 0;
}
@@ -553,13 +503,13 @@ static int usb_gpib_attach(gpib_board_t *board, const gpib_board_config_t *confi
*
*/
-static void usb_gpib_detach(gpib_board_t *board)
+static void usb_gpib_detach(struct gpib_board *board)
{
int retval;
- SHOW_STATUS(board);
+ show_status(board);
- DIA_LOG(0, "detaching %p\n", board);
+ DIA_LOG(0, "detaching\n");
if (board->private_data) {
if (GPIB_DEV) {
@@ -573,15 +523,14 @@ static void usb_gpib_detach(gpib_board_t *board)
board->private_data = NULL;
}
- DIA_LOG(0, "done %p\n", board);
- TTY_LOG("Module '%s' has been detached\n", NAME);
+ DIA_LOG(0, "detached\n");
}
/*
* Other functions follow in alphabetical order
*/
/* command */
-static int usb_gpib_command(gpib_board_t *board,
+static int usb_gpib_command(struct gpib_board *board,
u8 *buffer,
size_t length,
size_t *bytes_written)
@@ -614,7 +563,7 @@ static int usb_gpib_command(gpib_board_t *board,
* Cannot do nothing here, but remember for future use.
*/
-static void usb_gpib_disable_eos(gpib_board_t *board)
+static void usb_gpib_disable_eos(struct gpib_board *board)
{
((struct usb_gpib_priv *)board->private_data)->eos_flags &= ~REOS;
DIA_LOG(1, "done: %x\n",
@@ -630,7 +579,7 @@ static void usb_gpib_disable_eos(gpib_board_t *board)
*
*/
-static int usb_gpib_enable_eos(gpib_board_t *board,
+static int usb_gpib_enable_eos(struct gpib_board *board,
u8 eos_byte,
int compare_8_bits)
{
@@ -650,7 +599,7 @@ static int usb_gpib_enable_eos(gpib_board_t *board,
* @board: the gpib_board data area for this gpib interface
*/
-static int usb_gpib_go_to_standby(gpib_board_t *board)
+static int usb_gpib_go_to_standby(struct gpib_board *board)
{
int retval = set_control_line(board, IB_BUS_ATN, 0);
@@ -665,14 +614,14 @@ static int usb_gpib_go_to_standby(gpib_board_t *board)
* usb_gpib_interface_clear() - Assert or de-assert IFC
*
* @board: the gpib_board data area for this gpib interface
- * assert: 1: assert IFC; 0: de-assert IFC
+ * @assert: 1: assert IFC; 0: de-assert IFC
*
* Currently on the assert request we issue the lpvo IBZ
* command that cycles IFC low for 100 usec, then we ignore
* the de-assert request.
*/
-static void usb_gpib_interface_clear(gpib_board_t *board, int assert)
+static void usb_gpib_interface_clear(struct gpib_board *board, int assert)
{
int retval = 0;
@@ -688,21 +637,16 @@ static void usb_gpib_interface_clear(gpib_board_t *board, int assert)
}
/**
- * line_status() - Read the status of the bus lines.
+ * usb_gpib_line_status() - Read the status of the bus lines.
*
* @board: the gpib_board data area for this gpib interface
*
* We can read all lines.
*/
-
-#define WQT wait_queue_entry_t
-#define WQH head
-#define WQE entry
-
-static int usb_gpib_line_status(const gpib_board_t *board)
+static int usb_gpib_line_status(const struct gpib_board *board)
{
int buffer;
- int line_status = ValidALL; /* all lines will be read */
+ int line_status = VALID_ALL; /* all lines will be read */
struct list_head *p, *q;
WQT *item;
unsigned long flags;
@@ -730,30 +674,29 @@ static int usb_gpib_line_status(const gpib_board_t *board)
msleep(sleep);
}
- buffer = send_command((gpib_board_t *)board, USB_GPIB_STATUS, 0);
+ buffer = send_command((struct gpib_board *)board, USB_GPIB_STATUS, 0);
if (buffer < 0) {
- dev_alert(board->gpib_dev, "%s:%s - line status read failed with %d\n",
- NAME, __func__, buffer);
+ dev_err(board->gpib_dev, "line status read failed with %d\n", buffer);
return -1;
}
if ((buffer & 0x01) == 0)
- line_status |= BusREN;
+ line_status |= BUS_REN;
if ((buffer & 0x02) == 0)
- line_status |= BusIFC;
+ line_status |= BUS_IFC;
if ((buffer & 0x04) == 0)
- line_status |= BusNDAC;
+ line_status |= BUS_NDAC;
if ((buffer & 0x08) == 0)
- line_status |= BusNRFD;
+ line_status |= BUS_NRFD;
if ((buffer & 0x10) == 0)
- line_status |= BusDAV;
+ line_status |= BUS_DAV;
if ((buffer & 0x20) == 0)
- line_status |= BusEOI;
+ line_status |= BUS_EOI;
if ((buffer & 0x40) == 0)
- line_status |= BusATN;
+ line_status |= BUS_ATN;
if ((buffer & 0x80) == 0)
- line_status |= BusSRQ;
+ line_status |= BUS_SRQ;
DIA_LOG(1, "done with %x %x\n", buffer, line_status);
@@ -762,7 +705,7 @@ static int usb_gpib_line_status(const gpib_board_t *board)
/* parallel_poll */
-static int usb_gpib_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int usb_gpib_parallel_poll(struct gpib_board *board, uint8_t *result)
{
/* request parallel poll asserting ATN | EOI;
* we suppose ATN already asserted
@@ -773,27 +716,23 @@ static int usb_gpib_parallel_poll(gpib_board_t *board, uint8_t *result)
DIA_LOG(1, "enter %p\n", board);
retval = set_control_line(board, IB_BUS_EOI, 1);
- if (retval != ACK) {
- dev_alert(board->gpib_dev, "%s:%s - assert EOI failed\n", NAME, __func__);
+ if (retval != ACK)
return -EIO;
- }
*result = send_command(board, USB_GPIB_READ_DATA, 0);
DIA_LOG(1, "done with %x\n", *result);
retval = set_control_line(board, IB_BUS_EOI, 0);
- if (retval != 0x06) {
- dev_alert(board->gpib_dev, "%s:%s - unassert EOI failed\n", NAME, __func__);
+ if (retval != 0x06)
return -EIO;
- }
return 0;
}
/* read */
-static int usb_gpib_read(gpib_board_t *board,
+static int usb_gpib_read(struct gpib_board *board,
u8 *buffer,
size_t length,
int *end,
@@ -866,8 +805,7 @@ static int usb_gpib_read(gpib_board_t *board,
goto read_return;
if (one_char(board, &b) != DLE || one_char(board, &b) != STX) {
- dev_alert(board->gpib_dev, "%s:%s - wrong <DLE><STX> sequence\n",
- NAME, __func__);
+ dev_err(board->gpib_dev, "wrong <DLE><STX> sequence\n");
retval = -EIO;
goto read_return;
}
@@ -907,15 +845,12 @@ static int usb_gpib_read(gpib_board_t *board,
retval = 0;
goto read_return;
} else {
- dev_alert(board->gpib_dev, "%s:%s - %s %x\n",
- NAME, __func__,
- "Wrong end of message", c);
+ dev_err(board->gpib_dev, "wrong end of message %x", c);
retval = -ETIME;
goto read_return;
}
} else {
- dev_alert(board->gpib_dev, "%s:%s - %s\n", NAME, __func__,
- "lone <DLE> in stream");
+ dev_err(board->gpib_dev, "lone <DLE> in stream");
retval = -EIO;
goto read_return;
}
@@ -934,8 +869,7 @@ static int usb_gpib_read(gpib_board_t *board,
c = one_char(board, &b);
if (c == ACK) {
if (MAX_READ_EXCESS - read_count > 1)
- dev_alert(board->gpib_dev, "%s:%s - %s\n", NAME, __func__,
- "small buffer - maybe some data lost");
+ dev_dbg(board->gpib_dev, "small buffer - maybe some data lost");
retval = 0;
goto read_return;
}
@@ -943,15 +877,13 @@ static int usb_gpib_read(gpib_board_t *board,
}
}
- dev_alert(board->gpib_dev, "%s:%s - no input end - GPIB board in odd state\n",
- NAME, __func__);
+ dev_err(board->gpib_dev, "no input end - board in odd state\n");
retval = -EIO;
read_return:
kfree(b.inbuf);
- DIA_LOG(1, "done with byte/status: %d %x %d\n",
- (int)*bytes_read, retval, *end);
+ DIA_LOG(1, "done with byte/status: %d %x %d\n", (int)*bytes_read, retval, *end);
if (retval == 0 || retval == -ETIME) {
if (send_command(board, USB_GPIB_UNTALK, sizeof(USB_GPIB_UNTALK)) == 0x06)
@@ -964,21 +896,20 @@ read_return:
/* remote_enable */
-static void usb_gpib_remote_enable(gpib_board_t *board, int enable)
+static void usb_gpib_remote_enable(struct gpib_board *board, int enable)
{
int retval;
retval = set_control_line(board, IB_BUS_REN, enable ? 1 : 0);
if (retval != ACK)
- dev_alert(board->gpib_dev, "%s:%s - could not set REN line: %x\n",
- NAME, __func__, retval);
+ dev_err(board->gpib_dev, "could not set REN line: %x\n", retval);
DIA_LOG(1, "done with %x\n", retval);
}
/* request_system_control */
-static void usb_gpib_request_system_control(gpib_board_t *board,
+static void usb_gpib_request_system_control(struct gpib_board *board,
int request_control)
{
if (request_control)
@@ -992,7 +923,7 @@ static void usb_gpib_request_system_control(gpib_board_t *board,
/* take_control */
/* beware: the sync flag is ignored; what is its real meaning? */
-static int usb_gpib_take_control(gpib_board_t *board, int sync)
+static int usb_gpib_take_control(struct gpib_board *board, int sync)
{
int retval;
@@ -1007,7 +938,7 @@ static int usb_gpib_take_control(gpib_board_t *board, int sync)
/* update_status */
-static unsigned int usb_gpib_update_status(gpib_board_t *board,
+static unsigned int usb_gpib_update_status(struct gpib_board *board,
unsigned int clear_mask)
{
/* There is nothing we can do here, I guess */
@@ -1022,7 +953,7 @@ static unsigned int usb_gpib_update_status(gpib_board_t *board,
/* write */
/* beware: DLE characters are not escaped - can only send ASCII data */
-static int usb_gpib_write(gpib_board_t *board,
+static int usb_gpib_write(struct gpib_board *board,
u8 *buffer,
size_t length,
int send_eoi,
@@ -1053,9 +984,8 @@ static int usb_gpib_write(gpib_board_t *board,
*bytes_written = length;
- if (send_command(board, USB_GPIB_UNLISTEN, sizeof(USB_GPIB_UNLISTEN))
- != 0x06)
- return -EPIPE;
+ if (send_command(board, USB_GPIB_UNLISTEN, sizeof(USB_GPIB_UNLISTEN)) != 0x06)
+ return -EPIPE;
return length;
}
@@ -1066,64 +996,56 @@ static int usb_gpib_write(gpib_board_t *board,
/* parallel_poll configure */
-static void usb_gpib_parallel_poll_configure(gpib_board_t *board,
+static void usb_gpib_parallel_poll_configure(struct gpib_board *board,
uint8_t configuration)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
}
/* parallel_poll_response */
-static void usb_gpib_parallel_poll_response(gpib_board_t *board, int ist)
+static void usb_gpib_parallel_poll_response(struct gpib_board *board, int ist)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
}
/* primary_address */
-static int usb_gpib_primary_address(gpib_board_t *board, unsigned int address)
+static int usb_gpib_primary_address(struct gpib_board *board, unsigned int address)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
return 0;
}
/* return_to_local */
-static void usb_gpib_return_to_local(gpib_board_t *board)
+static void usb_gpib_return_to_local(struct gpib_board *board)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
}
/* secondary_address */
-static int usb_gpib_secondary_address(gpib_board_t *board,
+static int usb_gpib_secondary_address(struct gpib_board *board,
unsigned int address,
int enable)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
return 0;
}
/* serial_poll_response */
-static void usb_gpib_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void usb_gpib_serial_poll_response(struct gpib_board *board, uint8_t status)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
}
/* serial_poll_status */
-static uint8_t usb_gpib_serial_poll_status(gpib_board_t *board)
+static uint8_t usb_gpib_serial_poll_status(struct gpib_board *board)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
return 0;
}
/* t1_delay */
-static unsigned int usb_gpib_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int usb_gpib_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
- dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__);
return 0;
}
@@ -1181,7 +1103,7 @@ static int usb_gpib_init_module(struct usb_interface *interface)
if (!assigned_usb_minors) {
rv = gpib_register_driver(&usb_gpib_interface, THIS_MODULE);
if (rv) {
- pr_err("lpvo_usb_gpib: gpib_register_driver failed: error = %d\n", rv);
+ pr_err("gpib_register_driver failed: error = %d\n", rv);
goto exit;
}
} else {
@@ -1191,8 +1113,8 @@ static int usb_gpib_init_module(struct usb_interface *interface)
for (j = 0 ; j < MAX_DEV ; j++) {
if (usb_minors[j] == interface->minor && assigned_usb_minors & 1 << j) {
- pr_alert("%s:%s - CODE BUG: USB minor %d registered at %d.\n",
- NAME, __func__, interface->minor, j);
+ pr_err("CODE BUG: USB minor %d registered at %d.\n",
+ interface->minor, j);
rv = -1;
goto exit;
}
@@ -1207,13 +1129,11 @@ static int usb_gpib_init_module(struct usb_interface *interface)
usb_minors[j] = interface->minor;
lpvo_usb_interfaces[j] = interface;
assigned_usb_minors |= mask;
- DIA_LOG(0, "usb minor %d registered at %d\n", interface->minor, j);
rv = 0;
goto exit;
}
}
- pr_alert("%s:%s - No slot available for interface %p minor %d\n",
- NAME, __func__, interface, interface->minor);
+ pr_err("No slot available for interface %p minor %d\n", interface, interface->minor);
rv = -1;
exit:
@@ -1235,7 +1155,7 @@ static void usb_gpib_exit_module(int minor)
goto exit;
}
}
- pr_alert("%s:%s - CODE BUG: USB minor %d not found.\n", NAME, __func__, minor);
+ pr_err("CODE BUG: USB minor %d not found.\n", minor);
exit:
mutex_unlock(&minors_lock);
@@ -1267,7 +1187,7 @@ static int write_latency_timer(struct usb_device *udev)
LATENCY_TIMER, LATENCY_CHANNEL,
NULL, 0, WDR_TIMEOUT);
if (rv < 0)
- pr_alert("Unable to write latency timer: %i\n", rv);
+ dev_err(&udev->dev, "Unable to write latency timer: %i\n", rv);
return rv;
}
@@ -1363,18 +1283,15 @@ static void skel_delete(struct kref *kref)
* skel_do_open() - to be called by usb_gpib_attach
*/
-static int skel_do_open(gpib_board_t *board, int subminor)
+static int skel_do_open(struct gpib_board *board, int subminor)
{
struct usb_skel *dev;
struct usb_interface *interface;
int retval = 0;
- DIA_LOG(0, "Required minor: %d\n", subminor);
-
interface = usb_find_interface(&skel_driver, subminor);
if (!interface) {
- pr_err("%s - error, can't find device for minor %d\n",
- __func__, subminor);
+ dev_err(board->gpib_dev, "can't find device for minor %d\n", subminor);
retval = -ENODEV;
goto exit;
}
@@ -1403,7 +1320,7 @@ exit:
* skel_do_release() - to be called by usb_gpib_detach
*/
-static int skel_do_release(gpib_board_t *board)
+static int skel_do_release(struct gpib_board *board)
{
struct usb_skel *dev;
@@ -1439,9 +1356,8 @@ static void skel_read_bulk_callback(struct urb *urb)
if (!(urb->status == -ENOENT ||
urb->status == -ECONNRESET ||
urb->status == -ESHUTDOWN))
- dev_err(&dev->interface->dev,
- "%s - nonzero read bulk status received: %d\n",
- __func__, urb->status);
+ dev_err(&dev->interface->dev, "nonzero read bulk status received: %d\n",
+ urb->status);
dev->errors = urb->status;
} else {
@@ -1478,9 +1394,7 @@ static int skel_do_read_io(struct usb_skel *dev, size_t count)
/* do it */
rv = usb_submit_urb(dev->bulk_in_urb, GFP_KERNEL);
if (rv < 0) {
- dev_err(&dev->interface->dev,
- "%s - failed submitting read urb, error %d\n",
- __func__, rv);
+ dev_err(&dev->interface->dev, "failed submitting read urb, error %d\n", rv);
rv = (rv == -ENOMEM) ? rv : -EIO;
spin_lock_irq(&dev->err_lock);
dev->ongoing_read = 0;
@@ -1504,14 +1418,10 @@ static ssize_t skel_do_read(struct usb_skel *dev, char *buffer, size_t count)
if (!dev->bulk_in_urb || !count)
return 0;
- DIA_LOG(1, "enter for %zu.\n", count);
-
restart: /* added to comply with ftdi timeout technique */
/* no concurrent readers */
- DIA_LOG(2, "restart with %zd %zd.\n", dev->bulk_in_filled, dev->bulk_in_copied);
-
rv = mutex_lock_interruptible(&dev->io_mutex);
if (rv < 0)
return rv;
@@ -1527,8 +1437,6 @@ retry:
ongoing_io = dev->ongoing_read;
spin_unlock_irq(&dev->err_lock);
- DIA_LOG(2, "retry with %d.\n", ongoing_io);
-
if (ongoing_io) {
// /* nonblocking IO shall not wait */
// /* no file, no O_NONBLOCK; maybe provide when from user space */
@@ -1569,8 +1477,6 @@ retry:
// size_t chunk = min(available, count); /* compute chunk later */
size_t chunk;
- DIA_LOG(2, "we have data: %zu %zu.\n", dev->bulk_in_filled, dev->bulk_in_copied);
-
if (!available) {
/*
* all data has been used
@@ -1596,12 +1502,6 @@ retry:
*/
if (dev->bulk_in_copied) {
- int j;
-
- for (j = 0 ; j < dev->bulk_in_filled ; j++) {
- pr_alert("copy -> %x %zu %x\n",
- j, dev->bulk_in_copied, dev->bulk_in_buffer[j]);
- }
chunk = min(available, count);
memcpy(buffer, dev->bulk_in_buffer + dev->bulk_in_copied, chunk);
rv = chunk;
@@ -1613,7 +1513,7 @@ retry:
/* account for two bytes to be discarded */
chunk = min(available, count + 2);
if (chunk < 2) {
- pr_alert("BAD READ - chunk: %zu\n", chunk);
+ dev_err(&dev->udev->dev, "BAD READ - chunk: %zu\n", chunk);
rv = -EIO;
goto exit;
}
@@ -1633,8 +1533,6 @@ retry:
// if (available < count)
// skel_do_read_io(dev, dev->bulk_in_size);
} else {
- DIA_LOG(1, "no data - start read - copied: %zd.\n", dev->bulk_in_copied);
-
/* no data in the buffer */
rv = skel_do_read_io(dev, dev->bulk_in_size);
if (rv < 0)
@@ -1645,10 +1543,10 @@ retry:
exit:
mutex_unlock(&dev->io_mutex);
if (rv == 2)
- goto restart; /* ftdi chip returns two status bytes after a latency anyhow */
- DIA_LOG(1, "exit with %d.\n", rv);
+ goto restart; /* ftdi chip returns two status bytes after a latency anyhow */
+
if (rv > 0)
- return rv - 2; /* account for 2 discarded bytes in a valid buffer */
+ return rv - 2; /* account for 2 discarded bytes in a valid buffer */
return rv;
}
@@ -1669,8 +1567,7 @@ static void skel_write_bulk_callback(struct urb *urb)
urb->status == -ECONNRESET ||
urb->status == -ESHUTDOWN))
dev_err(&dev->interface->dev,
- "%s - nonzero write bulk status received: %d\n",
- __func__, urb->status);
+ "nonzero write bulk status received: %d\n", urb->status);
spin_lock_irqsave(&dev->err_lock, flags);
dev->errors = urb->status;
@@ -1763,9 +1660,7 @@ static ssize_t skel_do_write(struct usb_skel *dev, const char *buffer, size_t co
retval = usb_submit_urb(urb, GFP_KERNEL);
mutex_unlock(&dev->io_mutex);
if (retval) {
- dev_err(&dev->interface->dev,
- "%s - failed submitting write urb, error %d\n",
- __func__, retval);
+ dev_err(&dev->interface->dev, "failed submitting write urb, error %d\n", retval);
goto error_unanchor;
}
@@ -1831,8 +1726,7 @@ static int skel_open(struct inode *inode, struct file *file)
interface = usb_find_interface(&skel_driver, subminor);
if (!interface) {
- pr_err("%s - error, can't find device for minor %d\n",
- __func__, subminor);
+ pr_err("can't find device for minor %d\n", subminor);
retval = -ENODEV;
goto exit;
}
@@ -1895,8 +1789,6 @@ static ssize_t skel_read(struct file *file, char __user *buffer, size_t count,
rv = skel_do_read(dev, buf, count);
- pr_alert("%s - return with %zu\n", __func__, rv);
-
if (rv > 0) {
if (copy_to_user(buffer, buf, rv)) {
kfree(buf);
@@ -2015,8 +1907,8 @@ static int skel_probe(struct usb_interface *interface,
/* let the world know */
device_path = kobject_get_path(&dev->udev->dev.kobj, GFP_KERNEL);
- pr_alert("%s:%s - New lpvo_usb_device -> bus: %d dev: %d path: %s\n", NAME, __func__,
- dev->udev->bus->busnum, dev->udev->devnum, device_path);
+ dev_dbg(&interface->dev, "New lpvo_usb_device -> bus: %d dev: %d path: %s\n",
+ dev->udev->bus->busnum, dev->udev->devnum, device_path);
kfree(device_path);
#if USER_DEVICE
@@ -2029,14 +1921,9 @@ static int skel_probe(struct usb_interface *interface,
usb_set_intfdata(interface, NULL);
goto error;
}
-
- /* let the user know what node this device is now attached to */
- dev_info(&interface->dev,
- "lpvo_usb_gpib device now attached to lpvo_raw%d",
- interface->minor);
#endif
- write_latency_timer(dev->udev); /* adjust the latency timer */
+ write_latency_timer(dev->udev); /* adjust the latency timer */
usb_gpib_init_module(interface); /* last, init the lpvo for this minor */
@@ -2073,8 +1960,6 @@ static void skel_disconnect(struct usb_interface *interface)
/* decrement our usage count */
kref_put(&dev->kref, skel_delete);
-
- dev_info(&interface->dev, "USB lpvo_raw #%d now disconnected", minor);
}
static void skel_draw_down(struct usb_skel *dev)
diff --git a/drivers/staging/gpib/nec7210/nec7210.c b/drivers/staging/gpib/nec7210/nec7210.c
index c9a837fad96e..846c0a3fa1dc 100644
--- a/drivers/staging/gpib/nec7210/nec7210.c
+++ b/drivers/staging/gpib/nec7210/nec7210.c
@@ -4,6 +4,8 @@
* copyright : (C) 2001, 2002 by Frank Mori Hess
***************************************************************************/
+#define dev_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include "board.h"
#include <linux/ioport.h>
#include <linux/sched.h>
@@ -21,7 +23,7 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB library code for NEC uPD7210");
-int nec7210_enable_eos(gpib_board_t *board, struct nec7210_priv *priv, uint8_t eos_byte,
+int nec7210_enable_eos(struct gpib_board *board, struct nec7210_priv *priv, uint8_t eos_byte,
int compare_8_bits)
{
write_byte(priv, eos_byte, EOSR);
@@ -35,14 +37,14 @@ int nec7210_enable_eos(gpib_board_t *board, struct nec7210_priv *priv, uint8_t e
}
EXPORT_SYMBOL(nec7210_enable_eos);
-void nec7210_disable_eos(gpib_board_t *board, struct nec7210_priv *priv)
+void nec7210_disable_eos(struct gpib_board *board, struct nec7210_priv *priv)
{
priv->auxa_bits &= ~HR_REOS;
write_byte(priv, priv->auxa_bits, AUXMR);
}
EXPORT_SYMBOL(nec7210_disable_eos);
-int nec7210_parallel_poll(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *result)
+int nec7210_parallel_poll(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *result)
{
int ret;
@@ -62,14 +64,14 @@ int nec7210_parallel_poll(gpib_board_t *board, struct nec7210_priv *priv, uint8_
}
EXPORT_SYMBOL(nec7210_parallel_poll);
-void nec7210_parallel_poll_configure(gpib_board_t *board,
+void nec7210_parallel_poll_configure(struct gpib_board *board,
struct nec7210_priv *priv, unsigned int configuration)
{
write_byte(priv, PPR | configuration, AUXMR);
}
EXPORT_SYMBOL(nec7210_parallel_poll_configure);
-void nec7210_parallel_poll_response(gpib_board_t *board, struct nec7210_priv *priv, int ist)
+void nec7210_parallel_poll_response(struct gpib_board *board, struct nec7210_priv *priv, int ist)
{
if (ist)
write_byte(priv, AUX_SPPF, AUXMR);
@@ -83,7 +85,8 @@ EXPORT_SYMBOL(nec7210_parallel_poll_response);
* the 488.2 capability (for example with NI chips), or we need to implement the
* 488.2 set srv state machine in the driver (if that is even viable).
*/
-void nec7210_serial_poll_response(gpib_board_t *board, struct nec7210_priv *priv, uint8_t status)
+void nec7210_serial_poll_response(struct gpib_board *board,
+ struct nec7210_priv *priv, uint8_t status)
{
unsigned long flags;
@@ -100,13 +103,13 @@ void nec7210_serial_poll_response(gpib_board_t *board, struct nec7210_priv *priv
}
EXPORT_SYMBOL(nec7210_serial_poll_response);
-uint8_t nec7210_serial_poll_status(gpib_board_t *board, struct nec7210_priv *priv)
+uint8_t nec7210_serial_poll_status(struct gpib_board *board, struct nec7210_priv *priv)
{
return read_byte(priv, SPSR);
}
EXPORT_SYMBOL(nec7210_serial_poll_status);
-int nec7210_primary_address(const gpib_board_t *board, struct nec7210_priv *priv,
+int nec7210_primary_address(const struct gpib_board *board, struct nec7210_priv *priv,
unsigned int address)
{
// put primary address in address0
@@ -115,7 +118,7 @@ int nec7210_primary_address(const gpib_board_t *board, struct nec7210_priv *priv
}
EXPORT_SYMBOL(nec7210_primary_address);
-int nec7210_secondary_address(const gpib_board_t *board, struct nec7210_priv *priv,
+int nec7210_secondary_address(const struct gpib_board *board, struct nec7210_priv *priv,
unsigned int address, int enable)
{
if (enable) {
@@ -164,7 +167,7 @@ static void update_listener_state(struct nec7210_priv *priv, unsigned int addres
}
}
-unsigned int nec7210_update_status_nolock(gpib_board_t *board, struct nec7210_priv *priv)
+unsigned int nec7210_update_status_nolock(struct gpib_board *board, struct nec7210_priv *priv)
{
int address_status_bits;
u8 spoll_status;
@@ -198,7 +201,6 @@ unsigned int nec7210_update_status_nolock(gpib_board_t *board, struct nec7210_pr
priv->srq_pending = 0;
set_bit(SPOLL_NUM, &board->status);
}
-// dev_dbg(board->gpib_dev, "status 0x%x, state 0x%x\n", board->status, priv->state);
/* we rely on the interrupt handler to set the
* rest of the status bits
@@ -208,7 +210,7 @@ unsigned int nec7210_update_status_nolock(gpib_board_t *board, struct nec7210_pr
}
EXPORT_SYMBOL(nec7210_update_status_nolock);
-unsigned int nec7210_update_status(gpib_board_t *board, struct nec7210_priv *priv,
+unsigned int nec7210_update_status(struct gpib_board *board, struct nec7210_priv *priv,
unsigned int clear_mask)
{
unsigned long flags;
@@ -233,7 +235,7 @@ unsigned int nec7210_set_reg_bits(struct nec7210_priv *priv, unsigned int reg,
}
EXPORT_SYMBOL(nec7210_set_reg_bits);
-void nec7210_set_handshake_mode(gpib_board_t *board, struct nec7210_priv *priv, int mode)
+void nec7210_set_handshake_mode(struct gpib_board *board, struct nec7210_priv *priv, int mode)
{
unsigned long flags;
@@ -249,7 +251,7 @@ void nec7210_set_handshake_mode(gpib_board_t *board, struct nec7210_priv *priv,
}
EXPORT_SYMBOL(nec7210_set_handshake_mode);
-uint8_t nec7210_read_data_in(gpib_board_t *board, struct nec7210_priv *priv, int *end)
+uint8_t nec7210_read_data_in(struct gpib_board *board, struct nec7210_priv *priv, int *end)
{
unsigned long flags;
u8 data;
@@ -267,7 +269,7 @@ uint8_t nec7210_read_data_in(gpib_board_t *board, struct nec7210_priv *priv, int
}
EXPORT_SYMBOL(nec7210_read_data_in);
-int nec7210_take_control(gpib_board_t *board, struct nec7210_priv *priv, int syncronous)
+int nec7210_take_control(struct gpib_board *board, struct nec7210_priv *priv, int syncronous)
{
int i;
const int timeout = 100;
@@ -294,7 +296,7 @@ int nec7210_take_control(gpib_board_t *board, struct nec7210_priv *priv, int syn
}
EXPORT_SYMBOL(nec7210_take_control);
-int nec7210_go_to_standby(gpib_board_t *board, struct nec7210_priv *priv)
+int nec7210_go_to_standby(struct gpib_board *board, struct nec7210_priv *priv)
{
int i;
const int timeout = 1000;
@@ -319,10 +321,8 @@ int nec7210_go_to_standby(gpib_board_t *board, struct nec7210_priv *priv)
if (adsr_bits & HR_NATN)
break;
}
- if (i == HZ) {
- pr_err("nec7210: error waiting for NATN\n");
+ if (i == HZ)
return -ETIMEDOUT;
- }
}
clear_bit(COMMAND_READY_BN, &priv->state);
@@ -330,7 +330,7 @@ int nec7210_go_to_standby(gpib_board_t *board, struct nec7210_priv *priv)
}
EXPORT_SYMBOL(nec7210_go_to_standby);
-void nec7210_request_system_control(gpib_board_t *board, struct nec7210_priv *priv,
+void nec7210_request_system_control(struct gpib_board *board, struct nec7210_priv *priv,
int request_control)
{
if (request_control == 0) {
@@ -341,7 +341,7 @@ void nec7210_request_system_control(gpib_board_t *board, struct nec7210_priv *pr
}
EXPORT_SYMBOL(nec7210_request_system_control);
-void nec7210_interface_clear(gpib_board_t *board, struct nec7210_priv *priv, int assert)
+void nec7210_interface_clear(struct gpib_board *board, struct nec7210_priv *priv, int assert)
{
if (assert)
write_byte(priv, AUX_SIFC, AUXMR);
@@ -350,7 +350,7 @@ void nec7210_interface_clear(gpib_board_t *board, struct nec7210_priv *priv, int
}
EXPORT_SYMBOL(nec7210_interface_clear);
-void nec7210_remote_enable(gpib_board_t *board, struct nec7210_priv *priv, int enable)
+void nec7210_remote_enable(struct gpib_board *board, struct nec7210_priv *priv, int enable)
{
if (enable)
write_byte(priv, AUX_SREN, AUXMR);
@@ -359,7 +359,7 @@ void nec7210_remote_enable(gpib_board_t *board, struct nec7210_priv *priv, int e
}
EXPORT_SYMBOL(nec7210_remote_enable);
-void nec7210_release_rfd_holdoff(gpib_board_t *board, struct nec7210_priv *priv)
+void nec7210_release_rfd_holdoff(struct gpib_board *board, struct nec7210_priv *priv)
{
unsigned long flags;
@@ -373,8 +373,8 @@ void nec7210_release_rfd_holdoff(gpib_board_t *board, struct nec7210_priv *priv)
}
EXPORT_SYMBOL(nec7210_release_rfd_holdoff);
-unsigned int nec7210_t1_delay(gpib_board_t *board, struct nec7210_priv *priv,
- unsigned int nano_sec)
+int nec7210_t1_delay(struct gpib_board *board, struct nec7210_priv *priv,
+ unsigned int nano_sec)
{
unsigned int retval;
@@ -391,13 +391,13 @@ unsigned int nec7210_t1_delay(gpib_board_t *board, struct nec7210_priv *priv,
}
EXPORT_SYMBOL(nec7210_t1_delay);
-void nec7210_return_to_local(const gpib_board_t *board, struct nec7210_priv *priv)
+void nec7210_return_to_local(const struct gpib_board *board, struct nec7210_priv *priv)
{
write_byte(priv, AUX_RTL, AUXMR);
}
EXPORT_SYMBOL(nec7210_return_to_local);
-static inline short nec7210_atn_has_changed(gpib_board_t *board, struct nec7210_priv *priv)
+static inline short nec7210_atn_has_changed(struct gpib_board *board, struct nec7210_priv *priv)
{
short address_status_bits = read_byte(priv, ADSR);
@@ -415,7 +415,7 @@ static inline short nec7210_atn_has_changed(gpib_board_t *board, struct nec7210_
return -1;
}
-int nec7210_command(gpib_board_t *board, struct nec7210_priv *priv, uint8_t
+int nec7210_command(struct gpib_board *board, struct nec7210_priv *priv, uint8_t
*buffer, size_t length, size_t *bytes_written)
{
int retval = 0;
@@ -430,17 +430,14 @@ int nec7210_command(gpib_board_t *board, struct nec7210_priv *priv, uint8_t
test_bit(COMMAND_READY_BN, &priv->state) ||
test_bit(BUS_ERROR_BN, &priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib command wait interrupted\n");
+ dev_dbg(board->gpib_dev, "command wait interrupted\n");
retval = -ERESTARTSYS;
break;
}
if (test_bit(TIMO_NUM, &board->status))
break;
- if (test_and_clear_bit(BUS_ERROR_BN, &priv->state)) {
- pr_err("nec7210: bus error on command byte\n");
+ if (test_and_clear_bit(BUS_ERROR_BN, &priv->state))
break;
- }
-
spin_lock_irqsave(&board->spinlock, flags);
clear_bit(COMMAND_READY_BN, &priv->state);
write_byte(priv, buffer[*bytes_written], CDOR);
@@ -454,24 +451,20 @@ int nec7210_command(gpib_board_t *board, struct nec7210_priv *priv, uint8_t
// wait for last byte to get sent
if (wait_event_interruptible(board->wait, test_bit(COMMAND_READY_BN, &priv->state) ||
test_bit(BUS_ERROR_BN, &priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib command wait interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
retval = -ERESTARTSYS;
- }
- if (test_bit(TIMO_NUM, &board->status)) {
- dev_dbg(board->gpib_dev, "gpib command timed out\n");
+
+ if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
- }
- if (test_and_clear_bit(BUS_ERROR_BN, &priv->state)) {
- pr_err("nec7210: bus error on command byte\n");
+
+ if (test_and_clear_bit(BUS_ERROR_BN, &priv->state))
retval = -EIO;
- }
return retval;
}
EXPORT_SYMBOL(nec7210_command);
-static int pio_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+static int pio_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
ssize_t retval = 0;
@@ -484,7 +477,6 @@ static int pio_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buf
test_bit(READ_READY_BN, &priv->state) ||
test_bit(DEV_CLEAR_BN, &priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "nec7210: pio read wait interrupted\n");
retval = -ERESTARTSYS;
break;
}
@@ -503,12 +495,10 @@ static int pio_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buf
break;
}
if (test_bit(TIMO_NUM, &board->status)) {
- dev_dbg(board->gpib_dev, "interrupted by timeout\n");
retval = -ETIMEDOUT;
break;
}
if (test_bit(DEV_CLEAR_BN, &priv->state)) {
- dev_dbg(board->gpib_dev, "interrupted by device clear\n");
retval = -EINTR;
break;
}
@@ -523,7 +513,7 @@ static int pio_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buf
}
#ifdef NEC_DMA
-static ssize_t __dma_read(gpib_board_t *board, struct nec7210_priv *priv, size_t length)
+static ssize_t __dma_read(struct gpib_board *board, struct nec7210_priv *priv, size_t length)
{
ssize_t retval = 0;
size_t count = 0;
@@ -557,10 +547,9 @@ static ssize_t __dma_read(gpib_board_t *board, struct nec7210_priv *priv, size_t
if (wait_event_interruptible(board->wait,
test_bit(DMA_READ_IN_PROGRESS_BN, &priv->state) == 0 ||
test_bit(DEV_CLEAR_BN, &priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "nec7210: dma read wait interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
retval = -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
if (test_bit(DEV_CLEAR_BN, &priv->state))
@@ -579,7 +568,7 @@ static ssize_t __dma_read(gpib_board_t *board, struct nec7210_priv *priv, size_t
return retval ? retval : count;
}
-static ssize_t dma_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+static ssize_t dma_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length)
{
size_t remain = length;
@@ -606,7 +595,7 @@ static ssize_t dma_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t
}
#endif
-int nec7210_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+int nec7210_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
ssize_t retval = 0;
@@ -627,7 +616,7 @@ int nec7210_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer
}
EXPORT_SYMBOL(nec7210_read);
-static int pio_write_wait(gpib_board_t *board, struct nec7210_priv *priv,
+static int pio_write_wait(struct gpib_board *board, struct nec7210_priv *priv,
short wake_on_lacs, short wake_on_atn, short wake_on_bus_error)
{
// wait until byte is ready to be sent
@@ -638,26 +627,22 @@ static int pio_write_wait(gpib_board_t *board, struct nec7210_priv *priv,
(wake_on_bus_error && test_bit(BUS_ERROR_BN, &priv->state)) ||
(wake_on_lacs && test_bit(LACS_NUM, &board->status)) ||
(wake_on_atn && test_bit(ATN_NUM, &board->status)) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
return -ERESTARTSYS;
- }
- if (test_bit(TIMO_NUM, &board->status)) {
- dev_dbg(board->gpib_dev, "nec7210: write timed out\n");
+
+ if (test_bit(TIMO_NUM, &board->status))
return -ETIMEDOUT;
- }
- if (test_bit(DEV_CLEAR_BN, &priv->state)) {
- dev_dbg(board->gpib_dev, "nec7210: write interrupted by clear\n");
+
+ if (test_bit(DEV_CLEAR_BN, &priv->state))
return -EINTR;
- }
- if (wake_on_bus_error && test_and_clear_bit(BUS_ERROR_BN, &priv->state)) {
- dev_dbg(board->gpib_dev, "nec7210: bus error on write\n");
+
+ if (wake_on_bus_error && test_and_clear_bit(BUS_ERROR_BN, &priv->state))
return -EIO;
- }
+
return 0;
}
-static int pio_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+static int pio_write(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length, size_t *bytes_written)
{
size_t last_count = 0;
@@ -677,7 +662,6 @@ static int pio_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *bu
if (retval == -EIO) {
/* resend last byte on bus error */
*bytes_written = last_count;
- dev_dbg(board->gpib_dev, "resending %c\n", buffer[*bytes_written]);
/* we can get unrecoverable bus errors,
* so give up after a while
*/
@@ -701,7 +685,7 @@ static int pio_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *bu
}
#ifdef NEC_DMA
-static ssize_t __dma_write(gpib_board_t *board, struct nec7210_priv *priv, dma_addr_t address,
+static ssize_t __dma_write(struct gpib_board *board, struct nec7210_priv *priv, dma_addr_t address,
size_t length)
{
unsigned long flags, dma_irq_flags;
@@ -733,10 +717,9 @@ static ssize_t __dma_write(gpib_board_t *board, struct nec7210_priv *priv, dma_a
test_bit(DMA_WRITE_IN_PROGRESS_BN, &priv->state) == 0 ||
test_bit(BUS_ERROR_BN, &priv->state) ||
test_bit(DEV_CLEAR_BN, &priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted!\n");
+ test_bit(TIMO_NUM, &board->status)))
retval = -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
retval = -ETIMEDOUT;
if (test_and_clear_bit(DEV_CLEAR_BN, &priv->state))
@@ -759,7 +742,7 @@ static ssize_t __dma_write(gpib_board_t *board, struct nec7210_priv *priv, dma_a
return retval ? retval : length;
}
-static ssize_t dma_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer,
+static ssize_t dma_write(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer,
size_t length)
{
size_t remain = length;
@@ -783,8 +766,9 @@ static ssize_t dma_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t
return length - remain;
}
#endif
-int nec7210_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written)
+int nec7210_write(struct gpib_board *board, struct nec7210_priv *priv,
+ uint8_t *buffer, size_t length, int send_eoi,
+ size_t *bytes_written)
{
int retval = 0;
@@ -845,7 +829,7 @@ EXPORT_SYMBOL(nec7210_write);
/*
* interrupt service routine
*/
-irqreturn_t nec7210_interrupt(gpib_board_t *board, struct nec7210_priv *priv)
+irqreturn_t nec7210_interrupt(struct gpib_board *board, struct nec7210_priv *priv)
{
int status1, status2;
@@ -857,7 +841,7 @@ irqreturn_t nec7210_interrupt(gpib_board_t *board, struct nec7210_priv *priv)
}
EXPORT_SYMBOL(nec7210_interrupt);
-irqreturn_t nec7210_interrupt_have_status(gpib_board_t *board,
+irqreturn_t nec7210_interrupt_have_status(struct gpib_board *board,
struct nec7210_priv *priv, int status1, int status2)
{
#ifdef NEC_DMA
@@ -937,13 +921,8 @@ irqreturn_t nec7210_interrupt_have_status(gpib_board_t *board,
set_bit(COMMAND_READY_BN, &priv->state);
// command pass through received
- if (status1 & HR_CPT) {
- unsigned int command;
-
- command = read_byte(priv, CPTR) & gpib_command_mask;
+ if (status1 & HR_CPT)
write_byte(priv, AUX_NVAL, AUXMR);
-// printk("gpib: command pass through 0x%x\n", command);
- }
if (status1 & HR_ERR)
set_bit(BUS_ERROR_BN, &priv->state);
@@ -980,7 +959,7 @@ irqreturn_t nec7210_interrupt_have_status(gpib_board_t *board,
}
EXPORT_SYMBOL(nec7210_interrupt_have_status);
-void nec7210_board_reset(struct nec7210_priv *priv, const gpib_board_t *board)
+void nec7210_board_reset(struct nec7210_priv *priv, const struct gpib_board *board)
{
/* 7210 chip reset */
write_byte(priv, AUX_CR, AUXMR);
@@ -1014,7 +993,7 @@ void nec7210_board_reset(struct nec7210_priv *priv, const gpib_board_t *board)
}
EXPORT_SYMBOL(nec7210_board_reset);
-void nec7210_board_online(struct nec7210_priv *priv, const gpib_board_t *board)
+void nec7210_board_online(struct nec7210_priv *priv, const struct gpib_board *board)
{
/* set GPIB address */
nec7210_primary_address(board, priv, board->pad);
diff --git a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
index d0656dc520f5..14f7049a8e5e 100644
--- a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
+++ b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
@@ -5,6 +5,10 @@
* copyright : (C) 2004 by Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -20,7 +24,7 @@ MODULE_DESCRIPTION("GPIB driver for National Instruments USB devices");
static struct usb_interface *ni_usb_driver_interfaces[MAX_NUM_NI_USB_INTERFACES];
static int ni_usb_parse_status_block(const u8 *buffer, struct ni_usb_status_block *status);
-static int ni_usb_set_interrupt_monitor(gpib_board_t *board, unsigned int monitored_bits);
+static int ni_usb_set_interrupt_monitor(struct gpib_board *board, unsigned int monitored_bits);
static void ni_usb_stop(struct ni_usb_priv *ni_priv);
static DEFINE_MUTEX(ni_usb_hotplug_lock);
@@ -75,7 +79,7 @@ static unsigned short ni_usb_timeout_code(unsigned int usec)
*/
else if (usec <= 1000000000)
return 0x02;
- pr_err("%s: bug? usec is greater than 1e9\n", __func__);
+ pr_err("bug? usec is greater than 1e9\n");
return 0xf0;
}
@@ -83,8 +87,6 @@ static void ni_usb_bulk_complete(struct urb *urb)
{
struct ni_usb_urb_ctx *context = urb->context;
-// printk("debug: %s: status=0x%x, error_count=%i, actual_length=%i\n", __func__,
-// urb->status, urb->error_count, urb->actual_length);
complete(&context->complete);
}
@@ -137,8 +139,8 @@ static int ni_usb_nonblocking_send_bulk_msg(struct ni_usb_priv *ni_priv, void *d
del_timer_sync(&ni_priv->bulk_timer);
usb_free_urb(ni_priv->bulk_urb);
ni_priv->bulk_urb = NULL;
- dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to submit bulk out urb, retval=%i\n",
+ retval);
mutex_unlock(&ni_priv->bulk_transfer_lock);
return retval;
}
@@ -146,7 +148,7 @@ static int ni_usb_nonblocking_send_bulk_msg(struct ni_usb_priv *ni_priv, void *d
wait_for_completion(&context->complete); // wait for ni_usb_bulk_complete
if (context->timed_out) {
usb_kill_urb(ni_priv->bulk_urb);
- dev_err(&usb_dev->dev, "%s: killed urb due to timeout\n", __func__);
+ dev_err(&usb_dev->dev, "killed urb due to timeout\n");
retval = -ETIMEDOUT;
} else {
retval = ni_priv->bulk_urb->status;
@@ -218,14 +220,12 @@ static int ni_usb_nonblocking_receive_bulk_msg(struct ni_usb_priv *ni_priv,
if (timeout_msecs)
mod_timer(&ni_priv->bulk_timer, jiffies + msecs_to_jiffies(timeout_msecs));
- //printk("%s: submitting urb\n", __func__);
retval = usb_submit_urb(ni_priv->bulk_urb, GFP_KERNEL);
if (retval) {
del_timer_sync(&ni_priv->bulk_timer);
usb_free_urb(ni_priv->bulk_urb);
ni_priv->bulk_urb = NULL;
- dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to submit bulk in urb, retval=%i\n", retval);
mutex_unlock(&ni_priv->bulk_transfer_lock);
return retval;
}
@@ -250,7 +250,7 @@ static int ni_usb_nonblocking_receive_bulk_msg(struct ni_usb_priv *ni_priv,
}
if (context->timed_out) {
usb_kill_urb(ni_priv->bulk_urb);
- dev_err(&usb_dev->dev, "%s: killed urb due to timeout\n", __func__);
+ dev_err(&usb_dev->dev, "killed urb due to timeout\n");
retval = -ETIMEDOUT;
} else {
if (ni_priv->bulk_urb->status)
@@ -310,7 +310,7 @@ static int ni_usb_receive_control_msg(struct ni_usb_priv *ni_priv, __u8 request,
return retval;
}
-static void ni_usb_soft_update_status(gpib_board_t *board, unsigned int ni_usb_ibsta,
+static void ni_usb_soft_update_status(struct gpib_board *board, unsigned int ni_usb_ibsta,
unsigned int clear_mask)
{
static const unsigned int ni_usb_ibsta_mask = SRQI | ATN | CIC | REM | LACS | TACS | LOK;
@@ -330,14 +330,14 @@ static void ni_usb_soft_update_status(gpib_board_t *board, unsigned int ni_usb_i
ni_priv->monitored_ibsta_bits &= ~ni_usb_ibsta;
need_monitoring_bits &= ~ni_priv->monitored_ibsta_bits; /* mm - monitored set */
spin_unlock_irqrestore(&board->spinlock, flags);
- dev_dbg(&usb_dev->dev, "%s: need_monitoring_bits=0x%x\n", __func__, need_monitoring_bits);
+ dev_dbg(&usb_dev->dev, "need_monitoring_bits=0x%x\n", need_monitoring_bits);
if (need_monitoring_bits & ~ni_usb_ibsta)
ni_usb_set_interrupt_monitor(board, ni_usb_ibsta_monitor_mask);
else if (need_monitoring_bits & ni_usb_ibsta)
wake_up_interruptible(&board->wait);
- dev_dbg(&usb_dev->dev, "%s: ni_usb_ibsta=0x%x\n", __func__, ni_usb_ibsta);
+ dev_dbg(&usb_dev->dev, "ibsta=0x%x\n", ni_usb_ibsta);
}
static int ni_usb_parse_status_block(const u8 *buffer, struct ni_usb_status_block *status)
@@ -371,7 +371,7 @@ static int ni_usb_parse_register_read_block(const u8 *raw_data, unsigned int *re
int k;
if (raw_data[i++] != NIUSB_REGISTER_READ_DATA_START_ID) {
- pr_err("%s: parse error: wrong start id\n", __func__);
+ pr_err("parse error: wrong start id\n");
unexpected = 1;
}
for (k = 0; k < results_per_chunk && j < num_results; ++k)
@@ -380,18 +380,18 @@ static int ni_usb_parse_register_read_block(const u8 *raw_data, unsigned int *re
while (i % 4)
i++;
if (raw_data[i++] != NIUSB_REGISTER_READ_DATA_END_ID) {
- pr_err("%s: parse error: wrong end id\n", __func__);
+ pr_err("parse error: wrong end id\n");
unexpected = 1;
}
if (raw_data[i++] % results_per_chunk != num_results % results_per_chunk) {
- pr_err("%s: parse error: wrong count=%i for NIUSB_REGISTER_READ_DATA_END\n",
- __func__, (int)raw_data[i - 1]);
+ pr_err("parse error: wrong count=%i for NIUSB_REGISTER_READ_DATA_END\n",
+ (int)raw_data[i - 1]);
unexpected = 1;
}
while (i % 4) {
if (raw_data[i++] != 0) {
- pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n",
- __func__, i - 1, (int)raw_data[i - 1]);
+ pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n",
+ i - 1, (int)raw_data[i - 1]);
unexpected = 1;
}
}
@@ -408,9 +408,8 @@ static int ni_usb_parse_termination_block(const u8 *buffer)
buffer[i++] != 0x0 ||
buffer[i++] != 0x0 ||
buffer[i++] != 0x0) {
- pr_err("%s: received unexpected termination block\n", __func__);
- pr_err(" expected: 0x%x 0x%x 0x%x 0x%x\n",
- NIUSB_TERM_ID, 0x0, 0x0, 0x0);
+ pr_err("received unexpected termination block\n");
+ pr_err(" expected: 0x%x 0x%x 0x%x 0x%x\n", NIUSB_TERM_ID, 0x0, 0x0, 0x0);
pr_err(" received: 0x%x 0x%x 0x%x 0x%x\n",
buffer[i - 4], buffer[i - 3], buffer[i - 2], buffer[i - 1]);
}
@@ -427,7 +426,6 @@ static int parse_board_ibrd_readback(const u8 *raw_data, struct ni_usb_status_bl
int i = 0;
int j = 0;
int k;
- unsigned int adr1_bits;
int num_data_blocks = 0;
struct ni_usb_status_block register_write_status;
int unexpected = 0;
@@ -438,12 +436,12 @@ static int parse_board_ibrd_readback(const u8 *raw_data, struct ni_usb_status_bl
} else if (raw_data[i] == NIUSB_IBRD_EXTENDED_DATA_ID) {
data_block_length = ibrd_extended_data_block_length;
if (raw_data[++i] != 0) {
- pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n",
- __func__, i, (int)raw_data[i]);
+ pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n",
+ i, (int)raw_data[i]);
unexpected = 1;
}
} else {
- pr_err("%s: logic bug!\n", __func__);
+ pr_err("Unexpected NIUSB_IBRD ID\n");
return -EINVAL;
}
++i;
@@ -457,10 +455,10 @@ static int parse_board_ibrd_readback(const u8 *raw_data, struct ni_usb_status_bl
}
i += ni_usb_parse_status_block(&raw_data[i], status);
if (status->id != NIUSB_IBRD_STATUS_ID) {
- pr_err("%s: bug: status->id=%i, != ibrd_status_id\n", __func__, status->id);
+ pr_err("bug: status->id=%i, != ibrd_status_id\n", status->id);
return -EIO;
}
- adr1_bits = raw_data[i++];
+ i++;
if (num_data_blocks) {
*actual_bytes_read = (num_data_blocks - 1) * data_block_length + raw_data[i++];
} else {
@@ -468,29 +466,28 @@ static int parse_board_ibrd_readback(const u8 *raw_data, struct ni_usb_status_bl
*actual_bytes_read = 0;
}
if (*actual_bytes_read > j)
- pr_err("%s: bug: discarded data. actual_bytes_read=%i, j=%i\n",
- __func__, *actual_bytes_read, j);
+ pr_err("bug: discarded data. actual_bytes_read=%i, j=%i\n", *actual_bytes_read, j);
for (k = 0; k < 2; k++)
if (raw_data[i++] != 0) {
- pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n",
- __func__, i - 1, (int)raw_data[i - 1]);
+ pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n",
+ i - 1, (int)raw_data[i - 1]);
unexpected = 1;
}
i += ni_usb_parse_status_block(&raw_data[i], &register_write_status);
if (register_write_status.id != NIUSB_REG_WRITE_ID) {
- pr_err("%s: unexpected data: register write status id=0x%x, expected 0x%x\n",
- __func__, register_write_status.id, NIUSB_REG_WRITE_ID);
+ pr_err("unexpected data: register write status id=0x%x, expected 0x%x\n",
+ register_write_status.id, NIUSB_REG_WRITE_ID);
unexpected = 1;
}
if (raw_data[i++] != 2) {
- pr_err("%s: unexpected data: register write count=%i, expected 2\n",
- __func__, (int)raw_data[i - 1]);
+ pr_err("unexpected data: register write count=%i, expected 2\n",
+ (int)raw_data[i - 1]);
unexpected = 1;
}
for (k = 0; k < 3; k++)
if (raw_data[i++] != 0) {
- pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n",
- __func__, i - 1, (int)raw_data[i - 1]);
+ pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n",
+ i - 1, (int)raw_data[i - 1]);
unexpected = 1;
}
i += ni_usb_parse_termination_block(&raw_data[i]);
@@ -530,18 +527,14 @@ static int ni_usb_write_registers(struct ni_usb_priv *ni_priv,
out_data_length = num_writes * bytes_per_write + 0x10;
out_data = kmalloc(out_data_length, GFP_KERNEL);
- if (!out_data) {
- dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__);
+ if (!out_data)
return -ENOMEM;
- }
i += ni_usb_bulk_register_write_header(&out_data[i], num_writes);
for (j = 0; j < num_writes; j++)
i += ni_usb_bulk_register_write(&out_data[i], writes[j]);
while (i % 4)
out_data[i++] = 0x00;
i += ni_usb_bulk_termination(&out_data[i]);
- if (i > out_data_length)
- dev_err(&usb_dev->dev, "%s: bug! buffer overrun\n", __func__);
mutex_lock(&ni_priv->addressed_transfer_lock);
@@ -549,22 +542,21 @@ static int ni_usb_write_registers(struct ni_usb_priv *ni_priv,
kfree(out_data);
if (retval) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
return retval;
}
in_data = kmalloc(in_data_length, GFP_KERNEL);
if (!in_data) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__);
return -ENOMEM;
}
retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0);
if (retval || bytes_read != 16) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
ni_usb_dump_raw_block(in_data, bytes_read);
kfree(in_data);
return retval;
@@ -576,18 +568,16 @@ static int ni_usb_write_registers(struct ni_usb_priv *ni_priv,
//FIXME parse extra 09 status bits and termination
kfree(in_data);
if (status.id != NIUSB_REG_WRITE_ID) {
- dev_err(&usb_dev->dev, "%s: parse error, id=0x%x != NIUSB_REG_WRITE_ID\n",
- __func__, status.id);
+ dev_err(&usb_dev->dev, "parse error, id=0x%x != NIUSB_REG_WRITE_ID\n", status.id);
return -EIO;
}
if (status.error_code) {
- dev_err(&usb_dev->dev, "%s: nonzero error code 0x%x\n",
- __func__, status.error_code);
+ dev_err(&usb_dev->dev, "nonzero error code 0x%x\n", status.error_code);
return -EIO;
}
if (reg_writes_completed != num_writes) {
- dev_err(&usb_dev->dev, "%s: reg_writes_completed=%i, num_writes=%i\n",
- __func__, reg_writes_completed, num_writes);
+ dev_err(&usb_dev->dev, "reg_writes_completed=%i, num_writes=%i\n",
+ reg_writes_completed, num_writes);
return -EIO;
}
if (ibsta)
@@ -596,12 +586,12 @@ static int ni_usb_write_registers(struct ni_usb_priv *ni_priv,
}
// interface functions
-static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int ni_usb_read(struct gpib_board *board, uint8_t *buffer, size_t length,
int *end, size_t *bytes_read)
{
int retval, parse_retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
static const int out_data_length = 0x20;
int in_data_length;
@@ -614,10 +604,11 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
struct ni_usb_register reg;
*bytes_read = 0;
- if (length > max_read_length) {
- length = max_read_length;
- dev_err(&usb_dev->dev, "%s: read length too long\n", __func__);
- }
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ if (length > max_read_length)
+ return -EINVAL;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
return -ENOMEM;
@@ -649,8 +640,8 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
if (retval || usb_bytes_written != i) {
if (retval == 0)
retval = -EIO;
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n",
- __func__, retval, usb_bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n",
+ retval, usb_bytes_written, i);
mutex_unlock(&ni_priv->addressed_transfer_lock);
return retval;
}
@@ -668,8 +659,8 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
if (retval == -ERESTARTSYS) {
} else if (retval) {
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, usb_bytes_read=%i\n",
- __func__, retval, usb_bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, usb_bytes_read=%i\n",
+ retval, usb_bytes_read);
kfree(in_data);
return retval;
}
@@ -677,14 +668,14 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
if (parse_retval != usb_bytes_read) {
if (parse_retval >= 0)
parse_retval = -EIO;
- dev_err(&usb_dev->dev, "%s: retval=%i usb_bytes_read=%i\n",
- __func__, parse_retval, usb_bytes_read);
+ dev_err(&usb_dev->dev, "retval=%i usb_bytes_read=%i\n",
+ parse_retval, usb_bytes_read);
kfree(in_data);
return parse_retval;
}
if (actual_length != length - status.count) {
- dev_err(&usb_dev->dev, "%s: actual_length=%i expected=%li\n",
- __func__, actual_length, (long)(length - status.count));
+ dev_err(&usb_dev->dev, "actual_length=%i expected=%li\n",
+ actual_length, (long)(length - status.count));
ni_usb_dump_raw_block(in_data, usb_bytes_read);
}
kfree(in_data);
@@ -699,7 +690,7 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
break;
case NIUSB_ATN_STATE_ERROR:
retval = -EIO;
- dev_err(&usb_dev->dev, "%s: read when ATN set\n", __func__);
+ dev_err(&usb_dev->dev, "read when ATN set\n");
break;
case NIUSB_ADDRESSING_ERROR:
retval = -EIO;
@@ -708,12 +699,11 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
retval = -ETIMEDOUT;
break;
case NIUSB_EOSMODE_ERROR:
- dev_err(&usb_dev->dev, "%s: driver bug, we should have been able to avoid NIUSB_EOSMODE_ERROR.\n",
- __func__);
+ dev_err(&usb_dev->dev, "driver bug, we should have been able to avoid NIUSB_EOSMODE_ERROR.\n");
retval = -EINVAL;
break;
default:
- dev_err(&usb_dev->dev, "%s: unknown error code=%i\n", __func__, status.error_code);
+ dev_err(&usb_dev->dev, "unknown error code=%i\n", status.error_code);
retval = -EIO;
break;
}
@@ -726,12 +716,12 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
return retval;
}
-static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int ni_usb_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
int out_data_length;
static const int in_data_length = 0x10;
@@ -741,12 +731,11 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
struct ni_usb_status_block status;
static const int max_write_length = 0xffff;
- *bytes_written = 0;
- if (length > max_write_length) {
- length = max_write_length;
- send_eoi = 0;
- dev_err(&usb_dev->dev, "%s: write length too long\n", __func__);
- }
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ if (length > max_write_length)
+ return -EINVAL;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
out_data_length = length + 0x10;
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
@@ -777,8 +766,8 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
kfree(out_data);
if (retval || usb_bytes_written != i) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n",
- __func__, retval, usb_bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n",
+ retval, usb_bytes_written, i);
return retval;
}
@@ -793,8 +782,8 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
mutex_unlock(&ni_priv->addressed_transfer_lock);
if ((retval && retval != -ERESTARTSYS) || usb_bytes_read != 12) {
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, usb_bytes_read=%i\n",
- __func__, retval, usb_bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, usb_bytes_read=%i\n",
+ retval, usb_bytes_read);
kfree(in_data);
return retval;
}
@@ -810,8 +799,8 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
*/
break;
case NIUSB_ADDRESSING_ERROR:
- dev_err(&usb_dev->dev, "%s: Addressing error retval %d error code=%i\n",
- __func__, retval, status.error_code);
+ dev_err(&usb_dev->dev, "Addressing error retval %d error code=%i\n",
+ retval, status.error_code);
retval = -ENXIO;
break;
case NIUSB_NO_LISTENER_ERROR:
@@ -821,8 +810,7 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
retval = -ETIMEDOUT;
break;
default:
- dev_err(&usb_dev->dev, "%s: unknown error code=%i\n",
- __func__, status.error_code);
+ dev_err(&usb_dev->dev, "unknown error code=%i\n", status.error_code);
retval = -EPIPE;
break;
}
@@ -831,12 +819,12 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
return retval;
}
-static int ni_usb_command_chunk(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int ni_usb_command_chunk(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *command_bytes_written)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
int out_data_length;
static const int in_data_length = 0x10;
@@ -848,8 +836,11 @@ static int ni_usb_command_chunk(gpib_board_t *board, uint8_t *buffer, size_t len
static const int max_command_length = 0x10;
*command_bytes_written = 0;
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
if (length > max_command_length)
length = max_command_length;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
out_data_length = length + 0x10;
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
@@ -873,8 +864,8 @@ static int ni_usb_command_chunk(gpib_board_t *board, uint8_t *buffer, size_t len
kfree(out_data);
if (retval || bytes_written != i) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
return retval;
}
@@ -890,8 +881,8 @@ static int ni_usb_command_chunk(gpib_board_t *board, uint8_t *buffer, size_t len
mutex_unlock(&ni_priv->addressed_transfer_lock);
if ((retval && retval != -ERESTARTSYS) || bytes_read != 12) {
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
kfree(in_data);
return retval;
}
@@ -909,19 +900,19 @@ static int ni_usb_command_chunk(gpib_board_t *board, uint8_t *buffer, size_t len
case NIUSB_NO_BUS_ERROR:
return -ENOTCONN;
case NIUSB_EOSMODE_ERROR:
- dev_err(&usb_dev->dev, "%s: got eosmode error. Driver bug?\n", __func__);
+ dev_err(&usb_dev->dev, "got eosmode error. Driver bug?\n");
return -EIO;
case NIUSB_TIMEOUT_ERROR:
return -ETIMEDOUT;
default:
- dev_err(&usb_dev->dev, "%s: unknown error code=%i\n", __func__, status.error_code);
+ dev_err(&usb_dev->dev, "unknown error code=%i\n", status.error_code);
return -EIO;
}
ni_usb_soft_update_status(board, status.ibsta, 0);
return 0;
}
-static int ni_usb_command(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int ni_usb_command(struct gpib_board *board, uint8_t *buffer, size_t length,
size_t *bytes_written)
{
size_t count;
@@ -938,11 +929,11 @@ static int ni_usb_command(gpib_board_t *board, uint8_t *buffer, size_t length,
return 0;
}
-static int ni_usb_take_control(gpib_board_t *board, int synchronous)
+static int ni_usb_take_control(struct gpib_board *board, int synchronous)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
static const int out_data_length = 0x10;
static const int in_data_length = 0x10;
@@ -950,6 +941,9 @@ static int ni_usb_take_control(gpib_board_t *board, int synchronous)
int i = 0;
struct ni_usb_status_block status;
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
return -ENOMEM;
@@ -968,15 +962,14 @@ static int ni_usb_take_control(gpib_board_t *board, int synchronous)
kfree(out_data);
if (retval || bytes_written != i) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
return retval;
}
in_data = kmalloc(in_data_length, GFP_KERNEL);
if (!in_data) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__);
return -ENOMEM;
}
retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 1);
@@ -986,8 +979,8 @@ static int ni_usb_take_control(gpib_board_t *board, int synchronous)
if ((retval && retval != -ERESTARTSYS) || bytes_read != 12) {
if (retval == 0)
retval = -EIO;
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
kfree(in_data);
return retval;
}
@@ -997,11 +990,11 @@ static int ni_usb_take_control(gpib_board_t *board, int synchronous)
return retval;
}
-static int ni_usb_go_to_standby(gpib_board_t *board)
+static int ni_usb_go_to_standby(struct gpib_board *board)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
static const int out_data_length = 0x10;
static const int in_data_length = 0x20;
@@ -1009,6 +1002,9 @@ static int ni_usb_go_to_standby(gpib_board_t *board)
int i = 0;
struct ni_usb_status_block status;
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
return -ENOMEM;
@@ -1025,15 +1021,14 @@ static int ni_usb_go_to_standby(gpib_board_t *board)
kfree(out_data);
if (retval || bytes_written != i) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
return retval;
}
in_data = kmalloc(in_data_length, GFP_KERNEL);
if (!in_data) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__);
return -ENOMEM;
}
retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0);
@@ -1041,29 +1036,31 @@ static int ni_usb_go_to_standby(gpib_board_t *board)
mutex_unlock(&ni_priv->addressed_transfer_lock);
if (retval || bytes_read != 12) {
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
kfree(in_data);
return retval;
}
ni_usb_parse_status_block(in_data, &status);
kfree(in_data);
if (status.id != NIUSB_IBGTS_ID)
- dev_err(&usb_dev->dev, "%s: bug: status.id 0x%x != INUSB_IBGTS_ID\n",
- __func__, status.id);
+ dev_err(&usb_dev->dev, "bug: status.id 0x%x != INUSB_IBGTS_ID\n", status.id);
ni_usb_soft_update_status(board, status.ibsta, 0);
return 0;
}
-static void ni_usb_request_system_control(gpib_board_t *board, int request_control)
+static void ni_usb_request_system_control(struct gpib_board *board, int request_control)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
int i = 0;
struct ni_usb_register writes[4];
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return; // -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
if (request_control) {
writes[i].device = NIUSB_SUBDEV_TNT4882;
writes[i].address = CMDR;
@@ -1093,7 +1090,7 @@ static void ni_usb_request_system_control(gpib_board_t *board, int request_contr
}
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return; // retval;
}
if (!request_control)
@@ -1103,11 +1100,11 @@ static void ni_usb_request_system_control(gpib_board_t *board, int request_contr
}
//FIXME maybe the interface should have a "pulse interface clear" function that can return an error?
-static void ni_usb_interface_clear(gpib_board_t *board, int assert)
+static void ni_usb_interface_clear(struct gpib_board *board, int assert)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
static const int out_data_length = 0x10;
static const int in_data_length = 0x10;
@@ -1115,14 +1112,15 @@ static void ni_usb_interface_clear(gpib_board_t *board, int assert)
int i = 0;
struct ni_usb_status_block status;
- // FIXME: we are going to pulse when assert is true, and ignore otherwise
+ if (!ni_priv->bus_interface)
+ return; // -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+// FIXME: we are going to pulse when assert is true, and ignore otherwise
if (assert == 0)
return;
out_data = kmalloc(out_data_length, GFP_KERNEL);
- if (!out_data) {
- dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__);
+ if (!out_data)
return;
- }
out_data[i++] = NIUSB_IBSIC_ID;
out_data[i++] = 0x0;
out_data[i++] = 0x0;
@@ -1131,8 +1129,8 @@ static void ni_usb_interface_clear(gpib_board_t *board, int assert)
retval = ni_usb_send_bulk_msg(ni_priv, out_data, i, &bytes_written, 1000);
kfree(out_data);
if (retval || bytes_written != i) {
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
return;
}
in_data = kmalloc(in_data_length, GFP_KERNEL);
@@ -1141,8 +1139,8 @@ static void ni_usb_interface_clear(gpib_board_t *board, int assert)
retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0);
if (retval || bytes_read != 12) {
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
kfree(in_data);
return;
}
@@ -1151,14 +1149,17 @@ static void ni_usb_interface_clear(gpib_board_t *board, int assert)
ni_usb_soft_update_status(board, status.ibsta, 0);
}
-static void ni_usb_remote_enable(gpib_board_t *board, int enable)
+static void ni_usb_remote_enable(struct gpib_board *board, int enable)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
struct ni_usb_register reg;
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return; // -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
reg.device = NIUSB_SUBDEV_TNT4882;
reg.address = nec7210_to_tnt4882_offset(AUXMR);
if (enable)
@@ -1167,7 +1168,7 @@ static void ni_usb_remote_enable(gpib_board_t *board, int enable)
reg.value = AUX_CREN;
retval = ni_usb_write_registers(ni_priv, &reg, 1, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return; //retval;
}
ni_priv->ren_state = enable;
@@ -1175,7 +1176,7 @@ static void ni_usb_remote_enable(gpib_board_t *board, int enable)
return;// 0;
}
-static int ni_usb_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int ni_usb_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct ni_usb_priv *ni_priv = board->private_data;
@@ -1188,7 +1189,7 @@ static int ni_usb_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_
return 0;
}
-static void ni_usb_disable_eos(gpib_board_t *board)
+static void ni_usb_disable_eos(struct gpib_board *board)
{
struct ni_usb_priv *ni_priv = board->private_data;
/* adapter gets unhappy if you don't zero all the bits
@@ -1198,16 +1199,18 @@ static void ni_usb_disable_eos(gpib_board_t *board)
ni_priv->eos_char = 0;
}
-static unsigned int ni_usb_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int ni_usb_update_status(struct gpib_board *board, unsigned int clear_mask)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
static const int buffer_length = 8;
u8 *buffer;
struct ni_usb_status_block status;
- //printk("%s: receive control pipe is %i\n", __func__, pipe);
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
buffer = kmalloc(buffer_length, GFP_KERNEL);
if (!buffer)
return board->status;
@@ -1216,7 +1219,7 @@ static unsigned int ni_usb_update_status(gpib_board_t *board, unsigned int clear
USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x200, 0x0, buffer, buffer_length, 1000);
if (retval != buffer_length) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg returned %i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg returned %i\n", retval);
kfree(buffer);
return board->status;
}
@@ -1235,7 +1238,6 @@ static void ni_usb_stop(struct ni_usb_priv *ni_priv)
u8 *buffer;
struct ni_usb_status_block status;
- //printk("%s: receive control pipe is %i\n", __func__, pipe);
buffer = kmalloc(buffer_length, GFP_KERNEL);
if (!buffer)
return;
@@ -1244,7 +1246,7 @@ static void ni_usb_stop(struct ni_usb_priv *ni_priv)
USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x0, 0x0, buffer, buffer_length, 1000);
if (retval != buffer_length) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg returned %i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg returned %i\n", retval);
kfree(buffer);
return;
}
@@ -1252,15 +1254,18 @@ static void ni_usb_stop(struct ni_usb_priv *ni_priv)
kfree(buffer);
}
-static int ni_usb_primary_address(gpib_board_t *board, unsigned int address)
+static int ni_usb_primary_address(struct gpib_board *board, unsigned int address)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
int i = 0;
struct ni_usb_register writes[2];
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
writes[i].device = NIUSB_SUBDEV_TNT4882;
writes[i].address = nec7210_to_tnt4882_offset(ADR);
writes[i].value = address;
@@ -1271,7 +1276,7 @@ static int ni_usb_primary_address(gpib_board_t *board, unsigned int address)
i++;
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return retval;
}
ni_usb_soft_update_status(board, ibsta, 0);
@@ -1307,30 +1312,33 @@ static int ni_usb_write_sad(struct ni_usb_register *writes, int address, int ena
return i;
}
-static int ni_usb_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int ni_usb_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
int i = 0;
struct ni_usb_register writes[3];
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
i += ni_usb_write_sad(writes, address, enable);
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return retval;
}
ni_usb_soft_update_status(board, ibsta, 0);
return 0;
}
-static int ni_usb_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int ni_usb_parallel_poll(struct gpib_board *board, uint8_t *result)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
static const int out_data_length = 0x10;
static const int in_data_length = 0x20;
@@ -1339,6 +1347,9 @@ static int ni_usb_parallel_poll(gpib_board_t *board, uint8_t *result)
int j = 0;
struct ni_usb_status_block status;
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
return -ENOMEM;
@@ -1353,8 +1364,8 @@ static int ni_usb_parallel_poll(gpib_board_t *board, uint8_t *result)
kfree(out_data);
if (retval || bytes_written != i) {
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
return retval;
}
in_data = kmalloc(in_data_length, GFP_KERNEL);
@@ -1366,8 +1377,8 @@ static int ni_usb_parallel_poll(gpib_board_t *board, uint8_t *result)
&bytes_read, 1000, 1);
if (retval && retval != -ERESTARTSYS) {
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
kfree(in_data);
return retval;
}
@@ -1378,37 +1389,43 @@ static int ni_usb_parallel_poll(gpib_board_t *board, uint8_t *result)
return retval;
}
-static void ni_usb_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void ni_usb_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
int i = 0;
struct ni_usb_register writes[1];
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return; // -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
writes[i].device = NIUSB_SUBDEV_TNT4882;
writes[i].address = nec7210_to_tnt4882_offset(AUXMR);
writes[i].value = PPR | config;
i++;
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return;// retval;
}
ni_usb_soft_update_status(board, ibsta, 0);
return;// 0;
}
-static void ni_usb_parallel_poll_response(gpib_board_t *board, int ist)
+static void ni_usb_parallel_poll_response(struct gpib_board *board, int ist)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
int i = 0;
struct ni_usb_register writes[1];
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return; // -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
writes[i].device = NIUSB_SUBDEV_TNT4882;
writes[i].address = nec7210_to_tnt4882_offset(AUXMR);
if (ist)
@@ -1418,76 +1435,85 @@ static void ni_usb_parallel_poll_response(gpib_board_t *board, int ist)
i++;
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return;// retval;
}
ni_usb_soft_update_status(board, ibsta, 0);
return;// 0;
}
-static void ni_usb_serial_poll_response(gpib_board_t *board, u8 status)
+static void ni_usb_serial_poll_response(struct gpib_board *board, u8 status)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
int i = 0;
struct ni_usb_register writes[1];
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return; // -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
writes[i].device = NIUSB_SUBDEV_TNT4882;
writes[i].address = nec7210_to_tnt4882_offset(SPMR);
writes[i].value = status;
i++;
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return;// retval;
}
ni_usb_soft_update_status(board, ibsta, 0);
return;// 0;
}
-static uint8_t ni_usb_serial_poll_status(gpib_board_t *board)
+static uint8_t ni_usb_serial_poll_status(struct gpib_board *board)
{
return 0;
}
-static void ni_usb_return_to_local(gpib_board_t *board)
+static void ni_usb_return_to_local(struct gpib_board *board)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
int i = 0;
struct ni_usb_register writes[1];
unsigned int ibsta;
+ if (!ni_priv->bus_interface)
+ return; // -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
writes[i].device = NIUSB_SUBDEV_TNT4882;
writes[i].address = nec7210_to_tnt4882_offset(AUXMR);
writes[i].value = AUX_RTL;
i++;
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return;// retval;
}
ni_usb_soft_update_status(board, ibsta, 0);
return;// 0;
}
-static int ni_usb_line_status(const gpib_board_t *board)
+static int ni_usb_line_status(const struct gpib_board *board)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
u8 *out_data, *in_data;
static const int out_data_length = 0x20;
static const int in_data_length = 0x20;
int bytes_written = 0, bytes_read = 0;
int i = 0;
unsigned int bsr_bits;
- int line_status = ValidALL;
+ int line_status = VALID_ALL;
// NI windows driver reads 0xd(HSSEL), 0xc (ARD0), 0x1f (BSR)
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
out_data = kmalloc(out_data_length, GFP_KERNEL);
if (!out_data)
return -ENOMEM;
@@ -1509,15 +1535,14 @@ static int ni_usb_line_status(const gpib_board_t *board)
if (retval || bytes_written != i) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
if (retval != -EAGAIN)
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
- __func__, retval, bytes_written, i);
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n",
+ retval, bytes_written, i);
return retval;
}
in_data = kmalloc(in_data_length, GFP_KERNEL);
if (!in_data) {
mutex_unlock(&ni_priv->addressed_transfer_lock);
- dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__);
return -ENOMEM;
}
retval = ni_usb_nonblocking_receive_bulk_msg(ni_priv, in_data, in_data_length,
@@ -1527,8 +1552,8 @@ static int ni_usb_line_status(const gpib_board_t *board)
if (retval) {
if (retval != -EAGAIN)
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
kfree(in_data);
return retval;
}
@@ -1536,21 +1561,21 @@ static int ni_usb_line_status(const gpib_board_t *board)
ni_usb_parse_register_read_block(in_data, &bsr_bits, 1);
kfree(in_data);
if (bsr_bits & BCSR_REN_BIT)
- line_status |= BusREN;
+ line_status |= BUS_REN;
if (bsr_bits & BCSR_IFC_BIT)
- line_status |= BusIFC;
+ line_status |= BUS_IFC;
if (bsr_bits & BCSR_SRQ_BIT)
- line_status |= BusSRQ;
+ line_status |= BUS_SRQ;
if (bsr_bits & BCSR_EOI_BIT)
- line_status |= BusEOI;
+ line_status |= BUS_EOI;
if (bsr_bits & BCSR_NRFD_BIT)
- line_status |= BusNRFD;
+ line_status |= BUS_NRFD;
if (bsr_bits & BCSR_NDAC_BIT)
- line_status |= BusNDAC;
+ line_status |= BUS_NDAC;
if (bsr_bits & BCSR_DAV_BIT)
- line_status |= BusDAV;
+ line_status |= BUS_DAV;
if (bsr_bits & BCSR_ATN_BIT)
- line_status |= BusATN;
+ line_status |= BUS_ATN;
return line_status;
}
@@ -1591,28 +1616,31 @@ static int ni_usb_setup_t1_delay(struct ni_usb_register *reg, unsigned int nano_
return i;
}
-static unsigned int ni_usb_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int ni_usb_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
- struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
+ struct usb_device *usb_dev;
struct ni_usb_register writes[3];
unsigned int ibsta;
unsigned int actual_ns;
int i;
+ if (!ni_priv->bus_interface)
+ return -ENODEV;
+ usb_dev = interface_to_usbdev(ni_priv->bus_interface);
i = ni_usb_setup_t1_delay(writes, nano_sec, &actual_ns);
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
- return -1; //FIXME should change return type to int for error reporting
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
+ return retval;
}
board->t1_nano_sec = actual_ns;
ni_usb_soft_update_status(board, ibsta, 0);
return actual_ns;
}
-static int ni_usb_allocate_private(gpib_board_t *board)
+static int ni_usb_allocate_private(struct gpib_board *board)
{
struct ni_usb_priv *ni_priv;
@@ -1635,7 +1663,7 @@ static void ni_usb_free_private(struct ni_usb_priv *ni_priv)
}
#define NUM_INIT_WRITES 26
-static int ni_usb_setup_init(gpib_board_t *board, struct ni_usb_register *writes)
+static int ni_usb_setup_init(struct gpib_board *board, struct ni_usb_register *writes)
{
struct ni_usb_priv *ni_priv = board->private_data;
struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
@@ -1736,13 +1764,13 @@ static int ni_usb_setup_init(gpib_board_t *board, struct ni_usb_register *writes
writes[i].value = AUX_CPPF;
i++;
if (i > NUM_INIT_WRITES) {
- dev_err(&usb_dev->dev, "%s: bug!, buffer overrun, i=%i\n", __func__, i);
+ dev_err(&usb_dev->dev, "bug!, buffer overrun, i=%i\n", i);
return 0;
}
return i;
}
-static int ni_usb_init(gpib_board_t *board)
+static int ni_usb_init(struct gpib_board *board)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
@@ -1762,7 +1790,7 @@ static int ni_usb_init(gpib_board_t *board)
return -EFAULT;
kfree(writes);
if (retval) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return retval;
}
ni_usb_soft_update_status(board, ibsta, 0);
@@ -1771,16 +1799,13 @@ static int ni_usb_init(gpib_board_t *board)
static void ni_usb_interrupt_complete(struct urb *urb)
{
- gpib_board_t *board = urb->context;
+ struct gpib_board *board = urb->context;
struct ni_usb_priv *ni_priv = board->private_data;
struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
int retval;
struct ni_usb_status_block status;
unsigned long flags;
-// printk("debug: %s: status=0x%x, error_count=%i, actual_length=%i\n", __func__,
-// urb->status, urb->error_count, urb->actual_length);
-
switch (urb->status) {
/* success */
case 0:
@@ -1793,26 +1818,24 @@ static void ni_usb_interrupt_complete(struct urb *urb)
default: /* other error, resubmit */
retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_ATOMIC);
if (retval)
- dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__);
+ dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n");
return;
}
ni_usb_parse_status_block(urb->transfer_buffer, &status);
-// printk("debug: ibsta=0x%x\n", status.ibsta);
spin_lock_irqsave(&board->spinlock, flags);
ni_priv->monitored_ibsta_bits &= ~status.ibsta;
-// printk("debug: monitored_ibsta_bits=0x%x\n", ni_priv->monitored_ibsta_bits);
spin_unlock_irqrestore(&board->spinlock, flags);
wake_up_interruptible(&board->wait);
retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_ATOMIC);
if (retval)
- dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__);
+ dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n");
}
-static int ni_usb_set_interrupt_monitor(gpib_board_t *board, unsigned int monitored_bits)
+static int ni_usb_set_interrupt_monitor(struct gpib_board *board, unsigned int monitored_bits)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
@@ -1821,22 +1844,20 @@ static int ni_usb_set_interrupt_monitor(gpib_board_t *board, unsigned int monito
u8 *buffer;
struct ni_usb_status_block status;
unsigned long flags;
- //printk("%s: receive control pipe is %i\n", __func__, pipe);
+
buffer = kmalloc(buffer_length, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
spin_lock_irqsave(&board->spinlock, flags);
ni_priv->monitored_ibsta_bits = ni_usb_ibsta_monitor_mask & monitored_bits;
-// dev_err(&usb_dev->dev, "debug: %s: monitored_ibsta_bits=0x%x\n",
-// __func__, ni_priv->monitored_ibsta_bits);
spin_unlock_irqrestore(&board->spinlock, flags);
retval = ni_usb_receive_control_msg(ni_priv, NI_USB_WAIT_REQUEST, USB_DIR_IN |
USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x300, ni_usb_ibsta_monitor_mask & monitored_bits,
buffer, buffer_length, 1000);
if (retval != buffer_length) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg returned %i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg returned %i\n", retval);
kfree(buffer);
return -1;
}
@@ -1845,7 +1866,7 @@ static int ni_usb_set_interrupt_monitor(gpib_board_t *board, unsigned int monito
return 0;
}
-static int ni_usb_setup_urbs(gpib_board_t *board)
+static int ni_usb_setup_urbs(struct gpib_board *board)
{
struct ni_usb_priv *ni_priv = board->private_data;
struct usb_device *usb_dev;
@@ -1872,8 +1893,7 @@ static int ni_usb_setup_urbs(gpib_board_t *board)
retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_KERNEL);
mutex_unlock(&ni_priv->interrupt_transfer_lock);
if (retval) {
- dev_err(&usb_dev->dev, "%s: failed to submit first interrupt urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "failed to submit first interrupt urb, retval=%i\n", retval);
return retval;
}
return 0;
@@ -1904,7 +1924,6 @@ static int ni_usb_b_read_serial_number(struct ni_usb_priv *ni_priv)
int j;
unsigned int serial_number;
-// printk("%s: %s\n", __func__);
in_data = kmalloc(in_data_length, GFP_KERNEL);
if (!in_data)
return -ENOMEM;
@@ -1924,20 +1943,19 @@ static int ni_usb_b_read_serial_number(struct ni_usb_priv *ni_priv)
i += ni_usb_bulk_termination(&out_data[i]);
retval = ni_usb_send_bulk_msg(ni_priv, out_data, out_data_length, &bytes_written, 1000);
if (retval) {
- dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%li\n",
- __func__,
+ dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%li\n",
retval, bytes_written, (long)out_data_length);
goto serial_out;
}
retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0);
if (retval) {
- dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n",
- __func__, retval, bytes_read);
+ dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n",
+ retval, bytes_read);
ni_usb_dump_raw_block(in_data, bytes_read);
goto serial_out;
}
if (ARRAY_SIZE(results) < num_reads) {
- dev_err(&usb_dev->dev, "Setup bug\n");
+ dev_err(&usb_dev->dev, "serial number eetup bug\n");
retval = -EINVAL;
goto serial_out;
}
@@ -1945,7 +1963,7 @@ static int ni_usb_b_read_serial_number(struct ni_usb_priv *ni_priv)
serial_number = 0;
for (j = 0; j < num_reads; ++j)
serial_number |= (results[j] & 0xff) << (8 * j);
- dev_info(&usb_dev->dev, "%s: board serial number is 0x%x\n", __func__, serial_number);
+ dev_dbg(&usb_dev->dev, "board serial number is 0x%x\n", serial_number);
retval = 0;
serial_out:
kfree(in_data);
@@ -1973,22 +1991,22 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x0, 0x0, buffer, buffer_size, 1000);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n",
- __func__, NI_USB_SERIAL_NUMBER_REQUEST, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n",
+ NI_USB_SERIAL_NUMBER_REQUEST, retval);
goto ready_out;
}
j = 0;
if (buffer[j] != NI_USB_SERIAL_NUMBER_REQUEST) {
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x%x\n",
- __func__, j, (int)buffer[j], NI_USB_SERIAL_NUMBER_REQUEST);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x%x\n",
+ j, (int)buffer[j], NI_USB_SERIAL_NUMBER_REQUEST);
unexpected = 1;
}
if (unexpected)
ni_usb_dump_raw_block(buffer, retval);
// NI-USB-HS+ pads the serial with 0x0 to make 16 bytes
if (retval != 5 && retval != 16) {
- dev_err(&usb_dev->dev, "%s: received unexpected number of bytes = %i, expected 5 or 16\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "received unexpected number of bytes = %i, expected 5 or 16\n",
+ retval);
ni_usb_dump_raw_block(buffer, retval);
}
serial_number = 0;
@@ -1996,7 +2014,7 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
serial_number |= (buffer[++j] << 8);
serial_number |= (buffer[++j] << 16);
serial_number |= (buffer[++j] << 24);
- dev_info(&usb_dev->dev, "%s: board serial number is 0x%x\n", __func__, serial_number);
+ dev_dbg(&usb_dev->dev, "board serial number is 0x%x\n", serial_number);
for (i = 0; i < timeout; ++i) {
int ready = 0;
@@ -2004,26 +2022,26 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x0, 0x0, buffer, buffer_size, 100);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n",
- __func__, NI_USB_POLL_READY_REQUEST, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n",
+ NI_USB_POLL_READY_REQUEST, retval);
goto ready_out;
}
j = 0;
unexpected = 0;
if (buffer[j] != NI_USB_POLL_READY_REQUEST) { // [0]
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x%x\n",
- __func__, j, (int)buffer[j], NI_USB_POLL_READY_REQUEST);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x%x\n",
+ j, (int)buffer[j], NI_USB_POLL_READY_REQUEST);
unexpected = 1;
}
++j;
if (buffer[j] != 0x1 && buffer[j] != 0x0) { // [1] HS+ sends 0x0
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
if (buffer[++j] != 0x0) { // [2]
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x%x\n",
- __func__, j, (int)buffer[j], 0x0);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x%x\n",
+ j, (int)buffer[j], 0x0);
unexpected = 1;
}
++j;
@@ -2031,22 +2049,22 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
// NI-USB-HS+ sends 0x0
if (buffer[j] != 0x1 && buffer[j] != 0x8 && buffer[j] != 0x7 && buffer[j] != 0x0) {
// [3]
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0, 0x1, 0x7 or 0x8\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x0, 0x1, 0x7 or 0x8\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
++j;
// NI-USB-HS+ sends 0 here
if (buffer[j] != 0x30 && buffer[j] != 0x0) { // [4]
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x30\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x30\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
++j;
// MC usb-488 (and sometimes NI-USB-HS?) and NI-USB-HS+ sends 0x0 here
if (buffer[j] != 0x1 && buffer[j] != 0x0) { // [5]
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
if (buffer[++j] != 0x0) { // [6]
@@ -2054,8 +2072,8 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
// NI-USB-HS+ sends 0xf here
if (buffer[j] != 0x2 && buffer[j] != 0xe && buffer[j] != 0xf &&
buffer[j] != 0x16) {
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x2, 0xe, 0xf or 0x16\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x2, 0xe, 0xf or 0x16\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
}
@@ -2064,30 +2082,30 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
// MC usb-488 sends 0x5 here; MC usb-488A sends 0x6 here
if (buffer[j] != 0x3 && buffer[j] != 0x5 && buffer[j] != 0x6 &&
buffer[j] != 0x8) {
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x3 or 0x5, 0x6 or 0x08\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x3 or 0x5, 0x6 or 0x08\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
}
++j;
if (buffer[j] != 0x0 && buffer[j] != 0x2) { // [8] MC usb-488 sends 0x2 here
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x2\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, " unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x2\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
++j;
// MC usb-488A and NI-USB-HS sends 0x3 here; NI-USB-HS+ sends 0x30 here
if (buffer[j] != 0x0 && buffer[j] != 0x3 && buffer[j] != 0x30) { // [9]
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0, 0x3 or 0x30\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x0, 0x3 or 0x30\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
if (buffer[++j] != 0x0) {
ready = 1;
if (buffer[j] != 0x96 && buffer[j] != 0x7 && buffer[j] != 0x6e) {
// [10] MC usb-488 sends 0x7 here
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x96, 0x07 or 0x6e\n",
- __func__, j, (int)buffer[j]);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x96, 0x07 or 0x6e\n",
+ j, (int)buffer[j]);
unexpected = 1;
}
}
@@ -2097,7 +2115,6 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
break;
retval = msleep_interruptible(msec_sleep_duration);
if (retval) {
- dev_err(&usb_dev->dev, "ni_usb_gpib: msleep interrupted\n");
retval = -ERESTARTSYS;
goto ready_out;
}
@@ -2106,7 +2123,7 @@ static int ni_usb_hs_wait_for_ready(struct ni_usb_priv *ni_priv)
ready_out:
kfree(buffer);
- dev_dbg(&usb_dev->dev, "%s: exit retval=%d\n", __func__, retval);
+ dev_dbg(&usb_dev->dev, "exit retval=%d\n", retval);
return retval;
}
@@ -2134,14 +2151,14 @@ static int ni_usb_hs_plus_extra_init(struct ni_usb_priv *ni_priv)
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x0, 0x0, buffer, transfer_size, 1000);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n",
- __func__, NI_USB_HS_PLUS_0x48_REQUEST, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n",
+ NI_USB_HS_PLUS_0x48_REQUEST, retval);
break;
}
// expected response data: 48 f3 30 00 00 00 00 00 00 00 00 00 00 00 00 00
if (buffer[0] != NI_USB_HS_PLUS_0x48_REQUEST)
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[0]=0x%x, expected 0x%x\n",
- __func__, (int)buffer[0], NI_USB_HS_PLUS_0x48_REQUEST);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[0]=0x%x, expected 0x%x\n",
+ (int)buffer[0], NI_USB_HS_PLUS_0x48_REQUEST);
transfer_size = 2;
@@ -2149,14 +2166,14 @@ static int ni_usb_hs_plus_extra_init(struct ni_usb_priv *ni_priv)
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x1, 0x0, buffer, transfer_size, 1000);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n",
- __func__, NI_USB_HS_PLUS_LED_REQUEST, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n",
+ NI_USB_HS_PLUS_LED_REQUEST, retval);
break;
}
// expected response data: 4b 00
if (buffer[0] != NI_USB_HS_PLUS_LED_REQUEST)
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[0]=0x%x, expected 0x%x\n",
- __func__, (int)buffer[0], NI_USB_HS_PLUS_LED_REQUEST);
+ dev_err(&usb_dev->dev, "unexpected data: buffer[0]=0x%x, expected 0x%x\n",
+ (int)buffer[0], NI_USB_HS_PLUS_LED_REQUEST);
transfer_size = 9;
@@ -2165,15 +2182,14 @@ static int ni_usb_hs_plus_extra_init(struct ni_usb_priv *ni_priv)
USB_RECIP_INTERFACE,
0x0, 0x1, buffer, transfer_size, 1000);
if (retval < 0) {
- dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n",
- __func__, NI_USB_HS_PLUS_0xf8_REQUEST, retval);
+ dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n",
+ NI_USB_HS_PLUS_0xf8_REQUEST, retval);
break;
}
// expected response data: f8 01 00 00 00 01 00 00 00
if (buffer[0] != NI_USB_HS_PLUS_0xf8_REQUEST)
- dev_err(&usb_dev->dev, "%s: unexpected data: buffer[0]=0x%x, expected 0x%x\n",
- __func__, (int)buffer[0], NI_USB_HS_PLUS_0xf8_REQUEST);
-
+ dev_err(&usb_dev->dev, "unexpected data: buffer[0]=0x%x, expected 0x%x\n",
+ (int)buffer[0], NI_USB_HS_PLUS_0xf8_REQUEST);
} while (0);
// cleanup
@@ -2189,10 +2205,10 @@ static inline int ni_usb_device_match(struct usb_interface *interface,
return 1;
}
-static int ni_usb_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int ni_usb_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
int retval;
- int i;
+ int i, index;
struct ni_usb_priv *ni_priv;
int product_id;
struct usb_device *usb_dev;
@@ -2211,19 +2227,17 @@ static int ni_usb_attach(gpib_board_t *board, const gpib_board_config_t *config)
ni_priv->bus_interface = ni_usb_driver_interfaces[i];
usb_set_intfdata(ni_usb_driver_interfaces[i], board);
usb_dev = interface_to_usbdev(ni_priv->bus_interface);
- dev_info(&usb_dev->dev,
- "bus %d dev num %d attached to gpib minor %d, NI usb interface %i\n",
- usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
+ index = i;
break;
}
}
if (i == MAX_NUM_NI_USB_INTERFACES) {
mutex_unlock(&ni_usb_hotplug_lock);
- pr_err("No supported NI usb gpib adapters found, have you loaded its firmware?\n");
+ dev_err(board->gpib_dev, "No supported adapters found, have you loaded its firmware?\n");
return -ENODEV;
}
if (usb_reset_configuration(interface_to_usbdev(ni_priv->bus_interface)))
- dev_err(&usb_dev->dev, "ni_usb_gpib: usb_reset_configuration() failed.\n");
+ dev_err(&usb_dev->dev, "usb_reset_configuration() failed.\n");
product_id = le16_to_cpu(usb_dev->descriptor.idProduct);
ni_priv->product_id = product_id;
@@ -2296,7 +2310,9 @@ static int ni_usb_attach(gpib_board_t *board, const gpib_board_config_t *config)
}
mutex_unlock(&ni_usb_hotplug_lock);
- dev_info(&usb_dev->dev, "%s: attached\n", __func__);
+ dev_info(&usb_dev->dev,
+ "bus %d dev num %d attached to gpib%d, intf %i\n",
+ usb_dev->bus->busnum, usb_dev->devnum, board->minor, index);
return retval;
}
@@ -2304,33 +2320,25 @@ static int ni_usb_shutdown_hardware(struct ni_usb_priv *ni_priv)
{
struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface);
int retval;
- int i = 0;
struct ni_usb_register writes[2];
static const int writes_length = ARRAY_SIZE(writes);
unsigned int ibsta;
-// printk("%s: %s\n", __func__);
- writes[i].device = NIUSB_SUBDEV_TNT4882;
- writes[i].address = nec7210_to_tnt4882_offset(AUXMR);
- writes[i].value = AUX_CR;
- i++;
- writes[i].device = NIUSB_SUBDEV_UNKNOWN3;
- writes[i].address = 0x10;
- writes[i].value = 0x0;
- i++;
- if (i > writes_length) {
- dev_err(&usb_dev->dev, "%s: bug!, buffer overrun, i=%i\n", __func__, i);
- return -EINVAL;
- }
- retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
+ writes[0].device = NIUSB_SUBDEV_TNT4882;
+ writes[0].address = nec7210_to_tnt4882_offset(AUXMR);
+ writes[0].value = AUX_CR;
+ writes[1].device = NIUSB_SUBDEV_UNKNOWN3;
+ writes[1].address = 0x10;
+ writes[1].value = 0x0;
+ retval = ni_usb_write_registers(ni_priv, writes, writes_length, &ibsta);
if (retval) {
- dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval);
+ dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
return retval;
}
return 0;
}
-static void ni_usb_detach(gpib_board_t *board)
+static void ni_usb_detach(struct gpib_board *board)
{
struct ni_usb_priv *ni_priv;
@@ -2413,7 +2421,7 @@ static int ni_usb_driver_probe(struct usb_interface *interface, const struct usb
if (i == MAX_NUM_NI_USB_INTERFACES) {
usb_put_dev(usb_dev);
mutex_unlock(&ni_usb_hotplug_lock);
- dev_err(&usb_dev->dev, "%s: ni_usb_driver_interfaces[] full\n", __func__);
+ dev_err(&usb_dev->dev, "ni_usb_driver_interfaces[] full\n");
return -1;
}
path = kmalloc(path_length, GFP_KERNEL);
@@ -2423,7 +2431,7 @@ static int ni_usb_driver_probe(struct usb_interface *interface, const struct usb
return -ENOMEM;
}
usb_make_path(usb_dev, path, path_length);
- dev_info(&usb_dev->dev, "ni_usb_gpib: probe succeeded for path: %s\n", path);
+ dev_info(&usb_dev->dev, "probe succeeded for path: %s\n", path);
kfree(path);
mutex_unlock(&ni_usb_hotplug_lock);
return 0;
@@ -2437,7 +2445,7 @@ static void ni_usb_driver_disconnect(struct usb_interface *interface)
mutex_lock(&ni_usb_hotplug_lock);
for (i = 0; i < MAX_NUM_NI_USB_INTERFACES; i++) {
if (ni_usb_driver_interfaces[i] == interface) {
- gpib_board_t *board = usb_get_intfdata(interface);
+ struct gpib_board *board = usb_get_intfdata(interface);
if (board) {
struct ni_usb_priv *ni_priv = board->private_data;
@@ -2458,8 +2466,7 @@ static void ni_usb_driver_disconnect(struct usb_interface *interface)
}
}
if (i == MAX_NUM_NI_USB_INTERFACES)
- dev_err(&usb_dev->dev, "%s: unable to find interface in ni_usb_driver_interfaces[]? bug?\n",
- __func__);
+ dev_err(&usb_dev->dev, "unable to find interface bug?\n");
usb_put_dev(usb_dev);
mutex_unlock(&ni_usb_hotplug_lock);
}
@@ -2467,7 +2474,7 @@ static void ni_usb_driver_disconnect(struct usb_interface *interface)
static int ni_usb_driver_suspend(struct usb_interface *interface, pm_message_t message)
{
struct usb_device *usb_dev = interface_to_usbdev(interface);
- gpib_board_t *board;
+ struct gpib_board *board;
int i, retval;
mutex_lock(&ni_usb_hotplug_lock);
@@ -2498,9 +2505,9 @@ static int ni_usb_driver_suspend(struct usb_interface *interface, pm_message_t m
ni_usb_cleanup_urbs(ni_priv);
mutex_unlock(&ni_priv->interrupt_transfer_lock);
}
- dev_info(&usb_dev->dev,
- "bus %d dev num %d gpib minor %d, ni usb interface %i suspended\n",
- usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
+ dev_dbg(&usb_dev->dev,
+ "bus %d dev num %d gpib%d, interface %i suspended\n",
+ usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
}
mutex_unlock(&ni_usb_hotplug_lock);
@@ -2511,7 +2518,7 @@ static int ni_usb_driver_resume(struct usb_interface *interface)
{
struct usb_device *usb_dev = interface_to_usbdev(interface);
- gpib_board_t *board;
+ struct gpib_board *board;
int i, retval;
mutex_lock(&ni_usb_hotplug_lock);
@@ -2535,15 +2542,15 @@ static int ni_usb_driver_resume(struct usb_interface *interface)
mutex_lock(&ni_priv->interrupt_transfer_lock);
retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_KERNEL);
if (retval) {
- dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb, retval=%i\n",
- __func__, retval);
+ dev_err(&usb_dev->dev, "resume failed to resubmit interrupt urb, retval=%i\n",
+ retval);
mutex_unlock(&ni_priv->interrupt_transfer_lock);
mutex_unlock(&ni_usb_hotplug_lock);
return retval;
}
mutex_unlock(&ni_priv->interrupt_transfer_lock);
} else {
- dev_err(&usb_dev->dev, "%s: bug! int urb not set up\n", __func__);
+ dev_err(&usb_dev->dev, "bug! resume int urb not set up\n");
mutex_unlock(&ni_usb_hotplug_lock);
return -EINVAL;
}
@@ -2600,9 +2607,9 @@ static int ni_usb_driver_resume(struct usb_interface *interface)
if (ni_priv->ren_state)
ni_usb_remote_enable(board, 1);
- dev_info(&usb_dev->dev,
- "bus %d dev num %d gpib minor %d, ni usb interface %i resumed\n",
- usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
+ dev_dbg(&usb_dev->dev,
+ "bus %d dev num %d gpib%d, interface %i resumed\n",
+ usb_dev->bus->busnum, usb_dev->devnum, board->minor, i);
}
mutex_unlock(&ni_usb_hotplug_lock);
@@ -2610,7 +2617,7 @@ static int ni_usb_driver_resume(struct usb_interface *interface)
}
static struct usb_driver ni_usb_bus_driver = {
- .name = "ni_usb_gpib",
+ .name = DRV_NAME,
.probe = ni_usb_driver_probe,
.disconnect = ni_usb_driver_disconnect,
.suspend = ni_usb_driver_suspend,
@@ -2623,19 +2630,18 @@ static int __init ni_usb_init_module(void)
int i;
int ret;
- pr_info("ni_usb_gpib driver loading\n");
for (i = 0; i < MAX_NUM_NI_USB_INTERFACES; i++)
ni_usb_driver_interfaces[i] = NULL;
ret = usb_register(&ni_usb_bus_driver);
if (ret) {
- pr_err("ni_usb_gpib: usb_register failed: error = %d\n", ret);
+ pr_err("usb_register failed: error = %d\n", ret);
return ret;
}
ret = gpib_register_driver(&ni_usb_gpib_interface, THIS_MODULE);
if (ret) {
- pr_err("ni_usb_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
return ret;
}
@@ -2644,7 +2650,6 @@ static int __init ni_usb_init_module(void)
static void __exit ni_usb_exit_module(void)
{
- pr_info("ni_usb_gpib driver unloading\n");
gpib_unregister_driver(&ni_usb_gpib_interface);
usb_deregister(&ni_usb_bus_driver);
}
diff --git a/drivers/staging/gpib/pc2/pc2_gpib.c b/drivers/staging/gpib/pc2/pc2_gpib.c
index c0b07cb63d9a..96d3c09f2273 100644
--- a/drivers/staging/gpib/pc2/pc2_gpib.c
+++ b/drivers/staging/gpib/pc2/pc2_gpib.c
@@ -4,6 +4,9 @@
* copyright : (C) 2001, 2002 by Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/module.h>
@@ -49,22 +52,13 @@ static inline unsigned int CLEAR_INTR_REG(unsigned int irq)
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB driver for PC2/PC2a and compatible devices");
-static int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int pc2a_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int pc2a_cb7210_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int pc2_2a_attach(gpib_board_t *board, const gpib_board_config_t *config);
-
-static void pc2_detach(gpib_board_t *board);
-static void pc2a_detach(gpib_board_t *board);
-static void pc2_2a_detach(gpib_board_t *board);
-
/*
* GPIB interrupt service routines
*/
irqreturn_t pc2_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct pc2_priv *priv = board->private_data;
unsigned long flags;
irqreturn_t retval;
@@ -77,7 +71,7 @@ irqreturn_t pc2_interrupt(int irq, void *arg)
irqreturn_t pc2a_interrupt(int irq, void *arg)
{
- gpib_board_t *board = arg;
+ struct gpib_board *board = arg;
struct pc2_priv *priv = board->private_data;
int status1, status2;
unsigned long flags;
@@ -96,7 +90,7 @@ irqreturn_t pc2a_interrupt(int irq, void *arg)
}
// wrappers for interface functions
-static int pc2_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
+static int pc2_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
size_t *bytes_read)
{
struct pc2_priv *priv = board->private_data;
@@ -104,7 +98,7 @@ static int pc2_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *en
return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read);
}
-static int pc2_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
+static int pc2_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
size_t *bytes_written)
{
struct pc2_priv *priv = board->private_data;
@@ -112,245 +106,133 @@ static int pc2_write(gpib_board_t *board, uint8_t *buffer, size_t length, int se
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
}
-static int pc2_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int pc2_command(struct gpib_board *board, uint8_t *buffer, size_t length, size_t *bytes_written)
{
struct pc2_priv *priv = board->private_data;
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
}
-static int pc2_take_control(gpib_board_t *board, int synchronous)
+static int pc2_take_control(struct gpib_board *board, int synchronous)
{
struct pc2_priv *priv = board->private_data;
return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
}
-static int pc2_go_to_standby(gpib_board_t *board)
+static int pc2_go_to_standby(struct gpib_board *board)
{
struct pc2_priv *priv = board->private_data;
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-static void pc2_request_system_control(gpib_board_t *board, int request_control)
+static void pc2_request_system_control(struct gpib_board *board, int request_control)
{
struct pc2_priv *priv = board->private_data;
nec7210_request_system_control(board, &priv->nec7210_priv, request_control);
}
-static void pc2_interface_clear(gpib_board_t *board, int assert)
+static void pc2_interface_clear(struct gpib_board *board, int assert)
{
struct pc2_priv *priv = board->private_data;
nec7210_interface_clear(board, &priv->nec7210_priv, assert);
}
-static void pc2_remote_enable(gpib_board_t *board, int enable)
+static void pc2_remote_enable(struct gpib_board *board, int enable)
{
struct pc2_priv *priv = board->private_data;
nec7210_remote_enable(board, &priv->nec7210_priv, enable);
}
-static int pc2_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int pc2_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct pc2_priv *priv = board->private_data;
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
}
-static void pc2_disable_eos(gpib_board_t *board)
+static void pc2_disable_eos(struct gpib_board *board)
{
struct pc2_priv *priv = board->private_data;
nec7210_disable_eos(board, &priv->nec7210_priv);
}
-static unsigned int pc2_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int pc2_update_status(struct gpib_board *board, unsigned int clear_mask)
{
struct pc2_priv *priv = board->private_data;
return nec7210_update_status(board, &priv->nec7210_priv, clear_mask);
}
-static int pc2_primary_address(gpib_board_t *board, unsigned int address)
+static int pc2_primary_address(struct gpib_board *board, unsigned int address)
{
struct pc2_priv *priv = board->private_data;
return nec7210_primary_address(board, &priv->nec7210_priv, address);
}
-static int pc2_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int pc2_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct pc2_priv *priv = board->private_data;
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
}
-static int pc2_parallel_poll(gpib_board_t *board, uint8_t *result)
+static int pc2_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct pc2_priv *priv = board->private_data;
return nec7210_parallel_poll(board, &priv->nec7210_priv, result);
}
-static void pc2_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void pc2_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
struct pc2_priv *priv = board->private_data;
nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config);
}
-static void pc2_parallel_poll_response(gpib_board_t *board, int ist)
+static void pc2_parallel_poll_response(struct gpib_board *board, int ist)
{
struct pc2_priv *priv = board->private_data;
nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist);
}
-static void pc2_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void pc2_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct pc2_priv *priv = board->private_data;
nec7210_serial_poll_response(board, &priv->nec7210_priv, status);
}
-static uint8_t pc2_serial_poll_status(gpib_board_t *board)
+static uint8_t pc2_serial_poll_status(struct gpib_board *board)
{
struct pc2_priv *priv = board->private_data;
return nec7210_serial_poll_status(board, &priv->nec7210_priv);
}
-static unsigned int pc2_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int pc2_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct pc2_priv *priv = board->private_data;
return nec7210_t1_delay(board, &priv->nec7210_priv, nano_sec);
}
-static void pc2_return_to_local(gpib_board_t *board)
+static void pc2_return_to_local(struct gpib_board *board)
{
struct pc2_priv *priv = board->private_data;
nec7210_return_to_local(board, &priv->nec7210_priv);
}
-static gpib_interface_t pc2_interface = {
- .name = "pcII",
- .attach = pc2_attach,
- .detach = pc2_detach,
- .read = pc2_read,
- .write = pc2_write,
- .command = pc2_command,
- .take_control = pc2_take_control,
- .go_to_standby = pc2_go_to_standby,
- .request_system_control = pc2_request_system_control,
- .interface_clear = pc2_interface_clear,
- .remote_enable = pc2_remote_enable,
- .enable_eos = pc2_enable_eos,
- .disable_eos = pc2_disable_eos,
- .parallel_poll = pc2_parallel_poll,
- .parallel_poll_configure = pc2_parallel_poll_configure,
- .parallel_poll_response = pc2_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = NULL,
- .update_status = pc2_update_status,
- .primary_address = pc2_primary_address,
- .secondary_address = pc2_secondary_address,
- .serial_poll_response = pc2_serial_poll_response,
- .serial_poll_status = pc2_serial_poll_status,
- .t1_delay = pc2_t1_delay,
- .return_to_local = pc2_return_to_local,
-};
-
-static gpib_interface_t pc2a_interface = {
- .name = "pcIIa",
- .attach = pc2a_attach,
- .detach = pc2a_detach,
- .read = pc2_read,
- .write = pc2_write,
- .command = pc2_command,
- .take_control = pc2_take_control,
- .go_to_standby = pc2_go_to_standby,
- .request_system_control = pc2_request_system_control,
- .interface_clear = pc2_interface_clear,
- .remote_enable = pc2_remote_enable,
- .enable_eos = pc2_enable_eos,
- .disable_eos = pc2_disable_eos,
- .parallel_poll = pc2_parallel_poll,
- .parallel_poll_configure = pc2_parallel_poll_configure,
- .parallel_poll_response = pc2_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = NULL,
- .update_status = pc2_update_status,
- .primary_address = pc2_primary_address,
- .secondary_address = pc2_secondary_address,
- .serial_poll_response = pc2_serial_poll_response,
- .serial_poll_status = pc2_serial_poll_status,
- .t1_delay = pc2_t1_delay,
- .return_to_local = pc2_return_to_local,
-};
-
-static gpib_interface_t pc2a_cb7210_interface = {
- .name = "pcIIa_cb7210",
- .attach = pc2a_cb7210_attach,
- .detach = pc2a_detach,
- .read = pc2_read,
- .write = pc2_write,
- .command = pc2_command,
- .take_control = pc2_take_control,
- .go_to_standby = pc2_go_to_standby,
- .request_system_control = pc2_request_system_control,
- .interface_clear = pc2_interface_clear,
- .remote_enable = pc2_remote_enable,
- .enable_eos = pc2_enable_eos,
- .disable_eos = pc2_disable_eos,
- .parallel_poll = pc2_parallel_poll,
- .parallel_poll_configure = pc2_parallel_poll_configure,
- .parallel_poll_response = pc2_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = NULL, //XXX
- .update_status = pc2_update_status,
- .primary_address = pc2_primary_address,
- .secondary_address = pc2_secondary_address,
- .serial_poll_response = pc2_serial_poll_response,
- .serial_poll_status = pc2_serial_poll_status,
- .t1_delay = pc2_t1_delay,
- .return_to_local = pc2_return_to_local,
-};
-
-static gpib_interface_t pc2_2a_interface = {
- .name = "pcII_IIa",
- .attach = pc2_2a_attach,
- .detach = pc2_2a_detach,
- .read = pc2_read,
- .write = pc2_write,
- .command = pc2_command,
- .take_control = pc2_take_control,
- .go_to_standby = pc2_go_to_standby,
- .request_system_control = pc2_request_system_control,
- .interface_clear = pc2_interface_clear,
- .remote_enable = pc2_remote_enable,
- .enable_eos = pc2_enable_eos,
- .disable_eos = pc2_disable_eos,
- .parallel_poll = pc2_parallel_poll,
- .parallel_poll_configure = pc2_parallel_poll_configure,
- .parallel_poll_response = pc2_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = NULL,
- .update_status = pc2_update_status,
- .primary_address = pc2_primary_address,
- .secondary_address = pc2_secondary_address,
- .serial_poll_response = pc2_serial_poll_response,
- .serial_poll_status = pc2_serial_poll_status,
- .t1_delay = pc2_t1_delay,
- .return_to_local = pc2_return_to_local,
-};
-
-static int allocate_private(gpib_board_t *board)
+static int allocate_private(struct gpib_board *board)
{
struct pc2_priv *priv;
@@ -363,13 +245,13 @@ static int allocate_private(gpib_board_t *board)
return 0;
}
-static void free_private(gpib_board_t *board)
+static void free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
}
-static int pc2_generic_attach(gpib_board_t *board, const gpib_board_config_t *config,
+static int pc2_generic_attach(struct gpib_board *board, const gpib_board_config_t *config,
enum nec7210_chipset chipset)
{
struct pc2_priv *pc2_priv;
@@ -389,7 +271,8 @@ static int pc2_generic_attach(gpib_board_t *board, const gpib_board_config_t *co
* is adapted to use isa_register_driver.
*/
if (config->ibdma)
- pr_err("DMA disabled for pc2 gpib, driver needs to be adapted to use isa_register_driver to get a struct device*");
+ // driver needs to be adapted to use isa_register_driver to get a struct device*
+ dev_err(board->gpib_dev, "DMA disabled for pc2 gpib");
#else
if (config->ibdma) {
nec_priv->dma_buffer_length = 0x1000;
@@ -401,7 +284,7 @@ static int pc2_generic_attach(gpib_board_t *board, const gpib_board_config_t *co
// request isa dma channel
if (request_dma(config->ibdma, "pc2")) {
- pr_err("gpib: can't request DMA %d\n", config->ibdma);
+ dev_err(board->gpib_dev, "can't request DMA %d\n", config->ibdma);
return -1;
}
nec_priv->dma_channel = config->ibdma;
@@ -411,7 +294,7 @@ static int pc2_generic_attach(gpib_board_t *board, const gpib_board_config_t *co
return 0;
}
-int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int pc2_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
int isr_flags = 0;
struct pc2_priv *pc2_priv;
@@ -427,8 +310,8 @@ int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config)
nec_priv->offset = pc2_reg_offset;
if (!request_region(config->ibbase, pc2_iosize, "pc2")) {
- pr_err("gpib: ioports are already in use\n");
- return -1;
+ dev_err(board->gpib_dev, "ioports are already in use\n");
+ return -EBUSY;
}
nec_priv->iobase = config->ibbase;
@@ -437,14 +320,14 @@ int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config)
// install interrupt handler
if (config->ibirq) {
if (request_irq(config->ibirq, pc2_interrupt, isr_flags, "pc2", board)) {
- pr_err("gpib: can't request IRQ %d\n", config->ibirq);
- return -1;
+ dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq);
+ return -EBUSY;
}
}
pc2_priv->irq = config->ibirq;
/* poll so we can detect assertion of ATN */
if (gpib_request_pseudo_irq(board, pc2_interrupt)) {
- pr_err("pc2_gpib: failed to allocate pseudo_irq\n");
+ dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n");
return -1;
}
/* set internal counter register for 8 MHz input clock */
@@ -455,7 +338,7 @@ int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-void pc2_detach(gpib_board_t *board)
+static void pc2_detach(struct gpib_board *board)
{
struct pc2_priv *pc2_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -482,7 +365,7 @@ void pc2_detach(gpib_board_t *board)
free_private(board);
}
-static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *config,
+static int pc2a_common_attach(struct gpib_board *board, const gpib_board_config_t *config,
unsigned int num_registers, enum nec7210_chipset chipset)
{
unsigned int i, j;
@@ -505,18 +388,19 @@ static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *co
case 0x62e1:
break;
default:
- pr_err("PCIIa base range invalid, must be one of 0x[0246]2e1, but is 0x%d\n",
- config->ibbase);
+ dev_err(board->gpib_dev, "PCIIa base range invalid, must be one of 0x[0246]2e1, but is 0x%x\n",
+ config->ibbase);
return -1;
}
if (config->ibirq) {
if (config->ibirq < 2 || config->ibirq > 7) {
- pr_err("pc2_gpib: illegal interrupt level %i\n", config->ibirq);
+ dev_err(board->gpib_dev, "illegal interrupt level %i\n",
+ config->ibirq);
return -1;
}
} else {
- pr_err("pc2_gpib: interrupt disabled, using polling mode (slow)\n");
+ dev_err(board->gpib_dev, "interrupt disabled, using polling mode (slow)\n");
}
#ifdef CHECK_IOPORTS
unsigned int err = 0;
@@ -528,36 +412,36 @@ static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *co
if (config->ibirq && check_region(pc2a_clear_intr_iobase + config->ibirq, 1))
err++;
if (err) {
- pr_err("gpib: ioports are already in use");
- return -1;
+ dev_err(board->gpib_dev, "ioports are already in use");
+ return -EBUSY;
}
#endif
for (i = 0; i < num_registers; i++) {
if (!request_region(config->ibbase +
i * pc2a_reg_offset, 1, "pc2a")) {
- pr_err("gpib: ioports are already in use");
+ dev_err(board->gpib_dev, "ioports are already in use");
for (j = 0; j < i; j++)
release_region(config->ibbase +
j * pc2a_reg_offset, 1);
- return -1;
+ return -EBUSY;
}
}
nec_priv->iobase = config->ibbase;
if (config->ibirq) {
if (!request_region(pc2a_clear_intr_iobase + config->ibirq, 1, "pc2a")) {
- pr_err("gpib: ioports are already in use");
+ dev_err(board->gpib_dev, "ioports are already in use");
return -1;
}
pc2_priv->clear_intr_addr = pc2a_clear_intr_iobase + config->ibirq;
if (request_irq(config->ibirq, pc2a_interrupt, 0, "pc2a", board)) {
- pr_err("gpib: can't request IRQ %d\n", config->ibirq);
- return -1;
+ dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq);
+ return -EBUSY;
}
}
pc2_priv->irq = config->ibirq;
/* poll so we can detect assertion of ATN */
if (gpib_request_pseudo_irq(board, pc2_interrupt)) {
- pr_err("pc2_gpib: failed to allocate pseudo_irq\n");
+ dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n");
return -1;
}
@@ -575,22 +459,22 @@ static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *co
return 0;
}
-int pc2a_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int pc2a_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
return pc2a_common_attach(board, config, pc2a_iosize, NEC7210);
}
-int pc2a_cb7210_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int pc2a_cb7210_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
return pc2a_common_attach(board, config, pc2a_iosize, CB7210);
}
-int pc2_2a_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int pc2_2a_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
return pc2a_common_attach(board, config, pc2_2a_iosize, NAT4882);
}
-static void pc2a_common_detach(gpib_board_t *board, unsigned int num_registers)
+static void pc2a_common_detach(struct gpib_board *board, unsigned int num_registers)
{
int i;
struct pc2_priv *pc2_priv = board->private_data;
@@ -623,41 +507,153 @@ static void pc2a_common_detach(gpib_board_t *board, unsigned int num_registers)
free_private(board);
}
-void pc2a_detach(gpib_board_t *board)
+static void pc2a_detach(struct gpib_board *board)
{
pc2a_common_detach(board, pc2a_iosize);
}
-void pc2_2a_detach(gpib_board_t *board)
+static void pc2_2a_detach(struct gpib_board *board)
{
pc2a_common_detach(board, pc2_2a_iosize);
}
+static gpib_interface_t pc2_interface = {
+ .name = "pcII",
+ .attach = pc2_attach,
+ .detach = pc2_detach,
+ .read = pc2_read,
+ .write = pc2_write,
+ .command = pc2_command,
+ .take_control = pc2_take_control,
+ .go_to_standby = pc2_go_to_standby,
+ .request_system_control = pc2_request_system_control,
+ .interface_clear = pc2_interface_clear,
+ .remote_enable = pc2_remote_enable,
+ .enable_eos = pc2_enable_eos,
+ .disable_eos = pc2_disable_eos,
+ .parallel_poll = pc2_parallel_poll,
+ .parallel_poll_configure = pc2_parallel_poll_configure,
+ .parallel_poll_response = pc2_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = NULL,
+ .update_status = pc2_update_status,
+ .primary_address = pc2_primary_address,
+ .secondary_address = pc2_secondary_address,
+ .serial_poll_response = pc2_serial_poll_response,
+ .serial_poll_status = pc2_serial_poll_status,
+ .t1_delay = pc2_t1_delay,
+ .return_to_local = pc2_return_to_local,
+};
+
+static gpib_interface_t pc2a_interface = {
+ .name = "pcIIa",
+ .attach = pc2a_attach,
+ .detach = pc2a_detach,
+ .read = pc2_read,
+ .write = pc2_write,
+ .command = pc2_command,
+ .take_control = pc2_take_control,
+ .go_to_standby = pc2_go_to_standby,
+ .request_system_control = pc2_request_system_control,
+ .interface_clear = pc2_interface_clear,
+ .remote_enable = pc2_remote_enable,
+ .enable_eos = pc2_enable_eos,
+ .disable_eos = pc2_disable_eos,
+ .parallel_poll = pc2_parallel_poll,
+ .parallel_poll_configure = pc2_parallel_poll_configure,
+ .parallel_poll_response = pc2_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = NULL,
+ .update_status = pc2_update_status,
+ .primary_address = pc2_primary_address,
+ .secondary_address = pc2_secondary_address,
+ .serial_poll_response = pc2_serial_poll_response,
+ .serial_poll_status = pc2_serial_poll_status,
+ .t1_delay = pc2_t1_delay,
+ .return_to_local = pc2_return_to_local,
+};
+
+static gpib_interface_t pc2a_cb7210_interface = {
+ .name = "pcIIa_cb7210",
+ .attach = pc2a_cb7210_attach,
+ .detach = pc2a_detach,
+ .read = pc2_read,
+ .write = pc2_write,
+ .command = pc2_command,
+ .take_control = pc2_take_control,
+ .go_to_standby = pc2_go_to_standby,
+ .request_system_control = pc2_request_system_control,
+ .interface_clear = pc2_interface_clear,
+ .remote_enable = pc2_remote_enable,
+ .enable_eos = pc2_enable_eos,
+ .disable_eos = pc2_disable_eos,
+ .parallel_poll = pc2_parallel_poll,
+ .parallel_poll_configure = pc2_parallel_poll_configure,
+ .parallel_poll_response = pc2_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = NULL, //XXX
+ .update_status = pc2_update_status,
+ .primary_address = pc2_primary_address,
+ .secondary_address = pc2_secondary_address,
+ .serial_poll_response = pc2_serial_poll_response,
+ .serial_poll_status = pc2_serial_poll_status,
+ .t1_delay = pc2_t1_delay,
+ .return_to_local = pc2_return_to_local,
+};
+
+static gpib_interface_t pc2_2a_interface = {
+ .name = "pcII_IIa",
+ .attach = pc2_2a_attach,
+ .detach = pc2_2a_detach,
+ .read = pc2_read,
+ .write = pc2_write,
+ .command = pc2_command,
+ .take_control = pc2_take_control,
+ .go_to_standby = pc2_go_to_standby,
+ .request_system_control = pc2_request_system_control,
+ .interface_clear = pc2_interface_clear,
+ .remote_enable = pc2_remote_enable,
+ .enable_eos = pc2_enable_eos,
+ .disable_eos = pc2_disable_eos,
+ .parallel_poll = pc2_parallel_poll,
+ .parallel_poll_configure = pc2_parallel_poll_configure,
+ .parallel_poll_response = pc2_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = NULL,
+ .update_status = pc2_update_status,
+ .primary_address = pc2_primary_address,
+ .secondary_address = pc2_secondary_address,
+ .serial_poll_response = pc2_serial_poll_response,
+ .serial_poll_status = pc2_serial_poll_status,
+ .t1_delay = pc2_t1_delay,
+ .return_to_local = pc2_return_to_local,
+};
+
static int __init pc2_init_module(void)
{
int ret;
ret = gpib_register_driver(&pc2_interface, THIS_MODULE);
if (ret) {
- pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
return ret;
}
ret = gpib_register_driver(&pc2a_interface, THIS_MODULE);
if (ret) {
- pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pc2a;
}
ret = gpib_register_driver(&pc2a_cb7210_interface, THIS_MODULE);
if (ret) {
- pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_cb7210;
}
ret = gpib_register_driver(&pc2_2a_interface, THIS_MODULE);
if (ret) {
- pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret);
+ pr_err("gpib_register_driver failed: error = %d\n", ret);
goto err_pc2_2a;
}
diff --git a/drivers/staging/gpib/tms9914/tms9914.c b/drivers/staging/gpib/tms9914/tms9914.c
index ec8e1d4d762f..2abda9d7dfcb 100644
--- a/drivers/staging/gpib/tms9914/tms9914.c
+++ b/drivers/staging/gpib/tms9914/tms9914.c
@@ -4,6 +4,9 @@
* copyright : (C) 2001, 2002 by Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/module.h>
@@ -24,9 +27,9 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB library for tms9914");
-static unsigned int update_status_nolock(gpib_board_t *board, struct tms9914_priv *priv);
+static unsigned int update_status_nolock(struct gpib_board *board, struct tms9914_priv *priv);
-int tms9914_take_control(gpib_board_t *board, struct tms9914_priv *priv, int synchronous)
+int tms9914_take_control(struct gpib_board *board, struct tms9914_priv *priv, int synchronous)
{
int i;
const int timeout = 100;
@@ -63,7 +66,7 @@ EXPORT_SYMBOL_GPL(tms9914_take_control);
* The rest of the tms9914 based drivers still use tms9914_take_control
* directly (which does issue tcs).
*/
-int tms9914_take_control_workaround(gpib_board_t *board, struct tms9914_priv *priv, int synchronous)
+int tms9914_take_control_workaround(struct gpib_board *board, struct tms9914_priv *priv, int synchronous)
{
if (synchronous)
return -ETIMEDOUT;
@@ -71,7 +74,7 @@ int tms9914_take_control_workaround(gpib_board_t *board, struct tms9914_priv *pr
}
EXPORT_SYMBOL_GPL(tms9914_take_control_workaround);
-int tms9914_go_to_standby(gpib_board_t *board, struct tms9914_priv *priv)
+int tms9914_go_to_standby(struct gpib_board *board, struct tms9914_priv *priv)
{
int i;
const int timeout = 1000;
@@ -83,10 +86,8 @@ int tms9914_go_to_standby(gpib_board_t *board, struct tms9914_priv *priv)
break;
udelay(1);
}
- if (i == timeout) {
- pr_err("error waiting for NATN\n");
+ if (i == timeout)
return -ETIMEDOUT;
- }
clear_bit(COMMAND_READY_BN, &priv->state);
@@ -94,7 +95,7 @@ int tms9914_go_to_standby(gpib_board_t *board, struct tms9914_priv *priv)
}
EXPORT_SYMBOL_GPL(tms9914_go_to_standby);
-void tms9914_interface_clear(gpib_board_t *board, struct tms9914_priv *priv, int assert)
+void tms9914_interface_clear(struct gpib_board *board, struct tms9914_priv *priv, int assert)
{
if (assert) {
write_byte(priv, AUX_SIC | AUX_CS, AUXCR);
@@ -106,7 +107,7 @@ void tms9914_interface_clear(gpib_board_t *board, struct tms9914_priv *priv, int
}
EXPORT_SYMBOL_GPL(tms9914_interface_clear);
-void tms9914_remote_enable(gpib_board_t *board, struct tms9914_priv *priv, int enable)
+void tms9914_remote_enable(struct gpib_board *board, struct tms9914_priv *priv, int enable)
{
if (enable)
write_byte(priv, AUX_SRE | AUX_CS, AUXCR);
@@ -115,7 +116,7 @@ void tms9914_remote_enable(gpib_board_t *board, struct tms9914_priv *priv, int e
}
EXPORT_SYMBOL_GPL(tms9914_remote_enable);
-void tms9914_request_system_control(gpib_board_t *board, struct tms9914_priv *priv,
+void tms9914_request_system_control(struct gpib_board *board, struct tms9914_priv *priv,
int request_control)
{
if (request_control) {
@@ -127,7 +128,7 @@ void tms9914_request_system_control(gpib_board_t *board, struct tms9914_priv *pr
}
EXPORT_SYMBOL_GPL(tms9914_request_system_control);
-unsigned int tms9914_t1_delay(gpib_board_t *board, struct tms9914_priv *priv,
+unsigned int tms9914_t1_delay(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int nano_sec)
{
static const int clock_period = 200; // assuming 5Mhz input clock
@@ -153,7 +154,7 @@ unsigned int tms9914_t1_delay(gpib_board_t *board, struct tms9914_priv *priv,
}
EXPORT_SYMBOL_GPL(tms9914_t1_delay);
-void tms9914_return_to_local(const gpib_board_t *board, struct tms9914_priv *priv)
+void tms9914_return_to_local(const struct gpib_board *board, struct tms9914_priv *priv)
{
write_byte(priv, AUX_RTL, AUXCR);
}
@@ -175,7 +176,7 @@ void tms9914_set_holdoff_mode(struct tms9914_priv *priv, enum tms9914_holdoff_mo
write_byte(priv, AUX_HLDA | AUX_CS, AUXCR);
break;
default:
- pr_err("%s: bug! bad holdoff mode %i\n", __func__, mode);
+ pr_err("bug! bad holdoff mode %i\n", mode);
break;
}
priv->holdoff_mode = mode;
@@ -191,7 +192,7 @@ void tms9914_release_holdoff(struct tms9914_priv *priv)
}
EXPORT_SYMBOL_GPL(tms9914_release_holdoff);
-int tms9914_enable_eos(gpib_board_t *board, struct tms9914_priv *priv, uint8_t eos_byte,
+int tms9914_enable_eos(struct gpib_board *board, struct tms9914_priv *priv, uint8_t eos_byte,
int compare_8_bits)
{
priv->eos = eos_byte;
@@ -202,13 +203,13 @@ int tms9914_enable_eos(gpib_board_t *board, struct tms9914_priv *priv, uint8_t e
}
EXPORT_SYMBOL(tms9914_enable_eos);
-void tms9914_disable_eos(gpib_board_t *board, struct tms9914_priv *priv)
+void tms9914_disable_eos(struct gpib_board *board, struct tms9914_priv *priv)
{
priv->eos_flags &= ~REOS;
}
EXPORT_SYMBOL(tms9914_disable_eos);
-int tms9914_parallel_poll(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *result)
+int tms9914_parallel_poll(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *result)
{
// execute parallel poll
write_byte(priv, AUX_CS | AUX_RPP, AUXCR);
@@ -233,7 +234,7 @@ static void set_ppoll_reg(struct tms9914_priv *priv, int enable,
}
}
-void tms9914_parallel_poll_configure(gpib_board_t *board,
+void tms9914_parallel_poll_configure(struct gpib_board *board,
struct tms9914_priv *priv, uint8_t config)
{
priv->ppoll_enable = (config & PPC_DISABLE) == 0;
@@ -243,14 +244,14 @@ void tms9914_parallel_poll_configure(gpib_board_t *board,
}
EXPORT_SYMBOL(tms9914_parallel_poll_configure);
-void tms9914_parallel_poll_response(gpib_board_t *board,
+void tms9914_parallel_poll_response(struct gpib_board *board,
struct tms9914_priv *priv, int ist)
{
set_ppoll_reg(priv, priv->ppoll_enable, priv->ppoll_line, priv->ppoll_sense, ist);
}
EXPORT_SYMBOL(tms9914_parallel_poll_response);
-void tms9914_serial_poll_response(gpib_board_t *board, struct tms9914_priv *priv, uint8_t status)
+void tms9914_serial_poll_response(struct gpib_board *board, struct tms9914_priv *priv, uint8_t status)
{
unsigned long flags;
@@ -265,7 +266,7 @@ void tms9914_serial_poll_response(gpib_board_t *board, struct tms9914_priv *priv
}
EXPORT_SYMBOL(tms9914_serial_poll_response);
-uint8_t tms9914_serial_poll_status(gpib_board_t *board, struct tms9914_priv *priv)
+uint8_t tms9914_serial_poll_status(struct gpib_board *board, struct tms9914_priv *priv)
{
u8 status;
unsigned long flags;
@@ -278,7 +279,7 @@ uint8_t tms9914_serial_poll_status(gpib_board_t *board, struct tms9914_priv *pri
}
EXPORT_SYMBOL(tms9914_serial_poll_status);
-int tms9914_primary_address(gpib_board_t *board, struct tms9914_priv *priv, unsigned int address)
+int tms9914_primary_address(struct gpib_board *board, struct tms9914_priv *priv, unsigned int address)
{
// put primary address in address0
write_byte(priv, address & ADDRESS_MASK, ADR);
@@ -286,7 +287,7 @@ int tms9914_primary_address(gpib_board_t *board, struct tms9914_priv *priv, unsi
}
EXPORT_SYMBOL(tms9914_primary_address);
-int tms9914_secondary_address(gpib_board_t *board, struct tms9914_priv *priv,
+int tms9914_secondary_address(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int address, int enable)
{
if (enable)
@@ -299,7 +300,7 @@ int tms9914_secondary_address(gpib_board_t *board, struct tms9914_priv *priv,
}
EXPORT_SYMBOL(tms9914_secondary_address);
-unsigned int tms9914_update_status(gpib_board_t *board, struct tms9914_priv *priv,
+unsigned int tms9914_update_status(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int clear_mask)
{
unsigned long flags;
@@ -341,7 +342,7 @@ static void update_listener_state(struct tms9914_priv *priv, unsigned int addres
}
}
-static unsigned int update_status_nolock(gpib_board_t *board, struct tms9914_priv *priv)
+static unsigned int update_status_nolock(struct gpib_board *board, struct tms9914_priv *priv)
{
int address_status;
int bsr_bits;
@@ -387,29 +388,29 @@ static unsigned int update_status_nolock(gpib_board_t *board, struct tms9914_pri
return board->status;
}
-int tms9914_line_status(const gpib_board_t *board, struct tms9914_priv *priv)
+int tms9914_line_status(const struct gpib_board *board, struct tms9914_priv *priv)
{
int bsr_bits;
- int status = ValidALL;
+ int status = VALID_ALL;
bsr_bits = read_byte(priv, BSR);
if (bsr_bits & BSR_REN_BIT)
- status |= BusREN;
+ status |= BUS_REN;
if (bsr_bits & BSR_IFC_BIT)
- status |= BusIFC;
+ status |= BUS_IFC;
if (bsr_bits & BSR_SRQ_BIT)
- status |= BusSRQ;
+ status |= BUS_SRQ;
if (bsr_bits & BSR_EOI_BIT)
- status |= BusEOI;
+ status |= BUS_EOI;
if (bsr_bits & BSR_NRFD_BIT)
- status |= BusNRFD;
+ status |= BUS_NRFD;
if (bsr_bits & BSR_NDAC_BIT)
- status |= BusNDAC;
+ status |= BUS_NDAC;
if (bsr_bits & BSR_DAV_BIT)
- status |= BusDAV;
+ status |= BUS_DAV;
if (bsr_bits & BSR_ATN_BIT)
- status |= BusATN;
+ status |= BUS_ATN;
return status;
}
@@ -432,15 +433,14 @@ static int check_for_eos(struct tms9914_priv *priv, uint8_t byte)
return 0;
}
-static int wait_for_read_byte(gpib_board_t *board, struct tms9914_priv *priv)
+static int wait_for_read_byte(struct gpib_board *board, struct tms9914_priv *priv)
{
if (wait_event_interruptible(board->wait,
test_bit(READ_READY_BN, &priv->state) ||
test_bit(DEV_CLEAR_BN, &priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- pr_debug("gpib: pio read wait interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
return -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
return -ETIMEDOUT;
@@ -449,7 +449,7 @@ static int wait_for_read_byte(gpib_board_t *board, struct tms9914_priv *priv)
return 0;
}
-static inline uint8_t tms9914_read_data_in(gpib_board_t *board, struct tms9914_priv *priv, int *end)
+static inline uint8_t tms9914_read_data_in(struct gpib_board *board, struct tms9914_priv *priv, int *end)
{
unsigned long flags;
u8 data;
@@ -472,7 +472,7 @@ static inline uint8_t tms9914_read_data_in(gpib_board_t *board, struct tms9914_p
case TMS9914_HOLDOFF_NONE:
break;
default:
- pr_err("%s: bug! bad holdoff mode %i\n", __func__, priv->holdoff_mode);
+ dev_err(board->gpib_dev, "bug! bad holdoff mode %i\n", priv->holdoff_mode);
break;
}
spin_unlock_irqrestore(&board->spinlock, flags);
@@ -480,7 +480,7 @@ static inline uint8_t tms9914_read_data_in(gpib_board_t *board, struct tms9914_p
return data;
}
-static int pio_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer,
+static int pio_read(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
ssize_t retval = 0;
@@ -501,7 +501,7 @@ static int pio_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buf
return retval;
}
-int tms9914_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer,
+int tms9914_read(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer,
size_t length, int *end, size_t *bytes_read)
{
ssize_t retval = 0;
@@ -541,17 +541,16 @@ int tms9914_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer
}
EXPORT_SYMBOL(tms9914_read);
-static int pio_write_wait(gpib_board_t *board, struct tms9914_priv *priv)
+static int pio_write_wait(struct gpib_board *board, struct tms9914_priv *priv)
{
// wait until next byte is ready to be sent
if (wait_event_interruptible(board->wait,
test_bit(WRITE_READY_BN, &priv->state) ||
test_bit(BUS_ERROR_BN, &priv->state) ||
test_bit(DEV_CLEAR_BN, &priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted!\n");
+ test_bit(TIMO_NUM, &board->status)))
return -ERESTARTSYS;
- }
+
if (test_bit(TIMO_NUM, &board->status))
return -ETIMEDOUT;
if (test_bit(BUS_ERROR_BN, &priv->state))
@@ -562,7 +561,7 @@ static int pio_write_wait(gpib_board_t *board, struct tms9914_priv *priv)
return 0;
}
-static int pio_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer,
+static int pio_write(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer,
size_t length, size_t *bytes_written)
{
ssize_t retval = 0;
@@ -586,7 +585,7 @@ static int pio_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *bu
return length;
}
-int tms9914_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, size_t length,
+int tms9914_write(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, size_t length,
int send_eoi, size_t *bytes_written)
{
ssize_t retval = 0;
@@ -621,7 +620,7 @@ int tms9914_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffe
}
EXPORT_SYMBOL(tms9914_write);
-static void check_my_address_state(gpib_board_t *board, struct tms9914_priv *priv, int cmd_byte)
+static void check_my_address_state(struct gpib_board *board, struct tms9914_priv *priv, int cmd_byte)
{
if (cmd_byte == MLA(board->pad)) {
priv->primary_listen_addressed = 1;
@@ -656,7 +655,7 @@ static void check_my_address_state(gpib_board_t *board, struct tms9914_priv *pri
}
}
-int tms9914_command(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer,
+int tms9914_command(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer,
size_t length, size_t *bytes_written)
{
int retval = 0;
@@ -667,10 +666,8 @@ int tms9914_command(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *bu
if (wait_event_interruptible(board->wait,
test_bit(COMMAND_READY_BN,
&priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- pr_debug("gpib command wait interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
break;
- }
if (test_bit(TIMO_NUM, &board->status))
break;
@@ -695,7 +692,7 @@ int tms9914_command(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *bu
}
EXPORT_SYMBOL(tms9914_command);
-irqreturn_t tms9914_interrupt(gpib_board_t *board, struct tms9914_priv *priv)
+irqreturn_t tms9914_interrupt(struct gpib_board *board, struct tms9914_priv *priv)
{
int status0, status1;
@@ -706,7 +703,7 @@ irqreturn_t tms9914_interrupt(gpib_board_t *board, struct tms9914_priv *priv)
}
EXPORT_SYMBOL(tms9914_interrupt);
-irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, struct tms9914_priv *priv,
+irqreturn_t tms9914_interrupt_have_status(struct gpib_board *board, struct tms9914_priv *priv,
int status0, int status1)
{
// record reception of END
@@ -761,8 +758,6 @@ irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, struct tms9914_pr
write_byte(priv, AUX_INVAL, AUXCR);
}
} else {
- // printk("tms9914: unrecognized gpib command pass thru 0x%x\n",
- // command_byte);
// clear dac holdoff
write_byte(priv, AUX_INVAL, AUXCR);
}
@@ -799,7 +794,7 @@ irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, struct tms9914_pr
// check for being addressed with secondary addressing
if (status1 & HR_APT) {
if (board->sad < 0)
- pr_err("tms9914: bug, APT interrupt without secondary addressing?\n");
+ dev_err(board->gpib_dev, "bug, APT interrupt without secondary addressing?\n");
if ((read_byte(priv, CPTR) & gpib_command_mask) == MSA(board->sad))
write_byte(priv, AUX_VAL, AUXCR);
else
@@ -807,8 +802,8 @@ irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, struct tms9914_pr
}
if ((status0 & priv->imr0_bits) || (status1 & priv->imr1_bits)) {
-// dev_dbg(board->gpib_dev, "isr0 0x%x, imr0 0x%x, isr1 0x%x, imr1 0x%x\n",
-// status0, priv->imr0_bits, status1, priv->imr1_bits);
+ dev_dbg(board->gpib_dev, "isr0 0x%x, imr0 0x%x, isr1 0x%x, imr1 0x%x\n",
+ status0, priv->imr0_bits, status1, priv->imr1_bits);
update_status_nolock(board, priv);
wake_up_interruptible(&board->wait);
}
@@ -842,7 +837,7 @@ void tms9914_board_reset(struct tms9914_priv *priv)
}
EXPORT_SYMBOL_GPL(tms9914_board_reset);
-void tms9914_online(gpib_board_t *board, struct tms9914_priv *priv)
+void tms9914_online(struct gpib_board *board, struct tms9914_priv *priv)
{
/* set GPIB address */
tms9914_primary_address(board, priv, board->pad);
diff --git a/drivers/staging/gpib/tnt4882/Makefile b/drivers/staging/gpib/tnt4882/Makefile
index a3c3fb96d5ed..fa1687ad0d1b 100644
--- a/drivers/staging/gpib/tnt4882/Makefile
+++ b/drivers/staging/gpib/tnt4882/Makefile
@@ -1,4 +1,3 @@
-ccflags-$(CONFIG_GPIB_PCMCIA) := -DGPIB_PCMCIA
obj-$(CONFIG_GPIB_NI_PCI_ISA) += tnt4882.o
tnt4882-objs := tnt4882_gpib.o mite.o
diff --git a/drivers/staging/gpib/tnt4882/mite.c b/drivers/staging/gpib/tnt4882/mite.c
index ea64dde46bcb..847b96f411bd 100644
--- a/drivers/staging/gpib/tnt4882/mite.c
+++ b/drivers/staging/gpib/tnt4882/mite.c
@@ -88,7 +88,6 @@ int mite_setup(struct mite_struct *mite)
pr_err("mite: failed to remap mite io memory address.\n");
return -ENOMEM;
}
- pr_info("mite: 0x%08lx mapped to %p\n", mite->mite_phys_addr, mite->mite_io_addr);
addr = pci_resource_start(mite->pcidev, 1);
mite->daq_phys_addr = addr;
mite->daq_io_addr = ioremap(mite->daq_phys_addr, pci_resource_len(mite->pcidev, 1));
@@ -96,7 +95,6 @@ int mite_setup(struct mite_struct *mite)
pr_err("mite: failed to remap daq io memory address.\n");
return -ENOMEM;
}
- pr_info("mite: daq: 0x%08lx mapped to %p\n", mite->daq_phys_addr, mite->daq_io_addr);
writel(mite->daq_phys_addr | WENAB, mite->mite_io_addr + MITE_IODWBSR);
mite->used = 1;
return 0;
@@ -133,18 +131,3 @@ void mite_unsetup(struct mite_struct *mite)
}
mite->used = 0;
}
-
-void mite_list_devices(void)
-{
- struct mite_struct *mite, *next;
-
- pr_info("Available NI PCI device IDs:");
- if (mite_devices)
- for (mite = mite_devices; mite; mite = next) {
- next = mite->next;
- pr_info(" 0x%04x", mite_device_id(mite));
- if (mite->used)
- pr_info("(used)");
- }
- pr_info("\n");
-}
diff --git a/drivers/staging/gpib/tnt4882/tnt4882_gpib.c b/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
index b39ab2abe495..c35b084b6fd0 100644
--- a/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
+++ b/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
@@ -5,6 +5,10 @@
* copyright : (C) 2001, 2002 by Frank Mori Hess
***************************************************************************/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define dev_fmt pr_fmt
+#define DRV_NAME KBUILD_MODNAME
+
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/module.h>
@@ -47,49 +51,7 @@ struct tnt4882_priv {
unsigned short auxg_bits; // bits written to auxiliary register G
};
-// interface functions
-static int tnt4882_read(gpib_board_t *board, uint8_t *buffer, size_t length,
- int *end, size_t *bytes_read);
-static int tnt4882_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length,
- int *end, size_t *bytes_read);
-static int tnt4882_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written);
-static int tnt4882_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,
- int send_eoi, size_t *bytes_written);
-static int tnt4882_command(gpib_board_t *board, uint8_t *buffer, size_t length,
- size_t *bytes_written);
-static int tnt4882_command_unaccel(gpib_board_t *board, uint8_t *buffer,
- size_t length, size_t *bytes_written);
-static int tnt4882_take_control(gpib_board_t *board, int synchronous);
-static int tnt4882_go_to_standby(gpib_board_t *board);
-static void tnt4882_request_system_control(gpib_board_t *board, int request_control);
-static void tnt4882_interface_clear(gpib_board_t *board, int assert);
-static void tnt4882_remote_enable(gpib_board_t *board, int enable);
-static int tnt4882_enable_eos(gpib_board_t *board, uint8_t eos_byte, int
- compare_8_bits);
-static void tnt4882_disable_eos(gpib_board_t *board);
-static unsigned int tnt4882_update_status(gpib_board_t *board, unsigned int clear_mask);
-static int tnt4882_primary_address(gpib_board_t *board, unsigned int address);
-static int tnt4882_secondary_address(gpib_board_t *board, unsigned int address,
- int enable);
-static int tnt4882_parallel_poll(gpib_board_t *board, uint8_t *result);
-static void tnt4882_parallel_poll_configure(gpib_board_t *board, uint8_t config);
-static void tnt4882_parallel_poll_response(gpib_board_t *board, int ist);
-static void tnt4882_serial_poll_response(gpib_board_t *board, uint8_t status);
-static uint8_t tnt4882_serial_poll_status(gpib_board_t *board);
-static int tnt4882_line_status(const gpib_board_t *board);
-static unsigned int tnt4882_t1_delay(gpib_board_t *board, unsigned int nano_sec);
-static void tnt4882_return_to_local(gpib_board_t *board);
-
-// interrupt service routines
-static irqreturn_t tnt4882_internal_interrupt(gpib_board_t *board);
-static irqreturn_t tnt4882_interrupt(int irq, void *arg);
-
-// utility functions
-static int tnt4882_allocate_private(gpib_board_t *board);
-static void tnt4882_free_private(gpib_board_t *board);
-static void tnt4882_init(struct tnt4882_priv *tnt_priv, const gpib_board_t *board);
-static void tnt4882_board_reset(struct tnt4882_priv *tnt_priv, gpib_board_t *board);
+static irqreturn_t tnt4882_internal_interrupt(struct gpib_board *board);
// register offset for nec7210 compatible registers
static const int atgpib_reg_offset = 2;
@@ -139,7 +101,6 @@ static inline unsigned short tnt_readb(struct tnt4882_priv *priv, unsigned long
retval = 0;
break;
default:
- pr_err("tnt4882: bug! unsupported ni_chipset\n");
retval = 0;
break;
}
@@ -174,7 +135,6 @@ static inline void tnt_writeb(struct tnt4882_priv *priv, unsigned short value, u
case NEC7210:
break;
default:
- pr_err("tnt4882: bug! unsupported ni_chipset\n");
break;
}
break;
@@ -188,9 +148,9 @@ static inline void tnt_writeb(struct tnt4882_priv *priv, unsigned short value, u
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GPIB driver for National Instruments boards using tnt4882 or compatible chips");
-int tnt4882_line_status(const gpib_board_t *board)
+static int tnt4882_line_status(const struct gpib_board *board)
{
- int status = ValidALL;
+ int status = VALID_ALL;
int bcsr_bits;
struct tnt4882_priv *tnt_priv;
@@ -199,26 +159,26 @@ int tnt4882_line_status(const gpib_board_t *board)
bcsr_bits = tnt_readb(tnt_priv, BSR);
if (bcsr_bits & BCSR_REN_BIT)
- status |= BusREN;
+ status |= BUS_REN;
if (bcsr_bits & BCSR_IFC_BIT)
- status |= BusIFC;
+ status |= BUS_IFC;
if (bcsr_bits & BCSR_SRQ_BIT)
- status |= BusSRQ;
+ status |= BUS_SRQ;
if (bcsr_bits & BCSR_EOI_BIT)
- status |= BusEOI;
+ status |= BUS_EOI;
if (bcsr_bits & BCSR_NRFD_BIT)
- status |= BusNRFD;
+ status |= BUS_NRFD;
if (bcsr_bits & BCSR_NDAC_BIT)
- status |= BusNDAC;
+ status |= BUS_NDAC;
if (bcsr_bits & BCSR_DAV_BIT)
- status |= BusDAV;
+ status |= BUS_DAV;
if (bcsr_bits & BCSR_ATN_BIT)
- status |= BusATN;
+ status |= BUS_ATN;
return status;
}
-unsigned int tnt4882_t1_delay(gpib_board_t *board, unsigned int nano_sec)
+static int tnt4882_t1_delay(struct gpib_board *board, unsigned int nano_sec)
{
struct tnt4882_priv *tnt_priv = board->private_data;
struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv;
@@ -291,7 +251,7 @@ static int drain_fifo_words(struct tnt4882_priv *tnt_priv, uint8_t *buffer, int
return count;
}
-static void tnt4882_release_holdoff(gpib_board_t *board, struct tnt4882_priv *tnt_priv)
+static void tnt4882_release_holdoff(struct gpib_board *board, struct tnt4882_priv *tnt_priv)
{
struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv;
unsigned short sasr_bits;
@@ -314,8 +274,8 @@ static void tnt4882_release_holdoff(gpib_board_t *board, struct tnt4882_priv *tn
}
}
-int tnt4882_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
- size_t *bytes_read)
+static int tnt4882_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
+ size_t *bytes_read)
{
size_t count = 0;
ssize_t retval = 0;
@@ -368,22 +328,18 @@ int tnt4882_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(ADR_CHANGE_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_err("tnt4882: read interrupted\n");
retval = -ERESTARTSYS;
break;
}
if (test_bit(TIMO_NUM, &board->status)) {
- //pr_info("tnt4882: minor %i read timed out\n", board->minor);
retval = -ETIMEDOUT;
break;
}
if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) {
- pr_err("tnt4882: device clear interrupted read\n");
retval = -EINTR;
break;
}
if (test_bit(ADR_CHANGE_BN, &nec_priv->state)) {
- pr_err("tnt4882: address change interrupted read\n");
retval = -EINTR;
break;
}
@@ -410,20 +366,14 @@ int tnt4882_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
test_bit(ADR_CHANGE_BN, &nec_priv->state) ||
test_bit(TIMO_NUM, &board->status))) {
- pr_err("tnt4882: read interrupted\n");
retval = -ERESTARTSYS;
}
if (test_bit(TIMO_NUM, &board->status))
- //pr_info("tnt4882: read timed out\n");
retval = -ETIMEDOUT;
- if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) {
- pr_err("tnt4882: device clear interrupted read\n");
+ if (test_bit(DEV_CLEAR_BN, &nec_priv->state))
retval = -EINTR;
- }
- if (test_bit(ADR_CHANGE_BN, &nec_priv->state)) {
- pr_err("tnt4882: address change interrupted read\n");
+ if (test_bit(ADR_CHANGE_BN, &nec_priv->state))
retval = -EINTR;
- }
count += drain_fifo_words(tnt_priv, &buffer[count], length - count);
if (fifo_byte_available(tnt_priv) && count < length)
buffer[count++] = tnt_readb(tnt_priv, FIFOB);
@@ -476,7 +426,7 @@ static unsigned int tnt_transfer_count(struct tnt4882_priv *tnt_priv)
return -count;
};
-static int write_wait(gpib_board_t *board, struct tnt4882_priv *tnt_priv,
+static int write_wait(struct gpib_board *board, struct tnt4882_priv *tnt_priv,
int wait_for_done, int send_commands)
{
struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv;
@@ -486,26 +436,19 @@ static int write_wait(gpib_board_t *board, struct tnt4882_priv *tnt_priv,
fifo_xfer_done(tnt_priv) ||
test_bit(BUS_ERROR_BN, &nec_priv->state) ||
test_bit(DEV_CLEAR_BN, &nec_priv->state) ||
- test_bit(TIMO_NUM, &board->status))) {
- dev_dbg(board->gpib_dev, "gpib write interrupted\n");
+ test_bit(TIMO_NUM, &board->status)))
return -ERESTARTSYS;
- }
- if (test_bit(TIMO_NUM, &board->status)) {
- pr_info("tnt4882: write timed out\n");
+
+ if (test_bit(TIMO_NUM, &board->status))
return -ETIMEDOUT;
- }
- if (test_and_clear_bit(BUS_ERROR_BN, &nec_priv->state)) {
- pr_err("tnt4882: write bus error\n");
+ if (test_and_clear_bit(BUS_ERROR_BN, &nec_priv->state))
return (send_commands) ? -ENOTCONN : -ECOMM;
- }
- if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) {
- pr_err("tnt4882: device clear interrupted write\n");
+ if (test_bit(DEV_CLEAR_BN, &nec_priv->state))
return -EINTR;
- }
return 0;
}
-static int generic_write(gpib_board_t *board, uint8_t *buffer, size_t length,
+static int generic_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int send_eoi, int send_commands, size_t *bytes_written)
{
size_t count = 0;
@@ -596,18 +539,19 @@ static int generic_write(gpib_board_t *board, uint8_t *buffer, size_t length,
return retval;
}
-int tnt4882_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
+static int tnt4882_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
+ size_t *bytes_written)
{
return generic_write(board, buffer, length, send_eoi, 0, bytes_written);
}
-int tnt4882_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
+static int tnt4882_command(struct gpib_board *board, uint8_t *buffer, size_t length,
+ size_t *bytes_written)
{
return generic_write(board, buffer, length, 0, 1, bytes_written);
}
-irqreturn_t tnt4882_internal_interrupt(gpib_board_t *board)
+static irqreturn_t tnt4882_internal_interrupt(struct gpib_board *board)
{
struct tnt4882_priv *priv = board->private_data;
int isr0_bits, isr3_bits, imr3_bits;
@@ -633,7 +577,7 @@ irqreturn_t tnt4882_internal_interrupt(gpib_board_t *board)
if (isr3_bits & HR_DONE)
priv->imr3_bits &= ~HR_DONE;
if (isr3_bits & (HR_INTR | HR_TLCI)) {
- dev_dbg(board->gpib_dev, "tnt4882: minor %i isr0 0x%x imr0 0x%x isr3 0x%x imr3 0x%x\n",
+ dev_dbg(board->gpib_dev, "minor %i isr0 0x%x imr0 0x%x isr3 0x%x imr3 0x%x\n",
board->minor, isr0_bits, priv->imr0_bits, isr3_bits, imr3_bits);
tnt_writeb(priv, priv->imr3_bits, IMR3);
wake_up_interruptible(&board->wait);
@@ -642,28 +586,14 @@ irqreturn_t tnt4882_internal_interrupt(gpib_board_t *board)
return IRQ_HANDLED;
}
-irqreturn_t tnt4882_interrupt(int irq, void *arg)
+static irqreturn_t tnt4882_interrupt(int irq, void *arg)
{
return tnt4882_internal_interrupt(arg);
}
-static int ni_tnt_isa_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int ni_nat4882_isa_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int ni_nec_isa_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config);
-
-static void ni_isa_detach(gpib_board_t *board);
-static void ni_pci_detach(gpib_board_t *board);
-
-#ifdef GPIB_PCMCIA
-static int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static void ni_pcmcia_detach(gpib_board_t *board);
-static int init_ni_gpib_cs(void);
-static void __exit exit_ni_gpib_cs(void);
-#endif
-
// wrappers for interface functions
-int tnt4882_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read)
+static int tnt4882_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end,
+ size_t *bytes_read)
{
struct tnt4882_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -682,37 +612,37 @@ int tnt4882_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end,
return retval;
}
-int tnt4882_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi,
- size_t *bytes_written)
+static int tnt4882_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi,
+ size_t *bytes_written)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
}
-int tnt4882_command_unaccel(gpib_board_t *board, uint8_t *buffer,
- size_t length, size_t *bytes_written)
+static int tnt4882_command_unaccel(struct gpib_board *board, uint8_t *buffer,
+ size_t length, size_t *bytes_written)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
}
-int tnt4882_take_control(gpib_board_t *board, int synchronous)
+static int tnt4882_take_control(struct gpib_board *board, int synchronous)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
}
-int tnt4882_go_to_standby(gpib_board_t *board)
+static int tnt4882_go_to_standby(struct gpib_board *board)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-void tnt4882_request_system_control(gpib_board_t *board, int request_control)
+static void tnt4882_request_system_control(struct gpib_board *board, int request_control)
{
struct tnt4882_priv *priv = board->private_data;
@@ -727,44 +657,43 @@ void tnt4882_request_system_control(gpib_board_t *board, int request_control)
}
}
-void tnt4882_interface_clear(gpib_board_t *board, int assert)
+static void tnt4882_interface_clear(struct gpib_board *board, int assert)
{
struct tnt4882_priv *priv = board->private_data;
nec7210_interface_clear(board, &priv->nec7210_priv, assert);
}
-void tnt4882_remote_enable(gpib_board_t *board, int enable)
+static void tnt4882_remote_enable(struct gpib_board *board, int enable)
{
struct tnt4882_priv *priv = board->private_data;
nec7210_remote_enable(board, &priv->nec7210_priv, enable);
}
-int tnt4882_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits)
+static int tnt4882_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
}
-void tnt4882_disable_eos(gpib_board_t *board)
+static void tnt4882_disable_eos(struct gpib_board *board)
{
struct tnt4882_priv *priv = board->private_data;
nec7210_disable_eos(board, &priv->nec7210_priv);
}
-unsigned int tnt4882_update_status(gpib_board_t *board, unsigned int clear_mask)
+static unsigned int tnt4882_update_status(struct gpib_board *board, unsigned int clear_mask)
{
unsigned long flags;
u8 line_status;
- unsigned int retval;
struct tnt4882_priv *priv = board->private_data;
spin_lock_irqsave(&board->spinlock, flags);
board->status &= ~clear_mask;
- retval = nec7210_update_status_nolock(board, &priv->nec7210_priv);
+ nec7210_update_status_nolock(board, &priv->nec7210_priv);
/* set / clear SRQ state since it is not cleared by interrupt */
line_status = tnt_readb(priv, BSR);
if (line_status & BCSR_SRQ_BIT)
@@ -775,22 +704,21 @@ unsigned int tnt4882_update_status(gpib_board_t *board, unsigned int clear_mask)
return board->status;
}
-int tnt4882_primary_address(gpib_board_t *board, unsigned int address)
+static int tnt4882_primary_address(struct gpib_board *board, unsigned int address)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_primary_address(board, &priv->nec7210_priv, address);
}
-int tnt4882_secondary_address(gpib_board_t *board, unsigned int address, int enable)
+static int tnt4882_secondary_address(struct gpib_board *board, unsigned int address, int enable)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
}
-int tnt4882_parallel_poll(gpib_board_t *board, uint8_t *result)
-
+static int tnt4882_parallel_poll(struct gpib_board *board, uint8_t *result)
{
struct tnt4882_priv *tnt_priv = board->private_data;
@@ -807,7 +735,7 @@ int tnt4882_parallel_poll(gpib_board_t *board, uint8_t *result)
}
}
-void tnt4882_parallel_poll_configure(gpib_board_t *board, uint8_t config)
+static void tnt4882_parallel_poll_configure(struct gpib_board *board, uint8_t config)
{
struct tnt4882_priv *priv = board->private_data;
@@ -825,7 +753,7 @@ void tnt4882_parallel_poll_configure(gpib_board_t *board, uint8_t config)
}
}
-void tnt4882_parallel_poll_response(gpib_board_t *board, int ist)
+static void tnt4882_parallel_poll_response(struct gpib_board *board, int ist)
{
struct tnt4882_priv *priv = board->private_data;
@@ -835,14 +763,14 @@ void tnt4882_parallel_poll_response(gpib_board_t *board, int ist)
/* this is just used by the old nec7210 isa interfaces, the newer
* boards use tnt4882_serial_poll_response2
*/
-void tnt4882_serial_poll_response(gpib_board_t *board, uint8_t status)
+static void tnt4882_serial_poll_response(struct gpib_board *board, uint8_t status)
{
struct tnt4882_priv *priv = board->private_data;
nec7210_serial_poll_response(board, &priv->nec7210_priv, status);
}
-static void tnt4882_serial_poll_response2(gpib_board_t *board, uint8_t status,
+static void tnt4882_serial_poll_response2(struct gpib_board *board, uint8_t status,
int new_reason_for_service)
{
struct tnt4882_priv *priv = board->private_data;
@@ -876,303 +804,21 @@ static void tnt4882_serial_poll_response2(gpib_board_t *board, uint8_t status,
spin_unlock_irqrestore(&board->spinlock, flags);
}
-uint8_t tnt4882_serial_poll_status(gpib_board_t *board)
+static uint8_t tnt4882_serial_poll_status(struct gpib_board *board)
{
struct tnt4882_priv *priv = board->private_data;
return nec7210_serial_poll_status(board, &priv->nec7210_priv);
}
-void tnt4882_return_to_local(gpib_board_t *board)
+static void tnt4882_return_to_local(struct gpib_board *board)
{
struct tnt4882_priv *priv = board->private_data;
nec7210_return_to_local(board, &priv->nec7210_priv);
}
-static gpib_interface_t ni_pci_interface = {
- .name = "ni_pci",
- .attach = ni_pci_attach,
- .detach = ni_pci_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response2 = tnt4882_serial_poll_response2,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_pci_accel_interface = {
- .name = "ni_pci_accel",
- .attach = ni_pci_attach,
- .detach = ni_pci_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response2 = tnt4882_serial_poll_response2,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_isa_interface = {
- .name = "ni_isa",
- .attach = ni_tnt_isa_attach,
- .detach = ni_isa_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response2 = tnt4882_serial_poll_response2,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_nat4882_isa_interface = {
- .name = "ni_nat4882_isa",
- .attach = ni_nat4882_isa_attach,
- .detach = ni_isa_detach,
- .read = tnt4882_read,
- .write = tnt4882_write,
- .command = tnt4882_command_unaccel,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response2 = tnt4882_serial_poll_response2,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_nec_isa_interface = {
- .name = "ni_nec_isa",
- .attach = ni_nec_isa_attach,
- .detach = ni_isa_detach,
- .read = tnt4882_read,
- .write = tnt4882_write,
- .command = tnt4882_command_unaccel,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = NULL,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response = tnt4882_serial_poll_response,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_isa_accel_interface = {
- .name = "ni_isa_accel",
- .attach = ni_tnt_isa_attach,
- .detach = ni_isa_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response2 = tnt4882_serial_poll_response2,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_nat4882_isa_accel_interface = {
- .name = "ni_nat4882_isa_accel",
- .attach = ni_nat4882_isa_attach,
- .detach = ni_isa_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command_unaccel,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response2 = tnt4882_serial_poll_response2,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_nec_isa_accel_interface = {
- .name = "ni_nec_isa_accel",
- .attach = ni_nec_isa_attach,
- .detach = ni_isa_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command_unaccel,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = NULL,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response = tnt4882_serial_poll_response,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-#ifdef GPIB_PCMCIA
-static gpib_interface_t ni_pcmcia_interface = {
- .name = "ni_pcmcia",
- .attach = ni_pcmcia_attach,
- .detach = ni_pcmcia_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response = tnt4882_serial_poll_response,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-
-static gpib_interface_t ni_pcmcia_accel_interface = {
- .name = "ni_pcmcia_accel",
- .attach = ni_pcmcia_attach,
- .detach = ni_pcmcia_detach,
- .read = tnt4882_accel_read,
- .write = tnt4882_accel_write,
- .command = tnt4882_command,
- .take_control = tnt4882_take_control,
- .go_to_standby = tnt4882_go_to_standby,
- .request_system_control = tnt4882_request_system_control,
- .interface_clear = tnt4882_interface_clear,
- .remote_enable = tnt4882_remote_enable,
- .enable_eos = tnt4882_enable_eos,
- .disable_eos = tnt4882_disable_eos,
- .parallel_poll = tnt4882_parallel_poll,
- .parallel_poll_configure = tnt4882_parallel_poll_configure,
- .parallel_poll_response = tnt4882_parallel_poll_response,
- .local_parallel_poll_mode = NULL, // XXX
- .line_status = tnt4882_line_status,
- .update_status = tnt4882_update_status,
- .primary_address = tnt4882_primary_address,
- .secondary_address = tnt4882_secondary_address,
- .serial_poll_response = tnt4882_serial_poll_response,
- .serial_poll_status = tnt4882_serial_poll_status,
- .t1_delay = tnt4882_t1_delay,
- .return_to_local = tnt4882_return_to_local,
-};
-#endif
-
-void tnt4882_board_reset(struct tnt4882_priv *tnt_priv, gpib_board_t *board)
+static void tnt4882_board_reset(struct tnt4882_priv *tnt_priv, struct gpib_board *board)
{
struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv;
@@ -1185,7 +831,7 @@ void tnt4882_board_reset(struct tnt4882_priv *tnt_priv, gpib_board_t *board)
nec7210_board_reset(nec_priv, board);
}
-int tnt4882_allocate_private(gpib_board_t *board)
+static int tnt4882_allocate_private(struct gpib_board *board)
{
struct tnt4882_priv *tnt_priv;
@@ -1198,13 +844,13 @@ int tnt4882_allocate_private(gpib_board_t *board)
return 0;
}
-void tnt4882_free_private(gpib_board_t *board)
+static void tnt4882_free_private(struct gpib_board *board)
{
kfree(board->private_data);
board->private_data = NULL;
}
-void tnt4882_init(struct tnt4882_priv *tnt_priv, const gpib_board_t *board)
+static void tnt4882_init(struct tnt4882_priv *tnt_priv, const struct gpib_board *board)
{
struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv;
@@ -1252,7 +898,7 @@ void tnt4882_init(struct tnt4882_priv *tnt_priv, const gpib_board_t *board)
tnt_writeb(tnt_priv, tnt_priv->imr0_bits, IMR0);
}
-int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int ni_pci_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct tnt4882_priv *tnt_priv;
struct nec7210_priv *nec_priv;
@@ -1271,10 +917,8 @@ int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
nec_priv->write_byte = nec7210_locking_iomem_write_byte;
nec_priv->offset = atgpib_reg_offset;
- if (!mite_devices) {
- pr_err("no National Instruments PCI boards found\n");
- return -1;
- }
+ if (!mite_devices)
+ return -ENODEV;
for (mite = mite_devices; mite; mite = mite->next) {
short found_board;
@@ -1305,37 +949,32 @@ int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
if (found_board)
break;
}
- if (!mite) {
- pr_err("no NI PCI-GPIB boards found\n");
- return -1;
- }
+ if (!mite)
+ return -ENODEV;
+
tnt_priv->mite = mite;
retval = mite_setup(tnt_priv->mite);
- if (retval < 0) {
- pr_err("tnt4882: error setting up mite.\n");
+ if (retval < 0)
return retval;
- }
nec_priv->mmiobase = tnt_priv->mite->daq_io_addr;
// get irq
- if (request_irq(mite_irq(tnt_priv->mite), tnt4882_interrupt, isr_flags,
- "ni-pci-gpib", board)) {
- pr_err("gpib: can't request IRQ %d\n", mite_irq(tnt_priv->mite));
- return -1;
+ retval = request_irq(mite_irq(tnt_priv->mite), tnt4882_interrupt, isr_flags, "ni-pci-gpib",
+ board);
+ if (retval) {
+ dev_err(board->gpib_dev, "failed to obtain pci irq %d\n", mite_irq(tnt_priv->mite));
+ return retval;
}
tnt_priv->irq = mite_irq(tnt_priv->mite);
- pr_info("tnt4882: irq %i\n", tnt_priv->irq);
// TNT5004 detection
switch (tnt_readb(tnt_priv, CSR) & 0xf0) {
case 0x30:
nec_priv->type = TNT4882;
- pr_info("tnt4882: TNT4882 chipset detected\n");
break;
case 0x40:
nec_priv->type = TNT5004;
- pr_info("tnt4882: TNT5004 chipset detected\n");
break;
}
tnt4882_init(tnt_priv, board);
@@ -1343,7 +982,7 @@ int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-void ni_pci_detach(gpib_board_t *board)
+static void ni_pci_detach(struct gpib_board *board)
{
struct tnt4882_priv *tnt_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1365,28 +1004,22 @@ static int ni_isapnp_find(struct pnp_dev **dev)
{
*dev = pnp_find_dev(NULL, ISAPNP_VENDOR_ID_NI,
ISAPNP_FUNCTION(ISAPNP_ID_NI_ATGPIB_TNT), NULL);
- if (!*dev || !(*dev)->card) {
- pr_err("tnt4882: failed to find isapnp board\n");
+ if (!*dev || !(*dev)->card)
return -ENODEV;
- }
- if (pnp_device_attach(*dev) < 0) {
- pr_err("tnt4882: atgpib/tnt board already active, skipping\n");
+ if (pnp_device_attach(*dev) < 0)
return -EBUSY;
- }
if (pnp_activate_dev(*dev) < 0) {
pnp_device_detach(*dev);
- pr_err("tnt4882: failed to activate() atgpib/tnt, aborting\n");
return -EAGAIN;
}
if (!pnp_port_valid(*dev, 0) || !pnp_irq_valid(*dev, 0)) {
pnp_device_detach(*dev);
- pr_err("tnt4882: invalid port or irq for atgpib/tnt, aborting\n");
- return -ENOMEM;
+ return -EINVAL;
}
return 0;
}
-static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *config,
+static int ni_isa_attach_common(struct gpib_board *board, const gpib_board_config_t *config,
enum nec7210_chipset chipset)
{
struct tnt4882_priv *tnt_priv;
@@ -1394,6 +1027,7 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
int isr_flags = 0;
u32 iobase;
int irq;
+ int retval;
board->status = 0;
@@ -1409,7 +1043,6 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
// look for plug-n-play board
if (config->ibbase == 0) {
struct pnp_dev *dev;
- int retval;
retval = ni_isapnp_find(&dev);
if (retval < 0)
@@ -1422,18 +1055,18 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
irq = config->ibirq;
}
// allocate ioports
- if (!request_region(iobase, atgpib_iosize, "atgpib")) {
- pr_err("tnt4882: failed to allocate ioports\n");
- return -1;
- }
+ if (!request_region(iobase, atgpib_iosize, "atgpib"))
+ return -EBUSY;
+
nec_priv->mmiobase = ioport_map(iobase, atgpib_iosize);
if (!nec_priv->mmiobase)
- return -1;
+ return -EBUSY;
// get irq
- if (request_irq(irq, tnt4882_interrupt, isr_flags, "atgpib", board)) {
- pr_err("gpib: can't request IRQ %d\n", irq);
- return -1;
+ retval = request_irq(irq, tnt4882_interrupt, isr_flags, "atgpib", board);
+ if (retval) {
+ dev_err(board->gpib_dev, "failed to request ISA irq %d\n", irq);
+ return retval;
}
tnt_priv->irq = irq;
@@ -1442,22 +1075,22 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
return 0;
}
-int ni_tnt_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int ni_tnt_isa_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
return ni_isa_attach_common(board, config, TNT4882);
}
-int ni_nat4882_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int ni_nat4882_isa_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
return ni_isa_attach_common(board, config, NAT4882);
}
-int ni_nec_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int ni_nec_isa_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
return ni_isa_attach_common(board, config, NEC7210);
}
-void ni_isa_detach(gpib_board_t *board)
+static void ni_isa_detach(struct gpib_board *board)
{
struct tnt4882_priv *tnt_priv = board->private_data;
struct nec7210_priv *nec_priv;
@@ -1483,6 +1116,230 @@ static int tnt4882_pci_probe(struct pci_dev *dev, const struct pci_device_id *id
return 0;
}
+static gpib_interface_t ni_pci_interface = {
+ .name = "ni_pci",
+ .attach = ni_pci_attach,
+ .detach = ni_pci_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response2 = tnt4882_serial_poll_response2,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_pci_accel_interface = {
+ .name = "ni_pci_accel",
+ .attach = ni_pci_attach,
+ .detach = ni_pci_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response2 = tnt4882_serial_poll_response2,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_isa_interface = {
+ .name = "ni_isa",
+ .attach = ni_tnt_isa_attach,
+ .detach = ni_isa_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response2 = tnt4882_serial_poll_response2,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_nat4882_isa_interface = {
+ .name = "ni_nat4882_isa",
+ .attach = ni_nat4882_isa_attach,
+ .detach = ni_isa_detach,
+ .read = tnt4882_read,
+ .write = tnt4882_write,
+ .command = tnt4882_command_unaccel,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response2 = tnt4882_serial_poll_response2,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_nec_isa_interface = {
+ .name = "ni_nec_isa",
+ .attach = ni_nec_isa_attach,
+ .detach = ni_isa_detach,
+ .read = tnt4882_read,
+ .write = tnt4882_write,
+ .command = tnt4882_command_unaccel,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = NULL,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response = tnt4882_serial_poll_response,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_isa_accel_interface = {
+ .name = "ni_isa_accel",
+ .attach = ni_tnt_isa_attach,
+ .detach = ni_isa_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response2 = tnt4882_serial_poll_response2,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_nat4882_isa_accel_interface = {
+ .name = "ni_nat4882_isa_accel",
+ .attach = ni_nat4882_isa_attach,
+ .detach = ni_isa_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command_unaccel,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response2 = tnt4882_serial_poll_response2,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_nec_isa_accel_interface = {
+ .name = "ni_nec_isa_accel",
+ .attach = ni_nec_isa_attach,
+ .detach = ni_isa_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command_unaccel,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = NULL,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response = tnt4882_serial_poll_response,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
static const struct pci_device_id tnt4882_pci_table[] = {
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB)},
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB_PLUS)},
@@ -1499,16 +1356,26 @@ static const struct pci_device_id tnt4882_pci_table[] = {
MODULE_DEVICE_TABLE(pci, tnt4882_pci_table);
static struct pci_driver tnt4882_pci_driver = {
- .name = "tnt4882",
+ .name = DRV_NAME,
.id_table = tnt4882_pci_table,
.probe = &tnt4882_pci_probe
};
+#if 0
+/* unused, will be needed when the driver is turned into a pnp_driver */
static const struct pnp_device_id tnt4882_pnp_table[] = {
{.id = "NICC601"},
{.id = ""}
};
MODULE_DEVICE_TABLE(pnp, tnt4882_pnp_table);
+#endif
+
+#ifdef CONFIG_GPIB_PCMCIA
+static gpib_interface_t ni_pcmcia_interface;
+static gpib_interface_t ni_pcmcia_accel_interface;
+static int __init init_ni_gpib_cs(void);
+static void __exit exit_ni_gpib_cs(void);
+#endif
static int __init tnt4882_init_module(void)
{
@@ -1516,84 +1383,83 @@ static int __init tnt4882_init_module(void)
result = pci_register_driver(&tnt4882_pci_driver);
if (result) {
- pr_err("tnt4882_gpib: pci_register_driver failed: error = %d\n", result);
+ pr_err("pci_register_driver failed: error = %d\n", result);
return result;
}
result = gpib_register_driver(&ni_isa_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_isa;
}
result = gpib_register_driver(&ni_isa_accel_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_isa_accel;
}
result = gpib_register_driver(&ni_nat4882_isa_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_nat4882_isa;
}
result = gpib_register_driver(&ni_nat4882_isa_accel_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_nat4882_isa_accel;
}
result = gpib_register_driver(&ni_nec_isa_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_nec_isa;
}
result = gpib_register_driver(&ni_nec_isa_accel_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_nec_isa_accel;
}
result = gpib_register_driver(&ni_pci_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_pci;
}
result = gpib_register_driver(&ni_pci_accel_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_pci_accel;
}
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
result = gpib_register_driver(&ni_pcmcia_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_pcmcia;
}
result = gpib_register_driver(&ni_pcmcia_accel_interface, THIS_MODULE);
if (result) {
- pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result);
+ pr_err("gpib_register_driver failed: error = %d\n", result);
goto err_pcmcia_accel;
}
result = init_ni_gpib_cs();
if (result) {
- pr_err("tnt4882_gpib: pcmcia_register_driver failed: error = %d\n", result);
+ pr_err("pcmcia_register_driver failed: error = %d\n", result);
goto err_pcmcia_driver;
}
#endif
mite_init();
- mite_list_devices();
return 0;
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
err_pcmcia_driver:
gpib_unregister_driver(&ni_pcmcia_accel_interface);
err_pcmcia_accel:
@@ -1631,7 +1497,7 @@ static void __exit tnt4882_exit_module(void)
gpib_unregister_driver(&ni_nec_isa_accel_interface);
gpib_unregister_driver(&ni_pci_interface);
gpib_unregister_driver(&ni_pci_accel_interface);
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
gpib_unregister_driver(&ni_pcmcia_interface);
gpib_unregister_driver(&ni_pcmcia_accel_interface);
exit_ni_gpib_cs();
@@ -1642,7 +1508,7 @@ static void __exit tnt4882_exit_module(void)
pci_unregister_driver(&tnt4882_pci_driver);
}
-#ifdef GPIB_PCMCIA
+#ifdef CONFIG_GPIB_PCMCIA
#include <linux/kernel.h>
#include <linux/moduleparam.h>
@@ -1655,29 +1521,9 @@ static void __exit tnt4882_exit_module(void)
#include <pcmcia/cisreg.h>
#include <pcmcia/ds.h>
-/*
- * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
- * you do not define PCMCIA_DEBUG at all, all the debug code will be
- * left out. If you compile with PCMCIA_DEBUG=0, the debug code will
- * be present but disabled -- but it can then be enabled for specific
- * modules at load time with a 'pc_debug=#' option to insmod.
- */
-#define PCMCIA_DEBUG 1
-#ifdef PCMCIA_DEBUG
-static int pc_debug = PCMCIA_DEBUG;
-module_param(pc_debug, int, 0);
-#define DEBUG(n, args...) \
- do {if (pc_debug > (n)) \
- pr_debug(args); } \
- while (0)
-#else
-#define DEBUG(args...)
-#endif
-
static int ni_gpib_config(struct pcmcia_device *link);
static void ni_gpib_release(struct pcmcia_device *link);
-static int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config);
-static void ni_pcmcia_detach(gpib_board_t *board);
+static void ni_pcmcia_detach(struct gpib_board *board);
/*
* A linked list of "instances" of the dummy device. Each actual
@@ -1696,7 +1542,7 @@ static struct pcmcia_device *curr_dev;
struct local_info_t {
struct pcmcia_device *p_dev;
- gpib_board_t *dev;
+ struct gpib_board *dev;
int stop;
struct bus_operations *bus;
};
@@ -1710,9 +1556,7 @@ struct local_info_t {
static int ni_gpib_probe(struct pcmcia_device *link)
{
struct local_info_t *info;
- //struct gpib_board_t *dev;
-
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev;
/* Allocate space for private device-specific data */
info = kzalloc(sizeof(*info), GFP_KERNEL);
@@ -1745,9 +1589,7 @@ static int ni_gpib_probe(struct pcmcia_device *link)
static void ni_gpib_remove(struct pcmcia_device *link)
{
struct local_info_t *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
-
- DEBUG(0, "%s(%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
if (info->dev)
ni_pcmcia_detach(info->dev);
@@ -1776,11 +1618,9 @@ static int ni_gpib_config_iteration(struct pcmcia_device *link, void *priv_data)
static int ni_gpib_config(struct pcmcia_device *link)
{
//struct local_info_t *info = link->priv;
- //gpib_board_t *dev = info->dev;
+ //struct gpib_board *dev = info->dev;
int last_ret;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
-
last_ret = pcmcia_loop_config(link, &ni_gpib_config_iteration, NULL);
if (last_ret) {
dev_warn(&link->dev, "no configuration found\n");
@@ -1803,18 +1643,16 @@ static int ni_gpib_config(struct pcmcia_device *link)
*/
static void ni_gpib_release(struct pcmcia_device *link)
{
- DEBUG(0, "%s(0x%p)\n", __func__, link);
pcmcia_disable_device(link);
} /* ni_gpib_release */
static int ni_gpib_suspend(struct pcmcia_device *link)
{
//struct local_info_t *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
if (link->open)
- pr_err("Device still open ???\n");
+ dev_warn(&link->dev, "Device still open\n");
//netif_device_detach(dev);
return 0;
@@ -1823,12 +1661,10 @@ static int ni_gpib_suspend(struct pcmcia_device *link)
static int ni_gpib_resume(struct pcmcia_device *link)
{
//struct local_info_t *info = link->priv;
- //struct gpib_board_t *dev = info->dev;
- DEBUG(0, "%s(0x%p)\n", __func__, link);
+ //struct struct gpib_board *dev = info->dev;
/*if (link->open) {
* ni_gpib_probe(dev); / really?
- * printk("Gpib resumed ???\n");
* //netif_device_attach(dev);
*}
*/
@@ -1854,32 +1690,28 @@ static struct pcmcia_driver ni_gpib_cs_driver = {
.resume = ni_gpib_resume,
};
-int __init init_ni_gpib_cs(void)
+static int __init init_ni_gpib_cs(void)
{
return pcmcia_register_driver(&ni_gpib_cs_driver);
}
-void __exit exit_ni_gpib_cs(void)
+static void __exit exit_ni_gpib_cs(void)
{
- DEBUG(0, "ni_gpib_cs: unloading\n");
pcmcia_unregister_driver(&ni_gpib_cs_driver);
}
static const int pcmcia_gpib_iosize = 32;
-int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
+static int ni_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config)
{
struct local_info_t *info;
struct tnt4882_priv *tnt_priv;
struct nec7210_priv *nec_priv;
int isr_flags = IRQF_SHARED;
+ int retval;
- DEBUG(0, "%s(0x%p)\n", __func__, board);
-
- if (!curr_dev) {
- pr_err("gpib: no NI PCMCIA board found\n");
- return -1;
- }
+ if (!curr_dev)
+ return -ENODEV;
info = curr_dev->priv;
info->dev = board;
@@ -1888,6 +1720,7 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
if (tnt4882_allocate_private(board))
return -ENOMEM;
+
tnt_priv = board->private_data;
nec_priv = &tnt_priv->nec7210_priv;
nec_priv->type = TNT4882;
@@ -1895,23 +1728,20 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
nec_priv->write_byte = nec7210_locking_ioport_write_byte;
nec_priv->offset = atgpib_reg_offset;
- DEBUG(0, "ioport1 window attributes: 0x%lx\n", curr_dev->resource[0]->flags);
if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
- "tnt4882")) {
- pr_err("gpib: ioports starting at 0x%lx are already in use\n",
- (unsigned long)curr_dev->resource[0]->start);
- return -EIO;
- }
+ DRV_NAME))
+ return -ENOMEM;
nec_priv->mmiobase = ioport_map(curr_dev->resource[0]->start,
resource_size(curr_dev->resource[0]));
if (!nec_priv->mmiobase)
- return -1;
+ return -ENOMEM;
// get irq
- if (request_irq(curr_dev->irq, tnt4882_interrupt, isr_flags, "tnt4882", board)) {
- pr_err("gpib: can't request IRQ %d\n", curr_dev->irq);
- return -1;
+ retval = request_irq(curr_dev->irq, tnt4882_interrupt, isr_flags, DRV_NAME, board);
+ if (retval) {
+ dev_err(board->gpib_dev, "failed to obtain PCMCIA irq %d\n", curr_dev->irq);
+ return retval;
}
tnt_priv->irq = curr_dev->irq;
@@ -1920,13 +1750,11 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
return 0;
}
-void ni_pcmcia_detach(gpib_board_t *board)
+static void ni_pcmcia_detach(struct gpib_board *board)
{
struct tnt4882_priv *tnt_priv = board->private_data;
struct nec7210_priv *nec_priv;
- DEBUG(0, "%s(0x%p)\n", __func__, board);
-
if (tnt_priv) {
nec_priv = &tnt_priv->nec7210_priv;
if (tnt_priv->irq)
@@ -1941,7 +1769,63 @@ void ni_pcmcia_detach(gpib_board_t *board)
tnt4882_free_private(board);
}
-#endif // GPIB_PCMCIA
+static gpib_interface_t ni_pcmcia_interface = {
+ .name = "ni_pcmcia",
+ .attach = ni_pcmcia_attach,
+ .detach = ni_pcmcia_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response = tnt4882_serial_poll_response,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+static gpib_interface_t ni_pcmcia_accel_interface = {
+ .name = "ni_pcmcia_accel",
+ .attach = ni_pcmcia_attach,
+ .detach = ni_pcmcia_detach,
+ .read = tnt4882_accel_read,
+ .write = tnt4882_accel_write,
+ .command = tnt4882_command,
+ .take_control = tnt4882_take_control,
+ .go_to_standby = tnt4882_go_to_standby,
+ .request_system_control = tnt4882_request_system_control,
+ .interface_clear = tnt4882_interface_clear,
+ .remote_enable = tnt4882_remote_enable,
+ .enable_eos = tnt4882_enable_eos,
+ .disable_eos = tnt4882_disable_eos,
+ .parallel_poll = tnt4882_parallel_poll,
+ .parallel_poll_configure = tnt4882_parallel_poll_configure,
+ .parallel_poll_response = tnt4882_parallel_poll_response,
+ .local_parallel_poll_mode = NULL, // XXX
+ .line_status = tnt4882_line_status,
+ .update_status = tnt4882_update_status,
+ .primary_address = tnt4882_primary_address,
+ .secondary_address = tnt4882_secondary_address,
+ .serial_poll_response = tnt4882_serial_poll_response,
+ .serial_poll_status = tnt4882_serial_poll_status,
+ .t1_delay = tnt4882_t1_delay,
+ .return_to_local = tnt4882_return_to_local,
+};
+
+#endif // CONFIG_GPIB_PCMCIA
module_init(tnt4882_init_module);
module_exit(tnt4882_exit_module);
diff --git a/drivers/staging/gpib/uapi/gpib_user.h b/drivers/staging/gpib/uapi/gpib_user.h
index 0896a55a758f..5ff4588686fd 100644
--- a/drivers/staging/gpib/uapi/gpib_user.h
+++ b/drivers/staging/gpib/uapi/gpib_user.h
@@ -106,26 +106,15 @@ enum eos_flags {
/* GPIB Bus Control Lines bit vector */
enum bus_control_line {
- ValidDAV = 0x01,
- ValidNDAC = 0x02,
- ValidNRFD = 0x04,
- ValidIFC = 0x08,
- ValidREN = 0x10,
- ValidSRQ = 0x20,
- ValidATN = 0x40,
- ValidEOI = 0x80,
- ValidALL = 0xff,
- BusDAV = 0x0100, /* DAV line status bit */
- BusNDAC = 0x0200, /* NDAC line status bit */
- BusNRFD = 0x0400, /* NRFD line status bit */
- BusIFC = 0x0800, /* IFC line status bit */
- BusREN = 0x1000, /* REN line status bit */
- BusSRQ = 0x2000, /* SRQ line status bit */
- BusATN = 0x4000, /* ATN line status bit */
- BusEOI = 0x8000 /* EOI line status bit */
-};
-
-enum old_bus_control_line {
+ VALID_DAV = 0x01,
+ VALID_NDAC = 0x02,
+ VALID_NRFD = 0x04,
+ VALID_IFC = 0x08,
+ VALID_REN = 0x10,
+ VALID_SRQ = 0x20,
+ VALID_ATN = 0x40,
+ VALID_EOI = 0x80,
+ VALID_ALL = 0xff,
BUS_DAV = 0x0100, /* DAV line status bit */
BUS_NDAC = 0x0200, /* NDAC line status bit */
BUS_NRFD = 0x0400, /* NRFD line status bit */
diff --git a/drivers/staging/rtl8723bs/Kconfig b/drivers/staging/rtl8723bs/Kconfig
index 8d48c61961a6..353e6ee2c145 100644
--- a/drivers/staging/rtl8723bs/Kconfig
+++ b/drivers/staging/rtl8723bs/Kconfig
@@ -4,6 +4,7 @@ config RTL8723BS
depends on WLAN && MMC && CFG80211
depends on m
select CRYPTO
+ select CRYPTO_LIB_AES
select CRYPTO_LIB_ARC4
help
This option enables support for RTL8723BS SDIO drivers, such as
diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c
index a6dc88dd4ba1..50022bb5911e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -324,7 +324,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level)
{
unsigned char sta_band = 0, shortGIrate = false;
unsigned int tx_ra_bitmap = 0;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex
*pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
@@ -372,9 +372,9 @@ void update_bmc_sta(struct adapter *padapter)
unsigned char network_type;
int supportRateNum = 0;
unsigned int tx_ra_bitmap = 0;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
struct wlan_bssid_ex
*pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
struct sta_info *psta = rtw_get_bcmc_stainfo(padapter);
@@ -451,9 +451,9 @@ void update_bmc_sta(struct adapter *padapter)
void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
{
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv;
struct ht_priv *phtpriv_sta = &psta->htpriv;
u8 cur_ldpc_cap = 0, cur_stbc_cap = 0, cur_beamform_cap = 0;
@@ -563,10 +563,10 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
static void update_ap_info(struct adapter *padapter, struct sta_info *psta)
{
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex
*pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv;
psta->wireless_mode = pmlmeext->cur_wireless_mode;
@@ -609,7 +609,7 @@ static void update_hw_ht_param(struct adapter *padapter)
unsigned char max_AMPDU_len;
unsigned char min_MPDU_spacing;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
/* handle A-MPDU parameter field
*
@@ -645,13 +645,13 @@ void start_bss_network(struct adapter *padapter)
u32 acparm;
int ie_len;
struct registry_priv *pregpriv = &padapter->registrypriv;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- struct security_priv *psecuritypriv = &(padapter->securitypriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
struct wlan_bssid_ex
*pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network);
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
+ struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
struct HT_info_element *pht_info = NULL;
u8 cbw40_enable = 0;
@@ -823,7 +823,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
struct registry_priv *pregistrypriv = &padapter->registrypriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex
*pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
u8 *ie = pbss_network->ies;
@@ -845,7 +845,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
pbss_network->rssi = 0;
- memcpy(pbss_network->mac_address, myid(&(padapter->eeprompriv)), ETH_ALEN);
+ memcpy(pbss_network->mac_address, myid(&padapter->eeprompriv), ETH_ALEN);
/* beacon interval */
p = rtw_get_beacon_interval_from_ie(ie);/* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */
@@ -1186,7 +1186,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
if ((NUM_ACL - 1) < pacl_list->num)
return (-1);
- spin_lock_bh(&(pacl_node_q->lock));
+ spin_lock_bh(&pacl_node_q->lock);
phead = get_list_head(pacl_node_q);
list_for_each(plist, phead) {
@@ -1200,12 +1200,12 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
}
}
- spin_unlock_bh(&(pacl_node_q->lock));
+ spin_unlock_bh(&pacl_node_q->lock);
if (added)
return ret;
- spin_lock_bh(&(pacl_node_q->lock));
+ spin_lock_bh(&pacl_node_q->lock);
for (i = 0; i < NUM_ACL; i++) {
paclnode = &pacl_list->aclnode[i];
@@ -1225,7 +1225,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
}
}
- spin_unlock_bh(&(pacl_node_q->lock));
+ spin_unlock_bh(&pacl_node_q->lock);
return ret;
}
@@ -1238,7 +1238,7 @@ void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
struct __queue *pacl_node_q = &pacl_list->acl_node_q;
- spin_lock_bh(&(pacl_node_q->lock));
+ spin_lock_bh(&pacl_node_q->lock);
phead = get_list_head(pacl_node_q);
list_for_each_safe(plist, tmp, phead) {
@@ -1258,7 +1258,7 @@ void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
}
}
- spin_unlock_bh(&(pacl_node_q->lock));
+ spin_unlock_bh(&pacl_node_q->lock);
}
@@ -1308,7 +1308,7 @@ static int rtw_ap_set_key(
u8 keylen;
struct cmd_obj *pcmd;
struct setkey_parm *psetkeyparm;
- struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
int res = _SUCCESS;
pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
@@ -1345,7 +1345,7 @@ static int rtw_ap_set_key(
keylen = 16;
}
- memcpy(&(psetkeyparm->key[0]), key, keylen);
+ memcpy(&psetkeyparm->key[0], key, keylen);
pcmd->cmdcode = _SetKey_CMD_;
pcmd->parmbuf = (u8 *)psetkeyparm;
@@ -1397,10 +1397,10 @@ static void update_bcn_fixed_ie(struct adapter *padapter)
static void update_bcn_erpinfo_ie(struct adapter *padapter)
{
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
+ struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
unsigned char *p, *ie = pnetwork->ies;
u32 len = 0;
@@ -1461,10 +1461,10 @@ static void update_bcn_wps_ie(struct adapter *padapter)
u8 *pbackup_remainder_ie = NULL;
uint wps_ielen = 0, wps_offset, remainder_ielen;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
+ struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
unsigned char *ie = pnetwork->ies;
u32 ielen = pnetwork->ie_length;
@@ -1537,8 +1537,8 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
if (!padapter)
return;
- pmlmepriv = &(padapter->mlmepriv);
- pmlmeext = &(padapter->mlmeextpriv);
+ pmlmepriv = &padapter->mlmepriv;
+ pmlmeext = &padapter->mlmeextpriv;
/* pmlmeinfo = &(pmlmeext->mlmext_info); */
if (!pmlmeext->bstart_bss)
@@ -1619,7 +1619,7 @@ static int rtw_ht_operation_update(struct adapter *padapter)
{
u16 cur_op_mode, new_op_mode;
int op_mode_changes = 0;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv;
if (pmlmepriv->htpriv.ht_option)
@@ -1703,8 +1703,8 @@ void associated_clients_update(struct adapter *padapter, u8 updated)
void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
{
u8 beacon_updated = false;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) {
if (!psta->no_short_preamble_set) {
@@ -1823,8 +1823,8 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta)
{
u8 beacon_updated = false;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
if (!psta)
return beacon_updated;
@@ -1932,7 +1932,7 @@ void rtw_sta_flush(struct adapter *padapter)
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
@@ -1962,7 +1962,7 @@ void rtw_sta_flush(struct adapter *padapter)
void sta_info_update(struct adapter *padapter, struct sta_info *psta)
{
int flags = psta->flags;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
/* update wmm cap. */
if (WLAN_STA_WME & flags)
@@ -1991,7 +1991,7 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta)
void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta)
{
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
+ struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
if (psta->state & _FW_LINKED) {
pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta;
@@ -2006,7 +2006,7 @@ void rtw_ap_restore_network(struct adapter *padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct sta_priv *pstapriv = &padapter->stapriv;
struct sta_info *psta;
- struct security_priv *psecuritypriv = &(padapter->securitypriv);
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
struct list_head *phead, *plist;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -2072,7 +2072,7 @@ void rtw_ap_restore_network(struct adapter *padapter)
void start_ap_mode(struct adapter *padapter)
{
int i;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
@@ -2109,7 +2109,7 @@ void start_ap_mode(struct adapter *padapter)
pmlmepriv->p2p_probe_resp_ie = NULL;
/* for ACL */
- INIT_LIST_HEAD(&(pacl_list->acl_node_q.queue));
+ INIT_LIST_HEAD(&pacl_list->acl_node_q.queue);
pacl_list->num = 0;
pacl_list->mode = 0;
for (i = 0; i < NUM_ACL; i++) {
@@ -2124,7 +2124,7 @@ void stop_ap_mode(struct adapter *padapter)
struct rtw_wlan_acl_node *paclnode;
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
struct __queue *pacl_node_q = &pacl_list->acl_node_q;
@@ -2142,7 +2142,7 @@ void stop_ap_mode(struct adapter *padapter)
padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
/* for ACL */
- spin_lock_bh(&(pacl_node_q->lock));
+ spin_lock_bh(&pacl_node_q->lock);
phead = get_list_head(pacl_node_q);
list_for_each_safe(plist, tmp, phead) {
paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
@@ -2155,7 +2155,7 @@ void stop_ap_mode(struct adapter *padapter)
pacl_list->num--;
}
}
- spin_unlock_bh(&(pacl_node_q->lock));
+ spin_unlock_bh(&pacl_node_q->lock);
rtw_sta_flush(padapter);
diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c
index b41ec89932af..1213a91cffff 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -884,6 +884,9 @@ static u32 Array_kfreemap[] = {
0xfc, 0x0,
};
+#define REG_RF_BB_GAIN_OFFSET 0x7f
+//#define RF_GAIN_OFFSET_MASK 0xfffff
+
void rtw_bb_rf_gain_offset(struct adapter *padapter)
{
u8 value = padapter->eeprompriv.EEPROMRFGainOffset;
diff --git a/drivers/staging/rtl8723bs/include/osdep_intf.h b/drivers/staging/rtl8723bs/include/osdep_intf.h
index 73199be78139..83a25598e962 100644
--- a/drivers/staging/rtl8723bs/include/osdep_intf.h
+++ b/drivers/staging/rtl8723bs/include/osdep_intf.h
@@ -8,33 +8,6 @@
#ifndef __OSDEP_INTF_H_
#define __OSDEP_INTF_H_
-
-struct intf_priv {
-
- u8 *intf_dev;
- u32 max_iosz; /* USB2.0: 128, USB1.1: 64, SDIO:64 */
- u32 max_xmitsz; /* USB2.0: unlimited, SDIO:512 */
- u32 max_recvsz; /* USB2.0: unlimited, SDIO:512 */
-
- volatile u8 *io_rwmem;
- volatile u8 *allocated_io_rwmem;
- u32 io_wsz; /* unit: 4bytes */
- u32 io_rsz;/* unit: 4bytes */
- u8 intf_status;
-
- void (*_bus_io)(u8 *priv);
-
-/*
-Under Sync. IRP (SDIO/USB)
-A protection mechanism is necessary for the io_rwmem(read/write protocol)
-
-Under Async. IRP (SDIO/USB)
-The protection mechanism is through the pending queue.
-*/
-
- struct mutex ioctl_mutex;
-};
-
struct dvobj_priv *devobj_init(void);
void devobj_deinit(struct dvobj_priv *pdvobj);
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
index e6d6e9de5474..a4a14474c35d 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
@@ -15,7 +15,6 @@
#include "rtl8723b_recv.h"
#include "rtl8723b_xmit.h"
#include "rtl8723b_cmd.h"
-#include "rtw_mp.h"
#include "hal_pwr_seq.h"
#include "Hal8192CPhyReg.h"
#include "hal_phy_cfg.h"
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index 0ee87be6dc4f..adf1de4d7924 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -8,16 +8,7 @@
#ifndef _RTW_IO_H_
#define _RTW_IO_H_
-/*
- For prompt mode accessing, caller shall free io_req
- Otherwise, io_handler will free io_req
-*/
-
-/* below is for the intf_option bit definition... */
-
-struct intf_priv;
struct intf_hdl;
-struct io_queue;
struct _io_ops {
u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
@@ -36,8 +27,6 @@ struct _io_ops {
void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
- void (*_sync_irp_protocol_rw)(struct io_queue *pio_q);
-
u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr);
u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
@@ -49,18 +38,6 @@ struct _io_ops {
void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
};
-struct io_req {
- struct list_head list;
- u32 addr;
- volatile u32 val;
- u32 command;
- u32 status;
- u8 *pbuf;
-
- void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt);
- u8 *cnxt;
-};
-
struct intf_hdl {
struct adapter *padapter;
struct dvobj_priv *pintf_dev;/* pointer to &(padapter->dvobjpriv); */
@@ -74,21 +51,6 @@ struct intf_hdl {
int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj);
void rtw_reset_continual_io_error(struct dvobj_priv *dvobj);
-/*
-Below is the data structure used by _io_handler
-
-*/
-
-struct io_queue {
- spinlock_t lock;
- struct list_head free_ioreqs;
- struct list_head pending; /* The io_req list that will be served in the single protocol read/write. */
- struct list_head processing;
- u8 *free_ioreqs_buf; /* 4-byte aligned */
- u8 *pallocated_free_ioreqs_buf;
- struct intf_hdl intf;
-};
-
struct io_priv {
struct adapter *padapter;
@@ -97,20 +59,6 @@ struct io_priv {
};
-extern uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue);
-extern void sync_ioreq_enqueue(struct io_req *preq, struct io_queue *ioqueue);
-extern uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue);
-
-
-extern uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue);
-extern struct io_req *alloc_ioreq(struct io_queue *pio_q);
-
-extern uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl);
-extern void unregister_intf_hdl(struct intf_hdl *pintfhdl);
-
-extern void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-extern void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-
extern u8 rtw_read8(struct adapter *adapter, u32 addr);
extern u16 rtw_read16(struct adapter *adapter, u32 addr);
extern u32 rtw_read32(struct adapter *adapter, u32 addr);
@@ -121,46 +69,6 @@ extern int rtw_write32(struct adapter *adapter, u32 addr, u32 val);
extern u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-extern void rtw_write_scsi(struct adapter *adapter, u32 cnt, u8 *pmem);
-
-/* ioreq */
-extern void ioreq_read8(struct adapter *adapter, u32 addr, u8 *pval);
-extern void ioreq_read16(struct adapter *adapter, u32 addr, u16 *pval);
-extern void ioreq_read32(struct adapter *adapter, u32 addr, u32 *pval);
-extern void ioreq_write8(struct adapter *adapter, u32 addr, u8 val);
-extern void ioreq_write16(struct adapter *adapter, u32 addr, u16 val);
-extern void ioreq_write32(struct adapter *adapter, u32 addr, u32 val);
-
-
-extern uint async_read8(struct adapter *adapter, u32 addr, u8 *pbuff,
- void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
-extern uint async_read16(struct adapter *adapter, u32 addr, u8 *pbuff,
- void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
-extern uint async_read32(struct adapter *adapter, u32 addr, u8 *pbuff,
- void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
-
-extern void async_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-extern void async_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-
-extern void async_write8(struct adapter *adapter, u32 addr, u8 val,
- void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
-extern void async_write16(struct adapter *adapter, u32 addr, u16 val,
- void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
-extern void async_write32(struct adapter *adapter, u32 addr, u32 val,
- void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
-
-extern void async_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-extern void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
-
-
int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapter *padapter, struct _io_ops *pops));
-
-extern uint alloc_io_queue(struct adapter *adapter);
-extern void free_io_queue(struct adapter *adapter);
-extern void async_bus_io(struct io_queue *pio_q);
-extern void bus_sync_io(struct io_queue *pio_q);
-extern u32 _ioreq2rwmem(struct io_queue *pio_q);
-extern void dev_power_down(struct adapter *Adapter, u8 bpwrup);
-
#endif /* _RTL8711_IO_H_ */
diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h b/drivers/staging/rtl8723bs/include/rtw_mp.h
deleted file mode 100644
index 5a1cbd2ed851..000000000000
--- a/drivers/staging/rtl8723bs/include/rtw_mp.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- ******************************************************************************/
-#ifndef _RTW_MP_H_
-#define _RTW_MP_H_
-
-#define MAX_MP_XMITBUF_SZ 2048
-
-struct mp_xmit_frame {
- struct list_head list;
-
- struct pkt_attrib attrib;
-
- struct sk_buff *pkt;
-
- int frame_tag;
-
- struct adapter *padapter;
-
- uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
-};
-
-struct mp_wiparam {
- u32 bcompleted;
- u32 act_type;
- u32 io_offset;
- u32 io_value;
-};
-
-struct mp_tx {
- u8 stop;
- u32 count, sended;
- u8 payload;
- struct pkt_attrib attrib;
- /* struct tx_desc desc; */
- /* u8 resvdtx[7]; */
- u8 desc[TXDESC_SIZE];
- u8 *pallocated_buf;
- u8 *buf;
- u32 buf_size, write_size;
- void *PktTxThread;
-};
-
-#define MP_MAX_LINES 1000
-#define MP_MAX_LINES_BYTES 256
-
-typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
-struct mpt_context {
- /* Indicate if we have started Mass Production Test. */
- bool bMassProdTest;
-
- /* Indicate if the driver is unloading or unloaded. */
- bool bMptDrvUnload;
-
- struct timer_list MPh2c_timeout_timer;
-/* Event used to sync H2c for BT control */
-
- bool MptH2cRspEvent;
- bool MptBtC2hEvent;
- bool bMPh2c_timeout;
-
- /* 8190 PCI does not support NDIS_WORK_ITEM. */
- /* Work Item for Mass Production Test. */
- /* NDIS_WORK_ITEM MptWorkItem; */
-/* RT_WORK_ITEM MptWorkItem; */
- /* Event used to sync the case unloading driver and MptWorkItem is still in progress. */
-/* NDIS_EVENT MptWorkItemEvent; */
- /* To protect the following variables. */
-/* NDIS_SPIN_LOCK MptWorkItemSpinLock; */
- /* Indicate a MptWorkItem is scheduled and not yet finished. */
- bool bMptWorkItemInProgress;
- /* An instance which implements function and context of MptWorkItem. */
- MPT_WORK_ITEM_HANDLER CurrMptAct;
-
- /* 1 =Start, 0 =Stop from UI. */
- u32 MptTestStart;
- /* _TEST_MODE, defined in MPT_Req2.h */
- u32 MptTestItem;
- /* Variable needed in each implementation of CurrMptAct. */
- u32 MptActType; /* Type of action performed in CurrMptAct. */
- /* The Offset of IO operation is depend of MptActType. */
- u32 MptIoOffset;
- /* The Value of IO operation is depend of MptActType. */
- u32 MptIoValue;
- /* The RfPath of IO operation is depend of MptActType. */
- u32 MptRfPath;
-
- enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */
- u8 MptChannelToSw; /* Channel to switch. */
- u8 MptInitGainToSet; /* Initial gain to set. */
- u32 MptBandWidth; /* bandwidth to switch. */
- u32 MptRateIndex; /* rate index. */
- /* Register value kept for Single Carrier Tx test. */
- u8 btMpCckTxPower;
- /* Register value kept for Single Carrier Tx test. */
- u8 btMpOfdmTxPower;
- /* For MP Tx Power index */
- u8 TxPwrLevel[2]; /* rf-A, rf-B */
- u32 RegTxPwrLimit;
- /* Content of RCR Register for Mass Production Test. */
- u32 MptRCR;
- /* true if we only receive packets with specific pattern. */
- bool bMptFilterPattern;
- /* Rx OK count, statistics used in Mass Production Test. */
- u32 MptRxOkCnt;
- /* Rx CRC32 error count, statistics used in Mass Production Test. */
- u32 MptRxCrcErrCnt;
-
- bool bCckContTx; /* true if we are in CCK Continuous Tx test. */
- bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */
- bool bStartContTx; /* true if we have start Continuous Tx test. */
- /* true if we are in Single Carrier Tx test. */
- bool bSingleCarrier;
- /* true if we are in Carrier Suppression Tx Test. */
- bool bCarrierSuppression;
- /* true if we are in Single Tone Tx test. */
- bool bSingleTone;
-
- /* ACK counter asked by K.Y.. */
- bool bMptEnableAckCounter;
- u32 MptAckCounter;
-
- /* SD3 Willis For 8192S to save 1T/2T RF table for ACUT Only fro ACUT delete later ~~~! */
- /* s8 BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */
- /* s8 BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */
- /* s32 RfReadLine[2]; */
-
- u8 APK_bound[2]; /* for APK path A/path B */
- bool bMptIndexEven;
-
- u8 backup0xc50;
- u8 backup0xc58;
- u8 backup0xc30;
- u8 backup0x52_RF_A;
- u8 backup0x52_RF_B;
-
- u32 backup0x58_RF_A;
- u32 backup0x58_RF_B;
-
- u8 h2cReqNum;
- u8 c2hBuf[32];
-
- u8 btInBuf[100];
- u32 mptOutLen;
- u8 mptOutBuf[100];
-
-};
-/* endif */
-
-/* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */
-enum {
- WRITE_REG = 1,
- READ_REG,
- WRITE_RF,
- READ_RF,
- MP_START,
- MP_STOP,
- MP_RATE,
- MP_CHANNEL,
- MP_BANDWIDTH,
- MP_TXPOWER,
- MP_ANT_TX,
- MP_ANT_RX,
- MP_CTX,
- MP_QUERY,
- MP_ARX,
- MP_PSD,
- MP_PWRTRK,
- MP_THER,
- MP_IOCTL,
- EFUSE_GET,
- EFUSE_SET,
- MP_RESET_STATS,
- MP_DUMP,
- MP_PHYPARA,
- MP_SetRFPathSwh,
- MP_QueryDrvStats,
- MP_SetBT,
- CTA_TEST,
- MP_DISABLE_BT_COEXIST,
- MP_PwrCtlDM,
- MP_NULL,
- MP_GET_TXPOWER_INX,
-};
-
-struct mp_priv {
- struct adapter *papdater;
-
- /* Testing Flag */
- u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
-
- u32 prev_fw_state;
-
- /* OID cmd handler */
- struct mp_wiparam workparam;
-/* u8 act_in_progress; */
-
- /* Tx Section */
- u8 TID;
- u32 tx_pktcount;
- u32 pktInterval;
- struct mp_tx tx;
-
- /* Rx Section */
- u32 rx_bssidpktcount;
- u32 rx_pktcount;
- u32 rx_pktcount_filter_out;
- u32 rx_crcerrpktcount;
- u32 rx_pktloss;
- bool rx_bindicatePkt;
- struct recv_stat rxstat;
-
- /* RF/BB relative */
- u8 channel;
- u8 bandwidth;
- u8 prime_channel_offset;
- u8 txpoweridx;
- u8 txpoweridx_b;
- u8 rateidx;
- u32 preamble;
-/* u8 modem; */
- u32 CrystalCap;
-/* u32 curr_crystalcap; */
-
- u16 antenna_tx;
- u16 antenna_rx;
-/* u8 curr_rfpath; */
-
- u8 check_mp_pkt;
-
- u8 bSetTxPower;
-/* uint ForcedDataRate; */
- u8 mp_dm;
- u8 mac_filter[ETH_ALEN];
- u8 bmac_filter;
-
- struct wlan_network mp_network;
- NDIS_802_11_MAC_ADDRESS network_macaddr;
-
- u8 *pallocated_mp_xmitframe_buf;
- u8 *pmp_xmtframe_buf;
- struct __queue free_mp_xmitqueue;
- u32 free_mp_xmitframe_cnt;
- bool bSetRxBssid;
- bool bTxBufCkFail;
-
- struct mpt_context MptCtx;
-
- u8 *TXradomBuffer;
-};
-
-/* Hardware Registers */
-extern u8 mpdatarate[NumRates];
-
-#define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
-
-#define REG_RF_BB_GAIN_OFFSET 0x7f
-#define RF_GAIN_OFFSET_MASK 0xfffff
-
-/* */
-/* struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv); */
-/* int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe); */
-
-s32 init_mp_priv(struct adapter *padapter);
-void free_mp_priv(struct mp_priv *pmp_priv);
-s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel);
-void MPT_DeInitAdapter(struct adapter *padapter);
-s32 mp_start_test(struct adapter *padapter);
-void mp_stop_test(struct adapter *padapter);
-
-u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask);
-void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
-
-u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz);
-void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz);
-
-void SetChannel(struct adapter *padapter);
-void SetBandwidth(struct adapter *padapter);
-int SetTxPower(struct adapter *padapter);
-void SetAntennaPathPower(struct adapter *padapter);
-void SetDataRate(struct adapter *padapter);
-
-void SetAntenna(struct adapter *padapter);
-
-s32 SetThermalMeter(struct adapter *padapter, u8 target_ther);
-void GetThermalMeter(struct adapter *padapter, u8 *value);
-
-void SetContinuousTx(struct adapter *padapter, u8 bStart);
-void SetSingleCarrierTx(struct adapter *padapter, u8 bStart);
-void SetSingleToneTx(struct adapter *padapter, u8 bStart);
-void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
-void PhySetTxPowerLevel(struct adapter *padapter);
-
-void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc);
-void SetPacketTx(struct adapter *padapter);
-void SetPacketRx(struct adapter *padapter, u8 bStartRx);
-
-void ResetPhyRxPktCount(struct adapter *padapter);
-u32 GetPhyRxPktReceived(struct adapter *padapter);
-u32 GetPhyRxPktCRC32Error(struct adapter *padapter);
-
-s32 SetPowerTracking(struct adapter *padapter, u8 enable);
-void GetPowerTracking(struct adapter *padapter, u8 *enable);
-
-u32 mp_query_psd(struct adapter *padapter, u8 *data);
-
-void Hal_SetAntenna(struct adapter *padapter);
-void Hal_SetBandwidth(struct adapter *padapter);
-
-void Hal_SetTxPower(struct adapter *padapter);
-void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
-void Hal_SetSingleToneTx(struct adapter *padapter, u8 bStart);
-void Hal_SetSingleCarrierTx(struct adapter *padapter, u8 bStart);
-void Hal_SetContinuousTx(struct adapter *padapter, u8 bStart);
-
-void Hal_SetDataRate(struct adapter *padapter);
-void Hal_SetChannel(struct adapter *padapter);
-void Hal_SetAntennaPathPower(struct adapter *padapter);
-s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther);
-s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
-void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable);
-void Hal_GetThermalMeter(struct adapter *padapter, u8 *value);
-void Hal_mpt_SwitchRfSetting(struct adapter *padapter);
-void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14);
-void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven);
-void Hal_SetCCKTxPower(struct adapter *padapter, u8 *TxPower);
-void Hal_SetOFDMTxPower(struct adapter *padapter, u8 *TxPower);
-void Hal_TriggerRFThermalMeter(struct adapter *padapter);
-u8 Hal_ReadRFThermalMeter(struct adapter *padapter);
-void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart);
-void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart);
-void Hal_ProSetCrystalCap(struct adapter *padapter, u32 CrystalCapVal);
-void MP_PHY_SetRFPathSwitch(struct adapter *padapter, bool bMain);
-u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath);
-void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart);
-u8 MptToMgntRate(u32 MptRateIdx);
-
-#endif /* _RTW_MP_H_ */
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 738a601c55bb..de48c3454ab3 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -724,8 +724,6 @@ u8 rtw_free_drv_sw(struct adapter *padapter)
rtw_free_mlme_priv(&padapter->mlmepriv);
- /* free_io_queue(padapter); */
-
_rtw_free_xmit_priv(&padapter->xmitpriv);
_rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */
diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
index 02860d3ec365..025dae3756aa 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -228,8 +228,8 @@ int ddk750_init_hw(struct initchip_param *p_init_param)
reg = peek32(VGA_CONFIGURATION);
reg |= (VGA_CONFIGURATION_PLL | VGA_CONFIGURATION_MODE);
poke32(VGA_CONFIGURATION, reg);
+#ifdef CONFIG_X86
} else {
-#if defined(__i386__) || defined(__x86_64__)
/* set graphic mode via IO method */
outb_p(0x88, 0x3d4);
outb_p(0x06, 0x3d5);
diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index deec33f63bcf..b839b50ac26a 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -658,8 +658,6 @@ static const struct vb2_ops bcm2835_mmal_video_qops = {
.buf_queue = buffer_queue,
.start_streaming = start_streaming,
.stop_streaming = stop_streaming,
- .wait_prepare = vb2_ops_wait_prepare,
- .wait_finish = vb2_ops_wait_finish,
};
/* ------------------------------------------------------------------
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index a4e83e5d619b..5dbf8d53db09 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -97,13 +97,6 @@ struct vchiq_arm_state {
* tracked separately with the state.
*/
int peer_use_count;
-
- /*
- * Flag to indicate that the first vchiq connect has made it through.
- * This means that both sides should be fully ready, and we should
- * be able to suspend after this point.
- */
- int first_connect;
};
static int
@@ -271,7 +264,7 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
return -ENXIO;
}
- dev_dbg(&pdev->dev, "arm: vchiq_init - done (slots %pK, phys %pad)\n",
+ dev_dbg(&pdev->dev, "arm: vchiq_init - done (slots %p, phys %pad)\n",
vchiq_slot_zero, &slot_phys);
mutex_init(&drv_mgmt->connected_mutex);
@@ -280,32 +273,23 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
return 0;
}
-int
-vchiq_platform_init_state(struct vchiq_state *state)
+static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state)
{
- struct vchiq_arm_state *platform_state;
-
- platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
- if (!platform_state)
- return -ENOMEM;
-
- rwlock_init(&platform_state->susp_res_lock);
-
- init_completion(&platform_state->ka_evt);
- atomic_set(&platform_state->ka_use_count, 0);
- atomic_set(&platform_state->ka_use_ack_count, 0);
- atomic_set(&platform_state->ka_release_count, 0);
-
- platform_state->state = state;
-
- state->platform_state = (struct opaque_platform_state *)platform_state;
-
- return 0;
+ return (struct vchiq_arm_state *)state->platform_state;
}
-static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state)
+static void
+vchiq_platform_uninit(struct vchiq_drv_mgmt *mgmt)
{
- return (struct vchiq_arm_state *)state->platform_state;
+ struct vchiq_arm_state *arm_state;
+
+ kthread_stop(mgmt->state.sync_thread);
+ kthread_stop(mgmt->state.recycle_thread);
+ kthread_stop(mgmt->state.slot_handler_thread);
+
+ arm_state = vchiq_platform_get_arm_state(&mgmt->state);
+ if (!IS_ERR_OR_NULL(arm_state->ka_thread))
+ kthread_stop(arm_state->ka_thread);
}
void vchiq_dump_platform_state(struct seq_file *f)
@@ -368,7 +352,7 @@ void free_bulk_waiter(struct vchiq_instance *instance)
&instance->bulk_waiter_list, list) {
list_del(&waiter->list);
dev_dbg(instance->state->dev,
- "arm: bulk_waiter - cleaned up %pK for pid %d\n",
+ "arm: bulk_waiter - cleaned up %p for pid %d\n",
waiter, waiter->pid);
kfree(waiter);
}
@@ -622,7 +606,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
mutex_lock(&instance->bulk_waiter_list_mutex);
list_add(&waiter->list, &instance->bulk_waiter_list);
mutex_unlock(&instance->bulk_waiter_list_mutex);
- dev_dbg(instance->state->dev, "arm: saved bulk_waiter %pK for pid %d\n",
+ dev_dbg(instance->state->dev, "arm: saved bulk_waiter %p for pid %d\n",
waiter, current->pid);
}
@@ -998,6 +982,39 @@ exit:
}
int
+vchiq_platform_init_state(struct vchiq_state *state)
+{
+ struct vchiq_arm_state *platform_state;
+ char threadname[16];
+
+ platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
+ if (!platform_state)
+ return -ENOMEM;
+
+ snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
+ state->id);
+ platform_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
+ (void *)state, threadname);
+ if (IS_ERR(platform_state->ka_thread)) {
+ dev_err(state->dev, "couldn't create thread %s\n", threadname);
+ return PTR_ERR(platform_state->ka_thread);
+ }
+
+ rwlock_init(&platform_state->susp_res_lock);
+
+ init_completion(&platform_state->ka_evt);
+ atomic_set(&platform_state->ka_use_count, 0);
+ atomic_set(&platform_state->ka_use_ack_count, 0);
+ atomic_set(&platform_state->ka_release_count, 0);
+
+ platform_state->state = state;
+
+ state->platform_state = (struct opaque_platform_state *)platform_state;
+
+ return 0;
+}
+
+int
vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
enum USE_TYPE_E use_type)
{
@@ -1312,37 +1329,19 @@ out:
return ret;
}
+void vchiq_platform_connected(struct vchiq_state *state)
+{
+ struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
+
+ wake_up_process(arm_state->ka_thread);
+}
+
void vchiq_platform_conn_state_changed(struct vchiq_state *state,
enum vchiq_connstate oldstate,
enum vchiq_connstate newstate)
{
- struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
- char threadname[16];
-
dev_dbg(state->dev, "suspend: %d: %s->%s\n",
state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate));
- if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED)
- return;
-
- write_lock_bh(&arm_state->susp_res_lock);
- if (arm_state->first_connect) {
- write_unlock_bh(&arm_state->susp_res_lock);
- return;
- }
-
- arm_state->first_connect = 1;
- write_unlock_bh(&arm_state->susp_res_lock);
- snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
- state->id);
- arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
- (void *)state,
- threadname);
- if (IS_ERR(arm_state->ka_thread)) {
- dev_err(state->dev, "suspend: Couldn't create thread %s\n",
- threadname);
- } else {
- wake_up_process(arm_state->ka_thread);
- }
}
static const struct of_device_id vchiq_of_match[] = {
@@ -1386,8 +1385,6 @@ static int vchiq_probe(struct platform_device *pdev)
return ret;
}
- vchiq_debugfs_init(&mgmt->state);
-
dev_dbg(&pdev->dev, "arm: platform initialised - version %d (min %d)\n",
VCHIQ_VERSION, VCHIQ_VERSION_MIN);
@@ -1398,9 +1395,12 @@ static int vchiq_probe(struct platform_device *pdev)
ret = vchiq_register_chrdev(&pdev->dev);
if (ret) {
dev_err(&pdev->dev, "arm: Failed to initialize vchiq cdev\n");
+ vchiq_platform_uninit(mgmt);
return ret;
}
+ vchiq_debugfs_init(&mgmt->state);
+
bcm2835_audio = vchiq_device_register(&pdev->dev, "bcm2835-audio");
bcm2835_camera = vchiq_device_register(&pdev->dev, "bcm2835-camera");
@@ -1410,19 +1410,12 @@ static int vchiq_probe(struct platform_device *pdev)
static void vchiq_remove(struct platform_device *pdev)
{
struct vchiq_drv_mgmt *mgmt = dev_get_drvdata(&pdev->dev);
- struct vchiq_arm_state *arm_state;
vchiq_device_unregister(bcm2835_audio);
vchiq_device_unregister(bcm2835_camera);
vchiq_debugfs_deinit();
vchiq_deregister_chrdev();
-
- kthread_stop(mgmt->state.sync_thread);
- kthread_stop(mgmt->state.recycle_thread);
- kthread_stop(mgmt->state.slot_handler_thread);
-
- arm_state = vchiq_platform_get_arm_state(&mgmt->state);
- kthread_stop(arm_state->ka_thread);
+ vchiq_platform_uninit(mgmt);
}
static struct platform_driver vchiq_driver = {
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 8d5795db4f39..e7b0c800a205 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -470,7 +470,7 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason,
cb_userdata = bulk->cb_userdata;
}
- dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %pK, %pK %pK)\n",
+ dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %p, %p %p)\n",
service->state->id, service->localport, reason_names[reason],
header, cb_data, cb_userdata);
status = service->base.callback(service->instance, reason, header, service->handle,
@@ -778,7 +778,7 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found,
complete(&quota->quota_event);
} else if (count == 0) {
dev_err(state->dev,
- "core: service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)\n",
+ "core: service %d message_use_count=%d (header %p, msgid %x, header->msgid %x, header->size %x)\n",
port, quota->message_use_count, header, msgid,
header->msgid, header->size);
WARN(1, "invalid message use count\n");
@@ -799,11 +799,11 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found,
* it has dropped below its quota
*/
complete(&quota->quota_event);
- dev_dbg(state->dev, "core: %d: pfq:%d %x@%pK - slot_use->%d\n",
+ dev_dbg(state->dev, "core: %d: pfq:%d %x@%p - slot_use->%d\n",
state->id, port, header->size, header, count - 1);
} else {
dev_err(state->dev,
- "core: service %d slot_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)\n",
+ "core: service %d slot_use_count=%d (header %p, msgid %x, header->msgid %x, header->size %x)\n",
port, count, header, msgid, header->msgid, header->size);
WARN(1, "bad slot use count\n");
}
@@ -845,7 +845,7 @@ process_free_queue(struct vchiq_state *state, u32 *service_found,
*/
rmb();
- dev_dbg(state->dev, "core: %d: pfq %d=%pK %x %x\n",
+ dev_dbg(state->dev, "core: %d: pfq %d=%p %x %x\n",
state->id, slot_index, data, local->slot_queue_recycle,
slot_queue_available);
@@ -868,7 +868,7 @@ process_free_queue(struct vchiq_state *state, u32 *service_found,
pos += calc_stride(header->size);
if (pos > VCHIQ_SLOT_SIZE) {
dev_err(state->dev,
- "core: pfq - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x\n",
+ "core: pfq - pos %x: header %p, msgid %x, header->msgid %x, header->size %x\n",
pos, header, msgid, header->msgid, header->size);
WARN(1, "invalid slot position\n");
}
@@ -1060,7 +1060,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
int tx_end_index;
int slot_use_count;
- dev_dbg(state->dev, "core: %d: qm %s@%pK,%zx (%d->%d)\n",
+ dev_dbg(state->dev, "core: %d: qm %s@%p,%zx (%d->%d)\n",
state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size,
VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid));
@@ -1117,7 +1117,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count);
VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size);
} else {
- dev_dbg(state->dev, "core: %d: qm %s@%pK,%zx (%d->%d)\n",
+ dev_dbg(state->dev, "core: %d: qm %s@%p,%zx (%d->%d)\n",
state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size,
VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid));
if (size != 0) {
@@ -1204,7 +1204,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service,
state->id, oldmsgid);
}
- dev_dbg(state->dev, "sync: %d: qms %s@%pK,%x (%d->%d)\n",
+ dev_dbg(state->dev, "sync: %d: qms %s@%p,%x (%d->%d)\n",
state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size,
VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid));
@@ -1539,7 +1539,7 @@ create_pagelist(struct vchiq_instance *instance, struct vchiq_bulk *bulk)
pagelist = dma_alloc_coherent(instance->state->dev, pagelist_size, &dma_addr,
GFP_KERNEL);
- dev_dbg(instance->state->dev, "arm: %pK\n", pagelist);
+ dev_dbg(instance->state->dev, "arm: %p\n", pagelist);
if (!pagelist)
return NULL;
@@ -1692,7 +1692,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel
unsigned int num_pages = pagelistinfo->num_pages;
unsigned int cache_line_size;
- dev_dbg(instance->state->dev, "arm: %pK, %d\n", pagelistinfo->pagelist, actual);
+ dev_dbg(instance->state->dev, "arm: %p, %d\n", pagelistinfo->pagelist, actual);
drv_mgmt = dev_get_drvdata(instance->state->dev);
@@ -1849,7 +1849,7 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header)
payload = (struct vchiq_open_payload *)header->data;
fourcc = payload->fourcc;
- dev_dbg(state->dev, "core: %d: prs OPEN@%pK (%d->'%p4cc')\n",
+ dev_dbg(state->dev, "core: %d: prs OPEN@%p (%d->'%p4cc')\n",
state->id, header, localport, &fourcc);
service = get_listening_service(state, fourcc);
@@ -1976,14 +1976,14 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
service = get_connected_service(state, remoteport);
if (service)
dev_warn(state->dev,
- "core: %d: prs %s@%pK (%d->%d) - found connected service %d\n",
+ "core: %d: prs %s@%p (%d->%d) - found connected service %d\n",
state->id, msg_type_str(type), header,
remoteport, localport, service->localport);
}
if (!service) {
dev_err(state->dev,
- "core: %d: prs %s@%pK (%d->%d) - invalid/closed service %d\n",
+ "core: %d: prs %s@%p (%d->%d) - invalid/closed service %d\n",
state->id, msg_type_str(type), header, remoteport,
localport, localport);
goto skip_message;
@@ -2003,7 +2003,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
if (((unsigned long)header & VCHIQ_SLOT_MASK) +
calc_stride(size) > VCHIQ_SLOT_SIZE) {
- dev_err(state->dev, "core: header %pK (msgid %x) - size %x too big for slot\n",
+ dev_err(state->dev, "core: header %p (msgid %x) - size %x too big for slot\n",
header, (unsigned int)msgid, (unsigned int)size);
WARN(1, "oversized for slot\n");
}
@@ -2022,7 +2022,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
service->peer_version = payload->version;
}
dev_dbg(state->dev,
- "core: %d: prs OPENACK@%pK,%x (%d->%d) v:%d\n",
+ "core: %d: prs OPENACK@%p,%x (%d->%d) v:%d\n",
state->id, header, size, remoteport, localport,
service->peer_version);
if (service->srvstate == VCHIQ_SRVSTATE_OPENING) {
@@ -2037,7 +2037,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
case VCHIQ_MSG_CLOSE:
WARN_ON(size); /* There should be no data */
- dev_dbg(state->dev, "core: %d: prs CLOSE@%pK (%d->%d)\n",
+ dev_dbg(state->dev, "core: %d: prs CLOSE@%p (%d->%d)\n",
state->id, header, remoteport, localport);
mark_service_closing_internal(service, 1);
@@ -2049,7 +2049,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
&service->base.fourcc, service->localport, service->remoteport);
break;
case VCHIQ_MSG_DATA:
- dev_dbg(state->dev, "core: %d: prs DATA@%pK,%x (%d->%d)\n",
+ dev_dbg(state->dev, "core: %d: prs DATA@%p,%x (%d->%d)\n",
state->id, header, size, remoteport, localport);
if ((service->remoteport == remoteport) &&
@@ -2069,7 +2069,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
}
break;
case VCHIQ_MSG_CONNECT:
- dev_dbg(state->dev, "core: %d: prs CONNECT@%pK\n",
+ dev_dbg(state->dev, "core: %d: prs CONNECT@%p\n",
state->id, header);
state->version_common = ((struct vchiq_slot_zero *)
state->slot_data)->version;
@@ -2102,7 +2102,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
if ((int)(queue->remote_insert -
queue->local_insert) >= 0) {
dev_err(state->dev,
- "core: %d: prs %s@%pK (%d->%d) unexpected (ri=%d,li=%d)\n",
+ "core: %d: prs %s@%p (%d->%d) unexpected (ri=%d,li=%d)\n",
state->id, msg_type_str(type), header, remoteport,
localport, queue->remote_insert, queue->local_insert);
mutex_unlock(&service->bulk_mutex);
@@ -2120,7 +2120,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
bulk->actual = *(int *)header->data;
queue->remote_insert++;
- dev_dbg(state->dev, "core: %d: prs %s@%pK (%d->%d) %x@%pad\n",
+ dev_dbg(state->dev, "core: %d: prs %s@%p (%d->%d) %x@%pad\n",
state->id, msg_type_str(type), header, remoteport,
localport, bulk->actual, &bulk->dma_addr);
@@ -2140,12 +2140,12 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
}
break;
case VCHIQ_MSG_PADDING:
- dev_dbg(state->dev, "core: %d: prs PADDING@%pK,%x\n",
+ dev_dbg(state->dev, "core: %d: prs PADDING@%p,%x\n",
state->id, header, size);
break;
case VCHIQ_MSG_PAUSE:
/* If initiated, signal the application thread */
- dev_dbg(state->dev, "core: %d: prs PAUSE@%pK,%x\n",
+ dev_dbg(state->dev, "core: %d: prs PAUSE@%p,%x\n",
state->id, header, size);
if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) {
dev_err(state->dev, "core: %d: PAUSE received in state PAUSED\n",
@@ -2162,7 +2162,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSED);
break;
case VCHIQ_MSG_RESUME:
- dev_dbg(state->dev, "core: %d: prs RESUME@%pK,%x\n",
+ dev_dbg(state->dev, "core: %d: prs RESUME@%p,%x\n",
state->id, header, size);
/* Release the slot mutex */
mutex_unlock(&state->slot_mutex);
@@ -2179,7 +2179,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
break;
default:
- dev_err(state->dev, "core: %d: prs invalid msgid %x@%pK,%x\n",
+ dev_err(state->dev, "core: %d: prs invalid msgid %x@%p,%x\n",
state->id, msgid, header, size);
WARN(1, "invalid message\n");
break;
@@ -2400,7 +2400,7 @@ sync_func(void *v)
if (!service) {
dev_err(state->dev,
- "sync: %d: sf %s@%pK (%d->%d) - invalid/closed service %d\n",
+ "sync: %d: sf %s@%p (%d->%d) - invalid/closed service %d\n",
state->id, msg_type_str(type), header, remoteport,
localport, localport);
release_message_sync(state, header);
@@ -2422,7 +2422,7 @@ sync_func(void *v)
header->data;
service->peer_version = payload->version;
}
- dev_err(state->dev, "sync: %d: sf OPENACK@%pK,%x (%d->%d) v:%d\n",
+ dev_err(state->dev, "sync: %d: sf OPENACK@%p,%x (%d->%d) v:%d\n",
state->id, header, size, remoteport, localport,
service->peer_version);
if (service->srvstate == VCHIQ_SRVSTATE_OPENING) {
@@ -2435,7 +2435,7 @@ sync_func(void *v)
break;
case VCHIQ_MSG_DATA:
- dev_dbg(state->dev, "sync: %d: sf DATA@%pK,%x (%d->%d)\n",
+ dev_dbg(state->dev, "sync: %d: sf DATA@%p,%x (%d->%d)\n",
state->id, header, size, remoteport, localport);
if ((service->remoteport == remoteport) &&
@@ -2449,7 +2449,7 @@ sync_func(void *v)
break;
default:
- dev_err(state->dev, "sync: error: %d: sf unexpected msgid %x@%pK,%x\n",
+ dev_err(state->dev, "sync: error: %d: sf unexpected msgid %x@%p,%x\n",
state->id, msgid, header, size);
release_message_sync(state, header);
break;
@@ -2926,13 +2926,13 @@ release_service_messages(struct vchiq_service *service)
int port = VCHIQ_MSG_DSTPORT(msgid);
if ((port == service->localport) && (msgid & VCHIQ_MSGID_CLAIMED)) {
- dev_dbg(state->dev, "core: fsi - hdr %pK\n", header);
+ dev_dbg(state->dev, "core: fsi - hdr %p\n", header);
release_slot(state, slot_info, header, NULL);
}
pos += calc_stride(header->size);
if (pos > VCHIQ_SLOT_SIZE) {
dev_err(state->dev,
- "core: fsi - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x\n",
+ "core: fsi - pos %x: header %p, msgid %x, header->msgid %x, header->size %x\n",
pos, header, msgid, header->msgid, header->size);
WARN(1, "invalid slot position\n");
}
@@ -3091,7 +3091,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
*/
wmb();
- dev_dbg(state->dev, "core: %d: bt (%d->%d) %cx %x@%pad %pK\n",
+ dev_dbg(state->dev, "core: %d: bt (%d->%d) %cx %x@%pad %p\n",
state->id, service->localport, service->remoteport,
dir_char, bulk->size, &bulk->dma_addr, bulk->cb_data);
@@ -3343,6 +3343,7 @@ vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instanc
return -EAGAIN;
vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED);
+ vchiq_platform_connected(state);
complete(&state->connect);
}
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
index 9b4e766990a4..3b5c0618e567 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
@@ -575,6 +575,8 @@ int vchiq_send_remote_use(struct vchiq_state *state);
int vchiq_send_remote_use_active(struct vchiq_state *state);
+void vchiq_platform_connected(struct vchiq_state *state);
+
void vchiq_platform_conn_state_changed(struct vchiq_state *state,
enum vchiq_connstate oldstate,
enum vchiq_connstate newstate);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
index 454f43416503..3b20ba5c7362 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
@@ -270,7 +270,7 @@ static int vchiq_ioc_dequeue_message(struct vchiq_instance *instance,
}
} else {
dev_err(service->state->dev,
- "arm: header %pK: bufsize %x < size %x\n",
+ "arm: header %p: bufsize %x < size %x\n",
header, args->bufsize, header->size);
WARN(1, "invalid size\n");
ret = -EMSGSIZE;
@@ -328,7 +328,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
ret = -ESRCH;
goto out;
}
- dev_dbg(service->state->dev, "arm: found bulk_waiter %pK for pid %d\n",
+ dev_dbg(service->state->dev, "arm: found bulk_waiter %p for pid %d\n",
waiter, current->pid);
status = vchiq_bulk_xfer_waiting(instance, args->handle,
@@ -366,7 +366,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
mutex_lock(&instance->bulk_waiter_list_mutex);
list_add(&waiter->list, &instance->bulk_waiter_list);
mutex_unlock(&instance->bulk_waiter_list_mutex);
- dev_dbg(service->state->dev, "arm: saved bulk_waiter %pK for pid %d\n",
+ dev_dbg(service->state->dev, "arm: saved bulk_waiter %p for pid %d\n",
waiter, current->pid);
ret = put_user(mode_waiting, mode);
@@ -512,7 +512,7 @@ static int vchiq_ioc_await_completion(struct vchiq_instance *instance,
/* This must be a VCHIQ-style service */
if (args->msgbufsize < msglen) {
dev_err(service->state->dev,
- "arm: header %pK: msgbufsize %x < msglen %x\n",
+ "arm: header %p: msgbufsize %x < msglen %x\n",
header, args->msgbufsize, msglen);
WARN(1, "invalid message size\n");
if (ret == 0)
@@ -588,7 +588,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
long ret = 0;
int i, rc;
- dev_dbg(instance->state->dev, "arm: instance %pK, cmd %s, arg %lx\n", instance,
+ dev_dbg(instance->state->dev, "arm: instance %p, cmd %s, arg %lx\n", instance,
((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) && (_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?
ioctl_names[_IOC_NR(cmd)] : "<invalid>", arg);
@@ -874,12 +874,12 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (!status && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK)) {
dev_dbg(instance->state->dev,
- "arm: ioctl instance %pK, cmd %s -> status %d, %ld\n",
+ "arm: ioctl instance %p, cmd %s -> status %d, %ld\n",
instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ?
ioctl_names[_IOC_NR(cmd)] : "<invalid>", status, ret);
} else {
dev_dbg(instance->state->dev,
- "arm: ioctl instance %pK, cmd %s -> status %d\n, %ld\n",
+ "arm: ioctl instance %p, cmd %s -> status %d\n, %ld\n",
instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ?
ioctl_names[_IOC_NR(cmd)] : "<invalid>", status, ret);
}