From patchwork Sat Jun 15 20:38:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 251639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2F73C2C007E for ; Sun, 16 Jun 2013 06:38:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754575Ab3FOUiZ (ORCPT ); Sat, 15 Jun 2013 16:38:25 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:37522 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754532Ab3FOUiY (ORCPT ); Sat, 15 Jun 2013 16:38:24 -0400 Received: by mail-lb0-f177.google.com with SMTP id 10so1459896lbf.22 for ; Sat, 15 Jun 2013 13:38:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=l1dhF0/yXxQ6KwrxlN+VNjBObc5o5mGYOVj/M9WjPQY=; b=D22tZHb5nWvQwyMOSi9kKPfxm2RQCADcGXw0fGzdOoTKmpBnmyKmzuDAvUndzTM74V OqGlLw6wRlknUQuyxnuBojeK03T6NmGKWtD6c2l6NHGAOkAQObY7QhXmxBpG1NaZd2fe WAgaFI3Oj7I8wki6OLGnmch2T9AJ4JXYmyDoV/rYTYzZLe54qRAjpMOMmi4OoZAHxWjf yv2nDTeijECgX/Xk9MFMRX6LwB2PyQo6np3WPIO46J24UM+gnw/VtdgPSMAeEgjJm4g2 fus14RMHsO+M+0h5s23gwM42t2WE5iC8JuVaxk6HAmzMeug/AnzzO1MSb24jCNO+f1CS Uyow== X-Received: by 10.152.20.40 with SMTP id k8mr3777446lae.25.1371328703089; Sat, 15 Jun 2013 13:38:23 -0700 (PDT) Received: from localhost.localdomain (c83-249-208-143.bredband.comhem.se. [83.249.208.143]) by mx.google.com with ESMTPSA id x5sm2854661lbx.8.2013.06.15.13.38.21 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 15 Jun 2013 13:38:22 -0700 (PDT) From: Linus Walleij To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Linus Walleij Subject: [PATCH v2] i2c: nomadik: allocate adapter number dynamically Date: Sat, 15 Jun 2013 22:38:14 +0200 Message-Id: <1371328694-2073-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.1.4 X-Gm-Message-State: ALoCoQly0bxzrtq8RtD0D6tf1HihKeP5PbjfBCBHsCOf3Z+owJNQEh97olEsGHAik/ngnWy7pulf Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The Nomadik I2C was using a local atomic counter to number the I2C adapters. This does not work on configurations where you also add, say a GPIO bit-banged adapter to the system. They will start to conflict about being adapter 0. There is no reason to use the numbered adapter function, and the semantic effect on systems with only Nomadik I2C blocks will be none - instead of increasing the number atomically in the driver itself, it is done in the I2C core. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the default assignment if -1 to adap->nt as we're now using i2c_add_adapter(). --- drivers/i2c/busses/i2c-nomadik.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 9f1423a..063e726 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -981,8 +980,6 @@ static void nmk_i2c_of_probe(struct device_node *np, pdata->sm = I2C_FREQ_MODE_FAST; } -static atomic_t adapter_id = ATOMIC_INIT(0); - static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) { int ret = 0; @@ -1095,10 +1092,8 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; adap->algo = &nmk_i2c_algo; adap->timeout = msecs_to_jiffies(pdata->timeout); - adap->nr = atomic_read(&adapter_id); snprintf(adap->name, sizeof(adap->name), - "Nomadik I2C%d at %pR", adap->nr, &adev->res); - atomic_inc(&adapter_id); + "Nomadik I2C at %pR", &adev->res); /* fetch the controller configuration from machine */ dev->cfg.clk_freq = pdata->clk_freq; @@ -1113,7 +1108,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) "initialize %s on virtual base %p\n", adap->name, dev->virtbase); - ret = i2c_add_numbered_adapter(adap); + ret = i2c_add_adapter(adap); if (ret) { dev_err(&adev->dev, "failed to add adapter\n"); goto err_add_adap;