linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: linux-can@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH 5/7] can: dev: add berr_limit infrastrucutre
Date: Mon, 07 Oct 2013 18:00:45 +0200	[thread overview]
Message-ID: <5252DAAD.1020009@pengutronix.de> (raw)
In-Reply-To: <5252D9BE.9040905@pengutronix.de>

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

On 10/07/2013 05:56 PM, Marc Kleine-Budde wrote:
> On 10/07/2013 05:39 PM, Alexander Stein wrote:
>> Hello Marc,
>>
>> On Monday 07 October 2013 16:40:38, Marc Kleine-Budde wrote:
>>> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
>>> index bda1888..969d3cd 100644
>>> --- a/drivers/net/can/dev.c
>>> +++ b/drivers/net/can/dev.c
>>> @@ -486,6 +486,29 @@ void can_bus_off(struct net_device *dev)
>>>  }
>>>  EXPORT_SYMBOL_GPL(can_bus_off);
>>>  
>>> +static void can_berr_restart(unsigned long data)
>>> +{
>>> +	struct net_device *dev = (struct net_device *)data;
>>> +	struct can_priv *priv = netdev_priv(dev);
>>> +
>>> +	netdev_dbg(dev, "berr-restart\n");
>>> +	priv->do_berr_restart(dev);
>>      ^^^^^^^^^^^^^^^^^^^^^^^^
>> see below!
>>
>>> +}
>>> +
>>> +void can_berr_limit(struct net_device *dev)
>>> +{
>>> +	struct can_priv *priv = netdev_priv(dev);
>>> +
>>> +	if (priv->berr_limit_delay) {
>>> +		netdev_dbg(dev, "berr-limit\n");
>>> +		mod_timer(&priv->berr_limit_timer,
>>> +			  jiffies + priv->berr_limit_delay);
>>> +	} else {
>>> +		priv->do_berr_restart(dev);
>>          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
>> Here you are silently requiring that do_berr_restart is non-NULL. I
>> know that the driver has to properly set this when using
>> can_berr_limit, but it might seem confusing.
> 
> If the driver wants to make use of this feature, it has to setup this
> callback. If I add NULL pointer checks, the kernel wouldn't blow up, but
> the driver doesn't work any more.

I mean, if the driver doesn't setup the callback and there is a NULL
pointer checks in both functions, the driver doesn't work properly,
because the bus error interrupts will stay disabled and you might not
notice it, because there isn't any big sign of failure (like the NULL
pointer deref).

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  reply	other threads:[~2013-10-07 16:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-07 14:40 [PATCH 1/7] can: berr_limit support Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 1/7] can: dev: fix nlmsg size calculation in can_get_size() Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 2/7] can: dev: sort can_get_size() by IFLA_CAN_* Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 3/7] can: dev: sort can_fill_info() " Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 4/7] can: dev: sort can_changelink() " Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 5/7] can: dev: add berr_limit infrastrucutre Marc Kleine-Budde
2013-10-07 15:39   ` Alexander Stein
2013-10-07 15:56     ` Marc Kleine-Budde
2013-10-07 16:00       ` Marc Kleine-Budde [this message]
2013-10-08  6:03         ` Alexander Stein
2013-10-08  7:05           ` Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 6/7] can: dev: berr_limit netlink support for configuration Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 7/7] can: flexcan: add berr_limit support Marc Kleine-Budde
2013-10-07 19:38 ` [PATCH 1/7] can: " Wolfgang Grandegger
2013-10-07 19:42   ` Marc Kleine-Budde

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=5252DAAD.1020009@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=alexander.stein@systec-electronic.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).