Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5313211ybl; Tue, 4 Feb 2020 11:34:09 -0800 (PST) X-Google-Smtp-Source: APXvYqyRssA1QvYJJcU5qXnkEcN4Ahk+IIIFAM1qhtz4GIE7SPz7cPvXxZ5Ortcva6tM8XdzvKA6 X-Received: by 2002:a9d:7e8a:: with SMTP id m10mr21691501otp.27.1580844849609; Tue, 04 Feb 2020 11:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580844849; cv=none; d=google.com; s=arc-20160816; b=Riwj/pLmG2UxNveoz4ow0GcRgYPxTMs5DDTtbR6xzH1EA4iINcLz37AupTKuUHxEky enW+0eKzYn6zqhCi9JUV5PoAZcWkvMgcBm6C6yJV8+2f1k266i7tyQIzWIX1Baa9eD+C +Kz6eAc0HQrouP1jpC31kvNPohbPWTBHtOip2jXHD4LpsTV9HLQtCEn9WqjihMVZ1m7r 0DN9T3/frJJmZ5HR5bVjJrWDWT5Hv5xhbMjCH87mlKuKoudIxlb3ARd6mKAX8VXNiEVE tQuHXpjirZIJFM3DIhCFioLd8Y9GJp7Yctyod5sSJ/8nlsfiNQ1mPw7yb2iBcyUVF7di Pd8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N0feqpjiIoHn9/Mmqog1G13Nvzq6P+/4k/jXqeGN5W4=; b=lfhMs4Ypk4M2/1Q3jnYE6B+/eeb070mxXdduT/MnFScMsG/VO+Z9gUsSHmGmPZdWbJ R7jOiPf9IWg/G1rAim9qdUP0WwUev2Hi8G05pbm/IkyFZqNomJFG72UXHC6Ye8k5LOCC l3R0zjI2rOQMzOHy5E+eBB4I8FrRx3GvV3WBPPhycxlcV5vNGmG++P5FuxnXoWZN6ZkZ 3InjMMX+TcDHv/P1ANXfwpKPwcEkniOmQxuUy04i4cUOmJr/8X0rcg+Si9Sc20aTf9mb ncrnFqUgiwEZVbxGuWvwo05T3JMkvt450JnbXEnYX8hFk5xs9fdztp9TLqVovlQAbz38 DeEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=G3JESj+d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o16si11706322otp.289.2020.02.04.11.33.57; Tue, 04 Feb 2020 11:34:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=G3JESj+d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727579AbgBDTb6 (ORCPT + 99 others); Tue, 4 Feb 2020 14:31:58 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46088 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727486AbgBDTb4 (ORCPT ); Tue, 4 Feb 2020 14:31:56 -0500 Received: by mail-pl1-f194.google.com with SMTP id y8so7667346pll.13 for ; Tue, 04 Feb 2020 11:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N0feqpjiIoHn9/Mmqog1G13Nvzq6P+/4k/jXqeGN5W4=; b=G3JESj+dNoN1RTcDn6NVnvw+kbOcW38OQAUJL0SPzI3QJKq+Tan5slIeUBMtnTsq2O Z3Css13xCcrTLB463unY2yR1kaWJhFijMvduMNUAHLjL5LnR2S7J0J+wtw4IGcBenzbD 3F/WZE6q3n39bxrLJi2p3Avvri0iwIGtI+mC4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N0feqpjiIoHn9/Mmqog1G13Nvzq6P+/4k/jXqeGN5W4=; b=klC+EPhDwmQJCbf/opGTtGmlN467EszDH/DunPJ9aGI0HUmeNGsrKbVW9ob0PyHIFz q2pDIi+Tttsmd5zNVGQ1AFjwuY9HFgqYSOHTz2aTnwMYLHUOyBNG6i4d0RwUZq54yJVJ X2ChzAz3NHBEzqdw8SNX2YkC6cPYUYMEwvPiEdFYqUMBoDQtVB+0Bo0quvfAEbYgBedr DC14zB/SJXam3JXc8K6VqKq2xbtkcjzBc9Ms8g/ZBx8lq+xkH09KH6OX0I+kG3MjdPGl 4pCpWCMT2Xo+V0YHQkK8YkIdC3nQH8YWcS+A1AX4VgLfPlrHwEfqU3S4jKH5xBCvg3vZ 7/8Q== X-Gm-Message-State: APjAAAWwa59rAixuN/JWcnySM6ev2XixlBtwJf6MBuMujiPSoo+dBuki zWY5Av/ibSZOFYBjc1ctHbQcNg== X-Received: by 2002:a17:90a:c706:: with SMTP id o6mr801929pjt.82.1580844716160; Tue, 04 Feb 2020 11:31:56 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id g18sm24956626pfi.80.2020.02.04.11.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 11:31:55 -0800 (PST) From: Stephen Boyd To: Wolfram Sang Cc: linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, Girish Mahadevan , Dilip Kota , Alok Chauhan , Douglas Anderson Subject: [PATCH 2/3] i2c: qcom-geni: Grow a dev pointer to simplify code Date: Tue, 4 Feb 2020 11:31:51 -0800 Message-Id: <20200204193152.124980-3-swboyd@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200204193152.124980-1-swboyd@chromium.org> References: <20200204193152.124980-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some lines are long here. Use a struct dev pointer to shorten lines and simplify code. The clk_get() call can fail because of EPROBE_DEFER problems too, so just remove the error print message because it isn't useful. Cc: Girish Mahadevan Cc: Dilip Kota Cc: Alok Chauhan Cc: Douglas Anderson Signed-off-by: Stephen Boyd --- drivers/i2c/busses/i2c-qcom-geni.c | 51 ++++++++++++++---------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c index 3e13b54ce3f8..192a8f622f3d 100644 --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -502,45 +502,42 @@ static int geni_i2c_probe(struct platform_device *pdev) struct resource *res; u32 proto, tx_depth; int ret; + struct device *dev = &pdev->dev; - gi2c = devm_kzalloc(&pdev->dev, sizeof(*gi2c), GFP_KERNEL); + gi2c = devm_kzalloc(dev, sizeof(*gi2c), GFP_KERNEL); if (!gi2c) return -ENOMEM; - gi2c->se.dev = &pdev->dev; - gi2c->se.wrapper = dev_get_drvdata(pdev->dev.parent); + gi2c->se.dev = dev; + gi2c->se.wrapper = dev_get_drvdata(dev->parent); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - gi2c->se.base = devm_ioremap_resource(&pdev->dev, res); + gi2c->se.base = devm_ioremap_resource(dev, res); if (IS_ERR(gi2c->se.base)) return PTR_ERR(gi2c->se.base); - gi2c->se.clk = devm_clk_get(&pdev->dev, "se"); - if (IS_ERR(gi2c->se.clk) && !has_acpi_companion(&pdev->dev)) { + gi2c->se.clk = devm_clk_get(dev, "se"); + if (IS_ERR(gi2c->se.clk) && !has_acpi_companion(dev)) { ret = PTR_ERR(gi2c->se.clk); - dev_err(&pdev->dev, "Err getting SE Core clk %d\n", ret); return ret; } - ret = device_property_read_u32(&pdev->dev, "clock-frequency", - &gi2c->clk_freq_out); + ret = device_property_read_u32(dev, "clock-frequency", + &gi2c->clk_freq_out); if (ret) { - dev_info(&pdev->dev, - "Bus frequency not specified, default to 100kHz.\n"); + dev_info(dev, "Bus frequency not specified, default to 100kHz.\n"); gi2c->clk_freq_out = KHZ(100); } - if (has_acpi_companion(&pdev->dev)) - ACPI_COMPANION_SET(&gi2c->adap.dev, ACPI_COMPANION(&pdev->dev)); + if (has_acpi_companion(dev)) + ACPI_COMPANION_SET(&gi2c->adap.dev, ACPI_COMPANION(dev)); gi2c->irq = platform_get_irq(pdev, 0); - if (gi2c->irq < 0) { - dev_err(&pdev->dev, "IRQ error for i2c-geni\n"); + if (gi2c->irq < 0) return gi2c->irq; - } ret = geni_i2c_clk_map_idx(gi2c); if (ret) { - dev_err(&pdev->dev, "Invalid clk frequency %d Hz: %d\n", + dev_err(dev, "Invalid clk frequency %d Hz: %d\n", gi2c->clk_freq_out, ret); return ret; } @@ -550,28 +547,28 @@ static int geni_i2c_probe(struct platform_device *pdev) spin_lock_init(&gi2c->lock); platform_set_drvdata(pdev, gi2c); ret = devm_request_irq(dev, gi2c->irq, geni_i2c_irq, 0, - dev_name(&pdev->dev), gi2c); + dev_name(dev), gi2c); if (ret) { - dev_err(&pdev->dev, "Request_irq failed:%d: err:%d\n", + dev_err(dev, "Request_irq failed:%d: err:%d\n", gi2c->irq, ret); return ret; } /* Disable the interrupt so that the system can enter low-power mode */ disable_irq(gi2c->irq); i2c_set_adapdata(&gi2c->adap, gi2c); - gi2c->adap.dev.parent = &pdev->dev; - gi2c->adap.dev.of_node = pdev->dev.of_node; + gi2c->adap.dev.parent = dev; + gi2c->adap.dev.of_node = dev->of_node; strlcpy(gi2c->adap.name, "Geni-I2C", sizeof(gi2c->adap.name)); ret = geni_se_resources_on(&gi2c->se); if (ret) { - dev_err(&pdev->dev, "Error turning on resources %d\n", ret); + dev_err(dev, "Error turning on resources %d\n", ret); return ret; } proto = geni_se_read_proto(&gi2c->se); tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se); if (proto != GENI_SE_I2C) { - dev_err(&pdev->dev, "Invalid proto %d\n", proto); + dev_err(dev, "Invalid proto %d\n", proto); geni_se_resources_off(&gi2c->se); return -ENXIO; } @@ -581,11 +578,11 @@ static int geni_i2c_probe(struct platform_device *pdev) true, true, true); ret = geni_se_resources_off(&gi2c->se); if (ret) { - dev_err(&pdev->dev, "Error turning off resources %d\n", ret); + dev_err(dev, "Error turning off resources %d\n", ret); return ret; } - dev_dbg(&pdev->dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth); + dev_dbg(dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth); gi2c->suspended = 1; pm_runtime_set_suspended(gi2c->se.dev); @@ -595,12 +592,12 @@ static int geni_i2c_probe(struct platform_device *pdev) ret = i2c_add_adapter(&gi2c->adap); if (ret) { - dev_err(&pdev->dev, "Error adding i2c adapter %d\n", ret); + dev_err(dev, "Error adding i2c adapter %d\n", ret); pm_runtime_disable(gi2c->se.dev); return ret; } - dev_dbg(&pdev->dev, "Geni-I2C adaptor successfully added\n"); + dev_dbg(dev, "Geni-I2C adaptor successfully added\n"); return 0; } -- Sent by a computer, using git, on the internet