linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2]  support config of U-Blox Zed-F9P GNSS
@ 2023-05-08  1:11 alison
  2023-05-08  1:11 ` [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud alison
  2023-05-08  1:11 ` [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9 alison
  0 siblings, 2 replies; 7+ messages in thread
From: alison @ 2023-05-08  1:11 UTC (permalink / raw)
  To: johan
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree,
	linux-kernel, alison, achaiken, kernel test robot

From: Alison Chaiken <alison@she-devel.com>

Add generalized support for setting arbitrary configuration of the
U-Blox Zed-F9P GNSS.  Employ the new functionality to set the baud rate
of the Zed-F9P if the devicetree specifies a non-default value.

Tested with 6.1.22, only on a U-Blox Zed-F9P GNSS.

V5 -> V4 Wrap all new code in a CONFIG_OF=y check and fixes
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202305070938.8vWQFfIQ-lkp@intel.com/
V4 -> V3 Lookup device-specific properties by matching driver data.
V2 -> V3 Add email recipients whom I foolishly missed the first two times.
V1 -> V2 Fixes error identified by kernel test robot:

Alison Chaiken (2):
  gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud
  dt-bindings: gnss: Add U-Blox Zed-F9

 .../bindings/gnss/u-blox,neo-6m.yaml          |   1 +
 drivers/gnss/ubx.c                            | 242 +++++++++++++++++-
 2 files changed, 232 insertions(+), 11 deletions(-)


base-commit: ac9a78681b921877518763ba0e89202254349d1b
-- 
2.39.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud
  2023-05-08  1:11 [PATCH v5 0/2] support config of U-Blox Zed-F9P GNSS alison
@ 2023-05-08  1:11 ` alison
  2023-05-08  7:52   ` kernel test robot
  2023-05-08  8:00   ` Krzysztof Kozlowski
  2023-05-08  1:11 ` [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9 alison
  1 sibling, 2 replies; 7+ messages in thread
From: alison @ 2023-05-08  1:11 UTC (permalink / raw)
  To: johan
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree,
	linux-kernel, alison, achaiken

From: Alison Chaiken <achaiken@aurora.tech>

Add support for setting the baud rate of U-Blox Zed-F9P GNSS devices.
Provide functions that support writing of arbitrary configuration
messages to the device plus one that specifically configures the baud
rate.  Override the default gnss_serial_open() with a new method that
writes the configuration message to the GNSS if the devicetree declares
it to be a Zed F9P and requests a non-default baud.  Add a boolean flag
to the ubx_data private data of the GNSS driver in order to track
whether the configuration message has already been written.  Set the Zed
F9P to its default port speed if the devicetree does not specify a
value.

Signed-off-by: Alison Chaiken <achaiken@aurora.tech>
---

V5 -> V4 Compile out the changes if CONFIG_OF is not set.
V4 -> V3 Modified to lookup Zed-F9P-specific data via the device_id
               rather than the compatible string.

 drivers/gnss/ubx.c | 242 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 231 insertions(+), 11 deletions(-)

diff --git a/drivers/gnss/ubx.c b/drivers/gnss/ubx.c
index c951be202ca2..64fea07da87c 100644
--- a/drivers/gnss/ubx.c
+++ b/drivers/gnss/ubx.c
@@ -9,18 +9,214 @@
 #include <linux/gnss.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kstrtox.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/serdev.h>
 
 #include "serial.h"
 
+#ifdef CONFIG_OF
+/* Total configuration message length = PREAMBLE_LEN + MESSAGE_CLASS_LEN +
+ *   MESSAGE_LENGTH_LEN + payload length + CHECKSUM_LEN
+ */
+const int32_t PREAMBLE_LEN = 2;
+const int32_t MESSAGE_CLASS_LEN = 2;
+const int32_t MESSAGE_LENGTH_LEN = 2;
+const int32_t CHECKSUM_LEN = 2;
+const size_t FIRST_CONFIG_REGISTER_BYTE = 10U;
+const size_t FIRST_VALUE_BYTE = 14U;
+const size_t FIRST_CHECKSUM_BYTE = 18U;
+const size_t CFG_MSG_TOTAL_LEN = 20U;
+
+uint8_t ZED_F9P_CFG_VALSET_MSG[] = {
+	0xB5, 0x62, /* 0-1 preamble */
+	0x06, 0x8A, /* 2-3 CFG_VALSET command */
+	0x0C, 0x00, /* 4-5 payload length = 12 for one key-value pair */
+	0x00, /* 6 U-Blox API version */
+	0x01, /* 7 Write to RAM */
+	0x00, 0x00, /* 8-9 Reserved */
+	0x00, 0x00, 0x00, 0x00, /* 10-13 Placeholder for configuration register */
+	0x00, 0x00, 0x00, 0x00, /* 14-17 Placeholder for baud value */
+	0x00, 0x00 /* 18-19 Placeholder for checksum */
+};
+
+struct ubx_features {
+	u32 min_baud;
+	u32 default_baud;
+	u32 max_baud;
+	size_t baud_config_reg;
+	int (*open)(struct gnss_device *gdev);
+};
+
 struct ubx_data {
 	struct regulator *v_bckp;
 	struct regulator *vcc;
+	const struct ubx_features *features;
+	unsigned long is_configured;
+};
+
+union message_length {
+	uint16_t ml;
+	uint8_t bytes[2];
 };
 
+union int_to_bytes {
+	uint32_t int_val;
+	uint8_t bytes[4];
+};
+
+/* Payload  length is contained in bytes 0-2 after message class and ID.
+ *  While the checksum includes the Message class and ID plus message length, the
+ *  payload does not.
+ */
+static uint16_t get_payload_length(const uint8_t msg[])
+{
+	union message_length hs_msg_len;
+
+	hs_msg_len.bytes[0] = msg[PREAMBLE_LEN + MESSAGE_CLASS_LEN];
+	hs_msg_len.bytes[1] = msg[PREAMBLE_LEN + MESSAGE_CLASS_LEN + 1U];
+	return hs_msg_len.ml;
+}
+
+static int32_t get_msg_total_len(const uint8_t msg[])
+{
+	const size_t payload_len = get_payload_length(msg);
+
+	return PREAMBLE_LEN + MESSAGE_CLASS_LEN + MESSAGE_LENGTH_LEN + payload_len
+		+ CHECKSUM_LEN;
+}
+
+/* The checksum is calculated on message class, message ID, message length and
+ * payload.
+ */
+static void calc_ubx_checksum(const uint8_t msg[], uint8_t checksum[],
+			   const uint16_t total_len)
+{
+	uint8_t CK_A = 0;
+	uint8_t CK_B = 0;
+	int i;
+
+	for (i = PREAMBLE_LEN; i < (total_len - CHECKSUM_LEN); i++) {
+		CK_A += msg[i];
+		CK_B += CK_A;
+	}
+	checksum[0] = CK_A;
+	checksum[1] = CK_B;
+}
+
+static uint32_t  check_baud(speed_t speed, const struct device *dev,
+					const struct ubx_features *features)
+{
+	if ((speed < features->min_baud) || (speed > features->max_baud)) {
+		dev_warn(dev, "Baud rate specification %d out of range\n", speed);
+		speed = features->default_baud;
+	}
+	return speed;
+}
+
+static int prepare_zedf9p_config_msg(const speed_t speed,
+					const struct device *dev,
+					    const struct ubx_features *features)
+{
+	union int_to_bytes cfg_val, cfg_register;
+	int i = 0;
+	uint8_t checksum[2];
+	const size_t total_len = get_msg_total_len(ZED_F9P_CFG_VALSET_MSG);
+
+	if (total_len != CFG_MSG_TOTAL_LEN)
+		goto bad_msg;
+
+	cfg_val.int_val = check_baud(speed, dev, features);
+	cfg_register.int_val = features->baud_config_reg;
+	for (i = 0; i < 4; i++) {
+		ZED_F9P_CFG_VALSET_MSG[FIRST_VALUE_BYTE + i] = cfg_val.bytes[i];
+		ZED_F9P_CFG_VALSET_MSG[FIRST_CONFIG_REGISTER_BYTE + i] = cfg_register.bytes[i];
+	}
+	calc_ubx_checksum(ZED_F9P_CFG_VALSET_MSG, checksum, total_len);
+	ZED_F9P_CFG_VALSET_MSG[FIRST_CHECKSUM_BYTE] = checksum[0];
+	ZED_F9P_CFG_VALSET_MSG[FIRST_CHECKSUM_BYTE + 1U] = checksum[1];
+	return 0;
+
+ bad_msg:
+	dev_err(dev, "Malformed UBX-CFG-VALSET message\n");
+	return -EINVAL;
+}
+
+/* Configure the Zed F9P baud rate via the UBX-CFG-VALSET message. */
+static int set_zedf9p_baud(struct gnss_device *gdev,
+					struct serdev_device *serdev, struct gnss_serial *gserial)
+{
+	const struct ubx_data *data = gnss_serial_get_drvdata(gserial);
+	const struct ubx_features *features = data->features;
+	size_t count = 0U;
+	int ret;
+
+	if (!data->features)
+		return -EINVAL;
+	if (gserial->speed == features->default_baud)
+		return 0;
+
+	ret = prepare_zedf9p_config_msg(gserial->speed, &gdev->dev, features);
+	if (ret)
+		return ret;
+	/* Initially set the UART to the default speed to match the GNSS' power-on value. */
+	serdev_device_set_baudrate(serdev, features->default_baud);
+	/* Now set the new baud rate. */
+	count = gdev->ops->write_raw(gdev, ZED_F9P_CFG_VALSET_MSG, CFG_MSG_TOTAL_LEN);
+	if (count != CFG_MSG_TOTAL_LEN)
+		return count;
+
+	return 0;
+}
+
+static int zed_f9p_serial_open(struct gnss_device *gdev)
+{
+	struct gnss_serial *gserial = gnss_get_drvdata(gdev);
+	struct serdev_device *serdev = gserial->serdev;
+	struct ubx_data *data = gnss_serial_get_drvdata(gserial);
+	int ret;
+
+	ret = serdev_device_open(serdev);
+	if (ret)
+		return ret;
+	if (!data->features)
+		return -EINVAL;
+
+	serdev_device_set_flow_control(serdev, false);
+
+	if (!data->is_configured) {
+		/* 4800 is the default value set by gnss_serial_parse_dt() */
+		if (gserial->speed == 4800) {
+			/* Fall back instead to Zed F9P default */
+			gserial->speed = data->features->default_baud;
+		} else {
+			ret = set_zedf9p_baud(gdev, serdev, gserial);
+			if (ret)
+				return ret;
+		}
+		data->is_configured = 1;
+	}
+	serdev_device_set_baudrate(serdev, gserial->speed);
+
+	ret = pm_runtime_get_sync(&serdev->dev);
+	if (ret < 0) {
+		pm_runtime_put_noidle(&serdev->dev);
+		goto err_close;
+	}
+	return 0;
+
+err_close:
+	serdev_device_close(serdev);
+
+	return ret;
+}
+#endif  /* CONFIG_OF */
+
 static int ubx_set_active(struct gnss_serial *gserial)
 {
 	struct ubx_data *data = gnss_serial_get_drvdata(gserial);
@@ -63,10 +259,30 @@ static const struct gnss_serial_ops ubx_gserial_ops = {
 	.set_power = ubx_set_power,
 };
 
+#ifdef CONFIG_OF
+static const struct ubx_features zedf9p_feats = {
+	.min_baud		=	9600,
+	.default_baud		=	38400,
+	.max_baud		=	921600,
+	.baud_config_reg	=	0x40520001,
+	.open			=	zed_f9p_serial_open,
+};
+
+static const struct of_device_id ubx_of_match[] = {
+	{ .compatible = "u-blox,neo-6m" },
+	{ .compatible = "u-blox,neo-8" },
+	{ .compatible = "u-blox,neo-m8" },
+	{ .compatible = "u-blox,zed-f9p", .data = &zedf9p_feats },
+	{},
+};
+MODULE_DEVICE_TABLE(of, ubx_of_match);
+#endif
+
 static int ubx_probe(struct serdev_device *serdev)
 {
 	struct gnss_serial *gserial;
 	struct ubx_data *data;
+	struct gnss_operations *ubx_gnss_ops;
 	int ret;
 
 	gserial = gnss_serial_allocate(serdev, sizeof(*data));
@@ -74,13 +290,27 @@ static int ubx_probe(struct serdev_device *serdev)
 		ret = PTR_ERR(gserial);
 		return ret;
 	}
+	ubx_gnss_ops = kzalloc(sizeof(struct gnss_operations), GFP_KERNEL);
+	if (IS_ERR(ubx_gnss_ops)) {
+		ret = PTR_ERR(ubx_gnss_ops);
+		return ret;
+	}
 
 	gserial->ops = &ubx_gserial_ops;
 
 	gserial->gdev->type = GNSS_TYPE_UBX;
 
 	data = gnss_serial_get_drvdata(gserial);
-
+	if (IS_ENABLED(CONFIG_OF)) {
+		data->is_configured = 0;
+		data->features = of_match_device(ubx_of_match, &serdev->dev)->data;
+		if (data->features && data->features->open) {
+			ubx_gnss_ops->open  = data->features->open;
+			ubx_gnss_ops->close = gserial->gdev->ops->close;
+			ubx_gnss_ops->write_raw = gserial->gdev->ops->write_raw;
+			gserial->gdev->ops = ubx_gnss_ops;
+		}
+	}
 	data->vcc = devm_regulator_get(&serdev->dev, "vcc");
 	if (IS_ERR(data->vcc)) {
 		ret = PTR_ERR(data->vcc);
@@ -128,16 +358,6 @@ static void ubx_remove(struct serdev_device *serdev)
 	gnss_serial_free(gserial);
 }
 
-#ifdef CONFIG_OF
-static const struct of_device_id ubx_of_match[] = {
-	{ .compatible = "u-blox,neo-6m" },
-	{ .compatible = "u-blox,neo-8" },
-	{ .compatible = "u-blox,neo-m8" },
-	{},
-};
-MODULE_DEVICE_TABLE(of, ubx_of_match);
-#endif
-
 static struct serdev_device_driver ubx_driver = {
 	.driver	= {
 		.name		= "gnss-ubx",
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9
  2023-05-08  1:11 [PATCH v5 0/2] support config of U-Blox Zed-F9P GNSS alison
  2023-05-08  1:11 ` [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud alison
@ 2023-05-08  1:11 ` alison
  2023-05-08  2:26   ` Rob Herring
  2023-05-08  6:39   ` Krzysztof Kozlowski
  1 sibling, 2 replies; 7+ messages in thread
From: alison @ 2023-05-08  1:11 UTC (permalink / raw)
  To: johan
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree,
	linux-kernel, alison, achaiken

From: Alison Chaiken <achaiken@aurora.tech>

Add support for the U-Blox Zed-F9P GNSS device.

Signed-off-by: Alison Chaiken <achaiken@aurora.tech>
---
 Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml b/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml
index 4835a280b3bf..86b65d4d9266 100644
--- a/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml
+++ b/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml
@@ -21,6 +21,7 @@ properties:
       - u-blox,neo-6m
       - u-blox,neo-8
       - u-blox,neo-m8
+      - u-blox,zed-f9p
 
   reg:
     description: >
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9
  2023-05-08  1:11 ` [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9 alison
@ 2023-05-08  2:26   ` Rob Herring
  2023-05-08  6:39   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Herring @ 2023-05-08  2:26 UTC (permalink / raw)
  To: alison
  Cc: johan, krzysztof.kozlowski+dt, robh+dt, linux-kernel, achaiken,
	devicetree, conor+dt


On Sun, 07 May 2023 18:11:59 -0700, alison@she-devel.com wrote:
> From: Alison Chaiken <achaiken@aurora.tech>
> 
> Add support for the U-Blox Zed-F9P GNSS device.
> 
> Signed-off-by: Alison Chaiken <achaiken@aurora.tech>
> ---
>  Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml | 1 +
>  1 file changed, 1 insertion(+)
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.example.dtb: camera-sensor@3c: port:endpoint:data-lanes: [[1]] is too short
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/rockchip-isp1.example.dtb: camera@3c: port:endpoint:data-lanes: [[1]] is too short
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.example.dtb: pcie-ep@33800000: Unevaluated properties are not allowed ('assigned-clock-parents', 'assigned-clock-rates', 'assigned-clocks' were unexpected)
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml

doc reference errors (make refcheckdocs):
Documentation/usb/gadget_uvc.rst: Documentation/userspace-api/media/v4l/pixfmt-packed.yuv.rst
MAINTAINERS: Documentation/devicetree/bindings/pwm/pwm-apple.yaml

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230508011159.263322-3-alison@she-devel.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9
  2023-05-08  1:11 ` [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9 alison
  2023-05-08  2:26   ` Rob Herring
@ 2023-05-08  6:39   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-08  6:39 UTC (permalink / raw)
  To: alison, johan
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree,
	linux-kernel, achaiken

On 08/05/2023 03:11, alison@she-devel.com wrote:
> From: Alison Chaiken <achaiken@aurora.tech>
> 
> Add support for the U-Blox Zed-F9P GNSS device.
> 
> Signed-off-by: Alison Chaiken <achaiken@aurora.tech>
> ---

You miss versioning your paches and changelog here.

Also:

This is a friendly reminder during the review process.

It looks like you received a tag and forgot to add it.

If you do not know the process, here is a short explanation:
Please add Acked-by/Reviewed-by/Tested-by tags when posting new
versions. However, there's no need to repost patches *only* to add the
tags. The upstream maintainer will do that for acks received on the
version they apply.

https://elixir.bootlin.com/linux/v5.17/source/Documentation/process/submitting-patches.rst#L540

If a tag was not added on purpose, please state why and what changed.

Missing tag:
Acked-by: Rob Herring <robh@kernel.org>


>  Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml | 1 +
>  1 file changed, 1 insertion(+)

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud
  2023-05-08  1:11 ` [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud alison
@ 2023-05-08  7:52   ` kernel test robot
  2023-05-08  8:00   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2023-05-08  7:52 UTC (permalink / raw)
  To: alison, johan
  Cc: oe-kbuild-all, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	devicetree, linux-kernel, alison, achaiken

Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.4-rc1 next-20230508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/alison-she-devel-com/dt-bindings-gnss-Add-U-Blox-Zed-F9/20230508-101304
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20230508011159.263322-2-alison%40she-devel.com
patch subject: [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud
config: x86_64-randconfig-a004 (https://download.01.org/0day-ci/archive/20230508/202305081529.zgHsJsZq-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/93acd4265d325a1881a411703abc6dd45b81c1d0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review alison-she-devel-com/dt-bindings-gnss-Add-U-Blox-Zed-F9/20230508-101304
        git checkout 93acd4265d325a1881a411703abc6dd45b81c1d0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 olddefconfig
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305081529.zgHsJsZq-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/gnss/ubx.c: In function 'ubx_set_active':
>> drivers/gnss/ubx.c:225:36: error: invalid use of undefined type 'struct ubx_data'
     225 |         ret = regulator_enable(data->vcc);
         |                                    ^~
   drivers/gnss/ubx.c: In function 'ubx_set_standby':
   drivers/gnss/ubx.c:237:37: error: invalid use of undefined type 'struct ubx_data'
     237 |         ret = regulator_disable(data->vcc);
         |                                     ^~
   drivers/gnss/ubx.c: In function 'ubx_probe':
>> drivers/gnss/ubx.c:288:54: error: invalid application of 'sizeof' to incomplete type 'struct ubx_data'
     288 |         gserial = gnss_serial_allocate(serdev, sizeof(*data));
         |                                                      ^
   drivers/gnss/ubx.c:305:21: error: invalid use of undefined type 'struct ubx_data'
     305 |                 data->is_configured = 0;
         |                     ^~
   drivers/gnss/ubx.c:306:21: error: invalid use of undefined type 'struct ubx_data'
     306 |                 data->features = of_match_device(ubx_of_match, &serdev->dev)->data;
         |                     ^~
   drivers/gnss/ubx.c:306:50: error: 'ubx_of_match' undeclared (first use in this function)
     306 |                 data->features = of_match_device(ubx_of_match, &serdev->dev)->data;
         |                                                  ^~~~~~~~~~~~
   drivers/gnss/ubx.c:306:50: note: each undeclared identifier is reported only once for each function it appears in
   drivers/gnss/ubx.c:307:25: error: invalid use of undefined type 'struct ubx_data'
     307 |                 if (data->features && data->features->open) {
         |                         ^~
   drivers/gnss/ubx.c:307:43: error: invalid use of undefined type 'struct ubx_data'
     307 |                 if (data->features && data->features->open) {
         |                                           ^~
   drivers/gnss/ubx.c:308:51: error: invalid use of undefined type 'struct ubx_data'
     308 |                         ubx_gnss_ops->open  = data->features->open;
         |                                                   ^~
   drivers/gnss/ubx.c:314:13: error: invalid use of undefined type 'struct ubx_data'
     314 |         data->vcc = devm_regulator_get(&serdev->dev, "vcc");
         |             ^~
   drivers/gnss/ubx.c:315:24: error: invalid use of undefined type 'struct ubx_data'
     315 |         if (IS_ERR(data->vcc)) {
         |                        ^~
   drivers/gnss/ubx.c:316:35: error: invalid use of undefined type 'struct ubx_data'
     316 |                 ret = PTR_ERR(data->vcc);
         |                                   ^~
   drivers/gnss/ubx.c:320:13: error: invalid use of undefined type 'struct ubx_data'
     320 |         data->v_bckp = devm_regulator_get_optional(&serdev->dev, "v-bckp");
         |             ^~
   drivers/gnss/ubx.c:321:24: error: invalid use of undefined type 'struct ubx_data'
     321 |         if (IS_ERR(data->v_bckp)) {
         |                        ^~
   drivers/gnss/ubx.c:322:35: error: invalid use of undefined type 'struct ubx_data'
     322 |                 ret = PTR_ERR(data->v_bckp);
         |                                   ^~
   drivers/gnss/ubx.c:324:29: error: invalid use of undefined type 'struct ubx_data'
     324 |                         data->v_bckp = NULL;
         |                             ^~
   drivers/gnss/ubx.c:329:17: error: invalid use of undefined type 'struct ubx_data'
     329 |         if (data->v_bckp) {
         |                 ^~
   drivers/gnss/ubx.c:330:44: error: invalid use of undefined type 'struct ubx_data'
     330 |                 ret = regulator_enable(data->v_bckp);
         |                                            ^~
   drivers/gnss/ubx.c:342:17: error: invalid use of undefined type 'struct ubx_data'
     342 |         if (data->v_bckp)
         |                 ^~
   drivers/gnss/ubx.c:343:39: error: invalid use of undefined type 'struct ubx_data'
     343 |                 regulator_disable(data->v_bckp);
         |                                       ^~
   drivers/gnss/ubx.c: In function 'ubx_remove':
   drivers/gnss/ubx.c:356:17: error: invalid use of undefined type 'struct ubx_data'
     356 |         if (data->v_bckp)
         |                 ^~
   drivers/gnss/ubx.c:357:39: error: invalid use of undefined type 'struct ubx_data'
     357 |                 regulator_disable(data->v_bckp);
         |                                       ^~


vim +225 drivers/gnss/ubx.c

93acd4265d325a Alison Chaiken 2023-05-07  219  
1ad69f10e3a58d Johan Hovold   2018-06-01  220  static int ubx_set_active(struct gnss_serial *gserial)
1ad69f10e3a58d Johan Hovold   2018-06-01  221  {
1ad69f10e3a58d Johan Hovold   2018-06-01  222  	struct ubx_data *data = gnss_serial_get_drvdata(gserial);
1ad69f10e3a58d Johan Hovold   2018-06-01  223  	int ret;
1ad69f10e3a58d Johan Hovold   2018-06-01  224  
1ad69f10e3a58d Johan Hovold   2018-06-01 @225  	ret = regulator_enable(data->vcc);
1ad69f10e3a58d Johan Hovold   2018-06-01  226  	if (ret)
1ad69f10e3a58d Johan Hovold   2018-06-01  227  		return ret;
1ad69f10e3a58d Johan Hovold   2018-06-01  228  
1ad69f10e3a58d Johan Hovold   2018-06-01  229  	return 0;
1ad69f10e3a58d Johan Hovold   2018-06-01  230  }
1ad69f10e3a58d Johan Hovold   2018-06-01  231  
1ad69f10e3a58d Johan Hovold   2018-06-01  232  static int ubx_set_standby(struct gnss_serial *gserial)
1ad69f10e3a58d Johan Hovold   2018-06-01  233  {
1ad69f10e3a58d Johan Hovold   2018-06-01  234  	struct ubx_data *data = gnss_serial_get_drvdata(gserial);
1ad69f10e3a58d Johan Hovold   2018-06-01  235  	int ret;
1ad69f10e3a58d Johan Hovold   2018-06-01  236  
1ad69f10e3a58d Johan Hovold   2018-06-01  237  	ret = regulator_disable(data->vcc);
1ad69f10e3a58d Johan Hovold   2018-06-01  238  	if (ret)
1ad69f10e3a58d Johan Hovold   2018-06-01  239  		return ret;
1ad69f10e3a58d Johan Hovold   2018-06-01  240  
1ad69f10e3a58d Johan Hovold   2018-06-01  241  	return 0;
1ad69f10e3a58d Johan Hovold   2018-06-01  242  }
1ad69f10e3a58d Johan Hovold   2018-06-01  243  
1ad69f10e3a58d Johan Hovold   2018-06-01  244  static int ubx_set_power(struct gnss_serial *gserial,
1ad69f10e3a58d Johan Hovold   2018-06-01  245  				enum gnss_serial_pm_state state)
1ad69f10e3a58d Johan Hovold   2018-06-01  246  {
1ad69f10e3a58d Johan Hovold   2018-06-01  247  	switch (state) {
1ad69f10e3a58d Johan Hovold   2018-06-01  248  	case GNSS_SERIAL_ACTIVE:
1ad69f10e3a58d Johan Hovold   2018-06-01  249  		return ubx_set_active(gserial);
1ad69f10e3a58d Johan Hovold   2018-06-01  250  	case GNSS_SERIAL_OFF:
1ad69f10e3a58d Johan Hovold   2018-06-01  251  	case GNSS_SERIAL_STANDBY:
1ad69f10e3a58d Johan Hovold   2018-06-01  252  		return ubx_set_standby(gserial);
1ad69f10e3a58d Johan Hovold   2018-06-01  253  	}
1ad69f10e3a58d Johan Hovold   2018-06-01  254  
1ad69f10e3a58d Johan Hovold   2018-06-01  255  	return -EINVAL;
1ad69f10e3a58d Johan Hovold   2018-06-01  256  }
1ad69f10e3a58d Johan Hovold   2018-06-01  257  
55570f1a441787 Colin Ian King 2018-07-16  258  static const struct gnss_serial_ops ubx_gserial_ops = {
1ad69f10e3a58d Johan Hovold   2018-06-01  259  	.set_power = ubx_set_power,
1ad69f10e3a58d Johan Hovold   2018-06-01  260  };
1ad69f10e3a58d Johan Hovold   2018-06-01  261  
93acd4265d325a Alison Chaiken 2023-05-07  262  #ifdef CONFIG_OF
93acd4265d325a Alison Chaiken 2023-05-07  263  static const struct ubx_features zedf9p_feats = {
93acd4265d325a Alison Chaiken 2023-05-07  264  	.min_baud		=	9600,
93acd4265d325a Alison Chaiken 2023-05-07  265  	.default_baud		=	38400,
93acd4265d325a Alison Chaiken 2023-05-07  266  	.max_baud		=	921600,
93acd4265d325a Alison Chaiken 2023-05-07  267  	.baud_config_reg	=	0x40520001,
93acd4265d325a Alison Chaiken 2023-05-07  268  	.open			=	zed_f9p_serial_open,
93acd4265d325a Alison Chaiken 2023-05-07  269  };
93acd4265d325a Alison Chaiken 2023-05-07  270  
93acd4265d325a Alison Chaiken 2023-05-07  271  static const struct of_device_id ubx_of_match[] = {
93acd4265d325a Alison Chaiken 2023-05-07  272  	{ .compatible = "u-blox,neo-6m" },
93acd4265d325a Alison Chaiken 2023-05-07  273  	{ .compatible = "u-blox,neo-8" },
93acd4265d325a Alison Chaiken 2023-05-07  274  	{ .compatible = "u-blox,neo-m8" },
93acd4265d325a Alison Chaiken 2023-05-07  275  	{ .compatible = "u-blox,zed-f9p", .data = &zedf9p_feats },
93acd4265d325a Alison Chaiken 2023-05-07  276  	{},
93acd4265d325a Alison Chaiken 2023-05-07  277  };
93acd4265d325a Alison Chaiken 2023-05-07  278  MODULE_DEVICE_TABLE(of, ubx_of_match);
93acd4265d325a Alison Chaiken 2023-05-07  279  #endif
93acd4265d325a Alison Chaiken 2023-05-07  280  
1ad69f10e3a58d Johan Hovold   2018-06-01  281  static int ubx_probe(struct serdev_device *serdev)
1ad69f10e3a58d Johan Hovold   2018-06-01  282  {
1ad69f10e3a58d Johan Hovold   2018-06-01  283  	struct gnss_serial *gserial;
1ad69f10e3a58d Johan Hovold   2018-06-01  284  	struct ubx_data *data;
93acd4265d325a Alison Chaiken 2023-05-07  285  	struct gnss_operations *ubx_gnss_ops;
1ad69f10e3a58d Johan Hovold   2018-06-01  286  	int ret;
1ad69f10e3a58d Johan Hovold   2018-06-01  287  
1ad69f10e3a58d Johan Hovold   2018-06-01 @288  	gserial = gnss_serial_allocate(serdev, sizeof(*data));
1ad69f10e3a58d Johan Hovold   2018-06-01  289  	if (IS_ERR(gserial)) {
1ad69f10e3a58d Johan Hovold   2018-06-01  290  		ret = PTR_ERR(gserial);
1ad69f10e3a58d Johan Hovold   2018-06-01  291  		return ret;
1ad69f10e3a58d Johan Hovold   2018-06-01  292  	}
93acd4265d325a Alison Chaiken 2023-05-07  293  	ubx_gnss_ops = kzalloc(sizeof(struct gnss_operations), GFP_KERNEL);
93acd4265d325a Alison Chaiken 2023-05-07  294  	if (IS_ERR(ubx_gnss_ops)) {
93acd4265d325a Alison Chaiken 2023-05-07  295  		ret = PTR_ERR(ubx_gnss_ops);
93acd4265d325a Alison Chaiken 2023-05-07  296  		return ret;
93acd4265d325a Alison Chaiken 2023-05-07  297  	}
1ad69f10e3a58d Johan Hovold   2018-06-01  298  
1ad69f10e3a58d Johan Hovold   2018-06-01  299  	gserial->ops = &ubx_gserial_ops;
1ad69f10e3a58d Johan Hovold   2018-06-01  300  
10f146639fee5f Johan Hovold   2018-06-01  301  	gserial->gdev->type = GNSS_TYPE_UBX;
10f146639fee5f Johan Hovold   2018-06-01  302  
1ad69f10e3a58d Johan Hovold   2018-06-01  303  	data = gnss_serial_get_drvdata(gserial);
93acd4265d325a Alison Chaiken 2023-05-07  304  	if (IS_ENABLED(CONFIG_OF)) {
93acd4265d325a Alison Chaiken 2023-05-07  305  		data->is_configured = 0;
93acd4265d325a Alison Chaiken 2023-05-07  306  		data->features = of_match_device(ubx_of_match, &serdev->dev)->data;
93acd4265d325a Alison Chaiken 2023-05-07  307  		if (data->features && data->features->open) {
93acd4265d325a Alison Chaiken 2023-05-07  308  			ubx_gnss_ops->open  = data->features->open;
93acd4265d325a Alison Chaiken 2023-05-07  309  			ubx_gnss_ops->close = gserial->gdev->ops->close;
93acd4265d325a Alison Chaiken 2023-05-07  310  			ubx_gnss_ops->write_raw = gserial->gdev->ops->write_raw;
93acd4265d325a Alison Chaiken 2023-05-07  311  			gserial->gdev->ops = ubx_gnss_ops;
93acd4265d325a Alison Chaiken 2023-05-07  312  		}
93acd4265d325a Alison Chaiken 2023-05-07  313  	}
1ad69f10e3a58d Johan Hovold   2018-06-01  314  	data->vcc = devm_regulator_get(&serdev->dev, "vcc");
1ad69f10e3a58d Johan Hovold   2018-06-01  315  	if (IS_ERR(data->vcc)) {
1ad69f10e3a58d Johan Hovold   2018-06-01  316  		ret = PTR_ERR(data->vcc);
1ad69f10e3a58d Johan Hovold   2018-06-01  317  		goto err_free_gserial;
1ad69f10e3a58d Johan Hovold   2018-06-01  318  	}
1ad69f10e3a58d Johan Hovold   2018-06-01  319  
1ad69f10e3a58d Johan Hovold   2018-06-01  320  	data->v_bckp = devm_regulator_get_optional(&serdev->dev, "v-bckp");
1ad69f10e3a58d Johan Hovold   2018-06-01  321  	if (IS_ERR(data->v_bckp)) {
1ad69f10e3a58d Johan Hovold   2018-06-01  322  		ret = PTR_ERR(data->v_bckp);
1ad69f10e3a58d Johan Hovold   2018-06-01  323  		if (ret == -ENODEV)
1ad69f10e3a58d Johan Hovold   2018-06-01  324  			data->v_bckp = NULL;
1ad69f10e3a58d Johan Hovold   2018-06-01  325  		else
1ad69f10e3a58d Johan Hovold   2018-06-01  326  			goto err_free_gserial;
1ad69f10e3a58d Johan Hovold   2018-06-01  327  	}
1ad69f10e3a58d Johan Hovold   2018-06-01  328  
1ad69f10e3a58d Johan Hovold   2018-06-01  329  	if (data->v_bckp) {
1ad69f10e3a58d Johan Hovold   2018-06-01  330  		ret = regulator_enable(data->v_bckp);
1ad69f10e3a58d Johan Hovold   2018-06-01  331  		if (ret)
1ad69f10e3a58d Johan Hovold   2018-06-01  332  			goto err_free_gserial;
1ad69f10e3a58d Johan Hovold   2018-06-01  333  	}
1ad69f10e3a58d Johan Hovold   2018-06-01  334  
1ad69f10e3a58d Johan Hovold   2018-06-01  335  	ret = gnss_serial_register(gserial);
1ad69f10e3a58d Johan Hovold   2018-06-01  336  	if (ret)
1ad69f10e3a58d Johan Hovold   2018-06-01  337  		goto err_disable_v_bckp;
1ad69f10e3a58d Johan Hovold   2018-06-01  338  
1ad69f10e3a58d Johan Hovold   2018-06-01  339  	return 0;
1ad69f10e3a58d Johan Hovold   2018-06-01  340  
1ad69f10e3a58d Johan Hovold   2018-06-01  341  err_disable_v_bckp:
1ad69f10e3a58d Johan Hovold   2018-06-01  342  	if (data->v_bckp)
1ad69f10e3a58d Johan Hovold   2018-06-01  343  		regulator_disable(data->v_bckp);
1ad69f10e3a58d Johan Hovold   2018-06-01  344  err_free_gserial:
1ad69f10e3a58d Johan Hovold   2018-06-01  345  	gnss_serial_free(gserial);
1ad69f10e3a58d Johan Hovold   2018-06-01  346  
1ad69f10e3a58d Johan Hovold   2018-06-01  347  	return ret;
1ad69f10e3a58d Johan Hovold   2018-06-01  348  }
1ad69f10e3a58d Johan Hovold   2018-06-01  349  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud
  2023-05-08  1:11 ` [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud alison
  2023-05-08  7:52   ` kernel test robot
@ 2023-05-08  8:00   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-08  8:00 UTC (permalink / raw)
  To: alison, johan
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree,
	linux-kernel, achaiken

On 08/05/2023 03:11, alison@she-devel.com wrote:
> From: Alison Chaiken <achaiken@aurora.tech>
> 
> Add support for setting the baud rate of U-Blox Zed-F9P GNSS devices.
> Provide functions that support writing of arbitrary configuration
> messages to the device plus one that specifically configures the baud
> rate.  Override the default gnss_serial_open() with a new method that
> writes the configuration message to the GNSS if the devicetree declares
> it to be a Zed F9P and requests a non-default baud.  Add a boolean flag
> to the ubx_data private data of the GNSS driver in order to track
> whether the configuration message has already been written.  Set the Zed
> F9P to its default port speed if the devicetree does not specify a
> value.
> 
> Signed-off-by: Alison Chaiken <achaiken@aurora.tech>
> ---
> 
> V5 -> V4 Compile out the changes if CONFIG_OF is not set.

Judging by the number of kernel test robot failures, I am not sure if
you tested the patch.

Anyway, don't add more #ifdefs, that's not a correct approach. Depending
on the case, you either remove if entirely or add __maybe_unused. Why
did you need to add the #ifdefs?



Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-08  8:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08  1:11 [PATCH v5 0/2] support config of U-Blox Zed-F9P GNSS alison
2023-05-08  1:11 ` [PATCH v4 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud alison
2023-05-08  7:52   ` kernel test robot
2023-05-08  8:00   ` Krzysztof Kozlowski
2023-05-08  1:11 ` [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9 alison
2023-05-08  2:26   ` Rob Herring
2023-05-08  6:39   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).