Hi Alan, On Thu, 15 Nov 2018 16:24:21 -0600 Alan Tull atull@xxxxxxxxxx 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