[cpia] patch for cpia_pp.c - free_dma was missing and some comments on the '10 10'

Peter Pregler Peter.Pregler@risc.uni-linz.ac.at
Sun, 05 Mar 2000 23:08:25 +0100 (CET)


This message is in MIME format
--_=XFMail.1.4.4.Linux:20000305230825:1773=_
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

I think I have found the reason for the oopses _I_ encountered. Apparently
during the restructure of the init-process to adapt for usb the DMA-ifdef t=
hat
freed the registered DMA vanished in cpia_pp.c. This leads to very strange
oopses if one tries to load cpia_pp twice. I have attached the patch.  This
should solve problems of the sort 'cannot reload cpia_pp if dma was used'.

I don't think it is a solution for the '10 10 10 ...' problem. Actually, I =
am
not able to reproduce that one. I think I have to fetch a new 2.3-kernel fi=
rst.
The problem must be in reset_camera, the first goto_low_power at the beginn=
ing
of the function. Could someone with a not-working camera play around with t=
hat
initalisation ('see the trial-and-error comment') a bit. The developers gui=
de
does say nothing about what to do if we read '10 10'-garbage from the camer=
a.

As for the segfault I got in the '10 10'-case I think I have found the reas=
on.
Can anyone comment about the following change of return values. The functio=
n in
question is cpia_register_camera. Someone changed the return values ENXIO
(maybe EIO would have been better) to success??? Here is 0.5.0

        /* get version information from camera: open/reset/close */

        /* open cpia */
        if (camera[i]->ops->open(camera[i]->index, &camera[i]->lowlevel_dat=
a))
{                return -ENXIO;
        }
       =20
        /* reset the camera */
        if(reset_camera(camera[i]) !=3D 0) {
                camera[i]->ops->close(camera[i]->lowlevel_data);
                return -ENXIO;
        }

        /* close cpia */
        camera[i]->ops->close(camera[i]->lowlevel_data);

And here is the latest 0.7.3:

        /* get version information from camera: open/reset/close */

        /* open cpia */
        if (camera->ops->open(camera->lowlevel_data))
                return camera;
       =20
        /* reset the camera */
        if (reset_camera(camera) !=3D 0) {
                camera->ops->close(camera->lowlevel_data);
                return camera;
        }

        /* close cpia */
        camera->ops->close(camera->lowlevel_data);


If the open/reset of the camera fails there is not much reason to report
success. Actually I am pretty sure that is a road to hell, i.e. segmentatio=
n
faults and the like. IMHO the register of the device must fail if the
open/reset fails.

-Peter

-------------------------------
Even the thought that a ship was waiting to take him back to Earth
did not wipe out the sense of loss he felt at that moment.
-------------------------------
Email: Peter.Pregler@risc.uni-linz.ac.at
Peter Pregler / RISC, University of Linz, Austria

--_=XFMail.1.4.4.Linux:20000305230825:1773=_
Content-Disposition: attachment; filename="dma-free-patch"
Content-Description: dma-free-patch
Content-Type: text/plain;
 charset=iso-8859-1; name=dma-free-patch; SizeOnDisk=866
Content-Transfer-Encoding: base64

LS0tIGNwaWFfcHAuYy5vcmlnCVN1biBNYXIgIDUgMjI6Mjk6NTIgMjAwMAorKysgY3BpYV9wcC5j
CVN1biBNYXIgIDUgMjI6MjU6MjAgMjAwMApAQCAtMTUxNiw3ICsxNTE2LDcgQEAKIAkJY2FtLT5k
bWFfYnVmPWttYWxsb2MoRE1BX0JVRkZFUl9TSVpFLCBHRlBfRE1BKTsKIAkJaWYoY2FtLT5kbWFf
YnVmID09IE5VTEwpIHsKIAkJCWZyZWVfZG1hKGNhbS0+cGRldi0+cG9ydC0+ZG1hKTsKLQkJCUxP
RygiZmFpbGVkIHRvIGFsbG9jYXRlIGRtYSBidWZmZXIsIHVzaW5nIEZJRk8gbW9kZVxuIik7CisJ
CQlMT0coImZhaWxlZCB0byBhbGxvY2F0ZSBkbWEgYnVmZmVyLCB1c2luZyBQSU8gbW9kZVxuIik7
CiAJCX0gZWxzZSB7CiAJCQlpbml0X3dhaXRxdWV1ZSgmY2FtLT53cV9kbWEpOwogCQkJcHJpbnRr
KEtFUk5fSU5GTyAiICB1c2luZyBETUEgbW9kZSAoaXJxICVkLCBETUEgJWQpXG4iLCBwZGV2LT5w
b3J0LT5pcnEsIHBkZXYtPnBvcnQtPmRtYSk7CkBAIC0xNTUzLDYgKzE1NTMsMTMgQEAKIAkJaWYg
KGNhbSAmJiBjYW0tPnBvcnQtPm51bWJlciA9PSBwb3J0LT5udW1iZXIpIHsKIAkJCVJFTU9WRV9G
Uk9NX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