Re: [PATCH] staging: typec: rt1711h typec chip driver

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

 



Hi ShuFan,

On Fri, Mar 16, 2018 at 05:12:49PM +0800, ShuFan Lee wrote:
> +static int rt1711h_init_gpio(struct rt1711h_chip *chip)
> +{
> +	int ret;
> +	struct device_node *np = chip->dev->of_node;
> +
> +	ret = of_get_named_gpio(np, "rt,intr_gpio", 0);
> +	if (ret < 0) {
> +		dev_err(chip->dev, "%s get int gpio fail(%d)\n", __func__, ret);
> +		return ret;
> +	}
> +	chip->irq_gpio = ret;
> +
> +	ret = devm_gpio_request_one(chip->dev, chip->irq_gpio, GPIOF_IN,
> +				    dev_name(chip->dev));
> +	if (ret < 0) {
> +		dev_err(chip->dev, "%s request gpio fail(%d)\n", __func__, ret);
> +		return ret;
> +	}
> +
> +	chip->irq = gpio_to_irq(chip->irq_gpio);
> +	if (chip->irq <= 0) {
> +		dev_err(chip->dev, "%s gpio2irq fail(%d)\n", __func__,
> +			chip->irq);
> +		return -EINVAL;
> +	}
> +	return 0;

"rt,intr_gpio" should probable be "rt,intr-gpio". Then this function
can be prepared for all types of platforms:

static int rt1711h_init_gpio(struct rt1711h_chip *chip)
{
        struct gpio_desc *gpio;

        gpio = devm_gpiod_get(chip->dev, "rt,intr", GFP_KERNEL);
        if (IS_ERR(gpio))
                return PTR_ERR(gpio);

        chip->irq = gpiod_to_irq(gpio);
	if (chip->irq < 0)
		return chip->irq;

	return 0;
}


Thanks,

-- 
heikki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux