Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOPIC: GPIO] documentation refinements, test conversion, and sx1509b conversion for new API #18689

Closed
wants to merge 17 commits into from

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Aug 26, 2019

This PR provides a few documentation refinements to the API header and converts the generic GPIO test to confirm the legacy API and new API works as intended. It also switches the legacy API to be implemented in terms of the new API, though that may be premature.

This is based on PR #16648 under the assumption that's ready to be merged to the topic branch.

@pabigot pabigot added area: GPIO area: Tests Issues related to a particular existing or missing test area: API Changes to public APIs labels Aug 26, 2019
@pabigot pabigot requested a review from mnkp August 26, 2019 23:39
@pabigot pabigot changed the base branch from master to topic-gpio August 27, 2019 11:32
@pabigot pabigot changed the base branch from topic-gpio to master August 27, 2019 11:35
@zephyrbot
Copy link
Collaborator

zephyrbot commented Aug 27, 2019

Found the following issues, please fix and resubmit:

checkpatch issues

-:2450: WARNING:LINE_SPACING: Missing a blank line after declarations
#2450: FILE: drivers/gpio/gpio_sam.c:43:
+	struct gpio_sam_runtime *const dev_data = DEV_DATA(dev);
+	Pio *const pio = cfg->regs;

-:2450: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#2450: FILE: drivers/gpio/gpio_sam.c:43:
+	Pio *const pio = cfg->regs;
 	    ^

-:2599: WARNING:LINE_SPACING: Missing a blank line after declarations
#2599: FILE: drivers/gpio/gpio_sam.c:203:
+	const struct gpio_sam_config *const cfg = DEV_CFG(dev);
+	Pio *const pio = cfg->regs;

-:2599: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#2599: FILE: drivers/gpio/gpio_sam.c:203:
+	Pio *const pio = cfg->regs;
 	    ^

-:2610: WARNING:LINE_SPACING: Missing a blank line after declarations
#2610: FILE: drivers/gpio/gpio_sam.c:214:
+	const struct gpio_sam_config *const cfg = DEV_CFG(dev);
+	Pio *const pio = cfg->regs;

-:2610: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#2610: FILE: drivers/gpio/gpio_sam.c:214:
+	Pio *const pio = cfg->regs;
 	    ^

-:2620: WARNING:LINE_SPACING: Missing a blank line after declarations
#2620: FILE: drivers/gpio/gpio_sam.c:224:
+	const struct gpio_sam_config *const cfg = DEV_CFG(dev);
+	Pio *const pio = cfg->regs;

-:2620: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#2620: FILE: drivers/gpio/gpio_sam.c:224:
+	Pio *const pio = cfg->regs;
 	    ^

-:2631: WARNING:LINE_SPACING: Missing a blank line after declarations
#2631: FILE: drivers/gpio/gpio_sam.c:235:
+	const struct gpio_sam_config *const cfg = DEV_CFG(dev);
+	Pio *const pio = cfg->regs;

-:2631: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#2631: FILE: drivers/gpio/gpio_sam.c:235:
+	Pio *const pio = cfg->regs;
 	    ^

-:2642: WARNING:LINE_SPACING: Missing a blank line after declarations
#2642: FILE: drivers/gpio/gpio_sam.c:246:
+	const struct gpio_sam_config *const cfg = DEV_CFG(dev);
+	Pio *const pio = cfg->regs;

-:2642: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#2642: FILE: drivers/gpio/gpio_sam.c:246:
+	Pio *const pio = cfg->regs;
 	    ^

-:2655: WARNING:LINE_SPACING: Missing a blank line after declarations
#2655: FILE: drivers/gpio/gpio_sam.c:259:
+	struct gpio_sam_runtime *const dev_data = DEV_DATA(dev);
+	Pio *const pio = cfg->regs;

-:2655: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#2655: FILE: drivers/gpio/gpio_sam.c:259:
+	Pio *const pio = cfg->regs;
 	    ^

-:3139: WARNING:LONG_LINE: line over 80 characters
#3139: FILE: drivers/gpio/gpio_sx1509b.c:273:
+	LOG_DBG("write %04x msk %04x val %04x => %04x: %d", *outp, mask, value, out, rc);

-:3648: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3648: FILE: include/drivers/gpio.h:303:
+#define GPIO_DIR_IN             GPIO_DEPRECATED_MACRO GPIO_INPUT

-:3655: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3655: FILE: include/drivers/gpio.h:310:
+#define GPIO_DIR_OUT            GPIO_DEPRECATED_MACRO GPIO_OUTPUT

-:3661: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3661: FILE: include/drivers/gpio.h:316:
+#define GPIO_DS_DISCONNECT_LOW  GPIO_DEPRECATED_MACRO GPIO_OPEN_SOURCE

-:3667: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3667: FILE: include/drivers/gpio.h:322:
+#define GPIO_DS_DISCONNECT_HIGH GPIO_DEPRECATED_MACRO GPIO_OPEN_DRAIN

-:3678: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3678: FILE: include/drivers/gpio.h:333:
+#define GPIO_PUD_NORMAL		GPIO_DEPRECATED_MACRO 0

-:3685: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3685: FILE: include/drivers/gpio.h:340:
+#define GPIO_PUD_PULL_UP	GPIO_DEPRECATED_MACRO GPIO_PULL_UP

-:3692: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3692: FILE: include/drivers/gpio.h:347:
+#define GPIO_PUD_PULL_DOWN	GPIO_DEPRECATED_MACRO GPIO_PULL_DOWN

-:3698: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3698: FILE: include/drivers/gpio.h:353:
+#define GPIO_INT                GPIO_DEPRECATED_MACRO GPIO_INT_ENABLE

-:3713: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3713: FILE: include/drivers/gpio.h:368:
+#define GPIO_INT_ACTIVE_LOW     GPIO_DEPRECATED_MACRO GPIO_INT_LOW_0

-:3728: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3728: FILE: include/drivers/gpio.h:383:
+#define GPIO_INT_ACTIVE_HIGH    GPIO_DEPRECATED_MACRO GPIO_INT_HIGH_1

-:3734: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3734: FILE: include/drivers/gpio.h:389:
+#define GPIO_INT_DOUBLE_EDGE    GPIO_DEPRECATED_MACRO GPIO_INT_EDGE_BOTH

-:3745: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3745: FILE: include/drivers/gpio.h:400:
+#define GPIO_POL_NORMAL		GPIO_DEPRECATED_MACRO GPIO_ACTIVE_HIGH

-:3751: WARNING:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#3751: FILE: include/drivers/gpio.h:406:
+#define GPIO_POL_INV		GPIO_DEPRECATED_MACRO GPIO_ACTIVE_LOW

-:3972: WARNING:LONG_LINE: line over 80 characters
#3972: FILE: include/drivers/gpio.h:692:
+__syscall int gpio_port_set_masked_raw(struct device *port, gpio_port_pins_t mask,

-:4003: WARNING:LONG_LINE: line over 80 characters
#4003: FILE: include/drivers/gpio.h:723:
+static inline int gpio_port_set_masked(struct device *port, gpio_port_pins_t mask,

-:4023: WARNING:LONG_LINE: line over 80 characters
#4023: FILE: include/drivers/gpio.h:743:
+__syscall int gpio_port_set_bits_raw(struct device *port, gpio_port_pins_t pins);

-:4057: WARNING:LONG_LINE: line over 80 characters
#4057: FILE: include/drivers/gpio.h:777:
+__syscall int gpio_port_clear_bits_raw(struct device *port, gpio_port_pins_t pins);

-:4077: WARNING:LONG_LINE: line over 80 characters
#4077: FILE: include/drivers/gpio.h:797:
+static inline int gpio_port_clear_bits(struct device *port, gpio_port_pins_t pins)

-:5678: WARNING:LONG_LINE: line over 80 characters
#5678: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:134:
+	zassert_equal(gpio_port_set_masked(port, 1 << TEST_PIN, 1 << TEST_PIN), 0,

-:5734: WARNING:LONG_LINE: line over 80 characters
#5734: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:190:
+		port_set_masked_raw_and_verify(port, 1 << TEST_PIN, test_vector[i], i);

-:5777: WARNING:LONG_LINE: line over 80 characters
#5777: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:233:
+		port_set_masked_and_verify(port, 1 << TEST_PIN, test_vector[i], i);

-:5823: WARNING:LONG_LINE: line over 80 characters
#5823: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:279:
+		port_set_masked_and_verify(port, 1 << TEST_PIN, test_vector[i], i);

-:5834: WARNING:LONG_LINE: line over 80 characters
#5834: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:290:
+		port_set_masked_raw_and_verify(port, 1 << TEST_PIN, test_vector[i], i);

-:5883: WARNING:LONG_LINE: line over 80 characters
#5883: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:339:
+		port_set_masked_and_verify(port, 1 << TEST_PIN, test_vector[i], i);

-:5886: WARNING:LONG_LINE: line over 80 characters
#5886: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:342:
+		val_raw_expected |= (test_vector[i] & (1 << TEST_PIN)) ^ (1 << TEST_PIN);

-:5896: WARNING:LONG_LINE: line over 80 characters
#5896: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:352:
+		port_set_masked_raw_and_verify(port, 1 << TEST_PIN, test_vector[i], i);

-:5901: WARNING:LONG_LINE: line over 80 characters
#5901: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:357:
+		val_expected |= (test_vector[i] & (1 << TEST_PIN)) ^ (1 << TEST_PIN);

-:6010: WARNING:LONG_LINE: line over 80 characters
#6010: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:466:
+		port_set_clr_bits_raw(port, test_vector[i][0], test_vector[i][1], i);

-:6045: WARNING:LONG_LINE: line over 80 characters
#6045: FILE: tests/drivers/gpio/gpio_api_1pin/src/test_port.c:501:
+		port_set_clr_bits(port, test_vector[i][0], test_vector[i][1], i);

-:6105: WARNING:LONG_LINE: line over 80 characters
#6105: FILE: tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c:49:
+		rc = gpio_pin_interrupt_configure(dev, PIN_OUT, GPIO_INT_DISABLE);

-:6292: WARNING:LINE_SPACING: Missing a blank line after declarations
#6292: FILE: tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c:67:
+	int rc = gpio_pin_configure(dev, PIN_OUT, out_flags);
+	if (rc != 0) {

-:6323: WARNING:LONG_LINE: line over 80 characters
#6323: FILE: tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c:92:
+	rc = gpio_pin_interrupt_configure(dev, PIN_IN, mode | GPIO_INT_DEBOUNCE);

-:6452: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'raw_in', this function's name, in a string
#6452: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:28:
+		      "raw_in failed");

-:6478: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'raw_out', this function's name, in a string
#6478: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:54:
+		      "raw_out failed");

-:6494: WARNING:LONG_LINE: line over 80 characters
#6494: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:70:
+	TC_PRINT("Check %s output %d connected to input %d\n", DEV_NAME, PIN_OUT, PIN_IN);

-:6596: WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#6596: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:172:
+	 * is to set the bit. */

-:6598: ERROR:C99_COMMENTS: do not use C99 // comments
#6598: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:174:
+		// preserve set

-:6599: WARNING:LONG_LINE: line over 80 characters
#6599: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:175:
+		rc = gpio_port_set_clr_bits_raw(dev, BIT(PIN_OUT), BIT(PIN_OUT));

-:6605: ERROR:C99_COMMENTS: do not use C99 // comments
#6605: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:181:
+		// do set

-:6607: WARNING:LONG_LINE: line over 80 characters
#6607: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:183:
+		rc = gpio_port_set_clr_bits_raw(dev, BIT(PIN_OUT), BIT(PIN_OUT));

-:6854: WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#6854: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:430:
+	 * is to set the bit. */

-:6856: ERROR:C99_COMMENTS: do not use C99 // comments
#6856: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:432:
+		// preserve set

-:6863: ERROR:C99_COMMENTS: do not use C99 // comments
#6863: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:439:
+		// force set

-:6927: WARNING:LONG_LINE: line over 80 characters
#6927: FILE: tests/drivers/gpio/gpio_basic_api/src/test_pin_rw.c:28:
+	TC_PRINT("device=%s, pin1=%d, pin2=%d: %p\n", DEV_NAME, PIN_OUT, PIN_IN, dev);

- total: 11 errors, 48 warnings, 6471 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.



@pabigot
Copy link
Collaborator Author

pabigot commented Aug 27, 2019

@mnkp see the mcux commit 4260946e7e0d14a1d0b87e4f4c565476c56839ca which you might want to incorporate into your next update.

@mnkp
Copy link
Member

mnkp commented Aug 29, 2019

@pabigot Thanks for the PR.

I'm going to include the following minor updates directly into existing commits in #16648:

  • gpio: document replacement for deprecated callback functions
  • gpio: standardize deprecation message style
  • drivers/gpio_mcux: implement initial output flags

this will keep commit history clean. The changes could be part of the review process.

I'm going to cherry pick the following commit into #16648:

  • gpio: use named types to distinguish pin sets from pin values

I would like to include changes proposed in:

  • gpio: replace legacy API implementation with new API

in #16648 but that needs a bit more discussion. I'll follow up.

Remaining commits can be merged later directly into topic-gpio branch.

* be toggled.
* Note that the behavior required for pins present in both
* ``set_pins`` and ``clear_pins`` is to toggle the current pin
* setting.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is written as if it was an instruction for a person implementing the driver. The API documentation should be targeted at the users of the API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded.

* @param clear_pins Value indicating which pins will be set to inactive or
* toggled.
* @param set_pins Pins selected by this mask are changed to active if
* they were not already active.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the commit description:

It also clarifies the expected behavior of the driver in situations
where the driver can detect that an operation would have no effect,
which is signficant for external IO extenders where an unnecessary bus
transaction can be eliminated.

This optimization can be done by the driver also without changing the description. While we mention toggle functionality in the description of the function this text doesn't make it clear that "Pins selected by this mask can be changed to inactive if a matching pin is selected by clear_pins parameter." I'm not saying we shouldn't change the description of set_pins, clear_pins parameters but this proposal doesn't seem like an improvement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is one that was discussed some months ago: if a GPIO output state is requested, and the driver knows the pin is already in that state, does it have to execute an expensive operation that will have no effect? My recollection is the discussion converged to "no, it does not". (I believe this discussion was in a comment somewhere on #11880 that has since disappeared.)

There's a converse policy: if the driver knows the pin is already in that state is it permitted to go ahead and execute the operation anyway? Here I think the answer needs to be "yes" to simplify the common case where the cost of checking for effect is greater than just executing it unconditionally.

Somewhere that has to made clear to both the implementer and the user.

There are two goals of the commit that changes the documentation for this function:

  • First, provide an interpretation of set_pins and clear_pins that explains why having a pin selected by both should result in a toggle operation. The toggle behavior emerges naturally when the effect of pin selection is conditional on pin state: only the selection that would change the state is relevant. It is helpful to explicitly recognize that effect so users and implementers are aware of the expectation.
  • Second, by identifying that some requests may have no effect it supports an implementer decision to do nothing in cases where the effectless-operation has side effects, e.g. performing one or more external bus transactions (for SX1509B).

I'm open to proposals for alternative wording that accomplish these goals.

@pabigot
Copy link
Collaborator Author

pabigot commented Aug 29, 2019

@mnkp these new commits might be worth squashing into to your branch:

  • 1bcc9c1644 [Thu Aug 29 10:51:49 2019 -0500] gpio: simplify port clear bits
  • c637eb44ac [Thu Aug 29 14:09:11 2019 -0500] drivers: gpio: fix handler for output parameter

* Pins which are simultaneously selected by set_pins and clear_pins value will
* be toggled.
* Pins that are selected by both set_pins and clear_pins will be
* cleared to low.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the API would be "cleaner" if the function disallowed to have a pin selected by both set_pins and clear_pins values. If the application asks to have a pin set and cleared at the same time something clearly went wrong. It's better to report an error (or catch the issue via ASSERT) rather than quietly clear the pin.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that'd be OK. So the idea would be something like:

__ASSERT((set_pins & clear_pins) == 0,
         "Pins cannot be both set and cleared");
return gpio_port_set_masked(port, set_pins | clear_pins, set_pins);

The effect in the default situation of ignoring __ASSERT is that pins that are both set and cleared are actually just set, which is as good a choice as clearing them, and because this is done in the common header inline function such (illegal) usage would produce consistent behavior across drivers, which is desirable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll implement the change, you don't need to push an update to your PR.

@pabigot pabigot changed the title [TOPIC: GPIO] documentation refinements and test conversion for new API [TOPIC: GPIO] documentation refinements, test conversion, and sx1509b conversion for new API Sep 1, 2019
@@ -132,6 +132,12 @@ static int gpio_nrfx_config(struct device *port, int access_op,
u8_t from_pin;
u8_t to_pin;

/* Open Source is not supported on this platform */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a problem with the testcase, I needed to add pull up / pull down on a pin. I couldn't rely on the LED and resistor to set pin value. The test is passing on nrf52840_pca10056 board. The platform supports Open Drain / Open Source mode.

@pabigot pabigot changed the base branch from master to topic-gpio September 17, 2019 16:03
@zephyrbot
Copy link
Collaborator

zephyrbot commented Sep 17, 2019

Some checks failed. Please fix and resubmit.

Identity/Emails issues

ab0d822: author email (Peter Bigot peter.bigot@nordicsemi.no) needs to match one of the signed-off-by entries.

33a28b4: author email (Peter Bigot peter.bigot@nordicsemi.no) needs to match one of the signed-off-by entries.

checkpatch issues

-:924: WARNING:LONG_LINE: line over 80 characters
#924: FILE: drivers/gpio/gpio_sx1509b.c:273:
+	LOG_DBG("write %04x msk %04x val %04x => %04x: %d", *outp, mask, value, out, rc);

-:1488: ERROR:TRAILING_WHITESPACE: trailing whitespace
#1488: FILE: tests/drivers/gpio/gpio_basic_api/frdm_k64f.overlay:16:
+^I^I^I$

-:1574: WARNING:LINE_SPACING: Missing a blank line after declarations
#1574: FILE: tests/drivers/gpio/gpio_basic_api/src/main.c:22:
+	struct device *pmx = device_get_binding(pmx_name);
+	printk("pmx %s for %s: %p\n", pmx_name, DEV_NAME, pmx);

-:1576: WARNING:LINE_SPACING: Missing a blank line after declarations
#1576: FILE: tests/drivers/gpio/gpio_basic_api/src/main.c:24:
+	int rc = pinmux_pin_set(pmx, PIN_OUT, PORT_PCR_MUX(kPORT_MuxAsGpio));
+	printk("pmx pin %u: %d\n", PIN_OUT, rc);

-:1622: WARNING:LONG_LINE: line over 80 characters
#1622: FILE: tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c:49:
+		rc = gpio_pin_interrupt_configure(dev, PIN_OUT, GPIO_INT_DISABLE);

-:1809: WARNING:LINE_SPACING: Missing a blank line after declarations
#1809: FILE: tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c:67:
+	int rc = gpio_pin_configure(dev, PIN_OUT, out_flags);
+	if (rc != 0) {

-:1840: WARNING:LONG_LINE: line over 80 characters
#1840: FILE: tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c:92:
+	rc = gpio_pin_interrupt_configure(dev, PIN_IN, mode | GPIO_INT_DEBOUNCE);

-:1981: ERROR:POINTER_LOCATION: "foo* bar" should be "foo *bar"
#1981: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_perf.c:15:
+static void measure(const char* tag,

-:2037: ERROR:POINTER_LOCATION: "foo* bar" should be "foo *bar"
#2037: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_perf.c:71:
+		const char* devname;

-:2070: WARNING:LONG_LINE: line over 80 characters
#2070: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_perf.c:104:
+	const struct scope_type *const spe = sp + sizeof(scope_pins) / sizeof(*scope_pins);

-:2084: WARNING:LONG_LINE: line over 80 characters
#2084: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_perf.c:118:
+		printk("P%u : %s %u\n", (u32_t)(sp - scope_pins), sp->devname, sp->pin);

-:2087: WARNING:LINE_SPACING: Missing a blank line after declarations
#2087: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_perf.c:121:
+			u32_t flags = GPIO_OUTPUT_LOW;
+			out_pins |= BIT(sp->pin);

-:2092: WARNING:LONG_LINE: line over 80 characters
#2092: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_perf.c:126:
+			zassert_equal(gpio_pin_configure(dev, sp->pin, flags), 0,

-:2158: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'raw_in', this function's name, in a string
#2158: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:28:
+		      "raw_in failed");

-:2184: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'raw_out', this function's name, in a string
#2184: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:54:
+		      "raw_out failed");

-:2200: WARNING:LONG_LINE: line over 80 characters
#2200: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:70:
+	TC_PRINT("Check %s output %d connected to input %d\n", DEV_NAME, PIN_OUT, PIN_IN);

-:2302: WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#2302: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:172:
+	 * is to set the bit. */

-:2304: ERROR:C99_COMMENTS: do not use C99 // comments
#2304: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:174:
+		// preserve set

-:2305: WARNING:LONG_LINE: line over 80 characters
#2305: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:175:
+		rc = gpio_port_set_clr_bits_raw(dev, BIT(PIN_OUT), BIT(PIN_OUT));

-:2311: ERROR:C99_COMMENTS: do not use C99 // comments
#2311: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:181:
+		// do set

-:2313: WARNING:LONG_LINE: line over 80 characters
#2313: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:183:
+		rc = gpio_port_set_clr_bits_raw(dev, BIT(PIN_OUT), BIT(PIN_OUT));

-:2560: WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#2560: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:430:
+	 * is to set the bit. */

-:2562: ERROR:C99_COMMENTS: do not use C99 // comments
#2562: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:432:
+		// preserve set

-:2569: ERROR:C99_COMMENTS: do not use C99 // comments
#2569: FILE: tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c:439:
+		// force set

-:2633: WARNING:LONG_LINE: line over 80 characters
#2633: FILE: tests/drivers/gpio/gpio_basic_api/src/test_pin_rw.c:28:
+	TC_PRINT("device=%s, pin1=%d, pin2=%d: %p\n", DEV_NAME, PIN_OUT, PIN_IN, dev);

- total: 7 errors, 18 warnings, 2464 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Gitlint issues

Commit ab0d822:
1: T5 Title contains the word 'wip' (case-insensitive): "WIP tests/drivers/gpio: add performance tests"
1: UC2 Body does not contain a 'Signed-off-by:' line

Commit 33a28b4:
1: UC2 Body does not contain a 'Signed-off-by:' line
1: UC6 Body has no content, should at least have 1 line.
3: B6 Body message is missing

Commit 2db9c66:
1: T5 Title contains the word 'wip' (case-insensitive): "WIP tests/drivers/gpio: generalize gpio specification solution"

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

The comments identifying replacement API were inadvertently removed
along with the flag that triggers deprecation warnings.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
External GPIO drivers may not be supported from interrupt context
because they involve blocking bus transactions.  Describe the return
value for this situation, and add the I/O error to operations where it
was missing.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Add a comment that shows the hexadecimal representation of each flag, to
help a user who needs to decode a packed set of flags.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Update driver code and board files to use new GPIO configuration flags
such as GPIO_ACTIVE_LOW. Also add implementation of new port_* driver
API.

Tested on external SX1509B breakout board and Thingy:52.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Test that the new port API functions all behave as expected, including
physical vs logical level for input and output as well as masked and
set-based output operations.  Also tests the new pin API functions.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the recommended replacement as the implementation of the deprecated
pin read and write functions, rather than calling the old
implementation.

Retain the existing test, but silence the complaints related to using
deprecated functions.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Switch to gpio_pin_interrupt_configure() and the new interrupt flags.
Use logical level pin set operations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Switch to gpio_pin_interrupt_configure() and the new interrupt flags.
Use logical level pin set operations.  Test all standard interrupt
configurations including double edge.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Set the devicetree nodes to correctly reflect active levels for buttons,
leds, and antenna switch.  Update the board initialization code to use
the non-deprecated GPIO API for antenna switching.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Remove the old read and write implementation functions from the driver
API table, along with their system call implementations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The access-oriented GPIO read and write system calls have been replaced
with new API.  Remove the old implementation.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The access-oriented GPIO read and write system calls have been replaced
with new API.  Remove the old implementation.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The access-oriented GPIO read and write system calls have been replaced
with new API.  Remove the old implementation.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The access-oriented GPIO read and write system calls have been replaced
with new API.  Remove the old implementation.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Provide board-specific overlays that specify which pins to use for the
test, rather than use aliases in the board device tree.  This uses a
binding that's specifically documented for use in GPIO applications.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Time execution of a sequence of operations.

s1 test takes 7.02 us on pca10056.
@pabigot
Copy link
Collaborator Author

pabigot commented Sep 18, 2019

Since this branch has content that won't pass shippable it's not suitable for review. Future reviews will have to be on an unsubmitted branch.

@pabigot pabigot closed this Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Boards area: Devicetree area: GPIO area: Samples Samples area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants