From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752439AbdBJWiQ (ORCPT ); Fri, 10 Feb 2017 17:38:16 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36128 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752312AbdBJWiO (ORCPT ); Fri, 10 Feb 2017 17:38:14 -0500 From: Eddie James Subject: Re: [PATCH linux v7 3/6] hwmon: occ: Add I2C transport implementation for SCOM operations To: Joel Stanley References: <1486509056-25838-1-git-send-email-eajames@linux.vnet.ibm.com> <1486509056-25838-4-git-send-email-eajames@linux.vnet.ibm.com> Cc: Guenter Roeck , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, jdelvare@suse.com, corbet@lwn.net, Mark Rutland , Rob Herring , Wolfram Sang , Andrew Jeffery , Benjamin Herrenschmidt , "Edward A. James" Date: Fri, 10 Feb 2017 15:05:05 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17021021-0020-0000-0000-00000B558A0D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006592; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000203; SDB=6.00820065; UDB=6.00400922; IPR=6.00597518; BA=6.00005130; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014248; XFM=3.00000011; UTC=2017-02-10 21:05:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17021021-0021-0000-0000-00005A012D9F Message-Id: <4224dbab-d48c-be48-154d-5ed14dd5231e@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-10_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702100209 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/09/2017 11:31 PM, Joel Stanley wrote: > On Wed, Feb 8, 2017 at 9:40 AM, wrote: >> From: "Edward A. James" >> >> Add functions to send SCOM operations over I2C bus. The BMC can >> communicate with the Power8 host processor over I2C, but needs to use SCOM >> operations in order to access the OCC register space. > This doesn't need to be separate from the p8_occ_i2c.c file. You can > remove a layer of function calls by merging this in and having these > be your getscom putscom bus_ops callbacks. The purpose of having this separate was so that we could do the scom address shift for p8 separately. >> Signed-off-by: Edward A. James >> Signed-off-by: Andrew Jeffery >> --- >> drivers/hwmon/occ/occ_scom_i2c.c | 77 ++++++++++++++++++++++++++++++++++++++++ >> drivers/hwmon/occ/occ_scom_i2c.h | 26 ++++++++++++++ >> 2 files changed, 103 insertions(+) >> create mode 100644 drivers/hwmon/occ/occ_scom_i2c.c >> create mode 100644 drivers/hwmon/occ/occ_scom_i2c.h >> >> diff --git a/drivers/hwmon/occ/occ_scom_i2c.c b/drivers/hwmon/occ/occ_scom_i2c.c >> new file mode 100644 >> index 0000000..74bd6ff >> --- /dev/null >> +++ b/drivers/hwmon/occ/occ_scom_i2c.c >> @@ -0,0 +1,77 @@ >> + >> +int occ_i2c_getscom(void *bus, u32 address, u64 *data) >> +{ >> + ssize_t rc; >> + u64 buf; > If you add endianness annotations sparse can check your types are > consistent. The warning looks like this: > > make C=2 drivers/hwmon/occ/occ_scom_i2c.o > drivers/hwmon/occ/occ_scom_i2c.c:48:17: warning: cast to restricted __be64 > > Which tells you it expects the type you pass to be64_to_cpu to be __be64. > > >> + struct i2c_client *client = bus; >> + struct i2c_msg msgs[2]; >> + >> + msgs[0].addr = client->addr; >> + msgs[0].flags = client->flags & I2C_M_TEN; >> + msgs[0].len = sizeof(u32); >> + msgs[0].buf = (char *)&address; >> + >> + msgs[1].addr = client->addr; >> + msgs[1].flags = client->flags & I2C_M_TEN; >> + msgs[1].flags |= I2C_M_RD; > I first thought you had made a mistake here. Instead you could do: > > msgs[1].flags = client->flags & I2C_M_TEN | I2C_M_RD; Sure. Was just copying i2c_master_recv. >> + msgs[1].len = sizeof(u64); >> + msgs[1].buf = (char *)&buf; >> + >> + rc = i2c_transfer(client->adapter, msgs, 2); >> + if (rc < 0) >> + return rc; >> +