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:   Tue, 8 Aug 2023 17:08:05 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Marcus Folkesson <marcus.folkesson@...il.com>
Cc:     Kent Gustavsson <kent@...oris.se>,
        Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Conor Dooley <conor+dt@...nel.org>,
        Cosmin Tanislav <demonsingur@...il.com>,
        Arnd Bergmann <arnd@...db.de>,
        ChiYuan Huang <cy_huang@...htek.com>,
        Haibo Chen <haibo.chen@....com>,
        Ramona Bolboaca <ramona.bolboaca@...log.com>,
        Ibrahim Tilki <Ibrahim.Tilki@...log.com>,
        ChiaEn Wu <chiaen_wu@...htek.com>,
        William Breathitt Gray <william.gray@...aro.org>,
        linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/4] iio: adc: mcp3911: simplify usage of spi->dev in
 probe function

On Tue, Aug 08, 2023 at 01:04:30PM +0200, Marcus Folkesson wrote:
> Replace the usage of adc->spi->dev with spi->dev to make the code prettier.

Suggested-by: ?

> Signed-off-by: Marcus Folkesson <marcus.folkesson@...il.com>

...

> -	adc->vref = devm_regulator_get_optional(&adc->spi->dev, "vref");
> +	adc->vref = devm_regulator_get_optional(&spi->dev, "vref");

Why not

	struct device *dev = &spi->dev;

and all the rest accordingly?

>  	if (IS_ERR(adc->vref)) {
>  		if (PTR_ERR(adc->vref) == -ENODEV) {
>  			adc->vref = NULL;
>  		} else {
> -			dev_err(&adc->spi->dev,
> +			dev_err(&spi->dev,
>  				"failed to get regulator (%ld)\n",
>  				PTR_ERR(adc->vref));
>  			return PTR_ERR(adc->vref);

Actually, you may first to switch to dev_err_probe() with the above introduced

	struct device *dev = &spi->dev;
	...
			return dev_err_probe(dev, PTR_ERR(adc->vref),
					     "failed to get regulator\n",

and in the second patch do what you are doing here.

Will be much less changes and neater code at the end.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ