From: Anatolij Gustschin <agust@denx.de>
To: Alan Tull <atull@kernel.org>
Cc: linux-fpga@vger.kernel.org, Moritz Fischer <mdf@kernel.org>
Subject: Re: [PATCH v3] fpga: mgr: altera-ps-spi: enable usage on non-dt platforms
Date: Fri, 16 Nov 2018 01:02:55 +0100 [thread overview]
Message-ID: <20181116010255.16091acf@crub> (raw)
In-Reply-To: <CANk1AXS5q4z-3fjdD822g5tqg7ToBtwoqamSMuSJ9ChEpm2_vQ@mail.gmail.com>
Hi Alan,
On Thu, 15 Nov 2018 16:24:21 -0600
Alan Tull atull@kernel.org wrote:
...
>Need to update the header to explain what has been added since v2
>(added spi ids and an array and code to map spi ids to data).
Done in v4.
...
>> +static const struct altera_ps_data *altera_ps_data_map[] = {
>
>Please add a comment that array index is enum altera_ps_devtype or
>something like that. Make it easy for future generations to do the
>right thing. :)
Done in v4.
...
>> +static const struct altera_ps_data *id_to_data(const struct spi_device_id *id)
>> +{
>> + const struct altera_ps_data *data;
>> + unsigned int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(altera_ps_data_map); i++) {
>
>At this point, id->driver_data == CYCLONE5 or ARRIA10 (more added in
>the future) so we don't need a loop to search the mapping array for a
>matching id. Would something like the following work instead of
>this for loop? I understand you wanted to do some checking, this
>accomplishes some checking but will exit NULL if someone extends the
>array wrongly.
Yes, this works.
>kernel_ulong_t devtype = id->driver_data;
>
>/* someone added a altera_ps_devtype without adding to the map array */
>if (devtype >= ARRAY_SIZE(altera_ps_data_map))
> return NULL;
>
>data = altera_ps_data_map[devtype];
>if (!data || data->devtype != devtype)
> return NULL;
>
>return data;
Okay, v4 uses this code.
Thanks,
Anatolij
prev parent reply other threads:[~2018-11-16 0:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-01 21:22 [PATCH v3] fpga: mgr: altera-ps-spi: enable usage on non-dt platforms Anatolij Gustschin
2018-11-12 21:15 ` Anatolij Gustschin
2018-11-15 22:24 ` Alan Tull
2018-11-16 0:02 ` Anatolij Gustschin [this message]
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=20181116010255.16091acf@crub \
--to=agust@denx.de \
--cc=atull@kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=mdf@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).