[cpia] USB anyone?
sbertin@mindspring.com
sbertin@mindspring.com
Thu, 20 Jan 2000 22:29:17 -0500 (EST)
On 20 Jan, Jochen Scharrlach wrote:
> Ok, let's get back to the array-problem:
It looks like you have a good plan, but I have a few suggestions:
Keep the pointer to the list head in the high level driver, otherwise
you end up with a list in each lowlevel driver. This will require
keeping track of which lowlevel driver is responsible for the camera.
struct cam_lowlevel {
int type; /* CPIA_TYPE_PP or CPIA_TYPE_USB */
};
struct cam_data {
struct cam_data **previous;
struct cam_data *next;
struct cam_lowlevel *lowlevel;
[...]
};
Because we are using a pointer, there is no need for more detail. Each
lowlevel driver will have a structure that starts with the type. A
typecast from struct cam_lowlevel * to the actual type will be needed in
the lowlevel driver. This is somewhat like the way struct sockaddr is
handled.
cam_list_add and cam_list_remove could be functions provided by the high
level driver. cam_unregister should be handled in each lowlevel driver.
(Can you tell I don't like macros used as functions.)
[ code snipped ]
Nice cpia_close implementation. I like it :)
> Yes, the kernel_(un)lock is missing - did you use it only to protect
> the array operations or are there other critical parts?
That's what it was there for, but I just realized that we probably need
a lock around the if(--cam->open_count == 0) block to prevent an open of
the camera before the cleanup is complete.
Scott J. Bertin
sbertin@mindspring.com