Re: [PATCH v10 8/9] platform/chrome: Protect cros_ec_device lifecycle with revocable
From: Bartosz Golaszewski
Date: Mon May 11 2026 - 09:19:59 EST
On Fri, 8 May 2026 13:53:09 +0200, Jason Gunthorpe <jgg@xxxxxxxxxx> said:
> On Fri, May 08, 2026 at 06:54:47PM +0800, Tzung-Bi Shih wrote:
>> struct cros_ec_device *cros_ec_device_alloc(struct device *dev)
>> @@ -47,6 +49,15 @@ struct cros_ec_device *cros_ec_device_alloc(struct device *dev)
>> if (!ec_dev)
>> return NULL;
>>
>> + ec_dev->its_rev = revocable_alloc(ec_dev);
>> + if (!ec_dev->its_rev)
>> + return NULL;
>> + /*
>> + * Drop the extra reference for the caller as the caller is the
>> + * resource provider.
>> + */
>> + revocable_put(ec_dev->its_rev);
>> +
>> ec_dev->din_size = sizeof(struct ec_host_response) +
>> sizeof(struct ec_response_get_protocol_info) +
>> EC_MAX_RESPONSE_OVERHEAD;
>
> FWIW I am still very much against seeing any revokable concept used
> *between two drivers*. That will turn the kernel's lifetime model into
> spaghetti code.
>
I gave my R-b under the API definition and I'm fine with the GPIO changes.
Just for the record: I don't have an opinion on using it in this driver and
don't know if it's a good idea or not.
Bart