lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 3 Jan 2011 13:40:04 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Tomoya MORINAGA <tomoya-linux@....okisemi.com>
Cc:	Samuel Ortiz <sameo@...ux.intel.com>,
	Rabin Vincent <rabin.vincent@...ricsson.com>,
	Marc Zyngier <maz@...terjones.org>,
	Linus Walleij <linus.walleij@...ricsson.com>,
	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	linux-kernel@...r.kernel.org, qi.wang@...el.com,
	yong.y.wang@...el.com, joel.clark@...el.com, kok.howg.ewe@...el.com
Subject: Re: [PATCH] gpio/ml_ioh_gpio: ML7213 GPIO driver

On Thu, 23 Dec 2010 20:58:44 +0900
Tomoya MORINAGA <tomoya-linux@....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;
> +}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ