Skip to contentSkip to conversation

iio: cros: unify hw fifo attributes without API changes

PATCH Superseded Gwendal Grignou 2 participants 3 messages Mar 8, 2021 – Mar 9, 2021

Subsystems (2)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: cros: unify hw fifo attributes without API changes

fixes commit 2e2366c2d141 ("iio: cros_ec: unify hw fifo attributes into the core file") fixes commit 165aea80e2e2 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()")

1. Instead of adding has_fw_fifo, deduct it from the configuration:
- EC must support FIFO (EC_FEATURE_MOTION_SENSE_FIFO) set.
- sensors send data a regular interval (accelerometer, gyro, magnetomer, barometer, light sensor).
- "Legacy accelerometer" is only present on EC without FIFO, so we don't need to set buffer attributes.

2. devm_iio_triggered_buffer_setup_ext() does not need to be called. Only when the EC support FIFO we set the buffer attributes directly to set timeout and watermark.

---
 drivers/iio/accel/cros_ec_accel_legacy.c      |  2 +-
 .../cros_ec_sensors/cros_ec_lid_angle.c       |  3 +--
 .../common/cros_ec_sensors/cros_ec_sensors.c  |  3 +--
 .../cros_ec_sensors/cros_ec_sensors_core.c    | 19 +++++++------------
 drivers/iio/light/cros_ec_light_prox.c        |  3 +--
 drivers/iio/pressure/cros_ec_baro.c           |  3 +--
 .../linux/iio/common/cros_ec_sensors_core.h   |  3 +--
 7 files changed, 13 insertions(+), 23 deletions(-)
drivers/iio/accel/cros_ec_accel_legacy.c +1 -1
index 8f1232c38e0d7..b6f3471b62dcf 100644
@@ -215,7 +215,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
-					cros_ec_sensors_capture, NULL, false);
+					cros_ec_sensors_capture, NULL);
 	if (ret)
 		return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c +1 -2
index 752f59037715b..af801e203623e 100644
@@ -97,8 +97,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev)
 	if (!indio_dev)
 		return -ENOMEM;
 
-	ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL,
-					NULL, false);
+	ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL, NULL);
 	if (ret)
 		return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +1 -2
index dee1191de7528..376a5b30010ae 100644
@@ -236,8 +236,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
 
 	ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
 					cros_ec_sensors_capture,
-					cros_ec_sensors_push_data,
-					true);
+					cros_ec_sensors_push_data);
 	if (ret)
 		return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +7 -12
index c833ec0ef2147..1926f5719b2d4 100644
@@ -8,6 +8,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/buffer_impl.h>
 #include <linux/iio/common/cros_ec_sensors_core.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
@@ -240,7 +241,6 @@ static void cros_ec_sensors_core_clean(void *arg)
  *    for backward compatibility.
  * @push_data:          function to call when cros_ec_sensorhub receives
  *    a sample for that sensor.
- * @has_hw_fifo:	Set true if this device has/uses a HW FIFO
  *
  * Return: 0 on success, -errno on failure.
  */
@@ -248,8 +248,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
 			      struct iio_dev *indio_dev,
 			      bool physical_device,
 			      cros_ec_sensors_capture_t trigger_capture,
-			      cros_ec_sensorhub_push_data_cb_t push_data,
-			      bool has_hw_fifo)
+			      cros_ec_sensorhub_push_data_cb_t push_data)
 {
 	struct device *dev = &pdev->dev;
 	struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
@@ -358,21 +357,17 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
 			ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
 			if (ret)
 				return ret;
-		} else {
-			const struct attribute **fifo_attrs;
-
-			if (has_hw_fifo)
-				fifo_attrs = cros_ec_sensor_fifo_attributes;
-			else
-				fifo_attrs = NULL;
 
+			/* Set attributes to control EC FIFO directly. */
+			indio_dev->buffer->attrs = cros_ec_sensor_fifo_attributes;
+		} else {
 			/*
 			 * The only way to get samples in buffer is to set a
 			 * software trigger (systrig, hrtimer).
 			 */
-			ret = devm_iio_triggered_buffer_setup_ext(
+			ret = devm_iio_triggered_buffer_setup(
 					dev, indio_dev, NULL, trigger_capture,
-					NULL, fifo_attrs);
+					NULL);
 			if (ret)
 				return ret;
 		}
drivers/iio/light/cros_ec_light_prox.c +1 -2
index 75d6b5fcf2cc4..de472f23d1cba 100644
@@ -182,8 +182,7 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
 
 	ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
 					cros_ec_sensors_capture,
-					cros_ec_sensors_push_data,
-					true);
+					cros_ec_sensors_push_data);
 	if (ret)
 		return ret;
 
drivers/iio/pressure/cros_ec_baro.c +1 -2
index aa043cb9ac426..2f882e1094232 100644
@@ -139,8 +139,7 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
 
 	ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
 					cros_ec_sensors_capture,
-					cros_ec_sensors_push_data,
-					true);
+					cros_ec_sensors_push_data);
 	if (ret)
 		return ret;
 
include/linux/iio/common/cros_ec_sensors_core.h +1 -2
index c9b80be82440f..7ce8a8adad587 100644
@@ -96,8 +96,7 @@ struct platform_device;
 int cros_ec_sensors_core_init(struct platform_device *pdev,
 			      struct iio_dev *indio_dev, bool physical_device,
 			      cros_ec_sensors_capture_t trigger_capture,
-			      cros_ec_sensorhub_push_data_cb_t push_data,
-			      bool has_hw_fifo);
+			      cros_ec_sensorhub_push_data_cb_t push_data);
 
 irqreturn_t cros_ec_sensors_capture(int irq, void *p);
 int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog
#1 lore raw
Quoted 72 lines · Gwendal Grignou

fixes commit 2e2366c2d141 ("iio: cros_ec: unify hw fifo attributes into the core file") fixes commit 165aea80e2e2 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()")

1. Instead of adding has_fw_fifo, deduct it from the configuration:
- EC must support FIFO (EC_FEATURE_MOTION_SENSE_FIFO) set.
- sensors send data a regular interval (accelerometer, gyro, magnetomer, barometer, light sensor).
- "Legacy accelerometer" is only present on EC without FIFO, so we don't need to set buffer attributes.

2. devm_iio_triggered_buffer_setup_ext() does not need to be called. Only when the EC support FIFO we set the buffer attributes directly to set timeout and watermark.

---
 drivers/iio/accel/cros_ec_accel_legacy.c      |  2 +-
 .../cros_ec_sensors/cros_ec_lid_angle.c       |  3 +--
 .../common/cros_ec_sensors/cros_ec_sensors.c  |  3 +--
 .../cros_ec_sensors/cros_ec_sensors_core.c    | 19 +++++++------------
 drivers/iio/light/cros_ec_light_prox.c        |  3 +--
 drivers/iio/pressure/cros_ec_baro.c           |  3 +--
 .../linux/iio/common/cros_ec_sensors_core.h   |  3 +--
 7 files changed, 13 insertions(+), 23 deletions(-)
drivers/iio/accel/cros_ec_accel_legacy.c +1 -1
index 8f1232c38e0d7..b6f3471b62dcf 100644
@@ -215,7 +215,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
-                                       cros_ec_sensors_capture, NULL, false);
+                                       cros_ec_sensors_capture, NULL);
        if (ret)
                return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c +1 -2
index 752f59037715b..af801e203623e 100644
@@ -97,8 +97,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev)
        if (!indio_dev)
                return -ENOMEM;
 
-       ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL,
-                                       NULL, false);
+       ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL, NULL);
        if (ret)
                return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +1 -2
index dee1191de7528..376a5b30010ae 100644
@@ -236,8 +236,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
                                        cros_ec_sensors_capture,
-                                       cros_ec_sensors_push_data,
-                                       true);
+                                       cros_ec_sensors_push_data);
        if (ret)
                return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +0 -0
index c833ec0ef2147..1926f5719b2d4 100644

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c line 11

Quoted 4 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +1 -0
@@ -8,6 +8,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/buffer_impl.h>

buffer_impl.h should not need to be included in drivers; in should be included in buffer implementations like kfifo, dma-buffer, and others

Quoted 25 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +1 -3
 #include <linux/iio/common/cros_ec_sensors_core.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
@@ -240,7 +241,6 @@ static void cros_ec_sensors_core_clean(void *arg)
  *    for backward compatibility.
  * @push_data:          function to call when cros_ec_sensorhub receives
  *    a sample for that sensor.
- * @has_hw_fifo:       Set true if this device has/uses a HW FIFO
  *
  * Return: 0 on success, -errno on failure.
  */
@@ -248,8 +248,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
                              struct iio_dev *indio_dev,
                              bool physical_device,
                              cros_ec_sensors_capture_t trigger_capture,
-                             cros_ec_sensorhub_push_data_cb_t push_data,
-                             bool has_hw_fifo)
+                             cros_ec_sensorhub_push_data_cb_t push_data)
 {
        struct device *dev = &pdev->dev;
        struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
@@ -358,21 +357,17 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
                        ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
                        if (ret)
                                return ret;

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c int cros_ec_sensors_core_init(struct platform_device *pdev, · line 362

Quoted 10 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +2 -7
-               } else {
-                       const struct attribute **fifo_attrs;
-
-                       if (has_hw_fifo)
-                               fifo_attrs = cros_ec_sensor_fifo_attributes;
-                       else
-                               fifo_attrs = NULL;
 
+                       /* Set attributes to control EC FIFO directly. */
+                       indio_dev->buffer->attrs = cros_ec_sensor_fifo_attributes;

accessing 'indio_dev->buffer' directly will be discouraged, because the idea [moving forward] is to support more than one IIO buffer per IIO device;
the idea of devm_iio_triggered_buffer_setup_ext() is to pass the 'cros_ec_sensor_fifo_attributes' to the IIO buffer, without needing to dig it from the IIO device;

maybe a new method will be needed to access each IIO buffer of the IIO device; but when that happens, accessing a buffer with 'indio_dev->buffer' and iio_device_get_buffer(indio_dev, 0 [or 1]) will look a bit confusing (or at least duplicate)

Quoted 58 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +3 -2
+               } else {
                        /*
                         * The only way to get samples in buffer is to set a
                         * software trigger (systrig, hrtimer).
                         */
-                       ret = devm_iio_triggered_buffer_setup_ext(
+                       ret = devm_iio_triggered_buffer_setup(
                                        dev, indio_dev, NULL, trigger_capture,
-                                       NULL, fifo_attrs);
+                                       NULL);
                        if (ret)
                                return ret;
                }
drivers/iio/light/cros_ec_light_prox.c +1 -2
index 75d6b5fcf2cc4..de472f23d1cba 100644
@@ -182,8 +182,7 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
                                        cros_ec_sensors_capture,
-                                       cros_ec_sensors_push_data,
-                                       true);
+                                       cros_ec_sensors_push_data);
        if (ret)
                return ret;
 
drivers/iio/pressure/cros_ec_baro.c +1 -2
index aa043cb9ac426..2f882e1094232 100644
@@ -139,8 +139,7 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
                                        cros_ec_sensors_capture,
-                                       cros_ec_sensors_push_data,
-                                       true);
+                                       cros_ec_sensors_push_data);
        if (ret)
                return ret;
 
include/linux/iio/common/cros_ec_sensors_core.h +1 -3
index c9b80be82440f..7ce8a8adad587 100644
@@ -96,8 +96,7 @@ struct platform_device;
 int cros_ec_sensors_core_init(struct platform_device *pdev,
                              struct iio_dev *indio_dev, bool physical_device,
                              cros_ec_sensors_capture_t trigger_capture,
-                             cros_ec_sensorhub_push_data_cb_t push_data,
-                             bool has_hw_fifo);
+                             cros_ec_sensorhub_push_data_cb_t push_data);
 
 irqreturn_t cros_ec_sensors_capture(int irq, void *p);
 int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
--

2.30.1.766.gb4fecdf3b7-goog

#2 lore raw
Quoted 69 lines · Alexandru Ardelean
Quoted 67 lines · Gwendal Grignou

fixes commit 2e2366c2d141 ("iio: cros_ec: unify hw fifo attributes into the core file") fixes commit 165aea80e2e2 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()")

1. Instead of adding has_fw_fifo, deduct it from the configuration:
- EC must support FIFO (EC_FEATURE_MOTION_SENSE_FIFO) set.
- sensors send data a regular interval (accelerometer, gyro, magnetomer, barometer, light sensor).
- "Legacy accelerometer" is only present on EC without FIFO, so we don't need to set buffer attributes.

2. devm_iio_triggered_buffer_setup_ext() does not need to be called. Only when the EC support FIFO we set the buffer attributes directly to set timeout and watermark.

---
 drivers/iio/accel/cros_ec_accel_legacy.c      |  2 +-
 .../cros_ec_sensors/cros_ec_lid_angle.c       |  3 +--
 .../common/cros_ec_sensors/cros_ec_sensors.c  |  3 +--
 .../cros_ec_sensors/cros_ec_sensors_core.c    | 19 +++++++------------
 drivers/iio/light/cros_ec_light_prox.c        |  3 +--
 drivers/iio/pressure/cros_ec_baro.c           |  3 +--
 .../linux/iio/common/cros_ec_sensors_core.h   |  3 +--
 7 files changed, 13 insertions(+), 23 deletions(-)
drivers/iio/accel/cros_ec_accel_legacy.c +1 -1
index 8f1232c38e0d7..b6f3471b62dcf 100644
@@ -215,7 +215,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
-                                       cros_ec_sensors_capture, NULL, false);
+                                       cros_ec_sensors_capture, NULL);
        if (ret)
                return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c +1 -2
index 752f59037715b..af801e203623e 100644
@@ -97,8 +97,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev)
        if (!indio_dev)
                return -ENOMEM;
 
-       ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL,
-                                       NULL, false);
+       ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL, NULL);
        if (ret)
                return ret;
 
drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +1 -2
index dee1191de7528..376a5b30010ae 100644
@@ -236,8 +236,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
                                        cros_ec_sensors_capture,
-                                       cros_ec_sensors_push_data,
-                                       true);
+                                       cros_ec_sensors_push_data);
        if (ret)
                return ret;
 
Quoted 13 lines

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c line 11

Quoted 9 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +1 -0
index c833ec0ef2147..1926f5719b2d4 100644
@@ -8,6 +8,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/buffer_impl.h>

buffer_impl.h should not need to be included in drivers; in should be included in buffer implementations like kfifo, dma-buffer, and others

I added the include file to be able to access buffer->attrs. I agree it is not supposed to be called by iio driver themselves.

Quoted 34 lines
Quoted 34 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +1 -10
 #include <linux/iio/common/cros_ec_sensors_core.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
@@ -240,7 +241,6 @@ static void cros_ec_sensors_core_clean(void *arg)
  *    for backward compatibility.
  * @push_data:          function to call when cros_ec_sensorhub receives
  *    a sample for that sensor.
- * @has_hw_fifo:       Set true if this device has/uses a HW FIFO
  *
  * Return: 0 on success, -errno on failure.
  */
@@ -248,8 +248,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
                              struct iio_dev *indio_dev,
                              bool physical_device,
                              cros_ec_sensors_capture_t trigger_capture,
-                             cros_ec_sensorhub_push_data_cb_t push_data,
-                             bool has_hw_fifo)
+                             cros_ec_sensorhub_push_data_cb_t push_data)
 {
        struct device *dev = &pdev->dev;
        struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
@@ -358,21 +357,17 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
                        ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
                        if (ret)
                                return ret;
-               } else {
-                       const struct attribute **fifo_attrs;
-
-                       if (has_hw_fifo)
-                               fifo_attrs = cros_ec_sensor_fifo_attributes;
-                       else
-                               fifo_attrs = NULL;
 
Quoted 9 lines

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c int cros_ec_sensors_core_init(struct platform_device *pdev, · line 362

Quoted 2 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +2 -0
+                       /* Set attributes to control EC FIFO directly. */
+                       indio_dev->buffer->attrs = cros_ec_sensor_fifo_attributes;

accessing 'indio_dev->buffer' directly will be discouraged, because the idea [moving forward] is to support more than one IIO buffer per IIO device;
the idea of devm_iio_triggered_buffer_setup_ext() is to pass the 'cros_ec_sensor_fifo_attributes' to the IIO buffer, without needing to dig it from the IIO device;

What I can do using the existing iio API is to create a "slim" trigger that does not do much like hid sensor stack does at hid_sensor_setup_trigger() while callbacks callbacks.send_event and callbacks.capture_sample are doing the real work.
But once I have a trigger, I can call devm_iio_triggered_buffer_setup_ext and set the fifo attributes.

Gwendal.

Quoted 64 lines

maybe a new method will be needed to access each IIO buffer of the IIO device; but when that happens, accessing a buffer with 'indio_dev->buffer' and iio_device_get_buffer(indio_dev, 0 [or 1]) will look a bit confusing (or at least duplicate)

Quoted 58 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +3 -2
+               } else {
                        /*
                         * The only way to get samples in buffer is to set a
                         * software trigger (systrig, hrtimer).
                         */
-                       ret = devm_iio_triggered_buffer_setup_ext(
+                       ret = devm_iio_triggered_buffer_setup(
                                        dev, indio_dev, NULL, trigger_capture,
-                                       NULL, fifo_attrs);
+                                       NULL);
                        if (ret)
                                return ret;
                }
drivers/iio/light/cros_ec_light_prox.c +1 -2
index 75d6b5fcf2cc4..de472f23d1cba 100644
@@ -182,8 +182,7 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
                                        cros_ec_sensors_capture,
-                                       cros_ec_sensors_push_data,
-                                       true);
+                                       cros_ec_sensors_push_data);
        if (ret)
                return ret;
 
drivers/iio/pressure/cros_ec_baro.c +1 -2
index aa043cb9ac426..2f882e1094232 100644
@@ -139,8 +139,7 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
 
        ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
                                        cros_ec_sensors_capture,
-                                       cros_ec_sensors_push_data,
-                                       true);
+                                       cros_ec_sensors_push_data);
        if (ret)
                return ret;
 
include/linux/iio/common/cros_ec_sensors_core.h +1 -3
index c9b80be82440f..7ce8a8adad587 100644
@@ -96,8 +96,7 @@ struct platform_device;
 int cros_ec_sensors_core_init(struct platform_device *pdev,
                              struct iio_dev *indio_dev, bool physical_device,
                              cros_ec_sensors_capture_t trigger_capture,
-                             cros_ec_sensorhub_push_data_cb_t push_data,
-                             bool has_hw_fifo);
+                             cros_ec_sensorhub_push_data_cb_t push_data);
 
 irqreturn_t cros_ec_sensors_capture(int irq, void *p);
 int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
--

2.30.1.766.gb4fecdf3b7-goog