From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfram Sang Subject: [PATCH 08/12] i2c: ocores: refactor setup for polling Date: Wed, 3 Apr 2019 14:40:15 +0200 Message-ID: <20190403124019.8947-9-wsa+renesas@sang-engineering.com> References: <20190403124019.8947-1-wsa+renesas@sang-engineering.com> Return-path: In-Reply-To: <20190403124019.8947-1-wsa+renesas@sang-engineering.com> Sender: linux-kernel-owner@vger.kernel.org To: linux-i2c@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peter Rosin , Stefan Lengfeld , linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org, Linus Walleij , Andy Shevchenko , Wolfram Sang , Andrew Lunn List-Id: linux-tegra@vger.kernel.org By properly setting up the algorithm at probe time, we can skip the check at every transfer. This allows us to get rid of the flags completely. Signed-off-by: Wolfram Sang Cc: Andrew Lunn --- drivers/i2c/busses/i2c-ocores.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index 4e1a077fb688..1b99f467aae0 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c @@ -26,8 +26,6 @@ #include #include -#define OCORES_FLAG_POLL BIT(0) - /* * 'process_lock' exists because ocores_process() and ocores_process_timeout() * can't run in parallel. @@ -37,7 +35,6 @@ struct ocores_i2c { int iobase; u32 reg_shift; u32 reg_io_width; - unsigned long flags; wait_queue_head_t wait; struct i2c_adapter adap; struct i2c_msg *msg; @@ -403,11 +400,7 @@ static int ocores_xfer_polling(struct i2c_adapter *adap, static int ocores_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - struct ocores_i2c *i2c = i2c_get_adapdata(adap); - - if (i2c->flags & OCORES_FLAG_POLL) - return ocores_xfer_polling(adap, msgs, num); - return ocores_xfer_core(i2c, msgs, num, false); + return ocores_xfer_core(i2c_get_adapdata(adap), msgs, num, false); } static int ocores_init(struct device *dev, struct ocores_i2c *i2c) @@ -447,7 +440,7 @@ static u32 ocores_func(struct i2c_adapter *adap) return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } -static const struct i2c_algorithm ocores_algorithm = { +static struct i2c_algorithm ocores_algorithm = { .master_xfer = ocores_xfer, .functionality = ocores_func, }; @@ -673,13 +666,13 @@ static int ocores_i2c_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq == -ENXIO) { - i2c->flags |= OCORES_FLAG_POLL; + ocores_algorithm.master_xfer = ocores_xfer_polling; } else { if (irq < 0) return irq; } - if (!(i2c->flags & OCORES_FLAG_POLL)) { + if (ocores_algorithm.master_xfer != ocores_xfer_polling) { ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, pdev->name, i2c); if (ret) { -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81AEBC10F0B for ; Wed, 3 Apr 2019 12:41:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 50A512084C for ; Wed, 3 Apr 2019 12:41:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AD1Y17ys" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50A512084C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VfOWWfQJ05IINPzRPOGRBteW8c8dPTt7MEi542ExucI=; b=AD1Y17ysBb4x5IG2uCEX7tZqTd DiJaTjnvPvDQzQMPQEXxqGTVIp+dETQcacupymxgza+lkKe9wCxVXUuYTn4Llje8tzCo+AyQOLRII GK4xmAK/5t38ISG6WgMJTMpAwQHRBI4dAvXllq0i9X1TVv2yc7eKSgGyHQ74vDfpU13wSXaewqTcc zX5rBA46HWNvrmFPo6BN06DAQEWChjh/HCFwucVC6fwl3HwvBAlh9NJe0S21e57N0a4Mk9W/oZt4X zKY7NzigHY8yocNtcoqozHkgwVgi++N83ssPLYh2le4kSiGcNF3iWLAL1OLuSr3oohUEIG+9iX1e3 Te5a43Ow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBfCy-0007oM-Sz; Wed, 03 Apr 2019 12:41:36 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBfC6-0006WZ-LK for linux-arm-kernel@lists.infradead.org; Wed, 03 Apr 2019 12:40:44 +0000 Received: from localhost (p54B3311F.dip0.t-ipconnect.de [84.179.49.31]) by pokefinder.org (Postfix) with ESMTPSA id D6AAD3E43CF; Wed, 3 Apr 2019 14:40:38 +0200 (CEST) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [PATCH 08/12] i2c: ocores: refactor setup for polling Date: Wed, 3 Apr 2019 14:40:15 +0200 Message-Id: <20190403124019.8947-9-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190403124019.8947-1-wsa+renesas@sang-engineering.com> References: <20190403124019.8947-1-wsa+renesas@sang-engineering.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190403_054042_840732_A55FB113 X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Wolfram Sang , linux-tegra@vger.kernel.org, Stefan Lengfeld , linux-omap@vger.kernel.org, Peter Rosin , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org By properly setting up the algorithm at probe time, we can skip the check at every transfer. This allows us to get rid of the flags completely. Signed-off-by: Wolfram Sang Cc: Andrew Lunn --- drivers/i2c/busses/i2c-ocores.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index 4e1a077fb688..1b99f467aae0 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c @@ -26,8 +26,6 @@ #include #include -#define OCORES_FLAG_POLL BIT(0) - /* * 'process_lock' exists because ocores_process() and ocores_process_timeout() * can't run in parallel. @@ -37,7 +35,6 @@ struct ocores_i2c { int iobase; u32 reg_shift; u32 reg_io_width; - unsigned long flags; wait_queue_head_t wait; struct i2c_adapter adap; struct i2c_msg *msg; @@ -403,11 +400,7 @@ static int ocores_xfer_polling(struct i2c_adapter *adap, static int ocores_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - struct ocores_i2c *i2c = i2c_get_adapdata(adap); - - if (i2c->flags & OCORES_FLAG_POLL) - return ocores_xfer_polling(adap, msgs, num); - return ocores_xfer_core(i2c, msgs, num, false); + return ocores_xfer_core(i2c_get_adapdata(adap), msgs, num, false); } static int ocores_init(struct device *dev, struct ocores_i2c *i2c) @@ -447,7 +440,7 @@ static u32 ocores_func(struct i2c_adapter *adap) return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } -static const struct i2c_algorithm ocores_algorithm = { +static struct i2c_algorithm ocores_algorithm = { .master_xfer = ocores_xfer, .functionality = ocores_func, }; @@ -673,13 +666,13 @@ static int ocores_i2c_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq == -ENXIO) { - i2c->flags |= OCORES_FLAG_POLL; + ocores_algorithm.master_xfer = ocores_xfer_polling; } else { if (irq < 0) return irq; } - if (!(i2c->flags & OCORES_FLAG_POLL)) { + if (ocores_algorithm.master_xfer != ocores_xfer_polling) { ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, pdev->name, i2c); if (ret) { -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel