Re: [PATCH v1 12/12] gna: add a char device

From: Greg Kroah-Hartman
Date: Tue Feb 16 2021 - 12:49:43 EST


On Tue, Feb 16, 2021 at 05:05:25PM +0100, Maciej Kwapulinski wrote:
> +static inline struct gna_private *inode_to_gna(struct inode *inode)
> +{
> + return container_of(inode->i_cdev, struct gna_private, cdev);
> +}
> +
> +static int gna_open(struct inode *inode, struct file *f)
> +{
> + struct gna_file_private *file_priv;
> + struct gna_private *gna_priv;
> +
> + gna_priv = inode_to_gna(inode);
> + if (!gna_priv)
> + return -ENODEV;

Why are you testing for things that is impossible to ever happen?

Please go read your own function for proof...

{sigh}

greg k-h