From patchwork Fri Nov 24 09:30:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 119561 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1952258qgn; Fri, 24 Nov 2017 01:30:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMa1T/RcmTVlk/BE7a/32fKO9Cc3O9UEhXJu7hdYu06Sni19iVlOOPZeHT2gwK76E0tXRRV8 X-Received: by 10.84.169.67 with SMTP id g61mr4289933plb.152.1511515855704; Fri, 24 Nov 2017 01:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511515855; cv=none; d=google.com; s=arc-20160816; b=doMYXtJptFgLiqUFjVxuEqkYdR4tng9A9izIi2VSAD5hF+2Y9uEUTi3jPUgrfqDEiA OKvSXc5zuo9LUtlQwzQLioP3W4L8fGi4EMfGuEjSLL5JQ2MF2Z6Ssn6xI9pMfud2BG44 Y4b2tVnfKB/FMJnsIsMMkh4nEvOZQYiQiWCApYz9Mc4INWl7aBhvKjfpqXezALcuSapD qMRwjvfF8kLz9VKEjVqgbQTPMEUp0E8+oAMMvUfU+LFmE4UUxkR4u+rTirxkNeNAJr6d 09afQgu3G5se9OMpej+DZgbcnJYVmHoOzXbOksNhm5r+WOt/tEYgUYl3bMhVxAIiGXEL eXdQ== 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:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=amoPk+PEV3kDbsBtrtoL3Bs114v7bFQdlKYw1kTedcA=; b=CPNzt3vOdi0ZP4sTAOwJSKG4CkaPdY53228YVXiCtirrt27HJM/i+lFvHSJJnOHKMr R5ybynESp2+VrmW0ouMlrw4BWlNyb3aasGx7O1usb/Q+5Ca8P7cxRD5+lUG+SkA/yfz5 4kxczAQkJX2p7to5ZDlwEoLPLH/+ryjiBSure2QNiEjuGU0Vz1sTkjrpxRhnKxnhkyRW KCAvtLUIckAvJ3Ydg0xtPNtn6NU6jtpNMBsFthoQhehhrm0sBRCnnrPjGKZek+RtzCMV 5+mZEQlLxSvTaWxO5acmw8A8l2L1dV6z+F52IvOrb1C9cejkMTErygWvZoXdCyQQCE4C lSTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g3JjEjF5; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (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 u86si19793425pfg.173.2017.11.24.01.30.55 for ; Fri, 24 Nov 2017 01:30:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g3JjEjF5; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbdKXJay (ORCPT ); Fri, 24 Nov 2017 04:30:54 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:39677 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752688AbdKXJax (ORCPT ); Fri, 24 Nov 2017 04:30:53 -0500 Received: by mail-lf0-f67.google.com with SMTP id x76so20102146lfb.6 for ; Fri, 24 Nov 2017 01:30:53 -0800 (PST) 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; bh=BLM/E4znKAlNdOQWjqTuitwFLoge9b3S7NgfeG+1l1o=; b=g3JjEjF5VodimWnRUUjFMJLLHGDkrrUbmPY67nbLtrxI1uwkHg72c1xBEsUBXLkVyI WQAAGgdoda6bIINH3MRh1cjwVgveTqSk2HULZ7uS4ADSrA0EizeOxhm8c5V9daF8TUZs aXVzgU9Fvglu4tSkygvc45j0mUdIZ6yJngjRI= 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; bh=BLM/E4znKAlNdOQWjqTuitwFLoge9b3S7NgfeG+1l1o=; b=OI9mQ2t9ryU4jiaIz367axfi6Dbt7jwkXqJ6c32bYVK9BbPj0cggD3y+EMVlBl92on sM5acgBCXD9EHsUhiY1zV2ysSouYDdCrMScGwPIicosNP6XLgcVExnmB8djoHnFmUmZB jyuh2K/2NOAlvSHQ5vKtwbf1u2A+TCS+O5ZWlKhNFIL6c/+ZUhEkuvmb42yPv3k9bGQY zulVHSnDA8tljvmMqFNK9dK6VjIGq9KlPyOU9tZ0NxrLwSm+vZtnChtoxMkk5Z9vRIj4 L06GwWWwIf5vPOC0J3zFkLlZMexS3zwt3zmgJBU5UdBvVf5Hqr6xgvg1olTITgmvjdEg X3wQ== X-Gm-Message-State: AJaThX66CwS8Sorfq4p9gFEJOAlRNVOfWXdgNDbmWvs1AzGPGJwqxYHh zj3+xZ1m7eRTcoHz4PYqFFmmgw== X-Received: by 10.46.91.75 with SMTP id p72mr10456843ljb.95.1511515852513; Fri, 24 Nov 2017 01:30:52 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm4476608ljx.58.2017.11.24.01.30.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Nov 2017 01:30:51 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 2/5] gpio: pca953x: Name the gpiochip after the I2C address Date: Fri, 24 Nov 2017 10:30:42 +0100 Message-Id: <20171124093045.5961-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124093045.5961-1-linus.walleij@linaro.org> References: <20171124093045.5961-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Just putting the name of the I2C device as name for the GPIO chip (label) is ambigous, and makes it hard for us to use GPIO descriptor tables on systems such as DaVinci DA850EVM which has two chips but on I2C address 0x20 and 0x21. Instead, append "-XX" to the GPIOchip name using the I2C address so we get a unique chip name that can be used in descriptor tables, such as "tca6416-20" and "tca6416-21" on the DaVinci DA850EVM. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pca953x.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index babb7bd2ba59..bab09f1a6bc9 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -413,10 +413,17 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc, mutex_unlock(&chip->i2c_lock); } -static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) +static int pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) { + struct i2c_client *client = chip->client; struct gpio_chip *gc; + static char *chipname; + /* Gives a chip name from the chip name and I2C address */ + chipname = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%02x", + client->name, client->addr); + if (!chipname) + return -ENOMEM; gc = &chip->gpio_chip; gc->direction_input = pca953x_gpio_direction_input; @@ -429,10 +436,12 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) gc->base = chip->gpio_start; gc->ngpio = gpios; - gc->label = chip->client->name; + gc->label = chipname; gc->parent = &chip->client->dev; gc->owner = THIS_MODULE; gc->names = chip->names; + + return 0; } #ifdef CONFIG_GPIO_PCA953X_IRQ @@ -848,7 +857,9 @@ static int pca953x_probe(struct i2c_client *client, /* initialize cached registers from their original values. * we can't share this chip with another i2c master. */ - pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK); + ret = pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK); + if (ret) + goto err_exit; if (chip->gpio_chip.ngpio <= 8) { chip->write_regs = pca953x_write_regs_8;