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:   Thu, 27 Sep 2018 13:39:03 +0200
From:   Boris Brezillon <boris.brezillon@...tlin.com>
To:     Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
Cc:     David Woodhouse <dwmw2@...radead.org>,
        Brian Norris <computersforpeace@...il.com>,
        Marek Vasut <marek.vasut@...il.com>,
        Richard Weinberger <richard@....at>,
        Zhouyang Jia <jiazhouyang09@...il.com>,
        linux-mtd@...ts.infradead.org,
        linux-kernel@...r.kernel.org (open list)
Subject: Re: [PATCH v2 7/8] mtd: maps: gpio-addr-flash: Add support for
 device-tree devices

On Wed,  5 Sep 2018 16:36:42 +0200
Ricardo Ribalda Delgado <ricardo.ribalda@...il.com> wrote:

> +static int gpio_flash_probe_gpios(struct platform_device *pdev,
> +				  struct async_state *state)
> +{
> +	struct physmap_flash_data *pdata;
> +	struct device_node *dn;
> +	struct resource *gpios = NULL;
> +	int i;
> +
> +	dn = pdev->dev.of_node;
> +	if (dn) {
> +		state->gpio_count = of_gpio_count(dn);
> +	} else {
> +		pdata = dev_get_platdata(&pdev->dev);
> +		if (!pdata)
> +			return -EINVAL;
> +		gpios = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +		if (IS_ERR(gpios) || !gpios->end)
> +			return -EINVAL;
> +		state->gpio_count = gpios->end;
> +	}
> +
> +	state->gpio_addrs = devm_kzalloc(&pdev->dev,
> +					 sizeof(state->gpio_addrs[0])
> +						* state->gpio_count,
> +					 GFP_KERNEL);
> +	if (!state->gpio_addrs)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < state->gpio_count; i++) {
> +		long gpio;
> +		int ret;
> +
> +		if (dn)
> +			gpio = of_get_gpio(dn, i);
> +		else
> +			gpio = ((unsigned long *)gpios->start)[i];
> +

Hm, we should probably switch to GPIO descs (instead of GPIO numbers)
before adding DT support. This should make the code much more simpler
and remove one more user of the old/deprecated GPIO API.

> +		if (gpio < 0)
> +			return gpio;
> +
> +		ret =  devm_gpio_request(&pdev->dev, gpio, DRIVER_NAME);
> +		if (ret < 0) {
> +			dev_err(&pdev->dev, "failed to request gpio %ld\n",
> +				gpio);
> +			return ret;
> +		}
> +		state->gpio_addrs[i] = gpio;
> +		gpio_direction_output(state->gpio_addrs[i], 0);
> +	}
> +
> +	return 0;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ