Re: [PATCH v2 4/4] usb: usb3503: Convert to use GPIO descriptors

From: Marek Szyprowski
Date: Thu Dec 12 2019 - 03:23:15 EST


Hi Chunfeng,

On 12.12.2019 03:10, Chunfeng Yun wrote:
> On Wed, 2019-12-11 at 15:52 +0100, Marek Szyprowski wrote:
>> From: Linus Walleij <linus.walleij@xxxxxxxxxx>
>>
>> This converts the USB3503 to pick GPIO descriptors from the
>> device tree instead of iteratively picking out GPIO number
>> references and then referencing these from the global GPIO
>> numberspace.
>>
>> The USB3503 is only used from device tree among the in-tree
>> platforms. If board files would still desire to use it they can
>> provide machine descriptor tables.
>>
>> Make sure to preserve semantics such as the reset delay
>> introduced by Stefan.
>>
>> Cc: Chunfeng Yun <chunfeng.yun@xxxxxxxxxxxx>
>> Cc: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
>> Cc: Stefan Agner <stefan@xxxxxxxx>
>> Cc: Krzysztof Kozlowski <krzk@xxxxxxxxxx>
>> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
>> [mszyprow: invert the logic behind reset GPIO line]
>> Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
>> ---
>> drivers/usb/misc/usb3503.c | 94 ++++++++++-----------------
>> include/linux/platform_data/usb3503.h | 3 -
>> 2 files changed, 35 insertions(+), 62 deletions(-)
>>
>> diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
>> index 72f39a9751b5..116bd789e568 100644
>> --- a/drivers/usb/misc/usb3503.c
>> +++ b/drivers/usb/misc/usb3503.c
>> @@ -7,11 +7,10 @@
>>
>> #include <linux/clk.h>
>> #include <linux/i2c.h>
>> -#include <linux/gpio.h>
>> +#include <linux/gpio/consumer.h>
>> #include <linux/delay.h>
>> #include <linux/slab.h>
>> #include <linux/module.h>
>> -#include <linux/of_gpio.h>
>> #include <linux/platform_device.h>
>> #include <linux/platform_data/usb3503.h>
>> #include <linux/regmap.h>
>> @@ -47,19 +46,19 @@ struct usb3503 {
>> struct device *dev;
>> struct clk *clk;
>> u8 port_off_mask;
>> - int gpio_intn;
>> - int gpio_reset;
>> - int gpio_connect;
>> + struct gpio_desc *intn;
>> + struct gpio_desc *reset;
>> + struct gpio_desc *connect;
>> bool secondary_ref_clk;
>> };
>>
>> static int usb3503_reset(struct usb3503 *hub, int state)
>> {
>> - if (!state && gpio_is_valid(hub->gpio_connect))
>> - gpio_set_value_cansleep(hub->gpio_connect, 0);
>> + if (!state && hub->connect)
>> + gpiod_set_value_cansleep(hub->connect, 0);
>>
>> - if (gpio_is_valid(hub->gpio_reset))
>> - gpio_set_value_cansleep(hub->gpio_reset, state);
>> + if (hub->reset)
>> + gpiod_set_value_cansleep(hub->reset, !state);
> What about preparing another patch for @state before this path?

In such case the driver will be broken after such patch until a
conversion to descriptor based GPIO api is done.

...

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland