Re: agp(4): agpmmap fix

2012-11-13 Thread Mark Kettenis
> Date: Tue, 13 Nov 2012 11:55:07 +0100
> From: Martin Pieuchot 
> 
> After loosing some hairs trying to figure out where I screw up in
> mmaping the AGP aperture, here's a trivial fix.
> 
> Diff below corrects the first argument of the agpmmap() function that
> should be a dev_t and not a pointer to the driver's descriptor.

ok kettenis@ if you fix the spaces vs. tab issue.

> Index: agp.c
> ===
> RCS file: /cvs/src/sys/dev/pci/agp.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 agp.c
> --- agp.c 26 Dec 2010 15:41:00 -  1.34
> +++ agp.c 12 Nov 2012 18:20:48 -
> @@ -60,7 +60,7 @@ int agp_generic_free_memory(struct agp_s
>  void agp_attach(struct device *, struct device *, void *);
>  int  agp_probe(struct device *, void *, void *);
>  int  agpbusprint(void *, const char *);
> -paddr_t  agpmmap(void *, off_t, int);
> +paddr_t  agpmmap(dev_t, off_t, int);
>  int  agpioctl(dev_t, u_long, caddr_t, int, struct proc *);
>  int  agpopen(dev_t, int, int, struct proc *);
>  int  agpclose(dev_t, int, int , struct proc *);
> @@ -206,9 +206,12 @@ struct cfdriver agp_cd = {
>  };
>  
>  paddr_t
> -agpmmap(void *v, off_t off, int prot)
> +agpmmap(dev_t dev, off_t off, int prot)
>  {
> - struct agp_softc* sc = (struct agp_softc *)v;
> + struct agp_softc *sc = agp_find_device(AGPUNIT(dev));
> +
> +if (sc == NULL || sc->sc_chipc == NULL)
> +return (-1);
>  
>   if (sc->sc_apaddr) {



agp(4): agpmmap fix

2012-11-13 Thread Martin Pieuchot
After loosing some hairs trying to figure out where I screw up in
mmaping the AGP aperture, here's a trivial fix.

Diff below corrects the first argument of the agpmmap() function that
should be a dev_t and not a pointer to the driver's descriptor.

Ok?

Index: agp.c
===
RCS file: /cvs/src/sys/dev/pci/agp.c,v
retrieving revision 1.34
diff -u -p -r1.34 agp.c
--- agp.c   26 Dec 2010 15:41:00 -  1.34
+++ agp.c   12 Nov 2012 18:20:48 -
@@ -60,7 +60,7 @@ int   agp_generic_free_memory(struct agp_s
 void   agp_attach(struct device *, struct device *, void *);
 intagp_probe(struct device *, void *, void *);
 intagpbusprint(void *, const char *);
-paddr_tagpmmap(void *, off_t, int);
+paddr_tagpmmap(dev_t, off_t, int);
 intagpioctl(dev_t, u_long, caddr_t, int, struct proc *);
 intagpopen(dev_t, int, int, struct proc *);
 intagpclose(dev_t, int, int , struct proc *);
@@ -206,9 +206,12 @@ struct cfdriver agp_cd = {
 };
 
 paddr_t
-agpmmap(void *v, off_t off, int prot)
+agpmmap(dev_t dev, off_t off, int prot)
 {
-   struct agp_softc* sc = (struct agp_softc *)v;
+   struct agp_softc *sc = agp_find_device(AGPUNIT(dev));
+
+if (sc == NULL || sc->sc_chipc == NULL)
+return (-1);
 
if (sc->sc_apaddr) {