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:	Wed, 3 Aug 2016 18:03:41 -0700
From:	Bjorn Andersson <bjorn.andersson@...aro.org>
To:	John Stultz <john.stultz@...aro.org>
Cc:	lkml <linux-kernel@...r.kernel.org>,
	Andy Yan <andy.yan@...k-chips.com>,
	Rob Herring <robh@...nel.org>, Arnd Bergmann <arnd@...db.de>,
	Thierry Reding <treding@...dia.com>,
	Heiko St?bner <heiko@...ech.de>,
	Caesar Wang <wxt@...k-chips.com>,
	Kees Cook <keescook@...omium.org>,
	Guodong Xu <guodong.xu@...aro.org>,
	Haojian Zhuang <haojian.zhuang@...aro.org>,
	Vishal Bhoj <vishal.bhoj@...aro.org>,
	devicetree@...r.kernel.org,
	Android Kernel Team <kernel-team@...roid.com>
Subject: Re: [RFC][PATCH 3/4] power: reset: Add sram-reboot-mode driver

On Wed 03 Aug 16:05 PDT 2016, John Stultz wrote:

[..]
> diff --git a/drivers/power/reset/sram-reboot-mode.c b/drivers/power/reset/sram-reboot-mode.c
[..]
> +
> +struct sram_reboot_mode {
> +	struct reboot_mode_driver reboot;
> +	void __iomem *reboot_reason_val_addr;

23 characters is...a lot of characters...

> +};
> +
> +static int sram_reboot_mode_write(struct reboot_mode_driver *reboot,
> +					unsigned int magic)
> +{
> +	struct sram_reboot_mode *sram_rbm;
> +
> +	sram_rbm = container_of(reboot, struct sram_reboot_mode, reboot);
> +
> +	writel(magic, sram_rbm->reboot_reason_val_addr);
> +	return 0;
> +}
> +
> +static int sram_reboot_mode_probe(struct platform_device *pdev)
> +{
> +	struct sram_reboot_mode *sram_rbm;
> +	struct resource *res;
> +	int ret;
> +
> +	sram_rbm = devm_kzalloc(&pdev->dev, sizeof(*sram_rbm), GFP_KERNEL);
> +	if (!sram_rbm)
> +		return -ENOMEM;
> +
> +	sram_rbm->reboot.dev = &pdev->dev;
> +	sram_rbm->reboot.write = sram_reboot_mode_write;
> +
> +	dev_set_drvdata(&pdev->dev, sram_rbm);
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res)
> +		return PTR_ERR(res);
> +
> +	sram_rbm->reboot_reason_val_addr = devm_ioremap(&pdev->dev, res->start,
> +							 resource_size(res));

Use devm_ioremap_resource() instead, it saves you the return value check
on platform_get_resource() and is cleaner.

> +	if (IS_ERR(sram_rbm->reboot_reason_val_addr))
> +		return PTR_ERR(sram_rbm->reboot_reason_val_addr);
> +
> +	ret = reboot_mode_register(&sram_rbm->reboot);

I think you should take the time to throw in a
devm_reboot_mode_register(), it would save you from the
dev_set_drvdata() and you can drop the remove function.

> +	if (ret)
> +		dev_err(&pdev->dev, "can't register reboot mode\n");
> +
> +	return ret;
> +}
> +

Regards,
Bjorn

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ