Re: [PATCH v3 04/22] firmware: arm_scmi: add basic driver infrastructure for SCMI

From: Arnd Bergmann
Date: Wed Oct 04 2017 - 07:19:46 EST


On Thu, Sep 28, 2017 at 3:11 PM, Sudeep Holla <sudeep.holla@xxxxxxx> wrote:

> +static int scmi_mbox_free_channel(struct scmi_info *info)
> +{
> + if (!IS_ERR_OR_NULL(info->tx_chan)) {
> + mbox_free_channel(info->tx_chan);
> + info->tx_chan = NULL;
> + }
> +
> + return 0;
> +}

Any use of IS_ERR_OR_NULL() tends to be an indication of a bad API
design. Please make a decision about what you want to store in
info->tx_chan and stick with it.

Usually, we don't store error pointers in permanent data structures.
If you can deal with tx_chan being absent here, then you can just
store NULL into it when you don't have one, otherwise you should
make sure you never call this and fail the probe function earlier.

Arnd