Re: [PATCH v3 12/14] intel_gna: add a 'misc' device

From: Greg Kroah-Hartman
Date: Thu May 13 2021 - 13:15:37 EST


On Thu, May 13, 2021 at 07:06:18PM +0200, Maciej Kwapulinski wrote:
>
> Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx>
> >> Tested-by: Savo Novakovic <savox.novakovic@xxxxxxxxx>
> >> ---
> >> 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

Then don't provide an open at all, and it will be fine :)

>
> >
> >> +
> >> +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.

Ah. That's not obvious :(