RE: [PATCH 17/26] staging: comedi: ni_labpc: only allocate necessary subdevices

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

 



On Thursday, March 21, 2013 3:46 AM, Ian Abbott wrote:
> On 2013-03-20 15:50, H Hartley Sweeten wrote:
>> On Wednesday, March 20, 2013 4:46 AM, Ian Abbott wrote:
>>> On 2013-03-20 01:07, H Hartley Sweeten wrote:
>>>> Each comedi_subdevice uses one of the minors allocated to the
>>>> comedi subsystem. The devices used with this driver need a minimum
>>>> of 2 and a maximum of 5 subdevices.
>>>>
>>>> Only allocate and initialize the number of subdevices actually needed
>>>> by the device.
>>>
>>> This will break user-space code using one of these devices that assume
>>> the previous subdevice numbers are still valid.
>>
>> Fair enough. I'll drop this piece.
>>
>> But, it seems like a waste to allocate the space for the unused subdevices and
>> waste the minors. I'm not sure how much space each struct comedi_subevice
>> takes but they probably add up.
>
> It would be possible to add a layer of indirection to effectively pack 
> the unused subdevices, although that would increase the overhead for 
> used subdevices and complicate the code.  Probably not worth it.

No, not worth it. It will just add additional complexity and probably end up
being a maintenance nightmare.

To be fair, userspace should probably not depend on a given subdevice
type being located at a number. That's what the ->type is for...

> The subdevice minors are allocated dynamically to those subdevices that 
> support asynchronous commands, so unused subdevices won't waste the minors.

Ah, overlooked that. Only the dev->read_subdev and dev->write_subdev get
an additional minor allocated. But, we still waste the memory that is allocated
for the unused comedi_subdevice.

Regardless, I have dropped this piece of the series.

Regards,
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