bootstd: Add command to enable setting of bootmeth specific properties

We have previously added logic to allow a "fallback" option to be
specified in the extlinux configuration. Provide a command that allows
us to set this as the preferred default option when booting.

Combined with the bootcount functionality, this allows the "altbootcmd"
to provide a means of falling back to a previously known good state
after a failed update. For example, if "bootcmd" is set to:

    bootflow scan -lb

We would set "altbootcmd" to:

    bootmeth set extlinux fallback 1; bootflow scan -lb

Causing the boot process to boot from the fallback option.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
diff --git a/include/bootmeth.h b/include/bootmeth.h
index 4d8ca48..a08ebf0 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -146,6 +146,22 @@
 	 *	something changes, other -ve on other error
 	 */
 	int (*boot)(struct udevice *dev, struct bootflow *bflow);
+
+	/**
+	 * set_property() - set the bootmeth property
+	 *
+	 * This allows the setting of boot method specific properties to enable
+	 * automated finer grain control of the boot process
+	 *
+	 * @name: String containing the name of the relevant boot method
+	 * @property: String containing the name of the property to set
+	 * @value: String containing the value to be set for the specified
+	 *         property
+	 * Return: 0 if OK, -ENODEV if an unknown bootmeth or property is
+	 *      provided, -ENOENT if there are no bootmeth devices
+	 */
+	int (*set_property)(struct udevice *dev, const char *property,
+			    const char *value);
 };
 
 #define bootmeth_get_ops(dev)  ((struct bootmeth_ops *)(dev)->driver->ops)
@@ -291,6 +307,21 @@
 int bootmeth_set_order(const char *order_str);
 
 /**
+ * bootmeth_set_property() - Set the bootmeth property
+ *
+ * This allows the setting of boot method specific properties to enable
+ * automated finer grain control of the boot process
+ *
+ * @name: String containing the name of the relevant boot method
+ * @property: String containing the name of the property to set
+ * @value: String containing the value to be set for the specified property
+ * Return: 0 if OK, -ENODEV if an unknown bootmeth or property is provided,
+ * -ENOENT if there are no bootmeth devices
+ */
+int bootmeth_set_property(const char *name, const char *property,
+			  const char *value);
+
+/**
  * bootmeth_setup_fs() - Set up read to read a file
  *
  * We must redo the setup before each filesystem operation. This function