RE: [PATCH v2] staging: comedi: drivers: let core handle freeing s->private

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

 



On Tuesday, June 11, 2013 3:53 AM, Ian Abbott wrote:
> On 2013-06-11 01:58, H Hartley Sweeten wrote:
>> Introduce a new subdevice flag, SDF_FREE_SPRIV, to allow the comedi
>> core to automatically free the subdevice private data during the
>> cleanup_device() stage of the detach.
>
> This is an implementation detail that should really be hidden from 
> userspace.  With this patch it is exposed through the 'subd_flags' 
> member of 'struct comedi_subdinfo'.  That can easily be fixed by masking 
> out the 'SDF_FREE_SPRIV' flag when setting 'us->subd_flags' in 
> 'do_subdinfo_ioctl()'.  Ideally, 'SDF_FREE_SPRIV' shouldn't appear in 
> "comedi.h" at all as should be of no interest to userspace.

I agree, but I couldn't find a clean place to put the flag.

> As we're running out of SDF_ values, we might want to reassign the 
> current 'SDF_FREE_SPRIV' value to some other user-visible meaning at a 
> later date.
>
> We could put the internal flags in a different member of 'struct 
> comedi_subdevice'; either define a new member or abuse the existing 
> 'runflags' member.  (A new member could be placed in a 32-bit hole in 
> the structure for 64-bit kernels, so would only use extra space for 
> 32-bit kernels.)  (There are various members of 'struct 
> comedi_subdevice' that could be stripped out to save space if necessary, 
> such as 'settling_time_0', 'flags' and 'flaglist'.  These were intended 
> to pass various details from drivers to userspace but none of the 
> existing drivers actually set them.)

I'll move the new flag to the 'runflags' as:

	SRF_FREE_SPRIV = 0x80000000,

Note, the 'runflags' are normally accessed using the static helper functions
comedi_{set,get}_subdevice_runflags() in comedi_fops.c and protected
by the s->spin_lock. Since this flag is only used during the attach/detach
I don't think the spinlock is needed. This avoids needing to expose the
Helpers.

I'll post an update shortly.

Thanks,
Hartley

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/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