diff mbox

[1/3] PCI: rockchip: fix sign issues for current limits

Message ID 20170308233748.54706-1-briannorris@chromium.org (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Brian Norris March 8, 2017, 11:37 p.m. UTC
The regulator framework can return negative error codes via
regulator_get_current_limit() for regulators that don't provide current
information. The subsequent check for postive values isn't very useful,
if the variable is unsigned.

Let's just match the signedness of the return value.

Prevents error messages like this, seen on Samsung Chromebook Plus:

[    1.069372] rockchip-pcie f8000000.pcie: invalid power supply

Fixes: 4816c4c7b82b ("PCI: rockchip: Provide captured slot power limit and scale")
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
v4.11 candidate?

 drivers/pci/host/pcie-rockchip.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Shawn Lin March 9, 2017, 8:59 a.m. UTC | #1
On 2017/3/9 7:37, Brian Norris wrote:
> The regulator framework can return negative error codes via
> regulator_get_current_limit() for regulators that don't provide current
> information. The subsequent check for postive values isn't very useful,
> if the variable is unsigned.
>
> Let's just match the signedness of the return value.
>
> Prevents error messages like this, seen on Samsung Chromebook Plus:
>
> [    1.069372] rockchip-pcie f8000000.pcie: invalid power supply
>

For this patch,

Acked-by: Shawn Lin <shawn.lin@rock-chips.com>

And I think patch 2 is not so urgent so we could just wait for your
non-WIP patch 3?

> Fixes: 4816c4c7b82b ("PCI: rockchip: Provide captured slot power limit and scale")
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
> v4.11 candidate?
>
>  drivers/pci/host/pcie-rockchip.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
> index 26ddd3535272..d785f64ec03b 100644
> --- a/drivers/pci/host/pcie-rockchip.c
> +++ b/drivers/pci/host/pcie-rockchip.c
> @@ -425,7 +425,8 @@ static struct pci_ops rockchip_pcie_ops = {
>
>  static void rockchip_pcie_set_power_limit(struct rockchip_pcie *rockchip)
>  {
> -	u32 status, curr, scale, power;
> +	int curr;
> +	u32 status, scale, power;
>
>  	if (IS_ERR(rockchip->vpcie3v3))
>  		return;
>
Brian Norris March 10, 2017, 2:27 a.m. UTC | #2
On Thu, Mar 09, 2017 at 04:59:15PM +0800, Shawn Lin wrote:
> On 2017/3/9 7:37, Brian Norris wrote:
> >The regulator framework can return negative error codes via
> >regulator_get_current_limit() for regulators that don't provide current
> >information. The subsequent check for postive values isn't very useful,
> >if the variable is unsigned.
> >
> >Let's just match the signedness of the return value.
> >
> >Prevents error messages like this, seen on Samsung Chromebook Plus:
> >
> >[    1.069372] rockchip-pcie f8000000.pcie: invalid power supply
> >
> 
> For this patch,
> 
> Acked-by: Shawn Lin <shawn.lin@rock-chips.com>

Thanks.

> And I think patch 2 is not so urgent so we could just wait for your
> non-WIP patch 3?

Sure. I'll be resending the series with a proper patch 3 (and 4 and 5
actually) soon anyway. No changes to the first 2.

Brian
diff mbox

Patch

diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
index 26ddd3535272..d785f64ec03b 100644
--- a/drivers/pci/host/pcie-rockchip.c
+++ b/drivers/pci/host/pcie-rockchip.c
@@ -425,7 +425,8 @@  static struct pci_ops rockchip_pcie_ops = {
 
 static void rockchip_pcie_set_power_limit(struct rockchip_pcie *rockchip)
 {
-	u32 status, curr, scale, power;
+	int curr;
+	u32 status, scale, power;
 
 	if (IS_ERR(rockchip->vpcie3v3))
 		return;