staging: gpib: Add return value to request_control
PATCH 1/1 staging: gpib: Add return value to request_control
A number of drivers are unable to release control due to hardware or software limitations. As request_control was defined as void - no error could be signalled. Some drivers also did not implement request_control correctly by setting controller_in_charge instead of system_controller.
This patch changes the prototype of request_control to int and adds the appropriate checking and returns. In the case that a board cannot release control EPERM is returned. The faulty implementations have been corrected.
--- .../gpib/agilent_82350b/agilent_82350b.c | 7 +++-- .../gpib/agilent_82357a/agilent_82357a.c | 31 +++++++++---------- drivers/staging/gpib/cb7210/cb7210.c | 4 +-- drivers/staging/gpib/cec/cec_gpib.c | 4 +-- drivers/staging/gpib/common/gpib_os.c | 4 +-- drivers/staging/gpib/common/iblib.c | 15 ++++++--- drivers/staging/gpib/eastwood/fluke_gpib.c | 4 +-- drivers/staging/gpib/fmh_gpib/fmh_gpib.c | 4 +-- drivers/staging/gpib/gpio/gpib_bitbang.c | 21 ++++++++----- drivers/staging/gpib/hp_82335/hp82335.c | 4 +-- drivers/staging/gpib/hp_82341/hp_82341.c | 4 +-- drivers/staging/gpib/include/gpib_proto.h | 2 +- drivers/staging/gpib/include/gpib_types.h | 2 +- drivers/staging/gpib/include/nec7210.h | 4 +-- drivers/staging/gpib/include/tms9914.h | 4 +-- drivers/staging/gpib/ines/ines.h | 2 +- drivers/staging/gpib/ines/ines_gpib.c | 4 +-- .../gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 14 +++++---- drivers/staging/gpib/nec7210/nec7210.c | 5 +-- drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 8 ++--- drivers/staging/gpib/pc2/pc2_gpib.c | 4 +-- drivers/staging/gpib/tms9914/tms9914.c | 6 ++-- drivers/staging/gpib/tnt4882/tnt4882_gpib.c | 6 ++-- 23 files changed, 91 insertions(+), 72 deletions(-)
drivers/staging/gpib/agilent_82350b/agilent_82350b.c +5 -2
@@ -339,10 +339,11 @@ static int agilent_82350b_go_to_standby(gpib_board_t *board)return tms9914_go_to_standby (board, &priv->tms9914_priv); } -static void agilent_82350b_request_system_control (gpib_board_t *board,int request_control) +static int agilent_82350b_request_system_control (gpib_board_t *board,int request_control) {struct agilent_82350b_priv *a_priv = board->private_data; +int retval;if (request_control) { a_priv->card_mode_bits |=CM_SYSTEM_CONTROLLER_BIT ;
@@ -354,7 +355,9 @@ static void agilent_82350b_request_system_control(gpib_board_t *board, int requewriteb (0 , a_priv->gpib_base +INTERNAL_CONFIG_REG ); }writeb (a_priv->card_mode_bits, a_priv->gpib_base +CARD_MODE_REG ); -tms9914_request_system_control (board, &a_priv->tms9914_priv, request_control); + retval =tms9914_request_system_control (board, &a_priv->tms9914_priv, request_control); + +return retval; }static void agilent_82350b_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/agilent_82357a/agilent_82357a.c +15 -16
@@ -751,8 +751,7 @@ static int agilent_82357a_go_to_standby(gpib_board_t *board)return 0 ; } -//FIXME should change prototype to return int -static void agilent_82357a_request_system_control (gpib_board_t *board,int request_control) +static int agilent_82357a_request_system_control (gpib_board_t *board,int request_control) {struct agilent_82357a_priv *a_priv = board->private_data;struct usb_device *usb_dev;
@@ -761,19 +760,15 @@ static void agilent_82357a_request_system_control(gpib_board_t *board, int requeint i =0 ;if (!a_priv->bus_interface) -return ;// -ENODEV; +return -ENODEV ; +if (!request_control) +return -EPERM ;/* can't not be system controller */ 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) { - writes[i].value =AUX_RQC ; - a_priv->hw_control_bits |=SYSTEM_CONTROLLER ; - }else { - writes[i].value =AUX_RLC ; - a_priv->is_cic =0 ; - a_priv->hw_control_bits &= ~SYSTEM_CONTROLLER ; - } + writes[i].value =AUX_RQC ; + a_priv->hw_control_bits |=SYSTEM_CONTROLLER ; ++i; writes[i].address =HW_CONTROL ; writes[i].value = a_priv->hw_control_bits;
@@ -781,7 +776,7 @@ static void agilent_82357a_request_system_control(gpib_board_t *board, int reque retval =agilent_82357a_write_registers (a_priv, writes, i);if (retval)dev_err (&usb_dev->dev,"write_registers() returned error\n" ); -return ;// retval; +return retval; }static void agilent_82357a_interface_clear (gpib_board_t *board,int assert)
@@ -1584,7 +1579,7 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface) {struct usb_device *usb_dev =interface_to_usbdev (interface);gpib_board_t *board; -int i, retval; +int i, retval =0 ;mutex_lock (&agilent_82357a_hotplug_lock);
@@ -1595,8 +1590,10 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)break ; } } -if (i ==MAX_NUM_82357A_INTERFACES ) +if (i ==MAX_NUM_82357A_INTERFACES ) { + retval = -ENOENT ; goto resume_exit; + }struct agilent_82357a_priv *a_priv = board->private_data;
@@ -1619,7 +1616,9 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)return retval; }// set/unset system controller -agilent_82357a_request_system_control (board, board->master); + retval =agilent_82357a_request_system_control (board, board->master); +if (retval) + goto resume_exit;// toggle ifc if master if (board->master) {agilent_82357a_interface_clear (board,1 );
@@ -1637,7 +1636,7 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface) resume_exit:mutex_unlock (&agilent_82357a_hotplug_lock); -return 0 ; +return retval; }static struct usb_driver agilent_82357a_bus_driver = {
drivers/staging/gpib/cb7210/cb7210.c +2 -2
@@ -577,7 +577,7 @@ static int cb7210_go_to_standby(gpib_board_t *board)return nec7210_go_to_standby (board, &priv->nec7210_priv); } -static void cb7210_request_system_control (gpib_board_t *board,int request_control) +static int cb7210_request_system_control (gpib_board_t *board,int request_control) {struct cb7210_priv *priv = board->private_data;struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -588,7 +588,7 @@ static void cb7210_request_system_control(gpib_board_t *board, int request_contr priv->hs_mode_bits &= ~HS_SYS_CONTROL ;cb7210_write_byte (priv, priv->hs_mode_bits,HS_MODE ); -nec7210_request_system_control (board, nec_priv, request_control); +return nec7210_request_system_control (board, nec_priv, request_control); }static void cb7210_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/cec/cec_gpib.c +2 -2
@@ -82,11 +82,11 @@ static int cec_go_to_standby(gpib_board_t *board)return nec7210_go_to_standby (board, &priv->nec7210_priv); } -static void cec_request_system_control (gpib_board_t *board,int request_control) +static int cec_request_system_control (gpib_board_t *board,int request_control) {struct cec_priv *priv = board->private_data; -nec7210_request_system_control (board, &priv->nec7210_priv, request_control); +return nec7210_request_system_control (board, &priv->nec7210_priv, request_control); }static void cec_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/common/gpib_os.c +1 -3
@@ -1970,9 +1970,7 @@ static int request_system_control_ioctl(gpib_board_t *board, unsigned long arg)if (retval)return -EFAULT ; -ibrsc (board, request_control); - -return 0 ; +return ibrsc (board, request_control); }static int t1_delay_ioctl (gpib_board_t *board,unsigned long arg)
drivers/staging/gpib/common/iblib.c +11 -4
@@ -418,12 +418,19 @@ int ibsic(gpib_board_t *board, unsigned int usec_duration)return 0 ; } -/* FIXME make int */ -void ibrsc (gpib_board_t *board,int request_control) +int ibrsc (gpib_board_t *board,int request_control) { - board->master = request_control !=0 ; +int retval; +if (board->interface->request_system_control) - board->interface->request_system_control (board, request_control); + retval = board->interface->request_system_control (board, request_control); +else + retval = -EPERM ; + +if (!retval) + board->master = request_control !=0 ; + +return retval; }/*
drivers/staging/gpib/eastwood/fluke_gpib.c +2 -2
@@ -91,12 +91,12 @@ static int fluke_go_to_standby(gpib_board_t *board)return nec7210_go_to_standby (board, &priv->nec7210_priv); } -static void fluke_request_system_control (gpib_board_t *board,int request_control) +static int fluke_request_system_control (gpib_board_t *board,int request_control) {struct fluke_priv *priv = board->private_data;struct nec7210_priv *nec_priv = &priv->nec7210_priv; -nec7210_request_system_control (board, nec_priv, request_control); +return nec7210_request_system_control (board, nec_priv, request_control); }static void fluke_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/fmh_gpib/fmh_gpib.c +2 -2
@@ -82,12 +82,12 @@ static int fmh_gpib_go_to_standby(gpib_board_t *board)return nec7210_go_to_standby (board, &priv->nec7210_priv); } -static void fmh_gpib_request_system_control (gpib_board_t *board,int request_control) +static int fmh_gpib_request_system_control (gpib_board_t *board,int request_control) {struct fmh_priv *priv = board->private_data;struct nec7210_priv *nec_priv = &priv->nec7210_priv; -nec7210_request_system_control (board, nec_priv, request_control); +return nec7210_request_system_control (board, nec_priv, request_control); }static void fmh_gpib_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/gpio/gpib_bitbang.c +13 -8
@@ -855,6 +855,7 @@ static void set_atn(gpib_board_t *board, int atn_asserted) priv->listener_state = listener_addressed;if (priv->talker_state == talker_active) priv->talker_state = talker_addressed; +SET_DIR_WRITE (priv);// need to be able to read bus NRFD/NDAC }else {if (priv->listener_state == listener_addressed) { priv->listener_state = listener_active;
@@ -871,7 +872,6 @@ static int bb_take_control(gpib_board_t *board, int synchronous) {dbg_printk (2 ,"%d\n" , synchronous);set_atn (board,1 ); -set_bit (CIC_NUM , &board->status);return 0 ; }
@@ -882,16 +882,22 @@ static int bb_go_to_standby(gpib_board_t *board)return 0 ; } -static void bb_request_system_control (gpib_board_t *board,int request_control) +static int bb_request_system_control (gpib_board_t *board,int request_control) { +struct bb_priv *priv = board->private_data; +dbg_printk (2 ,"%d\n" , request_control);if (request_control) { -set_bit (CIC_NUM , &board->status); -// drive DAV & EOI false, enable NRFD & NDAC irqs -SET_DIR_WRITE (board->private_data); +gpiod_direction_output (REN ,1 );/* user space must enable REN if needed */ +gpiod_direction_output (IFC ,1 );/* user space must toggle IFC if needed */ +if (sn7516x) +gpiod_direction_output (DC ,0 );/* enable ATN as output on SN75161/2 */ +gpiod_direction_input (SRQ ); +ENABLE_IRQ (priv->irq_SRQ,IRQ_TYPE_EDGE_FALLING ); }else { -clear_bit (CIC_NUM , &board->status); +return -EPERM ; } +return 0 ; }static void bb_interface_clear (gpib_board_t *board,int assert)
@@ -903,6 +909,7 @@ static void bb_interface_clear(gpib_board_t *board, int assert)gpiod_direction_output (IFC ,0 ); priv->talker_state = talker_idle; priv->listener_state = listener_idle; +set_bit (CIC_NUM , &board->status); }else {gpiod_direction_output (IFC ,1 ); }
@@ -1293,8 +1300,6 @@ static int bb_attach(gpib_board_t *board, const gpib_board_config_t *config) IRQF_TRIGGER_NONE)) goto bb_attach_fail_r; -ENABLE_IRQ (priv->irq_SRQ,IRQ_TYPE_EDGE_FALLING ); -dbg_printk (0 ,"attached board %d\n" , board->minor); goto bb_attach_out;
drivers/staging/gpib/hp_82335/hp82335.c +2 -2
@@ -67,11 +67,11 @@ static int hp82335_go_to_standby(gpib_board_t *board)return tms9914_go_to_standby (board, &priv->tms9914_priv); } -static void hp82335_request_system_control (gpib_board_t *board,int request_control) +static int hp82335_request_system_control (gpib_board_t *board,int request_control) {struct hp82335_priv *priv = board->private_data; -tms9914_request_system_control (board, &priv->tms9914_priv, request_control); +return tms9914_request_system_control (board, &priv->tms9914_priv, request_control); }static void hp82335_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/hp_82341/hp_82341.c +2 -2
@@ -293,7 +293,7 @@ static int hp_82341_go_to_standby(gpib_board_t *board)return tms9914_go_to_standby (board, &priv->tms9914_priv); } -static void hp_82341_request_system_control (gpib_board_t *board,int request_control) +static int hp_82341_request_system_control (gpib_board_t *board,int request_control) {struct hp_82341_priv *priv = board->private_data;
@@ -302,7 +302,7 @@ static void hp_82341_request_system_control(gpib_board_t *board, int request_conelse priv->mode_control_bits &= ~SYSTEM_CONTROLLER_BIT ;outb (priv->mode_control_bits, priv->iobase[0 ] +MODE_CONTROL_STATUS_REG ); -tms9914_request_system_control (board, &priv->tms9914_priv, request_control); +return tms9914_request_system_control (board, &priv->tms9914_priv, request_control); }static void hp_82341_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/include/gpib_proto.h +1 -1
@@ -38,7 +38,7 @@ 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 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);
drivers/staging/gpib/include/gpib_types.h +1 -1
@@ -93,7 +93,7 @@ struct gpib_interface_struct {*/ int (*go_to_standby)(gpib_board_t *board);/* request/release control of the IFC and REN lines (system controller) */ -void (*request_system_control)(gpib_board_t *board,int request_control); +int (*request_system_control)(gpib_board_t *board,int request_control);/* Asserts or de-asserts 'interface clear' (IFC) depending on * boolean value of 'assert' */
drivers/staging/gpib/include/nec7210.h +2 -2
@@ -86,8 +86,8 @@ int nec7210_command(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buf 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, -struct nec7210_priv *priv,int request_control); +int nec7210_request_system_control (gpib_board_t *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,
drivers/staging/gpib/include/tms9914.h +2 -2
@@ -92,8 +92,8 @@ int tms9914_take_control(gpib_board_t *board, struct tms9914_priv *priv, int synint tms9914_take_control_workaround (gpib_board_t *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 request_control); +int tms9914_request_system_control (gpib_board_t *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,
drivers/staging/gpib/ines/ines.h +1 -1
@@ -46,7 +46,7 @@ int ines_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length,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); +int 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);
drivers/staging/gpib/ines/ines_gpib.c +2 -2
@@ -440,11 +440,11 @@ int ines_go_to_standby(gpib_board_t *board)return nec7210_go_to_standby (board, &priv->nec7210_priv); } -void ines_request_system_control (gpib_board_t *board,int request_control) +int ines_request_system_control (gpib_board_t *board,int request_control) {struct ines_priv *priv = board->private_data; -nec7210_request_system_control (board, &priv->nec7210_priv, request_control); +return nec7210_request_system_control (board, &priv->nec7210_priv, request_control); }void ines_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c +8 -6
@@ -921,15 +921,17 @@ static void usb_gpib_remote_enable(gpib_board_t *board, int enable)/* request_system_control */ -static void usb_gpib_request_system_control (gpib_board_t *board, -int request_control) +static int usb_gpib_request_system_control (gpib_board_t *board,int request_control) { -if (request_control) -set_bit (CIC_NUM , &board->status); +int retval; + +if (!request_control) + retval = -EPERM ;else -clear_bit (CIC_NUM , &board->status); + retval =0 ; +DIA_LOG (1 ,"done with %d -> retval %i\n" , request_control, retval); -DIA_LOG (1 ,"done with %d -> %lx\n" , request_control, board->status); +return retval; }/* take_control */
drivers/staging/gpib/nec7210/nec7210.c +3 -2
@@ -329,14 +329,15 @@ 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, -int request_control) +int nec7210_request_system_control (gpib_board_t *board,struct nec7210_priv *priv, +int request_control) {if (request_control ==0 ) {write_byte (priv,AUX_CREN ,AUXMR );write_byte (priv,AUX_CIFC ,AUXMR );write_byte (priv,AUX_DSC ,AUXMR ); } +return 0 ; }EXPORT_SYMBOL (nec7210_request_system_control);
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +4 -4
@@ -1049,7 +1049,7 @@ static int ni_usb_go_to_standby(gpib_board_t *board)return 0 ; } -static void ni_usb_request_system_control (gpib_board_t *board,int request_control) +static int ni_usb_request_system_control (gpib_board_t *board,int request_control) {int retval;struct ni_usb_priv *ni_priv = board->private_data;
@@ -1059,7 +1059,7 @@ static void ni_usb_request_system_control(gpib_board_t *board, int request_contrunsigned int ibsta;if (!ni_priv->bus_interface) -return ;// -ENODEV; +return -ENODEV ; usb_dev =interface_to_usbdev (ni_priv->bus_interface);if (request_control) { writes[i].device =NIUSB_SUBDEV_TNT4882 ;
@@ -1091,12 +1091,12 @@ 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,"register write failed, retval=%i\n" , retval); -return ;// retval; +return retval; }if (!request_control) ni_priv->ren_state =0 ;ni_usb_soft_update_status (board, ibsta,0 ); -return ;// 0; +return 0 ; }//FIXME maybe the interface should have a "pulse interface clear" function that can return an error?
drivers/staging/gpib/pc2/pc2_gpib.c +2 -2
@@ -127,11 +127,11 @@ static int pc2_go_to_standby(gpib_board_t *board)return nec7210_go_to_standby (board, &priv->nec7210_priv); } -static void pc2_request_system_control (gpib_board_t *board,int request_control) +static int pc2_request_system_control (gpib_board_t *board,int request_control) {struct pc2_priv *priv = board->private_data; -nec7210_request_system_control (board, &priv->nec7210_priv, request_control); +return nec7210_request_system_control (board, &priv->nec7210_priv, request_control); }static void pc2_interface_clear (gpib_board_t *board,int assert)
drivers/staging/gpib/tms9914/tms9914.c +4 -2
@@ -116,8 +116,8 @@ 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, -int request_control) +int tms9914_request_system_control (gpib_board_t *board,struct tms9914_priv *priv, +int request_control) {if (request_control) {write_byte (priv,AUX_RQC ,AUXCR );
@@ -125,6 +125,8 @@ void tms9914_request_system_control(gpib_board_t *board, struct tms9914_priv *prclear_bit (CIC_NUM , &board->status);write_byte (priv,AUX_RLC ,AUXCR ); } + +return 0 ; }EXPORT_SYMBOL_GPL (tms9914_request_system_control);
drivers/staging/gpib/tnt4882/tnt4882_gpib.c +4 -2
@@ -642,19 +642,21 @@ static int tnt4882_go_to_standby(gpib_board_t *board)return nec7210_go_to_standby (board, &priv->nec7210_priv); } -static void tnt4882_request_system_control (gpib_board_t *board,int request_control) +static int tnt4882_request_system_control (gpib_board_t *board,int request_control) {struct tnt4882_priv *priv = board->private_data; +int retval;if (request_control) {tnt_writeb (priv,SETSC ,CMDR );udelay (1 ); } -nec7210_request_system_control (board, &priv->nec7210_priv, request_control); + retval =nec7210_request_system_control (board, &priv->nec7210_priv, request_control);if (!request_control) {tnt_writeb (priv,CLRSC ,CMDR );udelay (1 ); } +return retval; }static void tnt4882_interface_clear (gpib_board_t *board,int assert)
Signature · 1 line
2.48.1
Quoted 11 lines · Dave Penkler
A number of drivers are unable to release control due to hardware or software limitations. As
request_controlwas defined as void - no error could be signalled. Some drivers also did not implementrequest_controlcorrectly by settingcontroller_in_chargeinstead ofsystem_controller.This patch changes the prototype of
request_controlto int and adds the appropriate checking and returns. In the case that a board cannot release control EPERM is returned. The faulty implementations have been corrected.
This patch is hard to read because it does several things:
1) It changes the functions from returning void to int. This is the overwhelming noisiest part of the patch so it's hard to even see the other changes in amongst the noise.
2) Returns -EPERM if request_control is false.
3) Changes some stuff like SET_DIR_WRITE(priv); and ENABLE_IRQ(priv->irq_SRQ, IRQ_TYPE_EDGE_FALLING); I can't tell if that's related or not.
You'll need to do it in two or three patches. The first thing is to just change the void to int. That's a simple mechanical change. The only worry is if some functions are returning an error code on failure and I don't know the answer to that. (That would break git bisect so it would be against the rules, even if it's fixed in patch 2 and 3).
The actual logic changes will hopefully be easier to understand when the diff is smaller.
Quoted 10 lines
drivers/staging/gpib/agilent_82350b/agilent_82350b.c +2
-1-static void agilent_82350b_request_system_control (gpib_board_t *board,int request_control) +static int agilent_82350b_request_system_control (gpib_board_t *board,int request_control) {struct agilent_82350b_priv *a_priv = board->private_data; +int retval;if (request_control) { a_priv->card_mode_bits |=CM_SYSTEM_CONTROLLER_BIT ;
drivers/staging/gpib/agilent_82350b/agilent_82350b.c static void agilent_82350b_request_system_control(gpib_board_t *board, int reque · line 360
Quoted 7 lines
drivers/staging/gpib/agilent_82350b/agilent_82350b.c +3
-1@@ -354,7 +355,9 @@ static void agilent_82350b_request_system_control(gpib_board_t *board, int requewriteb (0 , a_priv->gpib_base +INTERNAL_CONFIG_REG ); }writeb (a_priv->card_mode_bits, a_priv->gpib_base +CARD_MODE_REG ); -tms9914_request_system_control (board, &a_priv->tms9914_priv, request_control); + retval =tms9914_request_system_control (board, &a_priv->tms9914_priv, request_control); + +return retval;
Get rid of the retval variable. This should be:
return tms9914_request_system_control(board, &a_priv->tms9914_priv, request_control);
Quoted 17 lines
drivers/staging/gpib/common/iblib.c +3
-4@@ -418,12 +418,19 @@ int ibsic(gpib_board_t *board, unsigned int usec_duration)return 0 ; } -/* FIXME make int */ -void ibrsc (gpib_board_t *board,int request_control) +int ibrsc (gpib_board_t *board,int request_control) { - board->master = request_control !=0 ; +int retval; +if (board->interface->request_system_control) - board->interface->request_system_control (board, request_control);
drivers/staging/gpib/common/iblib.c int ibsic(gpib_board_t *board, unsigned int usec_duration) · line 435
Quoted 10 lines
drivers/staging/gpib/common/iblib.c +8
-0+ retval = board->interface->request_system_control (board, request_control); + else + retval = -EPERM ; + +if (!retval) + board->master = request_control !=0 ; + +return retval; }
It would be better to reverse some of these conditions are return earlier where it's possible. (Always do failure handling, not success handling).
int ibrsc(gpib_board_t *board, int request_control)
{
int ret;
if (!board->interface->request_system_control)
return -EPERM;
ret = board->interface->request_system_control(board, request_control);
if (ret)
return ret;
board->master = !request_control;
return 0;
}regards,
dan carpenter
Quoted 100 lines · Dan Carpenter
Quoted 11 lines · Dave Penkler
A number of drivers are unable to release control due to hardware or software limitations. As
request_controlwas defined as void - no error could be signalled. Some drivers also did not implementrequest_controlcorrectly by settingcontroller_in_chargeinstead ofsystem_controller.This patch changes the prototype of
request_controlto int and adds the appropriate checking and returns. In the case that a board cannot release control EPERM is returned. The faulty implementations have been corrected.This patch is hard to read because it does several things:
1) It changes the functions from returning void to int. This is the overwhelming noisiest part of the patch so it's hard to even see the other changes in amongst the noise.
2) Returns-EPERMifrequest_controlis false.
3) Changes some stuff likeSET_DIR_WRITE(priv); andENABLE_IRQ(priv->irq_SRQ, IRQ_TYPE_EDGE_FALLING); I can't tell if that's related or not.You'll need to do it in two or three patches. The first thing is to just change the void to int. That's a simple mechanical change. The only worry is if some functions are returning an error code on failure and I don't know the answer to that. (That would break git bisect so it would be against the rules, even if it's fixed in patch 2 and 3).
The actual logic changes will hopefully be easier to understand when the diff is smaller.
Quoted 10 lines
drivers/staging/gpib/agilent_82350b/agilent_82350b.c +2
-1-static void agilent_82350b_request_system_control (gpib_board_t *board,int request_control) +static int agilent_82350b_request_system_control (gpib_board_t *board,int request_control) {struct agilent_82350b_priv *a_priv = board->private_data; +int retval;if (request_control) { a_priv->card_mode_bits |=CM_SYSTEM_CONTROLLER_BIT ;drivers/staging/gpib/agilent_82350b/agilent_82350b.c static void agilent_82350b_request_system_control(gpib_board_t *board, int reque · line 360
Quoted 7 lines
drivers/staging/gpib/agilent_82350b/agilent_82350b.c +3
-1@@ -354,7 +355,9 @@ static void agilent_82350b_request_system_control(gpib_board_t *board, int requewriteb (0 , a_priv->gpib_base +INTERNAL_CONFIG_REG ); }writeb (a_priv->card_mode_bits, a_priv->gpib_base +CARD_MODE_REG ); -tms9914_request_system_control (board, &a_priv->tms9914_priv, request_control); + retval =tms9914_request_system_control (board, &a_priv->tms9914_priv, request_control); + +return retval;Get rid of the retval variable. This should be:
return tms9914_request_system_control(board, &a_priv->tms9914_priv, request_control);Quoted 17 lines
drivers/staging/gpib/common/iblib.c +3
-4@@ -418,12 +418,19 @@ int ibsic(gpib_board_t *board, unsigned int usec_duration)return 0 ; } -/* FIXME make int */ -void ibrsc (gpib_board_t *board,int request_control) +int ibrsc (gpib_board_t *board,int request_control) { - board->master = request_control !=0 ; +int retval; +if (board->interface->request_system_control) - board->interface->request_system_control (board, request_control);drivers/staging/gpib/common/iblib.c int ibsic(gpib_board_t *board, unsigned int usec_duration) · line 435
Quoted 10 lines
drivers/staging/gpib/common/iblib.c +8
-0+ retval = board->interface->request_system_control (board, request_control); + else + retval = -EPERM ; + +if (!retval) + board->master = request_control !=0 ; + +return retval; }It would be better to reverse some of these conditions are return earlier where it's possible. (Always do failure handling, not success handling).
int
ibrsc(gpib_board_t *board, int request_control){ int ret; if (!board->interface->request_system_control) return -EPERM; ret = board->interface->request_system_control(board, request_control); if (ret) return ret; board->master = !request_control; return 0; }
Quoted 2 lines
regards,
dan carpenter
Thanks Dan.
I will submit separate patches once Greg has merged a new baseline. -dave
…
Quoted 1 line
This patch changes the prototype of
request_controlto int
…
You may occasionally put more than 58 characters into text lines of such a change description.
Regards,
Markus