From patchwork Tue Apr 7 02:06:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46802 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 162AA214BA for ; Tue, 7 Apr 2015 02:06:22 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf9186072lbb.0 for ; Mon, 06 Apr 2015 19:06:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=0TR9mGUDlgysdF9+dxH8Od7QnPyHN2FCEYYa4CMFJ08=; b=Kd7Y76OhDtfxihtEJegAbHVdtVbOIxVWx0avirF0lQvGIAyNFIAfghO7eqjjQ/EEEa zJJk6EZgPx9cynekrSXLb3xTPRV2B3dCFeqH/xhOwUFvIKiti9Ob6Moq551e7azenSZe TQzcxYKGE0rqJ6nlgCjXR1uKRw6hs/mGNuM4geXtUoNyasQWEZSjTzy+znXP62Wl/IsU OSlEhJa1hmWtpbFrWFS0jfHJBsvY7Xr3AYpDYfVEeQ2m49m0gtx43PsTn4ooFIssiGSV UUsI8N4LmrSwAKkejoRPybQGnMOAxFX4ApuYVvv7kuChyrJYO9GcupHjeX1qFNs7AdnP a4iQ== X-Gm-Message-State: ALoCoQlE5CCbzirClsb0O3uQjO6ryeF479J9rcBOJrz2CLhF1Xed4PK13zQvt4l+LfUgyJvRo6KS X-Received: by 10.194.178.67 with SMTP id cw3mr3685447wjc.2.1428372381084; Mon, 06 Apr 2015 19:06:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.33 with SMTP id ld1ls634639lac.11.gmail; Mon, 06 Apr 2015 19:06:20 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr1150258lbc.86.1428372380896; Mon, 06 Apr 2015 19:06:20 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id jv2si4783873lab.94.2015.04.06.19.06.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 19:06:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by layy10 with SMTP id y10so31830433lay.0 for ; Mon, 06 Apr 2015 19:06:20 -0700 (PDT) X-Received: by 10.112.8.101 with SMTP id q5mr16027658lba.19.1428372380436; Mon, 06 Apr 2015 19:06:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp147274lbt; Mon, 6 Apr 2015 19:06:19 -0700 (PDT) X-Received: by 10.68.139.37 with SMTP id qv5mr32595492pbb.23.1428372376644; Mon, 06 Apr 2015 19:06:16 -0700 (PDT) Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com. [209.85.192.169]) by mx.google.com with ESMTPS id c3si8990443pdd.179.2015.04.06.19.06.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 19:06:16 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.169 as permitted sender) client-ip=209.85.192.169; Received: by pdbqa5 with SMTP id qa5so5554820pdb.1 for ; Mon, 06 Apr 2015 19:06:15 -0700 (PDT) X-Received: by 10.67.4.230 with SMTP id ch6mr32003538pad.137.1428372375656; Mon, 06 Apr 2015 19:06:15 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id z6sm6068447pdp.77.2015.04.06.19.06.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Apr 2015 19:06:15 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: Alex Elder , Greg Kroah-Hartman , John Stultz Subject: [PATCH 2/3] gbsim: i2c: Convert to using greybus i2c.h header Date: Mon, 6 Apr 2015 19:06:10 -0700 Message-Id: <1428372371-9927-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428372371-9927-1-git-send-email-john.stultz@linaro.org> References: <1428372371-9927-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Instead of duplicating the definitions, reuse the definitions in the newly split out greybus i2c.h header. Cc: Alex Elder Cc: Greg Kroah-Hartman Signed-off-by: John Stultz --- gbsim.h | 27 ++++----------------------- i2c.c | 14 +++++++------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/gbsim.h b/gbsim.h index 032f003..cd54841 100644 --- a/gbsim.h +++ b/gbsim.h @@ -15,6 +15,7 @@ #include #include "gpio.h" +#include "i2c.h" #include "i2s.h" extern int bbb_backend; @@ -73,26 +74,6 @@ struct protocol_version_rsp { __u8 version_minor; }; -/* I2C */ -struct i2c_functionality_rsp { - __le32 functionality; -}; - -struct i2c_transfer_desc { - __le16 addr; - __le16 flags; - __le16 size; -}; - -struct i2c_transfer_req { - __le16 op_count; - struct i2c_transfer_desc desc[0]; -}; - -struct i2c_transfer_rsp { - __u8 data[0]; -}; - /* PWM */ struct pwm_count_rsp { __u8 count; @@ -146,9 +127,9 @@ struct op_msg { struct gb_gpio_irq_unmask_request gpio_irq_unmask_req; struct gb_gpio_irq_ack_request gpio_irq_ack_req; struct gb_gpio_irq_event_request gpio_irq_event_req; - struct i2c_functionality_rsp i2c_fcn_rsp; - struct i2c_transfer_req i2c_xfer_req; - struct i2c_transfer_rsp i2c_xfer_rsp; + struct gb_i2c_functionality_response i2c_fcn_rsp; + struct gb_i2c_transfer_request i2c_xfer_req; + struct gb_i2c_transfer_response i2c_xfer_rsp; struct pwm_count_rsp pwm_cnt_rsp; struct pwm_activate_req pwm_act_req; struct pwm_deactivate_req pwm_deact_req; diff --git a/i2c.c b/i2c.c index aedf0ac..866c595 100644 --- a/i2c.c +++ b/i2c.c @@ -72,7 +72,7 @@ void i2c_handler(__u8 *rbuf, size_t size) break; case OP_I2C_PROTOCOL_FUNCTIONALITY: sz = sizeof(struct op_header) + - sizeof(struct i2c_functionality_rsp); + sizeof(struct gb_i2c_functionality_response); op_rsp->header.size = htole16((__u16)sz); op_rsp->header.id = oph->id; op_rsp->header.type = OP_RESPONSE | OP_I2C_PROTOCOL_FUNCTIONALITY; @@ -110,18 +110,18 @@ void i2c_handler(__u8 *rbuf, size_t size) break; case OP_I2C_PROTOCOL_TRANSFER: op_count = le16toh(op_req->i2c_xfer_req.op_count); - write_data = (__u8 *)&op_req->i2c_xfer_req.desc[op_count]; + write_data = (__u8 *)&op_req->i2c_xfer_req.ops[op_count]; gbsim_debug("Number of transfer ops %d\n", op_count); for (i = 0; i < op_count; i++) { - struct i2c_transfer_desc *desc; + struct gb_i2c_transfer_op *op; __u16 addr; __u16 flags; __u16 size; - desc = &op_req->i2c_xfer_req.desc[i]; - addr = le16toh(desc->addr); - flags = le16toh(desc->flags); - size = le16toh(desc->size); + op = &op_req->i2c_xfer_req.ops[i]; + addr = le16toh(op->addr); + flags = le16toh(op->flags); + size = le16toh(op->size); read_op = (flags & I2C_M_RD) ? true : false; gbsim_debug("op %d: %s address %04x size %04x\n", i, (read_op ? "read" : "write"),