| 170 | } |
| 171 | |
| 172 | static int |
| 173 | ccp_attach(device_t dev) |
| 174 | { |
| 175 | struct ccp_softc *sc; |
| 176 | int error; |
| 177 | |
| 178 | sc = device_get_softc(dev); |
| 179 | sc->dev = dev; |
| 180 | |
| 181 | sc->cid = crypto_get_driverid(dev, sizeof(struct ccp_session), |
| 182 | CRYPTOCAP_F_HARDWARE); |
| 183 | if (sc->cid < 0) { |
| 184 | device_printf(dev, "could not get crypto driver id\n"); |
| 185 | return (ENXIO); |
| 186 | } |
| 187 | |
| 188 | error = ccp_hw_attach(dev); |
| 189 | if (error != 0) |
| 190 | return (error); |
| 191 | |
| 192 | mtx_init(&sc->lock, "ccp", NULL, MTX_DEF); |
| 193 | |
| 194 | ccp_initialize_queues(sc); |
| 195 | |
| 196 | if (g_ccp_softc == NULL) { |
| 197 | g_ccp_softc = sc; |
| 198 | if ((sc->hw_features & VERSION_CAP_TRNG) != 0) |
| 199 | random_source_register(&random_ccp); |
| 200 | } |
| 201 | |
| 202 | return (0); |
| 203 | } |
| 204 | |
| 205 | static int |
| 206 | ccp_detach(device_t dev) |
nothing calls this directly
no test coverage detected