Date: Sun, 20 Aug 2000 17:48:28 +0900 From: Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org> To: sanpei@sanpei.org Cc: mobile@FreeBSD.org Subject: Re: [PCCARD,PATCH] IOC_GET_RESOURCE_RANGE patch Message-ID: <20000820174828I.iwasaki@jp.FreeBSD.org> In-Reply-To: <200008200445.e7K4jp402239@lavender.sanpei.org> References: <200008200445.e7K4jp402239@lavender.sanpei.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> I created experimental IOC_GET_RESOURCE_RANGE(but rename
> PIOCSRESOURCE) ioctl code in sys/pccard which was suggested by
> Warner-san. With below patch we could read free ioport/irq/memory
> resources from userland programs.
Great! I thought it should be done by adding new API to resource manager
(in subr_rman.c ?) in order to obtain available resource range but
try & error method also seems just enough for OLDCARD :-)
BTW, I have few things to suggest.
> + struct pccard_devinfo *devi;
[snip]
> + case PIOCSRESOURCE: /* sanpei */
> + pr = (struct pccard_resource *)data;
> + pr->resource_addr = ~0ul;
> + pccarddev = devclass_get_device(pccard_devclass, 0);
> + MALLOC(devi, struct pccard_devinfo *, sizeof(*devi), M_DEVBUF, M_WAITOK);
Do we need to malloc for pccard_devinfo dynamically? Also it seems
there is a memory leakage bug here. Auto variable just enough for
this I think.
> + strcpy(devi->name, "ed");
Why "ed" ? I think this is a dummy driver name so "pccard" or "null" would be
suitable rather than "ed", it's not big deal though, I could be wrong :-)
> + if (!err) {
> + r = bus_alloc_resource(child, pr->type, &rid, 0ul, ~0ul, pr->size, RF_ACTIVE);
Maybe we don't need activate the resource actually here, just give 0 as
flag instead of RF_ACTIVE.
> + default:
> + return EINVAL;
I prefer that this kind of error checking comes first, it's not big
deal though too.
Thanks
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000820174828I.iwasaki>
