From: Alexander Aring <alex.aring@gmail.com>
To: Brad Campbell <bradjc5@gmail.com>
Cc: linux-wpan@vger.kernel.org
Subject: Re: [PATCHv2 1/2] cc2520: Do not store platform_data in spi_device
Date: Tue, 17 Mar 2015 09:06:52 +0100 [thread overview]
Message-ID: <20150317080649.GB1303@omega> (raw)
In-Reply-To: <1426544203-60585-2-git-send-email-bradjc5@gmail.com>
Hi,
On Mon, Mar 16, 2015 at 06:16:42PM -0400, Brad Campbell wrote:
> Storing the `platform_data` struct inside of the SPI struct when using
> the device tree allows for a later function to edit the content of that
> struct. This patch refactors the `cc2520_get_platformat_data` function
> to accept a pointer to a `cc2520_platform_data` struct and populates
> the fields inside of it.
>
> This changes mirrors a similar change in the at86rf230.c driver.
For referencing other fixes use $COMMIT_ID ("$SHORT_COMMIT_MSG").
like: aaa1c4d226e4cd730075d3dac99a6d599a0190c7 ("at86rf230: copy pdata
to driver allocated space")
>
> Signed-off-by: Brad Campbell <bradjc5@gmail.com>
> ---
> drivers/net/ieee802154/cc2520.c | 93 +++++++++++++++++++----------------------
> 1 file changed, 44 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
> index 181b349..275e6fb 100644
> --- a/drivers/net/ieee802154/cc2520.c
> +++ b/drivers/net/ieee802154/cc2520.c
> @@ -714,6 +714,31 @@ static irqreturn_t cc2520_sfd_isr(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> +static int cc2520_get_platform_data(struct spi_device *spi,
> + struct cc2520_platform_data *pdata)
> +{
> + struct device_node *np = spi->dev.of_node;
> + struct cc2520_private *priv = spi_get_drvdata(spi);
> +
> + if (!np) {
> + struct cc2520_platform_data *spi_pdata = spi->dev.platform_data;
This can be null if somebody given no platform_data data.
Additional check with on (!spi_pdata) is required.
something like:
if (!spi_pdata)
return -ENOENT;
before dereferencing.
> + *pdata = *spi_pdata;
> + return 0;
> + }
>
Otherwise looking good.
- Alex
next prev parent reply other threads:[~2015-03-17 8:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 22:16 [PATCHv2 0/2] cc2520: add support for CC2591 Brad Campbell
2015-03-16 22:16 ` [PATCHv2 1/2] cc2520: Do not store platform_data in spi_device Brad Campbell
2015-03-17 8:06 ` Alexander Aring [this message]
2015-03-16 22:16 ` [PATCHv2 2/2] cc2520: Add support for CC2591 amplifier Brad Campbell
2015-03-17 8:03 ` Alexander Aring
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=20150317080649.GB1303@omega \
--to=alex.aring@gmail.com \
--cc=bradjc5@gmail.com \
--cc=linux-wpan@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