All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume
@ 2014-11-30 16:52 Lars-Peter Clausen
       [not found] ` <1417366352-22356-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
  2014-12-03 22:00 ` Jonathan Corbet
  0 siblings, 2 replies; 9+ messages in thread
From: Lars-Peter Clausen @ 2014-11-30 16:52 UTC (permalink / raw
  To: Wolfram Sang, Jonathan Corbet
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, Lars-Peter Clausen

New drivers should use PM ops instead of the legacy suspend/resume
callbacks. Update the I2C device driver guides to reflect this.

Signed-off-by: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
---
 Documentation/i2c/upgrading-clients | 6 ++----
 Documentation/i2c/writing-clients   | 8 ++++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Documentation/i2c/upgrading-clients b/Documentation/i2c/upgrading-clients
index 8e5fbd8..ccba3ff 100644
--- a/Documentation/i2c/upgrading-clients
+++ b/Documentation/i2c/upgrading-clients
@@ -79,11 +79,10 @@ static struct i2c_driver example_driver = {
  	.driver		= {
 		.owner		= THIS_MODULE,
 		.name		= "example",
+		.pm		= &example_pm_ops,
 	},
 	.attach_adapter = example_attach_adapter,
 	.detach_client	= example_detach,
-	.suspend	= example_suspend,
-	.resume		= example_resume,
 };
 
 
@@ -272,10 +271,9 @@ static struct i2c_driver example_driver = {
  	.driver		= {
 		.owner		= THIS_MODULE,
 		.name		= "example",
+		.pm		= &example_pm_ops,
 	},
 	.id_table	= example_idtable,
 	.probe		= example_probe,
 	.remove		= example_remove,
-	.suspend	= example_suspend,
-	.resume		= example_resume,
 };
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 6b344b5..a755b14 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -36,6 +36,7 @@ MODULE_DEVICE_TABLE(i2c, foo_idtable);
 static struct i2c_driver foo_driver = {
 	.driver = {
 		.name	= "foo",
+		.pm	= &foo_pm_ops,	/* optional */
 	},
 
 	.id_table	= foo_idtable,
@@ -47,8 +48,6 @@ static struct i2c_driver foo_driver = {
 	.address_list	= normal_i2c,
 
 	.shutdown	= foo_shutdown,	/* optional */
-	.suspend	= foo_suspend,	/* optional */
-	.resume		= foo_resume,	/* optional */
 	.command	= foo_command,	/* optional, deprecated */
 }
 
@@ -279,8 +278,9 @@ Power Management
 
 If your I2C device needs special handling when entering a system low
 power state -- like putting a transceiver into a low power mode, or
-activating a system wakeup mechanism -- do that in the suspend() method.
-The resume() method should reverse what the suspend() method does.
+activating a system wakeup mechanism -- do that by implementing the
+appropriate callbacks for the dev_pm_ops of the driver (like suspend
+and resume).
 
 These are standard driver model calls, and they work just like they
 would for any other driver stack.  The calls can sleep, and can use
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] i2c: Remove support for legacy PM
       [not found] ` <1417366352-22356-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
@ 2014-11-30 16:52   ` Lars-Peter Clausen
  2014-12-04 18:11     ` Wolfram Sang
       [not found]     ` <1417366352-22356-2-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
  2014-12-04 18:09   ` [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume Wolfram Sang
  1 sibling, 2 replies; 9+ messages in thread
From: Lars-Peter Clausen @ 2014-11-30 16:52 UTC (permalink / raw
  To: Wolfram Sang, Jonathan Corbet
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, Lars-Peter Clausen

There haven't been any I2C driver that use the legacy suspend/resume
callbacks for a while now and new drivers are supposed to use PM ops. So
remove support for legacy suspend/resume for I2C drivers.

Since there aren't any special bus specific things to do during
suspend/resume and since the PM core will automatically fallback directly to
using the device's PM ops if no bus PM ops are specified there is no need to
have any I2C bus PM ops.

Signed-off-by: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
---
 drivers/i2c/i2c-core.c | 118 -------------------------------------------------
 include/linux/i2c.h    |   4 --
 2 files changed, 122 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 3105bd2..f23c03b 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -695,101 +695,6 @@ static void i2c_device_shutdown(struct device *dev)
 		driver->shutdown(client);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int i2c_legacy_suspend(struct device *dev, pm_message_t mesg)
-{
-	struct i2c_client *client = i2c_verify_client(dev);
-	struct i2c_driver *driver;
-
-	if (!client || !dev->driver)
-		return 0;
-	driver = to_i2c_driver(dev->driver);
-	if (!driver->suspend)
-		return 0;
-	return driver->suspend(client, mesg);
-}
-
-static int i2c_legacy_resume(struct device *dev)
-{
-	struct i2c_client *client = i2c_verify_client(dev);
-	struct i2c_driver *driver;
-
-	if (!client || !dev->driver)
-		return 0;
-	driver = to_i2c_driver(dev->driver);
-	if (!driver->resume)
-		return 0;
-	return driver->resume(client);
-}
-
-static int i2c_device_pm_suspend(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_suspend(dev);
-	else
-		return i2c_legacy_suspend(dev, PMSG_SUSPEND);
-}
-
-static int i2c_device_pm_resume(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_resume(dev);
-	else
-		return i2c_legacy_resume(dev);
-}
-
-static int i2c_device_pm_freeze(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_freeze(dev);
-	else
-		return i2c_legacy_suspend(dev, PMSG_FREEZE);
-}
-
-static int i2c_device_pm_thaw(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_thaw(dev);
-	else
-		return i2c_legacy_resume(dev);
-}
-
-static int i2c_device_pm_poweroff(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_poweroff(dev);
-	else
-		return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
-}
-
-static int i2c_device_pm_restore(struct device *dev)
-{
-	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-	if (pm)
-		return pm_generic_restore(dev);
-	else
-		return i2c_legacy_resume(dev);
-}
-#else /* !CONFIG_PM_SLEEP */
-#define i2c_device_pm_suspend	NULL
-#define i2c_device_pm_resume	NULL
-#define i2c_device_pm_freeze	NULL
-#define i2c_device_pm_thaw	NULL
-#define i2c_device_pm_poweroff	NULL
-#define i2c_device_pm_restore	NULL
-#endif /* !CONFIG_PM_SLEEP */
-
 static void i2c_client_dev_release(struct device *dev)
 {
 	kfree(to_i2c_client(dev));
@@ -834,27 +739,12 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {
 	NULL
 };
 
-static const struct dev_pm_ops i2c_device_pm_ops = {
-	.suspend = i2c_device_pm_suspend,
-	.resume = i2c_device_pm_resume,
-	.freeze = i2c_device_pm_freeze,
-	.thaw = i2c_device_pm_thaw,
-	.poweroff = i2c_device_pm_poweroff,
-	.restore = i2c_device_pm_restore,
-	SET_RUNTIME_PM_OPS(
-		pm_generic_runtime_suspend,
-		pm_generic_runtime_resume,
-		NULL
-	)
-};
-
 struct bus_type i2c_bus_type = {
 	.name		= "i2c",
 	.match		= i2c_device_match,
 	.probe		= i2c_device_probe,
 	.remove		= i2c_device_remove,
 	.shutdown	= i2c_device_shutdown,
-	.pm		= &i2c_device_pm_ops,
 };
 EXPORT_SYMBOL_GPL(i2c_bus_type);
 
@@ -1850,14 +1740,6 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
 	if (res)
 		return res;
 
-	/* Drivers should switch to dev_pm_ops instead. */
-	if (driver->suspend)
-		pr_warn("i2c-core: driver [%s] using legacy suspend method\n",
-			driver->driver.name);
-	if (driver->resume)
-		pr_warn("i2c-core: driver [%s] using legacy resume method\n",
-			driver->driver.name);
-
 	pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
 
 	INIT_LIST_HEAD(&driver->clients);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index b556e0a..d0b66cc 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -128,8 +128,6 @@ extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
  * @probe: Callback for device binding
  * @remove: Callback for device unbinding
  * @shutdown: Callback for device shutdown
- * @suspend: Callback for device suspend
- * @resume: Callback for device resume
  * @alert: Alert callback, for example for the SMBus alert protocol
  * @command: Callback for bus-wide signaling (optional)
  * @driver: Device driver model driver
@@ -172,8 +170,6 @@ struct i2c_driver {
 
 	/* driver model interfaces that don't relate to enumeration  */
 	void (*shutdown)(struct i2c_client *);
-	int (*suspend)(struct i2c_client *, pm_message_t mesg);
-	int (*resume)(struct i2c_client *);
 
 	/* Alert callback, for example for the SMBus alert protocol.
 	 * The format and meaning of the data value depends on the protocol.
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume
  2014-11-30 16:52 [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume Lars-Peter Clausen
       [not found] ` <1417366352-22356-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
@ 2014-12-03 22:00 ` Jonathan Corbet
       [not found]   ` <20141203170022.6ec17a33-T1hC0tSOHrs@public.gmane.org>
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Corbet @ 2014-12-03 22:00 UTC (permalink / raw
  To: Lars-Peter Clausen; +Cc: Wolfram Sang, linux-i2c, linux-doc

On Sun, 30 Nov 2014 17:52:31 +0100
Lars-Peter Clausen <lars@metafoo.de> wrote:

> New drivers should use PM ops instead of the legacy suspend/resume
> callbacks. Update the I2C device driver guides to reflect this.

It looks like nobody has picked this up; I'll take it through the docs
tree, I guess, unless somebody objects...

jon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume
       [not found]   ` <20141203170022.6ec17a33-T1hC0tSOHrs@public.gmane.org>
@ 2014-12-04  4:39     ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2014-12-04  4:39 UTC (permalink / raw
  To: Jonathan Corbet
  Cc: Lars-Peter Clausen, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

On Wed, Dec 03, 2014 at 05:00:22PM -0500, Jonathan Corbet wrote:
> On Sun, 30 Nov 2014 17:52:31 +0100
> Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org> wrote:
> 
> > New drivers should use PM ops instead of the legacy suspend/resume
> > callbacks. Update the I2C device driver guides to reflect this.
> 
> It looks like nobody has picked this up; I'll take it through the docs
> tree, I guess, unless somebody objects...

I'll take it via I2C.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume
       [not found] ` <1417366352-22356-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
  2014-11-30 16:52   ` [PATCH 2/2] i2c: Remove support for legacy PM Lars-Peter Clausen
@ 2014-12-04 18:09   ` Wolfram Sang
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2014-12-04 18:09 UTC (permalink / raw
  To: Lars-Peter Clausen
  Cc: Jonathan Corbet, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 328 bytes --]

On Sun, Nov 30, 2014 at 05:52:31PM +0100, Lars-Peter Clausen wrote:
> New drivers should use PM ops instead of the legacy suspend/resume
> callbacks. Update the I2C device driver guides to reflect this.
> 
> Signed-off-by: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] i2c: Remove support for legacy PM
  2014-11-30 16:52   ` [PATCH 2/2] i2c: Remove support for legacy PM Lars-Peter Clausen
@ 2014-12-04 18:11     ` Wolfram Sang
  2014-12-04 18:19       ` Lars-Peter Clausen
       [not found]     ` <1417366352-22356-2-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2014-12-04 18:11 UTC (permalink / raw
  To: Lars-Peter Clausen; +Cc: Jonathan Corbet, linux-i2c, linux-doc

[-- Attachment #1: Type: text/plain, Size: 738 bytes --]

On Sun, Nov 30, 2014 at 05:52:32PM +0100, Lars-Peter Clausen wrote:
> There haven't been any I2C driver that use the legacy suspend/resume
> callbacks for a while now and new drivers are supposed to use PM ops. So
> remove support for legacy suspend/resume for I2C drivers.
> 
> Since there aren't any special bus specific things to do during
> suspend/resume and since the PM core will automatically fallback directly to
> using the device's PM ops if no bus PM ops are specified there is no need to
> have any I2C bus PM ops.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

I'll keep this for 3.20, 3.19 is too close now. But thanks, the diffstat
looks great :) Just curious, has buildbot tested this already?


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] i2c: Remove support for legacy PM
  2014-12-04 18:11     ` Wolfram Sang
@ 2014-12-04 18:19       ` Lars-Peter Clausen
  2014-12-04 18:23         ` Wolfram Sang
  0 siblings, 1 reply; 9+ messages in thread
From: Lars-Peter Clausen @ 2014-12-04 18:19 UTC (permalink / raw
  To: Wolfram Sang; +Cc: Jonathan Corbet, linux-i2c, linux-doc

On 12/04/2014 07:11 PM, Wolfram Sang wrote:
> On Sun, Nov 30, 2014 at 05:52:32PM +0100, Lars-Peter Clausen wrote:
>> There haven't been any I2C driver that use the legacy suspend/resume
>> callbacks for a while now and new drivers are supposed to use PM ops. So
>> remove support for legacy suspend/resume for I2C drivers.
>>
>> Since there aren't any special bus specific things to do during
>> suspend/resume and since the PM core will automatically fallback directly to
>> using the device's PM ops if no bus PM ops are specified there is no need to
>> have any I2C bus PM ops.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>
> I'll keep this for 3.20, 3.19 is too close now. But thanks, the diffstat
> looks great :) Just curious, has buildbot tested this already?
>

No, but I did allyesconfig on both ARM and x86. As well as a `grep " 
i2c_driver "  -A20 * -r | grep '\(suspend\|resume\)'` and running the 
following cocci script.

@@
identifier fn;
identifier drv;
@@
struct i2c_driver drv  = {
     ...,
*   .suspend = fn,
     ...,
};

@@
identifier fn;
identifier drv;
@@
struct i2c_driver drv = {
     ...,
*   .resume = fn,
     ...,
};

None of those methods found anything, so I'm quite confident that there are 
no users left.

- Lars

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] i2c: Remove support for legacy PM
  2014-12-04 18:19       ` Lars-Peter Clausen
@ 2014-12-04 18:23         ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2014-12-04 18:23 UTC (permalink / raw
  To: Lars-Peter Clausen; +Cc: Jonathan Corbet, linux-i2c, linux-doc

[-- Attachment #1: Type: text/plain, Size: 113 bytes --]


> None of those methods found anything, so I'm quite confident that there are
> no users left.

Great, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] i2c: Remove support for legacy PM
       [not found]     ` <1417366352-22356-2-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
@ 2014-12-22 19:10       ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2014-12-22 19:10 UTC (permalink / raw
  To: Lars-Peter Clausen
  Cc: Jonathan Corbet, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 670 bytes --]

On Sun, Nov 30, 2014 at 05:52:32PM +0100, Lars-Peter Clausen wrote:
> There haven't been any I2C driver that use the legacy suspend/resume
> callbacks for a while now and new drivers are supposed to use PM ops. So
> remove support for legacy suspend/resume for I2C drivers.
> 
> Since there aren't any special bus specific things to do during
> suspend/resume and since the PM core will automatically fallback directly to
> using the device's PM ops if no bus PM ops are specified there is no need to
> have any I2C bus PM ops.
> 
> Signed-off-by: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>

Happily applied to for-next, thanks! :)


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-12-22 19:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-30 16:52 [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume Lars-Peter Clausen
     [not found] ` <1417366352-22356-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2014-11-30 16:52   ` [PATCH 2/2] i2c: Remove support for legacy PM Lars-Peter Clausen
2014-12-04 18:11     ` Wolfram Sang
2014-12-04 18:19       ` Lars-Peter Clausen
2014-12-04 18:23         ` Wolfram Sang
     [not found]     ` <1417366352-22356-2-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2014-12-22 19:10       ` Wolfram Sang
2014-12-04 18:09   ` [PATCH 1/2] Documentation: i2c: Use PM ops instead of legacy suspend/resume Wolfram Sang
2014-12-03 22:00 ` Jonathan Corbet
     [not found]   ` <20141203170022.6ec17a33-T1hC0tSOHrs@public.gmane.org>
2014-12-04  4:39     ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.