Browse Source

Use a separate function for bfl initialise that doesn't require locking.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
e92b13a2a2
  1. 32
      driver-bflsc.c

32
driver-bflsc.c

@ -459,7 +459,7 @@ static void xlinkstr(char *xlink, int dev, struct bflsc_info *sc_info)
} }
} }
static void bflsc_initialise(struct cgpu_info *bflsc, bool lock) static void __bflsc_initialise(struct cgpu_info *bflsc)
{ {
int err; int err;
@ -468,11 +468,8 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
// TODO: does x-link bypass the other device FTDI? (I think it does) // TODO: does x-link bypass the other device FTDI? (I think it does)
// So no initialisation required except for the master device? // So no initialisation required except for the master device?
if (lock)
mutex_lock(&(bflsc->device_mutex));
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
goto failed; return;
// Reset // Reset
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_RESET,
@ -482,7 +479,7 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
bflsc->drv->name, bflsc->device_id, err); bflsc->drv->name, bflsc->device_id, err);
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
goto failed; return;
// Set data control // Set data control
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_DATA, err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_DATA,
@ -492,7 +489,7 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
bflsc->drv->name, bflsc->device_id, err); bflsc->drv->name, bflsc->device_id, err);
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
goto failed; return;
// Set the baud // Set the baud
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_BAUD, FTDI_VALUE_BAUD, err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_BAUD, FTDI_VALUE_BAUD,
@ -503,7 +500,7 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
bflsc->drv->name, bflsc->device_id, err); bflsc->drv->name, bflsc->device_id, err);
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
goto failed; return;
// Set Flow Control // Set Flow Control
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_FLOW, err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_FLOW,
@ -513,7 +510,7 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
bflsc->drv->name, bflsc->device_id, err); bflsc->drv->name, bflsc->device_id, err);
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
goto failed; return;
// Set Modem Control // Set Modem Control
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_MODEM, err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_MODEM,
@ -523,7 +520,7 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
bflsc->drv->name, bflsc->device_id, err); bflsc->drv->name, bflsc->device_id, err);
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
goto failed; return;
// Clear any sent data // Clear any sent data
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_RESET,
@ -533,7 +530,7 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
bflsc->drv->name, bflsc->device_id, err); bflsc->drv->name, bflsc->device_id, err);
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
goto failed; return;
// Clear any received data // Clear any received data
err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, err = usb_transfer(bflsc, FTDI_TYPE_OUT, FTDI_REQUEST_RESET,
@ -542,9 +539,12 @@ static void bflsc_initialise(struct cgpu_info *bflsc, bool lock)
applog(LOG_DEBUG, "%s%i: purgerx got err %d", applog(LOG_DEBUG, "%s%i: purgerx got err %d",
bflsc->drv->name, bflsc->device_id, err); bflsc->drv->name, bflsc->device_id, err);
failed: }
if (lock) static void bflsc_initialise(struct cgpu_info *bflsc)
{
mutex_lock(&(bflsc->device_mutex));
bflsc_initialise(bflsc);
mutex_unlock(&(bflsc->device_mutex)); mutex_unlock(&(bflsc->device_mutex));
} }
@ -690,7 +690,7 @@ retry:
init_sleep = REINIT_TIME_FIRST_MS; init_sleep = REINIT_TIME_FIRST_MS;
gettimeofday(&init_start, NULL); gettimeofday(&init_start, NULL);
reinit: reinit:
bflsc_initialise(bflsc, false); __bflsc_initialise(bflsc);
err = write_to_dev(bflsc, 0, BFLSC_IDENTIFY, BFLSC_IDENTIFY_LEN, &amount, C_REQUESTIDENTIFY); err = write_to_dev(bflsc, 0, BFLSC_IDENTIFY, BFLSC_IDENTIFY_LEN, &amount, C_REQUESTIDENTIFY);
if (err < 0 || amount != BFLSC_IDENTIFY_LEN) { if (err < 0 || amount != BFLSC_IDENTIFY_LEN) {
applog(LOG_ERR, "%s detect (%s) send identify request failed (%d:%d)", applog(LOG_ERR, "%s detect (%s) send identify request failed (%d:%d)",
@ -1313,7 +1313,7 @@ static void bflsc_thread_enable(struct thr_info *thr)
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
return; return;
bflsc_initialise(bflsc, true); bflsc_initialise(bflsc);
} }
static bool bflsc_send_work(struct cgpu_info *bflsc, int dev, struct work *work) static bool bflsc_send_work(struct cgpu_info *bflsc, int dev, struct work *work)
@ -1565,7 +1565,7 @@ static bool bflsc_thread_init(struct thr_info *thr)
if (bflsc->usbinfo.nodev) if (bflsc->usbinfo.nodev)
return false; return false;
bflsc_initialise(bflsc, true); bflsc_initialise(bflsc);
return true; return true;
} }

Loading…
Cancel
Save