lkml.org 
[lkml]   [2017]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC PATCH 03/12] staging: android: ion: Duplicate sg_table
From
Date
On 03/03/2017 12:18 AM, Hillf Danton wrote:
>
> On March 03, 2017 5:45 AM Laura Abbott wrote:
>>
>> +static struct sg_table *dup_sg_table(struct sg_table *table)
>> +{
>> + struct sg_table *new_table;
>> + int ret, i;
>> + struct scatterlist *sg, *new_sg;
>> +
>> + new_table = kzalloc(sizeof(*new_table), GFP_KERNEL);
>> + if (!new_table)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ret = sg_alloc_table(new_table, table->nents, GFP_KERNEL);
>> + if (ret) {
>> + kfree(table);
>
> Free new table?
>
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + new_sg = new_table->sgl;
>> + for_each_sg(table->sgl, sg, table->nents, i) {
>> + memcpy(new_sg, sg, sizeof(*sg));
>> + sg->dma_address = 0;
>> + new_sg = sg_next(new_sg);
>> + }
>> +
>
> Do we need a helper, sg_copy_table(dst_table, src_table)?
>
>> + return new_table;
>> +}
>> +

Yes, that would probably be good since I've seen this
code elsewhere.

Thanks,
Laura

\
 
 \ /
  Last update: 2017-03-03 19:43    [W:0.069 / U:0.916 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site