Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1453250

Re: [PATCH 5/5] i2c: i801: warn on i2c_handle_smbus_host_notify() errors

From Jean Delvare <jdelvare@suse.de>
Newsgroups linux.kernel
Subject Re: [PATCH 5/5] i2c: i801: warn on i2c_handle_smbus_host_notify() errors
Date 2016-08-01 16:40 +0200
Message-ID <s1mxP-7wE-3@gated-at.bofh.it> (permalink)
References <rZQgF-4ts-5@gated-at.bofh.it> <rZQgG-4ts-23@gated-at.bofh.it>
Organization SUSE Linux

Show all headers | View raw


Hi Benjamin,

On Thu, 28 Jul 2016 11:50:43 +0200, Benjamin Tissoires wrote:
> i2c_handle_smbus_host_notify() returns 1 on success, something else on
> errors.

I did not notice before, but that doesn't make much sense IMHO. Your
function follows the "negative number on error" return model, so
returning the boolean value from schedule_work() doesn't look good.
Either you don't care about that value, and you should ignore it and
return 0 on success. Or you care and you should handle it in the
function. Right now value false/0 is in a gray zone, you don't consider
it as success according to the above comment, but you don't treat it as
an error in the code below either. I suppose it can't actually happen?
If so, I advise you don't check the value returned by schedule_work().

> There is a chance we get called while Host Notify is not available (yet),
> so we need to clear the Host Notify bit in those rare case.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>  drivers/i2c/busses/i2c-i801.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index a9b9bb4..f02b248 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -578,12 +578,20 @@ static irqreturn_t i801_host_notify_isr(struct i801_priv *priv)
>  {
>  	unsigned short addr;
>  	unsigned int data;
> +	int ret;
> +
> +	if (unlikely(!priv->host_notify))
> +		goto out;

This covers the case where you get an interrupt before the handler is
installed. Good catch, I never considered it.

>  
>  	addr = inb_p(SMBNTFDADD(priv)) >> 1;
>  	data = inw_p(SMBNTFDDAT(priv));
>  
> -	i2c_handle_smbus_host_notify(priv->host_notify, addr, data);
> +	ret = i2c_handle_smbus_host_notify(priv->host_notify, addr, data);
> +	if (ret < 0)
> +		dev_warn(&priv->pci_dev->dev,
> +			 "Host Notify handling failed: %d\n", ret);
>  
> +out:
>  	/* clear Host Notify bit and return */
>  	outb_p(SMBSLVSTS_HST_NTFY_STS, SMBSLVSTS(priv));
>  	return IRQ_HANDLED;

Reviewed-by: Jean Delvare <jdelvare@suse.de>

-- 
Jean Delvare
SUSE L3 Support

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] i2c: Host Notify / i801 fixes Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-07-28 12:00 +0200
  [PATCH 5/5] i2c: i801: warn on i2c_handle_smbus_host_notify() errors Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-07-28 12:00 +0200
    Re: [PATCH 5/5] i2c: i801: warn on i2c_handle_smbus_host_notify()  errors Jean Delvare <jdelvare@suse.de> - 2016-08-01 16:40 +0200
  [PATCH 2/5] i2c: i801: minor formatting issues Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-07-28 12:00 +0200
    Re: [PATCH 2/5] i2c: i801: minor formatting issues Jean Delvare <jdelvare@suse.de> - 2016-07-29 11:20 +0200
  [PATCH 1/5] i2c: i2c-smbus: prevent races on remove when Host Notify is used Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-07-28 12:00 +0200
    Re: [PATCH 1/5] i2c: i2c-smbus: prevent races on remove when Host  Notify is used Jean Delvare <jdelvare@suse.de> - 2016-07-29 11:20 +0200
      Re: [PATCH 1/5] i2c: i2c-smbus: prevent races on remove when Host  Notify is used Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-07-29 18:40 +0200
      Re: [PATCH 1/5] i2c: i2c-smbus: prevent races on remove when Host  Notify is used Jean Delvare <jdelvare@suse.de> - 2016-08-01 15:40 +0200
  [PATCH 4/5] i2c: i801: do not report an error if FEATURE_HOST_NOTIFY is not set Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-07-28 12:00 +0200
    Re: [PATCH 4/5] i2c: i801: do not report an error if  FEATURE_HOST_NOTIFY is not set Jean Delvare <jdelvare@suse.de> - 2016-07-29 12:50 +0200

csiph-web