[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <85r1iaimwl.fsf@linux.intel.com>
Date: Thu, 13 May 2021 19:06:18 +0200
From: Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Arnd Bergmann <arnd@...db.de>, Jonathan Corbet <corbet@....net>,
Derek Kiernan <derek.kiernan@...inx.com>,
Dragan Cvetic <dragan.cvetic@...inx.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
Savo Novakovic <savox.novakovic@...el.com>
Subject: Re: [PATCH v3 12/14] intel_gna: add a 'misc' device
Greg Kroah-Hartman <gregkh@...uxfoundation.org> writes:
> On Thu, May 13, 2021 at 01:00:38PM +0200, Maciej Kwapulinski wrote:
>> The new 'misc' device is the node for applications in user space to
>> interact with the driver.
>>
>> Signed-off-by: Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>
>> Tested-by: Savo Novakovic <savox.novakovic@...el.com>
>> ---
>> drivers/misc/intel/gna/device.c | 52 +++++++++++++++++++++++++++++++--
>> drivers/misc/intel/gna/device.h | 11 +++----
>> 2 files changed, 55 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/misc/intel/gna/device.c b/drivers/misc/intel/gna/device.c
>> index 0e31b8c6bb70..1e6345a8325b 100644
>> --- a/drivers/misc/intel/gna/device.c
>> +++ b/drivers/misc/intel/gna/device.c
>> @@ -20,6 +20,18 @@ module_param(recovery_timeout, int, 0644);
>> MODULE_PARM_DESC(recovery_timeout, "Recovery timeout in seconds");
>> #endif
>>
>> +struct file;
>> +
>> +static int gna_open(struct inode *inode, struct file *f)
>> +{
>> + return -EPERM;
>> +}
>
> That sucks, why have an open that does nothing but fail?
next patch provides complete implementation of gna_open(), here it's
just a protection if someone would incidentally run gna in the middle of patch series
>
>> +
>> +static const struct file_operations gna_file_ops = {
>> + .owner = THIS_MODULE,
>> + .open = gna_open,
>> +};
>> +
>> static void gna_devm_idr_destroy(void *data)
>> {
>> struct idr *idr = data;
>> @@ -27,6 +39,36 @@ static void gna_devm_idr_destroy(void *data)
>> idr_destroy(idr);
>> }
>>
>> +static void gna_devm_deregister_misc_dev(void *data)
>
> Why is this a void *?
it goes to devm_add_action() api.
>
> This isn't windows, use real pointer types everywhere in the kernel
> please.
>
>> +{
>> + struct miscdevice *misc = data;
>> +
>> + misc_deregister(misc);
>> +}
>> +
>> +static int gna_devm_register_misc_dev(struct device *parent, struct miscdevice *misc)
>> +{
>> + int ret;
>> +
>> + ret = misc_register(misc);
>> + if (ret) {
>> + dev_err(parent, "misc device %s registering failed. errcode: %d\n",
>> + misc->name, ret);
>> + gna_devm_deregister_misc_dev(misc);
>> + } else {
>> + dev_dbg(parent, "device: %s registered\n",
>> + misc->name);
>
> You have loads of debugging in this driver still, is it really needed?
>
>> + }
>> +
>> + ret = devm_add_action(parent, gna_devm_deregister_misc_dev, misc);
>
> Why do you need this?
I'd like to avoid having gna_probe's fail path at all.
>
>
> thanks,
>
> greg k-h
Powered by blists - more mailing lists