[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANk1AXQ1PSqiCCXpJTd0zotG+hFCsfC_kCL-mwf92_1ufneKLQ@mail.gmail.com>
Date: Wed, 12 Jul 2017 11:33:52 -0500
From: Alan Tull <atull@...nel.org>
To: Moritz Fischer <moritz.fischer@...us.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-fpga@...r.kernel.org
Subject: Re: [PATCH v3 03/16] fpga: mgr: API change to replace fpga load
functions with single function
On Mon, Jul 10, 2017 at 12:36 PM, Moritz Fischer
<moritz.fischer@...us.com> wrote:
>> +struct fpga_image_info *fpga_image_info_alloc(struct device *dev)
>> +{
>> + struct fpga_image_info *info;
>> +
>> + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
>> + if (!info)
>> + return ERR_PTR(-ENOMEM);
>
> Doesn't this make it more complex? If in the end you'll anyway have to check
> if IS_ERR_OR_NULL()? As opposed to just checking if (!info) on the returned
> value.
>
> Just a thought.
Also I should save a pointer to the device in fpga_image_info so that
fpga_image_info_free() could lose the dev param. I'd add this here:
get_device(dev);
info->dev = dev;
>
>> +
>> + return info;
>> +}
>> +EXPORT_SYMBOL_GPL(fpga_image_info_alloc);
>> +
>> +void fpga_image_info_free(struct device *dev,
>> + struct fpga_image_info *info)
I'd get rid of the dev parameter.
>> +{
struct device *dev;
>> + if (!info)
>> + return;
dev = info->dev;
>> +
>> + if (info->firmware_name)
>> + devm_kfree(dev, info->firmware_name);
>> +
>> + devm_kfree(dev, info);
put_device(dev);
>> +}
>> +EXPORT_SYMBOL_GPL(fpga_image_info_free);
And fix all uses of this function to be fpga_image_info_free(info);
Alan Tull
Powered by blists - more mailing lists