public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Rabin Vincent <rabin.vincent@stericsson.com>,
	Marc Zyngier <maz@misterjones.org>,
	Linus Walleij <linus.walleij@stericsson.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	linux-kernel@vger.kernel.org, qi.wang@intel.com,
	yong.y.wang@intel.com, joel.clark@intel.com,
	kok.howg.ewe@intel.com
Subject: Re: [PATCH] gpio/ml_ioh_gpio: ML7213 GPIO driver
Date: Mon, 3 Jan 2011 13:40:04 -0800	[thread overview]
Message-ID: <20110103134004.04814deb.akpm@linux-foundation.org> (raw)
In-Reply-To: <1293105524-3250-1-git-send-email-tomoya-linux@dsn.okisemi.com>

On Thu, 23 Dec 2010 20:58:44 +0900
Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com> wrote:

> ML7213 is companion chip for Intel Atom E6xx series.
> This driver can be used for OKI SEMICONDUCTOR ML7213 IOH(Input/Output Hub) which
> is for IVI(In-Vehicle Infotainment) use.
> This driver can access the IOH's GPIO device.
> 
>
> ...
>
> +static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
> +				    const struct pci_device_id *id)
> +{
> +	int ret;
> +	int i;
> +	struct ioh_gpio *chip;
> +	void __iomem *base;
> +	void __iomem *chip_save;
> +
> +	ret = pci_enable_device(pdev);
> +	if (ret) {
> +		dev_err(&pdev->dev, "%s : pci_enable_device failed", __func__);
> +		goto err_pci_enable;
> +	}
> +
> +	ret = pci_request_regions(pdev, KBUILD_MODNAME);
> +	if (ret) {
> +		dev_err(&pdev->dev, "pci_request_regions failed-%d", ret);
> +		goto err_request_regions;
> +	}
> +
> +	base = pci_iomap(pdev, 1, 0);
> +	if (base == 0) {
> +		dev_err(&pdev->dev, "%s : pci_iomap failed", __func__);
> +		ret = -ENOMEM;
> +		goto err_iomap;
> +	}
> +
> +	chip_save = kzalloc(sizeof(*chip) * 8, GFP_KERNEL);
> +	if (chip_save == NULL) {
> +		dev_err(&pdev->dev, "%s : kzalloc failed", __func__);
> +		ret = -ENOMEM;
> +		goto err_kzalloc;
> +	}
> +
> +	for (i = 0, chip = chip_save; i < 8; i++, chip++) {

	chip = chip_save;
	for (i = 0; i < 8; i++, chip++) {

is simpler, and simpler is better.

> +		chip->dev = &pdev->dev;
> +		chip->base = base;
> +		chip->reg = chip->base;
> +		chip->ch = i;
> +		mutex_init(&chip->lock);
> +		ioh_gpio_setup(chip, num_ports[i]);
> +		ret = gpiochip_add(&chip->gpio);
> +		if (ret) {
> +			dev_err(&pdev->dev, "IOH gpio: Failed to register GPIO\n");
> +			goto err_gpiochip_add;

Here we should run gpiochip_remove() against chips 0 .. i-1, no?

> +		}
> +	}
> +
> +	chip = chip_save;
> +	pci_set_drvdata(pdev, chip);
> +
> +	return 0;
> +
> +err_gpiochip_add:
> +	kfree(chip_save);
> +
> +err_kzalloc:
> +	pci_iounmap(pdev, base);
> +
> +err_iomap:
> +	pci_release_regions(pdev);
> +
> +err_request_regions:
> +	pci_disable_device(pdev);
> +
> +err_pci_enable:
> +
> +	dev_err(&pdev->dev, "%s Failed returns %d\n", __func__, ret);
> +	return ret;
> +}


  reply	other threads:[~2011-01-03 21:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-23 11:58 [PATCH] gpio/ml_ioh_gpio: ML7213 GPIO driver Tomoya MORINAGA
2011-01-03 21:40 ` Andrew Morton [this message]
2011-01-05  5:24   ` Tomoya MORINAGA

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=20110103134004.04814deb.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=joel.clark@intel.com \
    --cc=kok.howg.ewe@intel.com \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@misterjones.org \
    --cc=qi.wang@intel.com \
    --cc=rabin.vincent@stericsson.com \
    --cc=sameo@linux.intel.com \
    --cc=tomoya-linux@dsn.okisemi.com \
    --cc=yong.y.wang@intel.com \
    /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