diff mbox

[v5,06/11] i2c: core: Convert to dev_pm_domain_attach|detach()

Message ID 1411151264-16245-7-git-send-email-ulf.hansson@linaro.org
State Awaiting Upstream
Headers show

Commit Message

Ulf Hansson Sept. 19, 2014, 6:27 p.m. UTC
Previously only the ACPI PM domain was supported by the i2c bus.

Let's convert to the common attach/detach functions for PM domains,
which currently means we are extending the support to include the
generic PM domain as well.

Cc: linux-i2c@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@linaro.org>
---
 drivers/i2c/i2c-core.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Wolfram Sang Sept. 20, 2014, 12:23 p.m. UTC | #1
On Fri, Sep 19, 2014 at 08:27:39PM +0200, Ulf Hansson wrote:
> Previously only the ACPI PM domain was supported by the i2c bus.
> 
> Let's convert to the common attach/detach functions for PM domains,
> which currently means we are extending the support to include the
> generic PM domain as well.
> 
> Cc: linux-i2c@vger.kernel.org
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>

Looks good to me, but I'd like to give Mika a chance to look at it,
since he does ACPI with I2C. Adding to CC.

> ---
>  drivers/i2c/i2c-core.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 632057a..3cd8f11 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -279,10 +279,13 @@ static int i2c_device_probe(struct device *dev)
>  	if (status < 0)
>  		return status;
>  
> -	acpi_dev_pm_attach(&client->dev, true);
> -	status = driver->probe(client, i2c_match_id(driver->id_table, client));
> -	if (status)
> -		acpi_dev_pm_detach(&client->dev, true);
> +	status = dev_pm_domain_attach(&client->dev, true);
> +	if (status != -EPROBE_DEFER) {
> +		status = driver->probe(client, i2c_match_id(driver->id_table,
> +					client));

Very minor: I think it is more readable to keep this in one line.

> +		if (status)
> +			dev_pm_domain_detach(&client->dev, true);
> +	}
>  
>  	return status;
>  }
> @@ -302,7 +305,7 @@ static int i2c_device_remove(struct device *dev)
>  		status = driver->remove(client);
>  	}
>  
> -	acpi_dev_pm_detach(&client->dev, true);
> +	dev_pm_domain_detach(&client->dev, true);
>  	return status;
>  }
>  
> -- 
> 1.9.1
>
Rafael J. Wysocki Sept. 20, 2014, 11:48 p.m. UTC | #2
On Saturday, September 20, 2014 02:23:19 PM Wolfram Sang wrote:
> 
> --bAmEntskrkuBymla
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
> 
> On Fri, Sep 19, 2014 at 08:27:39PM +0200, Ulf Hansson wrote:
> > Previously only the ACPI PM domain was supported by the i2c bus.
> >=20
> > Let's convert to the common attach/detach functions for PM domains,
> > which currently means we are extending the support to include the
> > generic PM domain as well.
> >=20
> > Cc: linux-i2c@vger.kernel.org
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > Reviewed-by: Kevin Hilman <khilman@linaro.org>
> 
> Looks good to me, but I'd like to give Mika a chance to look at it,
> since he does ACPI with I2C. Adding to CC.

It is not applicable without the [4/9] in this series anyway.

> > ---
> >  drivers/i2c/i2c-core.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >=20
> > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> > index 632057a..3cd8f11 100644
> > --- a/drivers/i2c/i2c-core.c
> > +++ b/drivers/i2c/i2c-core.c
> > @@ -279,10 +279,13 @@ static int i2c_device_probe(struct device *dev)
> >  	if (status < 0)
> >  		return status;
> > =20
> > -	acpi_dev_pm_attach(&client->dev, true);
> > -	status =3D driver->probe(client, i2c_match_id(driver->id_table, client)=
> );
> > -	if (status)
> > -		acpi_dev_pm_detach(&client->dev, true);
> > +	status =3D dev_pm_domain_attach(&client->dev, true);
> > +	if (status !=3D -EPROBE_DEFER) {
> > +		status =3D driver->probe(client, i2c_match_id(driver->id_table,
> > +					client));
> 
> Very minor: I think it is more readable to keep this in one line.

Agreed.

> > +		if (status)
> > +			dev_pm_domain_detach(&client->dev, true);
> > +	}
> > =20
> >  	return status;
> >  }
> > @@ -302,7 +305,7 @@ static int i2c_device_remove(struct device *dev)
> >  		status =3D driver->remove(client);
> >  	}
> > =20
> > -	acpi_dev_pm_detach(&client->dev, true);
> > +	dev_pm_domain_detach(&client->dev, true);
> >  	return status;
> >  }
> > =20
> > --=20
> > 1.9.1
> >=20
> 
> --bAmEntskrkuBymla
> Content-Type: application/pgp-signature; name="signature.asc"
> Content-Description: Digital signature
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> 
> iQIcBAEBAgAGBQJUHXG2AAoJEBQN5MwUoCm2E7EP/1ykOCTRgrozlYwdbXxO9X8Z
> b6ad23VambrSiQJTZcYheydiVW9qrXIsn8TQf1flWChXtkD06odQRy8tGN8Vw3MQ
> MTdhyB19x1Z0TMkdmcrbhohsRchjsaeMgcpCNklW8ul8nASuDjY9KUdhVfUaY07q
> O1zyZxrA5ykPCq/xP2gakHTTOrB6pj0zwOlDe4yQOd1hJcWrhX0/EBxY4DgvvQIr
> o05w2rdr+s6qCCgV3WSY9EJ0JBOqNhvvGpGnpZe6tms8e1RmrEnSil3piBC1nhHP
> LPeZr/ZHdoRbEgUPNnr/otLhufVeE5uMLu7FFhmZi3DTVXXVb+kMjE17C6XYc3mM
> DIumY2ubMBInCIZDjFZa0BvwuodKqkWrG5cmgimDw8VywhDfmCXm7Q1immbKZ0rw
> p9R4YHkBl5ii0KCyTSrf5M4+ksV80iplb4jmIwfmU0kKnOIan1fgkmyHXR/WN67M
> d6sZUpMsuCUNTRj7Axe6LdKuuQe/EbO9GC66umjxtckJIesM/BSHHgGAGqnxQolQ
> q/NnP2JBTVz6sSjoBRb+EMw5cri2Yb2M1Ak24nw+uoveiqBGGMuFFQGoHyV9UXVP
> zA0MaUKKESiwO1RIaqhYe5lRwIwFSUktD5s/yYQqKbSF0zGAeRn79O+U2ei7xI9a
> gv2ABkxPmYxBPoSf9y1B
> =izqF
> -----END PGP SIGNATURE-----
> 
> --bAmEntskrkuBymla--
>
Mika Westerberg Sept. 22, 2014, 9:52 a.m. UTC | #3
On Sat, Sep 20, 2014 at 02:23:19PM +0200, Wolfram Sang wrote:
> On Fri, Sep 19, 2014 at 08:27:39PM +0200, Ulf Hansson wrote:
> > Previously only the ACPI PM domain was supported by the i2c bus.
> > 
> > Let's convert to the common attach/detach functions for PM domains,
> > which currently means we are extending the support to include the
> > generic PM domain as well.
> > 
> > Cc: linux-i2c@vger.kernel.org
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > Reviewed-by: Kevin Hilman <khilman@linaro.org>
> 
> Looks good to me, but I'd like to give Mika a chance to look at it,
> since he does ACPI with I2C. Adding to CC.

Looks fine to me.
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang Sept. 22, 2014, 10 a.m. UTC | #4
On Mon, Sep 22, 2014 at 12:52:53PM +0300, Mika Westerberg wrote:
> On Sat, Sep 20, 2014 at 02:23:19PM +0200, Wolfram Sang wrote:
> > On Fri, Sep 19, 2014 at 08:27:39PM +0200, Ulf Hansson wrote:
> > > Previously only the ACPI PM domain was supported by the i2c bus.
> > > 
> > > Let's convert to the common attach/detach functions for PM domains,
> > > which currently means we are extending the support to include the
> > > generic PM domain as well.
> > > 
> > > Cc: linux-i2c@vger.kernel.org
> > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > > Reviewed-by: Kevin Hilman <khilman@linaro.org>
> > 
> > Looks good to me, but I'd like to give Mika a chance to look at it,
> > since he does ACPI with I2C. Adding to CC.
> 
> Looks fine to me.

Thanks! So:

Acked-by: Wolfram Sang <wsa@the-dreams.de>
diff mbox

Patch

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 632057a..3cd8f11 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -279,10 +279,13 @@  static int i2c_device_probe(struct device *dev)
 	if (status < 0)
 		return status;
 
-	acpi_dev_pm_attach(&client->dev, true);
-	status = driver->probe(client, i2c_match_id(driver->id_table, client));
-	if (status)
-		acpi_dev_pm_detach(&client->dev, true);
+	status = dev_pm_domain_attach(&client->dev, true);
+	if (status != -EPROBE_DEFER) {
+		status = driver->probe(client, i2c_match_id(driver->id_table,
+					client));
+		if (status)
+			dev_pm_domain_detach(&client->dev, true);
+	}
 
 	return status;
 }
@@ -302,7 +305,7 @@  static int i2c_device_remove(struct device *dev)
 		status = driver->remove(client);
 	}
 
-	acpi_dev_pm_detach(&client->dev, true);
+	dev_pm_domain_detach(&client->dev, true);
 	return status;
 }