Skip to contentSkip to conversation

misc: docs: Fix comments in misc.h

PATCH New Mario Six 3 participants 9 messages Jul 31, 2018 – Aug 6, 2018

Subsystems (2)
lore
Share & tools
lore

Mario Six

author
#0 lore raw

PATCH v4 1/4 misc: docs: Fix comments in misc.h

The comments in misc.h are not in kernel-doc format. Correct the format.

---

v3 -> v4:
No changes

v2 -> v3:
New in v3

---
 include/misc.h | 84 ++++++++++++++++++++++++++++++----------------------------
 1 file changed, 44 insertions(+), 40 deletions(-)
include/misc.h +44 -40
index 68f8e64d61a..ce2f05dfd4c 100644
@@ -6,38 +6,47 @@
 #ifndef _MISC_H_
 #define _MISC_H_
 
-/*
- * Read the device to buffer, optional.
- *
+/**
+ * misc_read() - Read the device to buffer, optional.
  * @dev: the device
  * @offset: offset to read the device
  * @buf: pointer to data buffer
  * @size: data size in bytes to read the device
- * @return: 0 if OK, -ve on error
+ *
+ * Return: 0 if OK, -ve on error
  */
 int misc_read(struct udevice *dev, int offset, void *buf, int size);
-/*
- * Write buffer to the device, optional.
- *
+
+/**
+ * misc_write() - Write buffer to the device, optional.
  * @dev: the device
  * @offset: offset to write the device
  * @buf: pointer to data buffer
  * @size: data size in bytes to write the device
- * @return: 0 if OK, -ve on error
+ *
+ * Return: 0 if OK, -ve on error
  */
 int misc_write(struct udevice *dev, int offset, void *buf, int size);
-/*
- * Assert command to the device, optional.
- *
+
+/**
+ * misc_ioctl() - Assert command to the device, optional.
  * @dev: the device
  * @request: command to be sent to the device
  * @buf: pointer to buffer related to the request
- * @return: 0 if OK, -ve on error
+ *
+ * Return: 0 if OK, -ve on error
  */
 int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
 
-/*
- * Send a message to the device and wait for a response.
+/**
+ * misc_call() - Send a message to the device and wait for a response.
+ * @dev: the device.
+ * @msgid: the message ID/number to send.
+ * @tx_msg: the request/transmit message payload.
+ * @tx_size: the size of the buffer pointed at by tx_msg.
+ * @rx_msg: the buffer to receive the response message payload. May be NULL if
+ *          the caller only cares about the error code.
+ * @rx_size: the size of the buffer pointed at by rx_msg.
  *
  * The caller provides the message type/ID and payload to be sent.
  * The callee constructs any message header required, transmits it to the
@@ -45,66 +54,61 @@ int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
  * strips any message header from the response, and returns the error code
  * (or a parsed version of it) and the response message payload.
  *
- * @dev: the device.
- * @msgid: the message ID/number to send.
- * tx_msg: the request/transmit message payload.
- * tx_size: the size of the buffer pointed at by tx_msg.
- * rx_msg: the buffer to receive the response message payload. May be NULL if
- *         the caller only cares about the error code.
- * rx_size: the size of the buffer pointed at by rx_msg.
- * @return the response message size if OK, -ve on error
+ * Return: the response message size if OK, -ve on error
  */
 int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
 	      void *rx_msg, int rx_size);
 
-/*
+/**
  * struct misc_ops - Driver model Misc operations
  *
  * The uclass interface is implemented by all miscellaneous devices which
  * use driver model.
  */
 struct misc_ops {
-	/*
+	/**
 	 * Read the device to buffer, optional.
-	 *
 	 * @dev: the device
 	 * @offset: offset to read the device
 	 * @buf: pointer to data buffer
 	 * @size: data size in bytes to read the device
-	 * @return: 0 if OK, -ve on error
+	 *
+	 * Return: 0 if OK, -ve on error
 	 */
 	int (*read)(struct udevice *dev, int offset, void *buf, int size);
-	/*
+
+	/**
 	 * Write buffer to the device, optional.
-	 *
 	 * @dev: the device
 	 * @offset: offset to write the device
 	 * @buf: pointer to data buffer
 	 * @size: data size in bytes to write the device
-	 * @return: 0 if OK, -ve on error
+	 *
+	 * Return: 0 if OK, -ve on error
 	 */
 	int (*write)(struct udevice *dev, int offset, const void *buf,
 		     int size);
-	/*
+	/**
 	 * Assert command to the device, optional.
-	 *
 	 * @dev: the device
 	 * @request: command to be sent to the device
 	 * @buf: pointer to buffer related to the request
-	 * @return: 0 if OK, -ve on error
+	 *
+	 * Return: 0 if OK, -ve on error
 	 */
 	int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
-	/*
+
+	/**
 	 * Send a message to the device and wait for a response.
-	 *
 	 * @dev: the device
 	 * @msgid: the message ID/number to send
-	 * tx_msg: the request/transmit message payload
-	 * tx_size: the size of the buffer pointed at by tx_msg
-	 * rx_msg: the buffer to receive the response message payload. May be
-	 *         NULL if the caller only cares about the error code.
-	 * rx_size: the size of the buffer pointed at by rx_msg
-	 * @return the response message size if OK, -ve on error
+	 * @tx_msg: the request/transmit message payload
+	 * @tx_size: the size of the buffer pointed at by tx_msg
+	 * @rx_msg: the buffer to receive the response message payload. May be
+	 *          NULL if the caller only cares about the error code.
+	 * @rx_size: the size of the buffer pointed at by rx_msg
+	 *
+	 * Return: the response message size if OK, -ve on error
 	 */
 	int (*call)(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
 		    void *rx_msg, int rx_size);

--
2.11.0

author
#1 lore raw

PATCH v4 2/4 misc: uclass: Add enable/disable function

Add generic enable/disable function to the misc uclass.

---

v3 -> v4:
No changes

v2 -> v3:
* Now return old state from misc_set_enabled

v1 -> v2:
* Merged the two functions into one function
* Explained the semantics of enabling/disabling more throughly

---
 drivers/misc/misc-uclass.c | 10 ++++++++++
 include/misc.h             | 27 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)
drivers/misc/misc-uclass.c +10 -0
index 0dc62d00344..f240cda5c05 100644
@@ -55,6 +55,16 @@ int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
 	return ops->call(dev, msgid, tx_msg, tx_size, rx_msg, rx_size);
 }
 
+int misc_set_enabled(struct udevice *dev, bool val)
+{
+	const struct misc_ops *ops = device_get_ops(dev);
+
+	if (!ops->set_enabled)
+		return -ENOSYS;
+
+	return ops->set_enabled(dev, val);
+}
+
 UCLASS_DRIVER(misc) = {
 	.id		= UCLASS_MISC,
 	.name		= "misc",
include/misc.h +27 -0
index ce2f05dfd4c..50515852b25 100644
@@ -60,6 +60,23 @@ int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
 	      void *rx_msg, int rx_size);
 
 /**
+ * misc_set_enabled() - Enable or disable a device.
+ * @dev: the device to enable or disable.
+ * @val: the flag that tells the driver to either enable or disable the device.
+ *
+ * The semantics of "disable" and "enable" should be understood here as
+ * activating or deactivating the device's primary function, hence a "disabled"
+ * device should be dormant, but still answer to commands and queries.
+ *
+ * A probed device may start in a disabled or enabled state, depending on the
+ * driver and hardware.
+ *
+ * Return: -ve on error, 0 if the previous state was "disabled", 1 if the
+ *	   previous state was "enabled"
+ */
+int misc_set_enabled(struct udevice *dev, bool val);
+
+/*
  * struct misc_ops - Driver model Misc operations
  *
  * The uclass interface is implemented by all miscellaneous devices which
@@ -112,6 +129,16 @@ struct misc_ops {
 	 */
 	int (*call)(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
 		    void *rx_msg, int rx_size);
+	/**
+	 * Enable or disable a device, optional.
+	 * @dev: the device to enable.
+	 * @val: the flag that tells the driver to either enable or disable the
+	 *	 device.
+	 *
+	 * Return: -ve on error, 0 if the previous state was "disabled", 1 if
+	 *	   the previous state was "enabled"
+	 */
+	int (*set_enabled)(struct udevice *dev, bool val);
 };
 
 #endif	/* _MISC_H_ */

--
2.11.0

#2 lore raw

PATCH v4 2/4 misc: uclass: Add enable/disable function

On Tue, 31 Jul 2018 14:24:13 +0200
Mario Six mario.six at gdsys.cc wrote:
...

Quoted 4 lines
---
 drivers/misc/misc-uclass.c | 10 ++++++++++
 include/misc.h             | 27 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

Applied to u-boot-staging/agust at denx.de, thanks!

--
Anatolij

author
#3 lore raw

PATCH v4 3/4 test: Add tests for misc uclass

In reply to Mario Six

Add a set of tests for the misc uclass.

---

v3 -> v4:
New in v4

---
 arch/sandbox/dts/test.dts   |   4 ++
 drivers/misc/Makefile       |   2 +-
 drivers/misc/misc_sandbox.c | 133 ++++++++++++++++++++++++++++++++++++++++++++
 test/dm/Makefile            |   1 +
 test/dm/misc.c              |  83 +++++++++++++++++++++++++++
 5 files changed, 222 insertions(+), 1 deletion(-)
 create mode 100644 drivers/misc/misc_sandbox.c
 create mode 100644 test/dm/misc.c
arch/sandbox/dts/test.dts +4 -0
index 137679abea9..c41375ac225 100644
@@ -283,6 +283,10 @@
 		mbox-names = "other", "test";
 	};
 
+	misc-test {
+		compatible = "sandbox,misc_sandbox";
+	};
+
 	mmc2 {
 		compatible = "sandbox,mmc";
 	};
drivers/misc/Makefile +1 -1
index e2c2b763b7a..5d2336d915f 100644
@@ -39,7 +39,7 @@ ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SANDBOX) += spltest_sandbox.o
 endif
 endif
-obj-$(CONFIG_SANDBOX) += syscon_sandbox.o
+obj-$(CONFIG_SANDBOX) += syscon_sandbox.o misc_sandbox.o
 obj-$(CONFIG_TEGRA_CAR) += tegra_car.o
 obj-$(CONFIG_TEGRA186_BPMP) += tegra186_bpmp.o
 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
drivers/misc/misc_sandbox.c new file +133 -0

133 lines not on this page · raw message

test/dm/Makefile +1 -0
index d2ed96c6153..ff0807873b0 100644
@@ -44,4 +44,5 @@ obj-$(CONFIG_DM_VIDEO) += video.o
 obj-$(CONFIG_ADC) += adc.o
 obj-$(CONFIG_SPMI) += spmi.o
 obj-$(CONFIG_WDT) += wdt.o
+obj-$(CONFIG_MISC) += misc.o
 endif
test/dm/misc.c new file +83 -0

83 lines not on this page · raw message

--
2.11.0

#4 lore raw

PATCH v4 3/4 test: Add tests for misc uclass

Quoted 8 lines · Mario Six

Add a set of tests for the misc uclass.

---

v3 -> v4:
New in v4

Quoted 10 lines
---
 arch/sandbox/dts/test.dts   |   4 ++
 drivers/misc/Makefile       |   2 +-
 drivers/misc/misc_sandbox.c | 133 ++++++++++++++++++++++++++++++++++++++++++++
 test/dm/Makefile            |   1 +
 test/dm/misc.c              |  83 +++++++++++++++++++++++++++
 5 files changed, 222 insertions(+), 1 deletion(-)
 create mode 100644 drivers/misc/misc_sandbox.c
 create mode 100644 test/dm/misc.c

Very nice, thanks.

Maybe we should have ut_asserttrue/false?

#5 lore raw

PATCH v4 3/4 test: Add tests for misc uclass

In reply to Mario Six

On Tue, 31 Jul 2018 14:24:14 +0200
Mario Six mario.six at gdsys.cc wrote:
...

Quoted 9 lines
---
 arch/sandbox/dts/test.dts   |   4 ++
 drivers/misc/Makefile       |   2 +-
 drivers/misc/misc_sandbox.c | 133 ++++++++++++++++++++++++++++++++++++++++++++
 test/dm/Makefile            |   1 +
 test/dm/misc.c              |  83 +++++++++++++++++++++++++++
 5 files changed, 222 insertions(+), 1 deletion(-)
 create mode 100644 drivers/misc/misc_sandbox.c
 create mode 100644 test/dm/misc.c

Applied to u-boot-staging/agust at denx.de, thanks!

--
Anatolij

author
#6 lore raw

PATCH v4 4/4 misc: Add gdsys_ioep driver

In reply to Mario Six

Add driver for the IHS IO endpoint on IHS FPGAs.

---

v3 -> v4:
* Fixed style violations
* Added full documentation
* Added binding file
* Made res/ret variable names consistent
* Improved error checking and error debug output

v2 -> v3:
No changes

v1 -> v2:
* Switched to regmap usage (instead of fpgamap)

---
 .../devicetree/bindings/misc/gdsys,io-endpoint.txt |  20 ++
 drivers/misc/Kconfig                               |   5 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/gdsys_ioep.c                          | 209 +++++++++++++++++++++
 drivers/misc/gdsys_ioep.h                          | 137 ++++++++++++++
 5 files changed, 372 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/gdsys,io-endpoint.txt
 create mode 100644 drivers/misc/gdsys_ioep.c
 create mode 100644 drivers/misc/gdsys_ioep.h
Documentation/devicetree/bindings/misc/gdsys,io-endpoint.txt new file +20 -0
new file mode 100644
index 00000000000..db2ff8ca128
@@ -0,0 +1,20 @@
+gdsys IO endpoint of IHS FPGA devices
+
+The IO endpoint of IHS FPGA devices is a packet-based transmission interface
+that allows interconnected gdsys devices to send and receive data over the
+FPGA's main ethernet connection.
+
+Required properties:
+- compatible: must be "gdsys,io-endpoint"
+- reg: describes the address and length of the endpoint's register map (within
+  the FPGA's register space)
+
+Example:
+
+fpga0_ep0 {
+	compatible = "gdsys,io-endpoint";
+	reg = <0x020 0x10
+           0x320 0x10
+           0x340 0x10
+           0x360 0x10>;
+};
drivers/misc/Kconfig +5 -0
index a479e4eec56..89854a4941b 100644
@@ -284,4 +284,9 @@ config MPC83XX_SERDES
 	help
 	  Support for serdes found on MPC83xx SoCs.
 
+config GDSYS_IOEP
+	bool "Enable gdsys IOEP driver"
+	depends on MISC
+	help
+	  Support gdsys FPGA's IO endpoint driver.
 endmenu
drivers/misc/Makefile +1 -0
index 5d2336d915f..b0ef97b6b31 100644
@@ -55,3 +55,4 @@ obj-$(CONFIG_STM32MP_FUSE) += stm32mp_fuse.o
 obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
 obj-$(CONFIG_MPC83XX_SERDES) += mpc83xx_serdes.o
+obj-$(CONFIG_GDSYS_IOEP) += gdsys_ioep.o
drivers/misc/gdsys_ioep.c new file +209 -0

209 lines not on this page · raw message

drivers/misc/gdsys_ioep.h new file +137 -0

137 lines not on this page · raw message

--
2.11.0

#7 lore raw

PATCH v4 4/4 misc: Add gdsys_ioep driver

On Tue, 31 Jul 2018 14:24:15 +0200
Mario Six mario.six at gdsys.cc wrote:
...

Quoted 10 lines
---
 .../devicetree/bindings/misc/gdsys,io-endpoint.txt |  20 ++
 drivers/misc/Kconfig                               |   5 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/gdsys_ioep.c                          | 209 +++++++++++++++++++++
 drivers/misc/gdsys_ioep.h                          | 137 ++++++++++++++
 5 files changed, 372 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/gdsys,io-endpoint.txt
 create mode 100644 drivers/misc/gdsys_ioep.c
 create mode 100644 drivers/misc/gdsys_ioep.h

Applied to u-boot-staging/agust at denx.de, thanks!

--
Anatolij

#8 lore raw

PATCH v4 1/4 misc: docs: Fix comments in misc.h

In reply to Mario Six

On Tue, 31 Jul 2018 14:24:12 +0200
Mario Six mario.six at gdsys.cc wrote:
...

Quoted 3 lines
---
 include/misc.h | 84 ++++++++++++++++++++++++++++++----------------------------
 1 file changed, 44 insertions(+), 40 deletions(-)

Applied to u-boot-staging/agust at denx.de, thanks!

--
Anatolij