All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Dan Murphy <dmurphy@ti.com>, wg@grandegger.com, davem@davemloft.net
Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v11 1/5] can: m_can: Create a m_can platform framework
Date: Wed, 8 May 2019 16:35:46 +0200	[thread overview]
Message-ID: <8b53474d-9dbf-4b81-defd-1587e022990b@pengutronix.de> (raw)
In-Reply-To: <20190319172651.10012-1-dmurphy@ti.com>


[-- Attachment #1.1: Type: text/plain, Size: 1932 bytes --]

On 3/19/19 6:26 PM, Dan Murphy wrote:
> Create a m_can platform framework that peripheral
> devices can register to and use common code and register sets.
> The peripheral devices may provide read/write and configuration
> support of the IP.
> 
> Acked-by: Wolfgang Grandegger <wg@grandegger.com>
> Signed-off-by: Dan Murphy <dmurphy@ti.com>

[...]

> -/* m_can private data structure */
> -struct m_can_priv {
> -	struct can_priv can;	/* must be the first member */
> -	struct napi_struct napi;
> -	struct net_device *dev;
> -	struct device *device;
> -	struct clk *hclk;
> -	struct clk *cclk;
> -	void __iomem *base;
> -	u32 irqstatus;
> -	int version;
> -
> -	/* message ram configuration */
> -	void __iomem *mram_base;
> -	struct mram_cfg mcfg[MRAM_CFG_NUM];
> -};
> +static u32 m_can_read(struct m_can_priv *priv, enum m_can_reg reg)
> +{
> +	if (priv->ops->read_reg)
> +		return priv->ops->read_reg(priv, reg);
> +	else
> +		return -EINVAL;
> +}

How do you plan to check the return value here?
What's the difference between a register value of 0xffffffe9 and
returning -EINVAL?

>  
> -static inline u32 m_can_read(const struct m_can_priv *priv, enum m_can_reg reg)
> +static int m_can_write(struct m_can_priv *priv, enum m_can_reg reg, u32 val)
>  {
> -	return readl(priv->base + reg);
> +	if (priv->ops->write_reg)
> +		return priv->ops->write_reg(priv, reg, val);
> +	else
> +		return -EINVAL;
>  }

I don't see anyone checking the return value. Better just dereference
the pointer and the kernel will produce a nice backtrace.

Same should be done for all read and write variants.

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: 488 bytes --]

  parent reply	other threads:[~2019-05-08 14:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 17:26 [PATCH v11 1/5] can: m_can: Create a m_can platform framework Dan Murphy
2019-03-19 17:26 ` Dan Murphy
2019-03-19 17:26 ` [PATCH v11 2/5] can: m_can: Rename m_can_priv to m_can_classdev Dan Murphy
2019-03-19 17:26   ` Dan Murphy
2019-03-19 17:26 ` [PATCH v11 3/5] dt-bindings: can: tcan4x5x: Add DT bindings for TCAN4x5X driver Dan Murphy
2019-03-19 17:26   ` Dan Murphy
2019-03-19 17:26 ` [PATCH v11 4/5] can: tcan4x5x: Add tcan4x5x driver to the kernel Dan Murphy
2019-03-19 17:26   ` Dan Murphy
2019-03-19 17:26 ` [PATCH v11 5/5] can: m_can: Fix checkpatch issues on existing code Dan Murphy
2019-03-19 17:26   ` Dan Murphy
2019-04-02 12:03 ` [PATCH v11 1/5] can: m_can: Create a m_can platform framework Dan Murphy
2019-04-02 12:03   ` Dan Murphy
2019-04-02 12:17   ` Wolfgang Grandegger
2019-04-10 13:24     ` Dan Murphy
2019-04-10 13:24       ` Dan Murphy
2019-04-18 14:36     ` Dan Murphy
2019-04-18 14:36       ` Dan Murphy
2019-05-01 14:10       ` Dan Murphy
2019-05-01 14:10         ` Dan Murphy
2019-05-08 14:35 ` Marc Kleine-Budde [this message]
2019-05-08 19:54   ` Dan Murphy
2019-05-08 19:54     ` Dan Murphy
2019-05-09  6:38     ` 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=8b53474d-9dbf-4b81-defd-1587e022990b@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=dmurphy@ti.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wg@grandegger.com \
    /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.