Deleted Added
full compact
if_ic.c (121816) if_ic.c (123922)
1/*-
2 * Copyright (c) 1998, 2001 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998, 2001 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/iicbus/if_ic.c 121816 2003-10-31 18:32:15Z brooks $");
28__FBSDID("$FreeBSD: head/sys/dev/iicbus/if_ic.c 123922 2003-12-28 03:56:00Z sam $");
29
30/*
31 * I2C bus IP driver
32 */
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/mbuf.h>

--- 24 unchanged lines hidden (view full) ---

61
62#include <dev/iicbus/iiconf.h>
63#include <dev/iicbus/iicbus.h>
64
65#include "iicbus_if.h"
66
67#define PCF_MASTER_ADDRESS 0xaa
68
29
30/*
31 * I2C bus IP driver
32 */
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/mbuf.h>

--- 24 unchanged lines hidden (view full) ---

61
62#include <dev/iicbus/iiconf.h>
63#include <dev/iicbus/iicbus.h>
64
65#include "iicbus_if.h"
66
67#define PCF_MASTER_ADDRESS 0xaa
68
69#define ICHDRLEN sizeof(u_int)
69#define ICHDRLEN sizeof(u_int32_t)
70#define ICMTU 1500 /* default mtu */
71
72struct ic_softc {
73 struct ifnet ic_if;
74
75 u_char ic_addr; /* peer I2C address */
76
77 int ic_sending;

--- 286 unchanged lines hidden (view full) ---

364{
365 device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit);
366 device_t parent = device_get_parent(icdev);
367 struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev);
368
369 int s, len, sent;
370 struct mbuf *mm;
371 u_char *cp;
70#define ICMTU 1500 /* default mtu */
71
72struct ic_softc {
73 struct ifnet ic_if;
74
75 u_char ic_addr; /* peer I2C address */
76
77 int ic_sending;

--- 286 unchanged lines hidden (view full) ---

364{
365 device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit);
366 device_t parent = device_get_parent(icdev);
367 struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev);
368
369 int s, len, sent;
370 struct mbuf *mm;
371 u_char *cp;
372 u_int hdr = dst->sa_family;
372 u_int32_t hdr = dst->sa_family;
373
374 ifp->if_flags |= IFF_RUNNING;
375
376 s = splhigh();
377
378 /* already sending? */
379 if (sc->ic_sending) {
380 ifp->if_oerrors ++;

--- 14 unchanged lines hidden (view full) ---

395 }
396
397 bcopy(mtod(mm,char *), cp, mm->m_len);
398 cp += mm->m_len;
399 len += mm->m_len;
400
401 } while ((mm = mm->m_next));
402
373
374 ifp->if_flags |= IFF_RUNNING;
375
376 s = splhigh();
377
378 /* already sending? */
379 if (sc->ic_sending) {
380 ifp->if_oerrors ++;

--- 14 unchanged lines hidden (view full) ---

395 }
396
397 bcopy(mtod(mm,char *), cp, mm->m_len);
398 cp += mm->m_len;
399 len += mm->m_len;
400
401 } while ((mm = mm->m_next));
402
403 if (ifp->if_bpf) {
404 struct mbuf m0, *n = m;
403 BPF_MTAP2(ifp, &hdr, sizeof(hdr), m);
405
404
406 /*
407 * We need to prepend the address family as
408 * a four byte field. Cons up a dummy header
409 * to pacify bpf. This is safe because bpf
410 * will only read from the mbuf (i.e., it won't
411 * try to free it or keep a pointer a to it).
412 */
413 m0.m_next = m;
414 m0.m_len = sizeof(u_int);
415 m0.m_data = (char *)&hdr;
416 n = &m0;
417
418 BPF_MTAP(ifp, n);
419 }
420
421 sc->ic_sending = 1;
422
423 m_freem(m);
424 splx(s);
425
426 /* send the packet */
427 if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf,
428 len + ICHDRLEN, &sent))

--- 21 unchanged lines hidden ---
405 sc->ic_sending = 1;
406
407 m_freem(m);
408 splx(s);
409
410 /* send the packet */
411 if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf,
412 len + ICHDRLEN, &sent))

--- 21 unchanged lines hidden ---