Date: Sun, 8 Dec 2002 11:08:52 +0100 (CET) From: Michal Mertl <mime@traveller.cz> To: roger@freebsd.org, <current@freebsd.org> Subject: bktr(4) bufs plus patch Message-ID: <Pine.BSF.4.41.0212081046090.73179-200000@prg.traveller.cz>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
I found 2 bugs and some potential problems in bktr(4) code.
Bug 1:
Compilation with options BKTR_USE_FREEBSD_SMBUS failes. Error is
that code tries to use iicbus which isn't defined where it looks for
it. I added it there and the compilation and detection goes fine. I don't
know how to actually test it though.
Bug 2:
On module unload destroy_dev(9) is called on dev_alias which leads to
panic. According to MAKE_DEV(9) it's forbidden. The patch removes the code
to remove aliases. All seems to work fine.
Problem 1:
When using bktr(4) in a module, there's a helper module
bktr_mem, which allocates memory for bktr(4) devices. There is fixed limit
(#define BKTR_MEM_MAX_DEVICES 8 in bktr_mem.h) on number of devices
supported - it should at least be mentioned somewhere and possibly raised
- I have 16 devices and soon will be using more.
Problem 2:
There's another limit on number of bktr(4) devices in device creation
on lines 443-448 in bktr_os.c.
bktr->bktrdev = make_dev(&bktr_cdevsw, unit,
0, 0, 0444, "bktr%d", unit);
bktr->tunerdev= make_dev(&bktr_cdevsw, unit+16,
0, 0, 0444, "tuner%d", unit);
bktr->vbidev = make_dev(&bktr_cdevsw, unit+32,
0, 0, 0444, "vbi%d" , unit);
If I read the code right it seems to limit the maximum number of devices
to 16. I don't see why it can't be much more here - say 256 (so change +16
to +256 and +32 to +512. In DEVFS world users should care about
majors/minors but with normal /dev it could be problem.
Problem 3: (affacting mainly STABLE)
In MAKEDEV there's only one char allowed so one can create only 10
devices. Patch could look like this:
*** MAKEDEV.ori Sun Dec 8 11:02:38 2002
--- MAKEDEV Sun Dec 8 11:07:01 2002
***************
*** 1552,1559 ****
chmod 444 meteor$unit
;;
! bktr?)
unit=`expr $i : 'bktr\(.*\)'`
mknod bktr$unit c 92 `unit2minor $unit`
mknod tuner$unit c 92 `unit2minor $((16 + $unit))`
mknod vbi$unit c 92 `unit2minor $((32 + $unit))`
--- 1552,1562 ----
chmod 444 meteor$unit
;;
! bktr*)
unit=`expr $i : 'bktr\(.*\)'`
+ if [ ${unit} -lt 0 -o ${unit} -gt 15 ]; then
+ die 3 "bktr(4) unit limited to 0-15"
+ fi
mknod bktr$unit c 92 `unit2minor $unit`
mknod tuner$unit c 92 `unit2minor $((16 + $unit))`
mknod vbi$unit c 92 `unit2minor $((32 + $unit))`
--
Michal Mertl
mime@traveller.cz
[-- Attachment #2 --]
*** dev/bktr/bktr_reg.h.ori Sun Dec 8 10:40:14 2002
--- dev/bktr/bktr_reg.h Sun Dec 8 10:40:38 2002
***************
*** 448,453 ****
--- 448,454 ----
struct bktr_i2c_softc {
int bus_owned;
+ device_t iicbus;
device_t iicbb;
device_t smbus;
};
*** dev/bktr/bktr_os.c.ori Sun Dec 8 10:39:13 2002
--- dev/bktr/bktr_os.c Sun Dec 8 10:39:35 2002
***************
*** 499,513 ****
destroy_dev(bktr->tunerdev);
destroy_dev(bktr->bktrdev);
- /* If this is unit 0, then destroy the alias entries too */
- #if (__FreeBSD_version >=500000)
- if (unit == 0) {
- destroy_dev(bktr->vbidev_alias);
- destroy_dev(bktr->tunerdev_alias);
- destroy_dev(bktr->bktrdev_alias);
- }
- #endif
-
/*
* Deallocate resources.
*/
--- 499,504 ----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.41.0212081046090.73179-200000>
