All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	Jonathan Corbet <corbet@lwn.net>, Corey Minyard <minyard@acm.org>,
	Jean Delvare <jdelvare@suse.de>,
	Guenter Roeck <linux@roeck-us.net>,
	Andrew Duggan <aduggan@synaptics.com>,
	Christopher Heiny <cheiny@synaptics.com>,
	linux-i2c@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH v8 4/4] Input: synaptics-rmi4 - add SMBus support
Date: Fri, 24 Jun 2016 09:19:32 +0200	[thread overview]
Message-ID: <20160624071931.GP24234@mail.corp.redhat.com> (raw)
In-Reply-To: <20160623230635.GS32561@dtor-ws>

On Jun 23 2016 or thereabouts, Dmitry Torokhov wrote:
> Hi Benjamin,
> 
> On Thu, Jun 09, 2016 at 04:53:50PM +0200, Benjamin Tissoires wrote:
> > +
> > +struct mapping_table_entry {
> > +	u16 rmiaddr;
> 
> Should be __le16 rmiaddr, otherwise:
> 
>   CHECK   drivers/input/rmi4/rmi_smbus.c
> drivers/input/rmi4/rmi_smbus.c:116:33: warning: incorrect type in assignment (different base types)
> drivers/input/rmi4/rmi_smbus.c:116:33:    expected unsigned short [unsigned] [usertype] rmiaddr
> drivers/input/rmi4/rmi_smbus.c:116:33:    got restricted __le16 [usertype] <noident>
> 
> > +
> > +static struct i2c_driver rmi_smb_driver;
> > +
> 
> I do not think this forward declaration is needed.
> 
> > +
> > +#ifdef CONFIG_PM_SLEEP
> > +static int rmi_smb_suspend(struct device *dev)
> 
> __maybe_unused instead of #ifdef.
> 
> > +{
> > +	struct i2c_client *client = to_i2c_client(dev);
> > +	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
> > +	int ret;
> > +
> > +	ret = rmi_driver_suspend(rmi_smb->xport.rmi_dev);
> > +	if (ret)
> > +		dev_warn(dev, "Failed to suspend device: %d\n", ret);
> > +
> > +	return ret;
> > +}
> > +#endif
> > +
> > +#ifdef CONFIG_PM
> > +static int rmi_smb_runtime_suspend(struct device *dev)
> 
> Same here?
> 
> > +{
> > +	struct i2c_client *client = to_i2c_client(dev);
> > +	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
> > +	int ret;
> > +
> > +	ret = rmi_driver_suspend(rmi_smb->xport.rmi_dev);
> > +	if (ret)
> > +		dev_warn(dev, "Failed to suspend device: %d\n", ret);
> > +
> > +	return 0;
> > +}
> > +
> > +static int rmi_smb_runtime_resume(struct device *dev)
> > +{
> > +	struct i2c_client *client = to_i2c_client(dev);
> > +	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
> > +	int ret;
> > +
> > +	ret = rmi_driver_resume(rmi_smb->xport.rmi_dev);
> > +	if (ret)
> > +		dev_warn(dev, "Failed to resume device: %d\n", ret);
> > +
> > +	return 0;
> > +}
> > +#endif
> > +
> > +static const struct dev_pm_ops rmi_smb_pm = {
> > +	SET_SYSTEM_SLEEP_PM_OPS(rmi_smb_suspend, NULL)
> > +	SET_RUNTIME_PM_OPS(rmi_smb_runtime_suspend, rmi_smb_runtime_resume,
> > +			   NULL)
> > +};
> > +
> > +static int rmi_smb_resume(struct device *dev)
> > +{
> > +	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
> > +	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
> > +	struct rmi_device *rmi_dev = rmi_smb->xport.rmi_dev;
> > +	int ret;
> > +
> > +	rmi_smb_reset(&rmi_smb->xport, 0);
> > +
> > +	rmi_reset(rmi_dev);
> > +
> > +	ret = rmi_driver_resume(rmi_smb->xport.rmi_dev);
> > +	if (ret)
> > +		dev_warn(dev, "Failed to resume device: %d\n", ret);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct i2c_device_id rmi_id[] = {
> > +	{ "rmi4_smbus", 0 },
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(i2c, rmi_id);
> > +
> > +static struct i2c_driver rmi_smb_driver = {
> > +	.driver = {
> > +		.owner	= THIS_MODULE,
> > +		.name	= "rmi4_smbus",
> > +		.pm	= &rmi_smb_pm,
> > +		.resume	= rmi_smb_resume,
> 
> Why rmi_smb_resume is not part of rmi_smb_pm?
> 

This is because rmi_smbus device both have a PS/2 interface and a SMBus
one. I'll have to check again now that I have a slightly different way
of binding smbus devices in my tree, but the issue was:
- having resume part of pm means it will get caught by PM directly
- the PS/2 node gets also resumed by PM
- calling PS/2 commands during resume switches the devices back into
  PS/2 and stops the SMBus communication.

So it's easier to wait only for the PS/2 PM resume call which will call
the SMBus resume function when the device is in a proper state.

I'll send out the updated patch with your comments next week hopefully.

Cheers,
Benjamin

  reply	other threads:[~2016-06-24  7:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 14:53 [PATCH v8 0/4] i2c-smbus: add support for HOST NOTIFY Benjamin Tissoires
2016-06-09 14:53 ` [PATCH v8 1/4] i2c: add a protocol parameter to the alert callback Benjamin Tissoires
2016-06-17 11:26   ` Wolfram Sang
2016-06-09 14:53 ` [PATCH v8 2/4] i2c-smbus: add SMBus Host Notify support Benjamin Tissoires
2016-06-17 11:26   ` Wolfram Sang
2016-07-18  9:37   ` Jean Delvare
2016-07-18 15:59     ` Benjamin Tissoires
2016-07-18 16:47       ` Jean Delvare
2016-07-18 14:31   ` Jean Delvare
2016-07-18 16:35     ` Benjamin Tissoires
2016-07-18 20:47       ` Jean Delvare
2016-06-09 14:53 ` [PATCH v8 3/4] i2c: i801: add support of Host Notify Benjamin Tissoires
2016-06-15  8:12   ` Benjamin Tissoires
2016-06-16  6:09     ` Wolfram Sang
2016-06-16 12:55       ` Benjamin Tissoires
2016-06-16 14:31         ` Wolfram Sang
2016-06-23 20:55       ` Dmitry Torokhov
2016-06-23 21:46         ` Wolfram Sang
2016-06-23 22:57           ` Dmitry Torokhov
2016-06-09 14:53 ` [PATCH v8 4/4] Input: synaptics-rmi4 - add SMBus support Benjamin Tissoires
2016-06-23 23:06   ` Dmitry Torokhov
2016-06-24  7:19     ` Benjamin Tissoires [this message]
2016-06-24 23:35       ` Dmitry Torokhov
2016-06-27 15:03         ` Benjamin Tissoires

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160624071931.GP24234@mail.corp.redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=aduggan@synaptics.com \
    --cc=cheiny@synaptics.com \
    --cc=corbet@lwn.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jdelvare@suse.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=minyard@acm.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.