Re: [PATCH 2/2] staging: goldfish: cleanup in goldfish_audio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan,

> > +     struct goldfish_audio *audio = fp->private_data;
>
> I've never written a misc driver (or any substantial kernel code at all
> if I'm being honest.  :P) but I think fp->private_data is a pointer to
> &goldfish_audio_device.
>
> But then that wouldn't ever work, and how was this tested then???

I followed other parts in this driver:

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/drivers/staging/goldfish/goldfish_audio.c?h=v4.17.6#n118
static ssize_t goldfish_audio_read(struct file *fp, char __user *buf,
size_t count, loff_t *pos)
{
    struct goldfish_audio *data = fp->private_data;

I assumed it points where we want, otherwise yes, we would notice
this. I checked other drivers and they do use private_data for similar
purposes.
The thing I missed is they set private_data in open, e.g.:

struct scr24x_dev *dev = container_of(inode->i_cdev, struct scr24x_dev, c_dev);
filp->private_data = dev;

Unfortunately, I cannot figure out how to pass a pointer from probe to
open. probe in examples (scr24x_cs.c) calls cdev_init which I am not
sure if applicable here.
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux