linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Varka Bhadram <varkabhadram@gmail.com>
To: Jun Nie <jun.nie@linaro.org>,
	haojian.zhuang@linaro.org, linus.walleij@linaro.org,
	linux-gpio@vger.kernel.org
Cc: tony@atomide.com, shawn.guo@linaro.org, wan.zhijun@zte.com.cn,
	jason.liu@linaro.org
Subject: Re: [PATCH v2] gpio: zx: Add ZTE zx296702 GPIO support
Date: Wed, 24 Jun 2015 16:26:39 +0530	[thread overview]
Message-ID: <558A8CE7.7020709@gmail.com> (raw)
In-Reply-To: <1435138299-20561-1-git-send-email-jun.nie@linaro.org>

Hi Jun Nie,

On 06/24/2015 03:01 PM, Jun Nie wrote:

> Add ZTE zx296702 GPIO controller support
>
> Signed-off-by: Jun Nie <jun.nie@linaro.org>
> ---

(...)

> +static int zx_gpio_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct zx_gpio *chip;
> +	struct resource *res;
> +	int irq, id, ret;
> +
> +	chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
> +	if (chip == NULL)
> +		return -ENOMEM;

We can simply check some thing like this:
	if (!chip)
		return -ENOMEM;

> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	chip->base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(chip->base))
> +		return PTR_ERR(chip->base);
> +
> +	spin_lock_init(&chip->lock);
> +	if (of_property_read_bool(dev->of_node, "gpio-ranges"))
> +		chip->uses_pinctrl = true;
> +
> +	id = of_alias_get_id(dev->of_node, "gpio");
> +	chip->gc.request = zx_gpio_request;
> +	chip->gc.free = zx_gpio_free;
> +	chip->gc.direction_input = zx_direction_input;
> +	chip->gc.direction_output = zx_direction_output;
> +	chip->gc.get = zx_get_value;
> +	chip->gc.set = zx_set_value;
> +	chip->gc.base = ZX_GPIO_NR * id;
> +	chip->gc.ngpio = ZX_GPIO_NR;
> +	chip->gc.label = dev_name(dev);
> +	chip->gc.dev = dev;
> +	chip->gc.owner = THIS_MODULE;
> +
> +	ret = gpiochip_add(&chip->gc);
> +	if (ret)
> +		return ret;
> +
> +	/*
> +	 * irq_chip support
> +	 */
> +	writew_relaxed(0xffff, chip->base + ZX_GPIO_IM);
> +	writew_relaxed(0, chip->base + ZX_GPIO_IE);
> +	irq = platform_get_irq(pdev, 0);
> +	if (irq < 0) {
> +		dev_err(dev, "invalid IRQ\n");

You added the gpiochio, but not removing on error here.

> +		return -ENODEV;
> +	}
> +
> +	ret = gpiochip_irqchip_add(&chip->gc, &zx_irqchip,
> +				   0, handle_simple_irq,
> +				   IRQ_TYPE_NONE);
> +	if (ret) {
> +		dev_info(dev, "could not add irqchip\n");

I think it should be dev_err().

Here also gpiochip_remove() ?

> +		return ret;
> +	}
> +	gpiochip_set_chained_irqchip(&chip->gc, &zx_irqchip,
> +				     irq, zx_irq_handler);
> +
> +	platform_set_drvdata(pdev, chip);
> +	dev_info(dev, "ZX GPIO chip registered\n");
> +
> +	return 0;
> +}
> +
> +#if defined(CONFIG_OF)
> +static const struct of_device_id zx_gpio_match[] = {
> +	{
> +		.compatible = "zte,zx296702-gpio",
> +	},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, zx_gpio_match);
> +#endif
> +

This driver may be populated through OF.

Do you think this #if..#endif is required ?


-- 
Best regards,
Varka Bhadram.


  reply	other threads:[~2015-06-24 10:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-24  9:31 [PATCH v2] gpio: zx: Add ZTE zx296702 GPIO support Jun Nie
2015-06-24 10:56 ` Varka Bhadram [this message]
2015-06-24 13:09 ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=558A8CE7.7020709@gmail.com \
    --to=varkabhadram@gmail.com \
    --cc=haojian.zhuang@linaro.org \
    --cc=jason.liu@linaro.org \
    --cc=jun.nie@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=shawn.guo@linaro.org \
    --cc=tony@atomide.com \
    --cc=wan.zhijun@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).