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] [day] [month] [year] [list]
Message-Id: <20130603155627.3f63cfd0ae1cec3c0e0a1444@linux-foundation.org>
Date:	Mon, 3 Jun 2013 15:56:27 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Jan Luebbe <jlu@...gutronix.de>
Cc:	Arnd Bergmann <arnd@...db.de>,
	Grant Likely <grant.likely@...aro.org>,
	Rob Herring <rob.herring@...xeda.com>,
	Rodolfo Giometti <giometti@...eenne.com>,
	devicetree-discuss@...ts.ozlabs.org, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] pps-gpio: add device-tree binding and support

On Sat,  1 Jun 2013 12:44:09 +0200 Jan Luebbe <jlu@...gutronix.de> wrote:

> Instead of allocating a struct pps_gpio_platform_data in the DT case, store
> the necessary information in struct pps_gpio_device_data itself. This avoids
> an additional allocation and the ifdef. It also gets rid of some indirection.
> 
> Also use dev_err instead of pr_err in the changed code.
> 
> ...
>
>  static int pps_gpio_probe(struct platform_device *pdev)
>  {
>  	struct pps_gpio_device_data *data;
> -	int irq;
> +	const char *gpio_label;
>  	int ret;
>  	int pps_default_params;
>  	const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
> +	struct device_node *np = pdev->dev.of_node;
>  
> +	/* allocate space for device info */
> +	data = devm_kzalloc(&pdev->dev, sizeof(struct pps_gpio_device_data),
> +			GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	if (pdata) {
> +		data->gpio_pin = pdata->gpio_pin;
> +		gpio_label = pdata->gpio_label;
> +
> +		data->assert_falling_edge = pdata->assert_falling_edge;
> +		data->capture_clear = pdata->capture_clear;
> +	} else {
> +		ret = of_get_gpio(np, 0);
> +		if (ret < 0) {
> +			dev_err(&pdev->dev, "failed to get GPIO from device tree\n");
> +			return ret;
> +		}
> +		data->gpio_pin = ret;
> +		gpio_label = PPS_GPIO_NAME;
> +
> +		if (of_get_property(np, "assert-falling-edge", NULL))
> +			data->assert_falling_edge = true;
> +	}
>  
>  	/* GPIO setup */
> -	ret = pps_gpio_setup(pdev);
> -	if (ret)
> -		return -EINVAL;
> +	ret = devm_gpio_request(&pdev->dev, data->gpio_pin, gpio_label);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to request GPIO %u\n",
> +			data->gpio_pin);
> +		return ret;
> +	}
>  
> -	/* IRQ setup */
> -	irq = gpio_to_irq(pdata->gpio_pin);
> -	if (irq < 0) {
> -		pr_err("failed to map GPIO to IRQ: %d\n", irq);
> +	ret = gpio_direction_input(data->gpio_pin);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to set pin direction\n");
>  		return -EINVAL;

Should we propagate the gpio_direction_input() return value?

>  	}
>  

--
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