reset: brcmstb: Misc fixes
cover reset: brcmstb: Misc fixes
Hi Philipp,
These two patches fix some recent issues brought up by Paul and Randy, feel free to squash into c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver") since this is only in reset/next and linux-next so far.
Thank you!
Florian Fainelli (2):
reset: brcmstb: Make it tristate
reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t
drivers/reset/Kconfig | 3 ++- drivers/reset/reset-brcmstb.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 reset: brcmstb: Make it tristate
The driver can be built as a module just fine, so let's make it selectable as such.
--- drivers/reset/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/reset/Kconfig +2 -1
@@ -41,7 +41,8 @@ config RESET_BERLIN This enables the reset controller driver for Marvell Berlin SoCs. config RESET_BRCMSTB - bool "Broadcom STB reset controller" if COMPILE_TEST + tristate "Broadcom STB reset controller" + depends on ARCH_BRCMSTB || COMPILE_TEST default ARCH_BRCMSTB help This enables the reset controller driver for Broadcom STB SoCs using
Signature · 1 line
2.17.1
PATCH 2/2 reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t
In reply to Florian FainelliOn 32-bit architectures defining resource_size_t as 64-bit (because of PAE), we can run into a linker failure because of the modulo and the division against resource_size(), replace the two problematic operations with an alignment check on the register resource (instead of modulo), and the division with DIV_ROUND_CLOSEST_ULL().
--- drivers/reset/reset-brcmstb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/reset/reset-brcmstb.c +4 -2
@@ -91,7 +91,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (resource_size (res) %SW_INIT_BANK_SIZE ) { +if (!IS_ALIGNED (res->start,SW_INIT_BANK_SIZE ) || + !IS_AGLINED (resource_size (res),SW_INIT_BANK_SIZE )) {dev_err (kdev,"incorrect register range\n" );return -EINVAL ; }
@@ -103,7 +104,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)dev_set_drvdata (kdev, priv); priv->rcdev.owner =THIS_MODULE ; - priv->rcdev.nr_resets = (resource_size (res) /SW_INIT_BANK_SIZE ) *32 ; + priv->rcdev.nr_resets =DIV_ROUND_CLOSEST_ULL (resource_size (res), +SW_INIT_BANK_SIZE ) *32 ; priv->rcdev.ops = &brcmstb_reset_ops; priv->rcdev.of_node = kdev->of_node;/* Use defaults: 1 cell and simple xlate function */
Signature · 1 line
2.17.1
Re: [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t
Quoted 29 lines · Florian Fainelli
On 32-bit architectures defining
resource_size_tas 64-bit (because of PAE), we can run into a linker failure because of the modulo and the division againstresource_size(), replace the two problematic operations with an alignment check on the register resource (instead of modulo), and the division withDIV_ROUND_CLOSEST_ULL().Reported-by Randy Dunlap <[email protected]>Fixes c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")Signed-off-by Florian Fainelli <[email protected]>--- drivers/reset/reset-brcmstb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/reset/reset-brcmstb.c +2
-1@@ -91,7 +91,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (resource_size (res) %SW_INIT_BANK_SIZE ) { +if (!IS_ALIGNED (res->start,SW_INIT_BANK_SIZE ) || + !IS_AGLINED (resource_size (res),SW_INIT_BANK_SIZE )) {dev_err (kdev,"incorrect register range\n" );return -EINVAL ; }
drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 111
Quoted 9 lines
drivers/reset/reset-brcmstb.c +2
-1@@ -103,7 +104,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)dev_set_drvdata (kdev, priv); priv->rcdev.owner =THIS_MODULE ; - priv->rcdev.nr_resets = (resource_size (res) /SW_INIT_BANK_SIZE ) *32 ; + priv->rcdev.nr_resets =DIV_ROUND_CLOSEST_ULL (resource_size (res), +SW_INIT_BANK_SIZE ) *32 ; priv->rcdev.ops = &brcmstb_reset_ops; priv->rcdev.of_node = kdev->of_node;/* Use defaults: 1 cell and simple xlate function */
Hi Florian,
This gives me:
CC drivers/reset/reset-brcmstb.o../drivers/reset/reset-brcmstb.c: In function ‘brcmstb_reset_probe’:../drivers/reset/reset-brcmstb.c:95:6: error: implicit declaration of function ‘IS_AGLINED’ [-Werror=implicit-function-declaration]
!IS_AGLINED(resource_size(res), SW_INIT_BANK_SIZE)) {
^but if the typo is fixed, it is fine :) then you can added:
Thanks.
Signature · 1 line
~Randy
Philipp Zabel
maintainerRe: [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t
In reply to Florian FainelliHi Florian,
Quoted 18 lines · Florian Fainelli
On 32-bit architectures defining
resource_size_tas 64-bit (because of PAE), we can run into a linker failure because of the modulo and the division againstresource_size(), replace the two problematic operations with an alignment check on the register resource (instead of modulo), and the division withDIV_ROUND_CLOSEST_ULL().Reported-by Randy Dunlap <[email protected]>Fixes c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")Signed-off-by Florian Fainelli <[email protected]>--- drivers/reset/reset-brcmstb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/reset/reset-brcmstb.c +0
-0
drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 95
Quoted 6 lines
drivers/reset/reset-brcmstb.c +2
-1@@ -91,7 +91,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (resource_size (res) %SW_INIT_BANK_SIZE ) { +if (!IS_ALIGNED (res->start,SW_INIT_BANK_SIZE ) || + !IS_AGLINED (resource_size (res),SW_INIT_BANK_SIZE )) {
Typo.
drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 108
Quoted 10 lines
drivers/reset/reset-brcmstb.c +2
-1dev_err (kdev,"incorrect register range\n" );return -EINVAL ; }@@ -103,7 +104,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)dev_set_drvdata (kdev, priv); priv->rcdev.owner =THIS_MODULE ; - priv->rcdev.nr_resets = (resource_size (res) /SW_INIT_BANK_SIZE ) *32 ; + priv->rcdev.nr_resets =DIV_ROUND_CLOSEST_ULL (resource_size (res), +SW_INIT_BANK_SIZE ) *32 ;
This should be DIV_ROUND_DOWN_ULL.
regards
Philipp
RE: [PATCH reset-next 2/2] reset: brcmstb: Fix 32-bit build with 64-bit resource_size_t
In reply to Florian FainelliFrom: Florian Fainelli
Quoted 30 lines
Sent: 23 January 2019 00:34
On 32-bit architectures defining
resource_size_tas 64-bit (because of PAE), we can run into a linker failure because of the modulo and the division againstresource_size(), replace the two problematic operations with an alignment check on the register resource (instead of modulo), and the division withDIV_ROUND_CLOSEST_ULL().Reported-by Randy Dunlap <[email protected]>Fixes c196cdc7659d ("reset: Add Broadcom STB SW_INIT reset controller driver")Signed-off-by Florian Fainelli <[email protected]>--- drivers/reset/reset-brcmstb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/reset/reset-brcmstb.c +2
-1@@ -91,7 +91,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (resource_size (res) %SW_INIT_BANK_SIZE ) { +if (!IS_ALIGNED (res->start,SW_INIT_BANK_SIZE ) || + !IS_AGLINED (resource_size (res),SW_INIT_BANK_SIZE )) {dev_err (kdev,"incorrect register range\n" );return -EINVAL ; }
drivers/reset/reset-brcmstb.c static int brcmstb_reset_probe(struct platform_device *pdev) · line 111
Quoted 9 lines
drivers/reset/reset-brcmstb.c +2
-1@@ -103,7 +104,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)dev_set_drvdata (kdev, priv); priv->rcdev.owner =THIS_MODULE ; - priv->rcdev.nr_resets = (resource_size (res) /SW_INIT_BANK_SIZE ) *32 ; + priv->rcdev.nr_resets =DIV_ROUND_CLOSEST_ULL (resource_size (res), +SW_INIT_BANK_SIZE ) *32 ; priv->rcdev.ops = &brcmstb_reset_ops; priv->rcdev.of_node = kdev->of_node;/* Use defaults: 1 cell and simple xlate function */
Isn't it enough to assign resource_size(res) to an 'unsigned int' ? The value is never actually going to be over 4G.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Philipp Zabel
maintainerQuoted 6 lines · Florian Fainelli
Hi Philipp,
These two patches fix some recent issues brought up by Paul and Randy, feel free to squash into
c196cdc7659d("reset: Add Broadcom STBSW_INITreset controller driver") since this is only in reset/next and linux-next so far.
If you want this squashed, feel free to submit an updated version of the original patches and I'll replace them. That way I don't have to decide how to stitch (or drop) the commit messages.
thanks
Philipp
Quoted 11 lines · Philipp Zabel
Quoted 6 lines · Florian Fainelli
Hi Philipp,
These two patches fix some recent issues brought up by Paul and Randy, feel free to squash into
c196cdc7659d("reset: Add Broadcom STBSW_INITreset controller driver") since this is only in reset/next and linux-next so far.If you want this squashed, feel free to submit an updated version of the original patches and I'll replace them. That way I don't have to decide how to stitch (or drop) the commit messages.
Thanks, I sent you a replacement version for the second patch only, hope that is alright.
Signature · 1 line
Florian