Re: [PATCH] gpio: devres: Handle nonexclusive GPIOs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 4, 2018 at 2:55 PM Marek Szyprowski
<m.szyprowski@xxxxxxxxxxx> wrote:

> It is still something wrong there, because I get a warning from
> devm_gpiod_unhinge() two times. If I got it right, I should only get one
> such warning with this patch.

So they should be coming from this:
arch/arm/boot/dts/exynos3250-artik5.dtsi

                        ldo11_reg: LDO11 {
                                /* VDD74 ~ VDD75 */
                                regulator-name = "VLDO11_1.8V";
                                regulator-min-microvolt = <1800000>;
                                regulator-max-microvolt = <1800000>;
                                samsung,ext-control-gpios = <&gpk0 2
GPIO_ACTIVE_HIGH>;
                        };

                        ldo12_reg: LDO12 {
                                /* VDD72 ~ VDD73 */
                                regulator-name = "VLDO12_2.8V";
                                regulator-min-microvolt = <2800000>;
                                regulator-max-microvolt = <2800000>;
                                samsung,ext-control-gpios = <&gpk0 2
GPIO_ACTIVE_HIGH>;
                        };

It would make sense on
arch/arm/boot/dts/exynos3250-monk.dts
that shares the same enable line three times.

My patch now looks like below:

+/**
+ * devm_gpiod_unhinge - Remove resource management from a gpio descriptor
+ * @dev:       GPIO consumer
+ * @desc:      GPIO descriptor to remove resource management from
+ *
+ * Remove resource management from a GPIO descriptor. This is needed when
+ * you want to hand over lifecycle management of a descriptor to another
+ * mechanism.
+ */
+
+void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc)
+{
+       int ret;
+
+       if (IS_ERR_OR_NULL(desc))
+               return;
+       ret = devres_destroy(dev, devm_gpiod_release,
+                            devm_gpiod_match, desc);
+       /*
+        * If the GPIO descriptor is requested as nonexclusive, we
+        * may call this function several times on the same descriptor
+        * so it is OK if devres_destroy() returns -ENOENT.
+        */
+       if (ret == -ENOENT)
+               return;
+       /* Anything else we should warn about */
+       WARN_ON(ret);
+}
+EXPORT_SYMBOL(devm_gpiod_unhinge);

I guess I should just resend the series. If -ENOENT appears
more than once we might need to introduce some prints
to figure out what's going on.

Should I put the fix that I'm sending upstream for the nonexclusive
descriptors in front of the series, with some [DO NOT APPLY]
in the subject, so we just know that is required by will soon
be upstream?

Yours,
Linus Walleij



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux