+static int switch_speed(struct hmcfgusb_dev *dev, struct recv_data *rdata, uint8_t speed)
+{
+ uint8_t out[0x40];
+ int pfd;
+
+ printf("Entering %uk-mode\n", speed);
+
+ memset(out, 0, sizeof(out));
+ out[0] = 'G';
+ out[1] = speed;
+
+ hmcfgusb_send(dev, out, sizeof(out), 2);
+
+ while (1) {
+ errno = 0;
+ pfd = hmcfgusb_poll(dev, 1);
+ if ((pfd < 0) && errno) {
+ if (errno != ETIMEDOUT) {
+ perror("\n\nhmcfgusb_poll");
+ exit(EXIT_FAILURE);
+ }
+ }
+ if (rdata->speed == speed)
+ break;
+ }
+
+ return 1;
+}
+