On 02/09/13(Mon) 18:51, Stefan Sperling wrote: > On Mon, Sep 02, 2013 at 02:32:50PM +0200, Martin Pieuchot wrote: > > You might also rely on the fact that if you have a "sc->synaptics" > > already allocated to try harder. Because in this case you know > > that you have a synaptic touchpad. > > That works. Here's a simpler diff that fixes my issue, too.
I like it, I'd still prefer to introduce *_knock() function instead of duplicating the magic sequence, but if you prefer it this way, go for it. ok mpi@ either way. > Index: pms.c > =================================================================== > RCS file: /cvs/src/sys/dev/pckbc/pms.c,v > retrieving revision 1.45 > diff -u -p -r1.45 pms.c > --- pms.c 16 Jul 2013 08:11:39 -0000 1.45 > +++ pms.c 2 Sep 2013 16:44:48 -0000 > @@ -937,15 +937,38 @@ pms_enable_synaptics(struct pms_softc *s > struct synaptics_softc *syn = sc->synaptics; > struct wsmousedev_attach_args a; > u_char resp[3]; > - int mode; > + int mode, i; > > if (pms_set_resolution(sc, 0) || > pms_set_resolution(sc, 0) || > pms_set_resolution(sc, 0) || > pms_set_resolution(sc, 0) || > pms_get_status(sc, resp) || > - resp[1] != SYNAPTICS_ID_MAGIC) > - goto err; > + resp[1] != SYNAPTICS_ID_MAGIC) { > + if (sc->synaptics == NULL) > + goto err; > + /* > + * Some synaptics touchpads don't resume quickly. > + * Retry a few times. > + */ > + for (i = 10; i > 0; --i) { > + printf("%s: device not resuming, retrying\n", > + DEVNAME(sc)); > + pms_reset(sc); > + if (pms_set_resolution(sc, 0) || > + pms_set_resolution(sc, 0) || > + pms_set_resolution(sc, 0) || > + pms_set_resolution(sc, 0) || > + pms_get_status(sc, resp) || > + resp[1] == SYNAPTICS_ID_MAGIC) > + break; > + delay(100000); > + } > + if (i == 0) { > + printf("%s: lost device\n", DEVNAME(sc)); > + goto err; > + } > + } > > if (sc->synaptics == NULL) { > sc->synaptics = syn = malloc(sizeof(struct synaptics_softc), >