예제 #1
0
static int
au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
{
	struct i2c_au1550_data *adap = i2c_adap->algo_data;
	struct i2c_msg *p;
	int i, err = 0;

	WR(adap, PSC_CTRL, PSC_CTRL_ENABLE);

	for (i = 0; !err && i < num; i++) {
		p = &msgs[i];
		err = do_address(adap, p->addr, p->flags & I2C_M_RD,
				 (p->len == 0));
		if (err || !p->len)
			continue;
		if (p->flags & I2C_M_RD)
			err = i2c_read(adap, p->buf, p->len);
		else
			err = i2c_write(adap, p->buf, p->len);
	}

	/* Return the number of messages processed, or the error code.
	*/
	if (err == 0)
		err = num;

	WR(adap, PSC_CTRL, PSC_CTRL_SUSPEND);

	return err;
}
예제 #2
0
static int
au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
{
	struct i2c_au1550_data *adap = i2c_adap->algo_data;
	volatile psc_smb_t *sp = (volatile psc_smb_t *)adap->psc_base;
	struct i2c_msg *p;
	int i, err = 0;

	sp->psc_ctrl = PSC_CTRL_ENABLE;
	au_sync();

	for (i = 0; !err && i < num; i++) {
		p = &msgs[i];
		err = do_address(adap, p->addr, p->flags & I2C_M_RD,
				 (p->len == 0));
		if (err || !p->len)
			continue;
		if (p->flags & I2C_M_RD)
			err = i2c_read(adap, p->buf, p->len);
		else
			err = i2c_write(adap, p->buf, p->len);
	}

	
	if (err == 0)
		err = num;

	sp->psc_ctrl = PSC_CTRL_SUSPEND;
	au_sync();

	return err;
}
예제 #3
0
int add_address (const char *ifname, struct in_addr address,
                 struct in_addr netmask, struct in_addr broadcast)
{
    logger (LOG_INFO, "adding IP address %s/%d",
            inet_ntoa (address), inet_ntocidr (netmask));

    return (do_address (ifname, address, netmask, broadcast, 0));
}
예제 #4
0
int del_address (const char *ifname, struct in_addr address)
{
  logger (LOG_INFO, "deleting IP address %s", inet_ntoa (address));

  struct in_addr t;
  memset (&t, 0, sizeof (t));
  return (do_address (ifname, address, t, t, 1));
}
예제 #5
0
static void do_address_str(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx)
{
    wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr;
    p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx;

    do_address(addr, tvb_string, actx);

    if (ctx && ctx->do_address && ddatype && tvb_string)
        wmem_strbuf_append(ddatype, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string)));
}
예제 #6
0
int add_address (const char *ifname, struct in_addr address,
		 struct in_addr netmask, struct in_addr broadcast)
{
  char *daddress = strdup (inet_ntoa (address));
  logger (LOG_INFO, "adding IP address %s netmask %s",
	  daddress, inet_ntoa (netmask));
  free (daddress);

  return (do_address (ifname, address, netmask, broadcast, 0));
}
예제 #7
0
int del_address (const char *ifname,
                 struct in_addr address, struct in_addr netmask)
{
    struct in_addr t;

    logger (LOG_INFO, "deleting IP address %s/%d",
            inet_ntoa (address), inet_ntocidr (netmask));

    memset (&t, 0, sizeof (t));
    return (do_address (ifname, address, netmask, t, 1));
}
예제 #8
0
static void do_address_str_tree(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx, proto_tree* tree)
{
    wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr;
    p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx;

    do_address(addr, tvb_string, actx);

    if (ctx && ctx->do_address && tvb_string && ddatype) {
        if (wmem_strbuf_get_len(ddatype) > 0) {
            proto_item_append_text (tree, " (%s=%s)", wmem_strbuf_get_str(ddatype), tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string)));
        }
    }
}
예제 #9
0
static int
platform_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
{
	struct i2c_platform_data *adap = i2c_adap->algo_data;
	struct i2c_msg *p;
	int i, err = 0;

	pr_debug("platform_xfer\n");
	for (i = 0; i < num; i++) {
#define __BUFSIZE 80
		int ii;
		static char buf[__BUFSIZE];
		char *b = buf;

		p = &msgs[i];
		b += sprintf(buf, " [%d bytes]", p->len);
		if ((p->flags & I2C_M_RD) == 0) {
			for (ii = 0; ii < p->len; ii++) {
				if (b < &buf[__BUFSIZE-4]) {
					b += sprintf(b, " %02x", p->buf[ii]);
				} else {
					strcat(b, "...");
					break;
				}
			}
		}
		pr_debug("xfer%d: DevAddr: %04x Op:%s Data:%s\n", i, p->addr,
			 (p->flags & I2C_M_RD) ? "Rd" : "Wr", buf);
	}


	for (i = 0; !err && i < num; i++) {
		p = &msgs[i];
		err = do_address(adap, p->addr, p->flags & I2C_M_RD);
		if (err || !p->len)
			continue;
		if (p->flags & I2C_M_RD)
			err = i2c_read(adap, p->buf, p->len);
		else
			err = i2c_write(adap, p->buf, p->len);
	}

	/* Return the number of messages processed, or the error code. */
	if (err == 0)
		err = num;

	return err;
}
예제 #10
0
파일: i2c-algo-sgi.c 프로젝트: 274914765/C
static int sgi_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,
            int num)
{
    struct i2c_algo_sgi_data *adap = i2c_adap->algo_data;
    struct i2c_msg *p;
    int i, err = 0;

    for (i = 0; !err && i < num; i++) {
        p = &msgs[i];
        err = do_address(adap, p->addr, p->flags & I2C_M_RD);
        if (err || !p->len)
            continue;
        if (p->flags & I2C_M_RD)
            err = i2c_read(adap, p->buf, p->len);
        else
            err = i2c_write(adap, p->buf, p->len);
    }

    return (err < 0) ? err : i;
}