|
|
@@ -847,6 +847,85 @@ bool add_cgpu_slave(struct cgpu_info *cgpu, struct cgpu_info *prev_cgpu)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+const char *proc_set_device_help(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
|
|
|
+{
|
|
|
+ const struct bfg_set_device_definition *sdf;
|
|
|
+ char *p = replybuf;
|
|
|
+ bool first = true;
|
|
|
+
|
|
|
+ *out_success = SDR_HELP;
|
|
|
+ sdf = proc->set_device_funcs;
|
|
|
+ if (!sdf)
|
|
|
+nohelp:
|
|
|
+ return "No help available";
|
|
|
+
|
|
|
+ for ( ; sdf->optname; ++sdf)
|
|
|
+ {
|
|
|
+ if (!sdf->description)
|
|
|
+ continue;
|
|
|
+ if (first)
|
|
|
+ first = false;
|
|
|
+ else
|
|
|
+ p++[0] = '\n';
|
|
|
+ p += sprintf(p, "%s: %s", sdf->optname, sdf->description);
|
|
|
+ }
|
|
|
+ if (replybuf == p)
|
|
|
+ goto nohelp;
|
|
|
+ return replybuf;
|
|
|
+}
|
|
|
+
|
|
|
+static inline
|
|
|
+void _set_auto_sdr(enum bfg_set_device_replytype * const out_success, const char * const rv, const char * const optname)
|
|
|
+{
|
|
|
+ if (!rv)
|
|
|
+ *out_success = SDR_OK;
|
|
|
+ else
|
|
|
+ if (!strcasecmp(optname, "help"))
|
|
|
+ *out_success = SDR_HELP;
|
|
|
+ else
|
|
|
+ *out_success = SDR_ERR;
|
|
|
+}
|
|
|
+
|
|
|
+const char *_proc_set_device(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
|
|
|
+{
|
|
|
+ const struct bfg_set_device_definition *sdf;
|
|
|
+
|
|
|
+ sdf = proc->set_device_funcs;
|
|
|
+ if (!sdf)
|
|
|
+ {
|
|
|
+ *out_success = SDR_NOSUPP;
|
|
|
+ return "Device does not support setting parameters.";
|
|
|
+ }
|
|
|
+ for ( ; sdf->optname; ++sdf)
|
|
|
+ if (!strcasecmp(optname, sdf->optname))
|
|
|
+ {
|
|
|
+ *out_success = SDR_AUTO;
|
|
|
+ const char * const rv = sdf->func(proc, optname, newvalue, replybuf, out_success);
|
|
|
+ if (SDR_AUTO == *out_success)
|
|
|
+ _set_auto_sdr(out_success, rv, optname);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!strcasecmp(optname, "help"))
|
|
|
+ return proc_set_device_help(proc, optname, newvalue, replybuf, out_success);
|
|
|
+
|
|
|
+ *out_success = SDR_UNKNOWN;
|
|
|
+ sprintf(replybuf, "Unknown option: %s", optname);
|
|
|
+ return replybuf;
|
|
|
+}
|
|
|
+
|
|
|
+const char *proc_set_device(struct cgpu_info * const proc, char * const optname, char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
|
|
|
+{
|
|
|
+ if (proc->drv->set_device)
|
|
|
+ {
|
|
|
+ const char * const rv = proc->drv->set_device(proc, optname, newvalue, replybuf);
|
|
|
+ _set_auto_sdr(out_success, rv, optname);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ return _proc_set_device(proc, optname, newvalue, replybuf, out_success);
|
|
|
+}
|
|
|
+
|
|
|
#ifdef NEED_BFG_LOWL_VCOM
|
|
|
bool _serial_detect_all(struct lowlevel_device_info * const info, void * const userp)
|
|
|
{
|