Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1777421rwl; Sun, 26 Mar 2023 08:56:54 -0700 (PDT) X-Google-Smtp-Source: AKy350YnVTgRa+8wU3RCfY5Wr/2vfMy3cBUkKIo52zMWok84T+dx1/Bmq1j+NWQbHyDZ1a2MON7D X-Received: by 2002:aa7:d1d9:0:b0:4fe:9621:ffdc with SMTP id g25-20020aa7d1d9000000b004fe9621ffdcmr9087462edp.16.1679846213960; Sun, 26 Mar 2023 08:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679846213; cv=none; d=google.com; s=arc-20160816; b=R3evocltg+l76qP4EOKsw36EhzKdw95iEIy8spUI2wwPn8ttbXB+H+cLQURa9PUbAd +pNhTOzpA88GAGSfAPTCdwXS2+fviSSCdT4Ed5k9mxwSXhKev5aYhkNritsWsAFtNwqe 8S4t8haTjwupVzjWDbRrWNCCtRdtAceAWcPrmySnl9DaFyaqf+GYjuRfPDGU/bHPDW21 udh1bKZIrxQOD7385wYNUfvjC2FQcDaFP0pqvFnf/3W8L7anfDSHY3PfC9IMjwJjpv+X elSHovasP8wiWc7oxzBlzOkHH2WXpRmg/ofwR7V9umMRhY57+HI89tF7MKWBDCrHCRGv p+HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XOyY6Z3bR+1FgTM6WaGlhe8ynfTivqup9Wjfg8rnNho=; b=wQ3z79BJrXrN044kZKP2CJYIVRgN2nRpyif7+zVhW6ghp8vUg0+GzMSWjY+6BRcbB7 LUwstmFo9m6OaV7IIw2tjb2cztAjoAM/sUpLlz1Px+f+2VYLc+2vxbFL4oTmzyjCHrOd NSoNzVsCvv564e/8oZa0OCouUzH1RaIRJpp8IVpXc6lIfc2onMmE0bq6TUkZTAP5xtr+ ztNLdkVaHnGT1eeoy2obf+2qqbdJ5V4rz9SmoqDQY8zpqT4mfJZ9bEWlMmn636LHRIqX 32NUZ/kSn3iymzUP5ClyAnprC3oToCg4PFwE1pPuvPF+afndeY9BWU9fQsdnRUt1qQGx 1tRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bxhix9dc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a17090676c500b008beb8136584si15329681ejn.491.2023.03.26.08.56.30; Sun, 26 Mar 2023 08:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bxhix9dc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232549AbjCZPiz (ORCPT + 99 others); Sun, 26 Mar 2023 11:38:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjCZPix (ORCPT ); Sun, 26 Mar 2023 11:38:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DD8710E4; Sun, 26 Mar 2023 08:38:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 28A7AB80C99; Sun, 26 Mar 2023 15:38:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4663AC433D2; Sun, 26 Mar 2023 15:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679845129; bh=ZXRo4uvGF4gNgO4cKBiMTZRNDq7znRBgZTcFSFWfvLg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bxhix9dcjXPnhYzB/QXdFvNBUX5kybYCNWZEhI/2ntjW0pWLhxIgYuqsKs12cdUam CxF6T299QsuyzU/02huAX13mzSqkwjQSGR4O2INXPZcpJeuMjtCMq1abt/x6nlfQUK 0Qk7bHy53AjpWiqLzbOEOdG4fPBPZK133ElDywDN0wBNlPxislzpZfEglziQ9NSxGx 1aP2F+1bUffMDF8ldk2Dn5ksyhiL3RqYiudf8/V/M51xyLdKx0c8/f9/oXTuMItoBG dZ0Au29pkMG1fMz96E9Qc6Zg01fRPSFgb+bXusTYiyUHUSCRK04Fq8/BqkNV70cVpA Ev0gwnW16RKGQ== Date: Sun, 26 Mar 2023 17:38:46 +0200 From: Andi Shyti To: Ye Xiang Cc: Greg Kroah-Hartman , Arnd Bergmann , Matthias Kaehlcke , Lee Jones , Wolfram Sang , Tyrone Ting , Mark Brown , Linus Walleij , Bartosz Golaszewski , linux-usb@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-gpio@vger.kernel.org, srinivas.pandruvada@intel.com, heikki.krogerus@linux.intel.com, andriy.shevchenko@linux.intel.com, sakari.ailus@linux.intel.com, zhifeng.wang@intel.com, wentong.wu@intel.com, lixu.zhang@intel.com Subject: Re: [PATCH v6 5/6] i2c: Add support for Intel LJCA USB I2C driver Message-ID: <20230326153846.zo77mbgti2injnxl@intel.intel> References: <20230323172113.1231050-1-xiang.ye@intel.com> <20230323172113.1231050-6-xiang.ye@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230323172113.1231050-6-xiang.ye@intel.com> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ye, looks good, just a few questions: On Fri, Mar 24, 2023 at 01:21:12AM +0800, Ye Xiang wrote: > This patch implements the I2C function of Intel USB-I2C/GPIO/SPI adapter also here, please keep using the imperative form. > device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA > I2c module with specific protocol through interfaces exported by LJCA USB > driver. > > Signed-off-by: Ye Xiang [...] > +enum ljca_xfer_type { > + LJCA_I2C_READ_XFER_TYPE, > + LJCA_I2C_WRITE_XFER_TYPE, > +}; > + > +/* I2C r/w Flags */ > +#define LJCA_I2C_SLAVE_TRANSFER_WRITE (0) > +#define LJCA_I2C_SLAVE_TRANSFER_READ (1) the enum above and the bits here look a bit redundant to me as they are the same thing. What's the point for writing something like: if (type == LJCA_I2C_READ_XFER_TYPE) addr |= LJCA_I2C_SLAVE_TRANSFER_WRITE when the two are the same. You are just adding confusion. As this is a bit field, you can just keep the defines. [...] > +static u8 ljca_i2c_format_slave_addr(u8 slave_addr, u8 type) > +{ > + return (slave_addr << 1) | (type == LJCA_I2C_READ_XFER_TYPE) ? > + LJCA_I2C_SLAVE_TRANSFER_READ : > + LJCA_I2C_SLAVE_TRANSFER_WRITE; > +} How about: return (slave_addr << 1) | !!type; BTW, am I reading correctly that the address here is composed as: 7 6 5 5 3 2 1 0 ADDR7 ADDR6 ADDR5 ADDR4 ADDR3 ADDR2 ADDR1 R/W [...] > +static u32 ljca_i2c_func(struct i2c_adapter *adap) > +{ > + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; how is the smbus supported here? Andi