Re: [RFC PATCH v2 14/22] devlink: implement DEVLINK_CMD_REGION_NEW

Jacob Keller
2020-03-02T22:11:30Z

On 3/2/2020 9:41 AM, Jiri Pirko wrote:
> Sat, Feb 15, 2020 at 12:22:13AM CET, jacob.e.keller@intel.com wrote:
>> +++ b/include/net/devlink.h
>> @@ -498,10 +498,16 @@ struct devlink_info_req;
>> * struct devlink_region_ops - Region operations
>> * @name: region name
>> * @destructor: callback used to free snapshot memory when deleting
>> + * @snapshot: callback to request an immediate snapshot. On success,
>> + * the data variable must be updated to point to the snapshot data.
>> + * The function will be called while the devlink instance lock is
>> + * held.
>> */
>> struct devlink_region_ops {
>> const char *name;
>> void (*destructor)(const void *data);
>> + int (*snapshot)(struct devlink *devlink, struct netlink_ext_ack *extack,
>> + u8 **data);
>
> Please have the same type here and for destructor. "u8 *" I guess.
>
So, changing the destructor to take a const u8 * is problematic, because
it can then no longer directly take kfree, vfree, or kvfree.

I'd be happy to change the snapshot function so that it takes a void **
though.

Thanks,
Jake