Date: Mon, 13 Aug 2018 19:00:43 +0000 (UTC) From: Vladimir Kondratyev <wulf@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337720 - in head/sys: arm/broadcom/bcm2835 dev/atkbdc dev/evdev dev/usb/input Message-ID: <201808131900.w7DJ0hWk016899@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: wulf Date: Mon Aug 13 19:00:42 2018 New Revision: 337720 URL: https://svnweb.freebsd.org/changeset/base/337720 Log: evdev: remove soft context from evdev methods parameter list. Now softc should be retrieved from struct edvev * pointer with evdev_get_softc() helper. wmt(4) is a sample of driver that support both KPI. Reviewed by: hselasky, gonzo Differential Revision: https://reviews.freebsd.org/D16614 Modified: head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c head/sys/dev/atkbdc/psm.c head/sys/dev/evdev/cdev.c head/sys/dev/evdev/evdev.c head/sys/dev/evdev/evdev.h head/sys/dev/evdev/evdev_utils.c head/sys/dev/evdev/uinput.c head/sys/dev/usb/input/uep.c head/sys/dev/usb/input/ums.c head/sys/dev/usb/input/wmt.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c Mon Aug 13 19:00:42 2018 (r337720) @@ -172,20 +172,22 @@ out: callout_reset(&sc->sc_callout, sc->sc_tick, ft5406ts_callout, sc); } -static void -ft5406ts_ev_close(struct evdev_dev *evdev, void *data) +static int +ft5406ts_ev_close(struct evdev_dev *evdev) { - struct ft5406ts_softc *sc = (struct ft5406ts_softc *)data; + struct ft5406ts_softc *sc = evdev_get_softc(evdev); FT5406_LOCK_ASSERT(sc); callout_stop(&sc->sc_callout); + + return (0); } static int -ft5406ts_ev_open(struct evdev_dev *evdev, void *data) +ft5406ts_ev_open(struct evdev_dev *evdev) { - struct ft5406ts_softc *sc = (struct ft5406ts_softc *)data; + struct ft5406ts_softc *sc = evdev_get_softc(evdev); FT5406_LOCK_ASSERT(sc); Modified: head/sys/dev/atkbdc/psm.c ============================================================================== --- head/sys/dev/atkbdc/psm.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/atkbdc/psm.c Mon Aug 13 19:00:42 2018 (r337720) @@ -2023,9 +2023,9 @@ psmdetach(device_t dev) #ifdef EVDEV_SUPPORT static int -psm_ev_open_r(struct evdev_dev *evdev, void *ev_softc) +psm_ev_open_r(struct evdev_dev *evdev) { - struct psm_softc *sc = (struct psm_softc *)ev_softc; + struct psm_softc *sc = evdev_get_softc(evdev); int err = 0; /* Get device data */ @@ -2043,24 +2043,27 @@ psm_ev_open_r(struct evdev_dev *evdev, void *ev_softc) return (err); } -static void -psm_ev_close_r(struct evdev_dev *evdev, void *ev_softc) +static int +psm_ev_close_r(struct evdev_dev *evdev) { - struct psm_softc *sc = (struct psm_softc *)ev_softc; + struct psm_softc *sc = evdev_get_softc(evdev); + int err = 0; sc->state &= ~PSM_EV_OPEN_R; if (sc->state & (PSM_OPEN | PSM_EV_OPEN_A)) - return; + return (0); if (sc->state & PSM_VALID) - psmclose(sc); + err = psmclose(sc); + + return (err); } static int -psm_ev_open_a(struct evdev_dev *evdev, void *ev_softc) +psm_ev_open_a(struct evdev_dev *evdev) { - struct psm_softc *sc = (struct psm_softc *)ev_softc; + struct psm_softc *sc = evdev_get_softc(evdev); int err = 0; /* Get device data */ @@ -2078,18 +2081,21 @@ psm_ev_open_a(struct evdev_dev *evdev, void *ev_softc) return (err); } -static void -psm_ev_close_a(struct evdev_dev *evdev, void *ev_softc) +static int +psm_ev_close_a(struct evdev_dev *evdev) { - struct psm_softc *sc = (struct psm_softc *)ev_softc; + struct psm_softc *sc = evdev_get_softc(evdev); + int err = 0; sc->state &= ~PSM_EV_OPEN_A; if (sc->state & (PSM_OPEN | PSM_EV_OPEN_R)) - return; + return (0); if (sc->state & PSM_VALID) - psmclose(sc); + err = psmclose(sc); + + return (err); } #endif Modified: head/sys/dev/evdev/cdev.c ============================================================================== --- head/sys/dev/evdev/cdev.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/evdev/cdev.c Mon Aug 13 19:00:42 2018 (r337720) @@ -419,7 +419,7 @@ evdev_ioctl(struct cdev *dev, u_long cmd, caddr_t data return (ENOTSUP); ke = (struct input_keymap_entry *)data; - evdev->ev_methods->ev_get_keycode(evdev, evdev->ev_softc, ke); + evdev->ev_methods->ev_get_keycode(evdev, ke); return (0); case EVIOCSKEYCODE: @@ -432,7 +432,7 @@ evdev_ioctl(struct cdev *dev, u_long cmd, caddr_t data return (ENOTSUP); ke = (struct input_keymap_entry *)data; - evdev->ev_methods->ev_set_keycode(evdev, evdev->ev_softc, ke); + evdev->ev_methods->ev_set_keycode(evdev, ke); return (0); case EVIOCGABS(0) ... EVIOCGABS(ABS_MAX): Modified: head/sys/dev/evdev/evdev.c ============================================================================== --- head/sys/dev/evdev/evdev.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/evdev/evdev.c Mon Aug 13 19:00:42 2018 (r337720) @@ -337,6 +337,13 @@ evdev_set_methods(struct evdev_dev *evdev, void *softc evdev->ev_softc = softc; } +inline void * +evdev_get_softc(struct evdev_dev *evdev) +{ + + return (evdev->ev_softc); +} + inline void evdev_support_prop(struct evdev_dev *evdev, uint16_t prop) { @@ -798,8 +805,7 @@ evdev_inject_event(struct evdev_dev *evdev, uint16_t t case EV_FF: if (evdev->ev_methods != NULL && evdev->ev_methods->ev_event != NULL) - evdev->ev_methods->ev_event(evdev, evdev->ev_softc, - type, code, value); + evdev->ev_methods->ev_event(evdev, type, code, value); /* * Leds and driver repeats should be reported in ev_event * method body to interoperate with kbdmux states and rates @@ -842,7 +848,7 @@ evdev_register_client(struct evdev_dev *evdev, struct evdev->ev_methods->ev_open != NULL) { debugf(evdev, "calling ev_open() on device %s", evdev->ev_shortname); - ret = evdev->ev_methods->ev_open(evdev, evdev->ev_softc); + ret = evdev->ev_methods->ev_open(evdev); } if (ret == 0) LIST_INSERT_HEAD(&evdev->ev_clients, client, ec_link); @@ -860,7 +866,7 @@ evdev_dispose_client(struct evdev_dev *evdev, struct e if (LIST_EMPTY(&evdev->ev_clients)) { if (evdev->ev_methods != NULL && evdev->ev_methods->ev_close != NULL) - evdev->ev_methods->ev_close(evdev, evdev->ev_softc); + (void)evdev->ev_methods->ev_close(evdev); if (evdev_event_supported(evdev, EV_REP) && bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) evdev_stop_repeat(evdev); Modified: head/sys/dev/evdev/evdev.h ============================================================================== --- head/sys/dev/evdev/evdev.h Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/evdev/evdev.h Mon Aug 13 19:00:42 2018 (r337720) @@ -38,11 +38,10 @@ struct evdev_dev; -typedef int (evdev_open_t)(struct evdev_dev *, void *); -typedef void (evdev_close_t)(struct evdev_dev *, void *); -typedef void (evdev_event_t)(struct evdev_dev *, void *, uint16_t, - uint16_t, int32_t); -typedef void (evdev_keycode_t)(struct evdev_dev *, void *, +typedef int (evdev_open_t)(struct evdev_dev *); +typedef int (evdev_close_t)(struct evdev_dev *); +typedef void (evdev_event_t)(struct evdev_dev *, uint16_t, uint16_t, int32_t); +typedef void (evdev_keycode_t)(struct evdev_dev *, struct input_keymap_entry *); /* @@ -126,6 +125,7 @@ void evdev_support_sw(struct evdev_dev *, uint16_t); void evdev_set_repeat_params(struct evdev_dev *, uint16_t, int); int evdev_set_report_size(struct evdev_dev *, size_t); void evdev_set_flag(struct evdev_dev *, uint16_t); +void *evdev_get_softc(struct evdev_dev *); /* Multitouch related functions: */ int32_t evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); Modified: head/sys/dev/evdev/evdev_utils.c ============================================================================== --- head/sys/dev/evdev/evdev_utils.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/evdev/evdev_utils.c Mon Aug 13 19:00:42 2018 (r337720) @@ -301,10 +301,10 @@ evdev_push_repeats(struct evdev_dev *evdev, keyboard_t } void -evdev_ev_kbd_event(struct evdev_dev *evdev, void *softc, uint16_t type, - uint16_t code, int32_t value) +evdev_ev_kbd_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, + int32_t value) { - keyboard_t *kbd = (keyboard_t *)softc; + keyboard_t *kbd = (keyboard_t *)evdev_get_softc(evdev); int delay[2], leds, oleds; size_t i; Modified: head/sys/dev/evdev/uinput.c ============================================================================== --- head/sys/dev/evdev/uinput.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/evdev/uinput.c Mon Aug 13 19:00:42 2018 (r337720) @@ -159,10 +159,10 @@ uinput_knl_assert_unlocked(void *arg) } static void -uinput_ev_event(struct evdev_dev *evdev, void *softc, uint16_t type, - uint16_t code, int32_t value) +uinput_ev_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, + int32_t value) { - struct uinput_cdev_state *state = softc; + struct uinput_cdev_state *state = evdev_get_softc(evdev); if (type == EV_LED) evdev_push_event(evdev, type, code, value); Modified: head/sys/dev/usb/input/uep.c ============================================================================== --- head/sys/dev/usb/input/uep.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/usb/input/uep.c Mon Aug 13 19:00:42 2018 (r337720) @@ -430,19 +430,21 @@ uep_detach(device_t dev) #ifdef EVDEV_SUPPORT -static void -uep_ev_close(struct evdev_dev *evdev, void *ev_softc) +static int +uep_ev_close(struct evdev_dev *evdev) { - struct uep_softc *sc = (struct uep_softc *)ev_softc; + struct uep_softc *sc = evdev_get_softc(evdev); mtx_assert(&sc->mtx, MA_OWNED); usbd_transfer_stop(sc->xfer[UEP_INTR_DT]); + + return (0); } static int -uep_ev_open(struct evdev_dev *evdev, void *ev_softc) +uep_ev_open(struct evdev_dev *evdev) { - struct uep_softc *sc = (struct uep_softc *)ev_softc; + struct uep_softc *sc = evdev_get_softc(evdev); mtx_assert(&sc->mtx, MA_OWNED); usbd_transfer_start(sc->xfer[UEP_INTR_DT]); Modified: head/sys/dev/usb/input/ums.c ============================================================================== --- head/sys/dev/usb/input/ums.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/usb/input/ums.c Mon Aug 13 19:00:42 2018 (r337720) @@ -950,9 +950,9 @@ ums_reset_buf(struct ums_softc *sc) #ifdef EVDEV_SUPPORT static int -ums_ev_open(struct evdev_dev *evdev, void *ev_softc) +ums_ev_open(struct evdev_dev *evdev) { - struct ums_softc *sc = (struct ums_softc *)ev_softc; + struct ums_softc *sc = evdev_get_softc(evdev); mtx_assert(&sc->sc_mtx, MA_OWNED); @@ -966,10 +966,10 @@ ums_ev_open(struct evdev_dev *evdev, void *ev_softc) return (0); } -static void -ums_ev_close(struct evdev_dev *evdev, void *ev_softc) +static int +ums_ev_close(struct evdev_dev *evdev) { - struct ums_softc *sc = (struct ums_softc *)ev_softc; + struct ums_softc *sc = evdev_get_softc(evdev); mtx_assert(&sc->sc_mtx, MA_OWNED); @@ -977,6 +977,8 @@ ums_ev_close(struct evdev_dev *evdev, void *ev_softc) if (sc->sc_fflags == 0) ums_stop_rx(sc); + + return (0); } #endif Modified: head/sys/dev/usb/input/wmt.c ============================================================================== --- head/sys/dev/usb/input/wmt.c Mon Aug 13 18:53:14 2018 (r337719) +++ head/sys/dev/usb/input/wmt.c Mon Aug 13 19:00:42 2018 (r337720) @@ -226,12 +226,22 @@ static device_probe_t wmt_probe; static device_attach_t wmt_attach; static device_detach_t wmt_detach; +#if __FreeBSD_version >= 1200077 static evdev_open_t wmt_ev_open; static evdev_close_t wmt_ev_close; +#else +static evdev_open_t wmt_ev_open_11; +static evdev_close_t wmt_ev_close_11; +#endif static const struct evdev_methods wmt_evdev_methods = { +#if __FreeBSD_version >= 1200077 .ev_open = &wmt_ev_open, .ev_close = &wmt_ev_close, +#else + .ev_open = &wmt_ev_open_11, + .ev_close = &wmt_ev_close_11, +#endif }; static const struct usb_config wmt_config[WMT_N_TRANSFER] = { @@ -525,24 +535,45 @@ tr_setup: } static void -wmt_ev_close(struct evdev_dev *evdev, void *ev_softc) +wmt_ev_close_11(struct evdev_dev *evdev, void *ev_softc) { - struct wmt_softc *sc = (struct wmt_softc *)ev_softc; + struct wmt_softc *sc = ev_softc; mtx_assert(&sc->mtx, MA_OWNED); usbd_transfer_stop(sc->xfer[WMT_INTR_DT]); } static int -wmt_ev_open(struct evdev_dev *evdev, void *ev_softc) +wmt_ev_open_11(struct evdev_dev *evdev, void *ev_softc) { - struct wmt_softc *sc = (struct wmt_softc *)ev_softc; + struct wmt_softc *sc = ev_softc; mtx_assert(&sc->mtx, MA_OWNED); usbd_transfer_start(sc->xfer[WMT_INTR_DT]); return (0); } + +#if __FreeBSD_version >= 1200077 +static int +wmt_ev_close(struct evdev_dev *evdev) +{ + struct wmt_softc *sc = evdev_get_softc(evdev); + + wmt_ev_close_11(evdev, sc); + + return (0); +} + +static int +wmt_ev_open(struct evdev_dev *evdev) +{ + struct wmt_softc *sc = evdev_get_softc(evdev); + + return (wmt_ev_open_11(evdev, sc)); + +} +#endif /* port of userland hid_report_size() from usbhid(3) to kernel */ static int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808131900.w7DJ0hWk016899>