-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix safety and correctness bugs in hostmot2 drivers #4488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
bf7defd
b3821a1
61850e9
ae94385
6d6eddb
29361fb
c3775d9
a484363
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,10 @@ int hm2_tram_add_bspi_frame(char *name, int chan, rtapi_u32 **wbuff, rtapi_u32 * | |
| HM2_ERR_NO_LL("Can not find BSPI instance %s.\n", name); | ||
| return -1; | ||
| } | ||
| if (chan < 0 || chan > 15) { | ||
| HM2_ERR("BSPI %s: channel number %i is out of range\n", name, chan); | ||
| return -1; | ||
| } | ||
|
Comment on lines
+124
to
+127
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other error exits return Same problem for changes in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair, I've updated them match existing convention. |
||
| if (hm2->bspi.instance[i].conf_flag[chan] != true){ | ||
| HM2_ERR("The selected write channel (%i) on bspi instance %s.\n" | ||
| "Has not been configured.\n", chan, name); | ||
|
|
@@ -205,6 +209,10 @@ int hm2_bspi_write_chan(char* name, int chan, rtapi_u32 val) | |
| HM2_ERR_NO_LL("Can not find BSPI instance %s.\n", name); | ||
| return -1; | ||
| } | ||
| if (chan < 0 || chan > 15) { | ||
| HM2_ERR("BSPI %s: channel number %i is out of range\n", name, chan); | ||
| return -1; | ||
| } | ||
| if (hm2->bspi.instance[i].conf_flag[chan] != true){ | ||
| HM2_ERR("The selected write channel (%i) on bspi instance %s.\n" | ||
| "Has not been configured.\n", chan, name); | ||
|
|
@@ -247,6 +255,10 @@ int hm2_bspi_setup_chan(char *name, int chan, int cs, int bits, double mhz, | |
| "BSPI only supports 1-64 bits\n", name, chan, bits); | ||
| return -1; | ||
| } | ||
| if (mhz <= 0) { | ||
| HM2_ERR("BSPI %s: clock frequency must be greater than zero\n", name); | ||
| return -1; | ||
| } | ||
| if (delay < 0 || delay > 1e6){ | ||
| HM2_ERR("The requested frame delay on channel %i of %inS seems " | ||
| "rather implausible for an SPI device. Exiting.\n", delay, chan); | ||
|
|
@@ -388,6 +400,3 @@ void hm2_bspi_write(hostmot2_t *hm2) | |
| { | ||
| (void)hm2; | ||
| } | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.