Allow per-device settings to use "DRBnn" as an identifier instead
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
diff --git a/driver-drillbit.c b/driver-drillbit.c
index 1e5caca..662bd18 100644
--- a/driver-drillbit.c
+++ b/driver-drillbit.c
@@ -310,37 +310,53 @@ static bool drillbit_reset(struct cgpu_info *drillbit)
return res;
}
+static config_setting *find_settings(struct cgpu_info *drillbit)
+{
+ struct drillbit_info *info = drillbit->device_data;
+ config_setting *setting;
+ uint8_t search_key[9];
+
+ // Search by serial (8 character hex string)
+ sprintf(search_key, "%08x", info->serial);
+ HASH_FIND_STR(settings, search_key, setting);
+ if(setting) {
+ drvlog(LOG_INFO, "Using unit-specific settings for serial %s", search_key);
+ return setting;
+ }
+
+ // Search by DRBxxx
+ snprintf(search_key, 9, "DRB%d", drillbit->device_id);
+ HASH_FIND_STR(settings, search_key, setting);
+ if(setting) {
+ drvlog(LOG_INFO, "Using device_id specific settings for device");
+ return setting;
+ }
+
+ // Failing that, search by product name
+ HASH_FIND_STR(settings, info->product, setting);
+ if(setting) {
+ drvlog(LOG_INFO, "Using product-specific settings for device %s", info->product);
+ return setting;
+ }
+
+ // Failing that, return default/generic config (null key)
+ search_key[0] = 0;
+ HASH_FIND_STR(settings, search_key, setting);
+ drvlog(LOG_INFO, "Using non-specific settings for device %s (serial %08x)", info->product,
+ info->serial);
+ return setting;
+}
+
static void drillbit_send_config(struct cgpu_info *drillbit)
{
struct drillbit_info *info = drillbit->device_data;
char cmd;
int amount;
- uint8_t search_key[9];
uint8_t buf[SZ_SERIALISED_BOARDCONFIG];
config_setting *setting;
// Find the relevant board config
-
- // Search by serial (8 character hex string)
- sprintf(search_key, "%08x", info->serial);
- HASH_FIND_STR(settings, search_key, setting);
- if(setting) {
- drvlog(LOG_INFO, "Using unit-specific settings for serial %s", search_key);
- }
- else {
- // Failing that, search by product name
- HASH_FIND_STR(settings, info->product, setting);
- if(setting) {
- drvlog(LOG_INFO, "Using product-specific settings for device %s", info->product);
- }
- else {
- // Failing that, return default/generic config (null key)
- search_key[0] = 0;
- HASH_FIND_STR(settings, search_key, setting);
- drvlog(LOG_INFO, "Using non-specific settings for device %s (serial %08x)", info->product,
- info->serial);
- }
- }
+ setting = find_settings(drillbit);
drvlog(LOG_INFO, "Sending board configuration voltage=%d use_ext_clock=%d int_clock_level=%d clock_div2=%d ext_clock_freq=%d",
setting->config.core_voltage, setting->config.use_ext_clock,