On 09/01/2015 11:48 PM, Christoph Hellwig wrote: > On Tue, Sep 01, 2015 at 05:03:28PM -0700, Lee Duncan wrote: >> +static int host_get_index(int *index) >> +{ >> + int error = -ENOMEM; >> + >> + do { >> + if (!ida_pre_get(&host_index_ida, GFP_KERNEL)) >> + break; >> + spin_lock(&host_index_lock); >> + error = ida_get_new(&host_index_ida, index); >> + spin_unlock(&host_index_lock); >> + } while (error == -EAGAIN); >> + >> + return error; >> +} >> + >> +static inline void host_put_index(int index) >> +{ >> + spin_lock(&host_index_lock); >> + ida_remove(&host_index_ida, index); >> + spin_unlock(&host_index_lock); >> +} > > I really hate how this pattern (and the equivalent for IDA) are > spread all over. Any chance to have some simple_ida/simple_idr helpers > instead of duplicating it again an again. > > Besides that why aren't we using and idr here and use it for host lookup > as well? > . > Good question. My original goal was just to fix the host_no wrap-around problem, but I agree, the hosts.c module could benefit from using idr, making scsi_host_lookup(hostnum) much simpler, and possible faster. I will submit another patch. This means I won't need the sequence any longer that you wanted made into helper functions, though I'd still be glad to create the helper functions and convert some of the ida users, if you wish. -- Lee Duncan -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html