From patchwork Thu Jul 25 07:56:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 169682 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11292669ilk; Thu, 25 Jul 2019 00:56:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqw52MYSgAxxFfTe4AVijdt6biRfgnyzBggKiu+VkR7XwKuBNsaLSTkxOJVkJRHQ6avKIuLC X-Received: by 2002:a63:7245:: with SMTP id c5mr71405482pgn.11.1564041397452; Thu, 25 Jul 2019 00:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564041397; cv=none; d=google.com; s=arc-20160816; b=D5pY0NlLM/mfvTHKt8HnycaETkyeXyeWB0/q5NnJhK341eOKtKIsTZgLVUTsPJsumJ W6hiTqVH0LeleOEuN88Up2CcBn+LWUV2DUoPIKjoD0KFb7XqwfeLqGRE9AURg4nFQfb2 zdtMEkxZl5T5iU6k/+DYuH6arVAPdbhAWUxXcpDP4pyaJ/3h0U8MX4SB0XiHX3APz33g 0kFDgBt0mBChX0OZXVT+xv4J1KDU7xDB9DP+nqP1EKUHikVBw3+bJ73PyrY8mg/g5fO5 T8TltyK+MEEgh8TepVtdtKOXcd2DY2O+SBWEP2uVNzvyDRxGBoDXDCFE8XjwEsTzmaYP WtTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=oPhMC5eLv3LSVkBhX5uqN94UAFd9buQ6xbizcntcIj4=; b=UZQW1cvqGdBS6BXorrI5Qf7F/2XBg1t25VQ9sRo2XOVoX2lO3Cq6Qgo3XjGKsX4dg9 6/TX8e/Sc0bFsugXXNYVZDMmBeLjkGTPDE6lF8UcL0Jsg8xhx0lQe5sL5IejObLICrid tcyyWQg5GGS4MZo6u1Vl4fMbvzPz+aWdPYS4Au5EN83NFgBiU0dKGnXSvgyspDMIKT/G Z17CVOxjT71wizbsqDYtVY7gjaNMEZqm/tCyD4C/zSP3ZkqC3nryVT7v0E//1Lu29ogZ yGka/JAfqUHTx8gtIJbhzBtvajeDNQEsWfogg4TZ9U9xEH1irtg5KasqDgepYSLkZMJm 6S3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gU9RlzjK; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si32636580pgp.288.2019.07.25.00.56.37; Thu, 25 Jul 2019 00:56:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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=@linaro.org header.s=google header.b=gU9RlzjK; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388670AbfGYH4g (ORCPT + 2 others); Thu, 25 Jul 2019 03:56:36 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42997 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388667AbfGYH4g (ORCPT ); Thu, 25 Jul 2019 03:56:36 -0400 Received: by mail-pg1-f194.google.com with SMTP id t132so22598256pgb.9 for ; Thu, 25 Jul 2019 00:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=oPhMC5eLv3LSVkBhX5uqN94UAFd9buQ6xbizcntcIj4=; b=gU9RlzjKhjVYpSzfgbQtfgo4FUEPEtq8PTlxfAMmALiP6j7lO9a1JjhQ2/waNbbRh3 q1cqem1MSNir9sfiSTZdURrn+1MBTgX6N4mdEU735+P37HKkR8LNRkiZJwGBuWz5FRKZ B5s70u0vk96SBR0+TgZteULP5GWzfT2/PH+NWm6TtTo3TnQ/gkOCPKbAJ3ColBXyB9BU vMxReKCWpwvNFYUeXmW497IB11fJ9hMBG6xvQtlFqFpQM5K6IQ8dPQuYSMEQsu15qQkZ r6HatIt/DN5NQcHMp1ItDn0gArYHDJ3e17HrL6b+3ta7UqGm9RXU01l81wiUHMDV1jNJ 24Ig== 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; bh=oPhMC5eLv3LSVkBhX5uqN94UAFd9buQ6xbizcntcIj4=; b=KHv6EpFX7gKFzA938G4Zs2qLySZmIwXFC6ljOHy1RUesZgIJwbgZ9MlrbF65SzD/P0 8IDHVizvMdswrkGgZfAL50zg0xtFCoH9CBNqqYEwba/24LUH5IMbjQCyu78DnPpISo6P 5MUKyFBhF7pcaPXZWSLFFlLMFqZPr5w2fUtFApHGKalfWdhxc30ga7kiaL2UyD4Q0GT3 hOaPq6aiXVvG1TjQMcXsUrpBeqln8l6AZvNpJqqzVQURXWNjphcTpAEeV0C6t4xCp1Ui KnojVrYL108fgbGDwa6YvCZ+w844lf+Yk90ZFBaPUskA08GOOEO74akJKmBm5ydFJsdN /cew== X-Gm-Message-State: APjAAAVS24rLzkV0qNppCSfHsinwTmYHtfcgNFuOtJELcOgJWAC80VNk 6dkrmui2KkiIJ6iddFP6/BeAqw== X-Received: by 2002:aa7:9407:: with SMTP id x7mr15929124pfo.163.1564041395498; Thu, 25 Jul 2019 00:56:35 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id m9sm89021419pgr.24.2019.07.25.00.56.32 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Jul 2019 00:56:35 -0700 (PDT) From: Baolin Wang To: wsa+renesas@sang-engineering.com, orsonzhai@gmail.com, zhang.lyra@gmail.com Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Date: Thu, 25 Jul 2019 15:56:16 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Now there is no need to keep our I2C driver to be initialized so early, thus changing to module level and let it can be built as a module, meanwhile adding some module information. Signed-off-by: Baolin Wang --- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-sprd.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) -- 1.7.9.5 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 09367fc..69f1931 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -977,7 +977,7 @@ config I2C_SIRF will be called i2c-sirf. config I2C_SPRD - bool "Spreadtrum I2C interface" + tristate "Spreadtrum I2C interface" depends on I2C=y && ARCH_SPRD help If you say yes to this option, support will be included for the diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c index 9611235..8002835 100644 --- a/drivers/i2c/busses/i2c-sprd.c +++ b/drivers/i2c/busses/i2c-sprd.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -644,8 +645,7 @@ static int __maybe_unused sprd_i2c_runtime_resume(struct device *dev) }, }; -static int sprd_i2c_init(void) -{ - return platform_driver_register(&sprd_i2c_driver); -} -arch_initcall_sync(sprd_i2c_init); +module_platform_driver(sprd_i2c_driver); + +MODULE_DESCRIPTION("Spreadtrum I2C master controller driver"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Jul 25 07:56:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 169684 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11292776ilk; Thu, 25 Jul 2019 00:56:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2Fo3ayhYCf+9q+9AyR6Sc1f20ZAiiUE3wyPrvArV6Hz+zf8dapL1R6SA87VK6pRRXcLbD X-Received: by 2002:a17:902:9a49:: with SMTP id x9mr90356346plv.282.1564041404145; Thu, 25 Jul 2019 00:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564041404; cv=none; d=google.com; s=arc-20160816; b=J6TUj5SKdFkDRYKhgeTjvXcVpgdc9jH0u3qt76ftTPz6BQgseTggq7hHTFccznEkub 0UKrMh2MEl0pIuVdM6Xyu3QfsOvCTU26cxd2EA8CoWeHj15oEEcYrYe35GN0lIgdRNN/ Az5hSPZ6pEzjSOvMuoaZCA+fMvlP3n29W2zzB/UKUFI1nKxIMZmvr5mM2AmK8WkuS/Nr 7REPi2WyHU57r5j0sG1zcJShvGLVRxfdxPoB6pgI+faOoKwfXiRAQHf60FdXkb6pP4OW ZHcwRSeaiM3OiEKyMbdK1s6ze9Hg5aJRmXAWVBTitAJTwgl3k0jGIyRt8+5UPRyEjgi+ fAuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=eNURmCt1o5sob1QOowvJXr5pL73KlOzcHKdzSxjtEkQ=; b=rvdZCJuj2D1VxWGymXb0UQmTD+SffTdxUftxTbpzhhMrknDyFwIZCyDCJkDgW+cS19 X73MjBNG4zkx/RXJ6NftIOx+gt8IH4f2dyaRQ9sNKgmfbCXaxQi7hmW1vCBsjPZxtL2S B/XCp7X3iupO1wkCbwLOgdO12uh6C2sfgMJ2yArp7IfnRdVjl3J8vrkYjHsPMNvo8Vc3 9sAP82O/yWlSNe13q7WjruyrjZ8bSVpY2mdKbppV1NrJaA3jhX4MDaNUp7wZOmzQ+o/6 kzM2vMYnYU2TE/Eu2Gv9mhS9g+WaIVv8OLAliQClNmw5gJog3FhvkvzAsNvhDdzbRyRJ JpRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U7zeKlTb; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si17215026pln.70.2019.07.25.00.56.43; Thu, 25 Jul 2019 00:56:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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=@linaro.org header.s=google header.b=U7zeKlTb; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388696AbfGYH4m (ORCPT + 2 others); Thu, 25 Jul 2019 03:56:42 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38957 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388726AbfGYH4l (ORCPT ); Thu, 25 Jul 2019 03:56:41 -0400 Received: by mail-pg1-f193.google.com with SMTP id u17so22604677pgi.6 for ; Thu, 25 Jul 2019 00:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eNURmCt1o5sob1QOowvJXr5pL73KlOzcHKdzSxjtEkQ=; b=U7zeKlTbIuS5u7DJxz9XnFhiBxEa+BpR7S41Ci+3WJQgscfSV6So2gzcTVQd+R96nf 5bg7QLcpx9FMCe/bbTeQ9qWon/c3Em0JdujbSKBovxMrHDRMbHPFUuxE0ZuVlhEoZbul Yxwj3ky3V06UmwsFaveXirOuoElDv2qXDcZPJ4pPMn2QK//CIoDzMdS3l0BHFhBW+NfI FLBhyvp4e5tBqxKQWI9M+VaoMfn/DaN4MOm+qzA1OSHnWH38gCy5D5VvVwS5psNckamW Wv79LKVv8TX6CrbAJq69u9WQIvlYR068FfnYjuIthjm0VOqh8SMh/KR3z/GyrC2TfUTF K0Hg== 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:in-reply-to:references; bh=eNURmCt1o5sob1QOowvJXr5pL73KlOzcHKdzSxjtEkQ=; b=V2vkuDUqh/LoqQOYLiFcnuIGAX4w6Aqike0jdvKvhwXTyVNhBNWVBVgqvPKGWL/rIc 0i0XLgGvURS74nRNgbeDZuJ6o8hRlyAKXmo+mXTX8h/gzPF5MYk1157vxJ81rQ9Hem9i Fz386rGmTREVeOo7pwk5giJBSyPOh2XdAefBUBTXN56cVInsxFpyhyvhSjG7PMXyXkh9 4ib94eQF/GxHp/hepJRFoXDE7DC5YQQilL4e0azNaInAALeafunauRnEglpehsPBMqtw hnJzDUZsuM86pG5Aau0w0Zz70s8swR4uK1s3uIGPz4D2vUJN+JbuIJFJUbzxN1q9Ctjy NjFw== X-Gm-Message-State: APjAAAVsMN8zHg727z+WYb4j19X+205ao0eTpQfbN3OpISTO572YOByr M/QKImDNU6kgGzwYpfJbdCp1Hw== X-Received: by 2002:a17:90a:8688:: with SMTP id p8mr92850220pjn.57.1564041400592; Thu, 25 Jul 2019 00:56:40 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id m9sm89021419pgr.24.2019.07.25.00.56.38 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Jul 2019 00:56:40 -0700 (PDT) From: Baolin Wang To: wsa+renesas@sang-engineering.com, orsonzhai@gmail.com, zhang.lyra@gmail.com Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] i2c: sprd: Validate the return value of clock initialization Date: Thu, 25 Jul 2019 15:56:18 +0800 Message-Id: <5f64dc0eedb348b15442f31f2f22f5bded7cd6ef.1564041157.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The 'enable' clock of I2C master is required, we should return an error if failed to get the 'enable' clock, to make sure the I2C driver can be defer probe if the clock resource is not ready. Signed-off-by: Baolin Wang --- drivers/i2c/busses/i2c-sprd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 1.7.9.5 diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c index bbcb056..b432e75 100644 --- a/drivers/i2c/busses/i2c-sprd.c +++ b/drivers/i2c/busses/i2c-sprd.c @@ -466,9 +466,9 @@ static int sprd_i2c_clk_init(struct sprd_i2c *i2c_dev) i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable"); if (IS_ERR(i2c_dev->clk)) { - dev_warn(i2c_dev->dev, "i2c%d can't get the enable clock\n", - i2c_dev->adap.nr); - i2c_dev->clk = NULL; + dev_err(i2c_dev->dev, "i2c%d can't get the enable clock\n", + i2c_dev->adap.nr); + return PTR_ERR(i2c_dev->clk); } return 0; @@ -519,7 +519,10 @@ static int sprd_i2c_probe(struct platform_device *pdev) if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000) return -EINVAL; - sprd_i2c_clk_init(i2c_dev); + ret = sprd_i2c_clk_init(i2c_dev); + if (ret) + return ret; + platform_set_drvdata(pdev, i2c_dev); ret = clk_prepare_enable(i2c_dev->clk);