+static int write_bootdev_sysparam(const char *name, uint8_t val)
+{
+ char path[50];
+ int fd, rc;
+
+ strcpy(path, sysparams_dir);
+ assert(strlen(name) < sizeof(path) - strlen(path));
+ strcat(path, name);
+
+ fd = open(path, O_WRONLY);
+ if (fd < 0) {
+ pb_debug("powerpc: can't access sysparam %s for writing\n",
+ name);
+ return -1;
+ }
+
+ for (;;) {
+ errno = 0;
+ rc = write(fd, &val, sizeof(val));
+ if (rc == sizeof(val)) {
+ rc = 0;
+ break;
+ }
+
+ if (rc <= 0 && errno != EINTR) {
+ pb_log("powerpc: error updating sysparam %s: %s",
+ name, strerror(errno));
+ rc = -1;
+ break;
+ }
+ }
+
+ close(fd);
+
+ if (!rc)
+ pb_debug("powerpc: set sysparam %s: 0x%02x\n", name, val);
+
+ return rc;
+}
+